diff --git a/sparkle/package-lock.json b/sparkle/package-lock.json index 2ae3be4999fe..64ab778fe32d 100644 --- a/sparkle/package-lock.json +++ b/sparkle/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dust-tt/sparkle", - "version": "0.2.324", + "version": "0.2.325", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dust-tt/sparkle", - "version": "0.2.324", + "version": "0.2.325", "license": "ISC", "dependencies": { "@emoji-mart/data": "^1.1.2", diff --git a/sparkle/package.json b/sparkle/package.json index c2d5b16f2b10..1d6340d7cc7d 100644 --- a/sparkle/package.json +++ b/sparkle/package.json @@ -1,6 +1,6 @@ { "name": "@dust-tt/sparkle", - "version": "0.2.324", + "version": "0.2.325", "scripts": { "build": "rm -rf dist && npm run tailwind && npm run build:esm && npm run build:cjs", "tailwind": "tailwindcss -i ./src/styles/tailwind.css -o dist/sparkle.css", diff --git a/sparkle/src/components/ConversationMessage.tsx b/sparkle/src/components/ConversationMessage.tsx index a74569a80a5b..1b2ad3524d3a 100644 --- a/sparkle/src/components/ConversationMessage.tsx +++ b/sparkle/src/components/ConversationMessage.tsx @@ -1,11 +1,6 @@ import React from "react"; import { Button } from "@sparkle/components"; -import { - ConversationMessageActions, - ConversationMessageEmojiSelectorProps, - ConversationMessageThumbSelectorProps, -} from "@sparkle/components/ConversationMessageActions"; import { ConversationMessageContent } from "@sparkle/components/ConversationMessageContent"; import { ConversationMessageHeader } from "@sparkle/components/ConversationMessageHeader"; import { cn } from "@sparkle/lib/utils"; @@ -29,8 +24,6 @@ type ConversationMessageProps = { buttons?: React.ReactElement[]; children?: React.ReactNode; citations?: React.ReactElement[]; - messageEmoji?: ConversationMessageEmojiSelectorProps; - messageThumb?: ConversationMessageThumbSelectorProps; name: string | null; pictureUrl?: string | React.ReactNode | null; renderName?: (name: string | null) => React.ReactNode; @@ -47,8 +40,6 @@ export function ConversationMessage({ buttons, children, citations, - messageEmoji, - messageThumb, name, pictureUrl, renderName = (name) => ( @@ -77,11 +68,7 @@ export function ConversationMessage({ {children} - +
{buttons}
); } diff --git a/sparkle/src/components/ConversationMessageActions.tsx b/sparkle/src/components/ConversationMessageActions.tsx deleted file mode 100644 index 31895691bb64..000000000000 --- a/sparkle/src/components/ConversationMessageActions.tsx +++ /dev/null @@ -1,310 +0,0 @@ -import React, { useRef } from "react"; - -import { Button } from "@sparkle/components/Button"; -import { - DataEmojiMart, - EmojiMartData, - EmojiPicker, -} from "@sparkle/components/EmojiPicker"; -import { Page } from "@sparkle/components/Page"; -import { - Popover, - PopoverContent, - PopoverRoot, - PopoverTrigger, -} from "@sparkle/components/Popover"; -import { TextArea } from "@sparkle/components/TextArea"; -import { - HandThumbDownIcon, - HandThumbUpIcon, - ReactionIcon, -} from "@sparkle/icons/solid"; -import { cn } from "@sparkle/lib/utils"; - -type ConversationMessageActionsProps = { - buttons?: React.ReactElement[]; - messageEmoji?: ConversationMessageEmojiSelectorProps; - messageThumb?: ConversationMessageThumbSelectorProps; -}; - -export function ConversationMessageActions({ - buttons = [], - messageEmoji, - messageThumb, -}: ConversationMessageActionsProps) { - if (messageThumb) { - buttons.push( - - ); - } - - if (messageEmoji) { - buttons.push( - - ); - } - - if (buttons.length === 0) { - return false; - } - - return
{buttons}
; -} - -const MAX_MORE_REACTIONS_TO_SHOW = 9; - -export type EmojoReaction = { - emoji: string; - hasReacted: boolean; - count: number; -}; -export interface ConversationMessageEmojiSelectorProps { - reactions: EmojoReaction[]; - onSubmitEmoji: (p: { emoji: string; isToRemove: boolean }) => Promise; - isSubmittingEmoji: boolean; -} - -export type ThumbReaction = "up" | "down"; -export interface ConversationMessageThumbSelectorProps { - onSubmitThumb: (p: { - thumb: string; - isToRemove: boolean; - feedback?: string | null; - }) => Promise; - isSubmittingThumb: boolean; -} - -function ConversationMessageEmojiSelector({ - reactions, - onSubmitEmoji, - isSubmittingEmoji, -}: ConversationMessageEmojiSelectorProps) { - const emojiData = DataEmojiMart as EmojiMartData; - - let slicedReactions = [...reactions]; - let hasMoreReactions = null; - if (slicedReactions.length > MAX_MORE_REACTIONS_TO_SHOW) { - hasMoreReactions = slicedReactions.length - MAX_MORE_REACTIONS_TO_SHOW; - slicedReactions = slicedReactions.slice(0, MAX_MORE_REACTIONS_TO_SHOW); - } - - return ( - <> - - {slicedReactions.map((reaction, index) => { - const hasReacted = reaction.hasReacted; - const emoji = emojiData?.emojis[reaction.emoji]; - const nativeEmoji = emoji?.skins[0].native; - if (!nativeEmoji) { - return null; - } - return ( - - onSubmitEmoji({ - emoji: reaction.emoji, - isToRemove: hasReacted, - }) - } - /> - ); - })} - {hasMoreReactions && ( -
- +{hasMoreReactions} -
- )} - - ); -} - -interface ButtonEmojiProps { - variant?: "selected" | "unselected"; - count?: string; - emoji?: string; - onClick?: () => void; -} - -export function ButtonEmoji({ - variant, - emoji, - count, - onClick, -}: ButtonEmojiProps) { - return ( -
- {emoji} - {count && {count}} -
- ); -} - -function EmojiSelector({ - reactions, - onSubmitEmoji, - emojiData, - isSubmittingEmoji = false, -}: { - emojiData: EmojiMartData | null; -} & ConversationMessageEmojiSelectorProps) { - const buttonRef = useRef(null); - - return ( - -