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,41 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import { CollapsibleContentState } from "../collapsible.svelte.js";
import type { CollapsibleContentProps } from "../types.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
child,
ref = $bindable(null),
forceMount = false,
hiddenUntilFound = false,
children,
id = createId(uid),
...restProps
}: CollapsibleContentProps = $props();
const contentState = CollapsibleContentState.create({
id: boxWith(() => id),
forceMount: boxWith(() => forceMount),
hiddenUntilFound: boxWith(() => hiddenUntilFound),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, contentState.props));
</script>
{#if child}
{@render child({
...contentState.snippetProps,
props: mergedProps,
})}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
@@ -0,0 +1,4 @@
import type { CollapsibleContentProps } from "../types.js";
declare const CollapsibleContent: import("svelte").Component<CollapsibleContentProps, {}, "ref">;
type CollapsibleContent = ReturnType<typeof CollapsibleContent>;
export default CollapsibleContent;
@@ -0,0 +1,36 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { CollapsibleTriggerProps } from "../types.js";
import { CollapsibleTriggerState } from "../collapsible.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
children,
child,
ref = $bindable(null),
id = createId(uid),
disabled = false,
...restProps
}: CollapsibleTriggerProps = $props();
const triggerState = CollapsibleTriggerState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
disabled: boxWith(() => disabled),
});
const mergedProps = $derived(mergeProps(restProps, triggerState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<button {...mergedProps}>
{@render children?.()}
</button>
{/if}
@@ -0,0 +1,4 @@
import type { CollapsibleTriggerProps } from "../types.js";
declare const CollapsibleTrigger: import("svelte").Component<CollapsibleTriggerProps, {}, "ref">;
type CollapsibleTrigger = ReturnType<typeof CollapsibleTrigger>;
export default CollapsibleTrigger;
@@ -0,0 +1,48 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { CollapsibleRootProps } from "../types.js";
import { CollapsibleRootState } from "../collapsible.svelte.js";
import { createId } from "../../../internal/create-id.js";
import { noop } from "../../../internal/noop.js";
const uid = $props.id();
let {
children,
child,
id = createId(uid),
ref = $bindable(null),
open = $bindable(false),
disabled = false,
onOpenChange = noop,
onOpenChangeComplete = noop,
...restProps
}: CollapsibleRootProps = $props();
const rootState = CollapsibleRootState.create({
open: boxWith(
() => open,
(v) => {
open = v;
onOpenChange(v);
}
),
disabled: boxWith(() => disabled),
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
onOpenChangeComplete: boxWith(() => onOpenChangeComplete),
});
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 { CollapsibleRootProps } from "../types.js";
declare const Collapsible: import("svelte").Component<CollapsibleRootProps, {}, "ref" | "open">;
type Collapsible = ReturnType<typeof Collapsible>;
export default Collapsible;