Skip to content

feat(ai-chat-log): add new components #4356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/nasty-files-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/codemods": patch
"@twilio-paste/core": patch
---

[AI Chat Log] Add new stories
6 changes: 6 additions & 0 deletions .changeset/stale-clocks-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/ai-chat-log": minor
"@twilio-paste/core": minor
---

[AI Chat Log] add new `AIChatMessageSourceLink` component and new stories
2 changes: 2 additions & 0 deletions packages/paste-codemods/tools/.cache/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"AIChatMessageAuthor": "@twilio-paste/core/ai-chat-log",
"AIChatMessageBody": "@twilio-paste/core/ai-chat-log",
"AIChatMessageLoading": "@twilio-paste/core/ai-chat-log",
"AIChatMessageSource": "@twilio-paste/core/ai-chat-log",
"AIChatMessageSourceLink": "@twilio-paste/core/ai-chat-log",
"useAIChatLogger": "@twilio-paste/core/ai-chat-log",
"Alert": "@twilio-paste/core/alert",
"AlertDialog": "@twilio-paste/core/alert-dialog",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { BoxElementProps } from "@twilio-paste/box";
import { Box, safelySpreadBoxProps } from "@twilio-paste/box";
import type { HTMLPasteProps } from "@twilio-paste/types";
import * as React from "react";

export interface AIChatMessageSourceProps extends HTMLPasteProps<"div"> {
children?: React.ReactNode;
/**
* Overrides the default element name to apply unique styles with the Customization Provider
*
* @default "AI_CHAT_MESSAGE"
* @type {BoxProps["element"]}
* @memberof AIChatMessageSourceProps
*/
element?: BoxElementProps["element"];
}

export const AIChatMessageSource = React.forwardRef<HTMLDivElement, AIChatMessageSourceProps>(
({ children, element = "AI_CHAT_MESSAGE_SOURCE", ...props }, ref) => {
return (
<Box
as="sup"
ref={ref}
element={element}
verticalAlign="inherit"
fontSize="inherit"
paddingX="space10"
color="colorTextWeak"
{...safelySpreadBoxProps(props)}
>
[{children}]
</Box>
);
},
);

AIChatMessageSource.displayName = "AIChatMessageSource";
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Anchor } from "@twilio-paste/anchor";
import type { BoxElementProps } from "@twilio-paste/box";
import { Box, safelySpreadBoxProps } from "@twilio-paste/box";
import type { HTMLPasteProps } from "@twilio-paste/types";
import * as React from "react";

export interface AIChatMessageSourceLinkProps extends HTMLPasteProps<"div"> {
children: React.ReactNode;
/**
* Overrides the default element name to apply unique styles with the Customization Provider
*
* @default "AI_CHAT_MESSAGE"
* @type {BoxProps["element"]}
* @memberof AIChatMessageSourceLinkProps
*/
element?: BoxElementProps["element"];
/**
* The item number of the source link in the AI chat message.
*
* @type {string}
* @memberof AIChatMessageSourceLinkProps
* @example "1"
*/
number: string;
/**
* The source link URL in the AI chat message.
*
* @type {string}
* @memberof AIChatMessageSourceLinkProps
* @example "https://example.com"
*/
url: string;
}

export const AIChatMessageSourceLink = React.forwardRef<HTMLDivElement, AIChatMessageSourceLinkProps>(
({ children, number, url, element = "AI_CHAT_MESSAGE_SOURCE_LINK", ...props }, ref) => {
return (
<Box
ref={ref}
element={element}
verticalAlign="inherit"
fontSize="inherit"
color="colorTextWeak"
{...safelySpreadBoxProps(props)}
>
[{number}]{" "}
<Box as="span" marginLeft="space10">
{children}
</Box>
<Anchor href={url} showExternal marginLeft="space20">
Source with url
</Anchor>
</Box>
);
},
);

AIChatMessageSourceLink.displayName = "AIChatMessageSourceLink";
5 changes: 5 additions & 0 deletions packages/paste-core/components/ai-chat-log/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ export { AIChatLogger } from "./AIChatLogger";
export type { AIChatLoggerProps } from "./AIChatLogger";

export type { AIMessageVariants } from "./AIMessageContext";

export { AIChatMessageSource } from "./AIChatMessageSource";
export type { AIChatMessageSourceProps } from "./AIChatMessageSource";
export { AIChatMessageSourceLink } from "./AIChatMessageSourceLink";
export type { AIChatMessageSourceLinkProps } from "./AIChatMessageSourceLink";
Loading
Loading