bits-ui 1.0.0-next.37 → 1.0.0-next.39
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/menu/components/menu-checkbox-item.svelte +2 -0
- package/dist/bits/menu/components/menu-item.svelte +2 -0
- package/dist/bits/menu/components/menu-radio-item.svelte +2 -0
- package/dist/bits/menu/menu.svelte.d.ts +2 -0
- package/dist/bits/menu/menu.svelte.js +6 -1
- package/dist/bits/menu/types.d.ts +16 -0
- package/dist/bits/select/select.svelte.d.ts +1 -0
- package/dist/bits/select/select.svelte.js +1 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
disabled = false,
|
|
16
16
|
onSelect = noop,
|
|
17
17
|
controlledChecked = false,
|
|
18
|
+
closeOnSelect = true,
|
|
18
19
|
...restProps
|
|
19
20
|
}: MenuCheckboxItemProps = $props();
|
|
20
21
|
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
() => ref,
|
|
38
39
|
(v) => (ref = v)
|
|
39
40
|
),
|
|
41
|
+
closeOnSelect: box.with(() => closeOnSelect),
|
|
40
42
|
});
|
|
41
43
|
|
|
42
44
|
function handleSelect(e: Event) {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
id = useId(),
|
|
13
13
|
disabled = false,
|
|
14
14
|
onSelect = noop,
|
|
15
|
+
closeOnSelect = true,
|
|
15
16
|
...restProps
|
|
16
17
|
}: MenuItemProps = $props();
|
|
17
18
|
|
|
@@ -23,6 +24,7 @@
|
|
|
23
24
|
() => ref,
|
|
24
25
|
(v) => (ref = v)
|
|
25
26
|
),
|
|
27
|
+
closeOnSelect: box.with(() => closeOnSelect),
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
const mergedProps = $derived(mergeProps(restProps, itemState.props));
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
onSelect = noop,
|
|
14
14
|
id = useId(),
|
|
15
15
|
disabled = false,
|
|
16
|
+
closeOnSelect = true,
|
|
16
17
|
...restProps
|
|
17
18
|
}: MenuRadioItemProps = $props();
|
|
18
19
|
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
() => ref,
|
|
26
27
|
(v) => (ref = v)
|
|
27
28
|
),
|
|
29
|
+
closeOnSelect: box.with(() => closeOnSelect),
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
function handleSelect(e: Event) {
|
|
@@ -110,6 +110,7 @@ declare class MenuItemSharedState {
|
|
|
110
110
|
}
|
|
111
111
|
type MenuItemStateProps = ReadableBoxedValues<{
|
|
112
112
|
onSelect: AnyFn;
|
|
113
|
+
closeOnSelect: boolean;
|
|
113
114
|
}>;
|
|
114
115
|
declare class MenuItemState {
|
|
115
116
|
#private;
|
|
@@ -257,6 +258,7 @@ declare class MenuRadioGroupState {
|
|
|
257
258
|
type MenuRadioItemStateProps = ReadableBoxedValues<{
|
|
258
259
|
value: string;
|
|
259
260
|
id: string;
|
|
261
|
+
closeOnSelect: boolean;
|
|
260
262
|
}> & WritableBoxedValues<{
|
|
261
263
|
ref: HTMLElement | null;
|
|
262
264
|
}>;
|
|
@@ -338,12 +338,14 @@ class MenuItemSharedState {
|
|
|
338
338
|
class MenuItemState {
|
|
339
339
|
#item;
|
|
340
340
|
#onSelect;
|
|
341
|
+
#closeOnSelect;
|
|
341
342
|
#isPointerDown = $state(false);
|
|
342
343
|
root;
|
|
343
344
|
constructor(props, item) {
|
|
344
345
|
this.#item = item;
|
|
345
346
|
this.root = item.content.parentMenu.root;
|
|
346
347
|
this.#onSelect = props.onSelect;
|
|
348
|
+
this.#closeOnSelect = props.closeOnSelect;
|
|
347
349
|
}
|
|
348
350
|
#onkeydown = (e) => {
|
|
349
351
|
const isTypingAhead = this.#item.content.search !== "";
|
|
@@ -370,8 +372,9 @@ class MenuItemState {
|
|
|
370
372
|
await tick();
|
|
371
373
|
if (selectEvent.defaultPrevented) {
|
|
372
374
|
this.#item.content.parentMenu.root.isUsingKeyboard.current = false;
|
|
375
|
+
return;
|
|
373
376
|
}
|
|
374
|
-
|
|
377
|
+
if (this.#closeOnSelect.current) {
|
|
375
378
|
this.#item.content.parentMenu.root.onClose();
|
|
376
379
|
}
|
|
377
380
|
};
|
|
@@ -633,6 +636,7 @@ class MenuRadioGroupState {
|
|
|
633
636
|
class MenuRadioItemState {
|
|
634
637
|
#id;
|
|
635
638
|
#ref;
|
|
639
|
+
#closeOnSelect;
|
|
636
640
|
#item;
|
|
637
641
|
#value;
|
|
638
642
|
#group;
|
|
@@ -643,6 +647,7 @@ class MenuRadioItemState {
|
|
|
643
647
|
this.#ref = props.ref;
|
|
644
648
|
this.#group = group;
|
|
645
649
|
this.#value = props.value;
|
|
650
|
+
this.#closeOnSelect = props.closeOnSelect;
|
|
646
651
|
useRefById({
|
|
647
652
|
id: this.#id,
|
|
648
653
|
ref: this.#ref,
|
|
@@ -72,6 +72,11 @@ export type MenuItemPropsWithoutHTML<U extends Record<PropertyKey, unknown> = {
|
|
|
72
72
|
* Prevent default behavior of selection with `event.preventDefault()`.
|
|
73
73
|
*/
|
|
74
74
|
onSelect?: (event: Event) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Whether or not the menu item should close when selected.
|
|
77
|
+
* @defaultValue true
|
|
78
|
+
*/
|
|
79
|
+
closeOnSelect?: boolean;
|
|
75
80
|
}, U>;
|
|
76
81
|
export type MenuItemProps = MenuItemPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, MenuItemPropsWithoutHTML>;
|
|
77
82
|
export type MenuCheckboxItemSnippetProps = {
|
|
@@ -97,6 +102,12 @@ export type MenuCheckboxItemPropsWithoutHTML = MenuItemPropsWithoutHTML<MenuChec
|
|
|
97
102
|
* @defaultValue false
|
|
98
103
|
*/
|
|
99
104
|
controlledChecked?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Whether or not the menu item should close when selected.
|
|
107
|
+
*
|
|
108
|
+
* @defaultValue true
|
|
109
|
+
*/
|
|
110
|
+
closeOnSelect?: boolean;
|
|
100
111
|
};
|
|
101
112
|
export type MenuCheckboxItemProps = MenuCheckboxItemPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, MenuCheckboxItemPropsWithoutHTML>;
|
|
102
113
|
export type MenuTriggerPropsWithoutHTML = WithChild<{
|
|
@@ -170,6 +181,11 @@ export type MenuRadioItemPropsWithoutHTML = MenuItemPropsWithoutHTML<MenuRadioIt
|
|
|
170
181
|
* The value of the radio item.
|
|
171
182
|
*/
|
|
172
183
|
value: string;
|
|
184
|
+
/**
|
|
185
|
+
* Whether or not the menu item should close when selected.
|
|
186
|
+
* @defaultValue true
|
|
187
|
+
*/
|
|
188
|
+
closeOnSelect?: boolean;
|
|
173
189
|
};
|
|
174
190
|
export type MenuRadioItemProps = MenuRadioItemPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, MenuRadioItemPropsWithoutHTML>;
|
|
175
191
|
export type MenuPortalPropsWithoutHTML = PortalProps;
|
|
@@ -261,6 +261,7 @@ declare class SelectItemState {
|
|
|
261
261
|
props: {
|
|
262
262
|
readonly [x: string]: string | ((e: PointerEvent) => void) | undefined;
|
|
263
263
|
readonly id: string;
|
|
264
|
+
readonly role: "option";
|
|
264
265
|
readonly "aria-selected": "true" | undefined;
|
|
265
266
|
readonly "data-value": string;
|
|
266
267
|
readonly "data-disabled": "" | undefined;
|
|
@@ -767,6 +767,7 @@ class SelectItemState {
|
|
|
767
767
|
};
|
|
768
768
|
props = $derived.by(() => ({
|
|
769
769
|
id: this.#id.current,
|
|
770
|
+
role: "option",
|
|
770
771
|
"aria-selected": this.root.includesItem(this.value.current) ? "true" : undefined,
|
|
771
772
|
"data-value": this.value.current,
|
|
772
773
|
"data-disabled": getDataDisabled(this.disabled.current),
|