bits-ui 1.6.1 → 1.7.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.
@@ -15,4 +15,5 @@ export { default as SubContentStatic } from "../menu/components/menu-sub-content
15
15
  export { default as SubTrigger } from "../menu/components/menu-sub-trigger.svelte";
16
16
  export { default as CheckboxItem } from "../menu/components/menu-checkbox-item.svelte";
17
17
  export { default as Portal } from "../utilities/portal/portal.svelte";
18
- export type { ContextMenuArrowProps as ArrowProps, ContextMenuCheckboxItemProps as CheckboxItemProps, ContextMenuGroupProps as GroupProps, ContextMenuItemProps as ItemProps, ContextMenuGroupHeadingProps as GroupHeadingProps, ContextMenuRootProps as RootProps, ContextMenuRadioGroupProps as RadioGroupProps, ContextMenuRadioItemProps as RadioItemProps, ContextMenuSeparatorProps as SeparatorProps, ContextMenuSubContentProps as SubContentProps, ContextMenuSubContentStaticProps as SubContentStaticProps, ContextMenuSubProps as SubProps, ContextMenuSubTriggerProps as SubTriggerProps, ContextMenuContentProps as ContentProps, ContextMenuContentStaticProps as ContentStaticProps, ContextMenuTriggerProps as TriggerProps, ContextMenuPortalProps as PortalProps, } from "./types.js";
18
+ export { default as CheckboxGroup } from "../menu/components/menu-checkbox-group.svelte";
19
+ export type { ContextMenuArrowProps as ArrowProps, ContextMenuCheckboxItemProps as CheckboxItemProps, ContextMenuGroupProps as GroupProps, ContextMenuItemProps as ItemProps, ContextMenuGroupHeadingProps as GroupHeadingProps, ContextMenuRootProps as RootProps, ContextMenuRadioGroupProps as RadioGroupProps, ContextMenuRadioItemProps as RadioItemProps, ContextMenuSeparatorProps as SeparatorProps, ContextMenuSubContentProps as SubContentProps, ContextMenuSubContentStaticProps as SubContentStaticProps, ContextMenuSubProps as SubProps, ContextMenuSubTriggerProps as SubTriggerProps, ContextMenuContentProps as ContentProps, ContextMenuContentStaticProps as ContentStaticProps, ContextMenuTriggerProps as TriggerProps, ContextMenuPortalProps as PortalProps, ContextMenuCheckboxGroupProps as CheckboxGroupProps, } from "./types.js";
@@ -15,3 +15,4 @@ export { default as SubContentStatic } from "../menu/components/menu-sub-content
15
15
  export { default as SubTrigger } from "../menu/components/menu-sub-trigger.svelte";
16
16
  export { default as CheckboxItem } from "../menu/components/menu-checkbox-item.svelte";
17
17
  export { default as Portal } from "../utilities/portal/portal.svelte";
18
+ export { default as CheckboxGroup } from "../menu/components/menu-checkbox-group.svelte";
@@ -11,5 +11,5 @@ export type ContextMenuTriggerPropsWithoutHTML = WithChild<{
11
11
  disabled?: boolean;
12
12
  }>;
13
13
  export type ContextMenuTriggerProps = ContextMenuTriggerPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, ContextMenuTriggerPropsWithoutHTML>;
14
- export type { MenuArrowProps as ContextMenuArrowProps, MenuContentStaticProps as ContextMenuContentStaticProps, MenuCheckboxItemProps as ContextMenuCheckboxItemProps, MenuGroupProps as ContextMenuGroupProps, MenuItemProps as ContextMenuItemProps, MenuGroupHeadingProps as ContextMenuGroupHeadingProps, MenuRootProps as ContextMenuRootProps, MenuRadioGroupProps as ContextMenuRadioGroupProps, MenuRadioItemProps as ContextMenuRadioItemProps, MenuSeparatorProps as ContextMenuSeparatorProps, MenuSubContentProps as ContextMenuSubContentProps, MenuSubContentStaticProps as ContextMenuSubContentStaticProps, MenuSubProps as ContextMenuSubProps, MenuSubTriggerProps as ContextMenuSubTriggerProps, MenuPortalProps as ContextMenuPortalProps, } from "../menu/types.js";
15
- export type { MenuRootPropsWithoutHTML as ContextMenuRootPropsWithoutHTML, MenuContentStaticPropsWithoutHTML as ContextMenuContentStaticPropsWithoutHTML, MenuArrowPropsWithoutHTML as ContextMenuArrowPropsWithoutHTML, MenuCheckboxItemPropsWithoutHTML as ContextMenuCheckboxItemPropsWithoutHTML, MenuGroupPropsWithoutHTML as ContextMenuGroupPropsWithoutHTML, MenuItemPropsWithoutHTML as ContextMenuItemPropsWithoutHTML, MenuGroupHeadingPropsWithoutHTML as ContextMenuGroupHeadingPropsWithoutHTML, MenuRadioGroupPropsWithoutHTML as ContextMenuRadioGroupPropsWithoutHTML, MenuRadioItemPropsWithoutHTML as ContextMenuRadioItemPropsWithoutHTML, MenuSeparatorPropsWithoutHTML as ContextMenuSeparatorPropsWithoutHTML, MenuSubPropsWithoutHTML as ContextMenuSubPropsWithoutHTML, MenuSubTriggerPropsWithoutHTML as ContextMenuSubTriggerPropsWithoutHTML, MenuSubContentPropsWithoutHTML as ContextMenuSubContentPropsWithoutHTML, MenuSubContentStaticPropsWithoutHTML as ContextMenuSubContentStaticPropsWithoutHTML, MenuPortalPropsWithoutHTML as ContextMenuPortalPropsWithoutHTML, } from "../menu/types.js";
14
+ export type { MenuArrowProps as ContextMenuArrowProps, MenuContentStaticProps as ContextMenuContentStaticProps, MenuCheckboxItemProps as ContextMenuCheckboxItemProps, MenuGroupProps as ContextMenuGroupProps, MenuItemProps as ContextMenuItemProps, MenuGroupHeadingProps as ContextMenuGroupHeadingProps, MenuRootProps as ContextMenuRootProps, MenuRadioGroupProps as ContextMenuRadioGroupProps, MenuRadioItemProps as ContextMenuRadioItemProps, MenuSeparatorProps as ContextMenuSeparatorProps, MenuSubContentProps as ContextMenuSubContentProps, MenuSubContentStaticProps as ContextMenuSubContentStaticProps, MenuSubProps as ContextMenuSubProps, MenuSubTriggerProps as ContextMenuSubTriggerProps, MenuPortalProps as ContextMenuPortalProps, MenuCheckboxGroupProps as ContextMenuCheckboxGroupProps, } from "../menu/types.js";
15
+ export type { MenuRootPropsWithoutHTML as ContextMenuRootPropsWithoutHTML, MenuContentStaticPropsWithoutHTML as ContextMenuContentStaticPropsWithoutHTML, MenuArrowPropsWithoutHTML as ContextMenuArrowPropsWithoutHTML, MenuCheckboxItemPropsWithoutHTML as ContextMenuCheckboxItemPropsWithoutHTML, MenuGroupPropsWithoutHTML as ContextMenuGroupPropsWithoutHTML, MenuItemPropsWithoutHTML as ContextMenuItemPropsWithoutHTML, MenuGroupHeadingPropsWithoutHTML as ContextMenuGroupHeadingPropsWithoutHTML, MenuRadioGroupPropsWithoutHTML as ContextMenuRadioGroupPropsWithoutHTML, MenuRadioItemPropsWithoutHTML as ContextMenuRadioItemPropsWithoutHTML, MenuSeparatorPropsWithoutHTML as ContextMenuSeparatorPropsWithoutHTML, MenuSubPropsWithoutHTML as ContextMenuSubPropsWithoutHTML, MenuSubTriggerPropsWithoutHTML as ContextMenuSubTriggerPropsWithoutHTML, MenuSubContentPropsWithoutHTML as ContextMenuSubContentPropsWithoutHTML, MenuSubContentStaticPropsWithoutHTML as ContextMenuSubContentStaticPropsWithoutHTML, MenuPortalPropsWithoutHTML as ContextMenuPortalPropsWithoutHTML, MenuCheckboxGroupPropsWithoutHTML as ContextMenuCheckboxGroupPropsWithoutHTML, } from "../menu/types.js";
@@ -15,4 +15,5 @@ export { default as SubContentStatic } from "../menu/components/menu-sub-content
15
15
  export { default as SubTrigger } from "../menu/components/menu-sub-trigger.svelte";
16
16
  export { default as CheckboxItem } from "../menu/components/menu-checkbox-item.svelte";
17
17
  export { default as Portal } from "../utilities/portal/portal.svelte";
18
- export type { DropdownMenuArrowProps as ArrowProps, DropdownMenuCheckboxItemProps as CheckboxItemProps, DropdownMenuContentProps as ContentProps, DropdownMenuContentStaticProps as ContentStaticProps, DropdownMenuGroupProps as GroupProps, DropdownMenuItemProps as ItemProps, DropdownMenuGroupHeadingProps as GroupHeadingProps, DropdownMenuRootProps as RootProps, DropdownMenuRadioGroupProps as RadioGroupProps, DropdownMenuRadioItemProps as RadioItemProps, DropdownMenuSeparatorProps as SeparatorProps, DropdownMenuSubContentProps as SubContentProps, DropdownMenuSubContentStaticProps as SubContentStaticProps, DropdownMenuSubProps as SubProps, DropdownMenuSubTriggerProps as SubTriggerProps, DropdownMenuTriggerProps as TriggerProps, DropdownMenuPortalProps as PortalProps, } from "./types.js";
18
+ export { default as CheckboxGroup } from "../menu/components/menu-checkbox-group.svelte";
19
+ export type { DropdownMenuArrowProps as ArrowProps, DropdownMenuCheckboxItemProps as CheckboxItemProps, DropdownMenuContentProps as ContentProps, DropdownMenuContentStaticProps as ContentStaticProps, DropdownMenuGroupProps as GroupProps, DropdownMenuItemProps as ItemProps, DropdownMenuGroupHeadingProps as GroupHeadingProps, DropdownMenuRootProps as RootProps, DropdownMenuRadioGroupProps as RadioGroupProps, DropdownMenuRadioItemProps as RadioItemProps, DropdownMenuSeparatorProps as SeparatorProps, DropdownMenuSubContentProps as SubContentProps, DropdownMenuSubContentStaticProps as SubContentStaticProps, DropdownMenuSubProps as SubProps, DropdownMenuSubTriggerProps as SubTriggerProps, DropdownMenuTriggerProps as TriggerProps, DropdownMenuPortalProps as PortalProps, DropdownMenuCheckboxGroupProps as CheckboxGroupProps, } from "./types.js";
@@ -15,3 +15,4 @@ export { default as SubContentStatic } from "../menu/components/menu-sub-content
15
15
  export { default as SubTrigger } from "../menu/components/menu-sub-trigger.svelte";
16
16
  export { default as CheckboxItem } from "../menu/components/menu-checkbox-item.svelte";
17
17
  export { default as Portal } from "../utilities/portal/portal.svelte";
18
+ export { default as CheckboxGroup } from "../menu/components/menu-checkbox-group.svelte";
@@ -1,2 +1,2 @@
1
- export type { MenuArrowProps as DropdownMenuArrowProps, MenuCheckboxItemProps as DropdownMenuCheckboxItemProps, MenuContentProps as DropdownMenuContentProps, MenuContentStaticProps as DropdownMenuContentStaticProps, MenuGroupProps as DropdownMenuGroupProps, MenuItemProps as DropdownMenuItemProps, MenuGroupHeadingProps as DropdownMenuGroupHeadingProps, MenuRootProps as DropdownMenuRootProps, MenuRadioGroupProps as DropdownMenuRadioGroupProps, MenuRadioItemProps as DropdownMenuRadioItemProps, MenuSeparatorProps as DropdownMenuSeparatorProps, MenuSubContentProps as DropdownMenuSubContentProps, MenuSubContentStaticProps as DropdownMenuSubContentStaticProps, MenuSubProps as DropdownMenuSubProps, MenuSubTriggerProps as DropdownMenuSubTriggerProps, MenuTriggerProps as DropdownMenuTriggerProps, MenuPortalProps as DropdownMenuPortalProps, } from "../menu/types.js";
2
- export type { MenuRootPropsWithoutHTML as DropdownMenuRootPropsWithoutHTML, MenuArrowPropsWithoutHTML as DropdownMenuArrowPropsWithoutHTML, MenuCheckboxItemPropsWithoutHTML as DropdownMenuCheckboxItemPropsWithoutHTML, MenuContentPropsWithoutHTML as DropdownMenuContentPropsWithoutHTML, MenuContentStaticPropsWithoutHTML as DropdownMenuContentStaticPropsWithoutHTML, MenuGroupPropsWithoutHTML as DropdownMenuGroupPropsWithoutHTML, MenuItemPropsWithoutHTML as DropdownMenuItemPropsWithoutHTML, MenuGroupHeadingPropsWithoutHTML as DropdownMenuGroupHeadingPropsWithoutHTML, MenuRadioGroupPropsWithoutHTML as DropdownMenuRadioGroupPropsWithoutHTML, MenuRadioItemPropsWithoutHTML as DropdownMenuRadioItemPropsWithoutHTML, MenuSeparatorPropsWithoutHTML as DropdownMenuSeparatorPropsWithoutHTML, MenuSubPropsWithoutHTML as DropdownMenuSubPropsWithoutHTML, MenuSubTriggerPropsWithoutHTML as DropdownMenuSubTriggerPropsWithoutHTML, MenuSubContentPropsWithoutHTML as DropdownMenuSubContentPropsWithoutHTML, MenuSubContentStaticPropsWithoutHTML as DropdownMenuSubContentStaticPropsWithoutHTML, MenuTriggerPropsWithoutHTML as DropdownMenuTriggerPropsWithoutHTML, MenuPortalPropsWithoutHTML as DropdownMenuPortalPropsWithoutHTML, } from "../menu/types.js";
1
+ export type { MenuArrowProps as DropdownMenuArrowProps, MenuCheckboxItemProps as DropdownMenuCheckboxItemProps, MenuContentProps as DropdownMenuContentProps, MenuContentStaticProps as DropdownMenuContentStaticProps, MenuGroupProps as DropdownMenuGroupProps, MenuItemProps as DropdownMenuItemProps, MenuGroupHeadingProps as DropdownMenuGroupHeadingProps, MenuRootProps as DropdownMenuRootProps, MenuRadioGroupProps as DropdownMenuRadioGroupProps, MenuRadioItemProps as DropdownMenuRadioItemProps, MenuSeparatorProps as DropdownMenuSeparatorProps, MenuSubContentProps as DropdownMenuSubContentProps, MenuSubContentStaticProps as DropdownMenuSubContentStaticProps, MenuSubProps as DropdownMenuSubProps, MenuSubTriggerProps as DropdownMenuSubTriggerProps, MenuTriggerProps as DropdownMenuTriggerProps, MenuPortalProps as DropdownMenuPortalProps, MenuCheckboxGroupProps as DropdownMenuCheckboxGroupProps, } from "../menu/types.js";
2
+ export type { MenuRootPropsWithoutHTML as DropdownMenuRootPropsWithoutHTML, MenuArrowPropsWithoutHTML as DropdownMenuArrowPropsWithoutHTML, MenuCheckboxItemPropsWithoutHTML as DropdownMenuCheckboxItemPropsWithoutHTML, MenuContentPropsWithoutHTML as DropdownMenuContentPropsWithoutHTML, MenuContentStaticPropsWithoutHTML as DropdownMenuContentStaticPropsWithoutHTML, MenuGroupPropsWithoutHTML as DropdownMenuGroupPropsWithoutHTML, MenuItemPropsWithoutHTML as DropdownMenuItemPropsWithoutHTML, MenuGroupHeadingPropsWithoutHTML as DropdownMenuGroupHeadingPropsWithoutHTML, MenuRadioGroupPropsWithoutHTML as DropdownMenuRadioGroupPropsWithoutHTML, MenuRadioItemPropsWithoutHTML as DropdownMenuRadioItemPropsWithoutHTML, MenuSeparatorPropsWithoutHTML as DropdownMenuSeparatorPropsWithoutHTML, MenuSubPropsWithoutHTML as DropdownMenuSubPropsWithoutHTML, MenuSubTriggerPropsWithoutHTML as DropdownMenuSubTriggerPropsWithoutHTML, MenuSubContentPropsWithoutHTML as DropdownMenuSubContentPropsWithoutHTML, MenuSubContentStaticPropsWithoutHTML as DropdownMenuSubContentStaticPropsWithoutHTML, MenuTriggerPropsWithoutHTML as DropdownMenuTriggerPropsWithoutHTML, MenuPortalPropsWithoutHTML as DropdownMenuPortalPropsWithoutHTML, MenuCheckboxGroupPropsWithoutHTML as DropdownMenuCheckboxGroupPropsWithoutHTML, } from "../menu/types.js";
@@ -0,0 +1,43 @@
1
+ <script lang="ts">
2
+ import { box, mergeProps } from "svelte-toolbelt";
3
+ import type { MenuCheckboxGroupProps } from "../types.js";
4
+ import { useMenuCheckboxGroup } from "../menu.svelte.js";
5
+ import { noop } from "../../../internal/noop.js";
6
+ import { useId } from "../../../internal/use-id.js";
7
+
8
+ let {
9
+ id = useId(),
10
+ children,
11
+ child,
12
+ ref = $bindable(null),
13
+ value = $bindable([]),
14
+ onValueChange = noop,
15
+ ...restProps
16
+ }: MenuCheckboxGroupProps = $props();
17
+
18
+ const checkboxGroupState = useMenuCheckboxGroup({
19
+ value: box.with(
20
+ () => $state.snapshot(value),
21
+ (v) => {
22
+ value = $state.snapshot(v);
23
+ onValueChange(v);
24
+ }
25
+ ),
26
+ onValueChange: box.with(() => onValueChange),
27
+ ref: box.with(
28
+ () => ref,
29
+ (v) => (ref = v)
30
+ ),
31
+ id: box.with(() => id),
32
+ });
33
+
34
+ const mergedProps = $derived(mergeProps(restProps, checkboxGroupState.props));
35
+ </script>
36
+
37
+ {#if child}
38
+ {@render child({ props: mergedProps })}
39
+ {:else}
40
+ <div {...mergedProps}>
41
+ {@render children?.()}
42
+ </div>
43
+ {/if}
@@ -0,0 +1,4 @@
1
+ import type { MenuCheckboxGroupProps } from "../types.js";
2
+ declare const MenuCheckboxGroup: import("svelte").Component<MenuCheckboxGroupProps, {}, "value" | "ref">;
3
+ type MenuCheckboxGroup = ReturnType<typeof MenuCheckboxGroup>;
4
+ export default MenuCheckboxGroup;
@@ -1,9 +1,10 @@
1
1
  <script lang="ts">
2
2
  import { box, mergeProps } from "svelte-toolbelt";
3
3
  import type { MenuCheckboxItemProps } from "../types.js";
4
- import { useMenuCheckboxItem } from "../menu.svelte.js";
4
+ import { MenuCheckboxGroupContext, useMenuCheckboxItem } from "../menu.svelte.js";
5
5
  import { useId } from "../../../internal/use-id.js";
6
6
  import { noop } from "../../../internal/noop.js";
7
+ import { watch } from "runed";
7
8
 
8
9
  let {
9
10
  child,
@@ -17,33 +18,61 @@
17
18
  closeOnSelect = true,
18
19
  indeterminate = $bindable(false),
19
20
  onIndeterminateChange = noop,
21
+ value = "",
20
22
  ...restProps
21
23
  }: MenuCheckboxItemProps = $props();
22
24
 
23
- const checkboxItemState = useMenuCheckboxItem({
24
- checked: box.with(
25
- () => checked,
26
- (v) => {
27
- checked = v;
28
- onCheckedChange(v);
29
- }
30
- ),
31
- id: box.with(() => id),
32
- disabled: box.with(() => disabled),
33
- onSelect: box.with(() => handleSelect),
34
- ref: box.with(
35
- () => ref,
36
- (v) => (ref = v)
37
- ),
38
- closeOnSelect: box.with(() => closeOnSelect),
39
- indeterminate: box.with(
40
- () => indeterminate,
41
- (v) => {
42
- indeterminate = v;
43
- onIndeterminateChange(v);
25
+ const group = MenuCheckboxGroupContext.getOr(null);
26
+
27
+ if (group && value) {
28
+ if (group.opts.value.current.includes(value)) {
29
+ checked = true;
30
+ } else {
31
+ checked = false;
32
+ }
33
+ }
34
+
35
+ watch.pre(
36
+ () => value,
37
+ () => {
38
+ if (group && value) {
39
+ if (group.opts.value.current.includes(value)) {
40
+ checked = true;
41
+ } else {
42
+ checked = false;
43
+ }
44
44
  }
45
- ),
46
- });
45
+ }
46
+ );
47
+
48
+ const checkboxItemState = useMenuCheckboxItem(
49
+ {
50
+ checked: box.with(
51
+ () => checked,
52
+ (v) => {
53
+ checked = v;
54
+ onCheckedChange(v);
55
+ }
56
+ ),
57
+ id: box.with(() => id),
58
+ disabled: box.with(() => disabled),
59
+ onSelect: box.with(() => handleSelect),
60
+ ref: box.with(
61
+ () => ref,
62
+ (v) => (ref = v)
63
+ ),
64
+ closeOnSelect: box.with(() => closeOnSelect),
65
+ indeterminate: box.with(
66
+ () => indeterminate,
67
+ (v) => {
68
+ indeterminate = v;
69
+ onIndeterminateChange(v);
70
+ }
71
+ ),
72
+ value: box.with(() => value),
73
+ },
74
+ group
75
+ );
47
76
 
48
77
  function handleSelect(e: Event) {
49
78
  onSelect(e);
@@ -1,5 +1,6 @@
1
1
  export { default as Root } from "./components/menu.svelte";
2
2
  export { default as Arrow } from "./components/menu-arrow.svelte";
3
+ export { default as CheckboxGroup } from "./components/menu-checkbox-group.svelte";
3
4
  export { default as CheckboxItem } from "./components/menu-checkbox-item.svelte";
4
5
  export { default as Content } from "./components/menu-content.svelte";
5
6
  export { default as ContentStatic } from "./components/menu-content-static.svelte";
@@ -15,4 +16,4 @@ export { default as SubContent } from "./components/menu-sub-content.svelte";
15
16
  export { default as SubTrigger } from "./components/menu-sub-trigger.svelte";
16
17
  export { default as Trigger } from "./components/menu-trigger.svelte";
17
18
  export { default as SubContentStatic } from "./components/menu-sub-content-static.svelte";
18
- export type { MenuRootPropsWithoutHTML as RootProps, MenuContentProps as ContentProps, MenuContentStaticProps as ContentStaticProps, MenuItemProps as ItemProps, MenuTriggerProps as TriggerProps, MenuSubPropsWithoutHTML as SubProps, MenuSubContentProps as SubContentProps, MenuSubContentStaticProps as SubContentStaticProps, MenuSeparatorProps as SeparatorProps, MenuArrowProps as ArrowProps, MenuCheckboxItemProps as CheckboxItemProps, MenuGroupHeadingProps as GroupHeadingProps, MenuGroupProps as GroupProps, MenuRadioGroupProps as RadioGroupProps, MenuRadioItemProps as RadioItemProps, MenuSubTriggerProps as SubTriggerProps, MenuPortalProps as PortalProps, } from "./types.js";
19
+ export type { MenuRootPropsWithoutHTML as RootProps, MenuContentProps as ContentProps, MenuContentStaticProps as ContentStaticProps, MenuItemProps as ItemProps, MenuTriggerProps as TriggerProps, MenuSubPropsWithoutHTML as SubProps, MenuSubContentProps as SubContentProps, MenuSubContentStaticProps as SubContentStaticProps, MenuSeparatorProps as SeparatorProps, MenuArrowProps as ArrowProps, MenuCheckboxGroupProps as CheckboxGroupProps, MenuCheckboxItemProps as CheckboxItemProps, MenuGroupHeadingProps as GroupHeadingProps, MenuGroupProps as GroupProps, MenuRadioGroupProps as RadioGroupProps, MenuRadioItemProps as RadioItemProps, MenuSubTriggerProps as SubTriggerProps, MenuPortalProps as PortalProps, } from "./types.js";
@@ -1,5 +1,6 @@
1
1
  export { default as Root } from "./components/menu.svelte";
2
2
  export { default as Arrow } from "./components/menu-arrow.svelte";
3
+ export { default as CheckboxGroup } from "./components/menu-checkbox-group.svelte";
3
4
  export { default as CheckboxItem } from "./components/menu-checkbox-item.svelte";
4
5
  export { default as Content } from "./components/menu-content.svelte";
5
6
  export { default as ContentStatic } from "./components/menu-content-static.svelte";
@@ -1,3 +1,4 @@
1
+ import { Context } from "runed";
1
2
  import type { ReadableBoxedValues, WritableBoxedValues } from "../../internal/box.svelte.js";
2
3
  import { CustomEventDispatcher } from "../../internal/events.js";
3
4
  import type { AnyFn, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, WithRefProps } from "../../internal/types.js";
@@ -5,6 +6,7 @@ import { useRovingFocus } from "../../internal/use-roving-focus.svelte.js";
5
6
  import type { Direction } from "../../shared/index.js";
6
7
  import { IsUsingKeyboard } from "../../index.js";
7
8
  export declare const CONTEXT_MENU_TRIGGER_ATTR = "data-context-menu-trigger";
9
+ export declare const MenuCheckboxGroupContext: Context<MenuCheckboxGroupState>;
8
10
  type MenuVariant = "context-menu" | "dropdown-menu" | "menubar";
9
11
  export type MenuRootStateProps = ReadableBoxedValues<{
10
12
  dir: Direction;
@@ -184,11 +186,14 @@ declare class MenuSubTriggerState {
184
186
  type MenuCheckboxItemStateProps = WritableBoxedValues<{
185
187
  checked: boolean;
186
188
  indeterminate: boolean;
189
+ }> & ReadableBoxedValues<{
190
+ value: string;
187
191
  }>;
188
192
  declare class MenuCheckboxItemState {
189
193
  readonly opts: MenuCheckboxItemStateProps;
190
194
  readonly item: MenuItemState;
191
- constructor(opts: MenuCheckboxItemStateProps, item: MenuItemState);
195
+ readonly group: MenuCheckboxGroupState | null;
196
+ constructor(opts: MenuCheckboxItemStateProps, item: MenuItemState, group?: MenuCheckboxGroupState | null);
192
197
  toggleChecked(): void;
193
198
  snippetProps: {
194
199
  checked: boolean;
@@ -231,8 +236,8 @@ declare class MenuGroupState {
231
236
  type MenuGroupHeadingStateProps = WithRefProps;
232
237
  declare class MenuGroupHeadingState {
233
238
  readonly opts: MenuGroupHeadingStateProps;
234
- readonly group: MenuGroupState | MenuRadioGroupState;
235
- constructor(opts: MenuGroupHeadingStateProps, group: MenuGroupState | MenuRadioGroupState);
239
+ readonly group: MenuGroupState | MenuRadioGroupState | MenuCheckboxGroupState;
240
+ constructor(opts: MenuGroupHeadingStateProps, group: MenuGroupState | MenuRadioGroupState | MenuCheckboxGroupState);
236
241
  props: {
237
242
  readonly [x: string]: string;
238
243
  readonly id: string;
@@ -360,6 +365,26 @@ declare class ContextMenuTriggerState {
360
365
  readonly oncontextmenu: (e: BitsMouseEvent) => void;
361
366
  };
362
367
  }
368
+ type MenuCheckboxGroupStateProps = WithRefProps & ReadableBoxedValues<{
369
+ onValueChange: (value: string[]) => void;
370
+ }> & WritableBoxedValues<{
371
+ value: string[];
372
+ }>;
373
+ declare class MenuCheckboxGroupState {
374
+ readonly opts: MenuCheckboxGroupStateProps;
375
+ readonly content: MenuContentState;
376
+ groupHeadingId: string | null;
377
+ root: MenuRootState;
378
+ constructor(opts: MenuCheckboxGroupStateProps, content: MenuContentState);
379
+ addValue(checkboxValue: string | undefined): void;
380
+ removeValue(checkboxValue: string | undefined): void;
381
+ props: {
382
+ readonly [x: string]: string | null;
383
+ readonly id: string;
384
+ readonly role: "group";
385
+ readonly "aria-labelledby": string | null;
386
+ };
387
+ }
363
388
  type MenuItemCombinedProps = MenuItemSharedStateProps & MenuItemStateProps;
364
389
  export declare function useMenuRoot(props: MenuRootStateProps): MenuRootState;
365
390
  export declare function useMenuMenu(root: MenuRootState, props: MenuMenuStateProps): MenuMenuState;
@@ -369,11 +394,12 @@ export declare function useMenuDropdownTrigger(props: DropdownMenuTriggerStatePr
369
394
  export declare function useMenuContextTrigger(props: ContextMenuTriggerStateProps): ContextMenuTriggerState;
370
395
  export declare function useMenuContent(props: MenuContentStateProps): MenuContentState;
371
396
  export declare function useMenuItem(props: MenuItemCombinedProps): MenuItemState;
372
- export declare function useMenuCheckboxItem(props: MenuItemCombinedProps & MenuCheckboxItemStateProps): MenuCheckboxItemState;
397
+ export declare function useMenuCheckboxItem(props: MenuItemCombinedProps & MenuCheckboxItemStateProps, checkboxGroup: MenuCheckboxGroupState | null): MenuCheckboxItemState;
373
398
  export declare function useMenuRadioGroup(props: MenuRadioGroupStateProps): MenuGroupState | MenuRadioGroupState;
374
399
  export declare function useMenuRadioItem(props: MenuRadioItemStateProps & MenuItemCombinedProps): MenuRadioItemState;
375
400
  export declare function useMenuGroup(props: MenuGroupStateProps): MenuGroupState | MenuRadioGroupState;
376
401
  export declare function useMenuGroupHeading(props: MenuGroupHeadingStateProps): MenuGroupHeadingState;
377
402
  export declare function useMenuSeparator(props: MenuSeparatorStateProps): MenuSeparatorState;
378
403
  export declare function useMenuArrow(): MenuArrowState;
404
+ export declare function useMenuCheckboxGroup(props: MenuCheckboxGroupStateProps): MenuCheckboxGroupState;
379
405
  export {};
@@ -19,6 +19,7 @@ const MenuMenuContext = new Context("Menu.Root | Menu.Sub");
19
19
  const MenuContentContext = new Context("Menu.Content");
20
20
  const MenuGroupContext = new Context("Menu.Group | Menu.RadioGroup");
21
21
  const MenuRadioGroupContext = new Context("Menu.RadioGroup");
22
+ export const MenuCheckboxGroupContext = new Context("Menu.CheckboxGroup");
22
23
  export const MenuOpenEvent = new CustomEventDispatcher("bitsmenuopen", {
23
24
  bubbles: false,
24
25
  cancelable: true,
@@ -534,9 +535,26 @@ class MenuSubTriggerState {
534
535
  class MenuCheckboxItemState {
535
536
  opts;
536
537
  item;
537
- constructor(opts, item) {
538
+ group;
539
+ constructor(opts, item, group = null) {
538
540
  this.opts = opts;
539
541
  this.item = item;
542
+ this.group = group;
543
+ // Watch for value changes in the group if we're part of one
544
+ if (this.group) {
545
+ watch(() => this.group.opts.value.current, (groupValues) => {
546
+ this.opts.checked.current = groupValues.includes(this.opts.value.current);
547
+ });
548
+ // Watch for checked state changes and sync with group
549
+ watch(() => this.opts.checked.current, (checked) => {
550
+ if (checked) {
551
+ this.group.addValue(this.opts.value.current);
552
+ }
553
+ else {
554
+ this.group.removeValue(this.opts.value.current);
555
+ }
556
+ });
557
+ }
540
558
  }
541
559
  toggleChecked() {
542
560
  if (this.opts.indeterminate.current) {
@@ -818,6 +836,43 @@ class ContextMenuTriggerState {
818
836
  oncontextmenu: this.oncontextmenu,
819
837
  }));
820
838
  }
839
+ class MenuCheckboxGroupState {
840
+ opts;
841
+ content;
842
+ groupHeadingId = $state(null);
843
+ root;
844
+ constructor(opts, content) {
845
+ this.opts = opts;
846
+ this.content = content;
847
+ this.root = content.parentMenu.root;
848
+ useRefById(opts);
849
+ }
850
+ addValue(checkboxValue) {
851
+ if (!checkboxValue)
852
+ return;
853
+ if (!this.opts.value.current.includes(checkboxValue)) {
854
+ const newValue = [...$state.snapshot(this.opts.value.current), checkboxValue];
855
+ this.opts.value.current = newValue;
856
+ this.opts.onValueChange.current(newValue);
857
+ }
858
+ }
859
+ removeValue(checkboxValue) {
860
+ if (!checkboxValue)
861
+ return;
862
+ const index = this.opts.value.current.indexOf(checkboxValue);
863
+ if (index === -1)
864
+ return;
865
+ const newValue = this.opts.value.current.filter((v) => v !== checkboxValue);
866
+ this.opts.value.current = newValue;
867
+ this.opts.onValueChange.current(newValue);
868
+ }
869
+ props = $derived.by(() => ({
870
+ id: this.opts.id.current,
871
+ [this.root.getAttr("checkbox-group")]: "",
872
+ role: "group",
873
+ "aria-labelledby": this.groupHeadingId,
874
+ }));
875
+ }
821
876
  export function useMenuRoot(props) {
822
877
  const root = new MenuRootState(props);
823
878
  FocusScopeContext.set({
@@ -853,9 +908,9 @@ export function useMenuItem(props) {
853
908
  const item = new MenuItemSharedState(props, MenuContentContext.get());
854
909
  return new MenuItemState(props, item);
855
910
  }
856
- export function useMenuCheckboxItem(props) {
911
+ export function useMenuCheckboxItem(props, checkboxGroup) {
857
912
  const item = new MenuItemState(props, new MenuItemSharedState(props, MenuContentContext.get()));
858
- return new MenuCheckboxItemState(props, item);
913
+ return new MenuCheckboxItemState(props, item, checkboxGroup);
859
914
  }
860
915
  export function useMenuRadioGroup(props) {
861
916
  return MenuGroupContext.set(MenuRadioGroupContext.set(new MenuRadioGroupState(props, MenuContentContext.get())));
@@ -870,6 +925,13 @@ export function useMenuGroup(props) {
870
925
  return MenuGroupContext.set(new MenuGroupState(props, MenuRootContext.get()));
871
926
  }
872
927
  export function useMenuGroupHeading(props) {
928
+ // Try to get checkbox group first, then radio group, then regular group
929
+ const checkboxGroup = MenuCheckboxGroupContext.getOr(null);
930
+ if (checkboxGroup)
931
+ return new MenuGroupHeadingState(props, checkboxGroup);
932
+ const radioGroup = MenuRadioGroupContext.getOr(null);
933
+ if (radioGroup)
934
+ return new MenuGroupHeadingState(props, radioGroup);
873
935
  return new MenuGroupHeadingState(props, MenuGroupContext.get());
874
936
  }
875
937
  export function useMenuSeparator(props) {
@@ -878,3 +940,6 @@ export function useMenuSeparator(props) {
878
940
  export function useMenuArrow() {
879
941
  return new MenuArrowState(MenuRootContext.get());
880
942
  }
943
+ export function useMenuCheckboxGroup(props) {
944
+ return MenuCheckboxGroupContext.set(new MenuCheckboxGroupState(props, MenuContentContext.get()));
945
+ }
@@ -98,8 +98,25 @@ export type MenuCheckboxItemPropsWithoutHTML = MenuItemPropsWithoutHTML<MenuChec
98
98
  * @defaultValue true
99
99
  */
100
100
  closeOnSelect?: boolean;
101
+ /**
102
+ * The value of the checkbox item when used in a checkbox group.
103
+ */
104
+ value?: string;
101
105
  };
102
106
  export type MenuCheckboxItemProps = MenuCheckboxItemPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, MenuCheckboxItemPropsWithoutHTML>;
107
+ export type MenuCheckboxGroupPropsWithoutHTML = WithChild<{
108
+ /**
109
+ * The values of the selected checkbox items.
110
+ *
111
+ * Supports two-way binding with `bind:value`.
112
+ */
113
+ value?: string[];
114
+ /**
115
+ * A callback that is fired when the selected checkbox items change.
116
+ */
117
+ onValueChange?: OnChangeFn<string[]>;
118
+ }>;
119
+ export type MenuCheckboxGroupProps = MenuCheckboxGroupPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, MenuCheckboxGroupPropsWithoutHTML>;
103
120
  export type MenuTriggerPropsWithoutHTML = WithChild<{
104
121
  /**
105
122
  * Whether the trigger is disabled.
@@ -16,5 +16,6 @@ export { default as SubTrigger } from "../menu/components/menu-sub-trigger.svelt
16
16
  export { default as RadioGroup } from "../menu/components/menu-radio-group.svelte";
17
17
  export { default as CheckboxItem } from "../menu/components/menu-checkbox-item.svelte";
18
18
  export { default as Portal } from "../utilities/portal/portal.svelte";
19
+ export { default as CheckboxGroup } from "../menu/components/menu-checkbox-group.svelte";
19
20
  export type { MenubarRootProps as RootProps, MenubarMenuProps as MenuProps, MenubarTriggerProps as TriggerProps, MenubarContentProps as ContentProps, MenubarContentStaticProps as ContentStaticProps, MenubarPortalProps as PortalProps, } from "./types.js";
20
- export type { MenuSubPropsWithoutHTML as SubProps, MenuItemProps as ItemProps, MenuGroupProps as GroupProps, MenuGroupHeadingProps as GroupHeadingProps, MenuArrowProps as ArrowProps, MenuRadioItemProps as RadioItemProps, MenuSeparatorProps as SeparatorProps, MenuSubContentProps as SubContentProps, MenuSubTriggerProps as SubTriggerProps, MenuRadioGroupProps as RadioGroupProps, MenuCheckboxItemProps as CheckboxItemProps, MenuSubContentStaticProps as SubContentStaticProps, } from "../menu/types.js";
21
+ export type { MenuSubPropsWithoutHTML as SubProps, MenuItemProps as ItemProps, MenuGroupProps as GroupProps, MenuGroupHeadingProps as GroupHeadingProps, MenuArrowProps as ArrowProps, MenuRadioItemProps as RadioItemProps, MenuSeparatorProps as SeparatorProps, MenuSubContentProps as SubContentProps, MenuSubTriggerProps as SubTriggerProps, MenuRadioGroupProps as RadioGroupProps, MenuCheckboxItemProps as CheckboxItemProps, MenuSubContentStaticProps as SubContentStaticProps, MenuCheckboxGroupProps as CheckboxGroupProps, } from "../menu/types.js";
@@ -16,3 +16,4 @@ export { default as SubTrigger } from "../menu/components/menu-sub-trigger.svelt
16
16
  export { default as RadioGroup } from "../menu/components/menu-radio-group.svelte";
17
17
  export { default as CheckboxItem } from "../menu/components/menu-checkbox-item.svelte";
18
18
  export { default as Portal } from "../utilities/portal/portal.svelte";
19
+ export { default as CheckboxGroup } from "../menu/components/menu-checkbox-group.svelte";
@@ -44,6 +44,6 @@ export type MenubarTriggerPropsWithoutHTML = WithChild<{
44
44
  disabled?: boolean | null | undefined;
45
45
  }>;
46
46
  export type MenubarTriggerProps = MenubarTriggerPropsWithoutHTML & Without<BitsPrimitiveButtonAttributes, MenubarTriggerPropsWithoutHTML>;
47
- export type { MenuContentPropsWithoutHTML as MenubarContentPropsWithoutHTML, MenuContentProps as MenubarContentProps, MenuContentStaticPropsWithoutHTML as MenubarContentStaticPropsWithoutHTML, MenuContentStaticProps as MenubarContentStaticProps, MenuItemPropsWithoutHTML as MenubarItemPropsWithoutHTML, MenuItemProps as MenubarItemProps, MenuGroupPropsWithoutHTML as MenubarGroupPropsWithoutHTML, MenuGroupProps as MenubarGroupProps, MenuGroupHeadingPropsWithoutHTML as MenubarGroupHeadingPropsWithoutHTML, MenuGroupHeadingProps as MenubarGroupHeadingProps, MenuCheckboxItemPropsWithoutHTML as MenubarCheckboxItemPropsWithoutHTML, MenuCheckboxItemProps as MenubarCheckboxItemProps, MenuRadioGroupPropsWithoutHTML as MenubarRadioGroupPropsWithoutHTML, MenuRadioGroupProps as MenubarRadioGroupProps, MenuRadioItemPropsWithoutHTML as MenubarRadioItemPropsWithoutHTML, MenuRadioItemProps as MenubarRadioItemProps, MenuSeparatorPropsWithoutHTML as MenubarSeparatorPropsWithoutHTML, MenuSeparatorProps as MenubarSeparatorProps, MenuSubContentPropsWithoutHTML as MenubarSubContentPropsWithoutHTML, MenuSubContentProps as MenubarSubContentProps, MenuSubContentStaticPropsWithoutHTML as MenubarSubContentStaticPropsWithoutHTML, MenuSubContentStaticProps as MenubarSubContentStaticProps, MenuSubTriggerPropsWithoutHTML as MenubarSubTriggerPropsWithoutHTML, MenuSubTriggerProps as MenubarSubTriggerProps, MenuSubPropsWithoutHTML as MenubarSubPropsWithoutHTML, MenuPortalPropsWithoutHTML as MenubarPortalPropsWithoutHTML, MenuPortalProps as MenubarPortalProps, } from "../menu/types.js";
47
+ export type { MenuContentPropsWithoutHTML as MenubarContentPropsWithoutHTML, MenuContentProps as MenubarContentProps, MenuContentStaticPropsWithoutHTML as MenubarContentStaticPropsWithoutHTML, MenuContentStaticProps as MenubarContentStaticProps, MenuItemPropsWithoutHTML as MenubarItemPropsWithoutHTML, MenuItemProps as MenubarItemProps, MenuGroupPropsWithoutHTML as MenubarGroupPropsWithoutHTML, MenuGroupProps as MenubarGroupProps, MenuGroupHeadingPropsWithoutHTML as MenubarGroupHeadingPropsWithoutHTML, MenuGroupHeadingProps as MenubarGroupHeadingProps, MenuCheckboxItemPropsWithoutHTML as MenubarCheckboxItemPropsWithoutHTML, MenuCheckboxItemProps as MenubarCheckboxItemProps, MenuRadioGroupPropsWithoutHTML as MenubarRadioGroupPropsWithoutHTML, MenuRadioGroupProps as MenubarRadioGroupProps, MenuRadioItemPropsWithoutHTML as MenubarRadioItemPropsWithoutHTML, MenuRadioItemProps as MenubarRadioItemProps, MenuSeparatorPropsWithoutHTML as MenubarSeparatorPropsWithoutHTML, MenuSeparatorProps as MenubarSeparatorProps, MenuSubContentPropsWithoutHTML as MenubarSubContentPropsWithoutHTML, MenuSubContentProps as MenubarSubContentProps, MenuSubContentStaticPropsWithoutHTML as MenubarSubContentStaticPropsWithoutHTML, MenuSubContentStaticProps as MenubarSubContentStaticProps, MenuSubTriggerPropsWithoutHTML as MenubarSubTriggerPropsWithoutHTML, MenuSubTriggerProps as MenubarSubTriggerProps, MenuSubPropsWithoutHTML as MenubarSubPropsWithoutHTML, MenuPortalPropsWithoutHTML as MenubarPortalPropsWithoutHTML, MenuPortalProps as MenubarPortalProps, MenuCheckboxGroupPropsWithoutHTML as MenubarCheckboxGroupPropsWithoutHTML, MenuCheckboxGroupProps as MenubarCheckboxGroupProps, } from "../menu/types.js";
48
48
  export type MenubarArrowPropsWithoutHTML = ArrowPropsWithoutHTML;
49
49
  export type MenubarArrowProps = MenuArrowProps;
@@ -27,7 +27,7 @@
27
27
  </script>
28
28
 
29
29
  {#if scrollButtonState.canScrollDown}
30
- <Mounted bind:mounted={scrollButtonState.state.mounted} />
30
+ <Mounted bind:mounted={scrollButtonState.scrollButtonState.mounted} />
31
31
  {#if child}
32
32
  {@render child({ props: restProps })}
33
33
  {:else}
@@ -27,7 +27,7 @@
27
27
  </script>
28
28
 
29
29
  {#if scrollButtonState.canScrollUp}
30
- <Mounted bind:mounted={scrollButtonState.state.mounted} />
30
+ <Mounted bind:mounted={scrollButtonState.scrollButtonState.mounted} />
31
31
  {#if child}
32
32
  {@render child({ props: restProps })}
33
33
  {:else}
@@ -334,12 +334,12 @@ declare class SelectScrollButtonImplState {
334
334
  };
335
335
  }
336
336
  declare class SelectScrollDownButtonState {
337
- readonly state: SelectScrollButtonImplState;
337
+ readonly scrollButtonState: SelectScrollButtonImplState;
338
338
  content: SelectContentState;
339
339
  root: SelectBaseRootState;
340
340
  canScrollDown: boolean;
341
341
  scrollIntoViewTimer: ReturnType<typeof globalThis.setTimeout> | null;
342
- constructor(state: SelectScrollButtonImplState);
342
+ constructor(scrollButtonState: SelectScrollButtonImplState);
343
343
  /**
344
344
  * @param manual - if true, it means the function was invoked manually outside of an event
345
345
  * listener, so we don't call `handleUserScroll` to prevent the auto scroll from kicking in.
@@ -358,11 +358,11 @@ declare class SelectScrollDownButtonState {
358
358
  };
359
359
  }
360
360
  declare class SelectScrollUpButtonState {
361
- readonly state: SelectScrollButtonImplState;
361
+ readonly scrollButtonState: SelectScrollButtonImplState;
362
362
  content: SelectContentState;
363
363
  root: SelectBaseRootState;
364
364
  canScrollUp: boolean;
365
- constructor(state: SelectScrollButtonImplState);
365
+ constructor(scrollButtonState: SelectScrollButtonImplState);
366
366
  /**
367
367
  * @param manual - if true, it means the function was invoked manually outside of an event
368
368
  * listener, so we don't call `handleUserScroll` to prevent the auto scroll from kicking in.
@@ -705,7 +705,11 @@ class SelectContentState {
705
705
  trapFocus: false,
706
706
  loop: false,
707
707
  onPlaced: () => {
708
- this.isPositioned = true;
708
+ // onPlaced is also called when the menu is closed, so we need to check if the menu
709
+ // is actually open to avoid setting positioning to true when the menu is closed
710
+ if (this.root.opts.open.current) {
711
+ this.isPositioned = true;
712
+ }
709
713
  },
710
714
  };
711
715
  }
@@ -993,25 +997,24 @@ class SelectScrollButtonImplState {
993
997
  }));
994
998
  }
995
999
  class SelectScrollDownButtonState {
996
- state;
1000
+ scrollButtonState;
997
1001
  content;
998
1002
  root;
999
1003
  canScrollDown = $state(false);
1000
1004
  scrollIntoViewTimer = null;
1001
- constructor(state) {
1002
- this.state = state;
1003
- this.content = state.content;
1004
- this.root = state.root;
1005
- this.state.onAutoScroll = this.handleAutoScroll;
1005
+ constructor(scrollButtonState) {
1006
+ this.scrollButtonState = scrollButtonState;
1007
+ this.content = scrollButtonState.content;
1008
+ this.root = scrollButtonState.root;
1009
+ this.scrollButtonState.onAutoScroll = this.handleAutoScroll;
1006
1010
  watch([() => this.content.viewportNode, () => this.content.isPositioned], () => {
1007
- if (!this.content.viewportNode || !this.content.isPositioned) {
1011
+ if (!this.content.viewportNode || !this.content.isPositioned)
1008
1012
  return;
1009
- }
1010
1013
  this.handleScroll(true);
1011
1014
  return on(this.content.viewportNode, "scroll", () => this.handleScroll());
1012
1015
  });
1013
- watch(() => this.state.mounted, () => {
1014
- if (!this.state.mounted)
1016
+ watch(() => this.scrollButtonState.mounted, () => {
1017
+ if (!this.scrollButtonState.mounted)
1015
1018
  return;
1016
1019
  if (this.scrollIntoViewTimer) {
1017
1020
  clearTimeout(this.scrollIntoViewTimer);
@@ -1028,7 +1031,7 @@ class SelectScrollDownButtonState {
1028
1031
  */
1029
1032
  handleScroll = (manual = false) => {
1030
1033
  if (!manual) {
1031
- this.state.handleUserScroll();
1034
+ this.scrollButtonState.handleUserScroll();
1032
1035
  }
1033
1036
  if (!this.content.viewportNode)
1034
1037
  return;
@@ -1044,18 +1047,21 @@ class SelectScrollDownButtonState {
1044
1047
  return;
1045
1048
  viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
1046
1049
  };
1047
- props = $derived.by(() => ({ ...this.state.props, [this.root.bitsAttrs["scroll-down-button"]]: "" }));
1050
+ props = $derived.by(() => ({
1051
+ ...this.scrollButtonState.props,
1052
+ [this.root.bitsAttrs["scroll-down-button"]]: "",
1053
+ }));
1048
1054
  }
1049
1055
  class SelectScrollUpButtonState {
1050
- state;
1056
+ scrollButtonState;
1051
1057
  content;
1052
1058
  root;
1053
1059
  canScrollUp = $state(false);
1054
- constructor(state) {
1055
- this.state = state;
1056
- this.content = state.content;
1057
- this.root = state.root;
1058
- this.state.onAutoScroll = this.handleAutoScroll;
1060
+ constructor(scrollButtonState) {
1061
+ this.scrollButtonState = scrollButtonState;
1062
+ this.content = scrollButtonState.content;
1063
+ this.root = scrollButtonState.root;
1064
+ this.scrollButtonState.onAutoScroll = this.handleAutoScroll;
1059
1065
  watch([() => this.content.viewportNode, () => this.content.isPositioned], () => {
1060
1066
  if (!this.content.viewportNode || !this.content.isPositioned)
1061
1067
  return;
@@ -1069,7 +1075,7 @@ class SelectScrollUpButtonState {
1069
1075
  */
1070
1076
  handleScroll = (manual = false) => {
1071
1077
  if (!manual) {
1072
- this.state.handleUserScroll();
1078
+ this.scrollButtonState.handleUserScroll();
1073
1079
  }
1074
1080
  if (!this.content.viewportNode)
1075
1081
  return;
@@ -1082,7 +1088,10 @@ class SelectScrollUpButtonState {
1082
1088
  this.content.viewportNode.scrollTop =
1083
1089
  this.content.viewportNode.scrollTop - this.root.highlightedNode.offsetHeight;
1084
1090
  };
1085
- props = $derived.by(() => ({ ...this.state.props, [this.root.bitsAttrs["scroll-up-button"]]: "" }));
1091
+ props = $derived.by(() => ({
1092
+ ...this.scrollButtonState.props,
1093
+ [this.root.bitsAttrs["scroll-up-button"]]: "",
1094
+ }));
1086
1095
  }
1087
1096
  const SelectRootContext = new Context("Select.Root | Combobox.Root");
1088
1097
  const SelectGroupContext = new Context("Select.Group | Combobox.Group");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",