This commit is contained in:
eewing
2026-02-17 14:10:16 -06:00
parent 2bca5834c5
commit cf73cd3b4c
11246 changed files with 1690552 additions and 0 deletions
@@ -0,0 +1,38 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { MenubarContentStaticProps } from "../types.js";
import { MenubarContentState } from "../menubar.svelte.js";
import { createId } from "../../../internal/create-id.js";
import MenuContentStatic from "../../menu/components/menu-content-static.svelte";
import { noop } from "../../../internal/noop.js";
const uid = $props.id();
let {
ref = $bindable(null),
interactOutsideBehavior = "close",
id = createId(uid),
onInteractOutside = noop,
onCloseAutoFocus = noop,
onFocusOutside = noop,
onOpenAutoFocus = noop,
...restProps
}: MenubarContentStaticProps = $props();
const contentState = MenubarContentState.create({
id: boxWith(() => id),
interactOutsideBehavior: boxWith(() => interactOutsideBehavior),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
onInteractOutside: boxWith(() => onInteractOutside),
onFocusOutside: boxWith(() => onFocusOutside),
onCloseAutoFocus: boxWith(() => onCloseAutoFocus),
onOpenAutoFocus: boxWith(() => onOpenAutoFocus),
});
const mergedProps = $derived(mergeProps(restProps, contentState.props));
</script>
<MenuContentStatic bind:ref {...mergedProps} {...contentState.popperProps} preventScroll={false} />
@@ -0,0 +1,4 @@
import type { MenubarContentStaticProps } from "../types.js";
declare const MenubarContentStatic: import("svelte").Component<MenubarContentStaticProps, {}, "ref">;
type MenubarContentStatic = ReturnType<typeof MenubarContentStatic>;
export default MenubarContentStatic;
@@ -0,0 +1,38 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { MenubarContentProps } from "../types.js";
import { MenubarContentState } from "../menubar.svelte.js";
import MenuContent from "../../menu/components/menu-content.svelte";
import { createId } from "../../../internal/create-id.js";
import { noop } from "../../../internal/noop.js";
const uid = $props.id();
let {
ref = $bindable(null),
interactOutsideBehavior = "close",
id = createId(uid),
onInteractOutside = noop,
onFocusOutside = noop,
onCloseAutoFocus = noop,
onOpenAutoFocus = noop,
...restProps
}: MenubarContentProps = $props();
const contentState = MenubarContentState.create({
id: boxWith(() => id),
interactOutsideBehavior: boxWith(() => interactOutsideBehavior),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
onInteractOutside: boxWith(() => onInteractOutside),
onFocusOutside: boxWith(() => onFocusOutside),
onCloseAutoFocus: boxWith(() => onCloseAutoFocus),
onOpenAutoFocus: boxWith(() => onOpenAutoFocus),
});
const mergedProps = $derived(mergeProps(restProps, contentState.props));
</script>
<MenuContent bind:ref {...mergedProps} {...contentState.popperProps} preventScroll={false} />
@@ -0,0 +1,4 @@
import type { MenubarContentProps } from "../types.js";
declare const MenubarContent: import("svelte").Component<MenubarContentProps, {}, "ref">;
type MenubarContent = ReturnType<typeof MenubarContent>;
export default MenubarContent;
+27
View File
@@ -0,0 +1,27 @@
<script lang="ts">
import { boxWith } from "svelte-toolbelt";
import type { MenubarMenuProps } from "../types.js";
import { MenubarMenuState } from "../menubar.svelte.js";
import Menu from "../../menu/components/menu.svelte";
import { noop } from "../../../internal/noop.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let { value = createId(uid), onOpenChange = noop, ...restProps }: MenubarMenuProps = $props();
const menuState = MenubarMenuState.create({
value: boxWith(() => value),
onOpenChange: boxWith(() => onOpenChange),
});
</script>
<Menu
open={menuState.open}
onOpenChange={(open) => {
if (!open) menuState.root.onMenuClose();
}}
dir={menuState.root.opts.dir.current}
_internal_variant="menubar"
{...restProps}
/>
@@ -0,0 +1,3 @@
declare const MenubarMenu: import("svelte").Component<import("../types.js").MenubarMenuPropsWithoutHTML, {}, "">;
type MenubarMenu = ReturnType<typeof MenubarMenu>;
export default MenubarMenu;
@@ -0,0 +1,49 @@
<script lang="ts">
import { attachRef, boxWith, mergeProps } from "svelte-toolbelt";
import type { MenubarTriggerProps } from "../types.js";
import { MenubarTriggerState } from "../menubar.svelte.js";
import { createId } from "../../../internal/create-id.js";
import FloatingLayerAnchor from "../../utilities/floating-layer/components/floating-layer-anchor.svelte";
import { DropdownMenuTriggerState } from "../../menu/menu.svelte.js";
const uid = $props.id();
let {
id = createId(uid),
disabled = false,
children,
child,
ref = $bindable(null),
...restProps
}: MenubarTriggerProps = $props();
const triggerState = MenubarTriggerState.create({
id: boxWith(() => id),
disabled: boxWith(() => disabled ?? false),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const dropdownTriggerState = DropdownMenuTriggerState.create(triggerState.opts);
const triggerAttachment = attachRef(
(v: HTMLElement | null) => (dropdownTriggerState.parentMenu.triggerNode = v)
);
const mergedProps = $derived(
mergeProps(restProps, triggerState.props, {
...triggerAttachment,
})
);
</script>
<FloatingLayerAnchor {id} ref={triggerState.opts.ref}>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<button {...mergedProps}>
{@render children?.()}
</button>
{/if}
</FloatingLayerAnchor>
@@ -0,0 +1,4 @@
import type { MenubarTriggerProps } from "../types.js";
declare const MenubarTrigger: import("svelte").Component<MenubarTriggerProps, {}, "ref">;
type MenubarTrigger = ReturnType<typeof MenubarTrigger>;
export default MenubarTrigger;
+48
View File
@@ -0,0 +1,48 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { MenubarRootProps } from "../types.js";
import { MenubarRootState } from "../menubar.svelte.js";
import { createId } from "../../../internal/create-id.js";
import { noop } from "../../../internal/noop.js";
const uid = $props.id();
let {
id = createId(uid),
children,
child,
ref = $bindable(null),
value = $bindable(""),
dir = "ltr",
loop = true,
onValueChange = noop,
...restProps
}: MenubarRootProps = $props();
const rootState = MenubarRootState.create({
id: boxWith(() => id),
value: boxWith(
() => value,
(v) => {
value = v;
onValueChange?.(v);
}
),
dir: boxWith(() => dir),
loop: boxWith(() => loop),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, rootState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
@@ -0,0 +1,4 @@
import type { MenubarRootProps } from "../types.js";
declare const Menubar: import("svelte").Component<MenubarRootProps, {}, "value" | "ref">;
type Menubar = ReturnType<typeof Menubar>;
export default Menubar;