源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s

This commit is contained in:
agent-radar committed 2026-09-01 20:17:27 +08:00
commit 2ed3415fb7
8018 files changed
+1936476

No files matched your search

@@ -0,0 +1,727 @@
import {
type CSSProperties,
type ComponentPropsWithoutRef,
type JSX,
type MouseEvent,
type WheelEvent,
useCallback,
useEffect,
useState
} from "react";
import { createPortal } from "react-dom";
import {
Button,
ToastProvider,
ToastRoot,
ToastTitle,
ToastViewport,
CloseIcon,
CopyIcon,
DownloadIcon
} from "@tutti-os/ui-system";
import { RotateCcwIcon, ZoomInIcon, ZoomOutIcon } from "lucide-react";
import { useTranslation } from "../../../i18n/index";
import { cn } from "../lib/utils";
import { ConversationImageContextMenu } from "../../../shared/agentConversation/components/ConversationImageContextMenu";
import { copyImageToClipboard } from "../../../shared/agentConversation/lib/copyImageToClipboard";
import { useOptionalAgentHostApi } from "../../../agentActivityHost";
import {
downloadImage,
resolveImageDownloadName
} from "./zoomableImageDownload";
interface ZoomableImageProps extends ComponentPropsWithoutRef<"img"> {
downloadName?: string;
wrapElement?: "div" | "span";
}
type ImageCopyStatus = {
busy: boolean;
message: string;
variant: "destructive" | "success";
};
const IMAGE_PREVIEW_ZOOM_MIN = 0.5;
const IMAGE_PREVIEW_ZOOM_MAX = 3;
const IMAGE_PREVIEW_ZOOM_STEP = 0.25;
export function ZoomableImage({
alt,
className,
downloadName,
onContextMenu,
src,
wrapElement = "div",
...props
}: ZoomableImageProps): JSX.Element {
const { t } = useTranslation();
const agentHostApi = useOptionalAgentHostApi();
const actionSource =
typeof src === "string" && src.trim() ? src.trim() : null;
const hasImageActions = Boolean(actionSource && downloadName !== undefined);
const [contextMenuPosition, setContextMenuPosition] = useState<{
x: number;
y: number;
inZoomDialog: boolean;
} | null>(null);
const [copyStatus, setCopyStatus] = useState<ImageCopyStatus | null>(null);
const [imagePreviewZoom, setImagePreviewZoom] = useState(1);
const [isWheelZooming, setIsWheelZooming] = useState(false);
const [isImagePreviewOpen, setIsImagePreviewOpen] = useState(false);
const [isImagePreviewClosing, setIsImagePreviewClosing] = useState(false);
const imagePreviewZoomPercent = Math.round(imagePreviewZoom * 100);
const canZoomOut = imagePreviewZoom > IMAGE_PREVIEW_ZOOM_MIN;
const canZoomIn = imagePreviewZoom < IMAGE_PREVIEW_ZOOM_MAX;
const closeContextMenu = useCallback(() => {
setContextMenuPosition(null);
}, []);
const finishClosePreviewImage = (): void => {
setIsImagePreviewOpen(false);
setIsImagePreviewClosing(false);
setIsWheelZooming(false);
setImagePreviewZoom(1);
};
const closePreviewImage = (): void => {
if (!isImagePreviewOpen) {
return;
}
setIsImagePreviewClosing(true);
setIsWheelZooming(false);
setImagePreviewZoom(1);
closeContextMenu();
};
const openPreviewImage = (): void => {
if (!actionSource) {
return;
}
closeContextMenu();
setIsImagePreviewClosing(false);
setIsImagePreviewOpen(true);
};
const handlePreviewSurfaceClick = (
event: MouseEvent<HTMLDivElement>
): void => {
const target = event.target;
if (target === event.currentTarget) {
closePreviewImage();
return;
}
if (!(target instanceof HTMLElement)) {
return;
}
if (
target.hasAttribute("data-rmiz-modal-overlay") ||
target.hasAttribute("data-rmiz-modal-content")
) {
closePreviewImage();
}
};
useEffect(() => {
const handleWindowKeyDown = (event: globalThis.KeyboardEvent): void => {
if (!isImagePreviewOpen || event.key !== "Escape") {
return;
}
event.preventDefault();
event.stopPropagation();
setIsImagePreviewClosing(true);
setIsWheelZooming(false);
setImagePreviewZoom(1);
closeContextMenu();
};
if (contextMenuPosition) {
document.addEventListener("click", closeContextMenu);
document.addEventListener("scroll", closeContextMenu, true);
}
if (isImagePreviewOpen) {
window.addEventListener("keydown", handleWindowKeyDown, true);
}
return () => {
document.removeEventListener("click", closeContextMenu);
document.removeEventListener("scroll", closeContextMenu, true);
window.removeEventListener("keydown", handleWindowKeyDown, true);
};
}, [closeContextMenu, contextMenuPosition, isImagePreviewOpen]);
const handleContextMenu = useCallback(
(event: MouseEvent<HTMLElement>): void => {
onContextMenu?.(event as MouseEvent<HTMLImageElement>);
if (event.defaultPrevented || !actionSource || !hasImageActions) {
return;
}
event.preventDefault();
event.stopPropagation();
setContextMenuPosition({
x: event.clientX,
y: event.clientY,
inZoomDialog: Boolean(event.currentTarget.closest(".tsh-zoom-dialog"))
});
},
[actionSource, hasImageActions, onContextMenu]
);
const handleCopyImage = useCallback(async (): Promise<void> => {
if (!actionSource) {
return;
}
const copyingMessage = t("common.copying");
setCopyStatus({
busy: true,
message: copyingMessage,
variant: "success"
});
closeContextMenu();
const copied = await Promise.race([
copyImageToClipboard(actionSource, agentHostApi?.clipboard),
new Promise<boolean>((resolve) => {
window.setTimeout(() => resolve(false), 5000);
})
]);
const message = t(
copied ? "agentHost.agentGui.messageCopied" : "common.copyFailed"
);
setCopyStatus({
busy: false,
message,
variant: copied ? "success" : "destructive"
});
}, [actionSource, agentHostApi?.clipboard, closeContextMenu, t]);
const handleCopyImageAction = useCallback((): void => {
void handleCopyImage().catch(() => undefined);
}, [handleCopyImage]);
const handleDownloadImage = useCallback((): void => {
if (!actionSource) {
return;
}
closeContextMenu();
downloadImage(
actionSource,
resolveImageDownloadName(downloadName, actionSource, alt)
);
setCopyStatus({
busy: false,
message: t("agentHost.agentGui.imageDownloaded"),
variant: "success"
});
}, [actionSource, alt, closeContextMenu, downloadName, t]);
const zoomOutPreviewImage = useCallback((): void => {
setIsWheelZooming(false);
setImagePreviewZoom((value) =>
clampSteppedImagePreviewZoom(value - IMAGE_PREVIEW_ZOOM_STEP)
);
}, []);
const zoomInPreviewImage = useCallback((): void => {
setIsWheelZooming(false);
setImagePreviewZoom((value) =>
clampSteppedImagePreviewZoom(value + IMAGE_PREVIEW_ZOOM_STEP)
);
}, []);
const resetPreviewImageZoom = useCallback((): void => {
setIsWheelZooming(false);
setImagePreviewZoom(1);
}, []);
const handlePreviewImageWheel = useCallback(
(event: WheelEvent<HTMLElement>): void => {
event.preventDefault();
event.stopPropagation();
if (event.deltaY === 0) {
return;
}
setIsWheelZooming(true);
setImagePreviewZoom((value) =>
clampImagePreviewZoom(value * Math.pow(2, resolveWheelZoomDelta(event)))
);
},
[]
);
const actionButtons = hasImageActions ? (
<ImageActionButtons
copyLabel={t("common.copyImage")}
downloadLabel={t("common.downloadImage")}
onCopy={handleCopyImageAction}
onDownload={handleDownloadImage}
/>
) : null;
const previewImage =
(isImagePreviewOpen || isImagePreviewClosing) && actionSource ? (
<img
alt={alt}
data-rmiz-modal-img=""
data-tsh-image-zoom={formatImagePreviewZoom(imagePreviewZoom)}
draggable={false}
src={actionSource}
title={typeof props.title === "string" ? props.title : undefined}
className="tsh-zoom-dialog__image nodrag tsh-desktop-no-drag"
style={{
transform: resolveZoomedImageTransform(
undefined,
imagePreviewZoom,
null,
null
),
transition: isWheelZooming
? "none"
: mergeImagePreviewTransition(undefined)
}}
onClick={(event) => {
event.stopPropagation();
closePreviewImage();
}}
onContextMenu={hasImageActions ? handleContextMenu : onContextMenu}
onTransitionEnd={
isImagePreviewClosing ? finishClosePreviewImage : undefined
}
onWheel={handlePreviewImageWheel}
/>
) : null;
const previewContent =
previewImage && !actionButtons && actionSource ? (
<ConversationImageContextMenu
src={actionSource}
asChild
contentStyle={{ zIndex: "var(--z-dialog-popover)" }}
>
{previewImage}
</ConversationImageContextMenu>
) : (
previewImage
);
const Wrapper = wrapElement;
return (
<>
<Wrapper
className={cn(
"tsh-zoomable-image nodrag tsh-desktop-no-drag",
wrapElement === "div" && "tsh-zoomable-image--block"
)}
>
<img
{...props}
alt={alt}
src={src}
onClick={(event) => {
props.onClick?.(event);
if (!event.defaultPrevented) {
openPreviewImage();
}
}}
onContextMenu={hasImageActions ? handleContextMenu : onContextMenu}
className={cn("nodrag tsh-desktop-no-drag cursor-zoom-in", className)}
/>
<button
type="button"
aria-label={t("common.expandImage")}
className="tsh-zoomable-image__trigger nodrag tsh-desktop-no-drag"
onClick={openPreviewImage}
onContextMenu={handleContextMenu}
/>
</Wrapper>
{contextMenuPosition && !contextMenuPosition.inZoomDialog && actionButtons
? createPortal(
<div
className="tsh-image-context-menu nodrag tsh-desktop-no-drag"
style={{
left: contextMenuPosition.x,
top: contextMenuPosition.y
}}
role="menu"
onClick={(event) => event.stopPropagation()}
>
<ImageActionButtons
copyLabel={t("common.copyImage")}
downloadLabel={t("common.downloadImage")}
itemRole="menuitem"
onCopy={handleCopyImageAction}
onDownload={handleDownloadImage}
/>
</div>,
document.body
)
: null}
{(isImagePreviewOpen || isImagePreviewClosing) && actionSource
? createPortal(
<div
aria-modal="true"
autoFocus
className="tsh-zoom-dialog nodrag tsh-desktop-no-drag"
data-closing={isImagePreviewClosing ? "true" : undefined}
data-tsh-image-actions={hasImageActions ? "true" : undefined}
data-rmiz-modal=""
role="dialog"
tabIndex={-1}
onClick={handlePreviewSurfaceClick}
onAnimationEnd={(event) => {
if (
isImagePreviewClosing &&
event.currentTarget === event.target
) {
finishClosePreviewImage();
}
}}
>
<div data-rmiz-modal-overlay="visible" />
<div data-rmiz-modal-content="true">{previewContent}</div>
<ImagePreviewZoomControls
canZoomIn={canZoomIn}
canZoomOut={canZoomOut}
percent={imagePreviewZoomPercent}
percentLabel={t("common.imageZoomPercent", {
percent: imagePreviewZoomPercent
})}
reportPercentStatus={!copyStatus}
resetLabel={t("common.resetImageZoom")}
zoomInLabel={t("common.zoomInImage")}
zoomOutLabel={t("common.zoomOutImage")}
onReset={resetPreviewImageZoom}
onZoomIn={zoomInPreviewImage}
onZoomOut={zoomOutPreviewImage}
onWheel={handlePreviewImageWheel}
/>
<div className="tsh-zoom-dialog__toolbar-actions nodrag tsh-desktop-no-drag">
{actionButtons}
<Button
aria-label={t("common.close")}
className="tsh-zoom-dialog__icon-button nodrag tsh-desktop-no-drag"
size="icon"
title={t("common.close")}
onPointerDown={(event) => event.stopPropagation()}
variant="chrome"
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
closePreviewImage();
}}
>
<CloseIcon aria-hidden="true" className="size-4" />
</Button>
</div>
{contextMenuPosition?.inZoomDialog && actionButtons ? (
<div
className="tsh-image-context-menu nodrag tsh-desktop-no-drag"
style={{
left: contextMenuPosition.x,
top: contextMenuPosition.y
}}
role="menu"
onClick={(event) => event.stopPropagation()}
>
<ImageActionButtons
copyLabel={t("common.copyImage")}
downloadLabel={t("common.downloadImage")}
itemRole="menuitem"
onCopy={handleCopyImageAction}
onDownload={handleDownloadImage}
/>
</div>
) : null}
{copyStatus ? (
<ImageCopyStatusToast
busy={copyStatus.busy}
message={copyStatus.message}
variant={copyStatus.variant}
onOpenChange={(open) => {
if (!open) {
setCopyStatus(null);
}
}}
/>
) : null}
</div>,
document.body
)
: null}
{copyStatus && !isImagePreviewOpen
? createPortal(
<ImageCopyStatusToast
busy={copyStatus.busy}
message={copyStatus.message}
variant={copyStatus.variant}
onOpenChange={(open) => {
if (!open) {
setCopyStatus(null);
}
}}
/>,
document.body
)
: null}
</>
);
}
function ImageCopyStatusToast({
busy,
message,
onOpenChange,
variant
}: {
busy: boolean;
message: string;
onOpenChange: (open: boolean) => void;
variant: ImageCopyStatus["variant"];
}): JSX.Element {
return (
<ToastProvider duration={1600} swipeDirection="right">
<ToastRoot
open
anchor="viewport"
busy={busy}
variant={variant}
data-tsh-image-copy-status="true"
style={{ zIndex: 100303 }}
onOpenChange={onOpenChange}
>
<ToastTitle>{message}</ToastTitle>
</ToastRoot>
<ToastViewport
className="nodrag tsh-desktop-no-drag"
style={{
top: "max(20px, calc(var(--cove-titlebar-reserve, 0px) + 10px))",
zIndex: 100303
}}
/>
</ToastProvider>
);
}
function ImagePreviewZoomControls({
canZoomIn,
canZoomOut,
percent,
percentLabel,
reportPercentStatus,
resetLabel,
zoomInLabel,
zoomOutLabel,
onReset,
onZoomIn,
onZoomOut,
onWheel
}: {
canZoomIn: boolean;
canZoomOut: boolean;
percent: number;
percentLabel: string;
reportPercentStatus: boolean;
resetLabel: string;
zoomInLabel: string;
zoomOutLabel: string;
onReset: () => void;
onZoomIn: () => void;
onZoomOut: () => void;
onWheel: (event: WheelEvent<HTMLElement>) => void;
}): JSX.Element {
return (
<div
className="tsh-zoom-dialog__zoom-controls nodrag tsh-desktop-no-drag"
onWheel={onWheel}
>
<button
type="button"
title={zoomOutLabel}
aria-label={zoomOutLabel}
disabled={!canZoomOut}
onClick={onZoomOut}
>
<ZoomOutIcon aria-hidden="true" className="size-4" />
</button>
<span
aria-label={percentLabel}
role={reportPercentStatus ? "status" : undefined}
>
{percent}%
</span>
<button
type="button"
title={resetLabel}
aria-label={resetLabel}
onClick={onReset}
>
<RotateCcwIcon aria-hidden="true" className="size-4" />
</button>
<button
type="button"
title={zoomInLabel}
aria-label={zoomInLabel}
disabled={!canZoomIn}
onClick={onZoomIn}
>
<ZoomInIcon aria-hidden="true" className="size-4" />
</button>
</div>
);
}
function ImageActionButtons({
copyLabel,
downloadLabel,
itemRole,
onCopy,
onDownload
}: {
copyLabel: string;
downloadLabel: string;
itemRole?: "menuitem";
onCopy: () => void;
onDownload: () => void;
}): JSX.Element {
if (!itemRole) {
return (
<>
<Button
aria-label={copyLabel}
className="tsh-zoom-dialog__icon-button"
size="icon"
title={copyLabel}
onPointerDown={(event) => event.stopPropagation()}
variant="chrome"
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
onCopy();
}}
>
<CopyIcon aria-hidden="true" className="size-4" />
</Button>
<Button
aria-label={downloadLabel}
className="tsh-zoom-dialog__icon-button"
size="icon"
title={downloadLabel}
onPointerDown={(event) => event.stopPropagation()}
variant="chrome"
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
onDownload();
}}
>
<DownloadIcon aria-hidden="true" className="size-4" />
</Button>
</>
);
}
return (
<>
<button
type="button"
role={itemRole}
title={copyLabel}
onPointerDown={(event) => event.stopPropagation()}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
onCopy();
}}
>
<CopyIcon aria-hidden="true" className="size-4" />
<span>{copyLabel}</span>
</button>
<button
type="button"
role={itemRole}
title={downloadLabel}
onPointerDown={(event) => event.stopPropagation()}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
onDownload();
}}
>
<DownloadIcon aria-hidden="true" className="size-4" />
<span>{downloadLabel}</span>
</button>
</>
);
}
function resolveWheelZoomDelta(event: WheelEvent<HTMLElement>): number {
return (
-event.deltaY *
(event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) *
(event.ctrlKey ? 10 : 1)
);
}
function resolveZoomedImageTransform(
transform: CSSProperties["transform"],
zoom: number,
width: number | null,
height: number | null
): CSSProperties["transform"] {
const baseTransform = typeof transform === "string" ? transform.trim() : "";
const zoomTransform = resolveImagePreviewZoomTransform(zoom, width, height);
if (!baseTransform) {
return zoomTransform || undefined;
}
if (!zoomTransform) {
return baseTransform;
}
return `${baseTransform} ${zoomTransform}`;
}
function resolveImagePreviewZoomTransform(
zoom: number,
width: number | null,
height: number | null
): string {
if (zoom === 1) {
return "";
}
const scale = `scale(${formatImagePreviewZoom(zoom)})`;
if (width === null || height === null) {
return scale;
}
const halfWidth = formatCssNumber(width / 2);
const halfHeight = formatCssNumber(height / 2);
return `translate(${halfWidth}px,${halfHeight}px) ${scale} translate(-${halfWidth}px,-${halfHeight}px)`;
}
function formatCssNumber(value: number): string {
return Number(value.toFixed(3)).toString();
}
function mergeImagePreviewTransition(
transition: CSSProperties["transition"]
): CSSProperties["transition"] {
const zoomTransition = "transform 120ms ease-out";
if (typeof transition !== "string" || !transition.trim()) {
return zoomTransition;
}
return transition.includes("transform")
? transition
: `${transition}, ${zoomTransition}`;
}
function clampSteppedImagePreviewZoom(value: number): number {
const stepped =
Math.round(value / IMAGE_PREVIEW_ZOOM_STEP) * IMAGE_PREVIEW_ZOOM_STEP;
return clampImagePreviewZoom(stepped);
}
function clampImagePreviewZoom(value: number): number {
return Math.min(
IMAGE_PREVIEW_ZOOM_MAX,
Math.max(IMAGE_PREVIEW_ZOOM_MIN, value)
);
}
function formatImagePreviewZoom(value: number): string {
return Number(value.toFixed(2)).toString();
}
@@ -0,0 +1,18 @@
import type { SVGProps } from "react";
export function AgentLinedIcon(props: SVGProps<SVGSVGElement>) {
"use memo";
return (
<svg
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M12 3C12.5523 3 13 3.44772 13 4V7H18C19.6569 7 21 8.34315 21 10V13H22C22.5523 13 23 13.4477 23 14C23 14.5523 22.5523 15 22 15H21V18C21 19.6569 19.6569 21 18 21H6C4.34315 21 3 19.6569 3 18V15H2C1.44772 15 1 14.5523 1 14C1 13.4477 1.44772 13 2 13H3V10C3 8.34315 4.34315 7 6 7H11V5H8C7.44772 5 7 4.55228 7 4C7 3.44772 7.44772 3 8 3H12ZM6 9C5.44772 9 5 9.44772 5 10V18C5 18.5523 5.44772 19 6 19H18C18.5523 19 19 18.5523 19 18V10C19 9.44772 18.5523 9 18 9H6ZM9 12C9.55229 12 10 12.4477 10 13V15C10 15.5523 9.55229 16 9 16C8.44772 16 8 15.5523 8 15V13C8 12.4477 8.44772 12 9 12ZM15 12C15.5523 12 16 12.4477 16 13V15C16 15.5523 15.5523 16 15 16C14.4477 16 14 15.5523 14 15V13C14 12.4477 14.4477 12 15 12Z"
fill="currentColor"
/>
</svg>
);
}
@@ -0,0 +1,177 @@
import type { HTMLAttributes, MouseEvent } from "react";
import {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useRef
} from "react";
import {
motion,
useAnimation,
useReducedMotion,
type Variants
} from "framer-motion";
import { cn } from "../../lib/utils";
export interface AtomIconHandle {
startAnimation: () => void;
stopAnimation: () => void;
}
interface AtomIconProps extends HTMLAttributes<HTMLDivElement> {
size?: number;
active?: boolean;
}
const ATOM_ICON_ANIMATION_DURATION = 0.75;
const ATOM_ICON_REPEAT_DELAY = 1.5;
const PATH_VARIANTS: Variants = {
normal: (custom: number) => ({
opacity: 1,
pathLength: 1,
pathOffset: 0,
transition: {
duration: ATOM_ICON_ANIMATION_DURATION,
ease: "easeInOut",
delay: custom
}
}),
animate: (custom: number) => ({
opacity: [0, 1],
pathLength: [0, 1],
pathOffset: [1, 0],
transition: {
duration: ATOM_ICON_ANIMATION_DURATION,
ease: "easeInOut",
delay: custom
}
}),
active: (custom: number) => ({
opacity: [0, 1],
pathLength: [0, 1],
pathOffset: [1, 0],
transition: {
duration: ATOM_ICON_ANIMATION_DURATION,
ease: "easeInOut",
delay: custom,
repeat: Infinity,
repeatDelay: ATOM_ICON_REPEAT_DELAY
}
})
};
const AtomIcon = forwardRef<AtomIconHandle, AtomIconProps>(
(
{
active = false,
onMouseEnter,
onMouseLeave,
className,
size = 28,
...props
},
ref
) => {
const controls = useAnimation();
const reduceMotion = useReducedMotion();
const isControlledRef = useRef(false);
const startAnimation = useCallback(() => {
if (reduceMotion) {
return;
}
void controls.start(active ? "active" : "animate");
}, [active, controls, reduceMotion]);
const stopAnimation = useCallback(() => {
void controls.start("normal");
}, [controls]);
useImperativeHandle(ref, () => {
isControlledRef.current = true;
return {
startAnimation,
stopAnimation
};
});
useEffect(() => {
if (active) {
startAnimation();
return;
}
stopAnimation();
}, [active, startAnimation, stopAnimation]);
const handleMouseEnter = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseEnter?.(event);
} else {
startAnimation();
}
},
[onMouseEnter, startAnimation]
);
const handleMouseLeave = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseLeave?.(event);
} else {
stopAnimation();
}
},
[onMouseLeave, stopAnimation]
);
return (
<div
className={cn("inline-flex items-center justify-center", className)}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
{...props}
>
<svg
fill="none"
height={size}
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
>
<motion.circle
animate={controls}
custom={0}
cx="12"
cy="12"
r="1"
variants={PATH_VARIANTS}
/>
<motion.path
animate={controls}
custom={0.3}
d="M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z"
variants={PATH_VARIANTS}
/>
<motion.path
animate={controls}
custom={0.6}
d="M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z"
variants={PATH_VARIANTS}
/>
</svg>
</div>
);
}
);
AtomIcon.displayName = "AtomIcon";
export { AtomIcon };
@@ -0,0 +1,215 @@
"use client";
import type { HTMLAttributes, MouseEvent } from "react";
import {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useRef
} from "react";
import {
motion,
useAnimation,
useReducedMotion,
type Transition,
type Variants
} from "framer-motion";
import { cn } from "../../lib/utils";
export interface BrainIconHandle {
startAnimation: () => void;
stopAnimation: () => void;
}
interface BrainIconProps extends HTMLAttributes<HTMLDivElement> {
size?: number;
active?: boolean;
}
const brainTransition: Transition = {
duration: 1.4,
repeat: Number.POSITIVE_INFINITY,
repeatType: "mirror" as const,
ease: "easeInOut"
};
const BRAIN_STEM_VARIANTS: Variants = {
normal: { pathLength: 1, pathOffset: 0 },
animate: {
pathLength: [1, 0.4, 1],
pathOffset: [0, 0.25, 0],
transition: brainTransition
}
};
const BRAIN_SIDE_VARIANTS: Variants = {
normal: { pathLength: 1, pathOffset: 0 },
animate: {
pathLength: [1, 0.5, 1],
pathOffset: [0, 0.25, 0],
transition: brainTransition
}
};
const BRAIN_TOP_ARC_VARIANTS: Variants = {
normal: { pathLength: 1, pathOffset: 0 },
animate: {
pathLength: [1, 0.8, 1],
pathOffset: [0, 0.07, 0],
transition: brainTransition
}
};
const BRAIN_LOWER_ARC_VARIANTS: Variants = {
normal: { pathLength: 1, pathOffset: 0 },
animate: {
pathLength: [1, 0.8, 1],
pathOffset: [0, 0.14, 0],
transition: brainTransition
}
};
const BrainIcon = forwardRef<BrainIconHandle, BrainIconProps>(
(
{
active = false,
onMouseEnter,
onMouseLeave,
className,
size = 28,
...props
},
ref
) => {
const controls = useAnimation();
const reduceMotion = useReducedMotion();
const isControlledRef = useRef(false);
const startAnimation = useCallback(() => {
if (reduceMotion) {
return;
}
void controls.start("animate");
}, [controls, reduceMotion]);
const stopAnimation = useCallback(() => {
void controls.start("normal");
}, [controls]);
useImperativeHandle(ref, () => {
isControlledRef.current = true;
return {
startAnimation,
stopAnimation
};
});
useEffect(() => {
if (active) {
startAnimation();
return;
}
stopAnimation();
}, [active, startAnimation, stopAnimation]);
const handleMouseEnter = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseEnter?.(event);
} else {
startAnimation();
}
},
[onMouseEnter, startAnimation]
);
const handleMouseLeave = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseLeave?.(event);
} else {
stopAnimation();
}
},
[onMouseLeave, stopAnimation]
);
return (
<div
className={cn("inline-flex items-center justify-center", className)}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
{...props}
>
<motion.svg
animate={controls}
fill="none"
height={size}
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
variants={{
normal: {
scale: 1,
strokeWidth: 2
},
animate: {
scale: [1, 1.08, 1],
strokeWidth: [2, 2.25, 2],
transition: brainTransition
}
}}
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
>
<motion.path
animate={controls}
d="M12 18V5"
variants={BRAIN_STEM_VARIANTS}
/>
<motion.path
animate={controls}
d="M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4"
variants={BRAIN_SIDE_VARIANTS}
/>
<motion.path
animate={controls}
d="M12 5A3 3 0 1 1 17.598 6.5"
variants={BRAIN_TOP_ARC_VARIANTS}
/>
<motion.path
animate={controls}
d="M12 5A3 3 0 1 0 6.402 6.5"
variants={BRAIN_TOP_ARC_VARIANTS}
/>
<path d="M17.997 5.125a4 4 0 0 1 2.526 5.77" />
<motion.path
animate={controls}
d="M18 18a4 4 0 0 0 2-7.464"
variants={BRAIN_LOWER_ARC_VARIANTS}
/>
<path d="M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517" />
<motion.path
animate={controls}
d="M6 18a4 4 0 0 1-2-7.464"
variants={BRAIN_LOWER_ARC_VARIANTS}
/>
<path d="M6.003 5.125a4 4 0 0 0-2.526 5.77" />
</motion.svg>
</div>
);
}
);
BrainIcon.displayName = "BrainIcon";
export { BrainIcon };
@@ -0,0 +1,156 @@
"use client";
import type { HTMLAttributes, MouseEvent } from "react";
import {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useRef
} from "react";
import {
motion,
useAnimation,
useReducedMotion,
type Variants
} from "framer-motion";
import { cn } from "../../lib/utils";
export interface CastIconHandle {
startAnimation: () => void;
stopAnimation: () => void;
}
interface CastIconProps extends HTMLAttributes<HTMLDivElement> {
size?: number;
active?: boolean;
}
const CAST_VARIANTS: Variants = {
normal: { opacity: 1 },
animate: (custom: number) => ({
opacity: [0.18, 1, 0.18],
transition: {
delay: custom,
duration: 1.1,
repeat: Number.POSITIVE_INFINITY,
ease: "easeInOut"
}
})
};
const CastIcon = forwardRef<CastIconHandle, CastIconProps>(
(
{
active = false,
onMouseEnter,
onMouseLeave,
className,
size = 16,
...props
},
ref
) => {
const controls = useAnimation();
const reduceMotion = useReducedMotion();
const isControlledRef = useRef(false);
const startAnimation = useCallback(() => {
if (reduceMotion) {
return;
}
void controls.start("animate");
}, [controls, reduceMotion]);
const stopAnimation = useCallback(() => {
void controls.start("normal");
}, [controls]);
useImperativeHandle(ref, () => {
isControlledRef.current = true;
return {
startAnimation,
stopAnimation
};
});
useEffect(() => {
if (active) {
startAnimation();
return;
}
stopAnimation();
}, [active, startAnimation, stopAnimation]);
const handleMouseEnter = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseEnter?.(event);
return;
}
startAnimation();
},
[onMouseEnter, startAnimation]
);
const handleMouseLeave = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseLeave?.(event);
return;
}
stopAnimation();
},
[onMouseLeave, stopAnimation]
);
return (
<div
className={cn("inline-flex items-center justify-center", className)}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
{...props}
>
<svg
fill="none"
height={size}
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
>
<path d="M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6" />
<motion.path
animate={controls}
custom={0.2}
d="M2 12a9 9 0 0 1 8 8"
variants={CAST_VARIANTS}
/>
<motion.path
animate={controls}
custom={0.1}
d="M2 16a5 5 0 0 1 4 4"
variants={CAST_VARIANTS}
/>
<motion.line
animate={controls}
custom={0}
variants={CAST_VARIANTS}
x1="2"
x2="2.01"
y1="20"
y2="20"
/>
</svg>
</div>
);
}
);
CastIcon.displayName = "CastIcon";
export { CastIcon };
@@ -0,0 +1,20 @@
import type { JSX, SVGProps } from "react";
/**
* Lined dismiss (24x24 viewBox). Fill uses `currentColor` for panel / chrome close buttons.
* Source asset: `assets/icons/close-lined.svg`.
*/
export function CloseLinedIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden
{...props}
>
<path d="M18.2925 4.29252C18.6829 3.90215 19.316 3.90245 19.7066 4.29252C20.0971 4.68305 20.0971 5.31606 19.7066 5.70659L13.4136 11.9996L19.7066 18.2925C20.0971 18.683 20.0971 19.3161 19.7066 19.7066C19.3161 20.0971 18.6831 20.0971 18.2925 19.7066L11.9996 13.4136L5.70659 19.7066C5.31607 20.0971 4.68305 20.0971 4.29253 19.7066C3.90246 19.316 3.90216 18.6829 4.29253 18.2925L10.5855 11.9996L4.29253 5.70659C3.90246 5.31603 3.90216 4.6829 4.29253 4.29252C4.68291 3.90215 5.31603 3.90245 5.70659 4.29252L11.9996 10.5855L18.2925 4.29252Z" />
</svg>
);
}
@@ -0,0 +1,24 @@
import type { JSX, SVGProps } from "react";
/**
* Lined direct/open glyph (24x24 viewBox). Fill uses `currentColor`.
*/
export function DirectLinedIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden
data-nexight-chrome-glyph="fill"
data-tutti-chrome-glyph="fill"
{...props}
>
<path
fill="currentColor"
d="M11 2C11.5523 2 12 2.44772 12 3C12 3.55228 11.5523 4 11 4H5C4.73478 4 4.4805 4.10543 4.29297 4.29297C4.10543 4.4805 4 4.73478 4 5V19C4 19.2652 4.10543 19.5195 4.29297 19.707C4.48051 19.8946 4.73478 20 5 20H19C19.2652 20 19.5195 19.8946 19.707 19.707C19.8946 19.5195 20 19.2652 20 19V13C20 12.4477 20.4477 12 21 12C21.5523 12 22 12.4477 22 13V19C22 19.7957 21.6837 20.5585 21.1211 21.1211C20.5585 21.6837 19.7957 22 19 22H5C4.20435 22 3.44152 21.6837 2.87891 21.1211C2.3163 20.5585 2 19.7957 2 19V5C2 4.20435 2.3163 3.44152 2.87891 2.87891C3.44152 2.3163 4.20435 2 5 2H11ZM21 2C21.0563 2 21.1113 2.00571 21.165 2.01465C21.1738 2.01611 21.1827 2.01686 21.1914 2.01855L21.2012 2.02051C21.211 2.02252 21.2207 2.02504 21.2305 2.02734C21.251 2.0322 21.2717 2.0368 21.292 2.04297C21.3408 2.05783 21.3873 2.0778 21.4326 2.09961C21.4466 2.10634 21.4609 2.11269 21.4746 2.12012C21.6203 2.19887 21.7441 2.31255 21.835 2.4502C21.8597 2.48768 21.8812 2.52662 21.9004 2.56641C21.9222 2.61159 21.9412 2.65838 21.9561 2.70703C21.9623 2.72732 21.9668 2.74799 21.9717 2.76855C21.9893 2.84294 22 2.92022 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41406L12.707 12.707C12.3165 13.0976 11.6835 13.0976 11.293 12.707C10.9024 12.3165 10.9024 11.6835 11.293 11.293L18.5859 4H15C14.4477 4 14 3.55228 14 3C14 2.44772 14.4477 2 15 2H21Z"
/>
</svg>
);
}
@@ -0,0 +1,180 @@
"use client";
import type { HTMLAttributes, MouseEvent } from "react";
import {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useRef
} from "react";
import {
motion,
useAnimation,
useReducedMotion,
type Variants
} from "framer-motion";
import { cn } from "../../lib/utils";
export interface FilePenLineIconHandle {
startAnimation: () => void;
stopAnimation: () => void;
}
interface FilePenLineIconProps extends HTMLAttributes<HTMLDivElement> {
size?: number;
active?: boolean;
}
const PEN_VARIANTS: Variants = {
normal: {
rotate: 0,
x: 0,
y: 0
},
animate: {
rotate: [-0.3, 0.2, -0.4],
x: [0, -0.5, 1, 0],
y: [0, 1, -0.5, 0],
transition: {
duration: 0.5,
repeat: 1,
ease: "easeInOut"
}
},
active: {
rotate: [-0.3, 0.2, -0.4],
x: [0, -0.5, 1, 0],
y: [0, 1, -0.5, 0],
transition: {
duration: 0.5,
repeat: Number.POSITIVE_INFINITY,
repeatDelay: 0.75,
ease: "easeInOut"
}
}
};
const LINE_VARIANTS: Variants = {
normal: { d: "M8 18h1" },
animate: {
d: "M8 18h5",
transition: { duration: 0.5 }
},
active: {
d: ["M8 18h1", "M8 18h5", "M8 18h1"],
transition: {
duration: 0.8,
repeat: Number.POSITIVE_INFINITY,
repeatDelay: 0.45,
ease: "easeInOut"
}
}
};
const FilePenLineIcon = forwardRef<FilePenLineIconHandle, FilePenLineIconProps>(
(
{
active = false,
onMouseEnter,
onMouseLeave,
className,
size = 28,
...props
},
ref
) => {
const controls = useAnimation();
const reduceMotion = useReducedMotion();
const isControlledRef = useRef(false);
const startAnimation = useCallback(() => {
if (reduceMotion) {
return;
}
void controls.start(active ? "active" : "animate");
}, [active, controls, reduceMotion]);
const stopAnimation = useCallback(() => {
void controls.start("normal");
}, [controls]);
useImperativeHandle(ref, () => {
isControlledRef.current = true;
return {
startAnimation,
stopAnimation
};
});
useEffect(() => {
if (active) {
startAnimation();
return;
}
stopAnimation();
}, [active, startAnimation, stopAnimation]);
const handleMouseEnter = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseEnter?.(event);
} else {
startAnimation();
}
},
[onMouseEnter, startAnimation]
);
const handleMouseLeave = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseLeave?.(event);
} else {
stopAnimation();
}
},
[onMouseLeave, stopAnimation]
);
return (
<div
className={cn("inline-flex items-center justify-center", className)}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
{...props}
>
<svg
fill="none"
height={size}
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
>
<path d="m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2" />
<motion.path
animate={controls}
d="M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z"
initial="normal"
variants={PEN_VARIANTS}
/>
<motion.path
animate={controls}
d="M8 18h1"
initial="normal"
variants={LINE_VARIANTS}
/>
</svg>
</div>
);
}
);
FilePenLineIcon.displayName = "FilePenLineIcon";
export { FilePenLineIcon };
@@ -0,0 +1,189 @@
"use client";
import type { HTMLAttributes, MouseEvent } from "react";
import {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useRef
} from "react";
import {
motion,
useAnimation,
useReducedMotion,
type Variants
} from "framer-motion";
import { cn } from "../../lib/utils";
export interface FileTextIconHandle {
startAnimation: () => void;
stopAnimation: () => void;
}
interface FileTextIconProps extends HTMLAttributes<HTMLDivElement> {
size?: number;
active?: boolean;
}
const FILE_TEXT_LINE_VARIANTS: Variants = {
normal: {
pathLength: 1,
pathOffset: 0
},
animate: (delay: number) => ({
pathLength: [1, 0, 1],
pathOffset: [0, 1, 0],
transition: {
duration: 0.7,
delay,
ease: "easeInOut"
}
}),
active: (delay: number) => ({
pathLength: [1, 0, 1],
pathOffset: [0, 1, 0],
transition: {
duration: 0.7,
delay,
ease: "easeInOut",
repeat: Number.POSITIVE_INFINITY,
repeatDelay: 1.1
}
})
};
const FileTextIcon = forwardRef<FileTextIconHandle, FileTextIconProps>(
(
{
active = false,
onMouseEnter,
onMouseLeave,
className,
size = 28,
...props
},
ref
) => {
const controls = useAnimation();
const reduceMotion = useReducedMotion();
const isControlledRef = useRef(false);
const startAnimation = useCallback(() => {
if (reduceMotion) {
return;
}
void controls.start(active ? "active" : "animate");
}, [active, controls, reduceMotion]);
const stopAnimation = useCallback(() => {
void controls.start("normal");
}, [controls]);
useImperativeHandle(ref, () => {
isControlledRef.current = true;
return {
startAnimation,
stopAnimation
};
});
useEffect(() => {
if (active) {
startAnimation();
return;
}
stopAnimation();
}, [active, startAnimation, stopAnimation]);
const handleMouseEnter = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseEnter?.(event);
} else {
startAnimation();
}
},
[onMouseEnter, startAnimation]
);
const handleMouseLeave = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseLeave?.(event);
} else {
stopAnimation();
}
},
[onMouseLeave, stopAnimation]
);
return (
<div
className={cn("inline-flex items-center justify-center", className)}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
{...props}
>
<motion.svg
animate={controls}
fill="none"
height={size}
initial="normal"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
variants={{
normal: { scale: 1 },
animate: {
scale: 1.05,
transition: {
duration: 0.3,
ease: "easeOut"
}
},
active: {
scale: [1, 1.05, 1],
transition: {
duration: 0.9,
ease: "easeInOut",
repeat: Number.POSITIVE_INFINITY,
repeatDelay: 0.9
}
}
}}
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
>
<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" />
<path d="M14 2v4a2 2 0 0 0 2 2h4" />
<motion.path
animate={controls}
custom={0.3}
d="M10 9H8"
variants={FILE_TEXT_LINE_VARIANTS}
/>
<motion.path
animate={controls}
custom={0.5}
d="M16 13H8"
variants={FILE_TEXT_LINE_VARIANTS}
/>
<motion.path
animate={controls}
custom={0.7}
d="M16 17H8"
variants={FILE_TEXT_LINE_VARIANTS}
/>
</motion.svg>
</div>
);
}
);
FileTextIcon.displayName = "FileTextIcon";
export { FileTextIcon };
@@ -0,0 +1,20 @@
import type { JSX, SVGProps } from "react";
export function GridBottomLinedIcon(
props: SVGProps<SVGSVGElement>
): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden
data-tutti-chrome-glyph="fill"
data-nexight-chrome-glyph="fill"
{...props}
>
<path d="M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H19ZM4 16V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V16H4ZM5 4C4.44772 4 4 4.44772 4 5V14H20V5C20 4.44772 19.5523 4 19 4H5Z" />
</svg>
);
}
@@ -0,0 +1,18 @@
import type { JSX, SVGProps } from "react";
export function GridLeftLinedIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden
data-tutti-chrome-glyph="fill"
data-nexight-chrome-glyph="fill"
{...props}
>
<path d="M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H19ZM10 20H19C19.5523 20 20 19.5523 20 19V5C20 4.44772 19.5523 4 19 4H10V20ZM5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H8V4H5Z" />
</svg>
);
}
@@ -0,0 +1,20 @@
import type { JSX, SVGProps } from "react";
export function GridRightLinedIcon(
props: SVGProps<SVGSVGElement>
): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden
data-tutti-chrome-glyph="fill"
data-nexight-chrome-glyph="fill"
{...props}
>
<path d="M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H19ZM16 20H19C19.5523 20 20 19.5523 20 19V5C20 4.44772 19.5523 4 19 4H16V20ZM5 4C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H14V4H5Z" />
</svg>
);
}
@@ -0,0 +1,18 @@
import type { JSX, SVGProps } from "react";
export function GridTopLinedIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden
data-tutti-chrome-glyph="fill"
data-nexight-chrome-glyph="fill"
{...props}
>
<path d="M19 2C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2H19ZM4 10V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V10H4ZM5 4C4.44772 4 4 4.44772 4 5V8H20V5C20 4.44772 19.5523 4 19 4H5Z" />
</svg>
);
}
@@ -0,0 +1,153 @@
import type { HTMLAttributes, MouseEvent } from "react";
import {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useRef
} from "react";
import {
motion,
useAnimation,
useReducedMotion,
type Variants
} from "framer-motion";
import { cn } from "../../lib/utils";
export interface HammerIconHandle {
startAnimation: () => void;
stopAnimation: () => void;
}
interface HammerIconProps extends HTMLAttributes<HTMLDivElement> {
size?: number;
active?: boolean;
}
const HAMMER_VARIANTS: Variants = {
normal: {
rotate: 0,
transition: {
duration: 0.3,
ease: "easeOut"
}
},
animate: {
rotate: [0, -20, 25, 0],
transition: {
duration: 0.8,
times: [0, 0.6, 0.8, 1],
ease: ["easeInOut", "easeOut", "easeOut"]
}
},
active: {
rotate: [0, -20, 25, 0],
transition: {
duration: 0.8,
times: [0, 0.6, 0.8, 1],
ease: ["easeInOut", "easeOut", "easeOut"],
repeat: Infinity,
repeatDelay: 0.9
}
}
};
const HammerIcon = forwardRef<HammerIconHandle, HammerIconProps>(
(
{
active = false,
onMouseEnter,
onMouseLeave,
className,
size = 28,
...props
},
ref
) => {
const controls = useAnimation();
const reduceMotion = useReducedMotion();
const isControlledRef = useRef(false);
const startAnimation = useCallback(() => {
if (reduceMotion) {
return;
}
void controls.start(active ? "active" : "animate");
}, [active, controls, reduceMotion]);
const stopAnimation = useCallback(() => {
void controls.start("normal");
}, [controls]);
useImperativeHandle(ref, () => {
isControlledRef.current = true;
return {
startAnimation,
stopAnimation
};
});
useEffect(() => {
if (active) {
startAnimation();
return;
}
stopAnimation();
}, [active, startAnimation, stopAnimation]);
const handleMouseEnter = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseEnter?.(event);
} else {
startAnimation();
}
},
[onMouseEnter, startAnimation]
);
const handleMouseLeave = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseLeave?.(event);
} else {
stopAnimation();
}
},
[onMouseLeave, stopAnimation]
);
return (
<div
className={cn("inline-flex items-center justify-center", className)}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
{...props}
>
<motion.svg
animate={controls}
fill="none"
height={size}
initial="normal"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
style={{ transformOrigin: "0% 100%", transformBox: "fill-box" }}
variants={HAMMER_VARIANTS}
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
>
<path d="m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9" />
<path d="m18 15 4-4" />
<path d="m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5" />
</motion.svg>
</div>
);
}
);
HammerIcon.displayName = "HammerIcon";
export { HammerIcon };
@@ -0,0 +1,181 @@
"use client";
import type { HTMLAttributes, MouseEvent } from "react";
import {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useRef
} from "react";
import {
motion,
useAnimation,
useReducedMotion,
type Variants
} from "framer-motion";
import { cn } from "../../lib/utils";
export interface MessageSquareMoreIconHandle {
startAnimation: () => void;
stopAnimation: () => void;
}
interface MessageSquareMoreIconProps extends HTMLAttributes<HTMLDivElement> {
size?: number;
active?: boolean;
}
const DOT_TRANSITION = {
times: [0, 0.1, 0.1, 0.2, 0.5, 0.6, 0.6, 0.7],
duration: 1.5
};
const DOT_VARIANTS: Variants = {
normal: {
opacity: 1
},
animate: (custom: number) => ({
opacity: [1, 0, 0, 1, 1, 0, 0, 1],
transition: {
opacity: {
...DOT_TRANSITION,
times: DOT_TRANSITION.times.map((time, index) =>
index === 2 || index === 3 || index === 6 || index === 7
? time + custom * 0.1
: time
)
}
}
}),
active: (custom: number) => ({
opacity: [1, 0, 0, 1, 1, 0, 0, 1],
transition: {
opacity: {
...DOT_TRANSITION,
repeat: Infinity,
times: DOT_TRANSITION.times.map((time, index) =>
index === 2 || index === 3 || index === 6 || index === 7
? time + custom * 0.1
: time
)
}
}
})
};
const MessageSquareMoreIcon = forwardRef<
MessageSquareMoreIconHandle,
MessageSquareMoreIconProps
>(
(
{
active = false,
onMouseEnter,
onMouseLeave,
className,
size = 28,
...props
},
ref
) => {
const controls = useAnimation();
const reduceMotion = useReducedMotion();
const isControlledRef = useRef(false);
const startAnimation = useCallback(() => {
if (reduceMotion) {
return;
}
void controls.start(active ? "active" : "animate");
}, [active, controls, reduceMotion]);
const stopAnimation = useCallback(() => {
void controls.start("normal");
}, [controls]);
useImperativeHandle(ref, () => {
isControlledRef.current = true;
return {
startAnimation,
stopAnimation
};
});
useEffect(() => {
if (active) {
startAnimation();
return;
}
stopAnimation();
}, [active, startAnimation, stopAnimation]);
const handleMouseEnter = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseEnter?.(event);
} else {
startAnimation();
}
},
[onMouseEnter, startAnimation]
);
const handleMouseLeave = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (isControlledRef.current) {
onMouseLeave?.(event);
} else {
stopAnimation();
}
},
[onMouseLeave, stopAnimation]
);
return (
<div
className={cn("inline-flex items-center justify-center", className)}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
{...props}
>
<svg
fill="none"
height={size}
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
>
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
<motion.path
animate={controls}
custom={0}
d="M8 10h.01"
variants={DOT_VARIANTS}
/>
<motion.path
animate={controls}
custom={1}
d="M12 10h.01"
variants={DOT_VARIANTS}
/>
<motion.path
animate={controls}
custom={2}
d="M16 10h.01"
variants={DOT_VARIANTS}
/>
</svg>
</div>
);
}
);
MessageSquareMoreIcon.displayName = "MessageSquareMoreIcon";
export { MessageSquareMoreIcon };
@@ -0,0 +1,19 @@
import type { JSX, SVGProps } from "react";
/**
* Filled pin (24x24 viewBox). Fill uses `currentColor` for active conversation pin buttons.
*/
export function PinFilledIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden
{...props}
>
<path d="M21.6066 8.05025C22.1692 8.61286 22.4849 9.37592 22.4849 10.1716C22.4849 10.9672 22.1692 11.7303 21.6066 12.2929C21.044 12.8555 20.2809 13.1713 19.4853 13.1713C18.6896 13.1713 17.9266 12.8555 17.3639 12.2929L14.7054 14.9514L14.6142 15.0564C14.531 15.1669 14.4714 15.2943 14.4395 15.43C14.3972 15.6109 14.406 15.8 14.4651 15.9762L14.4678 15.9831L15.0873 17.8717L15.1466 18.072C15.2691 18.5425 15.2761 19.037 15.1646 19.5124C15.0372 20.0557 14.7607 20.5526 14.3663 20.9474L13.8284 21.4853C13.4533 21.8604 12.9446 22.0709 12.4142 22.0709C11.8838 22.0709 11.3751 21.8604 11 21.4853L7.46445 17.9497L4.63603 20.7782C4.2455 21.1687 3.61234 21.1687 3.22181 20.7782C2.83129 20.3877 2.83129 19.7545 3.22181 19.364L6.05024 16.5355L2.51471 13C2.13963 12.6249 1.92913 12.1162 1.92913 11.5858C1.92913 11.0554 2.13963 10.5466 2.51471 10.1716L3.05263 9.63365L3.20524 9.49209C3.57235 9.17309 4.01205 8.94693 4.48756 8.83539C5.03093 8.70798 5.59924 8.73494 6.12827 8.91273L8.01688 9.53214L8.02379 9.5349C8.19995 9.59404 8.38907 9.60282 8.57 9.56045C8.7057 9.52863 8.83304 9.46898 8.94358 9.38575L9.04854 9.2946L11.7071 6.63604C11.1445 6.07343 10.8287 5.31037 10.8287 4.51472C10.8287 3.71907 11.1445 2.95601 11.7071 2.3934C12.2697 1.83079 13.0328 1.51504 13.8284 1.51504C14.6241 1.51504 15.3871 1.83079 15.9497 2.3934L21.6066 8.05025Z" />
</svg>
);
}
@@ -0,0 +1,19 @@
import type { JSX, SVGProps } from "react";
/**
* Lined pin (24x24 viewBox). Fill uses `currentColor` for conversation pin buttons.
*/
export function PinLinedIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden
{...props}
>
<path d="M21.6066 8.05025C22.1692 8.61286 22.4849 9.37592 22.4849 10.1716C22.4849 10.9672 22.1692 11.7303 21.6066 12.2929C21.044 12.8555 20.2809 13.1713 19.4853 13.1713C18.6896 13.1713 17.9266 12.8555 17.3639 12.2929L14.7054 14.9514L14.6142 15.0564C14.531 15.1669 14.4714 15.2943 14.4395 15.43C14.3972 15.6109 14.406 15.8 14.4651 15.9762L14.4678 15.9831L15.0873 17.8717L15.1466 18.072C15.2691 18.5425 15.2761 19.037 15.1646 19.5124C15.0372 20.0557 14.7607 20.5526 14.3663 20.9474L13.8284 21.4853C13.4533 21.8604 12.9446 22.0709 12.4142 22.0709C11.8838 22.0709 11.3751 21.8604 11 21.4853L7.46445 17.9497L4.63603 20.7782C4.2455 21.1687 3.61234 21.1687 3.22181 20.7782C2.83129 20.3877 2.83129 19.7545 3.22181 19.364L6.05024 16.5355L2.51471 13C2.13963 12.6249 1.92913 12.1162 1.92913 11.5858C1.92913 11.0554 2.13963 10.5466 2.51471 10.1716L3.05263 9.63365L3.20524 9.49209C3.57235 9.17309 4.01205 8.94693 4.48756 8.83539C5.03093 8.70798 5.59924 8.73494 6.12827 8.91273L8.01688 9.53214L8.02379 9.5349C8.19995 9.59404 8.38907 9.60282 8.57 9.56045C8.7057 9.52863 8.83304 9.46898 8.94358 9.38575L9.04854 9.2946L11.7071 6.63604C11.1445 6.07343 10.8287 5.31037 10.8287 4.51472C10.8287 3.71907 11.1445 2.95601 11.7071 2.3934C12.2697 1.83079 13.0328 1.51504 13.8284 1.51504C14.6241 1.51504 15.3871 1.83079 15.9497 2.3934L21.6066 8.05025ZM14.5355 3.80761C14.348 3.62008 14.0936 3.51483 13.8284 3.51483C13.5632 3.51483 13.3088 3.62008 13.1213 3.80761C12.9338 3.99515 12.8285 4.2495 12.8285 4.51472C12.8285 4.74685 12.9091 4.97066 13.055 5.14863L13.2539 5.36822C13.5457 5.72416 13.7069 6.17177 13.7069 6.63604C13.7069 7.16647 13.4964 7.67518 13.1213 8.05025L10.4621 10.7095C10.0673 11.1038 9.57037 11.3803 9.02713 11.5078C8.48575 11.6347 7.92002 11.6071 7.39264 11.4311V11.4325L5.49781 10.811L5.49091 10.8082C5.31475 10.7491 5.12562 10.7403 4.94469 10.7827C4.76366 10.8251 4.59774 10.9172 4.46615 11.0486L3.92892 11.5858L12.4142 20.0711L12.9514 19.5338C13.0828 19.4022 13.1748 19.2363 13.2173 19.0553C13.2597 18.8744 13.2509 18.6852 13.1917 18.5091L13.189 18.5022L12.5675 16.6073L12.5682 16.6067C12.3924 16.0795 12.3654 15.514 12.4922 14.9729C12.6197 14.4296 12.8962 13.9327 13.2905 13.5379L15.9497 10.8787C16.3248 10.5036 16.8335 10.2931 17.3639 10.2931C17.8282 10.2931 18.2758 10.4543 18.6318 10.7461L18.8514 10.945C19.0293 11.0909 19.2531 11.1715 19.4853 11.1715C19.7505 11.1715 20.0048 11.0662 20.1924 10.8787C20.3799 10.6911 20.4852 10.4368 20.4852 10.1716C20.4852 9.90636 20.3799 9.652 20.1924 9.46447L14.5355 3.80761Z" />
</svg>
);
}
@@ -0,0 +1,28 @@
import type { JSX, SVGProps } from "react";
export function SettingsLinedIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
"use memo";
return (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M12 8C9.79088 8 8.00002 9.79086 8.00002 12C8.00002 14.2091 9.79088 16 12 16C14.2092 16 16 14.2091 16 12C16 9.79086 14.2092 8 12 8ZM10 12C10 10.8954 10.8955 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14C10.8955 14 10 13.1046 10 12Z"
fill="currentColor"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M12.5147 2.08484C12.1951 1.90505 11.8048 1.90505 11.4852 2.08484L3.48518 6.58484C3.15456 6.77082 2.94995 7.12066 2.94995 7.5V16.5C2.94995 16.8793 3.15456 17.2292 3.48518 17.4152L11.4852 21.9152C11.8048 22.0949 12.1951 22.0949 12.5147 21.9152L20.5147 17.4152C20.8453 17.2292 21.0499 16.8793 21.0499 16.5V7.5C21.0499 7.12066 20.8453 6.77082 20.5147 6.58484L12.5147 2.08484ZM5.04995 15.8859V8.11409L12 4.20471L18.95 8.11409V15.8859L12 19.7953L5.04995 15.8859Z"
fill="currentColor"
/>
</svg>
);
}
@@ -0,0 +1,18 @@
import type { SVGProps } from "react";
export function ToolsLinedIcon(props: SVGProps<SVGSVGElement>) {
"use memo";
return (
<svg
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M12.5166 2C14.3722 2.0005 16.1516 2.73783 17.4639 4.0498L19.1211 5.70703L19.3203 5.92676C19.7578 6.46048 19.9999 7.13198 20 7.82812V8.17188L20.0049 8.27051C20.0276 8.49945 20.1288 8.71482 20.293 8.87891L21.5303 10.1162C21.9083 9.9151 22.3885 9.97443 22.707 10.293C23.0976 10.6835 23.0976 11.3165 22.707 11.707L18.707 15.707C18.3165 16.0976 17.6835 16.0976 17.293 15.707C16.9744 15.3885 16.9151 14.9083 17.1162 14.5303L15.8789 13.293C15.7431 13.1571 15.5715 13.0672 15.3867 13.0264L6.33398 22.0801C6.0442 22.3699 5.69992 22.5999 5.32129 22.7568C4.94266 22.9137 4.53679 22.995 4.12695 22.9951C3.29924 22.9952 2.50538 22.6661 1.91992 22.0811C1.3344 21.4957 1.00502 20.701 1.00488 19.873C1.00487 19.0453 1.33373 18.2514 1.91895 17.666L11 8.58496V8.48535C10.9999 7.1596 10.4734 5.88777 9.53613 4.9502L8.29297 3.70703C8.00697 3.42103 7.92139 2.99086 8.07617 2.61719C8.23098 2.24359 8.59558 2 9 2H12.5166ZM3.33301 19.0801C3.12284 19.2904 3.00487 19.5757 3.00488 19.873C3.00493 20.1705 3.12359 20.4557 3.33398 20.666C3.54437 20.8763 3.82951 20.9952 4.12695 20.9951C4.27409 20.9951 4.41972 20.9655 4.55566 20.9092C4.69174 20.8528 4.81578 20.7702 4.91992 20.666L13.0859 12.5L11.499 10.9131L3.33301 19.0801ZM11.3721 4C12.4187 5.2535 12.9999 6.83919 13 8.48535V9.58594L14.4141 11H15.1719C15.9674 11.0002 16.7305 11.3164 17.293 11.8789L18.5 13.0859L20.0859 11.5L18.8789 10.293C18.3164 9.73051 18.0002 8.96738 18 8.17188V7.82812C17.9999 7.56296 17.8946 7.30857 17.707 7.12109L16.0498 5.46387C15.1124 4.52677 13.8411 4.00028 12.5156 4H11.3721Z"
fill="currentColor"
/>
</svg>
);
}
@@ -0,0 +1,22 @@
import type { JSX, SVGProps } from "react";
/**
* Unavailable chat (25x25 viewBox). Fill uses `currentColor` so empty states can
* inherit the semantic text color.
*/
export function UnavailableChatIcon(
props: SVGProps<SVGSVGElement>
): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 25 25"
fill="currentColor"
aria-hidden
{...props}
>
<path d="M20.833 2.125C21.6507 2.125 22.4355 2.45019 23.0137 3.02832C23.5916 3.60645 23.9159 4.39053 23.916 5.20801V17.708C23.916 18.5257 23.5918 19.3104 23.0137 19.8887C22.4355 20.4668 21.6507 20.792 20.833 20.792H7.1123C6.82516 20.7922 6.5497 20.9063 6.34668 21.1094L4.05273 23.4033C3.80954 23.6464 3.49934 23.8118 3.16211 23.8789C2.82492 23.9459 2.47487 23.9118 2.15723 23.7803C1.83953 23.6486 1.56707 23.4256 1.37598 23.1396C1.18489 22.8536 1.08305 22.5168 1.08301 22.1729V5.20801C1.08309 4.39045 1.40827 3.60647 1.98633 3.02832C2.56441 2.45024 3.3485 2.12517 4.16602 2.125H20.833ZM16.1533 7.80566C15.7628 7.41518 15.1298 7.41527 14.7393 7.80566L12.5 10.0439L10.2607 7.80469C9.87031 7.41464 9.23712 7.41465 8.84668 7.80469C8.45627 8.19509 8.45651 8.8282 8.84668 9.21875L11.0859 11.458L8.84668 13.6982C8.45651 14.0888 8.45627 14.7219 8.84668 15.1123C9.2371 15.5026 9.87024 15.5024 10.2607 15.1123L12.5 12.873L14.7393 15.1113C15.1298 15.5017 15.7628 15.5018 16.1533 15.1113C16.5434 14.7208 16.5436 14.0877 16.1533 13.6973L13.9141 11.458L16.1533 9.21973C16.5437 8.82924 16.5437 8.19616 16.1533 7.80566Z" />
</svg>
);
}
@@ -0,0 +1,22 @@
import type { JSX, SVGProps } from "react";
/**
* Lined write glyph (24x24 viewBox). Fill uses `currentColor`.
*/
export function WriteLinedIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
"use memo";
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
aria-hidden
{...props}
>
<path
fill="currentColor"
d="M19.1816 1C20.1944 1.00019 21.1658 1.40292 21.8818 2.11914C22.5976 2.83537 23.0001 3.8067 23 4.81934C22.9998 5.7688 22.6461 6.68243 22.0117 7.38281L21.8808 7.51953L19.79 9.60937C19.7641 9.6428 19.7377 9.67636 19.707 9.70703C19.6763 9.7377 19.6428 9.76419 19.6093 9.79004L8.53414 20.8682L8.53317 20.8691C8.1855 21.2156 7.75766 21.4724 7.28805 21.6152H7.28707L2.93454 22.9355L2.93161 22.9365C2.67255 23.0143 2.39705 23.02 2.13473 22.9541C1.87235 22.8881 1.63194 22.7526 1.44039 22.5615C1.24885 22.3703 1.11234 22.1296 1.04586 21.8672C0.979582 21.605 0.985166 21.3294 1.06246 21.0703L1.06442 21.0664L2.38473 16.7139L2.38571 16.7109C2.52986 16.2409 2.78761 15.813 3.13571 15.4658L14.2089 4.38867C14.2346 4.35552 14.2625 4.32341 14.2929 4.29297C14.3234 4.26252 14.3555 4.23468 14.3886 4.20898L16.4804 2.11816C17.1967 1.40209 18.1688 0.999896 19.1816 1ZM4.54879 16.8818L4.54782 16.8828C4.43196 16.9985 4.34581 17.1413 4.29782 17.2978L3.24899 20.749L6.70602 19.7012L6.82028 19.6592C6.93185 19.6097 7.0341 19.5397 7.12106 19.4531L17.5791 8.99316L15.0068 6.4209L4.54879 16.8818ZM19.1816 3C18.6995 2.99996 18.2366 3.19147 17.8955 3.53223L16.4209 5.00683L18.9931 7.5791L20.4668 6.10547L20.5879 5.97168C20.8529 5.64823 20.9998 5.24116 21 4.81934C21 4.33701 20.8077 3.87434 20.4668 3.5332C20.1258 3.19221 19.6638 3.00019 19.1816 3Z"
/>
</svg>
);
}
@@ -0,0 +1,61 @@
import * as React from "react";
import { Button as UISystemButton, buttonVariants } from "@tutti-os/ui-system";
import { cn } from "../../lib/utils";
type UISystemButtonProps = React.ComponentProps<typeof UISystemButton>;
type LegacyButtonSize =
| UISystemButtonProps["size"]
| "mini"
| "md"
| "max"
| "iconClose";
export interface ButtonProps extends Omit<UISystemButtonProps, "size"> {
size?: LegacyButtonSize;
}
function resolveButtonSize(
size: LegacyButtonSize | undefined
): UISystemButtonProps["size"] {
switch (size) {
case "mini":
return "xs";
case "md":
return "default";
case "max":
return "lg";
case "iconClose":
return "icon-sm";
default:
return size;
}
}
function resolveButtonClassName(
size: LegacyButtonSize | undefined,
className: string | undefined
): string | undefined {
if (size !== "iconClose") {
return className;
}
return cn(
"h-[28px] w-[28px] min-h-[28px] min-w-[28px] shrink-0 rounded-[4px] p-0 [&_svg]:size-[14px]",
className
);
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, size, ...props }, ref) => (
<UISystemButton
ref={ref}
className={resolveButtonClassName(size, className)}
size={resolveButtonSize(size)}
{...props}
/>
)
);
Button.displayName = "Button";
export { Button, buttonVariants };
@@ -0,0 +1,334 @@
import {
forwardRef,
useCallback,
useEffect,
useRef,
useState,
type HTMLAttributes,
type ForwardedRef,
type MouseEvent as ReactMouseEvent,
type MutableRefObject,
type ReactNode
} from "react";
import { cn } from "../../lib/utils";
const MIN_THUMB_HEIGHT = 24;
interface ScrollbarState {
scrollable: boolean;
thumbHeight: number;
thumbTop: number;
}
interface ScrollbarDragState {
maxScrollTop: number;
maxThumbTop: number;
startClientY: number;
startScrollTop: number;
}
export interface CustomScrollbarProps {
getViewport: () => HTMLElement | null;
className?: string;
thumbClassName?: string;
testId?: string;
thumbTestId?: string;
syncKey?: unknown;
}
export function CustomScrollbar({
getViewport,
className,
thumbClassName,
testId,
thumbTestId,
syncKey
}: CustomScrollbarProps): React.JSX.Element {
"use memo";
const trackRef = useRef<HTMLDivElement | null>(null);
const dragStateRef = useRef<ScrollbarDragState | null>(null);
const [scrollbarState, setScrollbarState] = useState<ScrollbarState>({
scrollable: false,
thumbHeight: 0,
thumbTop: 0
});
const [dragging, setDragging] = useState(false);
const syncScrollbarState = useCallback(() => {
const viewport = getViewport();
if (!viewport) {
setScrollbarState({ scrollable: false, thumbHeight: 0, thumbTop: 0 });
return;
}
const { clientHeight, scrollHeight, scrollTop } = viewport;
const trackHeight = trackRef.current?.clientHeight ?? clientHeight;
const maxScrollTop = Math.max(0, scrollHeight - clientHeight);
if (clientHeight <= 0 || trackHeight <= 0 || maxScrollTop <= 0) {
setScrollbarState({ scrollable: false, thumbHeight: 0, thumbTop: 0 });
return;
}
const thumbHeight = Math.max(
MIN_THUMB_HEIGHT,
Math.round((clientHeight / scrollHeight) * trackHeight)
);
const maxThumbTop = Math.max(0, trackHeight - thumbHeight);
const thumbTop = Math.round((scrollTop / maxScrollTop) * maxThumbTop);
setScrollbarState((previous) =>
previous.scrollable &&
previous.thumbHeight === thumbHeight &&
previous.thumbTop === thumbTop
? previous
: { scrollable: true, thumbHeight, thumbTop }
);
}, [getViewport]);
const scrollViewportToThumbTop = useCallback(
(thumbTop: number) => {
const viewport = getViewport();
const track = trackRef.current;
if (!viewport || !track) {
return;
}
const maxScrollTop = Math.max(
0,
viewport.scrollHeight - viewport.clientHeight
);
const maxThumbTop = Math.max(
0,
track.clientHeight - scrollbarState.thumbHeight
);
if (maxScrollTop <= 0 || maxThumbTop <= 0) {
return;
}
viewport.scrollTop =
(clamp(thumbTop, 0, maxThumbTop) / maxThumbTop) * maxScrollTop;
syncScrollbarState();
},
[getViewport, scrollbarState.thumbHeight, syncScrollbarState]
);
const handleTrackMouseDown = useCallback(
(event: ReactMouseEvent<HTMLDivElement>) => {
if (event.button !== 0 || !scrollbarState.scrollable) {
return;
}
const track = trackRef.current;
if (!track) {
return;
}
event.preventDefault();
event.stopPropagation();
const trackRect = track.getBoundingClientRect();
scrollViewportToThumbTop(
event.clientY - trackRect.top - scrollbarState.thumbHeight / 2
);
},
[
scrollViewportToThumbTop,
scrollbarState.scrollable,
scrollbarState.thumbHeight
]
);
const handleThumbMouseDown = useCallback(
(event: ReactMouseEvent<HTMLDivElement>) => {
if (event.button !== 0 || !scrollbarState.scrollable) {
return;
}
const viewport = getViewport();
const track = trackRef.current;
if (!viewport || !track) {
return;
}
const maxScrollTop = Math.max(
0,
viewport.scrollHeight - viewport.clientHeight
);
const maxThumbTop = Math.max(
0,
track.clientHeight - scrollbarState.thumbHeight
);
if (maxScrollTop <= 0 || maxThumbTop <= 0) {
return;
}
event.preventDefault();
event.stopPropagation();
dragStateRef.current = {
maxScrollTop,
maxThumbTop,
startClientY: event.clientY,
startScrollTop: viewport.scrollTop
};
setDragging(true);
},
[getViewport, scrollbarState.scrollable, scrollbarState.thumbHeight]
);
useEffect(() => {
if (!dragging) {
return;
}
const handleMouseMove = (event: MouseEvent): void => {
const dragState = dragStateRef.current;
const viewport = getViewport();
if (!dragState || !viewport) {
return;
}
const nextThumbTop =
(dragState.startScrollTop / dragState.maxScrollTop) *
dragState.maxThumbTop +
(event.clientY - dragState.startClientY);
viewport.scrollTop =
(clamp(nextThumbTop, 0, dragState.maxThumbTop) /
dragState.maxThumbTop) *
dragState.maxScrollTop;
syncScrollbarState();
};
const handleMouseUp = (): void => {
dragStateRef.current = null;
setDragging(false);
};
window.addEventListener("mousemove", handleMouseMove);
window.addEventListener("mouseup", handleMouseUp);
return () => {
window.removeEventListener("mousemove", handleMouseMove);
window.removeEventListener("mouseup", handleMouseUp);
};
}, [dragging, getViewport, syncScrollbarState]);
useEffect(() => {
const viewport = getViewport();
if (!viewport) {
setScrollbarState({ scrollable: false, thumbHeight: 0, thumbTop: 0 });
return;
}
syncScrollbarState();
viewport.addEventListener("scroll", syncScrollbarState, { passive: true });
const resizeObserver =
typeof ResizeObserver !== "undefined"
? new ResizeObserver(syncScrollbarState)
: null;
resizeObserver?.observe(viewport);
const animationFrameId = window.requestAnimationFrame(syncScrollbarState);
return () => {
window.cancelAnimationFrame(animationFrameId);
viewport.removeEventListener("scroll", syncScrollbarState);
resizeObserver?.disconnect();
};
}, [getViewport, syncKey, syncScrollbarState]);
return (
<div
ref={trackRef}
className={cn("tsh-custom-scrollbar", className)}
data-scrollable={scrollbarState.scrollable ? "true" : "false"}
data-dragging={dragging ? "true" : "false"}
data-testid={testId}
aria-hidden="true"
onMouseDown={handleTrackMouseDown}
>
<div
className={cn("tsh-custom-scrollbar__thumb", thumbClassName)}
data-testid={thumbTestId}
onMouseDown={handleThumbMouseDown}
style={{
height: `${scrollbarState.thumbHeight}px`,
transform: `translateY(${scrollbarState.thumbTop}px)`
}}
/>
</div>
);
}
export interface CustomScrollAreaProps extends HTMLAttributes<HTMLDivElement> {
children: ReactNode;
viewportClassName?: string;
scrollbarClassName?: string;
scrollbarThumbClassName?: string;
scrollbarTestId?: string;
scrollbarThumbTestId?: string;
syncKey?: unknown;
}
export const CustomScrollArea = forwardRef<
HTMLDivElement,
CustomScrollAreaProps
>(function CustomScrollArea(
{
children,
className,
viewportClassName,
scrollbarClassName,
scrollbarThumbClassName,
scrollbarTestId,
scrollbarThumbTestId,
syncKey,
...viewportProps
},
forwardedRef
): React.JSX.Element {
"use memo";
const viewportRef = useRef<HTMLDivElement | null>(null);
const getViewport = useCallback(() => viewportRef.current, []);
return (
<div
className={cn(
"tsh-custom-scroll-area relative min-h-0 min-w-0",
className
)}
>
<div
ref={setRefs(viewportRef, forwardedRef)}
className={cn(
"overflow-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
viewportClassName
)}
{...viewportProps}
>
{children}
</div>
<CustomScrollbar
getViewport={getViewport}
className={scrollbarClassName}
thumbClassName={scrollbarThumbClassName}
testId={scrollbarTestId}
thumbTestId={scrollbarThumbTestId}
syncKey={syncKey ?? children}
/>
</div>
);
});
function setRefs<T>(
localRef: MutableRefObject<T | null>,
forwardedRef: ForwardedRef<T>
): (node: T | null) => void {
return (node) => {
localRef.current = node;
if (typeof forwardedRef === "function") {
forwardedRef(node);
} else if (forwardedRef) {
forwardedRef.current = node;
}
};
}
function clamp(value: number, min: number, max: number): number {
return Math.min(max, Math.max(min, value));
}
@@ -0,0 +1,96 @@
export function downloadImage(src: string, name: string): void {
const link = document.createElement("a");
link.href = src;
link.download = name;
link.rel = "noopener";
document.body.append(link);
link.click();
link.remove();
}
export function resolveImageDownloadName(
name: string | undefined,
src: string | null,
alt: string | undefined
): string {
const semanticName =
resolveImageNameBase(name) ??
resolveImageNameBase(alt) ??
resolveImageNameBase(src) ??
"image";
const extension =
resolveImageNameExtension(name) ??
resolveImageNameExtension(src) ??
resolveDataImageExtension(src) ??
"png";
return `${semanticName}-${formatImageDownloadTimestamp(new Date())}-${createDownloadRandomSuffix()}.${extension}`;
}
function resolveImageNameBase(value: string | null | undefined): string | null {
const segment = imageNameSegment(value);
if (!segment) {
return null;
}
const base = segment.replace(/\.[A-Za-z0-9]{2,8}$/u, "");
const sanitized = stripControlCharacters(base)
.replace(/[\\/:*?"<>|#%&{}$!'@+`=]+/gu, "-")
.replace(/\s+/gu, "-")
.replace(/-+/gu, "-")
.replace(/^-|-$/gu, "")
.slice(0, 80);
return sanitized || null;
}
function stripControlCharacters(value: string): string {
return Array.from(value)
.filter((char) => char.charCodeAt(0) >= 32)
.join("");
}
function resolveImageNameExtension(
value: string | null | undefined
): string | null {
const segment = imageNameSegment(value);
const match = segment?.match(/\.([A-Za-z0-9]{2,8})$/u);
return match?.[1] ? normalizeImageExtension(match[1]) : null;
}
function imageNameSegment(value: string | null | undefined): string | null {
const trimmed = value?.trim();
if (!trimmed) {
return null;
}
const withoutQuery = decodeURIComponentSafe(
trimmed.split(/[?#]/, 1)[0] ?? ""
);
return withoutQuery.split(/[\\/]/).pop()?.trim() || null;
}
function resolveDataImageExtension(src: string | null): string | null {
const match = src?.match(/^data:image\/([A-Za-z0-9.+-]+)[;,]/u);
return match?.[1] ? normalizeImageExtension(match[1]) : null;
}
function normalizeImageExtension(extension: string): string {
const normalized = extension.toLowerCase();
if (normalized === "jpeg") return "jpg";
if (normalized === "svg+xml") return "svg";
return normalized.replace(/[^a-z0-9]/gu, "") || "png";
}
function formatImageDownloadTimestamp(date: Date): string {
const pad = (value: number): string => String(value).padStart(2, "0");
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}-${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`;
}
function createDownloadRandomSuffix(): string {
return Math.random().toString(36).slice(2, 6).padEnd(4, "0");
}
function decodeURIComponentSafe(value: string): string {
try {
return decodeURIComponent(value);
} catch {
return value;
}
}