diff --git a/packages/bits-ui/src/lib/bits/popover/components/popover-content.svelte b/packages/bits-ui/src/lib/bits/popover/components/popover-content.svelte index 88bc8a6bd..bde7c9cdb 100644 --- a/packages/bits-ui/src/lib/bits/popover/components/popover-content.svelte +++ b/packages/bits-ui/src/lib/bits/popover/components/popover-content.svelte @@ -3,7 +3,6 @@ import { setPopoverContentState } from "../popover.svelte.js"; import { PopperLayer } from "$lib/bits/utilities/popper-layer/index.js"; import { mergeProps, readonlyBox, useId } from "$lib/internal/index.js"; - import Portal from "$lib/bits/utilities/portal/portal.svelte"; let { asChild, @@ -23,25 +22,23 @@ }); - - - {#snippet popper({ props })} - {@const mergedProps = mergeProps(restProps, state.props, props)} - {mergedProps.hidden} - {#if asChild} - {@render child?.({ props: mergedProps })} - {:else} - - {@render children?.()} - - {/if} - {/snippet} - - + + {#snippet popper({ props })} + {@const mergedProps = mergeProps(restProps, state.props, props)} + {mergedProps.hidden} + {#if asChild} + {@render child?.({ props: mergedProps })} + {:else} + + {@render children?.()} + + {/if} + {/snippet} + diff --git a/packages/bits-ui/src/lib/bits/popover/index.ts b/packages/bits-ui/src/lib/bits/popover/index.ts index e2fabcc02..bc11ccdb3 100644 --- a/packages/bits-ui/src/lib/bits/popover/index.ts +++ b/packages/bits-ui/src/lib/bits/popover/index.ts @@ -3,6 +3,7 @@ export { default as Arrow } from "./components/popover-arrow.svelte"; export { default as Content } from "./components/popover-content.svelte"; export { default as Trigger } from "./components/popover-trigger.svelte"; export { default as Close } from "./components/popover-close.svelte"; +export { default as Portal } from "$lib/bits/utilities/portal/portal.svelte"; export type { PopoverRootProps as RootProps, @@ -13,3 +14,5 @@ export type { PopoverTriggerEvents as TriggerEvents, PopoverCloseEvents as CloseEvents, } from "./types.js"; + +export type { PortalProps } from "$lib/bits/utilities/portal/types.js"; diff --git a/packages/bits-ui/src/lib/bits/utilities/portal/portal.svelte b/packages/bits-ui/src/lib/bits/utilities/portal/portal.svelte index e051434fc..fb00248d5 100644 --- a/packages/bits-ui/src/lib/bits/utilities/portal/portal.svelte +++ b/packages/bits-ui/src/lib/bits/utilities/portal/portal.svelte @@ -4,7 +4,7 @@ import type { PortalProps } from "./types.js"; import { isBrowser } from "$lib/internal/is.js"; - let { to = "body", children }: PortalProps = $props(); + let { to = "body", children, disabled }: PortalProps = $props(); const context = getAllContexts(); @@ -34,7 +34,7 @@ let instance: any; $effect(() => { - if (!target) { + if (!target || disabled) { return unmount(instance); } instance = mount(PortalConsumer, { target, props: { children }, context }); @@ -44,3 +44,7 @@ }; }); + +{#if disabled} + {@render children?.()} +{/if} diff --git a/sites/docs/src/lib/components/demos/popover-demo.svelte b/sites/docs/src/lib/components/demos/popover-demo.svelte index 7e41e136b..86c6b0feb 100644 --- a/sites/docs/src/lib/components/demos/popover-demo.svelte +++ b/sites/docs/src/lib/components/demos/popover-demo.svelte @@ -13,52 +13,60 @@ > Resize - - - - - - - - Resize image - Resize your photos easily - - - - - - - Width - W - + + + + + + - - Height - H - + + + Resize image + + + Resize your photos easily + + + + + + + + Width + W + + + + Height + H + + + + + - - - - - + +
Resize your photos easily
+ Resize your photos easily +