5import { Footer } from "./Footer.tsx";
6
7export function ProjectsRoute() {
8 const projects = useProjects();
9
37}
38
39function ProjectCard({
40 user,
41 project,
75}
76
77function Privacy({ privacy }: { privacy: "public" | "unlisted" | "private" }) {
78 switch (privacy) {
79 case "public":
9}
10
11export function PreviewFrame(props: PreviewProps) {
12 const previewKey = useRef<string>("new-chat");
13 const [count, setCount] = useState<number>(0);
73const TSRE = /\/$/;
74
75function URLInput({ url, pathname, setPathname }) {
76 const prefix = url.replace(TSRE, "");
77 return (
90}
91
92function PreviewSelect({ index, setIndex, files }) {
93 return (
94 <div>
116}
117
118function usePreviewURL({ files }) {
119 const [index, setIndex] = useState<number>(0);
120 const htmlVals = files?.filter(file => file.links?.endpoint !== undefined);
21 * Parse pagination parameters from URL
22 */
23export function getPaginationParams(url: URL): { page: number; pageSize: number } {
24 const page = parseInt(url.searchParams.get("page") || "1", 10);
25 const pageSize = parseInt(url.searchParams.get("pageSize") || "50", 10);
35 * Calculate pagination metadata
36 */
37export function calculatePagination(params: PaginationParams): PaginationResult {
38 const totalPages = Math.ceil(params.totalItems / params.pageSize);
39
51 * Generate SQL LIMIT and OFFSET clauses for pagination
52 */
53export function getPaginationSQL(page: number, pageSize: number): string {
54 const offset = (page - 1) * pageSize;
55 return `LIMIT ${pageSize} OFFSET ${offset}`;
59 * Generate HTML for pagination controls
60 */
61export function renderPaginationControls(pagination: PaginationResult, baseUrl: string): string {
62 const url = new URL(baseUrl);
63
64 // Function to generate page URL
65 const getPageUrl = (page: number) => {
66 url.searchParams.set("page", page.toString());
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2
3export function NotFoundRoute () {
4 return (
5 <div className="container">Page not found</div>
4import { useCreateProject } from "../hooks/useCreateProject.tsx";
5
6export function NewProjectRoute () {
7 const [name, setName] = useState("");
8 const [privacy, setPrivacy] = useState("public");
65]
66
67function PrivacyRadios ({
68 value,
69 onChange,
23});
24
25export function Messages ({
26 messages,
27 messageEndTimes,
58}
59
60function Message ({
61 message,
62 messageEndTimes,
86}
87
88function AssistantMessage ({ message, messageEndTimes, running }: {
89 message: Message;
90 messageEndTimes: Record<string, number>;
107}
108
109function Part ({ part }) {
110 switch (part.type) {
111 case "text":
122}
123
124function TextPart ({ part }) {
125 return (
126 <ReactMarkdown>
130}
131
132function Details ({ open, onClick, children, summary }) {
133 return (
134 <details
148}
149
150function ToolPart ({ part }) {
151 const { openSummaries, setOpenSummaries } = useContext(MessageContext);
152 const {
275}
276
277function EditorToolPart ({ part }) {
278 const { openSummaries, setOpenSummaries } = useContext(MessageContext);
279 const {
342}
343
344function UserMessage ({ message }: {
345 message: Message;
346}) {
11
12// server-side route for /login page
13function LoginRoute() {
14 return (
15 <html lang="en-us">
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2
3export function Loading () {
4 return (
5 <div className="muted">
10}
11
12export function renderLayout(content: string, options: LayoutOptions): string {
13 const { title, activeTab = "dashboard", scripts = [], styles = [] } = options;
14
149 // Default scripts
150 const defaultScripts = `
151 document.addEventListener('DOMContentLoaded', function() {
152 // Tab navigation
153 document.querySelectorAll('.tab').forEach(tab => {
154 tab.addEventListener('click', function(e) {
155 if (this.getAttribute('href') === '#') {
156 e.preventDefault();
3import { Header } from "./Header.tsx";
4
5export function LayoutRoute() {
6 return (
7 <>