bits-ui 1.3.9 → 1.3.11
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/alert-dialog/components/alert-dialog-content.svelte +4 -2
- package/dist/bits/command/command.svelte.js +2 -2
- package/dist/bits/context-menu/components/context-menu-content.svelte +3 -0
- package/dist/bits/context-menu/types.d.ts +1 -1
- package/dist/bits/dialog/dialog.svelte.d.ts +5 -0
- package/dist/bits/dialog/dialog.svelte.js +5 -0
- package/dist/bits/select/select.svelte.d.ts +4 -1
- package/dist/bits/select/select.svelte.js +3 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { box, mergeProps } from "svelte-toolbelt";
|
|
2
|
+
import { afterTick, 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";
|
|
@@ -64,7 +64,9 @@
|
|
|
64
64
|
onOpenAutoFocus(e);
|
|
65
65
|
if (e.defaultPrevented) return;
|
|
66
66
|
e.preventDefault();
|
|
67
|
-
|
|
67
|
+
afterTick(() => {
|
|
68
|
+
contentState.opts.ref.current?.focus();
|
|
69
|
+
});
|
|
68
70
|
}}
|
|
69
71
|
>
|
|
70
72
|
{#snippet focusScope({ props: focusScopeProps })}
|
|
@@ -258,7 +258,7 @@ class CommandRootState {
|
|
|
258
258
|
const node = this.opts.ref.current;
|
|
259
259
|
if (!node)
|
|
260
260
|
return;
|
|
261
|
-
const selectedNode = node.querySelector(`${COMMAND_VALID_ITEM_SELECTOR}[
|
|
261
|
+
const selectedNode = node.querySelector(`${COMMAND_VALID_ITEM_SELECTOR}[data-selected]`);
|
|
262
262
|
if (!selectedNode)
|
|
263
263
|
return;
|
|
264
264
|
return selectedNode;
|
|
@@ -662,7 +662,7 @@ class CommandInputState {
|
|
|
662
662
|
opts;
|
|
663
663
|
root;
|
|
664
664
|
#selectedItemId = $derived.by(() => {
|
|
665
|
-
const item = this.root.viewportNode?.querySelector(`${COMMAND_ITEM_SELECTOR}[${COMMAND_VALUE_ATTR}="${encodeURIComponent(this.opts.value.current)}"]`);
|
|
665
|
+
const item = this.root.viewportNode?.querySelector(`${COMMAND_ITEM_SELECTOR}[${COMMAND_VALUE_ATTR}="${encodeURIComponent(this.root.opts.value.current)}"]`);
|
|
666
666
|
if (!item)
|
|
667
667
|
return;
|
|
668
668
|
return item?.getAttribute("id") ?? undefined;
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
loop = true,
|
|
18
18
|
onInteractOutside = noop,
|
|
19
19
|
onCloseAutoFocus = noop,
|
|
20
|
+
onOpenAutoFocus = noop,
|
|
20
21
|
preventScroll = true,
|
|
21
22
|
// we need to explicitly pass this prop to the PopperLayer to override
|
|
22
23
|
// the default menu behavior of handling outside interactions on the trigger
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
{preventScroll}
|
|
74
75
|
onInteractOutside={handleInteractOutside}
|
|
75
76
|
onEscapeKeydown={handleEscapeKeydown}
|
|
77
|
+
{onOpenAutoFocus}
|
|
76
78
|
{isValidEvent}
|
|
77
79
|
trapFocus
|
|
78
80
|
{loop}
|
|
@@ -105,6 +107,7 @@
|
|
|
105
107
|
{preventScroll}
|
|
106
108
|
onInteractOutside={handleInteractOutside}
|
|
107
109
|
onEscapeKeydown={handleEscapeKeydown}
|
|
110
|
+
{onOpenAutoFocus}
|
|
108
111
|
{isValidEvent}
|
|
109
112
|
trapFocus
|
|
110
113
|
{loop}
|
|
@@ -2,7 +2,7 @@ import type { MenuContentProps, MenuContentPropsWithoutHTML } from "../menu/type
|
|
|
2
2
|
import type { WithChild, Without } from "../../internal/types.js";
|
|
3
3
|
import type { BitsPrimitiveDivAttributes } from "../../shared/attributes.js";
|
|
4
4
|
export type ContextMenuContentPropsWithoutHTML = Omit<MenuContentPropsWithoutHTML, "align" | "side" | "sideOffset">;
|
|
5
|
-
export type ContextMenuContentProps = Omit<MenuContentProps, "side" | "
|
|
5
|
+
export type ContextMenuContentProps = Omit<MenuContentProps, "side" | "sideOffset" | "align">;
|
|
6
6
|
export type ContextMenuTriggerPropsWithoutHTML = WithChild<{
|
|
7
7
|
/**
|
|
8
8
|
* Whether the context menu trigger is disabled. If disabled, the trigger will not
|
|
@@ -71,6 +71,7 @@ declare class DialogCloseState {
|
|
|
71
71
|
readonly onclick: (e: BitsMouseEvent) => void;
|
|
72
72
|
readonly onkeydown: (e: BitsKeyboardEvent) => void;
|
|
73
73
|
readonly disabled: true | undefined;
|
|
74
|
+
readonly tabindex: 0;
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
type DialogActionStateProps = WithRefProps;
|
|
@@ -120,11 +121,14 @@ declare class DialogContentState {
|
|
|
120
121
|
readonly "data-state": "open" | "closed";
|
|
121
122
|
readonly id: string;
|
|
122
123
|
readonly role: "dialog" | "alertdialog";
|
|
124
|
+
readonly "aria-modal": "true";
|
|
123
125
|
readonly "aria-describedby": string | undefined;
|
|
124
126
|
readonly "aria-labelledby": string | undefined;
|
|
125
127
|
readonly style: {
|
|
126
128
|
readonly pointerEvents: "auto";
|
|
129
|
+
readonly outline: "none" | undefined;
|
|
127
130
|
};
|
|
131
|
+
readonly tabindex: -1 | undefined;
|
|
128
132
|
};
|
|
129
133
|
}
|
|
130
134
|
type DialogOverlayStateProps = WithRefProps;
|
|
@@ -157,6 +161,7 @@ declare class AlertDialogCancelState {
|
|
|
157
161
|
readonly id: string;
|
|
158
162
|
readonly onclick: (e: BitsMouseEvent) => void;
|
|
159
163
|
readonly onkeydown: (e: BitsKeyboardEvent) => void;
|
|
164
|
+
readonly tabindex: 0;
|
|
160
165
|
};
|
|
161
166
|
}
|
|
162
167
|
export declare function useDialogRoot(props: DialogRootStateProps): DialogRootState;
|
|
@@ -123,6 +123,7 @@ class DialogCloseState {
|
|
|
123
123
|
onclick: this.onclick,
|
|
124
124
|
onkeydown: this.onkeydown,
|
|
125
125
|
disabled: this.opts.disabled.current ? true : undefined,
|
|
126
|
+
tabindex: 0,
|
|
126
127
|
...this.root.sharedProps,
|
|
127
128
|
}));
|
|
128
129
|
}
|
|
@@ -204,12 +205,15 @@ class DialogContentState {
|
|
|
204
205
|
props = $derived.by(() => ({
|
|
205
206
|
id: this.opts.id.current,
|
|
206
207
|
role: this.root.opts.variant.current === "alert-dialog" ? "alertdialog" : "dialog",
|
|
208
|
+
"aria-modal": "true",
|
|
207
209
|
"aria-describedby": this.root.descriptionId,
|
|
208
210
|
"aria-labelledby": this.root.titleId,
|
|
209
211
|
[this.root.attrs.content]: "",
|
|
210
212
|
style: {
|
|
211
213
|
pointerEvents: "auto",
|
|
214
|
+
outline: this.root.opts.variant.current === "alert-dialog" ? "none" : undefined,
|
|
212
215
|
},
|
|
216
|
+
tabindex: this.root.opts.variant.current === "alert-dialog" ? -1 : undefined,
|
|
213
217
|
...this.root.sharedProps,
|
|
214
218
|
}));
|
|
215
219
|
}
|
|
@@ -270,6 +274,7 @@ class AlertDialogCancelState {
|
|
|
270
274
|
[this.root.attrs.cancel]: "",
|
|
271
275
|
onclick: this.onclick,
|
|
272
276
|
onkeydown: this.onkeydown,
|
|
277
|
+
tabindex: 0,
|
|
273
278
|
...this.root.sharedProps,
|
|
274
279
|
}));
|
|
275
280
|
}
|
|
@@ -138,6 +138,8 @@ declare class SelectTriggerState {
|
|
|
138
138
|
readonly id: string;
|
|
139
139
|
readonly disabled: true | undefined;
|
|
140
140
|
readonly "aria-haspopup": "listbox";
|
|
141
|
+
readonly "aria-expanded": "true" | "false";
|
|
142
|
+
readonly "aria-activedescendant": string | undefined;
|
|
141
143
|
readonly "data-state": "open" | "closed";
|
|
142
144
|
readonly "data-disabled": "" | undefined;
|
|
143
145
|
readonly "data-placeholder": "" | undefined;
|
|
@@ -173,9 +175,10 @@ declare class SelectContentState {
|
|
|
173
175
|
readonly outline: "none";
|
|
174
176
|
readonly boxSizing: "border-box";
|
|
175
177
|
readonly pointerEvents: "auto";
|
|
176
|
-
};
|
|
178
|
+
} | undefined;
|
|
177
179
|
readonly id: string;
|
|
178
180
|
readonly role: "listbox";
|
|
181
|
+
readonly "aria-multiselectable": "true" | undefined;
|
|
179
182
|
readonly "data-state": "open" | "closed";
|
|
180
183
|
readonly style: {
|
|
181
184
|
readonly display: "flex";
|
|
@@ -589,6 +589,8 @@ class SelectTriggerState {
|
|
|
589
589
|
id: this.opts.id.current,
|
|
590
590
|
disabled: this.root.opts.disabled.current ? true : undefined,
|
|
591
591
|
"aria-haspopup": "listbox",
|
|
592
|
+
"aria-expanded": getAriaExpanded(this.root.opts.open.current),
|
|
593
|
+
"aria-activedescendant": this.root.highlightedId,
|
|
592
594
|
"data-state": getDataOpenClosed(this.root.opts.open.current),
|
|
593
595
|
"data-disabled": getDataDisabled(this.root.opts.disabled.current),
|
|
594
596
|
"data-placeholder": this.root.hasValue ? undefined : "",
|
|
@@ -664,6 +666,7 @@ class SelectContentState {
|
|
|
664
666
|
props = $derived.by(() => ({
|
|
665
667
|
id: this.opts.id.current,
|
|
666
668
|
role: "listbox",
|
|
669
|
+
"aria-multiselectable": this.root.isMulti ? "true" : undefined,
|
|
667
670
|
"data-state": getDataOpenClosed(this.root.opts.open.current),
|
|
668
671
|
[this.root.bitsAttrs.content]: "",
|
|
669
672
|
style: {
|