goji-search 1.1.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/goji-search/assets/avatar1.jpeg +0 -0
- package/dist/goji-search/assets/avatar2.jpeg +0 -0
- package/dist/goji-search/assets/avatar3.jpeg +0 -0
- package/dist/goji-search/assets/chat-logo.png +0 -0
- package/dist/goji-search/components/elements/closing-card.d.ts +20 -0
- package/dist/goji-search/components/elements/inspiration-menu.d.ts +3 -1
- package/dist/goji-search/components/elements/language-selector.d.ts +10 -0
- package/dist/goji-search/components/elements/message-list.d.ts +3 -1
- package/dist/goji-search/components/elements/search-input.d.ts +3 -1
- package/dist/goji-search/components/goji-search-component.d.ts +21 -2
- package/dist/goji-search/hooks/useCompanyTheme.d.ts +21 -0
- package/dist/goji-search/lib/goji-client.d.ts +24 -4
- package/dist/index.js +11767 -4
- package/package.json +20 -17
- package/dist/goji-search/components/elements/action-buttons.js +0 -164
- package/dist/goji-search/components/elements/auto-expanding-textarea.js +0 -46
- package/dist/goji-search/components/elements/calendar-integration.js +0 -49
- package/dist/goji-search/components/elements/inspiration-menu.js +0 -87
- package/dist/goji-search/components/elements/message-list.js +0 -301
- package/dist/goji-search/components/elements/search-input.js +0 -136
- package/dist/goji-search/components/elements/suggested-questions.js +0 -57
- package/dist/goji-search/components/goji-search-component.js +0 -679
- package/dist/goji-search/components/goji-search.css +0 -1
- package/dist/goji-search/config/company.js +0 -100
- package/dist/goji-search/lib/calendar-config.js +0 -10
- package/dist/goji-search/lib/goji-client.js +0 -229
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useEffect, useState } from "react";
|
|
3
|
-
import ReactMarkdown from "react-markdown";
|
|
4
|
-
import remarkGfm from "remark-gfm";
|
|
5
|
-
import { ExternalLink } from "lucide-react";
|
|
6
|
-
export function MessageList({ messages, isStreaming, aiAvatarSrc = '', size = 'l', }) {
|
|
7
|
-
const messagesEndRef = useRef(null);
|
|
8
|
-
const [expandedSourcesByMessageIndex, setExpandedSourcesByMessageIndex] = useState({});
|
|
9
|
-
const toggleSources = (messageIndex) => {
|
|
10
|
-
setExpandedSourcesByMessageIndex((prev) => ({
|
|
11
|
-
...prev,
|
|
12
|
-
[messageIndex]: !prev[messageIndex],
|
|
13
|
-
}));
|
|
14
|
-
};
|
|
15
|
-
const convertCitationLinksToUrls = (markdown, sources) => {
|
|
16
|
-
if (!markdown || !sources || sources.length === 0)
|
|
17
|
-
return markdown;
|
|
18
|
-
// Replace [text](N) where N is a positive integer referencing sources[N-1]
|
|
19
|
-
return markdown.replace(/\[([^\]]+)\]\((\d+)\)/g, (match, text, numStr) => {
|
|
20
|
-
const num = parseInt(numStr, 10);
|
|
21
|
-
if (Number.isNaN(num) || num < 1 || num > sources.length)
|
|
22
|
-
return match;
|
|
23
|
-
const url = sources[num - 1]?.url;
|
|
24
|
-
if (!url)
|
|
25
|
-
return match;
|
|
26
|
-
return `[${text}](${url})`;
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
31
|
-
}, [messages]);
|
|
32
|
-
const lastMessage = messages[messages.length - 1];
|
|
33
|
-
const showThinkingDots = isStreaming && (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.content);
|
|
34
|
-
return (_jsxs("div", { style: {
|
|
35
|
-
position: 'relative',
|
|
36
|
-
flex: 1,
|
|
37
|
-
overflowY: "auto",
|
|
38
|
-
marginTop: "1.3rem",
|
|
39
|
-
display: "flex",
|
|
40
|
-
flexDirection: "column",
|
|
41
|
-
gap: "0.5rem",
|
|
42
|
-
padding: "0.5rem",
|
|
43
|
-
borderRadius: "0.75rem",
|
|
44
|
-
backgroundColor: "rgba(255, 255, 255, 0.08)",
|
|
45
|
-
border: "1px solid rgba(255, 255, 255, 0.15)",
|
|
46
|
-
}, className: "custom-scrollbar", children: [messages.map((message, index) => {
|
|
47
|
-
// Skip rendering empty assistant messages during streaming (thinking dots will show instead)
|
|
48
|
-
const isEmptyAssistantWhileStreaming = message.role === "assistant" && !message.content && isStreaming;
|
|
49
|
-
if (isEmptyAssistantWhileStreaming)
|
|
50
|
-
return null;
|
|
51
|
-
return (_jsxs("div", { style: {
|
|
52
|
-
display: "flex",
|
|
53
|
-
justifyContent: message.role === "user" ? "flex-end" : "flex-start",
|
|
54
|
-
animation: "fadeIn 0.3s ease-in",
|
|
55
|
-
gap: "0.4rem",
|
|
56
|
-
}, children: [_jsx("div", { style: {
|
|
57
|
-
display: "flex",
|
|
58
|
-
gap: "0.4rem",
|
|
59
|
-
alignItems: message.role === "user" ? "flex-end" : "flex-start"
|
|
60
|
-
}, children: _jsx("div", { style: {
|
|
61
|
-
width: message.role === "user" ? "0" : "1.4rem",
|
|
62
|
-
height: message.role === "user" ? "0" : "auto",
|
|
63
|
-
borderRadius: "none",
|
|
64
|
-
backgroundColor: "transparent",
|
|
65
|
-
display: "flex",
|
|
66
|
-
alignItems: "center",
|
|
67
|
-
justifyContent: "center",
|
|
68
|
-
fontSize: "0.75rem",
|
|
69
|
-
border: "none",
|
|
70
|
-
boxShadow: "none",
|
|
71
|
-
}, children: message.role === "user" ? (
|
|
72
|
-
// <User size={16} color="rgba(0, 0, 0, 1)" />
|
|
73
|
-
_jsx("div", {})) : (aiAvatarSrc ? (_jsx("img", { src: aiAvatarSrc, alt: "AI Avatar", style: {
|
|
74
|
-
width: "100%",
|
|
75
|
-
height: "100%",
|
|
76
|
-
objectFit: "cover"
|
|
77
|
-
} })) : (_jsx("div", { style: {
|
|
78
|
-
width: "100%",
|
|
79
|
-
height: "100%",
|
|
80
|
-
display: "flex",
|
|
81
|
-
alignItems: "center",
|
|
82
|
-
justifyContent: "center",
|
|
83
|
-
fontSize: "0.75rem",
|
|
84
|
-
color: "rgba(217, 219, 234, 1)"
|
|
85
|
-
}, children: "AI" }))) }) }), _jsxs("div", { style: {
|
|
86
|
-
maxWidth: "85%",
|
|
87
|
-
padding: message.role === "user" ? "0.5rem 0.75rem" : "0.5rem 0",
|
|
88
|
-
borderRadius: message.role === "user" ? "1.2rem" : "0",
|
|
89
|
-
fontSize: "0.875rem",
|
|
90
|
-
marginLeft: message.role === "user" ? "0" : "1rem",
|
|
91
|
-
marginRight: message.role === "user" ? "1rem" : "0",
|
|
92
|
-
lineHeight: "1.4",
|
|
93
|
-
backgroundColor: message.role === "user" ? "rgb(114, 126, 237)" : "transparent",
|
|
94
|
-
color: message.role === "user" ? "white" : "rgba(0, 0, 0, 0.85)",
|
|
95
|
-
border: message.role === "user" ? "1px solid rgba(255, 255, 255, 0.35)" : "none",
|
|
96
|
-
boxShadow: message.role === "user" ? "0 2px 8px rgba(114, 126, 237, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25)" : "none",
|
|
97
|
-
}, children: [message.role === "user" ? (_jsx("p", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: message.content })) : (_jsx("div", { className: "markdown-content", style: {
|
|
98
|
-
fontSize: "0.875rem",
|
|
99
|
-
lineHeight: "1.4",
|
|
100
|
-
color: "rgba(0, 0, 0, 0.85)",
|
|
101
|
-
}, children: _jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: {
|
|
102
|
-
a: ({ href, children, ...props }) => {
|
|
103
|
-
const hasSources = Array.isArray(message.sources) && message.sources.length > 0;
|
|
104
|
-
if (!hasSources) {
|
|
105
|
-
const anyProps = props;
|
|
106
|
-
return (_jsx("span", { className: anyProps?.className, style: anyProps?.style, children: children }));
|
|
107
|
-
}
|
|
108
|
-
return (_jsx("a", { href: href || '', target: "_blank", rel: "noopener noreferrer", ...props, children: children }));
|
|
109
|
-
},
|
|
110
|
-
}, children: convertCitationLinksToUrls(message.content, message.sources) }) })), message.role === "assistant" && message.sources && message.sources.length > 0 && (_jsxs("div", { style: {
|
|
111
|
-
marginTop: "0.25rem",
|
|
112
|
-
paddingTop: "0.25rem",
|
|
113
|
-
borderTop: "1px solid rgba(0, 0, 0, 0.1)",
|
|
114
|
-
}, children: [_jsx("div", { style: {
|
|
115
|
-
display: "flex",
|
|
116
|
-
alignItems: "center",
|
|
117
|
-
justifyContent: "flex-end",
|
|
118
|
-
gap: "0.5rem",
|
|
119
|
-
marginBottom: "0.25rem",
|
|
120
|
-
}, children: _jsx("button", { type: "button", onClick: () => toggleSources(index), style: {
|
|
121
|
-
borderRadius: "0.5rem",
|
|
122
|
-
border: "1px solid rgba(255, 255, 255, 0.3)",
|
|
123
|
-
backgroundColor: "rgba(255, 255, 255, 0.2)",
|
|
124
|
-
padding: "0.2rem 0.4rem",
|
|
125
|
-
fontSize: "0.65rem",
|
|
126
|
-
color: "rgba(0, 0, 0, 0.75)",
|
|
127
|
-
cursor: "pointer",
|
|
128
|
-
outline: "none",
|
|
129
|
-
textTransform: "none",
|
|
130
|
-
}, children: expandedSourcesByMessageIndex[index] ? "Hide sources" : "Show sources" }) }), expandedSourcesByMessageIndex[index] && (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: message.sources.map((source) => (_jsxs("a", { href: source.url, target: "_blank", rel: "noopener noreferrer", style: {
|
|
131
|
-
display: "flex",
|
|
132
|
-
alignItems: "center",
|
|
133
|
-
gap: "0.5rem",
|
|
134
|
-
fontSize: "0.75rem",
|
|
135
|
-
color: "rgba(0, 0, 0, 0.7)",
|
|
136
|
-
textDecoration: "none",
|
|
137
|
-
transition: "color 0.2s",
|
|
138
|
-
}, onMouseEnter: (e) => {
|
|
139
|
-
e.currentTarget.style.color = "rgba(0, 0, 0, 0.9)";
|
|
140
|
-
}, onMouseLeave: (e) => {
|
|
141
|
-
e.currentTarget.style.color = "rgba(0, 0, 0, 0.7)";
|
|
142
|
-
}, children: [_jsxs("span", { style: {
|
|
143
|
-
backgroundColor: "rgba(0, 0, 0, 0.1)",
|
|
144
|
-
padding: "0.125rem 0.375rem",
|
|
145
|
-
borderRadius: "0.375rem",
|
|
146
|
-
fontSize: "0.65rem",
|
|
147
|
-
fontWeight: 600,
|
|
148
|
-
}, children: ["#", source.index] }), _jsx("span", { style: { flex: 1, wordBreak: "break-all" }, children: source.url }), _jsx(ExternalLink, { style: { width: "0.875rem", height: "0.875rem", opacity: 0.6 } })] }, source.index))) }))] }))] })] }, index));
|
|
149
|
-
}), showThinkingDots && (_jsxs("div", { style: { display: "flex", justifyContent: "flex-start", gap: "0.4rem", alignItems: "flex-start" }, children: [_jsx("div", { style: {
|
|
150
|
-
display: "flex",
|
|
151
|
-
gap: "0.4rem",
|
|
152
|
-
alignItems: "flex-start"
|
|
153
|
-
}, children: _jsx("div", { style: {
|
|
154
|
-
width: "1.4rem",
|
|
155
|
-
height: "auto",
|
|
156
|
-
borderRadius: "none",
|
|
157
|
-
backgroundColor: "transparent",
|
|
158
|
-
display: "flex",
|
|
159
|
-
alignItems: "center",
|
|
160
|
-
justifyContent: "center",
|
|
161
|
-
fontSize: "0.75rem",
|
|
162
|
-
border: "none",
|
|
163
|
-
boxShadow: "none",
|
|
164
|
-
}, children: aiAvatarSrc ? (_jsx("img", { src: aiAvatarSrc, alt: "AI Avatar", style: {
|
|
165
|
-
width: "100%",
|
|
166
|
-
height: "100%",
|
|
167
|
-
objectFit: "cover"
|
|
168
|
-
} })) : (_jsx("div", { style: {
|
|
169
|
-
width: "100%",
|
|
170
|
-
height: "100%",
|
|
171
|
-
display: "flex",
|
|
172
|
-
alignItems: "center",
|
|
173
|
-
justifyContent: "center",
|
|
174
|
-
fontSize: "0.75rem",
|
|
175
|
-
color: "rgba(217, 219, 234, 1)"
|
|
176
|
-
}, children: "AI" })) }) }), _jsxs("div", { style: {
|
|
177
|
-
marginLeft: "1rem",
|
|
178
|
-
padding: "0.25rem 0.5rem",
|
|
179
|
-
borderRadius: "1rem",
|
|
180
|
-
display: "flex",
|
|
181
|
-
gap: "0.25rem",
|
|
182
|
-
alignItems: "center",
|
|
183
|
-
}, children: [_jsx("span", { style: {
|
|
184
|
-
width: "0.35rem",
|
|
185
|
-
height: "0.35rem",
|
|
186
|
-
borderRadius: "50%",
|
|
187
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
188
|
-
animation: "pulse 1.4s ease-in-out infinite",
|
|
189
|
-
} }), _jsx("span", { style: {
|
|
190
|
-
width: "0.35rem",
|
|
191
|
-
height: "0.35rem",
|
|
192
|
-
borderRadius: "50%",
|
|
193
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
194
|
-
animation: "pulse 1.4s ease-in-out 0.2s infinite",
|
|
195
|
-
} }), _jsx("span", { style: {
|
|
196
|
-
width: "0.35rem",
|
|
197
|
-
height: "0.35rem",
|
|
198
|
-
borderRadius: "50%",
|
|
199
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
200
|
-
animation: "pulse 1.4s ease-in-out 0.4s infinite",
|
|
201
|
-
} })] })] })), _jsx("div", { ref: messagesEndRef }), _jsx("style", { children: `
|
|
202
|
-
.markdown-content p {
|
|
203
|
-
margin: 0 0 0.75rem 0;
|
|
204
|
-
}
|
|
205
|
-
.markdown-content p:last-child {
|
|
206
|
-
margin-bottom: 0;
|
|
207
|
-
}
|
|
208
|
-
.markdown-content h1,
|
|
209
|
-
.markdown-content h2,
|
|
210
|
-
.markdown-content h3,
|
|
211
|
-
.markdown-content h4 {
|
|
212
|
-
margin: 1rem 0 0.5rem 0;
|
|
213
|
-
font-weight: 600;
|
|
214
|
-
color: rgba(0, 0, 0, 0.9);
|
|
215
|
-
}
|
|
216
|
-
.markdown-content h1 {
|
|
217
|
-
font-size: 1.25rem;
|
|
218
|
-
}
|
|
219
|
-
.markdown-content h2 {
|
|
220
|
-
font-size: 1.125rem;
|
|
221
|
-
}
|
|
222
|
-
.markdown-content h3 {
|
|
223
|
-
font-size: 1rem;
|
|
224
|
-
}
|
|
225
|
-
.markdown-content ul,
|
|
226
|
-
.markdown-content ol {
|
|
227
|
-
margin: 0.5rem 0;
|
|
228
|
-
padding-left: 1.5rem;
|
|
229
|
-
}
|
|
230
|
-
.markdown-content li {
|
|
231
|
-
margin: 0.25rem 0;
|
|
232
|
-
}
|
|
233
|
-
.markdown-content code {
|
|
234
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
235
|
-
padding: 0.125rem 0.375rem;
|
|
236
|
-
border-radius: 0.25rem;
|
|
237
|
-
font-size: 0.8125rem;
|
|
238
|
-
font-family: ui-monospace, monospace;
|
|
239
|
-
}
|
|
240
|
-
.markdown-content pre {
|
|
241
|
-
background-color: rgba(0, 0, 0, 0.08);
|
|
242
|
-
padding: 0.75rem;
|
|
243
|
-
border-radius: 0.5rem;
|
|
244
|
-
overflow-x: auto;
|
|
245
|
-
margin: 0.75rem 0;
|
|
246
|
-
}
|
|
247
|
-
.markdown-content pre code {
|
|
248
|
-
background-color: transparent;
|
|
249
|
-
padding: 0;
|
|
250
|
-
}
|
|
251
|
-
.markdown-content a {
|
|
252
|
-
color: rgb(114, 126, 237);
|
|
253
|
-
text-decoration: underline;
|
|
254
|
-
}
|
|
255
|
-
.markdown-content a:hover {
|
|
256
|
-
color: rgb(94, 106, 217);
|
|
257
|
-
}
|
|
258
|
-
.markdown-content blockquote {
|
|
259
|
-
border-left: 3px solid rgba(0, 0, 0, 0.2);
|
|
260
|
-
padding-left: 1rem;
|
|
261
|
-
margin: 0.75rem 0;
|
|
262
|
-
color: rgba(0, 0, 0, 0.7);
|
|
263
|
-
}
|
|
264
|
-
.markdown-content strong {
|
|
265
|
-
font-weight: 600;
|
|
266
|
-
color: rgba(0, 0, 0, 0.9);
|
|
267
|
-
}
|
|
268
|
-
.markdown-content table {
|
|
269
|
-
border-collapse: collapse;
|
|
270
|
-
width: 100%;
|
|
271
|
-
margin: 0.75rem 0;
|
|
272
|
-
}
|
|
273
|
-
.markdown-content th,
|
|
274
|
-
.markdown-content td {
|
|
275
|
-
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
276
|
-
padding: 0.5rem;
|
|
277
|
-
text-align: left;
|
|
278
|
-
}
|
|
279
|
-
.markdown-content th {
|
|
280
|
-
background-color: rgba(0, 0, 0, 0.05);
|
|
281
|
-
font-weight: 600;
|
|
282
|
-
}
|
|
283
|
-
.custom-scrollbar {
|
|
284
|
-
scrollbar-width: thin;
|
|
285
|
-
scrollbar-color: rgba(0, 0, 0, 0.5) rgba(255, 255, 255, 0.08);
|
|
286
|
-
}
|
|
287
|
-
.custom-scrollbar::-webkit-scrollbar {
|
|
288
|
-
width: 0.5rem;
|
|
289
|
-
}
|
|
290
|
-
.custom-scrollbar::-webkit-scrollbar-track {
|
|
291
|
-
background: rgba(255, 255, 255, 0.08);
|
|
292
|
-
}
|
|
293
|
-
.custom-scrollbar::-webkit-scrollbar-thumb {
|
|
294
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
295
|
-
border-radius: 0.25rem;
|
|
296
|
-
}
|
|
297
|
-
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
298
|
-
background-color: rgba(0, 0, 0, 0.7);
|
|
299
|
-
}
|
|
300
|
-
` })] }));
|
|
301
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Sparkles } from "lucide-react";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { InspirationMenu } from "./inspiration-menu";
|
|
5
|
-
import AutoExpandingTextarea from "./auto-expanding-textarea"; // make sure path matches
|
|
6
|
-
export function SearchInput({ value, onChange, onFocus, onBlur, placeholder, size, setSize, inputRef, inspirationQuestions, onInspirationClick, sparkleRef, suggestedLabel = "Suggested", }) {
|
|
7
|
-
const [showInspirationMenu, setShowInspirationMenu] = useState(false);
|
|
8
|
-
const [isSparkleHovered, setIsSparkleHovered] = useState(false);
|
|
9
|
-
const [typewriterText, setTypewriterText] = useState("");
|
|
10
|
-
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
|
|
11
|
-
const [isTyping, setIsTyping] = useState(true);
|
|
12
|
-
const [charIndex, setCharIndex] = useState(0);
|
|
13
|
-
const [isSingleLine, setIsSingleLine] = useState(true);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (inputRef.current) {
|
|
16
|
-
const textarea = inputRef.current;
|
|
17
|
-
const lineHeight = 24; // match your `line-height` in CSS (1.5rem ≈ 24px)
|
|
18
|
-
setIsSingleLine(textarea.scrollHeight <= lineHeight * 1.5);
|
|
19
|
-
}
|
|
20
|
-
}, [value]);
|
|
21
|
-
// Typewriter animation for placeholder
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (size !== "s" || value || inspirationQuestions.length === 0)
|
|
24
|
-
return;
|
|
25
|
-
const currentQuestion = inspirationQuestions[currentQuestionIndex];
|
|
26
|
-
const typingSpeed = 40;
|
|
27
|
-
const deletingSpeed = 20;
|
|
28
|
-
const pauseAfterTyping = 2000;
|
|
29
|
-
const pauseAfterDeleting = 500;
|
|
30
|
-
const timer = setTimeout(() => {
|
|
31
|
-
if (isTyping) {
|
|
32
|
-
if (charIndex < currentQuestion.length) {
|
|
33
|
-
setTypewriterText(currentQuestion.slice(0, charIndex + 1));
|
|
34
|
-
setCharIndex(charIndex + 1);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
setTimeout(() => setIsTyping(false), pauseAfterTyping);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
if (charIndex > 0) {
|
|
42
|
-
setTypewriterText(currentQuestion.slice(0, charIndex - 1));
|
|
43
|
-
setCharIndex(charIndex - 1);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
setTimeout(() => {
|
|
47
|
-
setCurrentQuestionIndex((currentQuestionIndex + 1) % inspirationQuestions.length);
|
|
48
|
-
setIsTyping(true);
|
|
49
|
-
}, pauseAfterDeleting);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}, isTyping ? typingSpeed : deletingSpeed);
|
|
53
|
-
return () => clearTimeout(timer);
|
|
54
|
-
}, [size, value, inspirationQuestions, currentQuestionIndex, isTyping, charIndex]);
|
|
55
|
-
const handleSparkleClick = () => {
|
|
56
|
-
setShowInspirationMenu(!showInspirationMenu);
|
|
57
|
-
};
|
|
58
|
-
const handleQuestionClick = (question) => {
|
|
59
|
-
if (size !== "l" && size !== "xl") {
|
|
60
|
-
setSize("l");
|
|
61
|
-
}
|
|
62
|
-
onInspirationClick(question);
|
|
63
|
-
setShowInspirationMenu(false);
|
|
64
|
-
};
|
|
65
|
-
const displayPlaceholder = size === "s" && !value ? typewriterText : placeholder;
|
|
66
|
-
return (_jsxs("div", { style: { position: "relative", zIndex: 1 }, children: [size !== "s" && (_jsxs("div", { ref: sparkleRef, onClick: handleSparkleClick, onMouseEnter: () => {
|
|
67
|
-
setIsSparkleHovered(true);
|
|
68
|
-
setShowInspirationMenu(true);
|
|
69
|
-
}, onMouseLeave: () => {
|
|
70
|
-
setIsSparkleHovered(false);
|
|
71
|
-
// Don't immediately close, wait for user to move to menu
|
|
72
|
-
setTimeout(() => {
|
|
73
|
-
if (!document.querySelector('[data-inspiration-menu]:hover')) {
|
|
74
|
-
setShowInspirationMenu(false);
|
|
75
|
-
}
|
|
76
|
-
}, 150);
|
|
77
|
-
}, style: {
|
|
78
|
-
position: "absolute",
|
|
79
|
-
left: "0.75rem",
|
|
80
|
-
top: "0.42rem",
|
|
81
|
-
cursor: "pointer",
|
|
82
|
-
// Keep the trigger above the input; menu has an even higher z-index
|
|
83
|
-
zIndex: 2,
|
|
84
|
-
}, children: [_jsx(Sparkles, { className: "sparkle-icon-animated", style: {
|
|
85
|
-
width: "1rem",
|
|
86
|
-
height: "1rem",
|
|
87
|
-
color: "rgba(0, 0, 0, 0.6)",
|
|
88
|
-
transition: "all 0.3s ease",
|
|
89
|
-
} }), showInspirationMenu && (_jsx(InspirationMenu, { questions: inspirationQuestions, onQuestionClick: handleQuestionClick, onClose: () => setShowInspirationMenu(false), suggestedLabel: suggestedLabel }))] })), _jsx(AutoExpandingTextarea, { ref: inputRef, value: value, onChange: onChange, onFocus: onFocus, onMouseEnter: () => {
|
|
90
|
-
if (size === "m") {
|
|
91
|
-
setShowInspirationMenu(true);
|
|
92
|
-
}
|
|
93
|
-
}, onBlur: onBlur, placeholder: displayPlaceholder, className: `sparkle-input ${isSparkleHovered ? "sparkle-hover" : ""}`, style: {
|
|
94
|
-
padding: size === "s" ? "0 0.75rem" : "0 0.75rem 0 2rem",
|
|
95
|
-
outline: "none",
|
|
96
|
-
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
97
|
-
borderRadius: isSingleLine ? "9999px" : "15px",
|
|
98
|
-
} }), _jsx("style", { children: `
|
|
99
|
-
.sparkle-input {
|
|
100
|
-
width: 100%;
|
|
101
|
-
border: 1px solid rgba(255, 255, 255, 0.25);
|
|
102
|
-
background-color: transparent;
|
|
103
|
-
border-radius: 9999px; /* full rounded */
|
|
104
|
-
font-size: 0.85rem; /* ~14px */
|
|
105
|
-
color: rgba(0, 0, 0, 0.85);
|
|
106
|
-
backdrop-filter: blur(20px) saturate(180%);
|
|
107
|
-
-webkit-backdrop-filter: blur(20px) saturate(180%);
|
|
108
|
-
resize: none;
|
|
109
|
-
outline: none;
|
|
110
|
-
overflow: hidden; /* hide scrollbar toggles */
|
|
111
|
-
line-height: 1.5rem;
|
|
112
|
-
min-height: 1.5rem;
|
|
113
|
-
max-height: 160px;
|
|
114
|
-
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.sparkle-input::placeholder {
|
|
118
|
-
color: rgba(0, 0, 0, 0.75);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.sparkle-icon-animated {
|
|
122
|
-
animation: sparkleGlow 2s ease-in-out infinite;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@keyframes sparkleGlow {
|
|
126
|
-
0%, 100% {
|
|
127
|
-
opacity: 0.6;
|
|
128
|
-
transform: scale(1);
|
|
129
|
-
}
|
|
130
|
-
50% {
|
|
131
|
-
opacity: 1;
|
|
132
|
-
transform: scale(1.1);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
` })] }));
|
|
136
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
export function SuggestedQuestions({ questions, onQuestionClick }) {
|
|
3
|
-
return (_jsxs("div", { style: {
|
|
4
|
-
display: "flex",
|
|
5
|
-
flexDirection: "column",
|
|
6
|
-
gap: "0.5rem",
|
|
7
|
-
padding: "0 0.625rem",
|
|
8
|
-
borderRadius: "0.75rem",
|
|
9
|
-
backgroundColor: "rgba(255, 255, 255, 0.08)",
|
|
10
|
-
border: "1px solid rgba(255, 255, 255, 0.15)",
|
|
11
|
-
animation: "slideUp 0.3s ease-out",
|
|
12
|
-
}, children: [_jsx("div", { style: {
|
|
13
|
-
fontSize: "0.6875rem",
|
|
14
|
-
fontWeight: 600,
|
|
15
|
-
color: "rgba(0, 0, 0, 0.5)",
|
|
16
|
-
marginBottom: "0.125rem",
|
|
17
|
-
letterSpacing: "0.05em",
|
|
18
|
-
textTransform: "capitalize",
|
|
19
|
-
}, children: "suggested" }), _jsx("div", { style: {
|
|
20
|
-
display: "flex",
|
|
21
|
-
flexWrap: "wrap",
|
|
22
|
-
gap: "0.375rem",
|
|
23
|
-
}, children: questions.map((question, index) => {
|
|
24
|
-
const truncatedQuestion = question.length > 80 ? question.slice(0, 80) + '...' : question;
|
|
25
|
-
return (_jsx("button", { type: "button", onClick: () => onQuestionClick(question), title: question.length > 80 ? question : undefined, style: {
|
|
26
|
-
padding: "0.5rem 0.75rem",
|
|
27
|
-
borderRadius: "1.3rem",
|
|
28
|
-
border: "1px solid rgba(255, 255, 255, 0.25)",
|
|
29
|
-
backgroundColor: "rgba(255, 255, 255, 0.2)",
|
|
30
|
-
color: "rgba(0, 0, 0, 0.75)",
|
|
31
|
-
fontSize: "0.75rem",
|
|
32
|
-
textAlign: "left",
|
|
33
|
-
cursor: "pointer",
|
|
34
|
-
transition: "all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
35
|
-
backdropFilter: "blur(20px) saturate(180%)",
|
|
36
|
-
WebkitBackdropFilter: "blur(20px) saturate(180%)",
|
|
37
|
-
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.3)",
|
|
38
|
-
outline: "none",
|
|
39
|
-
lineHeight: "1.3",
|
|
40
|
-
}, onMouseEnter: (e) => {
|
|
41
|
-
e.currentTarget.style.backgroundColor = "rgba(140, 110, 230, 0.15)";
|
|
42
|
-
e.currentTarget.style.borderColor = "rgba(140, 110, 230, 0.3)";
|
|
43
|
-
e.currentTarget.style.transform = "translateY(-1px)";
|
|
44
|
-
e.currentTarget.style.boxShadow =
|
|
45
|
-
"0 3px 8px rgba(140, 110, 230, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4)";
|
|
46
|
-
}, onMouseLeave: (e) => {
|
|
47
|
-
e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.2)";
|
|
48
|
-
e.currentTarget.style.borderColor = "rgba(255, 255, 255, 0.25)";
|
|
49
|
-
e.currentTarget.style.transform = "translateY(0)";
|
|
50
|
-
e.currentTarget.style.boxShadow = "0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.3)";
|
|
51
|
-
}, onFocus: (e) => {
|
|
52
|
-
e.currentTarget.style.boxShadow = "0 0 0 2px rgba(140, 110, 230, 0.3)";
|
|
53
|
-
}, onBlur: (e) => {
|
|
54
|
-
e.currentTarget.style.boxShadow = "0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.3)";
|
|
55
|
-
}, children: truncatedQuestion }, index));
|
|
56
|
-
}) })] }));
|
|
57
|
-
}
|