Merge pull request #433 from DiegoSouzaPW/feature/SlotCloneError
Browse files
app/components/chat/Messages.client.tsx
CHANGED
|
@@ -73,8 +73,8 @@ export const Messages = React.forwardRef<HTMLDivElement, MessagesProps>((props:
|
|
| 73 |
</div>
|
| 74 |
{!isUserMessage && (
|
| 75 |
<div className="flex gap-2 flex-col lg:flex-row">
|
| 76 |
-
|
| 77 |
-
|
| 78 |
<button
|
| 79 |
onClick={() => handleRewind(messageId)}
|
| 80 |
key="i-ph:arrow-u-up-left"
|
|
@@ -83,8 +83,8 @@ export const Messages = React.forwardRef<HTMLDivElement, MessagesProps>((props:
|
|
| 83 |
'text-xl text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary transition-colors',
|
| 84 |
)}
|
| 85 |
/>
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
<WithTooltip tooltip="Fork chat from this message">
|
| 90 |
<button
|
|
|
|
| 73 |
</div>
|
| 74 |
{!isUserMessage && (
|
| 75 |
<div className="flex gap-2 flex-col lg:flex-row">
|
| 76 |
+
{messageId && (
|
| 77 |
+
<WithTooltip tooltip="Revert to this message">
|
| 78 |
<button
|
| 79 |
onClick={() => handleRewind(messageId)}
|
| 80 |
key="i-ph:arrow-u-up-left"
|
|
|
|
| 83 |
'text-xl text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary transition-colors',
|
| 84 |
)}
|
| 85 |
/>
|
| 86 |
+
</WithTooltip>
|
| 87 |
+
)}
|
| 88 |
|
| 89 |
<WithTooltip tooltip="Fork chat from this message">
|
| 90 |
<button
|
app/components/ui/IconButton.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { memo } from 'react';
|
| 2 |
import { classNames } from '~/utils/classNames';
|
| 3 |
|
| 4 |
type IconSize = 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
@@ -25,41 +25,48 @@ type IconButtonWithChildrenProps = {
|
|
| 25 |
|
| 26 |
type IconButtonProps = IconButtonWithoutChildrenProps | IconButtonWithChildrenProps;
|
| 27 |
|
|
|
|
| 28 |
export const IconButton = memo(
|
| 29 |
-
(
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
}
|
| 47 |
-
className
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
);
|
| 64 |
|
| 65 |
function getIconSize(size: IconSize) {
|
|
|
|
| 1 |
+
import { memo, forwardRef, type ForwardedRef } from 'react';
|
| 2 |
import { classNames } from '~/utils/classNames';
|
| 3 |
|
| 4 |
type IconSize = 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
|
|
| 25 |
|
| 26 |
type IconButtonProps = IconButtonWithoutChildrenProps | IconButtonWithChildrenProps;
|
| 27 |
|
| 28 |
+
// Componente IconButton com suporte a refs
|
| 29 |
export const IconButton = memo(
|
| 30 |
+
forwardRef(
|
| 31 |
+
(
|
| 32 |
+
{
|
| 33 |
+
icon,
|
| 34 |
+
size = 'xl',
|
| 35 |
+
className,
|
| 36 |
+
iconClassName,
|
| 37 |
+
disabledClassName,
|
| 38 |
+
disabled = false,
|
| 39 |
+
title,
|
| 40 |
+
onClick,
|
| 41 |
+
children,
|
| 42 |
+
}: IconButtonProps,
|
| 43 |
+
ref: ForwardedRef<HTMLButtonElement>,
|
| 44 |
+
) => {
|
| 45 |
+
return (
|
| 46 |
+
<button
|
| 47 |
+
ref={ref}
|
| 48 |
+
className={classNames(
|
| 49 |
+
'flex items-center text-bolt-elements-item-contentDefault bg-transparent enabled:hover:text-bolt-elements-item-contentActive rounded-md p-1 enabled:hover:bg-bolt-elements-item-backgroundActive disabled:cursor-not-allowed',
|
| 50 |
+
{
|
| 51 |
+
[classNames('opacity-30', disabledClassName)]: disabled,
|
| 52 |
+
},
|
| 53 |
+
className,
|
| 54 |
+
)}
|
| 55 |
+
title={title}
|
| 56 |
+
disabled={disabled}
|
| 57 |
+
onClick={(event) => {
|
| 58 |
+
if (disabled) {
|
| 59 |
+
return;
|
| 60 |
+
}
|
| 61 |
|
| 62 |
+
onClick?.(event);
|
| 63 |
+
}}
|
| 64 |
+
>
|
| 65 |
+
{children ? children : <div className={classNames(icon, getIconSize(size), iconClassName)}></div>}
|
| 66 |
+
</button>
|
| 67 |
+
);
|
| 68 |
+
},
|
| 69 |
+
),
|
| 70 |
);
|
| 71 |
|
| 72 |
function getIconSize(size: IconSize) {
|
app/components/ui/Tooltip.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import * as Tooltip from '@radix-ui/react-tooltip';
|
|
|
|
| 2 |
|
| 3 |
interface TooltipProps {
|
| 4 |
tooltip: React.ReactNode;
|
| 5 |
-
children:
|
| 6 |
sideOffset?: number;
|
| 7 |
className?: string;
|
| 8 |
arrowClassName?: string;
|
|
@@ -12,62 +13,67 @@ interface TooltipProps {
|
|
| 12 |
delay?: number;
|
| 13 |
}
|
| 14 |
|
| 15 |
-
const WithTooltip = (
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
max-h-[300px]
|
| 37 |
-
select-none
|
| 38 |
-
rounded-md
|
| 39 |
-
bg-bolt-elements-background-depth-3
|
| 40 |
-
text-bolt-elements-textPrimary
|
| 41 |
-
text-sm
|
| 42 |
-
leading-tight
|
| 43 |
-
shadow-lg
|
| 44 |
-
animate-in
|
| 45 |
-
fade-in-0
|
| 46 |
-
zoom-in-95
|
| 47 |
-
data-[state=closed]:animate-out
|
| 48 |
-
data-[state=closed]:fade-out-0
|
| 49 |
-
data-[state=closed]:zoom-out-95
|
| 50 |
-
${className}
|
| 51 |
-
`}
|
| 52 |
-
sideOffset={sideOffset}
|
| 53 |
-
style={{
|
| 54 |
-
maxWidth,
|
| 55 |
-
...tooltipStyle,
|
| 56 |
-
}}
|
| 57 |
-
>
|
| 58 |
-
<div className="break-words">{tooltip}</div>
|
| 59 |
-
<Tooltip.Arrow
|
| 60 |
className={`
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
`}
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
export default WithTooltip;
|
|
|
|
| 1 |
import * as Tooltip from '@radix-ui/react-tooltip';
|
| 2 |
+
import { forwardRef, type ForwardedRef, type ReactElement } from 'react';
|
| 3 |
|
| 4 |
interface TooltipProps {
|
| 5 |
tooltip: React.ReactNode;
|
| 6 |
+
children: ReactElement;
|
| 7 |
sideOffset?: number;
|
| 8 |
className?: string;
|
| 9 |
arrowClassName?: string;
|
|
|
|
| 13 |
delay?: number;
|
| 14 |
}
|
| 15 |
|
| 16 |
+
const WithTooltip = forwardRef(
|
| 17 |
+
(
|
| 18 |
+
{
|
| 19 |
+
tooltip,
|
| 20 |
+
children,
|
| 21 |
+
sideOffset = 5,
|
| 22 |
+
className = '',
|
| 23 |
+
arrowClassName = '',
|
| 24 |
+
tooltipStyle = {},
|
| 25 |
+
position = 'top',
|
| 26 |
+
maxWidth = 250,
|
| 27 |
+
delay = 0,
|
| 28 |
+
}: TooltipProps,
|
| 29 |
+
_ref: ForwardedRef<HTMLElement>,
|
| 30 |
+
) => {
|
| 31 |
+
return (
|
| 32 |
+
<Tooltip.Root delayDuration={delay}>
|
| 33 |
+
<Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
|
| 34 |
+
<Tooltip.Portal>
|
| 35 |
+
<Tooltip.Content
|
| 36 |
+
side={position}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
className={`
|
| 38 |
+
z-[2000]
|
| 39 |
+
px-2.5
|
| 40 |
+
py-1.5
|
| 41 |
+
max-h-[300px]
|
| 42 |
+
select-none
|
| 43 |
+
rounded-md
|
| 44 |
+
bg-bolt-elements-background-depth-3
|
| 45 |
+
text-bolt-elements-textPrimary
|
| 46 |
+
text-sm
|
| 47 |
+
leading-tight
|
| 48 |
+
shadow-lg
|
| 49 |
+
animate-in
|
| 50 |
+
fade-in-0
|
| 51 |
+
zoom-in-95
|
| 52 |
+
data-[state=closed]:animate-out
|
| 53 |
+
data-[state=closed]:fade-out-0
|
| 54 |
+
data-[state=closed]:zoom-out-95
|
| 55 |
+
${className}
|
| 56 |
`}
|
| 57 |
+
sideOffset={sideOffset}
|
| 58 |
+
style={{
|
| 59 |
+
maxWidth,
|
| 60 |
+
...tooltipStyle,
|
| 61 |
+
}}
|
| 62 |
+
>
|
| 63 |
+
<div className="break-words">{tooltip}</div>
|
| 64 |
+
<Tooltip.Arrow
|
| 65 |
+
className={`
|
| 66 |
+
fill-bolt-elements-background-depth-3
|
| 67 |
+
${arrowClassName}
|
| 68 |
+
`}
|
| 69 |
+
width={12}
|
| 70 |
+
height={6}
|
| 71 |
+
/>
|
| 72 |
+
</Tooltip.Content>
|
| 73 |
+
</Tooltip.Portal>
|
| 74 |
+
</Tooltip.Root>
|
| 75 |
+
);
|
| 76 |
+
},
|
| 77 |
+
);
|
| 78 |
|
| 79 |
export default WithTooltip;
|