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,33 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { ScrollAreaCornerProps } from "../types.js";
import { ScrollAreaCornerImplState } from "../scroll-area.svelte.js";
let {
ref = $bindable(null),
id,
children,
child,
...restProps
}: Omit<ScrollAreaCornerProps, "id"> & {
id: string;
} = $props();
const cornerState = ScrollAreaCornerImplState.create({
id: boxWith(() => id),
ref: boxWith(
() => 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}
@@ -0,0 +1,7 @@
import type { ScrollAreaCornerProps } from "../types.js";
type $$ComponentProps = Omit<ScrollAreaCornerProps, "id"> & {
id: string;
};
declare const ScrollAreaCornerImpl: import("svelte").Component<$$ComponentProps, {}, "ref">;
type ScrollAreaCornerImpl = ReturnType<typeof ScrollAreaCornerImpl>;
export default ScrollAreaCornerImpl;
@@ -0,0 +1,27 @@
<script lang="ts">
import type { ScrollAreaCornerProps } from "../types.js";
import { ScrollAreaRootContext } from "../scroll-area.svelte.js";
import ScrollAreaCornerImpl from "./scroll-area-corner-impl.svelte";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
ref = $bindable(null),
id = createId(uid),
...restProps
}: ScrollAreaCornerProps = $props();
const scrollAreaState = ScrollAreaRootContext.get();
const hasBothScrollbarsVisible = $derived(
Boolean(scrollAreaState.scrollbarXNode && scrollAreaState.scrollbarYNode)
);
const hasCorner = $derived(
scrollAreaState.opts.type.current !== "scroll" && hasBothScrollbarsVisible
);
</script>
{#if hasCorner}
<ScrollAreaCornerImpl {...restProps} {id} bind:ref />
{/if}
@@ -0,0 +1,4 @@
import type { ScrollAreaCornerProps } from "../types.js";
declare const ScrollAreaCorner: import("svelte").Component<ScrollAreaCornerProps, {}, "ref">;
type ScrollAreaCorner = ReturnType<typeof ScrollAreaCorner>;
export default ScrollAreaCorner;
@@ -0,0 +1,21 @@
<script lang="ts">
import { mergeProps } from "svelte-toolbelt";
import { ScrollAreaScrollbarAutoState } from "../scroll-area.svelte.js";
import type { _ScrollbarStubProps } from "../types.js";
import ScrollAreaScrollbarVisible from "./scroll-area-scrollbar-visible.svelte";
import PresenceLayer from "../../utilities/presence-layer/presence-layer.svelte";
let { forceMount = false, ...restProps }: _ScrollbarStubProps = $props();
const scrollbarAutoState = ScrollAreaScrollbarAutoState.create();
const mergedProps = $derived(mergeProps(restProps, scrollbarAutoState.props));
</script>
<PresenceLayer
open={forceMount || scrollbarAutoState.isVisible}
ref={scrollbarAutoState.scrollbar.opts.ref}
>
{#snippet presence()}
<ScrollAreaScrollbarVisible {...mergedProps} />
{/snippet}
</PresenceLayer>
@@ -0,0 +1,4 @@
import type { _ScrollbarStubProps } from "../types.js";
declare const ScrollAreaScrollbarAuto: import("svelte").Component<_ScrollbarStubProps, {}, "">;
type ScrollAreaScrollbarAuto = ReturnType<typeof ScrollAreaScrollbarAuto>;
export default ScrollAreaScrollbarAuto;
@@ -0,0 +1,30 @@
<script lang="ts">
import { mergeProps } from "svelte-toolbelt";
import {
ScrollAreaScrollbarAutoState,
ScrollAreaScrollbarHoverState,
} from "../scroll-area.svelte.js";
import type { _ScrollbarStubProps } from "../types.js";
import ScrollAreaScrollbarVisible from "./scroll-area-scrollbar-visible.svelte";
import PresenceLayer from "../../utilities/presence-layer/presence-layer.svelte";
let { forceMount = false, ...restProps }: _ScrollbarStubProps = $props();
const scrollbarHoverState = ScrollAreaScrollbarHoverState.create();
const scrollbarAutoState = ScrollAreaScrollbarAutoState.create();
const mergedProps = $derived(
mergeProps(restProps, scrollbarHoverState.props, scrollbarAutoState.props, {
"data-state": scrollbarHoverState.isVisible ? "visible" : "hidden",
})
);
const open = $derived(
forceMount || (scrollbarHoverState.isVisible && scrollbarAutoState.isVisible)
);
</script>
<PresenceLayer {open} ref={scrollbarAutoState.scrollbar.opts.ref}>
{#snippet presence()}
<ScrollAreaScrollbarVisible {...mergedProps} />
{/snippet}
</PresenceLayer>
@@ -0,0 +1,4 @@
import type { _ScrollbarStubProps } from "../types.js";
declare const ScrollAreaScrollbarHover: import("svelte").Component<_ScrollbarStubProps, {}, "">;
type ScrollAreaScrollbarHover = ReturnType<typeof ScrollAreaScrollbarHover>;
export default ScrollAreaScrollbarHover;
@@ -0,0 +1,23 @@
<script lang="ts">
import { mergeProps } from "svelte-toolbelt";
import { ScrollAreaScrollbarScrollState } from "../scroll-area.svelte.js";
import type { _ScrollbarStubProps } from "../types.js";
import ScrollAreaScrollbarVisible from "./scroll-area-scrollbar-visible.svelte";
import PresenceLayer from "../../utilities/presence-layer/presence-layer.svelte";
let { forceMount = false, ...restProps }: _ScrollbarStubProps = $props();
const scrollbarScrollState = ScrollAreaScrollbarScrollState.create();
const mergedProps = $derived(mergeProps(restProps, scrollbarScrollState.props));
</script>
<PresenceLayer
{...mergedProps}
open={forceMount || !scrollbarScrollState.isHidden}
ref={scrollbarScrollState.scrollbar.opts.ref}
>
{#snippet presence()}
<ScrollAreaScrollbarVisible {...mergedProps} />
{/snippet}
</PresenceLayer>
@@ -0,0 +1,4 @@
import type { _ScrollbarStubProps } from "../types.js";
declare const ScrollAreaScrollbarScroll: import("svelte").Component<_ScrollbarStubProps, {}, "">;
type ScrollAreaScrollbarScroll = ReturnType<typeof ScrollAreaScrollbarScroll>;
export default ScrollAreaScrollbarScroll;
@@ -0,0 +1,19 @@
<script lang="ts">
import { mergeProps } from "svelte-toolbelt";
import { ScrollAreaScrollbarSharedState } from "../scroll-area.svelte.js";
import type { _ScrollbarStubProps } from "../types.js";
let { child, children, ...restProps }: _ScrollbarStubProps = $props();
const scrollbarSharedState = ScrollAreaScrollbarSharedState.create();
const mergedProps = $derived(mergeProps(restProps, scrollbarSharedState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
@@ -0,0 +1,4 @@
import type { _ScrollbarStubProps } from "../types.js";
declare const ScrollAreaScrollbarShared: import("svelte").Component<_ScrollbarStubProps, {}, "">;
type ScrollAreaScrollbarShared = ReturnType<typeof ScrollAreaScrollbarShared>;
export default ScrollAreaScrollbarShared;
@@ -0,0 +1,16 @@
<script lang="ts">
import { ScrollAreaScrollbarVisibleState } 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 = ScrollAreaScrollbarVisibleState.create();
</script>
{#if scrollbarVisibleState.scrollbar.opts.orientation.current === "horizontal"}
<ScrollAreaScrollbarX {...restProps} />
{:else}
<ScrollAreaScrollbarY {...restProps} />
{/if}
@@ -0,0 +1,4 @@
import type { _ScrollbarStubProps } from "../types.js";
declare const ScrollAreaScrollbarVisible: import("svelte").Component<Omit<_ScrollbarStubProps, "forceMount">, {}, "">;
type ScrollAreaScrollbarVisible = ReturnType<typeof ScrollAreaScrollbarVisible>;
export default ScrollAreaScrollbarVisible;
@@ -0,0 +1,19 @@
<script lang="ts">
import { IsMounted } from "runed";
import { boxWith, mergeProps } from "svelte-toolbelt";
import { ScrollAreaScrollbarXState } from "../scroll-area.svelte.js";
import type { _ScrollbarStubProps } from "../types.js";
import ScrollAreaScrollbarShared from "./scroll-area-scrollbar-shared.svelte";
let { ...restProps }: _ScrollbarStubProps = $props();
const isMounted = new IsMounted();
const scrollbarXState = ScrollAreaScrollbarXState.create({
mounted: boxWith(() => isMounted.current),
});
// oxlint-disable-next-line no-explicit-any
const mergedProps = $derived(mergeProps(restProps, scrollbarXState.props)) as any;
</script>
<ScrollAreaScrollbarShared {...mergedProps} />
@@ -0,0 +1,4 @@
import type { _ScrollbarStubProps } from "../types.js";
declare const ScrollAreaScrollbarX: import("svelte").Component<_ScrollbarStubProps, {}, "">;
type ScrollAreaScrollbarX = ReturnType<typeof ScrollAreaScrollbarX>;
export default ScrollAreaScrollbarX;
@@ -0,0 +1,20 @@
<script lang="ts">
import { IsMounted } from "runed";
import { boxWith, mergeProps } from "svelte-toolbelt";
import { ScrollAreaScrollbarYState } from "../scroll-area.svelte.js";
import type { _ScrollbarStubProps } from "../types.js";
import ScrollAreaScrollbarShared from "./scroll-area-scrollbar-shared.svelte";
let { ...restProps }: _ScrollbarStubProps = $props();
const isMounted = new IsMounted();
const scrollbarYState = ScrollAreaScrollbarYState.create({
mounted: boxWith(() => isMounted.current),
});
// oxlint-disable-next-line no-explicit-any
const mergedProps = $derived(mergeProps(restProps, scrollbarYState.props)) as any;
</script>
<ScrollAreaScrollbarShared {...mergedProps} />
@@ -0,0 +1,4 @@
import type { _ScrollbarStubProps } from "../types.js";
declare const ScrollAreaScrollbarY: import("svelte").Component<_ScrollbarStubProps, {}, "">;
type ScrollAreaScrollbarY = ReturnType<typeof ScrollAreaScrollbarY>;
export default ScrollAreaScrollbarY;
@@ -0,0 +1,40 @@
<script lang="ts">
import { boxWith } from "svelte-toolbelt";
import type { ScrollAreaScrollbarProps } from "../types.js";
import { ScrollAreaScrollbarState } from "../scroll-area.svelte.js";
import ScrollAreaScrollbarAuto from "./scroll-area-scrollbar-auto.svelte";
import ScrollAreaScrollbarScroll from "./scroll-area-scrollbar-scroll.svelte";
import ScrollAreaScrollbarHover from "./scroll-area-scrollbar-hover.svelte";
import ScrollAreaScrollbarVisible from "./scroll-area-scrollbar-visible.svelte";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
ref = $bindable(null),
id = createId(uid),
orientation,
...restProps
}: ScrollAreaScrollbarProps = $props();
const scrollbarState = ScrollAreaScrollbarState.create({
orientation: boxWith(() => orientation),
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const type = $derived(scrollbarState.root.opts.type.current);
</script>
{#if type === "hover"}
<ScrollAreaScrollbarHover {...restProps} {id} />
{:else if type === "scroll"}
<ScrollAreaScrollbarScroll {...restProps} {id} />
{:else if type === "auto"}
<ScrollAreaScrollbarAuto {...restProps} {id} />
{:else if type === "always"}
<ScrollAreaScrollbarVisible {...restProps} {id} />
{/if}
@@ -0,0 +1,4 @@
import type { ScrollAreaScrollbarProps } from "../types.js";
declare const ScrollAreaScrollbar: import("svelte").Component<ScrollAreaScrollbarProps, {}, "ref">;
type ScrollAreaScrollbar = ReturnType<typeof ScrollAreaScrollbar>;
export default ScrollAreaScrollbar;
@@ -0,0 +1,45 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import { IsMounted } from "runed";
import type { ScrollAreaThumbProps } from "../types.js";
import { ScrollAreaThumbImplState } from "../scroll-area.svelte.js";
let {
ref = $bindable(null),
id,
child,
children,
present,
...restProps
}: Omit<ScrollAreaThumbProps, "forceMount" | "id"> & {
id: string;
present: boolean;
} = $props();
const isMounted = new IsMounted();
const thumbState = ScrollAreaThumbImplState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
mounted: boxWith(() => isMounted.current),
});
const mergedProps = $derived(
mergeProps(restProps, thumbState.props, {
style: {
hidden: !present,
},
})
);
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
@@ -0,0 +1,8 @@
import type { ScrollAreaThumbProps } from "../types.js";
type $$ComponentProps = Omit<ScrollAreaThumbProps, "forceMount" | "id"> & {
id: string;
present: boolean;
};
declare const ScrollAreaThumbImpl: import("svelte").Component<$$ComponentProps, {}, "ref">;
type ScrollAreaThumbImpl = ReturnType<typeof ScrollAreaThumbImpl>;
export default ScrollAreaThumbImpl;
@@ -0,0 +1,24 @@
<script lang="ts">
import type { ScrollAreaThumbProps } from "../types.js";
import { ScrollAreaScrollbarVisibleContext } from "../scroll-area.svelte.js";
import ScrollAreaThumbImpl from "./scroll-area-thumb-impl.svelte";
import { createId } from "../../../internal/create-id.js";
import PresenceLayer from "../../utilities/presence-layer/presence-layer.svelte";
const uid = $props.id();
let {
id = createId(uid),
ref = $bindable(null),
forceMount = false,
...restProps
}: ScrollAreaThumbProps = $props();
const scrollbarState = ScrollAreaScrollbarVisibleContext.get();
</script>
<PresenceLayer open={forceMount || scrollbarState.hasThumb} ref={scrollbarState.scrollbar.opts.ref}>
{#snippet presence({ present })}
<ScrollAreaThumbImpl {...restProps} {id} bind:ref {present} />
{/snippet}
</PresenceLayer>
@@ -0,0 +1,4 @@
import type { ScrollAreaThumbProps } from "../types.js";
declare const ScrollAreaThumb: import("svelte").Component<ScrollAreaThumbProps, {}, "ref">;
type ScrollAreaThumb = ReturnType<typeof ScrollAreaThumb>;
export default ScrollAreaThumb;
@@ -0,0 +1,53 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { ScrollAreaViewportProps } from "../types.js";
import { ScrollAreaViewportState } from "../scroll-area.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
ref = $bindable(null),
id = createId(uid),
children,
...restProps
}: ScrollAreaViewportProps = $props();
const viewportState = ScrollAreaViewportState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, viewportState.props));
const mergedContentProps = $derived(mergeProps({}, viewportState.contentProps));
</script>
<div {...mergedProps}>
<div {...mergedContentProps}>
{@render children?.()}
</div>
</div>
<style>
/* Hide scrollbars cross browser and enable momentum scroll for touch devices */
:global([data-scroll-area-viewport]) {
scrollbar-width: none !important;
-ms-overflow-style: none !important;
-webkit-overflow-scrolling: touch !important;
}
:global([data-scroll-area-viewport])::-webkit-scrollbar {
display: none !important;
}
:global(:where([data-scroll-area-viewport])) {
display: flex;
flex-direction: column;
align-items: stretch;
}
:global(:where([data-scroll-area-content])) {
flex-grow: 1;
}
</style>
@@ -0,0 +1,4 @@
import type { ScrollAreaViewportProps } from "../types.js";
declare const ScrollAreaViewport: import("svelte").Component<ScrollAreaViewportProps, {}, "ref">;
type ScrollAreaViewport = ReturnType<typeof ScrollAreaViewport>;
export default ScrollAreaViewport;
@@ -0,0 +1,40 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { ScrollAreaRootProps } from "../types.js";
import { ScrollAreaRootState } from "../scroll-area.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
ref = $bindable(null),
id = createId(uid),
type = "hover",
dir = "ltr",
scrollHideDelay = 600,
children,
child,
...restProps
}: ScrollAreaRootProps = $props();
const rootState = ScrollAreaRootState.create({
type: boxWith(() => type),
dir: boxWith(() => dir),
scrollHideDelay: boxWith(() => scrollHideDelay),
id: boxWith(() => id),
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 { ScrollAreaRootProps } from "../types.js";
declare const ScrollArea: import("svelte").Component<ScrollAreaRootProps, {}, "ref">;
type ScrollArea = ReturnType<typeof ScrollArea>;
export default ScrollArea;