@netlify/spark-ui 1.12.0-alpha.0 → 1.12.0-alpha.2
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/assets/AskNetlify.css +1 -1
- package/dist/assets/SearchLink.css +1 -1
- package/dist/assets/SearchModal.css +1 -1
- package/dist/chunks/{ChatInterface.EQAPs01R.js → AskNetlify.lrswYyKn.js} +119 -110
- package/dist/components/preact/AskNetlify/AskNetlify.d.ts +3 -3
- package/dist/components/preact/AskNetlify/AskNetlify.js +8 -34
- package/dist/components/preact/AskNetlify/components/ChatMessages.d.ts +2 -1
- package/dist/components/preact/AskNetlify/components/ChatMessages.js +25 -21
- package/dist/components/preact/AskNetlify/components/SourcesList.js +17 -13
- package/dist/components/preact/AskNetlify/hooks/useAskAnalytics.d.ts +23 -0
- package/dist/components/preact/AskNetlify/hooks/useAskAnalytics.js +22 -0
- package/dist/components/preact/Icon/index.js +6 -6
- package/dist/components/preact/SearchModal/components/SearchInput.js +18 -8
- package/dist/components/preact/SearchModal/components/SearchLink/SearchLink.d.ts +1 -1
- package/dist/components/preact/SearchModal/components/SearchLink/SearchLink.js +23 -22
- package/dist/components/preact/SearchModal/components/SearchLinkThemeToggle.d.ts +1 -0
- package/dist/components/preact/SearchModal/components/SearchLinkThemeToggle.js +26 -0
- package/dist/components/preact/SearchModal/components/SearchModal/SearchModal.js +89 -84
- package/dist/components/preact/SearchModal/components/SearchWindow.d.ts +1 -1
- package/dist/components/preact/SearchModal/components/SearchWindow.js +55 -48
- package/dist/components/preact/SearchModal/hooks/index.d.ts +1 -1
- package/dist/components/preact/SearchModal/hooks/index.js +8 -8
- package/dist/components/preact/SearchModal/hooks/useKeyboardNav.d.ts +1 -1
- package/dist/components/preact/SearchModal/hooks/useKeyboardNav.js +11 -12
- package/dist/components/preact/SearchModal/hooks/useSearch.js +19 -19
- package/dist/components/preact/SearchModal/hooks/{useSearchLogger.d.ts → useSearchAnalytics.d.ts} +2 -2
- package/dist/components/preact/SearchModal/hooks/{useSearchLogger.js → useSearchAnalytics.js} +5 -5
- package/dist/components/preact/SearchModal/hooks/useSearchHotkeys.d.ts +1 -1
- package/dist/components/preact/SearchModal/hooks/useSearchHotkeys.js +8 -9
- package/dist/components/preact/SearchModal/hooks/useSearchParams.d.ts +1 -1
- package/dist/components/preact/SearchModal/hooks/useSearchParams.js +14 -7
- package/dist/components/preact/SearchModal/hooks/useSearchToggles.d.ts +1 -1
- package/dist/components/preact/SearchModal/hooks/useSearchToggles.js +7 -8
- package/dist/components/preact/SearchModal/types/search.types.d.ts +11 -4
- package/dist/components/preact/index.js +3 -3
- package/package.json +1 -1
- package/packages/components/preact/AskNetlify/AskNetlify.css +41 -1
- package/packages/components/preact/AskNetlify/AskNetlify.tsx +98 -34
- package/packages/components/preact/AskNetlify/components/ChatMessages.tsx +9 -7
- package/packages/components/preact/AskNetlify/components/SourcesList.tsx +24 -16
- package/packages/components/preact/AskNetlify/hooks/useAskAnalytics.tsx +50 -0
- package/packages/components/preact/Icon/index.tsx +2 -2
- package/packages/components/preact/SearchModal/components/SearchInput.tsx +10 -0
- package/packages/components/preact/SearchModal/components/SearchLink/SearchLink.css +5 -0
- package/packages/components/preact/SearchModal/components/SearchLink/SearchLink.tsx +6 -4
- package/packages/components/preact/SearchModal/components/SearchLinkThemeToggle.tsx +19 -0
- package/packages/components/preact/SearchModal/components/SearchModal/SearchModal.css +33 -3
- package/packages/components/preact/SearchModal/components/SearchModal/SearchModal.tsx +73 -89
- package/packages/components/preact/SearchModal/components/SearchWindow.tsx +64 -46
- package/packages/components/preact/SearchModal/hooks/index.ts +1 -1
- package/packages/components/preact/SearchModal/hooks/useKeyboardNav.ts +1 -3
- package/packages/components/preact/SearchModal/hooks/useSearch.ts +20 -16
- package/packages/components/preact/SearchModal/hooks/{useSearchLogger.ts → useSearchAnalytics.ts} +9 -10
- package/packages/components/preact/SearchModal/hooks/useSearchHotkeys.ts +2 -4
- package/packages/components/preact/SearchModal/hooks/useSearchParams.ts +24 -2
- package/packages/components/preact/SearchModal/hooks/useSearchToggles.ts +1 -3
- package/packages/components/preact/SearchModal/types/search.types.tsx +7 -4
- package/packages/styles/loaders.css +18 -0
- package/packages/styles/tokens.css +4 -0
- package/dist/components/preact/AskNetlify/components/ChatInterface.d.ts +0 -7
- package/dist/components/preact/AskNetlify/components/ChatInterface.js +0 -10
- package/packages/components/preact/AskNetlify/components/ChatInterface.tsx +0 -94
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import "../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
|
|
2
|
-
import "../../../../chunks/hooks.module.DGkdD5n9.js";
|
|
3
|
-
import { C as f } from "../../../../chunks/ChatInterface.EQAPs01R.js";
|
|
4
|
-
import "./QuestionList/questions.js";
|
|
5
|
-
import "./QuestionList/QuestionList.js";
|
|
6
|
-
import "./BackButton.js";
|
|
7
|
-
import "./ChatMessages.js";
|
|
8
|
-
export {
|
|
9
|
-
f as default
|
|
10
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { useState, useRef, useEffect } from 'preact/hooks';
|
|
2
|
-
import { useChat } from '@kapaai/react-sdk';
|
|
3
|
-
import { questions } from './QuestionList/questions';
|
|
4
|
-
import { QuestionList } from './QuestionList/QuestionList';
|
|
5
|
-
import { BackButton } from './BackButton';
|
|
6
|
-
import { ChatMessages } from './ChatMessages';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
setModalState?: (e: { current: string }) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default function ChatInterface({ setModalState }: Props) {
|
|
13
|
-
const [message, setMessage] = useState('');
|
|
14
|
-
const [newMessageReady, setNewMessageReady] = useState(false);
|
|
15
|
-
const chatRef = useRef<HTMLDivElement>(null);
|
|
16
|
-
const menuRef = useRef<HTMLUListElement>(null);
|
|
17
|
-
const lastMessageRef = useRef<HTMLDivElement | null>(null);
|
|
18
|
-
|
|
19
|
-
const { conversation, submitQuery, isGeneratingAnswer, isPreparingAnswer, stopGeneration } =
|
|
20
|
-
useChat();
|
|
21
|
-
|
|
22
|
-
const handleSubmit = (e: Event | preact.JSX.TargetedMouseEvent<HTMLButtonElement>) => {
|
|
23
|
-
e.preventDefault();
|
|
24
|
-
const target = e.target as HTMLButtonElement;
|
|
25
|
-
const id = target?.getAttribute('data-question-id');
|
|
26
|
-
const text = id ? questions[id] : message;
|
|
27
|
-
|
|
28
|
-
if (text.trim()) {
|
|
29
|
-
submitQuery(text.trim());
|
|
30
|
-
}
|
|
31
|
-
if (!id) setMessage('');
|
|
32
|
-
|
|
33
|
-
setNewMessageReady(true);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/*
|
|
37
|
-
* When a new user message is ready, scroll it into view and reset the flag.
|
|
38
|
-
* This ensures the most recent message is visible to the user immediately after rendering.
|
|
39
|
-
*/
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (newMessageReady && lastMessageRef.current) {
|
|
42
|
-
lastMessageRef.current.scrollIntoView({ behavior: 'smooth' });
|
|
43
|
-
setNewMessageReady(false);
|
|
44
|
-
}
|
|
45
|
-
}, [newMessageReady]);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div className="n-ask-chat-container">
|
|
49
|
-
<BackButton onClick={() => setModalState?.({ current: 'search' })} />
|
|
50
|
-
<div ref={chatRef} className="n-ask-conversation n-search-window">
|
|
51
|
-
{!conversation.length ? (
|
|
52
|
-
<QuestionList onClick={handleSubmit} menuRef={menuRef} />
|
|
53
|
-
) : (
|
|
54
|
-
<ChatMessages conversation={conversation} lastMessageRef={lastMessageRef} />
|
|
55
|
-
)}
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
<form onSubmit={handleSubmit} className="n-ask-form n-search-input-wrapper">
|
|
59
|
-
<input
|
|
60
|
-
className="n-ask-input n-search-input"
|
|
61
|
-
type="text"
|
|
62
|
-
value={message}
|
|
63
|
-
onInput={e => setMessage(e.currentTarget.value)}
|
|
64
|
-
placeholder="Ask a question..."
|
|
65
|
-
disabled={isPreparingAnswer || isGeneratingAnswer}
|
|
66
|
-
/>
|
|
67
|
-
|
|
68
|
-
{isGeneratingAnswer ? (
|
|
69
|
-
<button
|
|
70
|
-
type="button"
|
|
71
|
-
className="n-ask-form-submit"
|
|
72
|
-
onClick={stopGeneration}
|
|
73
|
-
aria-label="Stop generation"
|
|
74
|
-
>
|
|
75
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="var(--neutral-100)">
|
|
76
|
-
<rect x="0" y="0" width="16" height="16" />
|
|
77
|
-
</svg>
|
|
78
|
-
</button>
|
|
79
|
-
) : (
|
|
80
|
-
<button
|
|
81
|
-
type="submit"
|
|
82
|
-
className="n-ask-form-submit"
|
|
83
|
-
disabled={!message.trim() || isPreparingAnswer}
|
|
84
|
-
aria-label="Send message"
|
|
85
|
-
>
|
|
86
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" fill="var(--neutral-100)">
|
|
87
|
-
<path d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z" />
|
|
88
|
-
</svg>
|
|
89
|
-
</button>
|
|
90
|
-
)}
|
|
91
|
-
</form>
|
|
92
|
-
</div>
|
|
93
|
-
);
|
|
94
|
-
}
|