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,34 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { AvatarFallbackProps } from "../types.js";
import { AvatarFallbackState } from "../avatar.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
children,
child,
id = createId(uid),
ref = $bindable(null),
...restProps
}: AvatarFallbackProps = $props();
const fallbackState = AvatarFallbackState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, fallbackState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<span {...mergedProps}>
{@render children?.()}
</span>
{/if}
@@ -0,0 +1,4 @@
import type { AvatarFallbackProps } from "../types.js";
declare const AvatarFallback: import("svelte").Component<AvatarFallbackProps, {}, "ref">;
type AvatarFallback = ReturnType<typeof AvatarFallback>;
export default AvatarFallback;
+37
View File
@@ -0,0 +1,37 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { AvatarImageProps } from "../types.js";
import { AvatarImageState } from "../avatar.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
src,
child,
id = createId(uid),
ref = $bindable(null),
crossorigin = undefined,
referrerpolicy = undefined,
...restProps
}: AvatarImageProps = $props();
const imageState = AvatarImageState.create({
src: boxWith(() => src),
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
crossOrigin: boxWith(() => crossorigin),
referrerPolicy: boxWith(() => referrerpolicy),
});
const mergedProps = $derived(mergeProps(restProps, imageState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<img {...mergedProps} {src} />
{/if}
@@ -0,0 +1,4 @@
import type { AvatarImageProps } from "../types.js";
declare const AvatarImage: import("svelte").Component<AvatarImageProps, {}, "ref">;
type AvatarImage = ReturnType<typeof AvatarImage>;
export default AvatarImage;
+47
View File
@@ -0,0 +1,47 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { AvatarRootProps } from "../types.js";
import { AvatarRootState } from "../avatar.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
delayMs = 0,
loadingStatus = $bindable("loading"),
onLoadingStatusChange,
child,
children,
id = createId(uid),
ref = $bindable(null),
...restProps
}: AvatarRootProps = $props();
const rootState = AvatarRootState.create({
delayMs: boxWith(() => delayMs),
loadingStatus: boxWith(
() => loadingStatus,
(v) => {
if (loadingStatus !== v) {
loadingStatus = v;
onLoadingStatusChange?.(v);
}
}
),
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}
+4
View File
@@ -0,0 +1,4 @@
import type { AvatarRootProps } from "../types.js";
declare const Avatar: import("svelte").Component<AvatarRootProps, {}, "ref" | "loadingStatus">;
type Avatar = ReturnType<typeof Avatar>;
export default Avatar;