Moved @tensamin/ui out of monorepo
This commit is contained in:
parent
60635d07c2
commit
39aa70a9a6
62 changed files with 309 additions and 3320 deletions
|
|
@ -24,7 +24,7 @@
|
|||
"@tensamin/user": "workspace:*",
|
||||
"@tensamin/markdown": "workspace:*",
|
||||
"@tensamin/shared": "workspace:*",
|
||||
"@tensamin/ui": "workspace:*",
|
||||
"@tensamin/ui": "*",
|
||||
"lucide-react": "^0.564.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import Input from "@tensamin/markdown/input";
|
||||
import { Card, CardHeader } from "@tensamin/ui/cmp/card";
|
||||
import { Card, CardHeader } from "@tensamin/ui";
|
||||
import { useStorage } from "@tensamin/storage/context";
|
||||
import * as React from "react";
|
||||
import { Button } from "@tensamin/ui/cmp/button";
|
||||
import { Button } from "@tensamin/ui";
|
||||
|
||||
import { Plus, Laugh, Clapperboard } from "lucide-react";
|
||||
import { useChat } from "../context";
|
||||
|
|
@ -10,7 +10,7 @@ import { useTTP } from "@tensamin/ttp/context";
|
|||
import { useCrypto } from "@tensamin/crypto/context";
|
||||
import { log, toast } from "@tensamin/shared/log";
|
||||
import Message from "./message";
|
||||
import { cn, useIsMobile } from "@tensamin/ui/utils";
|
||||
import { cn, useIsMobile } from "@tensamin/ui";
|
||||
|
||||
export default function InputComponent({
|
||||
value,
|
||||
|
|
|
|||
|
|
@ -10,19 +10,27 @@ import {
|
|||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@tensamin/ui/cmp/tooltip";
|
||||
import { useIsMobile } from "@tensamin/ui/utils";
|
||||
} from "@tensamin/ui";
|
||||
import { useIsMobile } from "@tensamin/ui";
|
||||
import {
|
||||
ContextMenu,
|
||||
ContextMenuContent,
|
||||
ContextMenuItem,
|
||||
ContextMenuTrigger,
|
||||
} from "@tensamin/ui/cmp/context-menu";
|
||||
} from "@tensamin/ui";
|
||||
|
||||
function generateFixedLoadingSize(size: number, height: number) {
|
||||
return size * 3 - (height / 20) * 11;
|
||||
}
|
||||
|
||||
function getSafeMessageHeight(height: number | undefined) {
|
||||
if (typeof height === "number" && Number.isFinite(height) && height > 0) {
|
||||
return Math.ceil(height);
|
||||
}
|
||||
|
||||
return 40;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes Message.
|
||||
* @param props Parameter props.
|
||||
|
|
@ -42,6 +50,7 @@ function MessageComponent(props: {
|
|||
|
||||
const [decodedContent, setDecodedContent] = React.useState("");
|
||||
const [isReady, setIsReady] = React.useState(false);
|
||||
const safeMessageHeight = getSafeMessageHeight(props.message.height);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (props.notEncrypted) {
|
||||
|
|
@ -121,13 +130,13 @@ function MessageComponent(props: {
|
|||
<Text value={decodedContent} />
|
||||
) : (
|
||||
<div
|
||||
className="h-8"
|
||||
className="block rounded-sm"
|
||||
style={{
|
||||
width: generateFixedLoadingSize(
|
||||
props.message.content.length,
|
||||
props.message.height,
|
||||
safeMessageHeight,
|
||||
),
|
||||
height: props.message.height,
|
||||
minHeight: safeMessageHeight,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,23 @@ import Message from "./components/message";
|
|||
|
||||
import { PAGE_SIZE } from "./values";
|
||||
import { useLayoutEffect } from "react";
|
||||
import { useIsMobile } from "@tensamin/ui/utils";
|
||||
import { useIsMobile } from "@tensamin/ui";
|
||||
|
||||
function getDistanceFromBottom(element: HTMLDivElement) {
|
||||
return element.scrollHeight - (element.scrollTop + element.clientHeight);
|
||||
}
|
||||
|
||||
const FALLBACK_MESSAGE_HEIGHT = 40;
|
||||
const ROW_VERTICAL_PADDING = 8;
|
||||
|
||||
function getSafeMessageHeight(height: number | undefined) {
|
||||
if (typeof height === "number" && Number.isFinite(height) && height > 0) {
|
||||
return Math.ceil(height);
|
||||
}
|
||||
|
||||
return FALLBACK_MESSAGE_HEIGHT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the chat screen with virtualized history and live message updates.
|
||||
* @returns Chat screen JSX.
|
||||
|
|
@ -93,7 +104,10 @@ export default function Screen() {
|
|||
count: messages.length,
|
||||
getScrollElement: () => scrollRef.current,
|
||||
getItemKey,
|
||||
estimateSize: (index) => messages[index].height,
|
||||
estimateSize: (index) => {
|
||||
const message = messages[index];
|
||||
return getSafeMessageHeight(message?.height) + ROW_VERTICAL_PADDING;
|
||||
},
|
||||
overscan: isMobile ? 10 : 6,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue