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
|
@@ -574,11 +574,13 @@ export class DateFieldInputState {
|
|
|
574
574
|
opts;
|
|
575
575
|
root;
|
|
576
576
|
domContext;
|
|
577
|
+
attachment;
|
|
577
578
|
constructor(opts, root) {
|
|
578
579
|
this.opts = opts;
|
|
579
580
|
this.root = root;
|
|
580
581
|
this.domContext = new DOMContext(opts.ref);
|
|
581
582
|
this.root.domContext = this.domContext;
|
|
583
|
+
this.attachment = attachRef(opts.ref, (v) => this.root.setFieldNode(v));
|
|
582
584
|
watch(() => this.opts.name.current, (v) => {
|
|
583
585
|
this.root.setName(v);
|
|
584
586
|
});
|
|
@@ -600,7 +602,7 @@ export class DateFieldInputState {
|
|
|
600
602
|
"data-invalid": this.root.isInvalid ? "" : undefined,
|
|
601
603
|
"data-disabled": getDataDisabled(this.root.disabled.current),
|
|
602
604
|
[dateFieldAttrs.input]: "",
|
|
603
|
-
...
|
|
605
|
+
...this.attachment,
|
|
604
606
|
}));
|
|
605
607
|
}
|
|
606
608
|
export class DateFieldHiddenInputState {
|
|
@@ -627,10 +629,12 @@ export class DateFieldLabelState {
|
|
|
627
629
|
}
|
|
628
630
|
opts;
|
|
629
631
|
root;
|
|
632
|
+
attachment;
|
|
630
633
|
constructor(opts, root) {
|
|
631
634
|
this.opts = opts;
|
|
632
635
|
this.root = root;
|
|
633
636
|
this.onclick = this.onclick.bind(this);
|
|
637
|
+
this.attachment = attachRef(opts.ref, (v) => this.root.setLabelNode(v));
|
|
634
638
|
}
|
|
635
639
|
onclick(_) {
|
|
636
640
|
if (this.root.disabled.current)
|
|
@@ -646,7 +650,7 @@ export class DateFieldLabelState {
|
|
|
646
650
|
"data-disabled": getDataDisabled(this.root.disabled.current),
|
|
647
651
|
[dateFieldAttrs.label]: "",
|
|
648
652
|
onclick: this.onclick,
|
|
649
|
-
...
|
|
653
|
+
...this.attachment,
|
|
650
654
|
}));
|
|
651
655
|
}
|
|
652
656
|
// Base class for numeric segments
|
|
@@ -656,6 +660,7 @@ class BaseNumericSegmentState {
|
|
|
656
660
|
announcer;
|
|
657
661
|
part;
|
|
658
662
|
config;
|
|
663
|
+
attachment;
|
|
659
664
|
constructor(opts, root, part, config) {
|
|
660
665
|
this.opts = opts;
|
|
661
666
|
this.root = root;
|
|
@@ -664,6 +669,7 @@ class BaseNumericSegmentState {
|
|
|
664
669
|
this.announcer = root.announcer;
|
|
665
670
|
this.onkeydown = this.onkeydown.bind(this);
|
|
666
671
|
this.onfocusout = this.onfocusout.bind(this);
|
|
672
|
+
this.attachment = attachRef(opts.ref);
|
|
667
673
|
}
|
|
668
674
|
#getMax() {
|
|
669
675
|
return typeof this.config.max === "function" ? this.config.max(this.root) : this.config.max;
|
|
@@ -908,7 +914,7 @@ class BaseNumericSegmentState {
|
|
|
908
914
|
onfocusout: this.onfocusout,
|
|
909
915
|
onclick: this.root.handleSegmentClick,
|
|
910
916
|
...this.root.getBaseSegmentAttrs(this.part, this.opts.id.current),
|
|
911
|
-
...
|
|
917
|
+
...this.attachment,
|
|
912
918
|
};
|
|
913
919
|
});
|
|
914
920
|
}
|
|
@@ -1085,12 +1091,14 @@ export class DateFieldDayPeriodSegmentState {
|
|
|
1085
1091
|
}
|
|
1086
1092
|
opts;
|
|
1087
1093
|
root;
|
|
1094
|
+
attachment;
|
|
1088
1095
|
#announcer;
|
|
1089
1096
|
constructor(opts, root) {
|
|
1090
1097
|
this.opts = opts;
|
|
1091
1098
|
this.root = root;
|
|
1092
1099
|
this.#announcer = this.root.announcer;
|
|
1093
1100
|
this.onkeydown = this.onkeydown.bind(this);
|
|
1101
|
+
this.attachment = attachRef(opts.ref, (v) => (this.root.dayPeriodNode = v));
|
|
1094
1102
|
}
|
|
1095
1103
|
onkeydown(e) {
|
|
1096
1104
|
if (e.ctrlKey || e.metaKey || this.root.disabled.current)
|
|
@@ -1151,7 +1159,7 @@ export class DateFieldDayPeriodSegmentState {
|
|
|
1151
1159
|
onkeydown: this.onkeydown,
|
|
1152
1160
|
onclick: this.root.handleSegmentClick,
|
|
1153
1161
|
...this.root.getBaseSegmentAttrs("dayPeriod", this.opts.id.current),
|
|
1154
|
-
...
|
|
1162
|
+
...this.attachment,
|
|
1155
1163
|
};
|
|
1156
1164
|
});
|
|
1157
1165
|
}
|
|
@@ -1161,15 +1169,17 @@ export class DateFieldLiteralSegmentState {
|
|
|
1161
1169
|
}
|
|
1162
1170
|
opts;
|
|
1163
1171
|
root;
|
|
1172
|
+
attachment;
|
|
1164
1173
|
constructor(opts, root) {
|
|
1165
1174
|
this.opts = opts;
|
|
1166
1175
|
this.root = root;
|
|
1176
|
+
this.attachment = attachRef(opts.ref);
|
|
1167
1177
|
}
|
|
1168
1178
|
props = $derived.by(() => ({
|
|
1169
1179
|
id: this.opts.id.current,
|
|
1170
1180
|
"aria-hidden": getAriaHidden(true),
|
|
1171
1181
|
...this.root.getBaseSegmentAttrs("literal", this.opts.id.current),
|
|
1172
|
-
...
|
|
1182
|
+
...this.attachment,
|
|
1173
1183
|
}));
|
|
1174
1184
|
}
|
|
1175
1185
|
export class DateFieldTimeZoneSegmentState {
|
|
@@ -1178,10 +1188,12 @@ export class DateFieldTimeZoneSegmentState {
|
|
|
1178
1188
|
}
|
|
1179
1189
|
opts;
|
|
1180
1190
|
root;
|
|
1191
|
+
attachment;
|
|
1181
1192
|
constructor(opts, root) {
|
|
1182
1193
|
this.opts = opts;
|
|
1183
1194
|
this.root = root;
|
|
1184
1195
|
this.onkeydown = this.onkeydown.bind(this);
|
|
1196
|
+
this.attachment = attachRef(opts.ref);
|
|
1185
1197
|
}
|
|
1186
1198
|
onkeydown(e) {
|
|
1187
1199
|
if (e.key !== kbd.TAB)
|
|
@@ -1202,7 +1214,7 @@ export class DateFieldTimeZoneSegmentState {
|
|
|
1202
1214
|
onkeydown: this.onkeydown,
|
|
1203
1215
|
...this.root.getBaseSegmentAttrs("timeZoneName", this.opts.id.current),
|
|
1204
1216
|
"data-readonly": getDataReadonly(true),
|
|
1205
|
-
...
|
|
1217
|
+
...this.attachment,
|
|
1206
1218
|
}));
|
|
1207
1219
|
}
|
|
1208
1220
|
export class DateFieldSegmentState {
|
|
@@ -3,7 +3,7 @@ import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "
|
|
|
3
3
|
import { Context } from "runed";
|
|
4
4
|
import { DateFieldInputState, DateFieldRootState } from "../date-field/date-field.svelte.js";
|
|
5
5
|
import type { DateOnInvalid, DateRange, DateRangeValidator, SegmentPart } from "../../shared/index.js";
|
|
6
|
-
import type { WithRefOpts } from "../../internal/types.js";
|
|
6
|
+
import type { RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
7
7
|
import type { Granularity } from "../../shared/date/types.js";
|
|
8
8
|
import { type Formatter } from "../../internal/date-time/formatter.js";
|
|
9
9
|
export declare const dateRangeFieldAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["root", "label"]>;
|
|
@@ -44,6 +44,7 @@ export declare class DateRangeFieldRootState {
|
|
|
44
44
|
readonly endValueComplete: boolean;
|
|
45
45
|
readonly rangeComplete: boolean;
|
|
46
46
|
domContext: DOMContext;
|
|
47
|
+
readonly attachment: RefAttachment;
|
|
47
48
|
constructor(opts: DateRangeFieldRootStateOpts);
|
|
48
49
|
readonly validationStatus: false | {
|
|
49
50
|
readonly reason: "custom";
|
|
@@ -69,6 +70,7 @@ export declare class DateRangeFieldLabelState {
|
|
|
69
70
|
static create(opts: DateRangeFieldLabelStateOpts): DateRangeFieldLabelState;
|
|
70
71
|
readonly opts: DateRangeFieldLabelStateOpts;
|
|
71
72
|
readonly root: DateRangeFieldRootState;
|
|
73
|
+
readonly attachment: RefAttachment;
|
|
72
74
|
constructor(opts: DateRangeFieldLabelStateOpts, root: DateRangeFieldRootState);
|
|
73
75
|
readonly props: {
|
|
74
76
|
readonly id: string;
|
|
@@ -28,6 +28,7 @@ export class DateRangeFieldRootState {
|
|
|
28
28
|
endValueComplete = $derived.by(() => this.opts.endValue.current !== undefined);
|
|
29
29
|
rangeComplete = $derived(this.startValueComplete && this.endValueComplete);
|
|
30
30
|
domContext;
|
|
31
|
+
attachment;
|
|
31
32
|
constructor(opts) {
|
|
32
33
|
this.opts = opts;
|
|
33
34
|
this.formatter = createFormatter({
|
|
@@ -36,6 +37,7 @@ export class DateRangeFieldRootState {
|
|
|
36
37
|
yearFormat: box.with(() => "numeric"),
|
|
37
38
|
});
|
|
38
39
|
this.domContext = new DOMContext(this.opts.ref);
|
|
40
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.fieldNode = v));
|
|
39
41
|
onDestroyEffect(() => {
|
|
40
42
|
removeDescriptionElement(this.descriptionId, this.domContext.getDocument());
|
|
41
43
|
});
|
|
@@ -142,7 +144,7 @@ export class DateRangeFieldRootState {
|
|
|
142
144
|
role: "group",
|
|
143
145
|
[dateRangeFieldAttrs.root]: "",
|
|
144
146
|
"data-invalid": getDataInvalid(this.isInvalid),
|
|
145
|
-
...
|
|
147
|
+
...this.attachment,
|
|
146
148
|
}));
|
|
147
149
|
}
|
|
148
150
|
export class DateRangeFieldLabelState {
|
|
@@ -151,9 +153,11 @@ export class DateRangeFieldLabelState {
|
|
|
151
153
|
}
|
|
152
154
|
opts;
|
|
153
155
|
root;
|
|
156
|
+
attachment;
|
|
154
157
|
constructor(opts, root) {
|
|
155
158
|
this.opts = opts;
|
|
156
159
|
this.root = root;
|
|
160
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.root.labelNode = v));
|
|
157
161
|
}
|
|
158
162
|
#onclick = () => {
|
|
159
163
|
if (this.root.opts.disabled.current)
|
|
@@ -169,7 +173,7 @@ export class DateRangeFieldLabelState {
|
|
|
169
173
|
"data-disabled": getDataDisabled(this.root.opts.disabled.current),
|
|
170
174
|
[dateRangeFieldAttrs.label]: "",
|
|
171
175
|
onclick: this.#onclick,
|
|
172
|
-
...
|
|
176
|
+
...this.attachment,
|
|
173
177
|
}));
|
|
174
178
|
}
|
|
175
179
|
export class DateRangeFieldInputState {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
2
|
-
import type { BitsKeyboardEvent, BitsMouseEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
|
|
2
|
+
import type { BitsKeyboardEvent, BitsMouseEvent, OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
3
3
|
type DialogVariant = "alert-dialog" | "dialog";
|
|
4
4
|
declare const dialogAttrs: import("../../internal/attrs.js").CreateBitsAttrsReturn<readonly ["content", "trigger", "overlay", "title", "description", "close", "cancel", "action"]>;
|
|
5
5
|
interface DialogRootStateOpts extends WritableBoxedValues<{
|
|
@@ -36,6 +36,7 @@ export declare class DialogTriggerState {
|
|
|
36
36
|
static create(opts: DialogTriggerStateOpts): DialogTriggerState;
|
|
37
37
|
readonly opts: DialogTriggerStateOpts;
|
|
38
38
|
readonly root: DialogRootState;
|
|
39
|
+
readonly attachment: RefAttachment;
|
|
39
40
|
constructor(opts: DialogTriggerStateOpts, root: DialogRootState);
|
|
40
41
|
onclick(e: BitsMouseEvent): void;
|
|
41
42
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
@@ -59,6 +60,7 @@ export declare class DialogCloseState {
|
|
|
59
60
|
static create(opts: DialogCloseStateOpts): DialogCloseState;
|
|
60
61
|
readonly opts: DialogCloseStateOpts;
|
|
61
62
|
readonly root: DialogRootState;
|
|
63
|
+
readonly attachment: RefAttachment;
|
|
62
64
|
constructor(opts: DialogCloseStateOpts, root: DialogRootState);
|
|
63
65
|
onclick(e: BitsMouseEvent): void;
|
|
64
66
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
@@ -77,6 +79,7 @@ export declare class DialogActionState {
|
|
|
77
79
|
static create(opts: DialogActionStateOpts): DialogActionState;
|
|
78
80
|
readonly opts: DialogActionStateOpts;
|
|
79
81
|
readonly root: DialogRootState;
|
|
82
|
+
readonly attachment: RefAttachment;
|
|
80
83
|
constructor(opts: DialogActionStateOpts, root: DialogRootState);
|
|
81
84
|
readonly props: {
|
|
82
85
|
readonly "data-state": "open" | "closed";
|
|
@@ -91,6 +94,7 @@ export declare class DialogTitleState {
|
|
|
91
94
|
static create(opts: DialogTitleStateOpts): DialogTitleState;
|
|
92
95
|
readonly opts: DialogTitleStateOpts;
|
|
93
96
|
readonly root: DialogRootState;
|
|
97
|
+
readonly attachment: RefAttachment;
|
|
94
98
|
constructor(opts: DialogTitleStateOpts, root: DialogRootState);
|
|
95
99
|
readonly props: {
|
|
96
100
|
readonly "data-state": "open" | "closed";
|
|
@@ -105,6 +109,7 @@ export declare class DialogDescriptionState {
|
|
|
105
109
|
static create(opts: DialogDescriptionStateOpts): DialogDescriptionState;
|
|
106
110
|
readonly opts: DialogDescriptionStateOpts;
|
|
107
111
|
readonly root: DialogRootState;
|
|
112
|
+
readonly attachment: RefAttachment;
|
|
108
113
|
constructor(opts: DialogDescriptionStateOpts, root: DialogRootState);
|
|
109
114
|
readonly props: {
|
|
110
115
|
readonly "data-state": "open" | "closed";
|
|
@@ -117,6 +122,7 @@ export declare class DialogContentState {
|
|
|
117
122
|
static create(opts: DialogContentStateOpts): DialogContentState;
|
|
118
123
|
readonly opts: DialogContentStateOpts;
|
|
119
124
|
readonly root: DialogRootState;
|
|
125
|
+
readonly attachment: RefAttachment;
|
|
120
126
|
constructor(opts: DialogContentStateOpts, root: DialogRootState);
|
|
121
127
|
readonly snippetProps: {
|
|
122
128
|
open: boolean;
|
|
@@ -141,6 +147,7 @@ export declare class DialogOverlayState {
|
|
|
141
147
|
static create(opts: DialogOverlayStateOpts): DialogOverlayState;
|
|
142
148
|
readonly opts: DialogOverlayStateOpts;
|
|
143
149
|
readonly root: DialogRootState;
|
|
150
|
+
readonly attachment: RefAttachment;
|
|
144
151
|
constructor(opts: DialogOverlayStateOpts, root: DialogRootState);
|
|
145
152
|
readonly snippetProps: {
|
|
146
153
|
open: boolean;
|
|
@@ -161,6 +168,7 @@ export declare class AlertDialogCancelState {
|
|
|
161
168
|
static create(opts: AlertDialogCancelStateOpts): AlertDialogCancelState;
|
|
162
169
|
readonly opts: AlertDialogCancelStateOpts;
|
|
163
170
|
readonly root: DialogRootState;
|
|
171
|
+
readonly attachment: RefAttachment;
|
|
164
172
|
constructor(opts: AlertDialogCancelStateOpts, root: DialogRootState);
|
|
165
173
|
onclick(e: BitsMouseEvent): void;
|
|
166
174
|
onkeydown(e: BitsKeyboardEvent): void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { attachRef, box, } from "svelte-toolbelt";
|
|
2
|
-
import { Context } from "runed";
|
|
2
|
+
import { Context, watch } from "runed";
|
|
3
3
|
import { createBitsAttrs, getAriaExpanded, getDataOpenClosed } from "../../internal/attrs.js";
|
|
4
4
|
import { kbd } from "../../internal/kbd.js";
|
|
5
|
-
import { untrack } from "svelte";
|
|
6
5
|
import { OpenChangeComplete } from "../../internal/open-change-complete.js";
|
|
7
6
|
const dialogAttrs = createBitsAttrs({
|
|
8
7
|
component: "dialog",
|
|
@@ -58,9 +57,14 @@ export class DialogTriggerState {
|
|
|
58
57
|
}
|
|
59
58
|
opts;
|
|
60
59
|
root;
|
|
60
|
+
attachment;
|
|
61
61
|
constructor(opts, root) {
|
|
62
62
|
this.opts = opts;
|
|
63
63
|
this.root = root;
|
|
64
|
+
this.attachment = attachRef(this.opts.ref, (v) => {
|
|
65
|
+
this.root.triggerNode = v;
|
|
66
|
+
this.root.triggerId = v?.id;
|
|
67
|
+
});
|
|
64
68
|
this.onclick = this.onclick.bind(this);
|
|
65
69
|
this.onkeydown = this.onkeydown.bind(this);
|
|
66
70
|
}
|
|
@@ -89,10 +93,7 @@ export class DialogTriggerState {
|
|
|
89
93
|
onclick: this.onclick,
|
|
90
94
|
disabled: this.opts.disabled.current ? true : undefined,
|
|
91
95
|
...this.root.sharedProps,
|
|
92
|
-
...
|
|
93
|
-
this.root.triggerNode = v;
|
|
94
|
-
this.root.triggerId = v?.id;
|
|
95
|
-
})),
|
|
96
|
+
...this.attachment,
|
|
96
97
|
}));
|
|
97
98
|
}
|
|
98
99
|
export class DialogCloseState {
|
|
@@ -101,9 +102,11 @@ export class DialogCloseState {
|
|
|
101
102
|
}
|
|
102
103
|
opts;
|
|
103
104
|
root;
|
|
105
|
+
attachment;
|
|
104
106
|
constructor(opts, root) {
|
|
105
107
|
this.opts = opts;
|
|
106
108
|
this.root = root;
|
|
109
|
+
this.attachment = attachRef(this.opts.ref);
|
|
107
110
|
this.onclick = this.onclick.bind(this);
|
|
108
111
|
this.onkeydown = this.onkeydown.bind(this);
|
|
109
112
|
}
|
|
@@ -130,7 +133,7 @@ export class DialogCloseState {
|
|
|
130
133
|
disabled: this.opts.disabled.current ? true : undefined,
|
|
131
134
|
tabindex: 0,
|
|
132
135
|
...this.root.sharedProps,
|
|
133
|
-
...
|
|
136
|
+
...this.attachment,
|
|
134
137
|
}));
|
|
135
138
|
}
|
|
136
139
|
export class DialogActionState {
|
|
@@ -139,15 +142,17 @@ export class DialogActionState {
|
|
|
139
142
|
}
|
|
140
143
|
opts;
|
|
141
144
|
root;
|
|
145
|
+
attachment;
|
|
142
146
|
constructor(opts, root) {
|
|
143
147
|
this.opts = opts;
|
|
144
148
|
this.root = root;
|
|
149
|
+
this.attachment = attachRef(this.opts.ref);
|
|
145
150
|
}
|
|
146
151
|
props = $derived.by(() => ({
|
|
147
152
|
id: this.opts.id.current,
|
|
148
153
|
[this.root.getBitsAttr("action")]: "",
|
|
149
154
|
...this.root.sharedProps,
|
|
150
|
-
...
|
|
155
|
+
...this.attachment,
|
|
151
156
|
}));
|
|
152
157
|
}
|
|
153
158
|
export class DialogTitleState {
|
|
@@ -156,9 +161,15 @@ export class DialogTitleState {
|
|
|
156
161
|
}
|
|
157
162
|
opts;
|
|
158
163
|
root;
|
|
164
|
+
attachment;
|
|
159
165
|
constructor(opts, root) {
|
|
160
166
|
this.opts = opts;
|
|
161
167
|
this.root = root;
|
|
168
|
+
this.root.titleId = this.opts.id.current;
|
|
169
|
+
this.attachment = attachRef(this.opts.ref);
|
|
170
|
+
watch.pre(() => this.opts.id.current, (id) => {
|
|
171
|
+
this.root.titleId = id;
|
|
172
|
+
});
|
|
162
173
|
}
|
|
163
174
|
props = $derived.by(() => ({
|
|
164
175
|
id: this.opts.id.current,
|
|
@@ -166,7 +177,7 @@ export class DialogTitleState {
|
|
|
166
177
|
"aria-level": this.opts.level.current,
|
|
167
178
|
[this.root.getBitsAttr("title")]: "",
|
|
168
179
|
...this.root.sharedProps,
|
|
169
|
-
...
|
|
180
|
+
...this.attachment,
|
|
170
181
|
}));
|
|
171
182
|
}
|
|
172
183
|
export class DialogDescriptionState {
|
|
@@ -175,18 +186,23 @@ export class DialogDescriptionState {
|
|
|
175
186
|
}
|
|
176
187
|
opts;
|
|
177
188
|
root;
|
|
189
|
+
attachment;
|
|
178
190
|
constructor(opts, root) {
|
|
179
191
|
this.opts = opts;
|
|
180
192
|
this.root = root;
|
|
193
|
+
this.root.descriptionId = this.opts.id.current;
|
|
194
|
+
this.attachment = attachRef(this.opts.ref, (v) => {
|
|
195
|
+
this.root.descriptionNode = v;
|
|
196
|
+
});
|
|
197
|
+
watch.pre(() => this.opts.id.current, (id) => {
|
|
198
|
+
this.root.descriptionId = id;
|
|
199
|
+
});
|
|
181
200
|
}
|
|
182
201
|
props = $derived.by(() => ({
|
|
183
202
|
id: this.opts.id.current,
|
|
184
203
|
[this.root.getBitsAttr("description")]: "",
|
|
185
204
|
...this.root.sharedProps,
|
|
186
|
-
...
|
|
187
|
-
this.root.descriptionNode = v;
|
|
188
|
-
this.root.descriptionId = v?.id;
|
|
189
|
-
}),
|
|
205
|
+
...this.attachment,
|
|
190
206
|
}));
|
|
191
207
|
}
|
|
192
208
|
export class DialogContentState {
|
|
@@ -195,9 +211,14 @@ export class DialogContentState {
|
|
|
195
211
|
}
|
|
196
212
|
opts;
|
|
197
213
|
root;
|
|
214
|
+
attachment;
|
|
198
215
|
constructor(opts, root) {
|
|
199
216
|
this.opts = opts;
|
|
200
217
|
this.root = root;
|
|
218
|
+
this.attachment = attachRef(this.opts.ref, (v) => {
|
|
219
|
+
this.root.contentNode = v;
|
|
220
|
+
this.root.contentId = v?.id;
|
|
221
|
+
});
|
|
201
222
|
}
|
|
202
223
|
snippetProps = $derived.by(() => ({ open: this.root.opts.open.current }));
|
|
203
224
|
props = $derived.by(() => ({
|
|
@@ -213,10 +234,7 @@ export class DialogContentState {
|
|
|
213
234
|
},
|
|
214
235
|
tabindex: this.root.opts.variant.current === "alert-dialog" ? -1 : undefined,
|
|
215
236
|
...this.root.sharedProps,
|
|
216
|
-
...
|
|
217
|
-
this.root.contentNode = v;
|
|
218
|
-
this.root.contentId = v?.id;
|
|
219
|
-
}),
|
|
237
|
+
...this.attachment,
|
|
220
238
|
}));
|
|
221
239
|
}
|
|
222
240
|
export class DialogOverlayState {
|
|
@@ -225,9 +243,11 @@ export class DialogOverlayState {
|
|
|
225
243
|
}
|
|
226
244
|
opts;
|
|
227
245
|
root;
|
|
246
|
+
attachment;
|
|
228
247
|
constructor(opts, root) {
|
|
229
248
|
this.opts = opts;
|
|
230
249
|
this.root = root;
|
|
250
|
+
this.attachment = attachRef(this.opts.ref);
|
|
231
251
|
}
|
|
232
252
|
snippetProps = $derived.by(() => ({ open: this.root.opts.open.current }));
|
|
233
253
|
props = $derived.by(() => ({
|
|
@@ -237,7 +257,7 @@ export class DialogOverlayState {
|
|
|
237
257
|
pointerEvents: "auto",
|
|
238
258
|
},
|
|
239
259
|
...this.root.sharedProps,
|
|
240
|
-
...
|
|
260
|
+
...this.attachment,
|
|
241
261
|
}));
|
|
242
262
|
}
|
|
243
263
|
export class AlertDialogCancelState {
|
|
@@ -246,9 +266,11 @@ export class AlertDialogCancelState {
|
|
|
246
266
|
}
|
|
247
267
|
opts;
|
|
248
268
|
root;
|
|
269
|
+
attachment;
|
|
249
270
|
constructor(opts, root) {
|
|
250
271
|
this.opts = opts;
|
|
251
272
|
this.root = root;
|
|
273
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.root.cancelNode = v));
|
|
252
274
|
this.onclick = this.onclick.bind(this);
|
|
253
275
|
this.onkeydown = this.onkeydown.bind(this);
|
|
254
276
|
}
|
|
@@ -274,6 +296,6 @@ export class AlertDialogCancelState {
|
|
|
274
296
|
onkeydown: this.onkeydown,
|
|
275
297
|
tabindex: 0,
|
|
276
298
|
...this.root.sharedProps,
|
|
277
|
-
...
|
|
299
|
+
...this.attachment,
|
|
278
300
|
}));
|
|
279
301
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
|
|
1
|
+
import type { BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
2
2
|
interface LabelRootStateOpts extends WithRefOpts {
|
|
3
3
|
}
|
|
4
4
|
export declare class LabelRootState {
|
|
5
5
|
static create(opts: LabelRootStateOpts): LabelRootState;
|
|
6
6
|
readonly opts: LabelRootStateOpts;
|
|
7
|
+
readonly attachment: RefAttachment;
|
|
7
8
|
constructor(opts: LabelRootStateOpts);
|
|
8
9
|
onmousedown(e: BitsMouseEvent): void;
|
|
9
10
|
readonly props: {
|
|
@@ -9,8 +9,10 @@ export class LabelRootState {
|
|
|
9
9
|
return new LabelRootState(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
|
this.onmousedown = this.onmousedown.bind(this);
|
|
15
17
|
}
|
|
16
18
|
onmousedown(e) {
|
|
@@ -21,6 +23,6 @@ export class LabelRootState {
|
|
|
21
23
|
id: this.opts.id.current,
|
|
22
24
|
[labelAttrs.root]: "",
|
|
23
25
|
onmousedown: this.onmousedown,
|
|
24
|
-
...
|
|
26
|
+
...this.attachment,
|
|
25
27
|
}));
|
|
26
28
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
2
|
-
import type { BitsFocusEvent, BitsPointerEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
|
|
2
|
+
import type { BitsFocusEvent, BitsPointerEvent, OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
3
3
|
interface LinkPreviewRootStateOpts extends WritableBoxedValues<{
|
|
4
4
|
open: boolean;
|
|
5
5
|
}>, ReadableBoxedValues<{
|
|
@@ -32,6 +32,7 @@ export declare class LinkPreviewTriggerState {
|
|
|
32
32
|
static create(opts: LinkPreviewTriggerStateOpts): LinkPreviewTriggerState;
|
|
33
33
|
readonly opts: LinkPreviewTriggerStateOpts;
|
|
34
34
|
readonly root: LinkPreviewRootState;
|
|
35
|
+
readonly attachment: RefAttachment;
|
|
35
36
|
constructor(opts: LinkPreviewTriggerStateOpts, root: LinkPreviewRootState);
|
|
36
37
|
onpointerenter(e: BitsPointerEvent): void;
|
|
37
38
|
onpointerleave(e: BitsPointerEvent): void;
|
|
@@ -59,6 +60,7 @@ export declare class LinkPreviewContentState {
|
|
|
59
60
|
static create(opts: LinkPreviewContentStateOpts): LinkPreviewContentState;
|
|
60
61
|
readonly opts: LinkPreviewContentStateOpts;
|
|
61
62
|
readonly root: LinkPreviewRootState;
|
|
63
|
+
readonly attachment: RefAttachment;
|
|
62
64
|
constructor(opts: LinkPreviewContentStateOpts, root: LinkPreviewRootState);
|
|
63
65
|
onpointerdown(e: BitsPointerEvent): void;
|
|
64
66
|
onpointerenter(e: BitsPointerEvent): void;
|
|
@@ -107,9 +107,11 @@ export class LinkPreviewTriggerState {
|
|
|
107
107
|
}
|
|
108
108
|
opts;
|
|
109
109
|
root;
|
|
110
|
+
attachment;
|
|
110
111
|
constructor(opts, root) {
|
|
111
112
|
this.opts = opts;
|
|
112
113
|
this.root = root;
|
|
114
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.root.triggerNode = v));
|
|
113
115
|
this.root.domContext = new DOMContext(opts.ref);
|
|
114
116
|
this.onpointerenter = this.onpointerenter.bind(this);
|
|
115
117
|
this.onpointerleave = this.onpointerleave.bind(this);
|
|
@@ -148,7 +150,7 @@ export class LinkPreviewTriggerState {
|
|
|
148
150
|
onfocus: this.onfocus,
|
|
149
151
|
onblur: this.onblur,
|
|
150
152
|
onpointerleave: this.onpointerleave,
|
|
151
|
-
...
|
|
153
|
+
...this.attachment,
|
|
152
154
|
}));
|
|
153
155
|
}
|
|
154
156
|
export class LinkPreviewContentState {
|
|
@@ -157,9 +159,11 @@ export class LinkPreviewContentState {
|
|
|
157
159
|
}
|
|
158
160
|
opts;
|
|
159
161
|
root;
|
|
162
|
+
attachment;
|
|
160
163
|
constructor(opts, root) {
|
|
161
164
|
this.opts = opts;
|
|
162
165
|
this.root = root;
|
|
166
|
+
this.attachment = attachRef(this.opts.ref, (v) => (this.root.contentNode = v));
|
|
163
167
|
this.root.domContext = new DOMContext(opts.ref);
|
|
164
168
|
this.onpointerdown = this.onpointerdown.bind(this);
|
|
165
169
|
this.onpointerenter = this.onpointerenter.bind(this);
|
|
@@ -221,7 +225,7 @@ export class LinkPreviewContentState {
|
|
|
221
225
|
onpointerdown: this.onpointerdown,
|
|
222
226
|
onpointerenter: this.onpointerenter,
|
|
223
227
|
onfocusout: this.onfocusout,
|
|
224
|
-
...
|
|
228
|
+
...this.attachment,
|
|
225
229
|
}));
|
|
226
230
|
popperProps = {
|
|
227
231
|
onInteractOutside: this.onInteractOutside,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
2
2
|
import { Context } from "runed";
|
|
3
3
|
import { CustomEventDispatcher } from "../../internal/events.js";
|
|
4
|
-
import type { AnyFn, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, WithRefOpts } from "../../internal/types.js";
|
|
4
|
+
import type { AnyFn, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
5
5
|
import type { Direction } from "../../shared/index.js";
|
|
6
6
|
import { IsUsingKeyboard } from "../../index.js";
|
|
7
7
|
import type { KeyboardEventHandler, PointerEventHandler } from "svelte/elements";
|
|
@@ -58,6 +58,7 @@ export declare class MenuContentState {
|
|
|
58
58
|
readonly parentMenu: MenuMenuState;
|
|
59
59
|
readonly rovingFocusGroup: RovingFocusGroup;
|
|
60
60
|
readonly domContext: DOMContext;
|
|
61
|
+
readonly attachment: RefAttachment;
|
|
61
62
|
search: string;
|
|
62
63
|
mounted: boolean;
|
|
63
64
|
constructor(opts: MenuContentStateOpts, parentMenu: MenuMenuState);
|
|
@@ -99,6 +100,7 @@ declare class MenuItemSharedState {
|
|
|
99
100
|
#private;
|
|
100
101
|
readonly opts: MenuItemSharedStateOpts;
|
|
101
102
|
readonly content: MenuContentState;
|
|
103
|
+
readonly attachment: RefAttachment;
|
|
102
104
|
constructor(opts: MenuItemSharedStateOpts, content: MenuContentState);
|
|
103
105
|
onpointermove(e: BitsPointerEvent): void;
|
|
104
106
|
onpointerleave(e: BitsPointerEvent): void;
|
|
@@ -163,6 +165,7 @@ export declare class MenuSubTriggerState {
|
|
|
163
165
|
readonly item: MenuItemSharedState;
|
|
164
166
|
readonly content: MenuContentState;
|
|
165
167
|
readonly submenu: MenuMenuState;
|
|
168
|
+
readonly attachment: RefAttachment;
|
|
166
169
|
constructor(opts: MenuSubTriggerStateOpts, item: MenuItemSharedState, content: MenuContentState, submenu: MenuMenuState);
|
|
167
170
|
onpointermove(e: BitsPointerEvent): void;
|
|
168
171
|
onpointerleave(e: BitsPointerEvent): void;
|
|
@@ -236,6 +239,7 @@ export declare class MenuGroupState {
|
|
|
236
239
|
static create(opts: MenuGroupStateOpts): MenuGroupState | MenuRadioGroupState;
|
|
237
240
|
readonly opts: MenuGroupStateOpts;
|
|
238
241
|
readonly root: MenuRootState;
|
|
242
|
+
readonly attachment: RefAttachment;
|
|
239
243
|
groupHeadingId: string | undefined;
|
|
240
244
|
constructor(opts: MenuGroupStateOpts, root: MenuRootState);
|
|
241
245
|
readonly props: {
|
|
@@ -250,6 +254,7 @@ export declare class MenuGroupHeadingState {
|
|
|
250
254
|
static create(opts: MenuGroupHeadingStateOpts): MenuGroupHeadingState;
|
|
251
255
|
readonly opts: MenuGroupHeadingStateOpts;
|
|
252
256
|
readonly group: MenuGroupState | MenuRadioGroupState | MenuCheckboxGroupState;
|
|
257
|
+
readonly attachment: RefAttachment;
|
|
253
258
|
constructor(opts: MenuGroupHeadingStateOpts, group: MenuGroupState | MenuRadioGroupState | MenuCheckboxGroupState);
|
|
254
259
|
readonly props: {
|
|
255
260
|
readonly id: string;
|
|
@@ -262,6 +267,7 @@ export declare class MenuSeparatorState {
|
|
|
262
267
|
static create(opts: MenuSeparatorStateOpts): MenuSeparatorState;
|
|
263
268
|
readonly opts: MenuSeparatorStateOpts;
|
|
264
269
|
readonly root: MenuRootState;
|
|
270
|
+
readonly attachment: RefAttachment;
|
|
265
271
|
constructor(opts: MenuSeparatorStateOpts, root: MenuRootState);
|
|
266
272
|
readonly props: {
|
|
267
273
|
readonly id: string;
|
|
@@ -284,6 +290,7 @@ export declare class MenuRadioGroupState {
|
|
|
284
290
|
static create(opts: MenuRadioGroupStateOpts): MenuGroupState | MenuRadioGroupState;
|
|
285
291
|
readonly opts: MenuRadioGroupStateOpts;
|
|
286
292
|
readonly content: MenuContentState;
|
|
293
|
+
readonly attachment: RefAttachment;
|
|
287
294
|
groupHeadingId: string | null;
|
|
288
295
|
root: MenuRootState;
|
|
289
296
|
constructor(opts: MenuRadioGroupStateOpts, content: MenuContentState);
|
|
@@ -304,6 +311,7 @@ export declare class MenuRadioItemState {
|
|
|
304
311
|
readonly opts: MenuRadioItemStateOpts;
|
|
305
312
|
readonly item: MenuItemState;
|
|
306
313
|
readonly group: MenuRadioGroupState;
|
|
314
|
+
readonly attachment: RefAttachment;
|
|
307
315
|
readonly isChecked: boolean;
|
|
308
316
|
constructor(opts: MenuRadioItemStateOpts, item: MenuItemState, group: MenuRadioGroupState);
|
|
309
317
|
selectValue(): void;
|
|
@@ -336,6 +344,7 @@ export declare class DropdownMenuTriggerState {
|
|
|
336
344
|
static create(opts: DropdownMenuTriggerStateOpts): DropdownMenuTriggerState;
|
|
337
345
|
readonly opts: DropdownMenuTriggerStateOpts;
|
|
338
346
|
readonly parentMenu: MenuMenuState;
|
|
347
|
+
readonly attachment: RefAttachment;
|
|
339
348
|
constructor(opts: DropdownMenuTriggerStateOpts, parentMenu: MenuMenuState);
|
|
340
349
|
onpointerdown: PointerEventHandler<HTMLElement>;
|
|
341
350
|
onpointerup: PointerEventHandler<HTMLElement>;
|
|
@@ -362,6 +371,7 @@ export declare class ContextMenuTriggerState {
|
|
|
362
371
|
static create(opts: ContextMenuTriggerStateOpts): ContextMenuTriggerState;
|
|
363
372
|
readonly opts: ContextMenuTriggerStateOpts;
|
|
364
373
|
readonly parentMenu: MenuMenuState;
|
|
374
|
+
readonly attachment: RefAttachment;
|
|
365
375
|
virtualElement: import("svelte-toolbelt").WritableBox<{
|
|
366
376
|
getBoundingClientRect: () => DOMRect;
|
|
367
377
|
}>;
|
|
@@ -396,6 +406,7 @@ export declare class MenuCheckboxGroupState {
|
|
|
396
406
|
readonly opts: MenuCheckboxGroupStateOpts;
|
|
397
407
|
readonly content: MenuContentState;
|
|
398
408
|
readonly root: MenuRootState;
|
|
409
|
+
readonly attachment: RefAttachment;
|
|
399
410
|
groupHeadingId: string | null;
|
|
400
411
|
constructor(opts: MenuCheckboxGroupStateOpts, content: MenuContentState);
|
|
401
412
|
addValue(checkboxValue: string | undefined): void;
|