@clubmed/usg-chat-ui 1.2.7 → 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.
Files changed (60) hide show
  1. package/README.md +36 -0
  2. package/assets/style.css +1 -1
  3. package/chunks/react.esm.js +2012 -1997
  4. package/chunks/react.esm.js.map +1 -1
  5. package/chunks/vi.2VT5v0um.js +1 -0
  6. package/config/chatLabels.d.ts +43 -0
  7. package/config/chatLabels.js +2 -0
  8. package/config/chatLabels.js.map +1 -0
  9. package/contexts/ChatLabelsContext.d.ts +13 -0
  10. package/contexts/ChatLabelsContext.js +24 -0
  11. package/contexts/ChatLabelsContext.js.map +1 -0
  12. package/contexts/ChatLabelsContext.test.d.ts +1 -0
  13. package/contexts/ChatLabelsContext.test.js +23 -0
  14. package/contexts/ChatLabelsContext.test.js.map +1 -0
  15. package/molecules/AiElements/Branch.js +45 -44
  16. package/molecules/AiElements/Branch.js.map +1 -1
  17. package/molecules/AiElements/PromptInput.js +60 -58
  18. package/molecules/AiElements/PromptInput.js.map +1 -1
  19. package/molecules/RichText/useCollaboration.test.js +1 -1
  20. package/organisms/canvas/CanvasLayout.d.ts +2 -1
  21. package/organisms/canvas/CanvasLayout.js +1249 -1248
  22. package/organisms/canvas/CanvasLayout.js.map +1 -1
  23. package/organisms/chat/Chat.d.ts +7 -1
  24. package/organisms/chat/Chat.js +67 -67
  25. package/organisms/chat/Chat.js.map +1 -1
  26. package/organisms/chat/ChatHeader.d.ts +4 -4
  27. package/organisms/chat/ChatHeader.js +41 -39
  28. package/organisms/chat/ChatHeader.js.map +1 -1
  29. package/organisms/chat/ChatHeader.test.d.ts +1 -0
  30. package/organisms/chat/ChatHeader.test.js +18 -0
  31. package/organisms/chat/ChatHeader.test.js.map +1 -0
  32. package/organisms/chat/ChatMessageList.d.ts +1 -2
  33. package/organisms/chat/ChatMessageList.js +73 -58
  34. package/organisms/chat/ChatMessageList.js.map +1 -1
  35. package/organisms/chat/ChatMessageList.test.d.ts +1 -0
  36. package/organisms/chat/ChatMessageList.test.js +67 -0
  37. package/organisms/chat/ChatMessageList.test.js.map +1 -0
  38. package/organisms/chat/ChatSettingsButton.d.ts +2 -0
  39. package/organisms/chat/ChatSettingsButton.js +24 -0
  40. package/organisms/chat/ChatSettingsButton.js.map +1 -0
  41. package/organisms/chat/ChatSettingsButton.test.d.ts +1 -0
  42. package/organisms/chat/ChatSettingsButton.test.js +16 -0
  43. package/organisms/chat/ChatSettingsButton.test.js.map +1 -0
  44. package/organisms/chat/ConversationSidebar.js +44 -43
  45. package/organisms/chat/ConversationSidebar.js.map +1 -1
  46. package/organisms/chat/MessageActions.js +104 -103
  47. package/organisms/chat/MessageActions.js.map +1 -1
  48. package/organisms/chat/MessageRenderers.js +1 -1
  49. package/organisms/chat/SidebarToggleButton.js +9 -7
  50. package/organisms/chat/SidebarToggleButton.js.map +1 -1
  51. package/organisms/chat/hooks/useChat.d.ts +1 -1
  52. package/organisms/chat/hooks/useChat.js +83 -83
  53. package/organisms/chat/hooks/useChat.js.map +1 -1
  54. package/package.json +1 -1
  55. package/utils/interpolate.d.ts +5 -0
  56. package/utils/interpolate.js +13 -0
  57. package/utils/interpolate.js.map +1 -0
  58. package/utils/interpolate.test.d.ts +1 -0
  59. package/utils/interpolate.test.js +21 -0
  60. 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.