@clubmed/usg-chat-ui 1.2.6 → 1.3.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 +36 -0
- package/assets/style.css +1 -1
- package/chunks/react.esm.js +2012 -1997
- package/chunks/react.esm.js.map +1 -1
- package/chunks/vi.2VT5v0um.js +1 -0
- package/config/chatLabels.d.ts +43 -0
- package/config/chatLabels.js +2 -0
- package/config/chatLabels.js.map +1 -0
- package/contexts/ChatLabelsContext.d.ts +13 -0
- package/contexts/ChatLabelsContext.js +24 -0
- package/contexts/ChatLabelsContext.js.map +1 -0
- package/contexts/ChatLabelsContext.test.d.ts +1 -0
- package/contexts/ChatLabelsContext.test.js +23 -0
- package/contexts/ChatLabelsContext.test.js.map +1 -0
- package/molecules/AiElements/Branch.js +45 -44
- package/molecules/AiElements/Branch.js.map +1 -1
- package/molecules/AiElements/PromptInput.js +60 -58
- package/molecules/AiElements/PromptInput.js.map +1 -1
- package/molecules/RichText/useCollaboration.test.js +1 -1
- package/organisms/canvas/CanvasLayout.d.ts +2 -1
- package/organisms/canvas/CanvasLayout.js +1249 -1248
- package/organisms/canvas/CanvasLayout.js.map +1 -1
- package/organisms/chat/Chat.d.ts +7 -1
- package/organisms/chat/Chat.js +67 -67
- package/organisms/chat/Chat.js.map +1 -1
- package/organisms/chat/ChatHeader.d.ts +4 -4
- package/organisms/chat/ChatHeader.js +41 -39
- package/organisms/chat/ChatHeader.js.map +1 -1
- package/organisms/chat/ChatHeader.test.d.ts +1 -0
- package/organisms/chat/ChatHeader.test.js +18 -0
- package/organisms/chat/ChatHeader.test.js.map +1 -0
- package/organisms/chat/ChatMessageList.d.ts +1 -2
- package/organisms/chat/ChatMessageList.js +73 -58
- package/organisms/chat/ChatMessageList.js.map +1 -1
- package/organisms/chat/ChatMessageList.test.d.ts +1 -0
- package/organisms/chat/ChatMessageList.test.js +67 -0
- package/organisms/chat/ChatMessageList.test.js.map +1 -0
- package/organisms/chat/ChatSettingsButton.d.ts +2 -0
- package/organisms/chat/ChatSettingsButton.js +24 -0
- package/organisms/chat/ChatSettingsButton.js.map +1 -0
- package/organisms/chat/ChatSettingsButton.test.d.ts +1 -0
- package/organisms/chat/ChatSettingsButton.test.js +16 -0
- package/organisms/chat/ChatSettingsButton.test.js.map +1 -0
- package/organisms/chat/ConversationSidebar.js +44 -43
- package/organisms/chat/ConversationSidebar.js.map +1 -1
- package/organisms/chat/MessageActions.js +104 -103
- package/organisms/chat/MessageActions.js.map +1 -1
- package/organisms/chat/MessageRenderers.js +1 -1
- package/organisms/chat/SidebarToggleButton.js +9 -7
- package/organisms/chat/SidebarToggleButton.js.map +1 -1
- package/organisms/chat/hooks/useChat.d.ts +1 -1
- package/organisms/chat/hooks/useChat.js +83 -83
- package/organisms/chat/hooks/useChat.js.map +1 -1
- package/package.json +1 -1
- package/utils/interpolate.d.ts +5 -0
- package/utils/interpolate.js +13 -0
- package/utils/interpolate.js.map +1 -0
- package/utils/interpolate.test.d.ts +1 -0
- package/utils/interpolate.test.js +21 -0
- package/utils/interpolate.test.js.map +1 -0
package/README.md
CHANGED
|
@@ -63,6 +63,42 @@ export function ChatPanel() {
|
|
|
63
63
|
|
|
64
64
|
If you need to customize HTTP transport or headers, provide a `fetcher` override or extend the HTTP client directly—`ChatProvider` keeps the config surface minimal (`apiUrl`, `fetcher`, `accessToken`, `user`).
|
|
65
65
|
|
|
66
|
+
## Labels & Accessibility
|
|
67
|
+
|
|
68
|
+
The chat UI exposes a `labels` prop on `<Chat />` so hosts can override empty‑state copy, greeting templates, and every aria-label used throughout the experience without editing component logic.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<Chat
|
|
72
|
+
labels={{
|
|
73
|
+
greetingTemplate: "Hola {{firstName}} 👋",
|
|
74
|
+
emptyStateTitle: "¡Bienvenido a tu copiloto!",
|
|
75
|
+
chatSettingsButtonAriaLabel: "Preferencias",
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Under the hood, the `ChatLabelsProvider` and `useChatLabels()` hook distribute these strings to all molecules. The hook exposes two helpers:
|
|
81
|
+
|
|
82
|
+
- `get(key, fallback)` → returns a plain string, falling back to the provided default when the host didn’t override it.
|
|
83
|
+
- `p(key, fallback, values)` → interpolates templates (e.g. `{{firstName}}`) and trims whitespace. Returns `undefined` when the final string is empty.
|
|
84
|
+
|
|
85
|
+
### Available label keys
|
|
86
|
+
|
|
87
|
+
| Key | Purpose / Example |
|
|
88
|
+
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
|
|
89
|
+
| `greetingTemplate` | Template for the empty-state greeting (`"Bonjour {{firstName}} 👋"`). |
|
|
90
|
+
| `emptyStateTitle` / `emptyStateDescription` | Marketing copy for the empty state. |
|
|
91
|
+
| `assistantThinkingIndicator` | Pulsing text while the assistant is streaming. |
|
|
92
|
+
| `chatSettingsButtonAriaLabel` | Settings button aria label. |
|
|
93
|
+
| `sidebarOpenHistoryAriaLabel`, `conversationRefreshAriaLabel`, `conversationCloseHistoryAriaLabel` | Sidebar toggle & controls. |
|
|
94
|
+
| `messageCopyAriaLabel`, `messageRegenerateAriaLabel`, `messageOpenCanvasAriaLabel` | Message action buttons. |
|
|
95
|
+
| `messageThumbsUpAriaLabel`, `messageThumbsDownAriaLabel`, `messageCloseFeedbackAriaLabel` | Feedback modal controls. |
|
|
96
|
+
| `canvasReduceAriaLabel`, `canvasExpandAriaLabel`, `canvasCloseAriaLabel` | Canvas panel controls. |
|
|
97
|
+
| `branchPreviousAriaLabel`, `branchNextAriaLabel` | Multi-branch navigation buttons. |
|
|
98
|
+
| `promptSubmitAriaLabel` | Submit icon on the prompt composer. |
|
|
99
|
+
|
|
100
|
+
> **Implementation convention:** All new user-facing strings or aria labels **must** use `useChatLabels()` (`const {get, p} = useChatLabels();`) instead of hard-coded literals. Declare the key inside `ChatLabelsConfig` with a short JSDoc example, then consume it via `get/p` with a sensible fallback so the UI remains resilient when a host doesn’t override that value yet.
|
|
101
|
+
|
|
66
102
|
## Storybook
|
|
67
103
|
|
|
68
104
|
Storybook v10 is configured at the workspace root (`usg-ui/.storybook`). Run `yarn storybook` from `usg-ui/` to browse molecules and verify appearance tokens in isolation. The build output (`storybook-static`) can be published alongside the npm package for visual regression if desired.
|