1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
"use client";
import { cn } from "@repo/lib/utils";
import { Badge } from "@repo/ui/components/badge";
import { Button } from "@repo/ui/components/button";
import { GlassMenuEffect } from "@repo/ui/other/glass-effect";
import { Brain, Calendar, ExternalLink, FileText, Hash, X } from "lucide-react";
import { motion } from "motion/react";
import { memo } from "react";
import {
GoogleDocs,
GoogleDrive,
GoogleSheets,
GoogleSlides,
MicrosoftExcel,
MicrosoftOneNote,
MicrosoftPowerpoint,
MicrosoftWord,
NotionDoc,
OneDrive,
PDF,
} from "../assets/icons";
import { HeadingH3Bold } from "../text/heading/heading-h3-bold";
import type {
DocumentWithMemories,
MemoryEntry,
NodeDetailPanelProps,
} from "./types";
const formatDocumentType = (type: string) => {
// Special case for PDF
if (type.toLowerCase() === "pdf") return "PDF";
// Replace underscores with spaces and capitalize each word
return type
.split("_")
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
.join(" ");
};
const getDocumentIcon = (type: string) => {
const iconProps = { className: "w-5 h-5 text-slate-300" };
switch (type) {
case "google_doc":
return <GoogleDocs {...iconProps} />;
case "google_sheet":
return <GoogleSheets {...iconProps} />;
case "google_slide":
return <GoogleSlides {...iconProps} />;
case "google_drive":
return <GoogleDrive {...iconProps} />;
case "notion":
case "notion_doc":
return <NotionDoc {...iconProps} />;
case "word":
case "microsoft_word":
return <MicrosoftWord {...iconProps} />;
case "excel":
case "microsoft_excel":
return <MicrosoftExcel {...iconProps} />;
case "powerpoint":
case "microsoft_powerpoint":
return <MicrosoftPowerpoint {...iconProps} />;
case "onenote":
case "microsoft_onenote":
return <MicrosoftOneNote {...iconProps} />;
case "onedrive":
return <OneDrive {...iconProps} />;
case "pdf":
return <PDF {...iconProps} />;
default:
return <FileText {...iconProps} />;
}
};
export const NodeDetailPanel = memo<NodeDetailPanelProps>(
({ node, onClose, variant = "console" }) => {
// Use explicit classes that Tailwind can detect
const getPositioningClasses = () => {
// Both variants use the same positioning for nodeDetail
return "top-4 right-4";
};
if (!node) return null;
const isDocument = node.type === "document";
const data = node.data;
return (
<motion.div
animate={{ opacity: 1 }}
className={cn(
"absolute w-80 rounded-xl overflow-hidden z-20 max-h-[80vh]",
getPositioningClasses(),
)}
exit={{ opacity: 0 }}
initial={{ opacity: 0 }}
transition={{
duration: 0.2,
ease: "easeInOut",
}}
>
{/* Glass effect background */}
<GlassMenuEffect rounded="rounded-xl" />
<motion.div
animate={{ opacity: 1 }}
className="relative z-10 p-4 overflow-y-auto max-h-[80vh]"
initial={{ opacity: 0 }}
transition={{ delay: 0.05, duration: 0.15 }}
>
<div className="flex items-center justify-between mb-3">
<div className="flex items-center gap-2">
{isDocument ? (
getDocumentIcon((data as DocumentWithMemories).type)
) : (
<Brain className="w-5 h-5 text-blue-400" />
)}
<HeadingH3Bold className="text-slate-100">
{isDocument ? "Document" : "Memory"}
</HeadingH3Bold>
</div>
<motion.div whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }}>
<Button
className="h-8 w-8 p-0 text-slate-300 hover:text-slate-100"
onClick={onClose}
size="sm"
variant="ghost"
>
<X className="w-4 h-4" />
</Button>
</motion.div>
</div>
<div className="space-y-3">
{isDocument ? (
<>
<div>
<span className="text-xs text-slate-400 uppercase tracking-wide">
Title
</span>
<p className="text-sm text-slate-200 mt-1">
{(data as DocumentWithMemories).title ||
"Untitled Document"}
</p>
</div>
{(data as DocumentWithMemories).summary && (
<div>
<span className="text-xs text-slate-400 uppercase tracking-wide">
Summary
</span>
<p className="text-sm text-slate-300 mt-1 line-clamp-3">
{(data as DocumentWithMemories).summary}
</p>
</div>
)}
<div>
<span className="text-xs text-slate-400 uppercase tracking-wide">
Type
</span>
<p className="text-sm text-slate-200 mt-1">
{formatDocumentType((data as DocumentWithMemories).type)}
</p>
</div>
<div>
<span className="text-xs text-slate-400 uppercase tracking-wide">
Memory Count
</span>
<p className="text-sm text-slate-200 mt-1">
{(data as DocumentWithMemories).memoryEntries.length}{" "}
memories
</p>
</div>
{((data as DocumentWithMemories).url ||
(data as DocumentWithMemories).customId) && (
<div>
<span className="text-xs text-slate-400 uppercase tracking-wide">
URL
</span>
<a
className="text-sm text-indigo-400 hover:text-indigo-300 mt-1 flex items-center gap-1"
href={(() => {
const doc = data as DocumentWithMemories;
if (doc.type === "google_doc" && doc.customId) {
return `https://docs.google.com/document/d/${doc.customId}`;
}
if (doc.type === "google_sheet" && doc.customId) {
return `https://docs.google.com/spreadsheets/d/${doc.customId}`;
}
if (doc.type === "google_slide" && doc.customId) {
return `https://docs.google.com/presentation/d/${doc.customId}`;
}
return doc.url ?? undefined;
})()}
rel="noopener noreferrer"
target="_blank"
>
<ExternalLink className="w-3 h-3" />
View Document
</a>
</div>
)}
</>
) : (
<>
<div>
<span className="text-xs text-slate-400 uppercase tracking-wide">
Memory
</span>
<p className="text-sm text-slate-200 mt-1">
{(data as MemoryEntry).memory}
</p>
{(data as MemoryEntry).isForgotten && (
<Badge className="mt-2" variant="destructive">
Forgotten
</Badge>
)}
{(data as MemoryEntry).forgetAfter && (
<p className="text-xs text-slate-400 mt-1">
Expires:{" "}
{(data as MemoryEntry).forgetAfter
? new Date(
(data as MemoryEntry).forgetAfter!,
).toLocaleDateString()
: ""}{" "}
{"forgetReason" in data &&
data.forgetReason &&
`- ${data.forgetReason}`}
</p>
)}
</div>
<div>
<span className="text-xs text-slate-400 uppercase tracking-wide">
Space
</span>
<p className="text-sm text-slate-200 mt-1">
{(data as MemoryEntry).spaceId || "Default"}
</p>
</div>
</>
)}
<div className="pt-2 border-t border-slate-700/50">
<div className="flex items-center gap-4 text-xs text-slate-400">
<span className="flex items-center gap-1">
<Calendar className="w-3 h-3" />
{new Date(data.createdAt).toLocaleDateString()}
</span>
<span className="flex items-center gap-1">
<Hash className="w-3 h-3" />
{node.id}
</span>
</div>
</div>
</div>
</motion.div>
</motion.div>
);
},
);
NodeDetailPanel.displayName = "NodeDetailPanel";
|