Files
upstream-mirror 1416db152c
All checks were successful
Release / Create Version PR or Publish Stable Release (push) Has been skipped
Release / Publish Prerelease to NPM (push) Has been skipped
Monitor Registries / Monitor registry health (push) Has been skipped
snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:44:43 +05:00

50 lines
1.0 KiB
TypeScript

import * as React from "react"
import { type TextUIPart } from "ai"
import { Markdown } from "@/components/markdown"
import { Bubble, BubbleContent } from "@/registry/bases/radix/ui/bubble"
type PartTextVariant = "default" | "bubble"
export function PartText({
part,
role,
variant,
tinted = false,
className,
...props
}: {
part: TextUIPart
role?: "user" | "system" | "assistant"
tinted?: boolean
variant?: PartTextVariant
} & Omit<
React.ComponentProps<typeof Bubble>,
"children" | "part" | "variant"
>) {
if (part.type !== "text") {
return null
}
const content =
role === "user" || variant === "bubble" ? (
part.text
) : (
<Markdown animated>{part.text}</Markdown>
)
const bubbleVariant =
variant === "bubble"
? tinted
? "tinted"
: "default"
: role === "user"
? "default"
: "ghost"
return (
<Bubble variant={bubbleVariant} className={className} {...props}>
<BubbleContent>{content}</BubbleContent>
</Bubble>
)
}