goji-search 1.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/README.md +70 -0
- package/dist/goji-search/components/elements/action-buttons.d.ts +12 -0
- package/dist/goji-search/components/elements/action-buttons.js +135 -0
- package/dist/goji-search/components/elements/calendar-integration.d.ts +5 -0
- package/dist/goji-search/components/elements/calendar-integration.js +49 -0
- package/dist/goji-search/components/elements/inspiration-menu.d.ts +7 -0
- package/dist/goji-search/components/elements/inspiration-menu.js +79 -0
- package/dist/goji-search/components/elements/message-list.d.ts +24 -0
- package/dist/goji-search/components/elements/message-list.js +293 -0
- package/dist/goji-search/components/elements/search-input.d.ts +15 -0
- package/dist/goji-search/components/elements/search-input.js +90 -0
- package/dist/goji-search/components/elements/suggested-questions.d.ts +6 -0
- package/dist/goji-search/components/elements/suggested-questions.js +54 -0
- package/dist/goji-search/components/goji-search-component.d.ts +2 -0
- package/dist/goji-search/components/goji-search-component.js +505 -0
- package/dist/goji-search/config/company.d.ts +29 -0
- package/dist/goji-search/config/company.js +68 -0
- package/dist/goji-search/lib/calendar-config.d.ts +9 -0
- package/dist/goji-search/lib/calendar-config.js +10 -0
- package/dist/goji-search/lib/goji-client.d.ts +81 -0
- package/dist/goji-search/lib/goji-client.js +176 -0
- package/dist/goji-search.css +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/package.json +47 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect, useState, useId } from "react";
|
|
3
|
+
import ReactMarkdown from "react-markdown";
|
|
4
|
+
import remarkGfm from "remark-gfm";
|
|
5
|
+
import { ExternalLink, User, X, Maximize2, Minimize2 } from "lucide-react";
|
|
6
|
+
export function MessageList({ messages, isStreaming, aiAvatarSrc = '', onClose, onExpand, size = 'l', }) {
|
|
7
|
+
const messagesEndRef = useRef(null);
|
|
8
|
+
const [hoverTopExpand, setHoverTopExpand] = useState(false);
|
|
9
|
+
const [hoverTopClose, setHoverTopClose] = useState(false);
|
|
10
|
+
const idBase = useId();
|
|
11
|
+
const xTooltipId = `${idBase}-x-tip`;
|
|
12
|
+
const expandTooltipId = `${idBase}-expand-tip`;
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
15
|
+
}, [messages]);
|
|
16
|
+
const lastMessage = messages[messages.length - 1];
|
|
17
|
+
const showThinkingDots = isStreaming && (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.content);
|
|
18
|
+
return (_jsxs("div", { style: {
|
|
19
|
+
position: 'relative',
|
|
20
|
+
flex: 1,
|
|
21
|
+
overflowY: "auto",
|
|
22
|
+
marginTop: "0",
|
|
23
|
+
display: "flex",
|
|
24
|
+
flexDirection: "column",
|
|
25
|
+
gap: "0.75rem",
|
|
26
|
+
padding: "0.5rem",
|
|
27
|
+
borderRadius: "0.75rem",
|
|
28
|
+
backgroundColor: "rgba(255, 255, 255, 0.08)",
|
|
29
|
+
border: "1px solid rgba(255, 255, 255, 0.15)",
|
|
30
|
+
}, className: "custom-scrollbar", children: [_jsxs("div", { style: { display: 'flex', gap: '0.5rem', zIndex: 20, justifyContent: 'flex-end', paddingTop: '0' }, children: [onExpand && (_jsxs("div", { style: { position: 'relative' }, children: [_jsx("button", { type: "button", onClick: onExpand, onMouseEnter: () => setHoverTopExpand(true), onMouseLeave: () => setHoverTopExpand(false), "aria-label": size === 'xl' ? 'Restore' : 'Expand', "aria-describedby": hoverTopExpand ? expandTooltipId : undefined, style: {
|
|
31
|
+
borderRadius: '1.3rem',
|
|
32
|
+
border: '1px solid rgba(255, 255, 255, 0.3)',
|
|
33
|
+
backgroundColor: 'rgba(255, 255, 255, 0.12)',
|
|
34
|
+
padding: '0.375rem',
|
|
35
|
+
display: 'flex',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
justifyContent: 'center',
|
|
38
|
+
color: 'rgba(0, 0, 0, 0.75)',
|
|
39
|
+
transition: 'all 0.15s',
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
outline: 'none',
|
|
42
|
+
boxShadow: 'inset 0 1px 0 rgba(255, 255, 255, 0.2)',
|
|
43
|
+
}, children: size === 'xl' ? _jsx(Minimize2, { style: { width: '0.9rem', height: '0.9rem' } }) : _jsx(Maximize2, { style: { width: '0.9rem', height: '0.9rem' } }) }), _jsx("span", { id: expandTooltipId, role: "tooltip", style: {
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
top: 'calc(100% + 0.4rem)',
|
|
46
|
+
left: '50%',
|
|
47
|
+
transform: 'translateX(-50%)',
|
|
48
|
+
whiteSpace: 'nowrap',
|
|
49
|
+
background: 'rgba(0,0,0,0.9)',
|
|
50
|
+
color: '#fff',
|
|
51
|
+
padding: '4px 6px',
|
|
52
|
+
borderRadius: '1.3rem',
|
|
53
|
+
fontSize: '0.55rem',
|
|
54
|
+
boxShadow: '0 6px 18px rgba(0,0,0,0.35)',
|
|
55
|
+
opacity: hoverTopExpand ? 1 : 0,
|
|
56
|
+
pointerEvents: 'none',
|
|
57
|
+
transition: 'opacity 120ms ease-in-out',
|
|
58
|
+
zIndex: 30,
|
|
59
|
+
}, children: size === 'xl' ? 'Restore' : 'Expand' })] })), onClose && (_jsxs("div", { style: { position: 'relative' }, children: [_jsx("button", { type: "button", onClick: onClose, onMouseEnter: () => setHoverTopClose(true), onMouseLeave: () => setHoverTopClose(false), "aria-label": "Close", "aria-describedby": hoverTopClose ? xTooltipId : undefined, style: {
|
|
60
|
+
borderRadius: '1.3rem',
|
|
61
|
+
border: '1px solid rgba(255, 255, 255, 0.3)',
|
|
62
|
+
backgroundColor: 'rgba(255, 255, 255, 0.12)',
|
|
63
|
+
padding: '0.375rem',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
justifyContent: 'center',
|
|
67
|
+
color: 'rgba(0, 0, 0, 0.75)',
|
|
68
|
+
transition: 'all 0.15s',
|
|
69
|
+
cursor: 'pointer',
|
|
70
|
+
outline: 'none',
|
|
71
|
+
boxShadow: 'inset 0 1px 0 rgba(255, 255, 255, 0.2)',
|
|
72
|
+
}, children: _jsx(X, { style: { width: '0.9rem', height: '0.9rem' } }) }), _jsx("span", { id: xTooltipId, role: "tooltip", style: {
|
|
73
|
+
position: 'absolute',
|
|
74
|
+
top: 'calc(100% + 0.4rem)',
|
|
75
|
+
left: '50%',
|
|
76
|
+
transform: 'translateX(-50%)',
|
|
77
|
+
whiteSpace: 'nowrap',
|
|
78
|
+
background: 'rgba(0,0,0,0.9)',
|
|
79
|
+
color: '#fff',
|
|
80
|
+
padding: '4px 6px',
|
|
81
|
+
borderRadius: '1.3rem',
|
|
82
|
+
fontSize: '0.55rem',
|
|
83
|
+
boxShadow: '0 6px 18px rgba(0,0,0,0.35)',
|
|
84
|
+
opacity: hoverTopClose ? 1 : 0,
|
|
85
|
+
pointerEvents: 'none',
|
|
86
|
+
transition: 'opacity 120ms ease-in-out',
|
|
87
|
+
zIndex: 30,
|
|
88
|
+
}, children: "Close" })] }))] }), messages.map((message, index) => (_jsxs("div", { style: {
|
|
89
|
+
display: "flex",
|
|
90
|
+
flexDirection: "column",
|
|
91
|
+
alignItems: message.role === "user" ? "flex-end" : "flex-start",
|
|
92
|
+
animation: "fadeIn 0.3s ease-in",
|
|
93
|
+
gap: "0.375rem",
|
|
94
|
+
}, children: [_jsx("div", { style: {
|
|
95
|
+
display: "flex",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
gap: "0.5rem",
|
|
98
|
+
flexDirection: message.role === "user" ? "row-reverse" : "row"
|
|
99
|
+
}, children: _jsx("div", { style: {
|
|
100
|
+
width: "1.75rem",
|
|
101
|
+
height: "1.75rem",
|
|
102
|
+
borderRadius: message.role === "user" ? "50%" : "0.75rem",
|
|
103
|
+
backgroundColor: message.role === "user" ? "rgba(255, 255, 255, 0.15)" : "rgba(114, 126, 237, 0.15)",
|
|
104
|
+
display: "flex",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
justifyContent: "center",
|
|
107
|
+
fontSize: "0.75rem",
|
|
108
|
+
color: "rgb(114, 126, 237)",
|
|
109
|
+
border: message.role === "user"
|
|
110
|
+
? "1px solid rgba(114, 126, 237, 0.3)"
|
|
111
|
+
: "1px dashed rgba(114, 126, 237, 0.3)",
|
|
112
|
+
boxShadow: message.role === "user" ? "0 2px 4px rgba(0,0,0,0.05)" : "none",
|
|
113
|
+
}, children: message.role === "user" ? (_jsx(User, { size: 16, color: "rgb(114, 126, 237)" })) : (aiAvatarSrc ? (_jsx("img", { src: aiAvatarSrc, alt: "AI Avatar", style: {
|
|
114
|
+
width: "100%",
|
|
115
|
+
height: "100%",
|
|
116
|
+
borderRadius: "inherit",
|
|
117
|
+
objectFit: "cover"
|
|
118
|
+
} })) : (_jsx("div", { style: {
|
|
119
|
+
width: "100%",
|
|
120
|
+
height: "100%",
|
|
121
|
+
display: "flex",
|
|
122
|
+
alignItems: "center",
|
|
123
|
+
justifyContent: "center",
|
|
124
|
+
fontSize: "0.75rem",
|
|
125
|
+
color: "rgb(114, 126, 237)"
|
|
126
|
+
}, children: "AI" }))) }) }), _jsxs("div", { style: {
|
|
127
|
+
maxWidth: "85%",
|
|
128
|
+
padding: message.role === "user" ? "0.275rem 0.75rem" : "0.5rem 0",
|
|
129
|
+
borderRadius: message.role === "user" ? "1rem" : "0",
|
|
130
|
+
fontSize: "0.875rem",
|
|
131
|
+
marginLeft: message.role === "user" ? "0" : "1rem",
|
|
132
|
+
marginRight: message.role === "user" ? "1rem" : "0",
|
|
133
|
+
lineHeight: "1.6",
|
|
134
|
+
backgroundColor: message.role === "user" ? "rgb(114, 126, 237)" : "transparent",
|
|
135
|
+
color: message.role === "user" ? "white" : "rgba(0, 0, 0, 0.85)",
|
|
136
|
+
border: message.role === "user" ? "1px solid rgba(255, 255, 255, 0.25)" : "none",
|
|
137
|
+
}, children: [message.role === "user" ? (_jsx("p", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: message.content })) : (_jsx("div", { className: "markdown-content", style: {
|
|
138
|
+
fontSize: "0.875rem",
|
|
139
|
+
lineHeight: "1.7",
|
|
140
|
+
color: "rgba(0, 0, 0, 0.85)",
|
|
141
|
+
}, children: _jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content }) })), message.role === "assistant" && message.sources && message.sources.length > 0 && (_jsxs("div", { style: {
|
|
142
|
+
marginTop: "1rem",
|
|
143
|
+
paddingTop: "0.75rem",
|
|
144
|
+
borderTop: "1px solid rgba(0, 0, 0, 0.1)",
|
|
145
|
+
}, children: [_jsx("p", { style: {
|
|
146
|
+
fontSize: "0.65rem",
|
|
147
|
+
fontWeight: 600,
|
|
148
|
+
textTransform: "uppercase",
|
|
149
|
+
letterSpacing: "0.05em",
|
|
150
|
+
color: "rgba(0, 0, 0, 0.5)",
|
|
151
|
+
marginBottom: "0.5rem",
|
|
152
|
+
}, children: "Sources" }), _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: {
|
|
153
|
+
display: "flex",
|
|
154
|
+
alignItems: "center",
|
|
155
|
+
gap: "0.5rem",
|
|
156
|
+
fontSize: "0.75rem",
|
|
157
|
+
color: "rgba(0, 0, 0, 0.7)",
|
|
158
|
+
textDecoration: "none",
|
|
159
|
+
transition: "color 0.2s",
|
|
160
|
+
}, onMouseEnter: (e) => {
|
|
161
|
+
e.currentTarget.style.color = "rgba(0, 0, 0, 0.9)";
|
|
162
|
+
}, onMouseLeave: (e) => {
|
|
163
|
+
e.currentTarget.style.color = "rgba(0, 0, 0, 0.7)";
|
|
164
|
+
}, children: [_jsxs("span", { style: {
|
|
165
|
+
backgroundColor: "rgba(0, 0, 0, 0.1)",
|
|
166
|
+
padding: "0.125rem 0.375rem",
|
|
167
|
+
borderRadius: "0.375rem",
|
|
168
|
+
fontSize: "0.65rem",
|
|
169
|
+
fontWeight: 600,
|
|
170
|
+
}, 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))), showThinkingDots && (_jsx("div", { style: { display: "flex", justifyContent: "flex-start" }, children: _jsxs("div", { style: {
|
|
171
|
+
padding: "0.75rem 0.6rem",
|
|
172
|
+
borderRadius: "1rem",
|
|
173
|
+
display: "flex",
|
|
174
|
+
gap: "0.375rem",
|
|
175
|
+
}, children: [_jsx("span", { style: {
|
|
176
|
+
width: "0.5rem",
|
|
177
|
+
height: "0.5rem",
|
|
178
|
+
borderRadius: "50%",
|
|
179
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
180
|
+
animation: "pulse 1.4s ease-in-out infinite",
|
|
181
|
+
} }), _jsx("span", { style: {
|
|
182
|
+
width: "0.5rem",
|
|
183
|
+
height: "0.5rem",
|
|
184
|
+
borderRadius: "50%",
|
|
185
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
186
|
+
animation: "pulse 1.4s ease-in-out 0.2s infinite",
|
|
187
|
+
} }), _jsx("span", { style: {
|
|
188
|
+
width: "0.5rem",
|
|
189
|
+
height: "0.5rem",
|
|
190
|
+
borderRadius: "50%",
|
|
191
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
192
|
+
animation: "pulse 1.4s ease-in-out 0.4s infinite",
|
|
193
|
+
} })] }) })), _jsx("div", { ref: messagesEndRef }), _jsx("style", { children: `
|
|
194
|
+
.markdown-content p {
|
|
195
|
+
margin: 0 0 0.75rem 0;
|
|
196
|
+
}
|
|
197
|
+
.markdown-content p:last-child {
|
|
198
|
+
margin-bottom: 0;
|
|
199
|
+
}
|
|
200
|
+
.markdown-content h1,
|
|
201
|
+
.markdown-content h2,
|
|
202
|
+
.markdown-content h3,
|
|
203
|
+
.markdown-content h4 {
|
|
204
|
+
margin: 1rem 0 0.5rem 0;
|
|
205
|
+
font-weight: 600;
|
|
206
|
+
color: rgba(0, 0, 0, 0.9);
|
|
207
|
+
}
|
|
208
|
+
.markdown-content h1 {
|
|
209
|
+
font-size: 1.25rem;
|
|
210
|
+
}
|
|
211
|
+
.markdown-content h2 {
|
|
212
|
+
font-size: 1.125rem;
|
|
213
|
+
}
|
|
214
|
+
.markdown-content h3 {
|
|
215
|
+
font-size: 1rem;
|
|
216
|
+
}
|
|
217
|
+
.markdown-content ul,
|
|
218
|
+
.markdown-content ol {
|
|
219
|
+
margin: 0.5rem 0;
|
|
220
|
+
padding-left: 1.5rem;
|
|
221
|
+
}
|
|
222
|
+
.markdown-content li {
|
|
223
|
+
margin: 0.25rem 0;
|
|
224
|
+
}
|
|
225
|
+
.markdown-content code {
|
|
226
|
+
background-color: rgba(0, 0, 0, 0.08);
|
|
227
|
+
padding: 0.125rem 0.375rem;
|
|
228
|
+
border-radius: 0.25rem;
|
|
229
|
+
font-size: 0.8125rem;
|
|
230
|
+
font-family: ui-monospace, monospace;
|
|
231
|
+
}
|
|
232
|
+
.markdown-content pre {
|
|
233
|
+
background-color: rgba(0, 0, 0, 0.08);
|
|
234
|
+
padding: 0.75rem;
|
|
235
|
+
border-radius: 0.5rem;
|
|
236
|
+
overflow-x: auto;
|
|
237
|
+
margin: 0.75rem 0;
|
|
238
|
+
}
|
|
239
|
+
.markdown-content pre code {
|
|
240
|
+
background-color: transparent;
|
|
241
|
+
padding: 0;
|
|
242
|
+
}
|
|
243
|
+
.markdown-content a {
|
|
244
|
+
color: rgb(114, 126, 237);
|
|
245
|
+
text-decoration: underline;
|
|
246
|
+
}
|
|
247
|
+
.markdown-content a:hover {
|
|
248
|
+
color: rgb(94, 106, 217);
|
|
249
|
+
}
|
|
250
|
+
.markdown-content blockquote {
|
|
251
|
+
border-left: 3px solid rgba(0, 0, 0, 0.2);
|
|
252
|
+
padding-left: 1rem;
|
|
253
|
+
margin: 0.75rem 0;
|
|
254
|
+
color: rgba(0, 0, 0, 0.7);
|
|
255
|
+
}
|
|
256
|
+
.markdown-content strong {
|
|
257
|
+
font-weight: 600;
|
|
258
|
+
color: rgba(0, 0, 0, 0.9);
|
|
259
|
+
}
|
|
260
|
+
.markdown-content table {
|
|
261
|
+
border-collapse: collapse;
|
|
262
|
+
width: 100%;
|
|
263
|
+
margin: 0.75rem 0;
|
|
264
|
+
}
|
|
265
|
+
.markdown-content th,
|
|
266
|
+
.markdown-content td {
|
|
267
|
+
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
268
|
+
padding: 0.5rem;
|
|
269
|
+
text-align: left;
|
|
270
|
+
}
|
|
271
|
+
.markdown-content th {
|
|
272
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
273
|
+
font-weight: 600;
|
|
274
|
+
}
|
|
275
|
+
.custom-scrollbar {
|
|
276
|
+
scrollbar-width: thin;
|
|
277
|
+
scrollbar-color: rgba(0, 0, 0, 0.5) rgba(255, 255, 255, 0.08);
|
|
278
|
+
}
|
|
279
|
+
.custom-scrollbar::-webkit-scrollbar {
|
|
280
|
+
width: 0.5rem;
|
|
281
|
+
}
|
|
282
|
+
.custom-scrollbar::-webkit-scrollbar-track {
|
|
283
|
+
background: rgba(255, 255, 255, 0.08);
|
|
284
|
+
}
|
|
285
|
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
|
286
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
287
|
+
border-radius: 0.25rem;
|
|
288
|
+
}
|
|
289
|
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
290
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
291
|
+
}
|
|
292
|
+
` })] }));
|
|
293
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
interface SearchInputProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
|
+
onFocus: () => void;
|
|
6
|
+
onBlur: () => void;
|
|
7
|
+
placeholder: string;
|
|
8
|
+
size: "xs" | "s" | "m" | "l" | "xl";
|
|
9
|
+
inputRef: React.RefObject<HTMLInputElement>;
|
|
10
|
+
inspirationQuestions: string[];
|
|
11
|
+
onInspirationClick: (question: string) => void;
|
|
12
|
+
sparkleRef: React.RefObject<HTMLDivElement>;
|
|
13
|
+
}
|
|
14
|
+
export declare function SearchInput({ value, onChange, onFocus, onBlur, placeholder, size, inputRef, inspirationQuestions, onInspirationClick, sparkleRef, }: SearchInputProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
export function SearchInput({ value, onChange, onFocus, onBlur, placeholder, size, inputRef, inspirationQuestions, onInspirationClick, sparkleRef, }) {
|
|
6
|
+
const [showInspirationMenu, setShowInspirationMenu] = useState(false);
|
|
7
|
+
const [isSparkleHovered, setIsSparkleHovered] = useState(false);
|
|
8
|
+
const [typewriterText, setTypewriterText] = useState("");
|
|
9
|
+
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
|
|
10
|
+
const [isTyping, setIsTyping] = useState(true);
|
|
11
|
+
const [charIndex, setCharIndex] = useState(0);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (size !== "s" || value || inspirationQuestions.length === 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const currentQuestion = inspirationQuestions[currentQuestionIndex];
|
|
17
|
+
const typingSpeed = 40; // ms per character when typing
|
|
18
|
+
const deletingSpeed = 20; // ms per character when deleting
|
|
19
|
+
const pauseAfterTyping = 2000; // pause when fully typed
|
|
20
|
+
const pauseAfterDeleting = 500; // pause before typing next question
|
|
21
|
+
const timer = setTimeout(() => {
|
|
22
|
+
if (isTyping) {
|
|
23
|
+
// Typing phase
|
|
24
|
+
if (charIndex < currentQuestion.length) {
|
|
25
|
+
setTypewriterText(currentQuestion.slice(0, charIndex + 1));
|
|
26
|
+
setCharIndex(charIndex + 1);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// Finished typing, pause then start deleting
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
setIsTyping(false);
|
|
32
|
+
}, pauseAfterTyping);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Deleting phase
|
|
37
|
+
if (charIndex > 0) {
|
|
38
|
+
setTypewriterText(currentQuestion.slice(0, charIndex - 1));
|
|
39
|
+
setCharIndex(charIndex - 1);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Finished deleting, move to next question
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
setCurrentQuestionIndex((currentQuestionIndex + 1) % inspirationQuestions.length);
|
|
45
|
+
setIsTyping(true);
|
|
46
|
+
}, pauseAfterDeleting);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, isTyping ? typingSpeed : deletingSpeed);
|
|
50
|
+
return () => clearTimeout(timer);
|
|
51
|
+
}, [size, value, inspirationQuestions, currentQuestionIndex, isTyping, charIndex]);
|
|
52
|
+
const handleSparkleClick = () => {
|
|
53
|
+
setShowInspirationMenu(!showInspirationMenu);
|
|
54
|
+
};
|
|
55
|
+
const handleQuestionClick = (question) => {
|
|
56
|
+
onInspirationClick(question);
|
|
57
|
+
setShowInspirationMenu(false);
|
|
58
|
+
};
|
|
59
|
+
const displayPlaceholder = size === "s" && !value ? typewriterText : placeholder;
|
|
60
|
+
return (_jsxs("div", { style: { position: "relative" }, children: [_jsxs("div", { ref: sparkleRef, onClick: handleSparkleClick, onMouseEnter: () => setIsSparkleHovered(true), onMouseLeave: () => setIsSparkleHovered(false), style: {
|
|
61
|
+
position: "absolute",
|
|
62
|
+
left: "0.75rem",
|
|
63
|
+
top: "50%",
|
|
64
|
+
transform: "translateY(-50%)",
|
|
65
|
+
cursor: "pointer",
|
|
66
|
+
zIndex: 10,
|
|
67
|
+
}, children: [_jsx(Sparkles, { style: {
|
|
68
|
+
width: size === "s" ? "0.875rem" : "1rem",
|
|
69
|
+
height: size === "s" ? "0.875rem" : "1rem",
|
|
70
|
+
color: "rgba(0, 0, 0, 0.6)",
|
|
71
|
+
transition: "all 0.3s ease",
|
|
72
|
+
} }), showInspirationMenu && (_jsx(InspirationMenu, { questions: inspirationQuestions, onQuestionClick: handleQuestionClick, onClose: () => setShowInspirationMenu(false) }))] }), _jsx("input", { ref: inputRef, type: "text", value: value, onChange: onChange, onFocus: onFocus, className: "sparkle-input", onBlur: onBlur, placeholder: displayPlaceholder, style: {
|
|
73
|
+
width: "100%",
|
|
74
|
+
borderRadius: "1.3rem",
|
|
75
|
+
border: "1px solid rgba(255, 255, 255, 0.25)",
|
|
76
|
+
backgroundColor: "rgba(255, 255, 255, 0.3)",
|
|
77
|
+
padding: size === "s" ? "0.375rem 0.5rem 0.375rem 2rem" : "0.5rem 0.75rem 0.5rem 2.25rem",
|
|
78
|
+
fontSize: size === "s" ? "0.8125rem" : "0.875rem",
|
|
79
|
+
color: "rgba(0, 0, 0, 0.85)",
|
|
80
|
+
backdropFilter: "blur(20px) saturate(180%)",
|
|
81
|
+
WebkitBackdropFilter: "blur(20px) saturate(180%)",
|
|
82
|
+
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
83
|
+
outline: "none",
|
|
84
|
+
boxShadow: "inset 0 1px 0 rgba(255, 255, 255, 0.4)",
|
|
85
|
+
} }), _jsx("style", { children: `
|
|
86
|
+
input::placeholder {
|
|
87
|
+
color: rgba(0, 0, 0, 0.75);
|
|
88
|
+
}
|
|
89
|
+
` })] }));
|
|
90
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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.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) => (_jsx("button", { type: "button", onClick: () => onQuestionClick(question), style: {
|
|
24
|
+
padding: "0.5rem 0.75rem",
|
|
25
|
+
borderRadius: "1.3rem",
|
|
26
|
+
border: "1px solid rgba(255, 255, 255, 0.25)",
|
|
27
|
+
backgroundColor: "rgba(255, 255, 255, 0.2)",
|
|
28
|
+
color: "rgba(0, 0, 0, 0.75)",
|
|
29
|
+
fontSize: "0.75rem",
|
|
30
|
+
textAlign: "left",
|
|
31
|
+
cursor: "pointer",
|
|
32
|
+
transition: "all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
33
|
+
backdropFilter: "blur(20px) saturate(180%)",
|
|
34
|
+
WebkitBackdropFilter: "blur(20px) saturate(180%)",
|
|
35
|
+
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.3)",
|
|
36
|
+
outline: "none",
|
|
37
|
+
lineHeight: "1.3",
|
|
38
|
+
}, onMouseEnter: (e) => {
|
|
39
|
+
e.currentTarget.style.backgroundColor = "rgba(0, 122, 255, 0.15)";
|
|
40
|
+
e.currentTarget.style.borderColor = "rgba(0, 122, 255, 0.3)";
|
|
41
|
+
e.currentTarget.style.transform = "translateY(-1px)";
|
|
42
|
+
e.currentTarget.style.boxShadow =
|
|
43
|
+
"0 3px 8px rgba(0, 122, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.4)";
|
|
44
|
+
}, onMouseLeave: (e) => {
|
|
45
|
+
e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.2)";
|
|
46
|
+
e.currentTarget.style.borderColor = "rgba(255, 255, 255, 0.25)";
|
|
47
|
+
e.currentTarget.style.transform = "translateY(0)";
|
|
48
|
+
e.currentTarget.style.boxShadow = "0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.3)";
|
|
49
|
+
}, onFocus: (e) => {
|
|
50
|
+
e.currentTarget.style.boxShadow = "0 0 0 2px rgba(0, 122, 255, 0.3)";
|
|
51
|
+
}, onBlur: (e) => {
|
|
52
|
+
e.currentTarget.style.boxShadow = "0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.3)";
|
|
53
|
+
}, children: question }, index))) })] }));
|
|
54
|
+
}
|