bits-ui 2.8.0 → 2.8.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.
- package/dist/bits/accordion/accordion.svelte.d.ts +6 -1
- package/dist/bits/accordion/accordion.svelte.js +15 -5
- package/dist/bits/alert-dialog/components/alert-dialog-content.svelte +6 -9
- 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/calendar/components/calendar-next-button.svelte +3 -1
- package/dist/bits/calendar/components/calendar-prev-button.svelte +3 -1
- package/dist/bits/checkbox/checkbox.svelte.d.ts +4 -1
- package/dist/bits/checkbox/checkbox.svelte.js +9 -3
- package/dist/bits/collapsible/collapsible.svelte.d.ts +4 -1
- package/dist/bits/collapsible/collapsible.svelte.js +9 -3
- package/dist/bits/command/command.svelte.d.ts +13 -1
- package/dist/bits/command/command.svelte.js +36 -12
- package/dist/bits/context-menu/components/context-menu-content.svelte +1 -1
- 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/components/dialog-content.svelte +5 -7
- package/dist/bits/dialog/dialog.svelte.d.ts +9 -1
- package/dist/bits/dialog/dialog.svelte.js +33 -18
- package/dist/bits/dropdown-menu/components/dropdown-menu-content.svelte +3 -2
- 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 +38 -26
- package/dist/bits/menubar/components/menubar-trigger.svelte +4 -3
- package/dist/bits/menubar/menubar.svelte.d.ts +4 -3
- package/dist/bits/menubar/menubar.svelte.js +9 -6
- package/dist/bits/meter/meter.svelte.d.ts +2 -1
- package/dist/bits/meter/meter.svelte.js +3 -1
- package/dist/bits/navigation-menu/components/navigation-menu-link.svelte +2 -1
- package/dist/bits/navigation-menu/components/navigation-menu-trigger.svelte +2 -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/bits/utilities/focus-scope/focus-scope-manager.d.ts +12 -0
- package/dist/bits/utilities/focus-scope/focus-scope-manager.js +40 -0
- package/dist/bits/utilities/focus-scope/focus-scope.svelte +6 -8
- package/dist/bits/utilities/focus-scope/focus-scope.svelte.d.ts +1 -0
- package/dist/bits/utilities/focus-scope/focus-scope.svelte.js +204 -0
- package/dist/bits/utilities/focus-scope/types.d.ts +2 -6
- package/dist/bits/utilities/popper-layer/popper-layer-inner.svelte +2 -2
- package/dist/internal/focus.js +1 -1
- package/dist/internal/should-enable-focus-trap.d.ts +5 -0
- package/dist/internal/should-enable-focus-trap.js +5 -0
- package/dist/internal/types.d.ts +2 -1
- package/package.json +2 -2
- package/dist/bits/utilities/focus-scope/focus-scope-stack.svelte.d.ts +0 -14
- package/dist/bits/utilities/focus-scope/focus-scope-stack.svelte.js +0 -50
- package/dist/bits/utilities/focus-scope/use-focus-scope.svelte.d.ts +0 -49
- package/dist/bits/utilities/focus-scope/use-focus-scope.svelte.js +0 -218
- package/dist/internal/should-trap-focus.d.ts +0 -6
- package/dist/internal/should-trap-focus.js +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Box, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
2
|
-
import type { BitsKeyboardEvent, BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
|
|
2
|
+
import type { BitsKeyboardEvent, BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
3
3
|
import type { Orientation } from "../../shared/index.js";
|
|
4
4
|
import { RovingFocusGroup } from "../../internal/roving-focus-group.js";
|
|
5
5
|
interface AccordionBaseStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
@@ -47,6 +47,7 @@ declare abstract class AccordionBaseState {
|
|
|
47
47
|
readonly opts: AccordionBaseStateOpts;
|
|
48
48
|
readonly rovingFocusGroup: RovingFocusGroup;
|
|
49
49
|
abstract readonly isMulti: boolean;
|
|
50
|
+
readonly attachment: RefAttachment;
|
|
50
51
|
constructor(opts: AccordionBaseStateOpts);
|
|
51
52
|
abstract includesItem(item: string): boolean;
|
|
52
53
|
abstract toggleItem(item: string): void;
|
|
@@ -79,6 +80,7 @@ export declare class AccordionItemState {
|
|
|
79
80
|
readonly root: AccordionRoot;
|
|
80
81
|
readonly isActive: boolean;
|
|
81
82
|
readonly isDisabled: boolean;
|
|
83
|
+
readonly attachment: RefAttachment;
|
|
82
84
|
constructor(opts: AccordionItemStateOpts);
|
|
83
85
|
updateValue(): void;
|
|
84
86
|
readonly props: {
|
|
@@ -92,6 +94,7 @@ export declare class AccordionTriggerState {
|
|
|
92
94
|
#private;
|
|
93
95
|
readonly opts: AccordionTriggerStateOpts;
|
|
94
96
|
readonly itemState: AccordionItemState;
|
|
97
|
+
readonly attachment: RefAttachment;
|
|
95
98
|
constructor(opts: AccordionTriggerStateOpts, itemState: AccordionItemState);
|
|
96
99
|
static create(props: AccordionTriggerStateOpts): AccordionTriggerState;
|
|
97
100
|
onclick(e: BitsMouseEvent): void;
|
|
@@ -113,6 +116,7 @@ export declare class AccordionContentState {
|
|
|
113
116
|
#private;
|
|
114
117
|
readonly opts: AccordionContentStateOpts;
|
|
115
118
|
readonly item: AccordionItemState;
|
|
119
|
+
readonly attachment: RefAttachment;
|
|
116
120
|
readonly open: boolean;
|
|
117
121
|
constructor(opts: AccordionContentStateOpts, item: AccordionItemState);
|
|
118
122
|
static create(props: AccordionContentStateOpts): AccordionContentState;
|
|
@@ -133,6 +137,7 @@ export declare class AccordionContentState {
|
|
|
133
137
|
export declare class AccordionHeaderState {
|
|
134
138
|
readonly opts: AccordionHeaderStateOpts;
|
|
135
139
|
readonly item: AccordionItemState;
|
|
140
|
+
readonly attachment: RefAttachment;
|
|
136
141
|
constructor(opts: AccordionHeaderStateOpts, item: AccordionItemState);
|
|
137
142
|
static create(props: AccordionHeaderStateOpts): AccordionHeaderState;
|
|
138
143
|
readonly props: {
|
|
@@ -13,6 +13,7 @@ const AccordionItemContext = new Context("Accordion.Item");
|
|
|
13
13
|
class AccordionBaseState {
|
|
14
14
|
opts;
|
|
15
15
|
rovingFocusGroup;
|
|
16
|
+
attachment;
|
|
16
17
|
constructor(opts) {
|
|
17
18
|
this.opts = opts;
|
|
18
19
|
this.rovingFocusGroup = new RovingFocusGroup({
|
|
@@ -21,13 +22,14 @@ class AccordionBaseState {
|
|
|
21
22
|
loop: this.opts.loop,
|
|
22
23
|
orientation: this.opts.orientation,
|
|
23
24
|
});
|
|
25
|
+
this.attachment = attachRef(this.opts.ref);
|
|
24
26
|
}
|
|
25
27
|
props = $derived.by(() => ({
|
|
26
28
|
id: this.opts.id.current,
|
|
27
29
|
"data-orientation": getDataOrientation(this.opts.orientation.current),
|
|
28
30
|
"data-disabled": getDataDisabled(this.opts.disabled.current),
|
|
29
31
|
[accordionAttrs.root]: "",
|
|
30
|
-
...
|
|
32
|
+
...this.attachment,
|
|
31
33
|
}));
|
|
32
34
|
}
|
|
33
35
|
class AccordionSingleState extends AccordionBaseState {
|
|
@@ -81,10 +83,12 @@ export class AccordionItemState {
|
|
|
81
83
|
root;
|
|
82
84
|
isActive = $derived.by(() => this.root.includesItem(this.opts.value.current));
|
|
83
85
|
isDisabled = $derived.by(() => this.opts.disabled.current || this.root.opts.disabled.current);
|
|
86
|
+
attachment;
|
|
84
87
|
constructor(opts) {
|
|
85
88
|
this.opts = opts;
|
|
86
89
|
this.root = opts.rootState;
|
|
87
90
|
this.updateValue = this.updateValue.bind(this);
|
|
91
|
+
this.attachment = attachRef(this.opts.ref);
|
|
88
92
|
}
|
|
89
93
|
updateValue() {
|
|
90
94
|
this.root.toggleItem(this.opts.value.current);
|
|
@@ -95,7 +99,7 @@ export class AccordionItemState {
|
|
|
95
99
|
"data-disabled": getDataDisabled(this.isDisabled),
|
|
96
100
|
"data-orientation": getDataOrientation(this.root.opts.orientation.current),
|
|
97
101
|
[accordionAttrs.item]: "",
|
|
98
|
-
...
|
|
102
|
+
...this.attachment,
|
|
99
103
|
}));
|
|
100
104
|
}
|
|
101
105
|
export class AccordionTriggerState {
|
|
@@ -105,12 +109,14 @@ export class AccordionTriggerState {
|
|
|
105
109
|
#isDisabled = $derived.by(() => this.opts.disabled.current ||
|
|
106
110
|
this.itemState.opts.disabled.current ||
|
|
107
111
|
this.#root.opts.disabled.current);
|
|
112
|
+
attachment;
|
|
108
113
|
constructor(opts, itemState) {
|
|
109
114
|
this.opts = opts;
|
|
110
115
|
this.itemState = itemState;
|
|
111
116
|
this.#root = itemState.root;
|
|
112
117
|
this.onclick = this.onclick.bind(this);
|
|
113
118
|
this.onkeydown = this.onkeydown.bind(this);
|
|
119
|
+
this.attachment = attachRef(this.opts.ref);
|
|
114
120
|
}
|
|
115
121
|
static create(props) {
|
|
116
122
|
return new AccordionTriggerState(props, AccordionItemContext.get());
|
|
@@ -144,12 +150,13 @@ export class AccordionTriggerState {
|
|
|
144
150
|
tabindex: 0,
|
|
145
151
|
onclick: this.onclick,
|
|
146
152
|
onkeydown: this.onkeydown,
|
|
147
|
-
...
|
|
153
|
+
...this.attachment,
|
|
148
154
|
}));
|
|
149
155
|
}
|
|
150
156
|
export class AccordionContentState {
|
|
151
157
|
opts;
|
|
152
158
|
item;
|
|
159
|
+
attachment;
|
|
153
160
|
#originalStyles = undefined;
|
|
154
161
|
#isMountAnimationPrevented = false;
|
|
155
162
|
#dimensions = $state({ width: 0, height: 0 });
|
|
@@ -158,6 +165,7 @@ export class AccordionContentState {
|
|
|
158
165
|
this.opts = opts;
|
|
159
166
|
this.item = item;
|
|
160
167
|
this.#isMountAnimationPrevented = this.item.isActive;
|
|
168
|
+
this.attachment = attachRef(this.opts.ref);
|
|
161
169
|
// Prevent mount animations on initial render
|
|
162
170
|
$effect(() => {
|
|
163
171
|
const rAF = requestAnimationFrame(() => {
|
|
@@ -206,15 +214,17 @@ export class AccordionContentState {
|
|
|
206
214
|
"--bits-accordion-content-height": `${this.#dimensions.height}px`,
|
|
207
215
|
"--bits-accordion-content-width": `${this.#dimensions.width}px`,
|
|
208
216
|
},
|
|
209
|
-
...
|
|
217
|
+
...this.attachment,
|
|
210
218
|
}));
|
|
211
219
|
}
|
|
212
220
|
export class AccordionHeaderState {
|
|
213
221
|
opts;
|
|
214
222
|
item;
|
|
223
|
+
attachment;
|
|
215
224
|
constructor(opts, item) {
|
|
216
225
|
this.opts = opts;
|
|
217
226
|
this.item = item;
|
|
227
|
+
this.attachment = attachRef(this.opts.ref);
|
|
218
228
|
}
|
|
219
229
|
static create(props) {
|
|
220
230
|
return new AccordionHeaderState(props, AccordionItemContext.get());
|
|
@@ -227,6 +237,6 @@ export class AccordionHeaderState {
|
|
|
227
237
|
"data-state": getDataOpenClosed(this.item.isActive),
|
|
228
238
|
"data-orientation": getDataOrientation(this.item.root.opts.orientation.current),
|
|
229
239
|
[accordionAttrs.header]: "",
|
|
230
|
-
...
|
|
240
|
+
...this.attachment,
|
|
231
241
|
}));
|
|
232
242
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { afterSleep, box, mergeProps } from "svelte-toolbelt";
|
|
3
3
|
import type { AlertDialogContentProps } from "../types.js";
|
|
4
4
|
import DismissibleLayer from "../../utilities/dismissible-layer/dismissible-layer.svelte";
|
|
5
5
|
import EscapeLayer from "../../utilities/escape-layer/escape-layer.svelte";
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { noop } from "../../../internal/noop.js";
|
|
11
11
|
import ScrollLock from "../../utilities/scroll-lock/scroll-lock.svelte";
|
|
12
12
|
import { DialogContentState } from "../../dialog/dialog.svelte.js";
|
|
13
|
-
import {
|
|
13
|
+
import { shouldEnableFocusTrap } from "../../../internal/should-enable-focus-trap.js";
|
|
14
14
|
|
|
15
15
|
const uid = $props.id();
|
|
16
16
|
|
|
@@ -51,25 +51,22 @@
|
|
|
51
51
|
<FocusScope
|
|
52
52
|
ref={contentState.opts.ref}
|
|
53
53
|
loop
|
|
54
|
-
trapFocus
|
|
54
|
+
{trapFocus}
|
|
55
|
+
enabled={shouldEnableFocusTrap({
|
|
55
56
|
forceMount,
|
|
56
57
|
present: contentState.root.opts.open.current,
|
|
57
|
-
trapFocus,
|
|
58
58
|
open: contentState.root.opts.open.current,
|
|
59
59
|
})}
|
|
60
|
-
{id}
|
|
61
60
|
onCloseAutoFocus={(e) => {
|
|
62
61
|
onCloseAutoFocus(e);
|
|
63
62
|
if (e.defaultPrevented) return;
|
|
64
|
-
contentState.root.triggerNode?.focus();
|
|
63
|
+
afterSleep(0, () => contentState.root.triggerNode?.focus());
|
|
65
64
|
}}
|
|
66
65
|
onOpenAutoFocus={(e) => {
|
|
67
66
|
onOpenAutoFocus(e);
|
|
68
67
|
if (e.defaultPrevented) return;
|
|
69
68
|
e.preventDefault();
|
|
70
|
-
|
|
71
|
-
contentState.opts.ref.current?.focus();
|
|
72
|
-
});
|
|
69
|
+
afterSleep(0, () => contentState.opts.ref.current?.focus());
|
|
73
70
|
}}
|
|
74
71
|
>
|
|
75
72
|
{#snippet focusScope({ props: focusScopeProps })}
|
|
@@ -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 AspectRatioRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
4
4
|
ratio: number;
|
|
5
5
|
}> {
|
|
@@ -7,6 +7,7 @@ interface AspectRatioRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
|
|
|
7
7
|
export declare class AspectRatioRootState {
|
|
8
8
|
static create(opts: AspectRatioRootStateOpts): AspectRatioRootState;
|
|
9
9
|
readonly opts: AspectRatioRootStateOpts;
|
|
10
|
+
readonly attachment: RefAttachment;
|
|
10
11
|
constructor(opts: AspectRatioRootStateOpts);
|
|
11
12
|
readonly props: {
|
|
12
13
|
readonly id: string;
|
|
@@ -9,8 +9,10 @@ export class AspectRatioRootState {
|
|
|
9
9
|
return new AspectRatioRootState(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
|
id: this.opts.id.current,
|
|
@@ -22,6 +24,6 @@ export class AspectRatioRootState {
|
|
|
22
24
|
left: 0,
|
|
23
25
|
},
|
|
24
26
|
[aspectRatioAttrs.root]: "",
|
|
25
|
-
...
|
|
27
|
+
...this.attachment,
|
|
26
28
|
}));
|
|
27
29
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DOMContext, type ReadableBox, type WritableBox, type ReadableBoxedValues } from "svelte-toolbelt";
|
|
2
2
|
import type { HTMLImgAttributes } from "svelte/elements";
|
|
3
3
|
import type { AvatarImageLoadingStatus } from "./types.js";
|
|
4
|
-
import type { WithRefOpts } from "../../internal/types.js";
|
|
4
|
+
import type { RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
5
5
|
type CrossOrigin = HTMLImgAttributes["crossorigin"];
|
|
6
6
|
type ReferrerPolicy = HTMLImgAttributes["referrerpolicy"];
|
|
7
7
|
type AvatarImageSrc = string | null | undefined;
|
|
@@ -13,6 +13,7 @@ export declare class AvatarRootState {
|
|
|
13
13
|
static create(opts: AvatarRootStateOpts): AvatarRootState;
|
|
14
14
|
readonly opts: AvatarRootStateOpts;
|
|
15
15
|
readonly domContext: DOMContext;
|
|
16
|
+
readonly attachment: RefAttachment;
|
|
16
17
|
constructor(opts: AvatarRootStateOpts);
|
|
17
18
|
loadImage(src: string, crossorigin?: CrossOrigin, referrerPolicy?: ReferrerPolicy): (() => void) | undefined;
|
|
18
19
|
props: {
|
|
@@ -30,6 +31,7 @@ export declare class AvatarImageState {
|
|
|
30
31
|
static create(opts: AvatarImageStateOpts): AvatarImageState;
|
|
31
32
|
readonly opts: AvatarImageStateOpts;
|
|
32
33
|
readonly root: AvatarRootState;
|
|
34
|
+
readonly attachment: RefAttachment;
|
|
33
35
|
constructor(opts: AvatarImageStateOpts, root: AvatarRootState);
|
|
34
36
|
readonly props: {
|
|
35
37
|
readonly id: string;
|
|
@@ -48,6 +50,7 @@ export declare class AvatarFallbackState {
|
|
|
48
50
|
static create(opts: AvatarFallbackStateOpts): AvatarFallbackState;
|
|
49
51
|
readonly opts: AvatarFallbackStateOpts;
|
|
50
52
|
readonly root: AvatarRootState;
|
|
53
|
+
readonly attachment: RefAttachment;
|
|
51
54
|
constructor(opts: AvatarFallbackStateOpts, root: AvatarRootState);
|
|
52
55
|
readonly style: {
|
|
53
56
|
display: string;
|
|
@@ -12,10 +12,12 @@ export class AvatarRootState {
|
|
|
12
12
|
}
|
|
13
13
|
opts;
|
|
14
14
|
domContext;
|
|
15
|
+
attachment;
|
|
15
16
|
constructor(opts) {
|
|
16
17
|
this.opts = opts;
|
|
17
18
|
this.domContext = new DOMContext(this.opts.ref);
|
|
18
19
|
this.loadImage = this.loadImage.bind(this);
|
|
20
|
+
this.attachment = attachRef(this.opts.ref);
|
|
19
21
|
}
|
|
20
22
|
loadImage(src, crossorigin, referrerPolicy) {
|
|
21
23
|
if (this.opts.loadingStatus.current === "loaded")
|
|
@@ -46,7 +48,7 @@ export class AvatarRootState {
|
|
|
46
48
|
id: this.opts.id.current,
|
|
47
49
|
[avatarAttrs.root]: "",
|
|
48
50
|
"data-status": this.opts.loadingStatus.current,
|
|
49
|
-
...
|
|
51
|
+
...this.attachment,
|
|
50
52
|
}));
|
|
51
53
|
}
|
|
52
54
|
export class AvatarImageState {
|
|
@@ -55,9 +57,11 @@ export class AvatarImageState {
|
|
|
55
57
|
}
|
|
56
58
|
opts;
|
|
57
59
|
root;
|
|
60
|
+
attachment;
|
|
58
61
|
constructor(opts, root) {
|
|
59
62
|
this.opts = opts;
|
|
60
63
|
this.root = root;
|
|
64
|
+
this.attachment = attachRef(this.opts.ref);
|
|
61
65
|
watch.pre([() => this.opts.src.current, () => this.opts.crossOrigin.current], ([src, crossOrigin]) => {
|
|
62
66
|
if (!src) {
|
|
63
67
|
this.root.opts.loadingStatus.current = "error";
|
|
@@ -76,7 +80,7 @@ export class AvatarImageState {
|
|
|
76
80
|
src: this.opts.src.current,
|
|
77
81
|
crossorigin: this.opts.crossOrigin.current,
|
|
78
82
|
referrerpolicy: this.opts.referrerPolicy.current,
|
|
79
|
-
...
|
|
83
|
+
...this.attachment,
|
|
80
84
|
}));
|
|
81
85
|
}
|
|
82
86
|
export class AvatarFallbackState {
|
|
@@ -85,15 +89,17 @@ export class AvatarFallbackState {
|
|
|
85
89
|
}
|
|
86
90
|
opts;
|
|
87
91
|
root;
|
|
92
|
+
attachment;
|
|
88
93
|
constructor(opts, root) {
|
|
89
94
|
this.opts = opts;
|
|
90
95
|
this.root = root;
|
|
96
|
+
this.attachment = attachRef(this.opts.ref);
|
|
91
97
|
}
|
|
92
98
|
style = $derived.by(() => this.root.opts.loadingStatus.current === "loaded" ? { display: "none" } : undefined);
|
|
93
99
|
props = $derived.by(() => ({
|
|
94
100
|
style: this.style,
|
|
95
101
|
"data-status": this.root.opts.loadingStatus.current,
|
|
96
102
|
[avatarAttrs.fallback]: "",
|
|
97
|
-
...
|
|
103
|
+
...this.attachment,
|
|
98
104
|
}));
|
|
99
105
|
}
|
|
@@ -2,7 +2,7 @@ import { type DateValue } from "@internationalized/date";
|
|
|
2
2
|
import { DOMContext, type ReadableBoxedValues, type WritableBoxedValues } from "svelte-toolbelt";
|
|
3
3
|
import { Context } from "runed";
|
|
4
4
|
import type { RangeCalendarRootState } from "../range-calendar/range-calendar.svelte.js";
|
|
5
|
-
import type { BitsKeyboardEvent, BitsMouseEvent, WithRefOpts } from "../../internal/types.js";
|
|
5
|
+
import type { BitsKeyboardEvent, BitsMouseEvent, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
6
6
|
import type { DateMatcher, Month } from "../../shared/index.js";
|
|
7
7
|
import { type Announcer } from "../../internal/date-time/announcer.js";
|
|
8
8
|
import { type Formatter } from "../../internal/date-time/formatter.js";
|
|
@@ -49,6 +49,7 @@ export declare class CalendarRootState {
|
|
|
49
49
|
readonly formatter: Formatter;
|
|
50
50
|
readonly accessibleHeadingId: string;
|
|
51
51
|
readonly domContext: DOMContext;
|
|
52
|
+
readonly attachment: RefAttachment;
|
|
52
53
|
months: Month<DateValue>[];
|
|
53
54
|
announcer: Announcer;
|
|
54
55
|
constructor(opts: CalendarRootStateOpts);
|
|
@@ -109,6 +110,7 @@ export declare class CalendarHeadingState {
|
|
|
109
110
|
static create(opts: CalendarHeadingStateOpts): CalendarHeadingState;
|
|
110
111
|
readonly opts: CalendarHeadingStateOpts;
|
|
111
112
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
113
|
+
readonly attachment: RefAttachment;
|
|
112
114
|
constructor(opts: CalendarHeadingStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
113
115
|
readonly props: {
|
|
114
116
|
readonly id: string;
|
|
@@ -135,6 +137,7 @@ export declare class CalendarCellState {
|
|
|
135
137
|
readonly isFocusedDate: boolean;
|
|
136
138
|
readonly isSelectedDate: boolean;
|
|
137
139
|
readonly labelText: string;
|
|
140
|
+
readonly attachment: RefAttachment;
|
|
138
141
|
constructor(opts: CalendarCellStateOpts, root: CalendarRootState);
|
|
139
142
|
readonly snippetProps: {
|
|
140
143
|
disabled: boolean;
|
|
@@ -176,6 +179,7 @@ export declare class CalendarDayState {
|
|
|
176
179
|
static create(opts: CalendarDayStateOpts): CalendarDayState;
|
|
177
180
|
readonly opts: CalendarDayStateOpts;
|
|
178
181
|
readonly cell: CalendarCellState;
|
|
182
|
+
readonly attachment: RefAttachment;
|
|
179
183
|
constructor(opts: CalendarDayStateOpts, cell: CalendarCellState);
|
|
180
184
|
onclick(e: BitsMouseEvent): void;
|
|
181
185
|
readonly snippetProps: {
|
|
@@ -210,6 +214,7 @@ export declare class CalendarNextButtonState {
|
|
|
210
214
|
readonly opts: CalendarNextButtonStateOpts;
|
|
211
215
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
212
216
|
readonly isDisabled: boolean;
|
|
217
|
+
readonly attachment: RefAttachment;
|
|
213
218
|
constructor(opts: CalendarNextButtonStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
214
219
|
onclick(_: BitsMouseEvent): void;
|
|
215
220
|
readonly props: {
|
|
@@ -230,6 +235,7 @@ export declare class CalendarPrevButtonState {
|
|
|
230
235
|
readonly opts: CalendarPrevButtonStateOpts;
|
|
231
236
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
232
237
|
readonly isDisabled: boolean;
|
|
238
|
+
readonly attachment: RefAttachment;
|
|
233
239
|
constructor(opts: CalendarPrevButtonStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
234
240
|
onclick(_: BitsMouseEvent): void;
|
|
235
241
|
readonly props: {
|
|
@@ -249,6 +255,7 @@ export declare class CalendarGridState {
|
|
|
249
255
|
static create(opts: CalendarGridStateOpts): CalendarGridState;
|
|
250
256
|
readonly opts: CalendarGridStateOpts;
|
|
251
257
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
258
|
+
readonly attachment: RefAttachment;
|
|
252
259
|
constructor(opts: CalendarGridStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
253
260
|
readonly props: {
|
|
254
261
|
readonly id: string;
|
|
@@ -266,6 +273,7 @@ export declare class CalendarGridBodyState {
|
|
|
266
273
|
static create(opts: CalendarGridBodyStateOpts): CalendarGridBodyState;
|
|
267
274
|
readonly opts: CalendarGridBodyStateOpts;
|
|
268
275
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
276
|
+
readonly attachment: RefAttachment;
|
|
269
277
|
constructor(opts: CalendarGridBodyStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
270
278
|
readonly props: {
|
|
271
279
|
readonly id: string;
|
|
@@ -279,6 +287,7 @@ export declare class CalendarGridHeadState {
|
|
|
279
287
|
static create(opts: CalendarGridHeadStateOpts): CalendarGridHeadState;
|
|
280
288
|
readonly opts: CalendarGridHeadStateOpts;
|
|
281
289
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
290
|
+
readonly attachment: RefAttachment;
|
|
282
291
|
constructor(opts: CalendarGridHeadStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
283
292
|
readonly props: {
|
|
284
293
|
readonly id: string;
|
|
@@ -292,6 +301,7 @@ export declare class CalendarGridRowState {
|
|
|
292
301
|
static create(opts: CalendarGridRowStateOpts): CalendarGridRowState;
|
|
293
302
|
readonly opts: CalendarGridRowStateOpts;
|
|
294
303
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
304
|
+
readonly attachment: RefAttachment;
|
|
295
305
|
constructor(opts: CalendarGridRowStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
296
306
|
readonly props: {
|
|
297
307
|
readonly id: string;
|
|
@@ -305,6 +315,7 @@ export declare class CalendarHeadCellState {
|
|
|
305
315
|
static create(opts: CalendarHeadCellStateOpts): CalendarHeadCellState;
|
|
306
316
|
readonly opts: CalendarHeadCellStateOpts;
|
|
307
317
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
318
|
+
readonly attachment: RefAttachment;
|
|
308
319
|
constructor(opts: CalendarHeadCellStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
309
320
|
readonly props: {
|
|
310
321
|
readonly id: string;
|
|
@@ -318,6 +329,7 @@ export declare class CalendarHeaderState {
|
|
|
318
329
|
static create(opts: CalendarHeaderStateOpts): CalendarHeaderState;
|
|
319
330
|
readonly opts: CalendarHeaderStateOpts;
|
|
320
331
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
332
|
+
readonly attachment: RefAttachment;
|
|
321
333
|
constructor(opts: CalendarHeaderStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
322
334
|
readonly props: {
|
|
323
335
|
readonly id: string;
|
|
@@ -335,6 +347,7 @@ export declare class CalendarMonthSelectState {
|
|
|
335
347
|
static create(opts: CalendarMonthSelectStateOpts): CalendarMonthSelectState;
|
|
336
348
|
readonly opts: CalendarMonthSelectStateOpts;
|
|
337
349
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
350
|
+
readonly attachment: RefAttachment;
|
|
338
351
|
constructor(opts: CalendarMonthSelectStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
339
352
|
readonly monthItems: {
|
|
340
353
|
value: number;
|
|
@@ -371,6 +384,7 @@ export declare class CalendarYearSelectState {
|
|
|
371
384
|
static create(opts: CalendarYearSelectStateOpts): CalendarYearSelectState;
|
|
372
385
|
readonly opts: CalendarYearSelectStateOpts;
|
|
373
386
|
readonly root: CalendarRootState | RangeCalendarRootState;
|
|
387
|
+
readonly attachment: RefAttachment;
|
|
374
388
|
constructor(opts: CalendarYearSelectStateOpts, root: CalendarRootState | RangeCalendarRootState);
|
|
375
389
|
readonly years: number[];
|
|
376
390
|
readonly yearItems: {
|