bits-ui 2.3.0 → 2.4.0
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 +0 -5
- package/dist/bits/accordion/accordion.svelte.js +11 -14
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.d.ts +0 -1
- package/dist/bits/aspect-ratio/aspect-ratio.svelte.js +6 -2
- package/dist/bits/avatar/avatar.svelte.d.ts +0 -3
- package/dist/bits/avatar/avatar.svelte.js +8 -6
- package/dist/bits/calendar/calendar.svelte.d.ts +2 -2
- package/dist/bits/calendar/calendar.svelte.js +4 -4
- package/dist/bits/calendar/components/calendar.svelte +4 -3
- package/dist/bits/checkbox/checkbox.svelte.d.ts +0 -3
- package/dist/bits/checkbox/checkbox.svelte.js +14 -14
- package/dist/bits/collapsible/collapsible.svelte.d.ts +0 -3
- package/dist/bits/collapsible/collapsible.svelte.js +8 -7
- package/dist/bits/command/command.svelte.d.ts +0 -12
- package/dist/bits/command/command.svelte.js +35 -31
- package/dist/bits/date-field/components/date-field.svelte +4 -3
- package/dist/bits/date-field/date-field.svelte.d.ts +2 -4
- package/dist/bits/date-field/date-field.svelte.js +8 -6
- package/dist/bits/date-picker/components/date-picker-trigger.svelte +2 -2
- package/dist/bits/date-picker/components/date-picker.svelte +4 -3
- package/dist/bits/date-range-field/components/date-range-field.svelte +4 -3
- package/dist/bits/date-range-field/date-range-field.svelte.d.ts +1 -3
- package/dist/bits/date-range-field/date-range-field.svelte.js +7 -5
- package/dist/bits/date-range-picker/components/date-range-picker-trigger.svelte +2 -2
- package/dist/bits/date-range-picker/components/date-range-picker.svelte +4 -3
- package/dist/bits/dialog/dialog.svelte.d.ts +2 -12
- package/dist/bits/dialog/dialog.svelte.js +16 -24
- package/dist/bits/index.d.ts +1 -0
- package/dist/bits/index.js +1 -0
- package/dist/bits/label/label.svelte.d.ts +0 -1
- package/dist/bits/label/label.svelte.js +6 -2
- package/dist/bits/link-preview/link-preview.svelte.d.ts +0 -2
- package/dist/bits/link-preview/link-preview.svelte.js +7 -5
- package/dist/bits/menu/components/menu-sub-content-static.svelte +1 -1
- package/dist/bits/menu/components/menu-sub-content.svelte +1 -1
- package/dist/bits/menu/menu.svelte.d.ts +2 -1
- package/dist/bits/menu/menu.svelte.js +39 -21
- package/dist/bits/menubar/menubar.svelte.d.ts +1 -7
- package/dist/bits/menubar/menubar.svelte.js +12 -14
- package/dist/bits/meter/meter.svelte.d.ts +0 -1
- package/dist/bits/meter/meter.svelte.js +6 -2
- package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +2 -11
- package/dist/bits/navigation-menu/navigation-menu.svelte.js +30 -25
- package/dist/bits/pagination/pagination.svelte.d.ts +0 -4
- package/dist/bits/pagination/pagination.svelte.js +9 -10
- package/dist/bits/pin-input/pin-input.svelte.d.ts +0 -2
- package/dist/bits/pin-input/pin-input.svelte.js +7 -5
- package/dist/bits/popover/popover.svelte.d.ts +0 -3
- package/dist/bits/popover/popover.svelte.js +9 -5
- package/dist/bits/progress/progress.svelte.d.ts +0 -1
- package/dist/bits/progress/progress.svelte.js +6 -2
- package/dist/bits/radio-group/radio-group.svelte.d.ts +7 -9
- package/dist/bits/radio-group/radio-group.svelte.js +9 -10
- package/dist/bits/range-calendar/components/range-calendar.svelte +4 -3
- package/dist/bits/range-calendar/range-calendar.svelte.d.ts +38 -38
- package/dist/bits/range-calendar/range-calendar.svelte.js +79 -79
- package/dist/bits/rating-group/rating-group.svelte.d.ts +0 -2
- package/dist/bits/rating-group/rating-group.svelte.js +33 -11
- package/dist/bits/scroll-area/scroll-area.svelte.d.ts +15 -19
- package/dist/bits/scroll-area/scroll-area.svelte.js +10 -10
- package/dist/bits/select/select.svelte.d.ts +28 -30
- package/dist/bits/select/select.svelte.js +37 -49
- package/dist/bits/separator/separator.svelte.d.ts +1 -2
- package/dist/bits/separator/separator.svelte.js +6 -3
- package/dist/bits/slider/slider.svelte.d.ts +17 -24
- package/dist/bits/slider/slider.svelte.js +15 -17
- package/dist/bits/switch/switch.svelte.d.ts +6 -8
- package/dist/bits/switch/switch.svelte.js +7 -5
- package/dist/bits/tabs/tabs.svelte.d.ts +5 -9
- package/dist/bits/tabs/tabs.svelte.js +11 -11
- package/dist/bits/time-field/components/time-field.svelte +4 -3
- package/dist/bits/time-field/time-field.svelte.d.ts +1 -3
- package/dist/bits/time-field/time-field.svelte.js +7 -5
- package/dist/bits/time-range-field/components/time-range-field.svelte +4 -3
- package/dist/bits/time-range-field/time-range-field.svelte.d.ts +1 -3
- package/dist/bits/time-range-field/time-range-field.svelte.js +7 -5
- package/dist/bits/toggle/toggle.svelte.d.ts +3 -3
- package/dist/bits/toggle/toggle.svelte.js +6 -3
- package/dist/bits/toggle-group/toggle-group.svelte.d.ts +1 -2
- package/dist/bits/toggle-group/toggle-group.svelte.js +8 -6
- package/dist/bits/toolbar/toolbar.svelte.d.ts +11 -18
- package/dist/bits/toolbar/toolbar.svelte.js +14 -17
- package/dist/bits/tooltip/tooltip.svelte.d.ts +13 -14
- package/dist/bits/tooltip/tooltip.svelte.js +7 -5
- package/dist/bits/utilities/config/bits-config.d.ts +44 -0
- package/dist/bits/utilities/config/bits-config.js +92 -0
- package/dist/bits/utilities/config/components/bits-config.svelte +14 -0
- package/dist/bits/utilities/config/components/bits-config.svelte.d.ts +4 -0
- package/dist/bits/utilities/config/exports.d.ts +2 -0
- package/dist/bits/utilities/config/exports.js +2 -0
- package/dist/bits/utilities/config/index.d.ts +1 -0
- package/dist/bits/utilities/config/index.js +1 -0
- package/dist/bits/utilities/config/prop-resolvers.d.ts +13 -0
- package/dist/bits/utilities/config/prop-resolvers.js +37 -0
- package/dist/bits/utilities/config/types.d.ts +13 -0
- package/dist/bits/utilities/config/types.js +1 -0
- package/dist/bits/utilities/portal/portal.svelte +21 -21
- package/dist/bits/utilities/portal/types.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/attrs.d.ts +14 -0
- package/dist/internal/attrs.js +18 -0
- package/dist/internal/date-time/calendar-helpers.svelte.d.ts +1 -0
- package/dist/internal/date-time/calendar-helpers.svelte.js +18 -1
- package/dist/internal/use-arrow-navigation.d.ts +2 -2
- package/dist/internal/use-arrow-navigation.js +1 -1
- package/dist/internal/use-data-typeahead.svelte.d.ts +1 -1
- package/dist/internal/use-data-typeahead.svelte.js +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/bits/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { Accordion } from "./accordion/index.js";
|
|
|
2
2
|
export { AlertDialog } from "./alert-dialog/index.js";
|
|
3
3
|
export { AspectRatio } from "./aspect-ratio/index.js";
|
|
4
4
|
export { Avatar } from "./avatar/index.js";
|
|
5
|
+
export { BitsConfig, getBitsConfig } from "./utilities/config/index.js";
|
|
5
6
|
export { Button } from "./button/index.js";
|
|
6
7
|
export { Calendar } from "./calendar/index.js";
|
|
7
8
|
export { Checkbox } from "./checkbox/index.js";
|
package/dist/bits/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { Accordion } from "./accordion/index.js";
|
|
|
2
2
|
export { AlertDialog } from "./alert-dialog/index.js";
|
|
3
3
|
export { AspectRatio } from "./aspect-ratio/index.js";
|
|
4
4
|
export { Avatar } from "./avatar/index.js";
|
|
5
|
+
export { BitsConfig, getBitsConfig } from "./utilities/config/index.js";
|
|
5
6
|
export { Button } from "./button/index.js";
|
|
6
7
|
export { Calendar } from "./calendar/index.js";
|
|
7
8
|
export { Checkbox } from "./checkbox/index.js";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { attachRef } from "svelte-toolbelt";
|
|
2
|
-
|
|
2
|
+
import { createBitsAttrs } from "../../internal/attrs.js";
|
|
3
|
+
const labelAttrs = createBitsAttrs({
|
|
4
|
+
component: "label",
|
|
5
|
+
parts: ["root"],
|
|
6
|
+
});
|
|
3
7
|
class LabelRootState {
|
|
4
8
|
opts;
|
|
5
9
|
constructor(opts) {
|
|
@@ -12,7 +16,7 @@ class LabelRootState {
|
|
|
12
16
|
}
|
|
13
17
|
props = $derived.by(() => ({
|
|
14
18
|
id: this.opts.id.current,
|
|
15
|
-
[
|
|
19
|
+
[labelAttrs.root]: "",
|
|
16
20
|
onmousedown: this.onmousedown,
|
|
17
21
|
...attachRef(this.opts.ref),
|
|
18
22
|
}));
|
|
@@ -40,7 +40,6 @@ declare class LinkPreviewTriggerState {
|
|
|
40
40
|
readonly "data-state": "open" | "closed";
|
|
41
41
|
readonly "aria-controls": string | undefined;
|
|
42
42
|
readonly role: "button";
|
|
43
|
-
readonly "data-link-preview-trigger": "";
|
|
44
43
|
readonly onpointerenter: (e: BitsPointerEvent) => void;
|
|
45
44
|
readonly onfocus: (e: BitsFocusEvent) => void;
|
|
46
45
|
readonly onblur: (_: BitsFocusEvent) => void;
|
|
@@ -69,7 +68,6 @@ declare class LinkPreviewContentState {
|
|
|
69
68
|
readonly id: string;
|
|
70
69
|
readonly tabindex: -1;
|
|
71
70
|
readonly "data-state": "open" | "closed";
|
|
72
|
-
readonly "data-link-preview-content": "";
|
|
73
71
|
readonly onpointerdown: (e: BitsPointerEvent) => void;
|
|
74
72
|
readonly onpointerenter: (e: BitsPointerEvent) => void;
|
|
75
73
|
readonly onfocusout: (e: BitsFocusEvent) => void;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { afterSleep, onDestroyEffect, attachRef, DOMContext } from "svelte-toolbelt";
|
|
2
2
|
import { Context, watch } from "runed";
|
|
3
3
|
import { on } from "svelte/events";
|
|
4
|
-
import { getAriaExpanded, getDataOpenClosed } from "../../internal/attrs.js";
|
|
4
|
+
import { createBitsAttrs, getAriaExpanded, getDataOpenClosed } from "../../internal/attrs.js";
|
|
5
5
|
import { isElement, isFocusVisible, isTouch } from "../../internal/is.js";
|
|
6
6
|
import { getTabbableCandidates } from "../../internal/focus.js";
|
|
7
7
|
import { useGraceArea } from "../../internal/use-grace-area.svelte.js";
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const linkPreviewAttrs = createBitsAttrs({
|
|
9
|
+
component: "link-preview",
|
|
10
|
+
parts: ["content", "trigger"],
|
|
11
|
+
});
|
|
10
12
|
class LinkPreviewRootState {
|
|
11
13
|
opts;
|
|
12
14
|
hasSelection = $state(false);
|
|
@@ -126,7 +128,7 @@ class LinkPreviewTriggerState {
|
|
|
126
128
|
"data-state": getDataOpenClosed(this.root.opts.open.current),
|
|
127
129
|
"aria-controls": this.root.contentNode?.id,
|
|
128
130
|
role: "button",
|
|
129
|
-
[
|
|
131
|
+
[linkPreviewAttrs.trigger]: "",
|
|
130
132
|
onpointerenter: this.onpointerenter,
|
|
131
133
|
onfocus: this.onfocus,
|
|
132
134
|
onblur: this.onblur,
|
|
@@ -197,7 +199,7 @@ class LinkPreviewContentState {
|
|
|
197
199
|
id: this.opts.id.current,
|
|
198
200
|
tabindex: -1,
|
|
199
201
|
"data-state": getDataOpenClosed(this.root.opts.open.current),
|
|
200
|
-
[
|
|
202
|
+
[linkPreviewAttrs.content]: "",
|
|
201
203
|
onpointerdown: this.onpointerdown,
|
|
202
204
|
onpointerenter: this.onpointerenter,
|
|
203
205
|
onfocusout: this.onfocusout,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const dataAttr = $derived(subContentState.parentMenu.root.
|
|
57
|
+
const dataAttr = $derived(subContentState.parentMenu.root.getBitsAttr("sub-content"));
|
|
58
58
|
|
|
59
59
|
const mergedProps = $derived(
|
|
60
60
|
mergeProps(restProps, subContentState.props, {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const dataAttr = $derived(subContentState.parentMenu.root.
|
|
58
|
+
const dataAttr = $derived(subContentState.parentMenu.root.getBitsAttr("sub-content"));
|
|
59
59
|
|
|
60
60
|
const mergedProps = $derived(
|
|
61
61
|
mergeProps(restProps, subContentState.props, {
|
|
@@ -17,13 +17,14 @@ export type MenuRootStateProps = ReadableBoxedValues<{
|
|
|
17
17
|
onClose: AnyFn;
|
|
18
18
|
};
|
|
19
19
|
export declare const MenuOpenEvent: CustomEventDispatcher<unknown>;
|
|
20
|
+
export declare const menuAttrs: import("../../internal/attrs.js").BitsAttrs<readonly ["trigger", "content", "sub-trigger", "item", "group", "group-heading", "checkbox-group", "checkbox-item", "radio-group", "radio-item", "separator", "sub-content", "arrow"]>;
|
|
20
21
|
declare class MenuRootState {
|
|
21
22
|
readonly opts: MenuRootStateProps;
|
|
22
23
|
isUsingKeyboard: IsUsingKeyboard;
|
|
23
24
|
ignoreCloseAutoFocus: boolean;
|
|
24
25
|
isPointerInTransit: boolean;
|
|
25
26
|
constructor(opts: MenuRootStateProps);
|
|
26
|
-
|
|
27
|
+
getBitsAttr: typeof menuAttrs.getAttr;
|
|
27
28
|
}
|
|
28
29
|
type MenuMenuStateProps = WritableBoxedValues<{
|
|
29
30
|
open: boolean;
|
|
@@ -7,7 +7,7 @@ import { useDOMTypeahead } from "../../internal/use-dom-typeahead.svelte.js";
|
|
|
7
7
|
import { isElement, isElementOrSVGElement, isHTMLElement } from "../../internal/is.js";
|
|
8
8
|
import { useRovingFocus } from "../../internal/use-roving-focus.svelte.js";
|
|
9
9
|
import { kbd } from "../../internal/kbd.js";
|
|
10
|
-
import { getAriaChecked, getAriaDisabled, getAriaExpanded, getAriaOrientation, getDataDisabled, getDataOpenClosed, } from "../../internal/attrs.js";
|
|
10
|
+
import { createBitsAttrs, getAriaChecked, getAriaDisabled, getAriaExpanded, getAriaOrientation, getDataDisabled, getDataOpenClosed, } from "../../internal/attrs.js";
|
|
11
11
|
import { IsUsingKeyboard } from "../../index.js";
|
|
12
12
|
import { useGraceArea } from "../../internal/use-grace-area.svelte.js";
|
|
13
13
|
import { getTabbableFrom } from "../../internal/tabbable.js";
|
|
@@ -25,6 +25,24 @@ export const MenuOpenEvent = new CustomEventDispatcher("bitsmenuopen", {
|
|
|
25
25
|
bubbles: false,
|
|
26
26
|
cancelable: true,
|
|
27
27
|
});
|
|
28
|
+
export const menuAttrs = createBitsAttrs({
|
|
29
|
+
component: "menu",
|
|
30
|
+
parts: [
|
|
31
|
+
"trigger",
|
|
32
|
+
"content",
|
|
33
|
+
"sub-trigger",
|
|
34
|
+
"item",
|
|
35
|
+
"group",
|
|
36
|
+
"group-heading",
|
|
37
|
+
"checkbox-group",
|
|
38
|
+
"checkbox-item",
|
|
39
|
+
"radio-group",
|
|
40
|
+
"radio-item",
|
|
41
|
+
"separator",
|
|
42
|
+
"sub-content",
|
|
43
|
+
"arrow",
|
|
44
|
+
],
|
|
45
|
+
});
|
|
28
46
|
class MenuRootState {
|
|
29
47
|
opts;
|
|
30
48
|
isUsingKeyboard = new IsUsingKeyboard();
|
|
@@ -33,9 +51,9 @@ class MenuRootState {
|
|
|
33
51
|
constructor(opts) {
|
|
34
52
|
this.opts = opts;
|
|
35
53
|
}
|
|
36
|
-
|
|
37
|
-
return
|
|
38
|
-
}
|
|
54
|
+
getBitsAttr = (part) => {
|
|
55
|
+
return menuAttrs.getAttr(part, this.opts.variant.current);
|
|
56
|
+
};
|
|
39
57
|
}
|
|
40
58
|
class MenuMenuState {
|
|
41
59
|
opts;
|
|
@@ -90,7 +108,7 @@ class MenuContentState {
|
|
|
90
108
|
contentNode: () => this.parentMenu.contentNode,
|
|
91
109
|
triggerNode: () => this.parentMenu.triggerNode,
|
|
92
110
|
enabled: () => this.parentMenu.opts.open.current &&
|
|
93
|
-
Boolean(this.parentMenu.triggerNode?.hasAttribute(this.parentMenu.root.
|
|
111
|
+
Boolean(this.parentMenu.triggerNode?.hasAttribute(this.parentMenu.root.getBitsAttr("sub-trigger"))),
|
|
94
112
|
onPointerExit: () => {
|
|
95
113
|
this.parentMenu.opts.open.current = false;
|
|
96
114
|
},
|
|
@@ -104,7 +122,7 @@ class MenuContentState {
|
|
|
104
122
|
}).handleTypeaheadSearch;
|
|
105
123
|
this.rovingFocusGroup = useRovingFocus({
|
|
106
124
|
rootNode: box.with(() => this.parentMenu.contentNode),
|
|
107
|
-
candidateAttr: this.parentMenu.root.
|
|
125
|
+
candidateAttr: this.parentMenu.root.getBitsAttr("item"),
|
|
108
126
|
loop: this.opts.loop,
|
|
109
127
|
orientation: box.with(() => "vertical"),
|
|
110
128
|
});
|
|
@@ -130,7 +148,7 @@ class MenuContentState {
|
|
|
130
148
|
const node = this.parentMenu.contentNode;
|
|
131
149
|
if (!node)
|
|
132
150
|
return [];
|
|
133
|
-
const candidates = Array.from(node.querySelectorAll(`[${this.parentMenu.root.
|
|
151
|
+
const candidates = Array.from(node.querySelectorAll(`[${this.parentMenu.root.getBitsAttr("item")}]:not([data-disabled])`));
|
|
134
152
|
return candidates;
|
|
135
153
|
}
|
|
136
154
|
#isPointerMovingToSubmenu() {
|
|
@@ -193,7 +211,7 @@ class MenuContentState {
|
|
|
193
211
|
const currentTarget = e.currentTarget;
|
|
194
212
|
if (!isHTMLElement(target) || !isHTMLElement(currentTarget))
|
|
195
213
|
return;
|
|
196
|
-
const isKeydownInside = target.closest(`[${this.parentMenu.root.
|
|
214
|
+
const isKeydownInside = target.closest(`[${this.parentMenu.root.getBitsAttr("content")}]`)?.id ===
|
|
197
215
|
this.parentMenu.contentId.current;
|
|
198
216
|
const isModifierKey = e.ctrlKey || e.altKey || e.metaKey;
|
|
199
217
|
const isCharacterKey = e.key.length === 1;
|
|
@@ -240,7 +258,7 @@ class MenuContentState {
|
|
|
240
258
|
return this.#isPointerMovingToSubmenu();
|
|
241
259
|
}
|
|
242
260
|
onItemLeave(e) {
|
|
243
|
-
if (e.currentTarget.hasAttribute(this.parentMenu.root.
|
|
261
|
+
if (e.currentTarget.hasAttribute(this.parentMenu.root.getBitsAttr("sub-trigger")))
|
|
244
262
|
return;
|
|
245
263
|
if (this.#isPointerMovingToSubmenu() || this.parentMenu.root.isUsingKeyboard.current)
|
|
246
264
|
return;
|
|
@@ -277,7 +295,7 @@ class MenuContentState {
|
|
|
277
295
|
id: this.opts.id.current,
|
|
278
296
|
role: "menu",
|
|
279
297
|
"aria-orientation": getAriaOrientation("vertical"),
|
|
280
|
-
[this.parentMenu.root.
|
|
298
|
+
[this.parentMenu.root.getBitsAttr("content")]: "",
|
|
281
299
|
"data-state": getDataOpenClosed(this.parentMenu.opts.open.current),
|
|
282
300
|
onkeydown: this.onkeydown,
|
|
283
301
|
onblur: this.onblur,
|
|
@@ -356,7 +374,7 @@ class MenuItemSharedState {
|
|
|
356
374
|
"aria-disabled": getAriaDisabled(this.opts.disabled.current),
|
|
357
375
|
"data-disabled": getDataDisabled(this.opts.disabled.current),
|
|
358
376
|
"data-highlighted": this.#isFocused ? "" : undefined,
|
|
359
|
-
[this.content.parentMenu.root.
|
|
377
|
+
[this.content.parentMenu.root.getBitsAttr("item")]: "",
|
|
360
378
|
//
|
|
361
379
|
onpointermove: this.onpointermove,
|
|
362
380
|
onpointerleave: this.onpointerleave,
|
|
@@ -520,7 +538,7 @@ class MenuSubTriggerState {
|
|
|
520
538
|
"aria-controls": this.submenu.opts.open.current
|
|
521
539
|
? this.submenu.contentId.current
|
|
522
540
|
: undefined,
|
|
523
|
-
[this.submenu.root.
|
|
541
|
+
[this.submenu.root.getBitsAttr("sub-trigger")]: "",
|
|
524
542
|
onclick: this.onclick,
|
|
525
543
|
onpointermove: this.onpointermove,
|
|
526
544
|
onpointerleave: this.onpointerleave,
|
|
@@ -570,7 +588,7 @@ class MenuCheckboxItemState {
|
|
|
570
588
|
role: "menuitemcheckbox",
|
|
571
589
|
"aria-checked": getAriaChecked(this.opts.checked.current, this.opts.indeterminate.current),
|
|
572
590
|
"data-state": getCheckedState(this.opts.checked.current),
|
|
573
|
-
[this.item.root.
|
|
591
|
+
[this.item.root.getBitsAttr("checkbox-item")]: "",
|
|
574
592
|
}));
|
|
575
593
|
}
|
|
576
594
|
class MenuGroupState {
|
|
@@ -585,7 +603,7 @@ class MenuGroupState {
|
|
|
585
603
|
id: this.opts.id.current,
|
|
586
604
|
role: "group",
|
|
587
605
|
"aria-labelledby": this.groupHeadingId,
|
|
588
|
-
[this.root.
|
|
606
|
+
[this.root.getBitsAttr("group")]: "",
|
|
589
607
|
...attachRef(this.opts.ref),
|
|
590
608
|
}));
|
|
591
609
|
}
|
|
@@ -599,7 +617,7 @@ class MenuGroupHeadingState {
|
|
|
599
617
|
props = $derived.by(() => ({
|
|
600
618
|
id: this.opts.id.current,
|
|
601
619
|
role: "group",
|
|
602
|
-
[this.group.root.
|
|
620
|
+
[this.group.root.getBitsAttr("group-heading")]: "",
|
|
603
621
|
...attachRef(this.opts.ref, (v) => (this.group.groupHeadingId = v?.id)),
|
|
604
622
|
}));
|
|
605
623
|
}
|
|
@@ -613,7 +631,7 @@ class MenuSeparatorState {
|
|
|
613
631
|
props = $derived.by(() => ({
|
|
614
632
|
id: this.opts.id.current,
|
|
615
633
|
role: "group",
|
|
616
|
-
[this.root.
|
|
634
|
+
[this.root.getBitsAttr("separator")]: "",
|
|
617
635
|
...attachRef(this.opts.ref),
|
|
618
636
|
}));
|
|
619
637
|
}
|
|
@@ -623,7 +641,7 @@ class MenuArrowState {
|
|
|
623
641
|
this.root = root;
|
|
624
642
|
}
|
|
625
643
|
props = $derived.by(() => ({
|
|
626
|
-
[this.root.
|
|
644
|
+
[this.root.getBitsAttr("arrow")]: "",
|
|
627
645
|
}));
|
|
628
646
|
}
|
|
629
647
|
class MenuRadioGroupState {
|
|
@@ -641,7 +659,7 @@ class MenuRadioGroupState {
|
|
|
641
659
|
}
|
|
642
660
|
props = $derived.by(() => ({
|
|
643
661
|
id: this.opts.id.current,
|
|
644
|
-
[this.root.
|
|
662
|
+
[this.root.getBitsAttr("radio-group")]: "",
|
|
645
663
|
role: "group",
|
|
646
664
|
"aria-labelledby": this.groupHeadingId,
|
|
647
665
|
...attachRef(this.opts.ref),
|
|
@@ -661,7 +679,7 @@ class MenuRadioItemState {
|
|
|
661
679
|
this.group.setValue(this.opts.value.current);
|
|
662
680
|
}
|
|
663
681
|
props = $derived.by(() => ({
|
|
664
|
-
[this.group.root.
|
|
682
|
+
[this.group.root.getBitsAttr("radio-item")]: "",
|
|
665
683
|
...this.item.props,
|
|
666
684
|
role: "menuitemradio",
|
|
667
685
|
"aria-checked": getAriaChecked(this.isChecked, false),
|
|
@@ -723,7 +741,7 @@ class DropdownMenuTriggerState {
|
|
|
723
741
|
"aria-controls": this.#ariaControls,
|
|
724
742
|
"data-disabled": getDataDisabled(this.opts.disabled.current),
|
|
725
743
|
"data-state": getDataOpenClosed(this.parentMenu.opts.open.current),
|
|
726
|
-
[this.parentMenu.root.
|
|
744
|
+
[this.parentMenu.root.getBitsAttr("trigger")]: "",
|
|
727
745
|
//
|
|
728
746
|
onpointerdown: this.onpointerdown,
|
|
729
747
|
onpointerup: this.onpointerup,
|
|
@@ -844,7 +862,7 @@ class MenuCheckboxGroupState {
|
|
|
844
862
|
}
|
|
845
863
|
props = $derived.by(() => ({
|
|
846
864
|
id: this.opts.id.current,
|
|
847
|
-
[this.root.
|
|
865
|
+
[this.root.getBitsAttr("checkbox-group")]: "",
|
|
848
866
|
role: "group",
|
|
849
867
|
"aria-labelledby": this.groupHeadingId,
|
|
850
868
|
...attachRef(this.opts.ref),
|
|
@@ -38,7 +38,6 @@ declare class MenubarRootState {
|
|
|
38
38
|
props: {
|
|
39
39
|
readonly id: string;
|
|
40
40
|
readonly role: "menubar";
|
|
41
|
-
readonly "data-menubar-root": "";
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
type MenubarMenuStateProps = ReadableBoxedValues<{
|
|
@@ -87,7 +86,6 @@ declare class MenubarTriggerState {
|
|
|
87
86
|
readonly "data-menu-value": string;
|
|
88
87
|
readonly disabled: true | undefined;
|
|
89
88
|
readonly tabindex: number;
|
|
90
|
-
readonly "data-menubar-trigger": "";
|
|
91
89
|
readonly onpointerdown: PointerEventHandler<HTMLElement>;
|
|
92
90
|
readonly onpointerenter: PointerEventHandler<HTMLElement>;
|
|
93
91
|
readonly onkeydown: KeyboardEventHandler<HTMLElement>;
|
|
@@ -117,11 +115,7 @@ declare class MenubarContentState {
|
|
|
117
115
|
readonly id: string;
|
|
118
116
|
readonly "aria-labelledby": string | undefined;
|
|
119
117
|
readonly style: {
|
|
120
|
-
|
|
121
|
-
readonly "--bits-menubar-content-available-width": "var(--bits-floating-available-width)";
|
|
122
|
-
readonly "--bits-menubar-content-available-height": "var(--bits-floating-available-height)";
|
|
123
|
-
readonly "--bits-menubar-anchor-width": "var(--bits-floating-anchor-width)";
|
|
124
|
-
readonly "--bits-menubar-anchor-height": "var(--bits-floating-anchor-height)";
|
|
118
|
+
[x: string]: string;
|
|
125
119
|
};
|
|
126
120
|
readonly onkeydown: KeyboardEventHandler<HTMLElement>;
|
|
127
121
|
readonly "data-menu-content": "";
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { afterTick, box, attachRef } from "svelte-toolbelt";
|
|
2
2
|
import { Context, watch } from "runed";
|
|
3
3
|
import { useRovingFocus, } from "../../internal/use-roving-focus.svelte.js";
|
|
4
|
-
import { getAriaExpanded, getDataDisabled, getDataOpenClosed } from "../../internal/attrs.js";
|
|
4
|
+
import { createBitsAttrs, getAriaExpanded, getDataDisabled, getDataOpenClosed, } from "../../internal/attrs.js";
|
|
5
5
|
import { kbd } from "../../internal/kbd.js";
|
|
6
6
|
import { wrapArray } from "../../internal/arrays.js";
|
|
7
7
|
import { FocusScopeContext, } from "../utilities/focus-scope/use-focus-scope.svelte.js";
|
|
8
8
|
import { onMount } from "svelte";
|
|
9
|
-
|
|
10
|
-
const
|
|
9
|
+
import { getFloatingContentCSSVars } from "../../internal/floating-svelte/floating-utils.svelte";
|
|
10
|
+
const menubarAttrs = createBitsAttrs({
|
|
11
|
+
component: "menubar",
|
|
12
|
+
parts: ["root", "trigger", "content"],
|
|
13
|
+
});
|
|
11
14
|
class MenubarRootState {
|
|
12
15
|
opts;
|
|
13
16
|
rovingFocusGroup;
|
|
@@ -18,7 +21,7 @@ class MenubarRootState {
|
|
|
18
21
|
this.opts = opts;
|
|
19
22
|
this.rovingFocusGroup = useRovingFocus({
|
|
20
23
|
rootNode: this.opts.ref,
|
|
21
|
-
candidateAttr:
|
|
24
|
+
candidateAttr: menubarAttrs.trigger,
|
|
22
25
|
loop: this.opts.loop,
|
|
23
26
|
orientation: box.with(() => "horizontal"),
|
|
24
27
|
});
|
|
@@ -60,7 +63,7 @@ class MenubarRootState {
|
|
|
60
63
|
const node = this.opts.ref.current;
|
|
61
64
|
if (!node)
|
|
62
65
|
return [];
|
|
63
|
-
return Array.from(node.querySelectorAll(
|
|
66
|
+
return Array.from(node.querySelectorAll(menubarAttrs.selector("trigger")));
|
|
64
67
|
};
|
|
65
68
|
onMenuOpen = (id, triggerId) => {
|
|
66
69
|
this.updateValue(id);
|
|
@@ -75,7 +78,7 @@ class MenubarRootState {
|
|
|
75
78
|
props = $derived.by(() => ({
|
|
76
79
|
id: this.opts.id.current,
|
|
77
80
|
role: "menubar",
|
|
78
|
-
[
|
|
81
|
+
[menubarAttrs.root]: "",
|
|
79
82
|
...attachRef(this.opts.ref),
|
|
80
83
|
}));
|
|
81
84
|
}
|
|
@@ -185,7 +188,7 @@ class MenubarTriggerState {
|
|
|
185
188
|
"data-menu-value": this.menu.opts.value.current,
|
|
186
189
|
disabled: this.opts.disabled.current ? true : undefined,
|
|
187
190
|
tabindex: this.#tabIndex,
|
|
188
|
-
[
|
|
191
|
+
[menubarAttrs.trigger]: "",
|
|
189
192
|
onpointerdown: this.onpointerdown,
|
|
190
193
|
onpointerenter: this.onpointerenter,
|
|
191
194
|
onkeydown: this.onkeydown,
|
|
@@ -262,15 +265,10 @@ class MenubarContentState {
|
|
|
262
265
|
props = $derived.by(() => ({
|
|
263
266
|
id: this.opts.id.current,
|
|
264
267
|
"aria-labelledby": this.menu.triggerId,
|
|
265
|
-
style:
|
|
266
|
-
"--bits-menubar-content-transform-origin": "var(--bits-floating-transform-origin)",
|
|
267
|
-
"--bits-menubar-content-available-width": "var(--bits-floating-available-width)",
|
|
268
|
-
"--bits-menubar-content-available-height": "var(--bits-floating-available-height)",
|
|
269
|
-
"--bits-menubar-anchor-width": "var(--bits-floating-anchor-width)",
|
|
270
|
-
"--bits-menubar-anchor-height": "var(--bits-floating-anchor-height)",
|
|
271
|
-
},
|
|
268
|
+
style: getFloatingContentCSSVars("menubar"),
|
|
272
269
|
onkeydown: this.onkeydown,
|
|
273
270
|
"data-menu-content": "",
|
|
271
|
+
[menubarAttrs.content]: "",
|
|
274
272
|
...attachRef(this.opts.ref, (v) => (this.menu.contentNode = v)),
|
|
275
273
|
}));
|
|
276
274
|
popperProps = {
|
|
@@ -17,7 +17,6 @@ declare class MeterRootState {
|
|
|
17
17
|
readonly "data-value": number;
|
|
18
18
|
readonly "data-max": number;
|
|
19
19
|
readonly "data-min": number;
|
|
20
|
-
readonly "data-meter-root": "";
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
export declare function useMeterRootState(props: MeterRootStateProps): MeterRootState;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { attachRef } from "svelte-toolbelt";
|
|
2
|
-
|
|
2
|
+
import { createBitsAttrs } from "../../internal/attrs.js";
|
|
3
|
+
const meterAttrs = createBitsAttrs({
|
|
4
|
+
component: "meter",
|
|
5
|
+
parts: ["root"],
|
|
6
|
+
});
|
|
3
7
|
class MeterRootState {
|
|
4
8
|
opts;
|
|
5
9
|
constructor(opts) {
|
|
@@ -14,7 +18,7 @@ class MeterRootState {
|
|
|
14
18
|
"data-value": this.opts.value.current,
|
|
15
19
|
"data-max": this.opts.max.current,
|
|
16
20
|
"data-min": this.opts.min.current,
|
|
17
|
-
[
|
|
21
|
+
[meterAttrs.root]: "",
|
|
18
22
|
...attachRef(this.opts.ref),
|
|
19
23
|
}));
|
|
20
24
|
}
|
|
@@ -10,6 +10,7 @@ import { type Direction, type Orientation } from "../../shared/index.js";
|
|
|
10
10
|
import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent } from "../../internal/types.js";
|
|
11
11
|
import { useRovingFocus } from "../../internal/use-roving-focus.svelte.js";
|
|
12
12
|
import type { FocusEventHandler, KeyboardEventHandler, MouseEventHandler, PointerEventHandler } from "svelte/elements";
|
|
13
|
+
declare const navigationMenuAttrs: import("../../internal/attrs.js").BitsAttrs<readonly ["root", "sub", "item", "list", "trigger", "content", "link", "viewport", "menu", "indicator"]>;
|
|
13
14
|
type NavigationMenuProviderStateProps = ReadableBoxedValues<{
|
|
14
15
|
dir: Direction;
|
|
15
16
|
orientation: Orientation;
|
|
@@ -62,8 +63,6 @@ declare class NavigationMenuRootState {
|
|
|
62
63
|
readonly id: string;
|
|
63
64
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
64
65
|
readonly dir: Direction;
|
|
65
|
-
readonly "data-navigation-menu-root": "";
|
|
66
|
-
readonly "data-navigation-menu": "";
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
type NavigationMenuSubStateProps = WithRefProps<WritableBoxedValues<{
|
|
@@ -81,8 +80,6 @@ declare class NavigationMenuSubState {
|
|
|
81
80
|
props: {
|
|
82
81
|
readonly id: string;
|
|
83
82
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
84
|
-
readonly "data-navigation-menu-sub": "";
|
|
85
|
-
readonly "data-navigation-menu": "";
|
|
86
83
|
};
|
|
87
84
|
}
|
|
88
85
|
type NavigationMenuListStateProps = WithRefProps;
|
|
@@ -102,7 +99,6 @@ declare class NavigationMenuListState {
|
|
|
102
99
|
props: {
|
|
103
100
|
readonly id: string;
|
|
104
101
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
105
|
-
readonly "data-navigation-menu-list": "";
|
|
106
102
|
};
|
|
107
103
|
}
|
|
108
104
|
type NavigationMenuItemStateProps = WithRefProps<ReadableBoxedValues<{
|
|
@@ -132,8 +128,8 @@ export declare class NavigationMenuItemState {
|
|
|
132
128
|
onRootContentClose: () => void;
|
|
133
129
|
onContentFocusOutside: () => void;
|
|
134
130
|
props: {
|
|
131
|
+
readonly [navigationMenuAttrs.item]: "";
|
|
135
132
|
readonly id: string;
|
|
136
|
-
readonly "data-navigation-menu-item": "";
|
|
137
133
|
};
|
|
138
134
|
}
|
|
139
135
|
type NavigationMenuTriggerStateProps = WithRefProps & ReadableBoxedValues<{
|
|
@@ -170,7 +166,6 @@ declare class NavigationMenuTriggerState {
|
|
|
170
166
|
readonly "data-value": string;
|
|
171
167
|
readonly "aria-expanded": "true" | "false";
|
|
172
168
|
readonly "aria-controls": string | undefined;
|
|
173
|
-
readonly "data-navigation-menu-trigger": "";
|
|
174
169
|
readonly onpointermove: PointerEventHandler<HTMLElement>;
|
|
175
170
|
readonly onpointerleave: PointerEventHandler<HTMLElement>;
|
|
176
171
|
readonly onpointerenter: (_: BitsPointerEvent<HTMLButtonElement>) => void;
|
|
@@ -219,7 +214,6 @@ declare class NavigationMenuLinkState {
|
|
|
219
214
|
readonly onblur: (_: BitsFocusEvent) => void;
|
|
220
215
|
readonly onpointerenter: PointerEventHandler<HTMLAnchorElement>;
|
|
221
216
|
readonly onpointermove: PointerEventHandler<HTMLElement>;
|
|
222
|
-
readonly "data-navigation-menu-link": "";
|
|
223
217
|
};
|
|
224
218
|
}
|
|
225
219
|
type NavigationMenuIndicatorStateProps = WithRefProps;
|
|
@@ -260,7 +254,6 @@ declare class NavigationMenuIndicatorImplState {
|
|
|
260
254
|
readonly transform: string;
|
|
261
255
|
readonly position: "absolute";
|
|
262
256
|
};
|
|
263
|
-
readonly "data-navigation-menu-indicator": "";
|
|
264
257
|
};
|
|
265
258
|
}
|
|
266
259
|
type NavigationMenuContentStateProps = WithRefProps;
|
|
@@ -308,7 +301,6 @@ declare class NavigationMenuContentImplState {
|
|
|
308
301
|
readonly "data-orientation": "horizontal" | "vertical";
|
|
309
302
|
readonly "data-state": "open" | "closed";
|
|
310
303
|
readonly onkeydown: (e: BitsKeyboardEvent) => void;
|
|
311
|
-
readonly "data-navigation-menu-content": "";
|
|
312
304
|
};
|
|
313
305
|
}
|
|
314
306
|
declare class NavigationMenuViewportState {
|
|
@@ -334,7 +326,6 @@ declare class NavigationMenuViewportState {
|
|
|
334
326
|
readonly "--bits-navigation-menu-viewport-width": string | undefined;
|
|
335
327
|
readonly "--bits-navigation-menu-viewport-height": string | undefined;
|
|
336
328
|
};
|
|
337
|
-
readonly "data-navigation-menu-viewport": "";
|
|
338
329
|
readonly onpointerenter: () => void;
|
|
339
330
|
readonly onpointerleave: () => void;
|
|
340
331
|
};
|