import type { Expand } from "svelte-toolbelt"; import type { PopperLayerProps, PopperLayerStaticProps } from "../utilities/popper-layer/types.js"; import type { ArrowProps, ArrowPropsWithoutHTML } from "../utilities/arrow/types.js"; import type { OnChangeFn, WithChild, WithChildNoChildrenSnippetProps, WithChildren, Without } from "../../internal/types.js"; import type { BitsPrimitiveButtonAttributes, BitsPrimitiveDivAttributes } from "../../shared/attributes.js"; import type { Direction } from "../../shared/index.js"; import type { PortalProps } from "../utilities/portal/types.js"; import type { FloatingContentSnippetProps, StaticContentSnippetProps } from "../../shared/types.js"; export type MenuRootPropsWithoutHTML = WithChildren<{ /** * The open state of the menu. */ open?: boolean; /** * A callback that is called when the menu is opened or closed. */ onOpenChange?: OnChangeFn; /** * A callback that is called when the menu is opened or closed. */ onOpenChangeComplete?: OnChangeFn; /** * The direction of the site. * * @defaultValue "ltr" */ dir?: Direction; }>; export type MenuRootProps = MenuRootPropsWithoutHTML; export type _SharedMenuContentProps = { /** * When `true`, the menu will loop through items when navigating with the keyboard. * * @defaultValue false */ loop?: boolean; }; export type MenuContentPropsWithoutHTML = Expand & _SharedMenuContentProps, FloatingContentSnippetProps>>; export type MenuContentProps = MenuContentPropsWithoutHTML & Without; export type MenuContentStaticPropsWithoutHTML = Expand & _SharedMenuContentProps, StaticContentSnippetProps>>; export type MenuContentStaticProps = MenuContentStaticPropsWithoutHTML & Without; export type MenuItemPropsWithoutHTML = { _default: never; }> = WithChild<{ /** * When `true`, the user will not be able to interact with the menu item. * * @defaultValue false */ disabled?: boolean; /** * Optional text to use for typeahead filtering. By default, typeahead will use * the `.textContent` of the menu item. When the content is more complex, you * can provide a string here instead. * * @defaultValue undefined */ textValue?: string; /** * A callback fired when the menu item is selected. * * Prevent default behavior of selection with `event.preventDefault()`. */ onSelect?: (event: Event) => void; /** * Whether or not the menu item should close when selected. * @defaultValue true */ closeOnSelect?: boolean; }, U>; export type MenuItemProps = MenuItemPropsWithoutHTML & Without; export type MenuCheckboxItemSnippetProps = { checked: boolean; indeterminate: boolean; }; export type MenuCheckboxItemPropsWithoutHTML = MenuItemPropsWithoutHTML & { /** * The checked state of the checkbox. It can be one of: * - `true` for checked * - `false` for unchecked * * @defaultValue false */ checked?: boolean; /** * A callback that is fired when the checked state changes. */ onCheckedChange?: OnChangeFn; /** * Whether the checkbox is in an indeterminate state or not. * * @defaultValue false */ indeterminate?: boolean; /** * A callback function called when the indeterminate state changes. */ onIndeterminateChange?: OnChangeFn; /** * Whether or not the menu item should close when selected. * * @defaultValue true */ closeOnSelect?: boolean; /** * The value of the checkbox item when used in a checkbox group. */ value?: string; }; export type MenuCheckboxItemProps = MenuCheckboxItemPropsWithoutHTML & Without; export type MenuCheckboxGroupPropsWithoutHTML = WithChild<{ /** * The values of the selected checkbox items. * * Supports two-way binding with `bind:value`. */ value?: string[]; /** * A callback that is fired when the selected checkbox items change. */ onValueChange?: OnChangeFn; }>; export type MenuCheckboxGroupProps = MenuCheckboxGroupPropsWithoutHTML & Without; export type MenuTriggerPropsWithoutHTML = WithChild<{ /** * Whether the trigger is disabled. * * @defaultValue false */ disabled?: boolean | null | undefined; }>; export type MenuTriggerProps = MenuTriggerPropsWithoutHTML & Without; export type MenuSubPropsWithoutHTML = WithChildren<{ /** * The open state of the menu. */ open?: boolean; /** * A callback that is called when the menu is opened or closed. */ onOpenChange?: OnChangeFn; /** * A callback that is called when the menu finishes opening/closing animations. */ onOpenChangeComplete?: OnChangeFn; }>; export type MenuSubProps = MenuSubPropsWithoutHTML; export type MenuSubContentPropsWithoutHTML = Expand & _SharedMenuContentProps, FloatingContentSnippetProps>>; export type MenuSubContentProps = MenuSubContentPropsWithoutHTML & Without; export type MenuSubContentStaticPropsWithoutHTML = Expand & _SharedMenuContentProps, StaticContentSnippetProps>>; export type MenuSubContentStaticProps = MenuSubContentStaticPropsWithoutHTML & Without; export type MenuSubTriggerPropsWithoutHTML = Omit & { /** * The amount of time in ms from when the mouse enters the subtrigger until * the submenu opens. This is useful for preventing the submenu from opening * as a user is moving their mouse through the menu without a true intention to open that * submenu. * * To disable the behavior, set it to `0`. * * @default 100 */ openDelay?: number; }; export type MenuSubTriggerProps = MenuSubTriggerPropsWithoutHTML & Without; export type MenuSeparatorPropsWithoutHTML = WithChild; export type MenuSeparatorProps = MenuSeparatorPropsWithoutHTML & Without; export type MenuArrowPropsWithoutHTML = ArrowPropsWithoutHTML; export type MenuArrowProps = ArrowProps; export type MenuGroupPropsWithoutHTML = WithChild; export type MenuGroupProps = MenuGroupPropsWithoutHTML & Without; export type MenuGroupHeadingPropsWithoutHTML = WithChild; export type MenuGroupHeadingProps = MenuGroupHeadingPropsWithoutHTML & Without; export type MenuRadioGroupPropsWithoutHTML = WithChild<{ /** * The value of the selected radio item. * * Supports two-way binding with `bind:value`. */ value?: string; /** * A callback that is fired when the selected radio item changes. */ onValueChange?: OnChangeFn; }>; export type MenuRadioGroupProps = MenuRadioGroupPropsWithoutHTML & Without; export type MenuRadioItemSnippetProps = { checked: boolean; }; export type MenuRadioItemPropsWithoutHTML = MenuItemPropsWithoutHTML & { /** * The value of the radio item. */ value: string; /** * Whether or not the menu item should close when selected. * @defaultValue true */ closeOnSelect?: boolean; }; export type MenuRadioItemProps = MenuRadioItemPropsWithoutHTML & Without; export type MenuPortalPropsWithoutHTML = PortalProps; export type MenuPortalProps = MenuPortalPropsWithoutHTML;