-
-
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
41 changed files
with
1,896 additions
and
536 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
Empty file.
34 changes: 0 additions & 34 deletions
34
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-content.svelte
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-corner-impl.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,34 @@ | ||
<script lang="ts"> | ||
import { box } from "svelte-toolbelt"; | ||
import type { CornerProps } from "../index.js"; | ||
import { useScrollAreaCorner } from "../scroll-area.svelte.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
let { | ||
ref = $bindable(null), | ||
id, | ||
children, | ||
child, | ||
...restProps | ||
}: Omit<CornerProps, "id"> & { | ||
id: string; | ||
} = $props(); | ||
const cornerState = useScrollAreaCorner({ | ||
id: box.with(() => id), | ||
ref: box.with( | ||
() => ref, | ||
(v) => (ref = v) | ||
), | ||
}); | ||
const mergedProps = $derived(mergeProps(restProps, cornerState.props)); | ||
</script> | ||
|
||
{#if child} | ||
{@render child({ props: mergedProps })} | ||
{:else} | ||
<div {...mergedProps}> | ||
{@render children?.()} | ||
</div> | ||
{/if} |
37 changes: 11 additions & 26 deletions
37
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-corner.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,34 +1,19 @@ | ||
<script lang="ts"> | ||
import { melt } from "@melt-ui/svelte"; | ||
import type { CornerProps } from "../index.js"; | ||
import { getCtx } from "../ctx.js"; | ||
import { getScrollAreaRootContext } from "../scroll-area.svelte.js"; | ||
import ScrollAreaCornerImpl from "./scroll-area-corner-impl.svelte"; | ||
import { useId } from "$lib/internal/useId.svelte.js"; | ||
type $$Props = CornerProps; | ||
let { ref = $bindable(null), id = useId(), ...restProps }: CornerProps = $props(); | ||
export let asChild: $$Props["asChild"] = false; | ||
export let ref: $$Props["el"] = undefined; | ||
const scrollAreaState = getScrollAreaRootContext(); | ||
const { | ||
elements: { corner }, | ||
getAttrs, | ||
} = getCtx(); | ||
const bitsAttrs = getAttrs("corner"); | ||
$: attrs = { | ||
...$$restProps, | ||
...bitsAttrs, | ||
}; | ||
$: builder = $corner; | ||
$: Object.assign(builder, attrs); | ||
const hasBothScrollbarsVisible = $derived( | ||
Boolean(scrollAreaState.scrollbarXNode && scrollAreaState.scrollbarYNode) | ||
); | ||
const hasCorner = $derived(scrollAreaState.type.value !== "scroll" && hasBothScrollbarsVisible); | ||
</script> | ||
|
||
{#if asChild} | ||
<slot {builder} /> | ||
{:else} | ||
<div use:melt={builder} bind:this={ref}> | ||
<slot {builder} /> | ||
</div> | ||
{#if hasCorner} | ||
<ScrollAreaCornerImpl {...restProps} {id} bind:ref /> | ||
{/if} |
18 changes: 18 additions & 0 deletions
18
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-scrollbar-auto.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,18 @@ | ||
<script lang="ts"> | ||
import { useScrollAreaScrollbarAuto } from "../scroll-area.svelte.js"; | ||
import type { _ScrollbarStubProps } from "../types.js"; | ||
import ScrollAreaScrollbarVisible from "./scroll-area-scrollbar-visible.svelte"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
import { PresenceLayer } from "$lib/bits/utilities/presence-layer/index.js"; | ||
let { forceMount = false, ...restProps }: _ScrollbarStubProps = $props(); | ||
const scrollbarAutoState = useScrollAreaScrollbarAuto(); | ||
const mergedProps = $derived(mergeProps(restProps, scrollbarAutoState.props)); | ||
</script> | ||
|
||
<PresenceLayer present={forceMount || scrollbarAutoState.isVisible} {...mergedProps}> | ||
{#snippet presence()} | ||
<ScrollAreaScrollbarVisible {...mergedProps} /> | ||
{/snippet} | ||
</PresenceLayer> |
30 changes: 30 additions & 0 deletions
30
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-scrollbar-hover.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,30 @@ | ||
<script lang="ts"> | ||
import { | ||
useScrollAreaScrollbarAuto, | ||
useScrollAreaScrollbarHover, | ||
} from "../scroll-area.svelte.js"; | ||
import type { _ScrollbarStubProps } from "../types.js"; | ||
import ScrollAreaScrollbarVisible from "./scroll-area-scrollbar-visible.svelte"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
import { PresenceLayer } from "$lib/bits/utilities/presence-layer/index.js"; | ||
let { forceMount = false, ...restProps }: _ScrollbarStubProps = $props(); | ||
const scrollbarHoverState = useScrollAreaScrollbarHover(); | ||
const scrollbarAutoState = useScrollAreaScrollbarAuto(); | ||
const mergedProps = $derived( | ||
mergeProps(restProps, scrollbarHoverState.props, scrollbarAutoState.props, { | ||
"data-state": scrollbarHoverState.isVisible ? "visible" : "hidden", | ||
}) | ||
); | ||
const present = $derived( | ||
forceMount || (scrollbarHoverState.isVisible && scrollbarAutoState.isVisible) | ||
); | ||
</script> | ||
|
||
<PresenceLayer {...mergedProps} {present}> | ||
{#snippet presence()} | ||
<ScrollAreaScrollbarVisible {...mergedProps} /> | ||
{/snippet} | ||
</PresenceLayer> |
19 changes: 19 additions & 0 deletions
19
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-scrollbar-scroll.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,19 @@ | ||
<script lang="ts"> | ||
import { useScrollAreaScrollbarScroll } from "../scroll-area.svelte.js"; | ||
import type { _ScrollbarStubProps } from "../types.js"; | ||
import ScrollAreaScrollbarVisible from "./scroll-area-scrollbar-visible.svelte"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
import { PresenceLayer } from "$lib/bits/utilities/presence-layer/index.js"; | ||
let { forceMount = false, ...restProps }: _ScrollbarStubProps = $props(); | ||
const scrollbarScrollState = useScrollAreaScrollbarScroll(); | ||
const mergedProps = $derived(mergeProps(restProps, scrollbarScrollState.props)); | ||
</script> | ||
|
||
<PresenceLayer {...mergedProps} present={forceMount || !scrollbarScrollState.isHidden}> | ||
{#snippet presence()} | ||
<ScrollAreaScrollbarVisible {...mergedProps} /> | ||
{/snippet} | ||
</PresenceLayer> |
19 changes: 19 additions & 0 deletions
19
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-scrollbar-shared.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,19 @@ | ||
<script lang="ts"> | ||
import { useScrollAreaScrollbarShared } from "../scroll-area.svelte.js"; | ||
import type { _ScrollbarStubProps } from "../types.js"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
let { child, children, ...restProps }: _ScrollbarStubProps = $props(); | ||
const scrollbarSharedState = useScrollAreaScrollbarShared(); | ||
const mergedProps = $derived(mergeProps(restProps, scrollbarSharedState.props)); | ||
</script> | ||
|
||
{#if child} | ||
{@render child?.({ props: mergedProps })} | ||
{:else} | ||
<div {...mergedProps}> | ||
{@render children?.()} | ||
</div> | ||
{/if} |
16 changes: 16 additions & 0 deletions
16
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-scrollbar-visible.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,16 @@ | ||
<script lang="ts"> | ||
import { useScrollAreaScrollbarVisible } from "../scroll-area.svelte.js"; | ||
import type { _ScrollbarStubProps } from "../types.js"; | ||
import ScrollAreaScrollbarX from "./scroll-area-scrollbar-x.svelte"; | ||
import ScrollAreaScrollbarY from "./scroll-area-scrollbar-y.svelte"; | ||
let { ...restProps }: Omit<_ScrollbarStubProps, "forceMount"> = $props(); | ||
const scrollbarVisibleState = useScrollAreaScrollbarVisible(); | ||
</script> | ||
|
||
{#if scrollbarVisibleState.scrollbar.orientation.value === "horizontal"} | ||
<ScrollAreaScrollbarX {...restProps} /> | ||
{:else} | ||
<ScrollAreaScrollbarY {...restProps} /> | ||
{/if} |
41 changes: 13 additions & 28 deletions
41
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-scrollbar-x.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,34 +1,19 @@ | ||
<script lang="ts"> | ||
import { melt } from "@melt-ui/svelte"; | ||
import type { ScrollbarProps } from "../index.js"; | ||
import { getCtx } from "../ctx.js"; | ||
import { IsMounted } from "runed"; | ||
import { box } from "svelte-toolbelt"; | ||
import { useScrollAreaScrollbarX } from "../scroll-area.svelte.js"; | ||
import type { _ScrollbarStubProps } from "../types.js"; | ||
import ScrollAreaScrollbarShared from "./scroll-area-scrollbar-shared.svelte"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
type $$Props = Omit<ScrollbarProps, "orientation">; | ||
let { ...restProps }: _ScrollbarStubProps = $props(); | ||
export let asChild: $$Props["asChild"] = false; | ||
export let ref: $$Props["el"] = undefined; | ||
const isMounted = new IsMounted(); | ||
const { | ||
elements: { scrollbarX }, | ||
getAttrs, | ||
} = getCtx(); | ||
const bitsAttrs = getAttrs("scrollbar-x"); | ||
$: attrs = { | ||
...$$restProps, | ||
...bitsAttrs, | ||
}; | ||
$: builder = $scrollbarX; | ||
$: Object.assign(builder, attrs); | ||
const scrollbarXState = useScrollAreaScrollbarX({ | ||
mounted: box.with(() => isMounted.current), | ||
}); | ||
const mergedProps = $derived(mergeProps(restProps, scrollbarXState.props)); | ||
</script> | ||
|
||
{#if asChild} | ||
<slot {builder} /> | ||
{:else} | ||
<div use:melt={builder} bind:this={ref}> | ||
<slot {builder} /> | ||
</div> | ||
{/if} | ||
<ScrollAreaScrollbarShared {...mergedProps} /> |
40 changes: 13 additions & 27 deletions
40
packages/bits-ui/src/lib/bits/scroll-area/components/scroll-area-scrollbar-y.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,34 +1,20 @@ | ||
<script lang="ts"> | ||
import { melt } from "@melt-ui/svelte"; | ||
import type { ScrollbarProps } from "../index.js"; | ||
import { getCtx } from "../ctx.js"; | ||
import { IsMounted } from "runed"; | ||
import { box } from "svelte-toolbelt"; | ||
import { useScrollAreaScrollbarY } from "../scroll-area.svelte.js"; | ||
import type { _ScrollbarStubProps } from "../types.js"; | ||
import ScrollAreaScrollbarShared from "./scroll-area-scrollbar-shared.svelte"; | ||
import { mergeProps } from "$lib/internal/mergeProps.js"; | ||
type $$Props = Omit<ScrollbarProps, "orientation">; | ||
let { ...restProps }: _ScrollbarStubProps = $props(); | ||
export let asChild: $$Props["asChild"] = false; | ||
export let ref: $$Props["el"] = undefined; | ||
const isMounted = new IsMounted(); | ||
const { | ||
elements: { scrollbarY }, | ||
getAttrs, | ||
} = getCtx(); | ||
const scrollbarYState = useScrollAreaScrollbarY({ | ||
mounted: box.with(() => isMounted.current), | ||
}); | ||
const bitsAttrs = getAttrs("scrollbar-y"); | ||
$: attrs = { | ||
...$$restProps, | ||
...bitsAttrs, | ||
}; | ||
$: builder = $scrollbarY; | ||
$: Object.assign(builder, attrs); | ||
const mergedProps = $derived(mergeProps(restProps, scrollbarYState.props)); | ||
</script> | ||
|
||
{#if asChild} | ||
<slot {builder} /> | ||
{:else} | ||
<div use:melt={builder} bind:this={ref}> | ||
<slot {builder} /> | ||
</div> | ||
{/if} | ||
<ScrollAreaScrollbarShared {...mergedProps} /> |
Oops, something went wrong.