Components
AI Attachments
One file riding the prompt: its glyph by extension, its name and human size, and a quiet way to take it back off. Uploading reads as a dashed ghost, error as danger ink.
#Basic usage
colophon.png47.1 KBnotes.md1.0 KBwireframe.figdenied.exe64.0 KBa-very-long-document-name-that-keeps-going-and-going.pdf2.0 MB
Click a chip's × to remove it.
<script setup lang="ts">
import { AiAttachment, AiAttachments } from "@bysages/vue";
import { ref } from "vue";
// The files riding the prompt: every chip state, and the quiet way
// back off.
const files = ref([
{ name: "colophon.png", size: 48213, status: "ready" as "ready" | "uploading" | "error" },
{ name: "notes.md", size: 1024, status: "ready" as "ready" | "uploading" | "error" },
{ name: "wireframe.fig", status: "uploading" as "ready" | "uploading" | "error" },
{ name: "denied.exe", size: 65536, status: "error" as "ready" | "uploading" | "error" },
{
name: "a-very-long-document-name-that-keeps-going-and-going.pdf",
size: 2097152,
status: "ready" as "ready" | "uploading" | "error",
},
]);
const removed = ref("");
const remove = (name: string) => {
files.value = files.value.filter((f) => f.name !== name);
removed.value = name;
};
</script>
<template>
<div class="grid gap-4 w-full">
<AiAttachments>
<AiAttachment
v-for="file in files"
:key="file.name"
:name="file.name"
:size="file.size"
:status="file.status"
@remove="remove(file.name)"
/>
</AiAttachments>
<p class="m-0 text-tertiary text-sm">
{{ removed ? `Removed: ${removed}` : "Click a chip's × to remove it." }}
</p>
</div>
</template>
#Props
#AiAttachment
One file riding the prompt: its glyph by extension, its name and human size, and a quiet way to take it back off. Uploading reads as a dashed ghost, error as danger ink.
| Prop | Type | Default | Description |
|---|---|---|---|
name | String | The file's name — it picks the glyph by extension. | |
size | Number | undefined | The file's size in bytes, when known — rendered human. |
status | String as PropType<"uploading" | "ready" | "error"> | "ready" | The upload's state on the wire. |
#AiAttachments
The row the files ride in — a wrapping line of chips.
A styled part — no props of its own; it takes the anatomy's shared styling.