@sybilion/uilib 1.3.77 → 1.3.79

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.
Files changed (48) hide show
  1. package/dist/esm/components/ui/Chat/Chat.js +2 -2
  2. package/dist/esm/components/ui/Chat/Chat.styl.js +1 -1
  3. package/dist/esm/components/ui/Chat/ChatChrome/ChatChrome.js +6 -6
  4. package/dist/esm/components/ui/Chat/ChatChrome/ChatChrome.styl.js +2 -2
  5. package/dist/esm/components/ui/Chat/ChatEmptyState/ChatEmptyState.styl.js +1 -1
  6. package/dist/esm/components/ui/Chat/ChatMessage/ChatMessage.js +2 -2
  7. package/dist/esm/components/ui/Chat/ChatMessage/ChatMessage.styl.js +1 -1
  8. package/dist/esm/components/ui/Chat/ChatPresets/ChatPresets.styl.js +1 -1
  9. package/dist/esm/components/ui/Chat/ChatSheet/ChatSelector.js +2 -2
  10. package/dist/esm/components/ui/Chat/ChatSheet/ChatSheet.js +2 -1
  11. package/dist/esm/components/ui/Chat/ChatSheet/useChatPanelChromeModel.js +6 -5
  12. package/dist/esm/components/ui/FileChip/FileChip.js +4 -0
  13. package/dist/esm/contexts/chat-context.js +36 -4
  14. package/dist/esm/index.js +1 -0
  15. package/dist/esm/types/src/components/ui/Chat/Chat.d.ts +1 -1
  16. package/dist/esm/types/src/components/ui/Chat/Chat.types.d.ts +10 -0
  17. package/dist/esm/types/src/components/ui/Chat/ChatChrome/ChatChrome.d.ts +1 -1
  18. package/dist/esm/types/src/components/ui/Chat/ChatChrome/ChatChrome.types.d.ts +4 -0
  19. package/dist/esm/types/src/components/ui/Chat/ChatMessage/ChatMessage.d.ts +1 -1
  20. package/dist/esm/types/src/components/ui/Chat/ChatSheet/ChatSelector.d.ts +2 -1
  21. package/dist/esm/types/src/components/ui/Chat/ChatSheet/ChatSheet.d.ts +1 -1
  22. package/dist/esm/types/src/components/ui/Chat/ChatSheet/useChatPanelChromeModel.d.ts +5 -3
  23. package/dist/esm/types/src/components/ui/Chat/index.d.ts +3 -1
  24. package/dist/esm/types/src/components/ui/FileChip/FileChip.types.d.ts +1 -1
  25. package/dist/esm/types/src/contexts/chat-context.d.ts +16 -4
  26. package/package.json +1 -1
  27. package/src/components/ui/Chat/Chat.styl +4 -1
  28. package/src/components/ui/Chat/Chat.tsx +2 -1
  29. package/src/components/ui/Chat/Chat.types.ts +12 -0
  30. package/src/components/ui/Chat/ChatChrome/ChatChrome.styl +20 -10
  31. package/src/components/ui/Chat/ChatChrome/ChatChrome.styl.d.ts +2 -0
  32. package/src/components/ui/Chat/ChatChrome/ChatChrome.tsx +12 -4
  33. package/src/components/ui/Chat/ChatChrome/ChatChrome.types.ts +4 -0
  34. package/src/components/ui/Chat/ChatEmptyState/ChatEmptyState.styl +1 -2
  35. package/src/components/ui/Chat/ChatMessage/ChatMessage.styl +1 -0
  36. package/src/components/ui/Chat/ChatMessage/ChatMessage.tsx +9 -1
  37. package/src/components/ui/Chat/ChatPresets/ChatPresets.styl +5 -4
  38. package/src/components/ui/Chat/ChatSheet/ChatSelector.tsx +3 -1
  39. package/src/components/ui/Chat/ChatSheet/ChatSheet.tsx +2 -0
  40. package/src/components/ui/Chat/ChatSheet/useChatPanelChromeModel.tsx +24 -5
  41. package/src/components/ui/Chat/index.ts +4 -0
  42. package/src/components/ui/FileChip/FileChip.tsx +11 -0
  43. package/src/components/ui/FileChip/FileChip.types.ts +1 -1
  44. package/src/contexts/chat-context.tsx +57 -5
  45. package/src/docs/pages/ChatPage.styl +6 -0
  46. package/src/docs/pages/ChatPage.styl.d.ts +7 -0
  47. package/src/docs/pages/ChatPage.tsx +30 -87
  48. package/src/docs/pages/ChatSlashCommandsPage.tsx +4 -4
@@ -1,106 +1,49 @@
1
- import { useCallback, useEffect, useRef, useState } from 'react';
2
-
3
- import { ChatChrome, Message, MessageRole } from '#uilib/components/ui/Chat';
1
+ import { ChatChrome, useChatPanelChromeModel } from '#uilib/components/ui/Chat';
4
2
  import { PageContentSection } from '#uilib/components/ui/Page';
5
- import { ScrollRef } from '@homecode/ui';
6
3
 
4
+ import {
5
+ DOCS_DATASET_PRESETS,
6
+ DOCS_SAMPLE_DATASET_NAME,
7
+ } from '../chatPresets.sample';
7
8
  import { AppPageHeader } from '../components/AppPageHeader/AppPageHeader';
9
+ import { DOCS_CHAT_USER_KEY } from '../docsConstants';
8
10
  import { DocsHeaderActions } from '../docsHeaderActions';
11
+ import S from './ChatPage.styl';
9
12
 
10
- const NO_QUICK_REPLY_KEYS: ReadonlySet<string> = new Set();
11
-
12
- const ASSISTANT_REPLY_TEXT =
13
- 'This is a generic assistant reply for the docs preview. Wire your app to a real model here.';
14
-
15
- function makeMessage(role: MessageRole, text: string): Message {
16
- return {
17
- id: crypto.randomUUID(),
18
- role,
19
- text,
20
- timestamp: Date.now(),
21
- };
22
- }
13
+ const DOCS_CHAT_INLINE_SCOPE_ID = `${DOCS_CHAT_USER_KEY}-docs-chat-inline`;
23
14
 
24
15
  export default function ChatPage() {
25
- const [messages, setMessages] = useState<Message[]>([]);
26
- const [isLoading, setIsLoading] = useState(false);
27
- const replyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
28
- const scrollRef = useRef<ScrollRef>(null);
29
-
30
- useEffect(() => {
31
- return () => {
32
- if (replyTimeoutRef.current != null) {
33
- clearTimeout(replyTimeoutRef.current);
34
- }
35
- };
36
- }, []);
37
-
38
- const isEmpty = messages.length === 0 && !isLoading;
39
- const isLastMessageFromUser =
40
- messages.length > 0 &&
41
- messages[messages.length - 1]?.role === MessageRole.USER;
42
-
43
- const onSubmit = useCallback(
44
- (raw: string) => {
45
- const text = raw.trim();
46
- if (!text || isLoading) return;
47
-
48
- setMessages(prev => [...prev, makeMessage(MessageRole.USER, text)]);
49
- setIsLoading(true);
50
-
51
- if (replyTimeoutRef.current != null) {
52
- clearTimeout(replyTimeoutRef.current);
53
- }
54
- replyTimeoutRef.current = setTimeout(() => {
55
- replyTimeoutRef.current = null;
56
- setMessages(prev => [
57
- ...prev,
58
- makeMessage(MessageRole.ASSISTANT, ASSISTANT_REPLY_TEXT),
59
- ]);
60
- setIsLoading(false);
61
- }, 900);
16
+ const { chromeProps } = useChatPanelChromeModel({
17
+ embedAsPage: true,
18
+ scopeId: DOCS_CHAT_INLINE_SCOPE_ID,
19
+ presets: DOCS_DATASET_PRESETS,
20
+ emptyState: {
21
+ title: 'Start a conversation',
22
+ description:
23
+ 'Send a message below or pick a preset chip. The demo echoes your text after a short delay.',
24
+ additionalContent: (
25
+ <p>Optional empty-state slot via additionalContent.</p>
26
+ ),
62
27
  },
63
- [isLoading],
64
- );
28
+ });
65
29
 
66
30
  return (
67
31
  <>
68
32
  <AppPageHeader
69
33
  breadcrumbs={[{ label: 'Chat' }]}
70
34
  title="Chat"
71
- subheader="Chat shell with message list and prompt."
72
- actions={<DocsHeaderActions />}
35
+ subheader={`Chat shell with message list, prompt, and dataset-scoped preset bubbles for "${DOCS_SAMPLE_DATASET_NAME}".`}
36
+ actions={<DocsHeaderActions presets={DOCS_DATASET_PRESETS} />}
73
37
  />
74
38
  <PageContentSection>
75
- <ChatChrome
76
- showResizeHandle={false}
77
- resizeHandle={undefined}
78
- onClose={undefined}
79
- isEmpty={isEmpty}
80
- renderPresets={() => null}
81
- messages={messages}
82
- onQuickReply={() => {}}
83
- suppressedQuickReplyKeys={NO_QUICK_REPLY_KEYS}
84
- isLoading={isLoading}
85
- scriptContinueLabel={undefined}
86
- onScriptContinue={undefined}
87
- showSyntheticBranchButtons={false}
88
- unusedBranchKeys={[]}
89
- showInlinePresets={false}
90
- isLastMessageFromUser={isLastMessageFromUser}
91
- scrollRef={scrollRef}
92
- effectiveScopeId="docs-chat-inline"
93
- onPromptSubmit={onSubmit}
94
- onChatDeleted={() => {}}
95
- emptyState={{
96
- title: 'Start a conversation',
97
- description:
98
- 'Send a message below. This demo appends a canned reply after a short delay.',
99
- additionalContent: (
100
- <p>Optional empty-state slot via additionalContent.</p>
101
- ),
102
- }}
103
- />
39
+ <p style={{ marginBottom: 16, fontSize: 14, lineHeight: 1.5 }}>
40
+ Preset chips render above the prompt in the empty state (fixed layout)
41
+ and inline after the assistant reply. Click a chip to send its text;
42
+ used chips hide for the session.
43
+ </p>
44
+ <div className={S.chatDemoHost}>
45
+ <ChatChrome {...chromeProps} />
46
+ </div>
104
47
  </PageContentSection>
105
48
  </>
106
49
  );
@@ -18,9 +18,9 @@ const NO_QUICK_REPLY_KEYS: ReadonlySet<string> = new Set();
18
18
  /** Sample items — default TipTap mention insert; optional `className` / `color` style the chip. */
19
19
  const DOCS_SLASH_ITEMS: SlashCommandItem[] = [
20
20
  {
21
- id: 'generate-dashboard',
22
- label: 'Generate dashboard',
23
- description: 'Insert /generate-dashboard',
21
+ id: 'generate-report',
22
+ label: 'Generate report',
23
+ description: 'Insert /generate-report',
24
24
  color: 'var(--brand-color-600)',
25
25
  },
26
26
  {
@@ -48,7 +48,7 @@ function makeMessage(role: MessageRole, text: string): Message {
48
48
  }
49
49
 
50
50
  const ASSISTANT_REPLY_TEXT =
51
- 'Demo reply. Slash picks insert inline mention chips; plain text on send uses each item id (e.g. /generate-dashboard).';
51
+ 'Demo reply. Slash picks insert inline mention chips; plain text on send uses each item id (e.g. /generate-report).';
52
52
 
53
53
  export default function ChatSlashCommandsPage() {
54
54
  const [messages, setMessages] = useState<Message[]>([]);