-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
next: update Svelte and other deps (#664)
- Loading branch information
Showing
99 changed files
with
2,303 additions
and
1,225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/bits-ui/src/lib/bits/context-menu/components/context-menu-content-static.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<script lang="ts"> | ||
import { box } from "svelte-toolbelt"; | ||
import type { ContentStaticProps } from "../index.js"; | ||
import { CONTEXT_MENU_TRIGGER_ATTR, useMenuContent } from "$lib/bits/menu/menu.svelte.js"; | ||
import { useId } from "$lib/internal/useId.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
import { noop } from "$lib/internal/callbacks.js"; | ||
import PopperLayer from "$lib/bits/utilities/popper-layer/popper-layer.svelte"; | ||
import { isElement } from "$lib/internal/is.js"; | ||
import type { InteractOutsideEvent } from "$lib/bits/utilities/dismissable-layer/types.js"; | ||
import Mounted from "$lib/bits/utilities/mounted.svelte"; | ||
let { | ||
id = useId(), | ||
child, | ||
children, | ||
ref = $bindable(null), | ||
loop = true, | ||
onInteractOutside = noop, | ||
// we need to explicitly pass this prop to the PopperLayer to override | ||
// the default menu behavior of handling outside interactions on the trigger | ||
onInteractOutsideStart = noop, | ||
onEscapeKeydown = noop, | ||
forceMount = false, | ||
...restProps | ||
}: ContentStaticProps = $props(); | ||
let isMounted = $state(false); | ||
const contentState = useMenuContent({ | ||
id: box.with(() => id), | ||
loop: box.with(() => loop), | ||
ref: box.with( | ||
() => ref, | ||
(v) => (ref = v) | ||
), | ||
isMounted: box.with(() => isMounted), | ||
}); | ||
function handleInteractOutsideStart(e: InteractOutsideEvent) { | ||
if (!isElement(e.target)) return; | ||
if (e.target.id === contentState.parentMenu.triggerNode?.id) { | ||
e.preventDefault(); | ||
return; | ||
} | ||
if (e.target.closest(`#${contentState.parentMenu.triggerNode?.id}`)) { | ||
e.preventDefault(); | ||
} | ||
} | ||
const mergedProps = $derived( | ||
mergeProps(restProps, contentState.props, { | ||
onInteractOutsideStart: handleInteractOutsideStart, | ||
}) | ||
); | ||
</script> | ||
|
||
<PopperLayer | ||
{...mergedProps} | ||
side="right" | ||
sideOffset={2} | ||
align="start" | ||
present={contentState.parentMenu.open.current || forceMount} | ||
{onInteractOutsideStart} | ||
onInteractOutside={(e) => { | ||
onInteractOutside(e); | ||
if (e.defaultPrevented) return; | ||
contentState.parentMenu.onClose(); | ||
}} | ||
onEscapeKeydown={(e) => { | ||
onEscapeKeydown(e); | ||
if (e.defaultPrevented) return; | ||
contentState.parentMenu.onClose(); | ||
}} | ||
isValidEvent={(e) => { | ||
if ("button" in e && e.button === 2) { | ||
const target = e.target as HTMLElement; | ||
if (!target) return false; | ||
const isAnotherContextTrigger = | ||
target.closest(`[${CONTEXT_MENU_TRIGGER_ATTR}]`) !== | ||
contentState.parentMenu.triggerNode; | ||
return isAnotherContextTrigger; | ||
} | ||
return false; | ||
}} | ||
trapFocus | ||
{loop} | ||
> | ||
{#snippet popper({ props })} | ||
{#if child} | ||
{@render child({ props })} | ||
{:else} | ||
<div {...props}> | ||
{@render children?.()} | ||
</div> | ||
{/if} | ||
<Mounted bind:isMounted /> | ||
{/snippet} | ||
</PopperLayer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/bits-ui/src/lib/bits/date-picker/components/date-picker-content-static.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script lang="ts"> | ||
import type { ContentStaticProps } from "../index.js"; | ||
import PopoverContentStatic from "$lib/bits/popover/components/popover-content-static.svelte"; | ||
import { pickerOpenFocus } from "$lib/shared/date/index.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
let { ref = $bindable(null), onMountAutoFocus, ...restProps }: ContentStaticProps = $props(); | ||
const mergedProps = $derived( | ||
mergeProps({ onMountAutoFocus }, { onMountAutoFocus: pickerOpenFocus }) | ||
) as any; | ||
</script> | ||
|
||
<PopoverContentStatic {...mergedProps} bind:ref {...restProps} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/bits-ui/src/lib/bits/dropdown-menu/components/dropdown-menu-content-static.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<script lang="ts"> | ||
import { box } from "svelte-toolbelt"; | ||
import type { ContentStaticProps } from "../index.js"; | ||
import { useMenuContent } from "$lib/bits/menu/menu.svelte.js"; | ||
import { useId } from "$lib/internal/useId.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
import { noop } from "$lib/internal/callbacks.js"; | ||
import PopperLayer from "$lib/bits/utilities/popper-layer/popper-layer.svelte"; | ||
import Mounted from "$lib/bits/utilities/mounted.svelte"; | ||
let { | ||
id = useId(), | ||
child, | ||
children, | ||
ref = $bindable(null), | ||
loop = true, | ||
onInteractOutside = noop, | ||
onEscapeKeydown = noop, | ||
forceMount = false, | ||
...restProps | ||
}: ContentStaticProps = $props(); | ||
let isMounted = $state(false); | ||
const contentState = useMenuContent({ | ||
id: box.with(() => id), | ||
loop: box.with(() => loop), | ||
ref: box.with( | ||
() => ref, | ||
(v) => (ref = v) | ||
), | ||
isMounted: box.with(() => isMounted), | ||
}); | ||
const mergedProps = $derived(mergeProps(restProps, contentState.props)); | ||
</script> | ||
|
||
<PopperLayer | ||
isStatic={true} | ||
{...mergedProps} | ||
present={contentState.parentMenu.open.current || forceMount} | ||
onInteractOutsideStart={(e) => { | ||
contentState.handleInteractOutside(e); | ||
}} | ||
onInteractOutside={(e) => { | ||
contentState.handleInteractOutside(e); | ||
if (e.defaultPrevented) return; | ||
onInteractOutside(e); | ||
contentState.parentMenu.onClose(); | ||
}} | ||
onEscapeKeydown={(e) => { | ||
onEscapeKeydown(e); | ||
if (e.defaultPrevented) return; | ||
contentState.parentMenu.onClose(); | ||
}} | ||
trapFocus | ||
{loop} | ||
> | ||
{#snippet popper({ props })} | ||
{@const finalProps = mergeProps(props)} | ||
{#if child} | ||
{@render child({ props: finalProps })} | ||
{:else} | ||
<div {...finalProps}> | ||
{@render children?.()} | ||
</div> | ||
{/if} | ||
<Mounted bind:isMounted /> | ||
{/snippet} | ||
</PopperLayer> |
Oops, something went wrong.