-
-
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.
- Loading branch information
Showing
51 changed files
with
1,434 additions
and
487 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
27 changes: 0 additions & 27 deletions
27
packages/bits-ui/src/lib/bits/popover/components/popover-arrow.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 |
---|---|---|
@@ -1,27 +0,0 @@ | ||
<script lang="ts"> | ||
import { melt } from "@melt-ui/svelte"; | ||
import { setArrow } from "../ctx.js"; | ||
import type { ArrowProps } from "../index.js"; | ||
type $$Props = ArrowProps; | ||
export let asChild: $$Props["asChild"] = false; | ||
export let el: $$Props["el"] = undefined; | ||
export let size = 8; | ||
const { | ||
elements: { arrow }, | ||
getAttrs, | ||
} = setArrow(size); | ||
const attrs = getAttrs("arrow"); | ||
$: builder = $arrow; | ||
$: Object.assign(builder, attrs); | ||
</script> | ||
|
||
{#if asChild} | ||
<slot {builder} /> | ||
{:else} | ||
<div bind:this={el} use:melt={builder} {...$$restProps} /> | ||
{/if} | ||
38 changes: 0 additions & 38 deletions
38
packages/bits-ui/src/lib/bits/popover/components/popover-close.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 |
---|---|---|
@@ -1,38 +0,0 @@ | ||
<script lang="ts"> | ||
import { melt } from "@melt-ui/svelte"; | ||
import { getCtx } from "../ctx.js"; | ||
import type { CloseEvents, CloseProps } from "../index.js"; | ||
import { createDispatcher } from "$lib/internal/events.js"; | ||
type $$Props = CloseProps; | ||
type $$Events = CloseEvents; | ||
export let asChild: $$Props["asChild"] = false; | ||
export let el: $$Props["el"] = undefined; | ||
const { | ||
elements: { close }, | ||
getAttrs, | ||
} = getCtx(); | ||
const dispatch = createDispatcher(); | ||
const attrs = getAttrs("close"); | ||
$: builder = $close; | ||
$: Object.assign(builder, attrs); | ||
</script> | ||
|
||
{#if asChild} | ||
<slot {builder} /> | ||
{:else} | ||
<button | ||
bind:this={el} | ||
use:melt={builder} | ||
type="button" | ||
{...$$restProps} | ||
on:m-click={dispatch} | ||
on:m-keydown={dispatch} | ||
> | ||
<slot {builder} /> | ||
</button> | ||
{/if} | ||
135 changes: 40 additions & 95 deletions
135
packages/bits-ui/src/lib/bits/popover/components/popover-content.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 |
---|---|---|
@@ -1,99 +1,44 @@ | ||
<script lang="ts"> | ||
import { melt } from "@melt-ui/svelte"; | ||
import { getCtx, updatePositioning } from "../ctx.js"; | ||
import type { ContentProps } from "../index.js"; | ||
import type { Transition } from "$lib/internal/index.js"; | ||
type T = $$Generic<Transition>; | ||
type In = $$Generic<Transition>; | ||
type Out = $$Generic<Transition>; | ||
type $$Props = ContentProps<T, In, Out>; | ||
export let transition: $$Props["transition"] = undefined; | ||
export let transitionConfig: $$Props["transitionConfig"] = undefined; | ||
export let inTransition: $$Props["inTransition"] = undefined; | ||
export let inTransitionConfig: $$Props["inTransitionConfig"] = undefined; | ||
export let outTransition: $$Props["outTransition"] = undefined; | ||
export let outTransitionConfig: $$Props["outTransitionConfig"] = undefined; | ||
export let asChild: $$Props["asChild"] = false; | ||
export let id: $$Props["id"] = undefined; | ||
export let side: $$Props["side"] = "bottom"; | ||
export let align: $$Props["align"] = "center"; | ||
export let sideOffset: $$Props["sideOffset"] = 0; | ||
export let alignOffset: $$Props["alignOffset"] = 0; | ||
export let collisionPadding: $$Props["collisionPadding"] = 8; | ||
export let avoidCollisions: $$Props["avoidCollisions"] = true; | ||
export let collisionBoundary: $$Props["collisionBoundary"] = undefined; | ||
export let sameWidth: $$Props["sameWidth"] = false; | ||
export let fitViewport: $$Props["fitViewport"] = false; | ||
export let strategy: $$Props["strategy"] = "absolute"; | ||
export let overlap: $$Props["overlap"] = false; | ||
export let el: $$Props["el"] = undefined; | ||
const { | ||
elements: { content }, | ||
states: { open }, | ||
ids, | ||
getAttrs, | ||
} = getCtx(); | ||
const attrs = getAttrs("content"); | ||
$: if (id) { | ||
ids.content.set(id); | ||
} | ||
$: builder = $content; | ||
$: Object.assign(builder, attrs); | ||
$: if ($open) { | ||
updatePositioning({ | ||
side, | ||
align, | ||
sideOffset, | ||
alignOffset, | ||
collisionPadding, | ||
avoidCollisions, | ||
collisionBoundary, | ||
sameWidth, | ||
fitViewport, | ||
strategy, | ||
overlap, | ||
}); | ||
} | ||
import { setPopoverContentState } from "../popover.svelte.js"; | ||
import { FloatingLayer, PresenceLayer } from "$lib/bits/utilities/index.js"; | ||
import { readonlyBox } from "$lib/internal/box.svelte.js"; | ||
import { generateId } from "$lib/internal/id.js"; | ||
let { | ||
asChild, | ||
child, | ||
children, | ||
el = $bindable(), | ||
style = {}, | ||
id = generateId(), | ||
forceMount = false, | ||
...restProps | ||
}: ContentProps = $props(); | ||
const state = setPopoverContentState({ | ||
id: readonlyBox(() => id), | ||
}); | ||
</script> | ||
|
||
{#if asChild && $open} | ||
<slot {builder} /> | ||
{:else if transition && $open} | ||
<div | ||
bind:this={el} | ||
transition:transition={transitionConfig} | ||
use:melt={builder} | ||
{...$$restProps} | ||
> | ||
<slot {builder} /> | ||
</div> | ||
{:else if inTransition && outTransition && $open} | ||
<div | ||
bind:this={el} | ||
in:inTransition={inTransitionConfig} | ||
out:outTransition={outTransitionConfig} | ||
use:melt={builder} | ||
{...$$restProps} | ||
> | ||
<slot {builder} /> | ||
</div> | ||
{:else if inTransition && $open} | ||
<div bind:this={el} in:inTransition={inTransitionConfig} use:melt={builder} {...$$restProps}> | ||
<slot {builder} /> | ||
</div> | ||
{:else if outTransition && $open} | ||
<div bind:this={el} out:outTransition={outTransitionConfig} use:melt={builder} {...$$restProps}> | ||
<slot {builder} /> | ||
</div> | ||
{:else if $open} | ||
<div bind:this={el} use:melt={builder} {...$$restProps}> | ||
<slot {builder} /> | ||
</div> | ||
{/if} | ||
<PresenceLayer.Root forceMount={true} present={state.root.open.value || forceMount} {id}> | ||
{#snippet presence({ present })} | ||
<FloatingLayer.Content {id} {style} {...restProps}> | ||
{#snippet content({ props })} | ||
{@const mergedProps = { | ||
...state.props, | ||
...props, | ||
hidden: present.value ? undefined : true, | ||
...restProps, | ||
}} | ||
{#if asChild} | ||
{@render child?.({ props: mergedProps })} | ||
{:else} | ||
<div {...mergedProps} bind:this={el}> | ||
{@render children?.()} | ||
</div> | ||
{/if} | ||
{/snippet} | ||
</FloatingLayer.Content> | ||
{/snippet} | ||
</PresenceLayer.Root> |
Oops, something went wrong.