@liveblocks/react-ui 2.24.0 → 2.25.0-aiprivatebeta0

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 (68) hide show
  1. package/dist/_private/index.cjs +6 -0
  2. package/dist/_private/index.cjs.map +1 -1
  3. package/dist/_private/index.d.cts +166 -10
  4. package/dist/_private/index.d.ts +166 -10
  5. package/dist/_private/index.js +3 -0
  6. package/dist/_private/index.js.map +1 -1
  7. package/dist/components/AiChat/AiChat.cjs +200 -0
  8. package/dist/components/AiChat/AiChat.cjs.map +1 -0
  9. package/dist/components/AiChat/AiChat.js +198 -0
  10. package/dist/components/AiChat/AiChat.js.map +1 -0
  11. package/dist/components/internal/AiChatAssistantMessage.cjs +353 -0
  12. package/dist/components/internal/AiChatAssistantMessage.cjs.map +1 -0
  13. package/dist/components/internal/AiChatAssistantMessage.js +351 -0
  14. package/dist/components/internal/AiChatAssistantMessage.js.map +1 -0
  15. package/dist/components/internal/AiChatComposer.cjs +385 -0
  16. package/dist/components/internal/AiChatComposer.cjs.map +1 -0
  17. package/dist/components/internal/AiChatComposer.js +379 -0
  18. package/dist/components/internal/AiChatComposer.js.map +1 -0
  19. package/dist/components/internal/AiChatUserMessage.cjs +187 -0
  20. package/dist/components/internal/AiChatUserMessage.cjs.map +1 -0
  21. package/dist/components/internal/AiChatUserMessage.js +185 -0
  22. package/dist/components/internal/AiChatUserMessage.js.map +1 -0
  23. package/dist/icons/Copy.cjs +26 -0
  24. package/dist/icons/Copy.cjs.map +1 -0
  25. package/dist/icons/Copy.js +24 -0
  26. package/dist/icons/Copy.js.map +1 -0
  27. package/dist/index.cjs +2 -0
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +65 -4
  30. package/dist/index.d.ts +65 -4
  31. package/dist/index.js +1 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/overrides.cjs +13 -1
  34. package/dist/overrides.cjs.map +1 -1
  35. package/dist/overrides.js +13 -1
  36. package/dist/overrides.js.map +1 -1
  37. package/dist/primitives/Chat/Composer/index.cjs +323 -0
  38. package/dist/primitives/Chat/Composer/index.cjs.map +1 -0
  39. package/dist/primitives/Chat/Composer/index.js +315 -0
  40. package/dist/primitives/Chat/Composer/index.js.map +1 -0
  41. package/dist/primitives/index.cjs +9 -4
  42. package/dist/primitives/index.cjs.map +1 -1
  43. package/dist/primitives/index.d.cts +108 -2
  44. package/dist/primitives/index.d.ts +108 -2
  45. package/dist/primitives/index.js +1 -0
  46. package/dist/primitives/index.js.map +1 -1
  47. package/dist/primitives/internal/Collapsible.cjs +99 -0
  48. package/dist/primitives/internal/Collapsible.cjs.map +1 -0
  49. package/dist/primitives/internal/Collapsible.js +95 -0
  50. package/dist/primitives/internal/Collapsible.js.map +1 -0
  51. package/dist/primitives/internal/Markdown.cjs +444 -0
  52. package/dist/primitives/internal/Markdown.cjs.map +1 -0
  53. package/dist/primitives/internal/Markdown.js +440 -0
  54. package/dist/primitives/internal/Markdown.js.map +1 -0
  55. package/dist/version.cjs +1 -1
  56. package/dist/version.cjs.map +1 -1
  57. package/dist/version.js +1 -1
  58. package/dist/version.js.map +1 -1
  59. package/package.json +5 -5
  60. package/src/styles/constants.css +4 -0
  61. package/src/styles/dark/index.css +1 -0
  62. package/src/styles/index.css +510 -0
  63. package/styles/dark/attributes.css +1 -1
  64. package/styles/dark/attributes.css.map +1 -1
  65. package/styles/dark/media-query.css +1 -1
  66. package/styles/dark/media-query.css.map +1 -1
  67. package/styles.css +1 -1
  68. package/styles.css.map +1 -1
@@ -0,0 +1,185 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { memo, forwardRef, useState } from 'react';
3
+ import '../../icons/index.js';
4
+ import { useOverrides } from '../../overrides.js';
5
+ import { classNames } from '../../utils/class-names.js';
6
+ import { formatFileSize } from '../../utils/format-file-size.js';
7
+ import { useChatAttachmentUrl, splitFileName, MAX_DISPLAYED_MEDIA_SIZE } from './AiChatComposer.js';
8
+ import { SpinnerIcon } from '../../icons/Spinner.js';
9
+
10
+ const AiChatUserMessage = memo(
11
+ forwardRef(
12
+ ({ message, className }, forwardedRef) => {
13
+ const text = message.content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
14
+ const images = message.content.filter((c) => c.type === "image");
15
+ if (message.deletedAt !== void 0) {
16
+ return /* @__PURE__ */ jsx("div", {
17
+ ref: forwardedRef,
18
+ className: classNames("lb-ai-chat-user-message", className),
19
+ children: /* @__PURE__ */ jsx("div", {
20
+ className: "lb-ai-chat-user-message-deleted",
21
+ children: "This message has been deleted."
22
+ })
23
+ });
24
+ }
25
+ return /* @__PURE__ */ jsxs("div", {
26
+ ref: forwardedRef,
27
+ className: classNames("lb-ai-chat-user-message", className),
28
+ children: [
29
+ images.length > 0 && /* @__PURE__ */ jsx("div", {
30
+ className: "lb-ai-chat-user-message-attachments",
31
+ children: /* @__PURE__ */ jsx("div", {
32
+ className: "lb-ai-chat-user-message-media-attachments",
33
+ children: images.map((image) => /* @__PURE__ */ jsx(AiChatUserMessageMediaAttachment, {
34
+ chatId: message.chatId,
35
+ attachment: image,
36
+ className: "lb-ai-chat-user-message-attachment"
37
+ }, image.id))
38
+ })
39
+ }),
40
+ /* @__PURE__ */ jsx("div", {
41
+ className: "lb-ai-chat-user-message-content",
42
+ children: /* @__PURE__ */ jsx("div", {
43
+ className: "lb-ai-chat-user-message-body",
44
+ children: text
45
+ })
46
+ })
47
+ ]
48
+ });
49
+ }
50
+ )
51
+ );
52
+ function AiChatUserMessageMediaAttachment({
53
+ className,
54
+ chatId,
55
+ attachment,
56
+ overrides,
57
+ onClick,
58
+ onKeyDown,
59
+ ...props
60
+ }) {
61
+ if (!attachment.mimeType.startsWith("image/")) {
62
+ throw new Error("Only image attachments are supported.");
63
+ }
64
+ const { url } = useChatAttachmentUrl(chatId, attachment.id);
65
+ const { base, extension } = splitFileName(attachment.name);
66
+ const $ = useOverrides(overrides);
67
+ const description = formatFileSize(attachment.size, $.locale);
68
+ return /* @__PURE__ */ jsxs("div", {
69
+ className: classNames(
70
+ "lb-ai-chat-user-message-attachment lb-attachment lb-media-attachment",
71
+ className
72
+ ),
73
+ role: url !== void 0 ? "button" : void 0,
74
+ tabIndex: url !== void 0 ? 0 : -1,
75
+ onKeyDown: (event) => {
76
+ onKeyDown?.(event);
77
+ if (event.isDefaultPrevented())
78
+ return;
79
+ if (url === void 0)
80
+ return;
81
+ if (event.key === "Enter" || event.key === " ") {
82
+ window.open(url, "_blank");
83
+ }
84
+ },
85
+ ...props,
86
+ onClick: (event) => {
87
+ onClick?.(event);
88
+ if (event.isDefaultPrevented())
89
+ return;
90
+ if (url === void 0)
91
+ return;
92
+ window.open(url, "_blank");
93
+ },
94
+ children: [
95
+ /* @__PURE__ */ jsx(AttachmentPreview, {
96
+ attachment,
97
+ url
98
+ }),
99
+ /* @__PURE__ */ jsxs("div", {
100
+ className: "lb-attachment-details",
101
+ children: [
102
+ /* @__PURE__ */ jsxs("span", {
103
+ className: "lb-attachment-name",
104
+ title: attachment.name,
105
+ children: [
106
+ /* @__PURE__ */ jsx("span", {
107
+ className: "lb-attachment-name-base",
108
+ children: base
109
+ }),
110
+ extension && /* @__PURE__ */ jsx("span", {
111
+ className: "lb-attachment-name-extension",
112
+ children: extension
113
+ })
114
+ ]
115
+ }),
116
+ /* @__PURE__ */ jsx("span", {
117
+ className: "lb-attachment-description",
118
+ title: description,
119
+ children: description
120
+ })
121
+ ]
122
+ })
123
+ ]
124
+ });
125
+ }
126
+ function AttachmentPreview({
127
+ attachment,
128
+ url,
129
+ ...props
130
+ }) {
131
+ const [isUnsupportedPreview, setUnsupportedPreview] = useState(false);
132
+ const [isLoaded, setLoaded] = useState(false);
133
+ if (!isUnsupportedPreview && attachment.size <= MAX_DISPLAYED_MEDIA_SIZE) {
134
+ return /* @__PURE__ */ jsxs("div", {
135
+ className: "lb-attachment-preview",
136
+ ...props,
137
+ children: [
138
+ !isLoaded ? /* @__PURE__ */ jsx(SpinnerIcon, {}) : null,
139
+ url ? /* @__PURE__ */ jsx("div", {
140
+ className: "lb-attachment-preview-media",
141
+ "data-hidden": !isLoaded ? "" : void 0,
142
+ children: /* @__PURE__ */ jsx("img", {
143
+ src: url,
144
+ loading: "lazy",
145
+ onLoad: () => setLoaded(true),
146
+ onError: () => setUnsupportedPreview(true)
147
+ })
148
+ }) : null
149
+ ]
150
+ });
151
+ }
152
+ return /* @__PURE__ */ jsxs("svg", {
153
+ className: "lb-attachment-icon",
154
+ width: 30,
155
+ height: 30,
156
+ viewBox: "0 0 30 30",
157
+ fill: "currentColor",
158
+ fillRule: "evenodd",
159
+ clipRule: "evenodd",
160
+ xmlns: "http://www.w3.org/2000/svg",
161
+ children: [
162
+ /* @__PURE__ */ jsx("path", {
163
+ d: "M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z",
164
+ className: "lb-attachment-icon-shadow"
165
+ }),
166
+ /* @__PURE__ */ jsx("path", {
167
+ d: "M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z",
168
+ className: "lb-attachment-icon-background"
169
+ }),
170
+ /* @__PURE__ */ jsx("path", {
171
+ d: "M14.382 3.037a4 4 0 0 1 2.29 1.135l6.156 6.157a4 4 0 0 1 1.136 2.289A2 2 0 0 0 22 11h-4a2 2 0 0 1-2-2V5a2 2 0 0 0-1.618-1.963Z",
172
+ className: "lb-attachment-icon-fold"
173
+ }),
174
+ /* @__PURE__ */ jsx("g", {
175
+ className: "lb-attachment-icon-glyph",
176
+ children: /* @__PURE__ */ jsx("path", {
177
+ d: "M12 16h6a1 1 0 0 1 1 1v3l-1.293-1.293a1 1 0 0 0-1.414 0L14.09 20.91l-.464-.386a1 1 0 0 0-1.265-.013l-1.231.985A.995.995 0 0 1 11 21v-4a1 1 0 0 1 1-1Zm-2 1a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-4Zm3 2a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
178
+ })
179
+ })
180
+ ]
181
+ });
182
+ }
183
+
184
+ export { AiChatUserMessage };
185
+ //# sourceMappingURL=AiChatUserMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiChatUserMessage.js","sources":["../../../src/components/internal/AiChatUserMessage.tsx"],"sourcesContent":["import type { UiUserMessage } from \"@liveblocks/core\";\nimport type { HTMLAttributes } from \"react\";\nimport { forwardRef, memo, useState } from \"react\";\n\nimport { SpinnerIcon } from \"../../icons\";\nimport type { GlobalOverrides } from \"../../overrides\";\nimport { useOverrides } from \"../../overrides\";\nimport { classNames } from \"../../utils/class-names\";\nimport { formatFileSize } from \"../../utils/format-file-size\";\nimport {\n MAX_DISPLAYED_MEDIA_SIZE,\n splitFileName,\n useChatAttachmentUrl,\n} from \"./AiChatComposer\";\n\n/* -------------------------------------------------------------------------------------------------\n * AiChatUserMessage\n * -----------------------------------------------------------------------------------------------*/\nexport type AiChatUserMessageProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * The message to display.\n */\n message: UiUserMessage;\n /**\n * Override the component's strings.\n */\n overrides?: Partial<GlobalOverrides>;\n};\n\nexport const AiChatUserMessage = memo(\n forwardRef<HTMLDivElement, AiChatUserMessageProps>(\n ({ message, className }, forwardedRef) => {\n const text = message.content\n .filter((c) => c.type === \"text\")\n .map((c) => c.text)\n .join(\"\\n\");\n\n const images = message.content.filter((c) => c.type === \"image\");\n\n if (message.deletedAt !== undefined) {\n return (\n <div\n ref={forwardedRef}\n className={classNames(\"lb-ai-chat-user-message\", className)}\n >\n <div className=\"lb-ai-chat-user-message-deleted\">\n This message has been deleted.\n </div>\n </div>\n );\n }\n\n return (\n <div\n ref={forwardedRef}\n className={classNames(\"lb-ai-chat-user-message\", className)}\n >\n {images.length > 0 && (\n <div className=\"lb-ai-chat-user-message-attachments\">\n <div className=\"lb-ai-chat-user-message-media-attachments\">\n {images.map((image) => (\n <AiChatUserMessageMediaAttachment\n key={image.id}\n chatId={message.chatId}\n attachment={image}\n className=\"lb-ai-chat-user-message-attachment\"\n />\n ))}\n </div>\n </div>\n )}\n\n <div className=\"lb-ai-chat-user-message-content\">\n <div className=\"lb-ai-chat-user-message-body\">{text}</div>\n </div>\n </div>\n );\n }\n )\n);\n\ntype AiChatUserMessageMediaAttachmentProps = HTMLAttributes<HTMLDivElement> & {\n chatId: string;\n attachment: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n };\n overrides?: Partial<GlobalOverrides>;\n};\n\nfunction AiChatUserMessageMediaAttachment({\n className,\n chatId,\n attachment,\n overrides,\n onClick,\n onKeyDown,\n ...props\n}: AiChatUserMessageMediaAttachmentProps) {\n if (!attachment.mimeType.startsWith(\"image/\")) {\n throw new Error(\"Only image attachments are supported.\");\n }\n\n const { url } = useChatAttachmentUrl(chatId, attachment.id);\n\n const { base, extension } = splitFileName(attachment.name);\n const $ = useOverrides(overrides);\n const description = formatFileSize(attachment.size, $.locale);\n\n return (\n <div\n className={classNames(\n \"lb-ai-chat-user-message-attachment lb-attachment lb-media-attachment\",\n className\n )}\n role={url !== undefined ? \"button\" : undefined}\n tabIndex={url !== undefined ? 0 : -1}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.isDefaultPrevented()) return;\n\n if (url === undefined) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n window.open(url, \"_blank\");\n }\n }}\n {...props}\n onClick={(event) => {\n onClick?.(event);\n if (event.isDefaultPrevented()) return;\n\n if (url === undefined) return;\n window.open(url, \"_blank\");\n }}\n >\n <AttachmentPreview attachment={attachment} url={url} />\n\n <div className=\"lb-attachment-details\">\n <span className=\"lb-attachment-name\" title={attachment.name}>\n <span className=\"lb-attachment-name-base\">{base}</span>\n {extension && (\n <span className=\"lb-attachment-name-extension\">{extension}</span>\n )}\n </span>\n\n <span className=\"lb-attachment-description\" title={description}>\n {description}\n </span>\n </div>\n </div>\n );\n}\n\ntype AttachmentPreviewProps = HTMLAttributes<HTMLDivElement> & {\n attachment: { name: string; size: number };\n url: string | undefined;\n};\n\nfunction AttachmentPreview({\n attachment,\n url,\n ...props\n}: AttachmentPreviewProps) {\n const [isUnsupportedPreview, setUnsupportedPreview] = useState(false);\n const [isLoaded, setLoaded] = useState(false);\n\n if (!isUnsupportedPreview && attachment.size <= MAX_DISPLAYED_MEDIA_SIZE) {\n return (\n <div className=\"lb-attachment-preview\" {...props}>\n {!isLoaded ? <SpinnerIcon /> : null}\n\n {url ? (\n <div\n className=\"lb-attachment-preview-media\"\n data-hidden={!isLoaded ? \"\" : undefined}\n >\n <img\n src={url}\n loading=\"lazy\"\n onLoad={() => setLoaded(true)}\n onError={() => setUnsupportedPreview(true)}\n />\n </div>\n ) : null}\n </div>\n );\n }\n\n return (\n <svg\n className=\"lb-attachment-icon\"\n width={30}\n height={30}\n viewBox=\"0 0 30 30\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z\"\n className=\"lb-attachment-icon-shadow\"\n />\n <path\n d=\"M6 5a2 2 0 0 1 2-2h5.843a4 4 0 0 1 2.829 1.172l6.156 6.156A4 4 0 0 1 24 13.157V25a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5Z\"\n className=\"lb-attachment-icon-background\"\n />\n <path\n d=\"M14.382 3.037a4 4 0 0 1 2.29 1.135l6.156 6.157a4 4 0 0 1 1.136 2.289A2 2 0 0 0 22 11h-4a2 2 0 0 1-2-2V5a2 2 0 0 0-1.618-1.963Z\"\n className=\"lb-attachment-icon-fold\"\n />\n\n <g className=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,SAAU,EAAA,0BAAA;AAAA,QACX,QAAC,kBAAA,GAAA,CAAA,MAAA,EAAA;AAAA,UAAK,CAAE,EAAA,gQAAA;AAAA,SAAiQ,CAAA;AAAA,OAC3Q,CAAA;AAAA,KAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Icon = require('../components/internal/Icon.cjs');
5
+
6
+ function CopyIcon(props) {
7
+ return /* @__PURE__ */ jsxRuntime.jsxs(Icon.Icon, {
8
+ ...props,
9
+ children: [
10
+ /* @__PURE__ */ jsxRuntime.jsx("rect", {
11
+ x: "7.33",
12
+ y: "7.33",
13
+ width: "9.48",
14
+ height: "9.48",
15
+ rx: "1.38",
16
+ ry: "1.38"
17
+ }),
18
+ /* @__PURE__ */ jsxRuntime.jsx("path", {
19
+ d: "M4.57 12.67 c-0.73 0 -1.38 -0.65 -1.38 -1.38 V4.57 c0 -0.73 0.65 -1.38 1.38 -1.38 h6.72 c0.73 0 1.38 0.65 1.38 1.38"
20
+ })
21
+ ]
22
+ });
23
+ }
24
+
25
+ exports.CopyIcon = CopyIcon;
26
+ //# sourceMappingURL=Copy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Copy.cjs","sources":["../../src/icons/Copy.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\n\nimport { Icon } from \"../components/internal/Icon\";\n\nexport function CopyIcon(props: ComponentProps<\"svg\">) {\n return (\n <Icon {...props}>\n <rect x=\"7.33\" y=\"7.33\" width=\"9.48\" height=\"9.48\" rx=\"1.38\" ry=\"1.38\" />\n <path d=\"M4.57 12.67 c-0.73 0 -1.38 -0.65 -1.38 -1.38 V4.57 c0 -0.73 0.65 -1.38 1.38 -1.38 h6.72 c0.73 0 1.38 0.65 1.38 1.38\" />\n </Icon>\n );\n}\n"],"names":["jsxs","Icon","jsx"],"mappings":";;;;;AAIO,SAAS,SAAS,KAA8B,EAAA;AACrD,EAAA,uBACGA,eAAA,CAAAC,SAAA,EAAA;AAAA,IAAM,GAAG,KAAA;AAAA,IACR,QAAA,EAAA;AAAA,sBAACC,cAAA,CAAA,MAAA,EAAA;AAAA,QAAK,CAAE,EAAA,MAAA;AAAA,QAAO,CAAE,EAAA,MAAA;AAAA,QAAO,KAAM,EAAA,MAAA;AAAA,QAAO,MAAO,EAAA,MAAA;AAAA,QAAO,EAAG,EAAA,MAAA;AAAA,QAAO,EAAG,EAAA,MAAA;AAAA,OAAO,CAAA;AAAA,sBACtEA,cAAA,CAAA,MAAA,EAAA;AAAA,QAAK,CAAE,EAAA,qHAAA;AAAA,OAAsH,CAAA;AAAA,KAAA;AAAA,GAChI,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,24 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Icon } from '../components/internal/Icon.js';
3
+
4
+ function CopyIcon(props) {
5
+ return /* @__PURE__ */ jsxs(Icon, {
6
+ ...props,
7
+ children: [
8
+ /* @__PURE__ */ jsx("rect", {
9
+ x: "7.33",
10
+ y: "7.33",
11
+ width: "9.48",
12
+ height: "9.48",
13
+ rx: "1.38",
14
+ ry: "1.38"
15
+ }),
16
+ /* @__PURE__ */ jsx("path", {
17
+ d: "M4.57 12.67 c-0.73 0 -1.38 -0.65 -1.38 -1.38 V4.57 c0 -0.73 0.65 -1.38 1.38 -1.38 h6.72 c0.73 0 1.38 0.65 1.38 1.38"
18
+ })
19
+ ]
20
+ });
21
+ }
22
+
23
+ export { CopyIcon };
24
+ //# sourceMappingURL=Copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Copy.js","sources":["../../src/icons/Copy.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\n\nimport { Icon } from \"../components/internal/Icon\";\n\nexport function CopyIcon(props: ComponentProps<\"svg\">) {\n return (\n <Icon {...props}>\n <rect x=\"7.33\" y=\"7.33\" width=\"9.48\" height=\"9.48\" rx=\"1.38\" ry=\"1.38\" />\n <path d=\"M4.57 12.67 c-0.73 0 -1.38 -0.65 -1.38 -1.38 V4.57 c0 -0.73 0.65 -1.38 1.38 -1.38 h6.72 c0.73 0 1.38 0.65 1.38 1.38\" />\n </Icon>\n );\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,SAAS,KAA8B,EAAA;AACrD,EAAA,uBACG,IAAA,CAAA,IAAA,EAAA;AAAA,IAAM,GAAG,KAAA;AAAA,IACR,QAAA,EAAA;AAAA,sBAAC,GAAA,CAAA,MAAA,EAAA;AAAA,QAAK,CAAE,EAAA,MAAA;AAAA,QAAO,CAAE,EAAA,MAAA;AAAA,QAAO,KAAM,EAAA,MAAA;AAAA,QAAO,MAAO,EAAA,MAAA;AAAA,QAAO,EAAG,EAAA,MAAA;AAAA,QAAO,EAAG,EAAA,MAAA;AAAA,OAAO,CAAA;AAAA,sBACtE,GAAA,CAAA,MAAA,EAAA;AAAA,QAAK,CAAE,EAAA,qHAAA;AAAA,OAAsH,CAAA;AAAA,KAAA;AAAA,GAChI,CAAA,CAAA;AAEJ;;;;"}
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  var core = require('@liveblocks/core');
4
4
  var version = require('./version.cjs');
5
+ var AiChat = require('./components/AiChat/AiChat.cjs');
5
6
  var Comment = require('./components/Comment.cjs');
6
7
  var Composer = require('./components/Composer.cjs');
7
8
  var HistoryVersionSummary = require('./components/HistoryVersionSummary.cjs');
@@ -15,6 +16,7 @@ var overrides = require('./overrides.cjs');
15
16
 
16
17
  core.detectDupes(version.PKG_NAME, version.PKG_VERSION, version.PKG_FORMAT);
17
18
 
19
+ exports.AiChat = AiChat.AiChat;
18
20
  exports.Comment = Comment.Comment;
19
21
  exports.Composer = Composer.Composer;
20
22
  exports.HistoryVersionSummary = HistoryVersionSummary.HistoryVersionSummary;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { CommentProps } from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type { HistoryVersionSummaryProps } from \"./components/HistoryVersionSummary\";\nexport { HistoryVersionSummary } from \"./components/HistoryVersionSummary\";\nexport type { HistoryVersionSummaryListProps } from \"./components/HistoryVersionSummaryList\";\nexport { HistoryVersionSummaryList } from \"./components/HistoryVersionSummaryList\";\nexport type {\n InboxNotificationAvatarProps,\n InboxNotificationCustomKindProps,\n InboxNotificationCustomProps,\n InboxNotificationIconProps,\n InboxNotificationProps,\n InboxNotificationTextMentionKindProps,\n InboxNotificationTextMentionProps,\n InboxNotificationThreadKindProps,\n InboxNotificationThreadProps,\n} from \"./components/InboxNotification\";\nexport { InboxNotification } from \"./components/InboxNotification\";\nexport type { InboxNotificationListProps } from \"./components/InboxNotificationList\";\nexport { InboxNotificationList } from \"./components/InboxNotificationList\";\nexport type { ThreadProps } from \"./components/Thread\";\nexport { Thread } from \"./components/Thread\";\nexport { LiveblocksUIConfig } from \"./config\";\nexport * as Icon from \"./icon\";\nexport type {\n CommentOverrides,\n ComposerOverrides,\n GlobalOverrides,\n InboxNotificationOverrides,\n LocalizationOverrides,\n Overrides,\n ThreadOverrides,\n} from \"./overrides\";\nexport { useOverrides } from \"./overrides\";\nexport type { ComposerSubmitComment } from \"./primitives\";\nexport type {\n CommentAttachmentArgs,\n ComposerBodyMark,\n ComposerBodyMarks,\n} from \"./types\";\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;;;;;;AAIAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport { AiChat, type AiChatProps } from \"./components/AiChat/AiChat\";\nexport type { CommentProps } from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type { HistoryVersionSummaryProps } from \"./components/HistoryVersionSummary\";\nexport { HistoryVersionSummary } from \"./components/HistoryVersionSummary\";\nexport type { HistoryVersionSummaryListProps } from \"./components/HistoryVersionSummaryList\";\nexport { HistoryVersionSummaryList } from \"./components/HistoryVersionSummaryList\";\nexport type {\n InboxNotificationAvatarProps,\n InboxNotificationCustomKindProps,\n InboxNotificationCustomProps,\n InboxNotificationIconProps,\n InboxNotificationProps,\n InboxNotificationTextMentionKindProps,\n InboxNotificationTextMentionProps,\n InboxNotificationThreadKindProps,\n InboxNotificationThreadProps,\n} from \"./components/InboxNotification\";\nexport { InboxNotification } from \"./components/InboxNotification\";\nexport type { InboxNotificationListProps } from \"./components/InboxNotificationList\";\nexport { InboxNotificationList } from \"./components/InboxNotificationList\";\nexport type { ThreadProps } from \"./components/Thread\";\nexport { Thread } from \"./components/Thread\";\nexport { LiveblocksUIConfig } from \"./config\";\nexport * as Icon from \"./icon\";\nexport type {\n ChatComposerOverrides,\n CommentOverrides,\n ComposerOverrides,\n GlobalOverrides,\n InboxNotificationOverrides,\n LocalizationOverrides,\n Overrides,\n ThreadOverrides,\n} from \"./overrides\";\nexport { useOverrides } from \"./overrides\";\nexport type { ComposerSubmitComment } from \"./primitives\";\nexport type {\n CommentAttachmentArgs,\n ComposerBodyMark,\n ComposerBodyMarks,\n} from \"./types\";\n"],"names":["detectDupes","PKG_NAME","PKG_VERSION","PKG_FORMAT"],"mappings":";;;;;;;;;;;;;;;;AAIAA,gBAAY,CAAAC,gBAAA,EAAUC,qBAAaC,kBAAU,CAAA;;;;;;;;;;;;;;"}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { ElementType, ComponentPropsWithoutRef, ReactNode, FormEvent, ComponentType, RefAttributes, MouseEvent, ComponentProps, PropsWithChildren } from 'react';
3
- import { CommentAttachment, CommentBody, BaseMetadata, DM, CommentData, HistoryVersion, InboxNotificationData, InboxNotificationThreadData, InboxNotificationTextMentionData, InboxNotificationCustomData, KDAD, ThreadData } from '@liveblocks/core';
2
+ import { ElementType, ComponentPropsWithoutRef, ReactNode, HTMLAttributes, FormEvent, ComponentType, RefAttributes, MouseEvent, ComponentProps, PropsWithChildren } from 'react';
3
+ import { CommentAttachment, CopilotId, AiChatContext, ClientToolDefinition, CommentBody, BaseMetadata, DM, CommentData, HistoryVersion, InboxNotificationData, InboxNotificationThreadData, InboxNotificationTextMentionData, InboxNotificationCustomData, KDAD, ThreadData } from '@liveblocks/core';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
 
6
6
  type Direction = "ltr" | "rtl";
@@ -73,6 +73,22 @@ interface ComposerOverrides {
73
73
  COMPOSER_SEND: string;
74
74
  COMPOSER_TOGGLE_MARK: (mark: ComposerBodyMark) => string;
75
75
  }
76
+ interface ChatComposerOverrides {
77
+ CHAT_COMPOSER_PLACEHOLDER: string;
78
+ CHAT_COMPOSER_SEND: string;
79
+ CHAT_COMPOSER_ATTACH_FILES: string;
80
+ CHAT_COMPOSER_REMOVE_ATTACHMENT: string;
81
+ CHAT_COMPOSER_ABORT: string;
82
+ }
83
+ interface ChatMessageOverrides {
84
+ CHAT_MESSAGE_DELETED: string;
85
+ CHAT_MESSAGE_THINKING: string;
86
+ CHAT_MESSAGE_COPY: string;
87
+ CHAT_MESSAGE_TRY_AGAIN: string;
88
+ }
89
+ interface ChatOverrides {
90
+ GET_CHAT_MESSAGES_ERROR: (error: Error) => ReactNode;
91
+ }
76
92
  interface ThreadOverrides {
77
93
  THREAD_RESOLVE: string;
78
94
  THREAD_UNRESOLVE: string;
@@ -97,9 +113,54 @@ interface HistoryVersionPreviewOverrides {
97
113
  HISTORY_VERSION_PREVIEW_EMPTY: ReactNode;
98
114
  HISTORY_VERSION_PREVIEW_ERROR: (error: Error) => ReactNode;
99
115
  }
100
- type Overrides = LocalizationOverrides & GlobalOverrides & ComposerOverrides & CommentOverrides & ThreadOverrides & InboxNotificationOverrides & HistoryVersionPreviewOverrides;
116
+ type Overrides = LocalizationOverrides & GlobalOverrides & ComposerOverrides & CommentOverrides & ThreadOverrides & InboxNotificationOverrides & HistoryVersionPreviewOverrides & ChatComposerOverrides & ChatMessageOverrides & ChatOverrides;
101
117
  declare function useOverrides(overrides?: Partial<Overrides>): Overrides;
102
118
 
119
+ type AiChatProps = HTMLAttributes<HTMLDivElement> & {
120
+ /**
121
+ * The id of the chat the composer belongs to.
122
+ */
123
+ chatId: string;
124
+ /**
125
+ * The id of the copilot to use to send the message.
126
+ */
127
+ copilotId?: CopilotId;
128
+ /**
129
+ * The contextual information to include in the chat. Used by the assistant when generating responses.
130
+ */
131
+ contexts?: AiChatContext[];
132
+ /**
133
+ * The contextual information to include in the chat. Used by the assistant when generating responses.
134
+ */
135
+ tools?: Record<string, ClientToolDefinition>;
136
+ /**
137
+ * Override the component's strings.
138
+ */
139
+ overrides?: Partial<GlobalOverrides & ChatMessageOverrides & ChatComposerOverrides & ChatOverrides>;
140
+ };
141
+ declare const AiChat: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
142
+ /**
143
+ * The id of the chat the composer belongs to.
144
+ */
145
+ chatId: string;
146
+ /**
147
+ * The id of the copilot to use to send the message.
148
+ */
149
+ copilotId?: CopilotId;
150
+ /**
151
+ * The contextual information to include in the chat. Used by the assistant when generating responses.
152
+ */
153
+ contexts?: AiChatContext[];
154
+ /**
155
+ * The contextual information to include in the chat. Used by the assistant when generating responses.
156
+ */
157
+ tools?: Record<string, ClientToolDefinition>;
158
+ /**
159
+ * Override the component's strings.
160
+ */
161
+ overrides?: Partial<GlobalOverrides & ChatMessageOverrides & ChatComposerOverrides & ChatOverrides>;
162
+ } & react.RefAttributes<HTMLDivElement>>;
163
+
103
164
  interface ComposerEditorMentionProps {
104
165
  /**
105
166
  * Whether the mention is selected.
@@ -812,4 +873,4 @@ declare namespace icon {
812
873
  };
813
874
  }
814
875
 
815
- export { Comment, CommentAttachmentArgs, CommentOverrides, CommentProps, Composer, ComposerBodyMark, ComposerBodyMarks, ComposerOverrides, ComposerProps, ComposerSubmitComment, GlobalOverrides, HistoryVersionSummary, HistoryVersionSummaryList, HistoryVersionSummaryListProps, HistoryVersionSummaryProps, icon as Icon, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationOverrides, InboxNotificationProps, InboxNotificationTextMentionKindProps, InboxNotificationTextMentionProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUIConfig, LocalizationOverrides, Overrides, Thread, ThreadOverrides, ThreadProps, useOverrides };
876
+ export { AiChat, AiChatProps, ChatComposerOverrides, Comment, CommentAttachmentArgs, CommentOverrides, CommentProps, Composer, ComposerBodyMark, ComposerBodyMarks, ComposerOverrides, ComposerProps, ComposerSubmitComment, GlobalOverrides, HistoryVersionSummary, HistoryVersionSummaryList, HistoryVersionSummaryListProps, HistoryVersionSummaryProps, icon as Icon, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationOverrides, InboxNotificationProps, InboxNotificationTextMentionKindProps, InboxNotificationTextMentionProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUIConfig, LocalizationOverrides, Overrides, Thread, ThreadOverrides, ThreadProps, useOverrides };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { ElementType, ComponentPropsWithoutRef, ReactNode, FormEvent, ComponentType, RefAttributes, MouseEvent, ComponentProps, PropsWithChildren } from 'react';
3
- import { CommentAttachment, CommentBody, BaseMetadata, DM, CommentData, HistoryVersion, InboxNotificationData, InboxNotificationThreadData, InboxNotificationTextMentionData, InboxNotificationCustomData, KDAD, ThreadData } from '@liveblocks/core';
2
+ import { ElementType, ComponentPropsWithoutRef, ReactNode, HTMLAttributes, FormEvent, ComponentType, RefAttributes, MouseEvent, ComponentProps, PropsWithChildren } from 'react';
3
+ import { CommentAttachment, CopilotId, AiChatContext, ClientToolDefinition, CommentBody, BaseMetadata, DM, CommentData, HistoryVersion, InboxNotificationData, InboxNotificationThreadData, InboxNotificationTextMentionData, InboxNotificationCustomData, KDAD, ThreadData } from '@liveblocks/core';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
 
6
6
  type Direction = "ltr" | "rtl";
@@ -73,6 +73,22 @@ interface ComposerOverrides {
73
73
  COMPOSER_SEND: string;
74
74
  COMPOSER_TOGGLE_MARK: (mark: ComposerBodyMark) => string;
75
75
  }
76
+ interface ChatComposerOverrides {
77
+ CHAT_COMPOSER_PLACEHOLDER: string;
78
+ CHAT_COMPOSER_SEND: string;
79
+ CHAT_COMPOSER_ATTACH_FILES: string;
80
+ CHAT_COMPOSER_REMOVE_ATTACHMENT: string;
81
+ CHAT_COMPOSER_ABORT: string;
82
+ }
83
+ interface ChatMessageOverrides {
84
+ CHAT_MESSAGE_DELETED: string;
85
+ CHAT_MESSAGE_THINKING: string;
86
+ CHAT_MESSAGE_COPY: string;
87
+ CHAT_MESSAGE_TRY_AGAIN: string;
88
+ }
89
+ interface ChatOverrides {
90
+ GET_CHAT_MESSAGES_ERROR: (error: Error) => ReactNode;
91
+ }
76
92
  interface ThreadOverrides {
77
93
  THREAD_RESOLVE: string;
78
94
  THREAD_UNRESOLVE: string;
@@ -97,9 +113,54 @@ interface HistoryVersionPreviewOverrides {
97
113
  HISTORY_VERSION_PREVIEW_EMPTY: ReactNode;
98
114
  HISTORY_VERSION_PREVIEW_ERROR: (error: Error) => ReactNode;
99
115
  }
100
- type Overrides = LocalizationOverrides & GlobalOverrides & ComposerOverrides & CommentOverrides & ThreadOverrides & InboxNotificationOverrides & HistoryVersionPreviewOverrides;
116
+ type Overrides = LocalizationOverrides & GlobalOverrides & ComposerOverrides & CommentOverrides & ThreadOverrides & InboxNotificationOverrides & HistoryVersionPreviewOverrides & ChatComposerOverrides & ChatMessageOverrides & ChatOverrides;
101
117
  declare function useOverrides(overrides?: Partial<Overrides>): Overrides;
102
118
 
119
+ type AiChatProps = HTMLAttributes<HTMLDivElement> & {
120
+ /**
121
+ * The id of the chat the composer belongs to.
122
+ */
123
+ chatId: string;
124
+ /**
125
+ * The id of the copilot to use to send the message.
126
+ */
127
+ copilotId?: CopilotId;
128
+ /**
129
+ * The contextual information to include in the chat. Used by the assistant when generating responses.
130
+ */
131
+ contexts?: AiChatContext[];
132
+ /**
133
+ * The contextual information to include in the chat. Used by the assistant when generating responses.
134
+ */
135
+ tools?: Record<string, ClientToolDefinition>;
136
+ /**
137
+ * Override the component's strings.
138
+ */
139
+ overrides?: Partial<GlobalOverrides & ChatMessageOverrides & ChatComposerOverrides & ChatOverrides>;
140
+ };
141
+ declare const AiChat: react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
142
+ /**
143
+ * The id of the chat the composer belongs to.
144
+ */
145
+ chatId: string;
146
+ /**
147
+ * The id of the copilot to use to send the message.
148
+ */
149
+ copilotId?: CopilotId;
150
+ /**
151
+ * The contextual information to include in the chat. Used by the assistant when generating responses.
152
+ */
153
+ contexts?: AiChatContext[];
154
+ /**
155
+ * The contextual information to include in the chat. Used by the assistant when generating responses.
156
+ */
157
+ tools?: Record<string, ClientToolDefinition>;
158
+ /**
159
+ * Override the component's strings.
160
+ */
161
+ overrides?: Partial<GlobalOverrides & ChatMessageOverrides & ChatComposerOverrides & ChatOverrides>;
162
+ } & react.RefAttributes<HTMLDivElement>>;
163
+
103
164
  interface ComposerEditorMentionProps {
104
165
  /**
105
166
  * Whether the mention is selected.
@@ -812,4 +873,4 @@ declare namespace icon {
812
873
  };
813
874
  }
814
875
 
815
- export { Comment, CommentAttachmentArgs, CommentOverrides, CommentProps, Composer, ComposerBodyMark, ComposerBodyMarks, ComposerOverrides, ComposerProps, ComposerSubmitComment, GlobalOverrides, HistoryVersionSummary, HistoryVersionSummaryList, HistoryVersionSummaryListProps, HistoryVersionSummaryProps, icon as Icon, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationOverrides, InboxNotificationProps, InboxNotificationTextMentionKindProps, InboxNotificationTextMentionProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUIConfig, LocalizationOverrides, Overrides, Thread, ThreadOverrides, ThreadProps, useOverrides };
876
+ export { AiChat, AiChatProps, ChatComposerOverrides, Comment, CommentAttachmentArgs, CommentOverrides, CommentProps, Composer, ComposerBodyMark, ComposerBodyMarks, ComposerOverrides, ComposerProps, ComposerSubmitComment, GlobalOverrides, HistoryVersionSummary, HistoryVersionSummaryList, HistoryVersionSummaryListProps, HistoryVersionSummaryProps, icon as Icon, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationOverrides, InboxNotificationProps, InboxNotificationTextMentionKindProps, InboxNotificationTextMentionProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUIConfig, LocalizationOverrides, Overrides, Thread, ThreadOverrides, ThreadProps, useOverrides };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { detectDupes } from '@liveblocks/core';
2
2
  import { PKG_NAME, PKG_VERSION, PKG_FORMAT } from './version.js';
3
+ export { AiChat } from './components/AiChat/AiChat.js';
3
4
  export { Comment } from './components/Comment.js';
4
5
  export { Composer } from './components/Composer.js';
5
6
  export { HistoryVersionSummary } from './components/HistoryVersionSummary.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport type { CommentProps } from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type { HistoryVersionSummaryProps } from \"./components/HistoryVersionSummary\";\nexport { HistoryVersionSummary } from \"./components/HistoryVersionSummary\";\nexport type { HistoryVersionSummaryListProps } from \"./components/HistoryVersionSummaryList\";\nexport { HistoryVersionSummaryList } from \"./components/HistoryVersionSummaryList\";\nexport type {\n InboxNotificationAvatarProps,\n InboxNotificationCustomKindProps,\n InboxNotificationCustomProps,\n InboxNotificationIconProps,\n InboxNotificationProps,\n InboxNotificationTextMentionKindProps,\n InboxNotificationTextMentionProps,\n InboxNotificationThreadKindProps,\n InboxNotificationThreadProps,\n} from \"./components/InboxNotification\";\nexport { InboxNotification } from \"./components/InboxNotification\";\nexport type { InboxNotificationListProps } from \"./components/InboxNotificationList\";\nexport { InboxNotificationList } from \"./components/InboxNotificationList\";\nexport type { ThreadProps } from \"./components/Thread\";\nexport { Thread } from \"./components/Thread\";\nexport { LiveblocksUIConfig } from \"./config\";\nexport * as Icon from \"./icon\";\nexport type {\n CommentOverrides,\n ComposerOverrides,\n GlobalOverrides,\n InboxNotificationOverrides,\n LocalizationOverrides,\n Overrides,\n ThreadOverrides,\n} from \"./overrides\";\nexport { useOverrides } from \"./overrides\";\nexport type { ComposerSubmitComment } from \"./primitives\";\nexport type {\n CommentAttachmentArgs,\n ComposerBodyMark,\n ComposerBodyMarks,\n} from \"./types\";\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\n\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport { AiChat, type AiChatProps } from \"./components/AiChat/AiChat\";\nexport type { CommentProps } from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type { HistoryVersionSummaryProps } from \"./components/HistoryVersionSummary\";\nexport { HistoryVersionSummary } from \"./components/HistoryVersionSummary\";\nexport type { HistoryVersionSummaryListProps } from \"./components/HistoryVersionSummaryList\";\nexport { HistoryVersionSummaryList } from \"./components/HistoryVersionSummaryList\";\nexport type {\n InboxNotificationAvatarProps,\n InboxNotificationCustomKindProps,\n InboxNotificationCustomProps,\n InboxNotificationIconProps,\n InboxNotificationProps,\n InboxNotificationTextMentionKindProps,\n InboxNotificationTextMentionProps,\n InboxNotificationThreadKindProps,\n InboxNotificationThreadProps,\n} from \"./components/InboxNotification\";\nexport { InboxNotification } from \"./components/InboxNotification\";\nexport type { InboxNotificationListProps } from \"./components/InboxNotificationList\";\nexport { InboxNotificationList } from \"./components/InboxNotificationList\";\nexport type { ThreadProps } from \"./components/Thread\";\nexport { Thread } from \"./components/Thread\";\nexport { LiveblocksUIConfig } from \"./config\";\nexport * as Icon from \"./icon\";\nexport type {\n ChatComposerOverrides,\n CommentOverrides,\n ComposerOverrides,\n GlobalOverrides,\n InboxNotificationOverrides,\n LocalizationOverrides,\n Overrides,\n ThreadOverrides,\n} from \"./overrides\";\nexport { useOverrides } from \"./overrides\";\nexport type { ComposerSubmitComment } from \"./primitives\";\nexport type {\n CommentAttachmentArgs,\n ComposerBodyMark,\n ComposerBodyMarks,\n} from \"./types\";\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
@@ -119,7 +119,19 @@ const defaultOverrides = {
119
119
  }),
120
120
  HISTORY_VERSION_PREVIEW_RESTORE: "Restore",
121
121
  HISTORY_VERSION_PREVIEW_EMPTY: "No content.",
122
- HISTORY_VERSION_PREVIEW_ERROR: () => "There was an error while getting this version."
122
+ HISTORY_VERSION_PREVIEW_ERROR: () => "There was an error while getting this version.",
123
+ CHAT_COMPOSER_PLACEHOLDER: "Ask anything\u2026",
124
+ CHAT_COMPOSER_SEND: "Send",
125
+ CHAT_COMPOSER_ATTACH_FILES: "Attach files",
126
+ CHAT_COMPOSER_REMOVE_ATTACHMENT: "Remove attachment",
127
+ CHAT_COMPOSER_ABORT: "Abort response.",
128
+ CHAT_MESSAGE_DELETED: "This message has been deleted.",
129
+ CHAT_MESSAGE_THINKING: "Thinking\u2026",
130
+ CHAT_MESSAGE_COPY: "Copy",
131
+ CHAT_MESSAGE_TRY_AGAIN: "Try again",
132
+ GET_CHAT_MESSAGES_ERROR: () => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
133
+ children: "There was an error while getting the messages"
134
+ })
123
135
  };
124
136
  const OverridesContext = react.createContext(void 0);
125
137
  function useOverrides(overrides) {
@@ -1 +1 @@
1
- {"version":3,"file":"overrides.cjs","sources":["../src/overrides.tsx"],"sourcesContent":["\"use client\";\n\nimport { assertNever } from \"@liveblocks/core\";\nimport type { PropsWithChildren, ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\n\nimport { Emoji } from \"./components/internal/Emoji\";\nimport type { ComposerBodyMark, Direction } from \"./types\";\nimport { pluralize } from \"./utils/pluralize\";\n\nexport interface LocalizationOverrides {\n locale: string;\n dir: Direction;\n}\n\nexport interface GlobalOverrides {\n USER_SELF: string;\n USER_UNKNOWN: string;\n LIST_REMAINING: (count: number) => string;\n LIST_REMAINING_USERS: (count: number) => string;\n LIST_REMAINING_COMMENTS: (count: number) => string;\n EMOJI_PICKER_SEARCH_PLACEHOLDER: string;\n EMOJI_PICKER_EMPTY: ReactNode;\n EMOJI_PICKER_ERROR: (error: Error) => ReactNode;\n EMOJI_PICKER_CHANGE_SKIN_TONE: string;\n ATTACHMENT_TOO_LARGE: (maxSize?: string) => string;\n ATTACHMENT_ERROR: (error: Error) => string;\n}\n\nexport interface CommentOverrides {\n COMMENT_EDITED: ReactNode;\n COMMENT_DELETED: ReactNode;\n COMMENT_MORE: string;\n COMMENT_EDIT: string;\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: string;\n COMMENT_EDIT_COMPOSER_CANCEL: string;\n COMMENT_EDIT_COMPOSER_SAVE: string;\n COMMENT_DELETE: string;\n COMMENT_DELETE_ATTACHMENT: string;\n COMMENT_ADD_REACTION: string;\n COMMENT_REACTION_LIST: (\n list: ReactNode,\n emoji: string,\n count: number\n ) => ReactNode;\n COMMENT_REACTION_DESCRIPTION: (emoji: string, count: number) => string;\n}\n\nexport interface ComposerOverrides {\n COMPOSER_INSERT_MENTION: string;\n COMPOSER_INSERT_EMOJI: string;\n COMPOSER_ATTACH_FILES: string;\n COMPOSER_REMOVE_ATTACHMENT: string;\n COMPOSER_PLACEHOLDER: string;\n COMPOSER_SEND: string;\n COMPOSER_TOGGLE_MARK: (mark: ComposerBodyMark) => string;\n}\n\nexport interface ThreadOverrides {\n THREAD_RESOLVE: string;\n THREAD_UNRESOLVE: string;\n THREAD_SUBSCRIBE: string;\n THREAD_UNSUBSCRIBE: string;\n THREAD_NEW_INDICATOR: string;\n THREAD_NEW_INDICATOR_DESCRIPTION: string;\n THREAD_COMPOSER_PLACEHOLDER: string;\n THREAD_COMPOSER_SEND: string;\n}\n\nexport interface InboxNotificationOverrides {\n INBOX_NOTIFICATION_MORE: string;\n INBOX_NOTIFICATION_MARK_AS_READ: string;\n INBOX_NOTIFICATION_DELETE: string;\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode | undefined,\n count: number\n ) => ReactNode;\n INBOX_NOTIFICATION_THREAD_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n INBOX_NOTIFICATION_TEXT_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n}\n\nexport interface HistoryVersionPreviewOverrides {\n HISTORY_VERSION_PREVIEW_AUTHORS_LIST: (list: ReactNode) => ReactNode;\n HISTORY_VERSION_PREVIEW_RESTORE: string;\n HISTORY_VERSION_PREVIEW_EMPTY: ReactNode;\n HISTORY_VERSION_PREVIEW_ERROR: (error: Error) => ReactNode;\n}\n\nexport type Overrides = LocalizationOverrides &\n GlobalOverrides &\n ComposerOverrides &\n CommentOverrides &\n ThreadOverrides &\n InboxNotificationOverrides &\n HistoryVersionPreviewOverrides;\n\ntype OverridesProviderProps = PropsWithChildren<{\n overrides?: Partial<Overrides>;\n}>;\n\nexport const defaultOverrides: Overrides = {\n locale: \"en\",\n dir: \"ltr\",\n USER_SELF: \"you\",\n USER_UNKNOWN: \"Anonymous\",\n LIST_REMAINING: (count) => `${count} more`,\n LIST_REMAINING_USERS: (count) => `${count} ${pluralize(count, \"other\")}`,\n LIST_REMAINING_COMMENTS: (count) =>\n `${count} more ${pluralize(count, \"comment\")}`,\n EMOJI_PICKER_SEARCH_PLACEHOLDER: \"Search…\",\n EMOJI_PICKER_EMPTY: \"No emoji found.\",\n EMOJI_PICKER_ERROR: () =>\n \"There was an error while getting the list of emoji.\",\n EMOJI_PICKER_CHANGE_SKIN_TONE: \"Change skin tone\",\n ATTACHMENT_TOO_LARGE: (maxSize) =>\n maxSize ? `The file is larger than ${maxSize}` : \"The file is too large\",\n ATTACHMENT_ERROR: () => \"The file couldn’t be uploaded.\",\n COMPOSER_INSERT_MENTION: \"Mention someone\",\n COMPOSER_INSERT_EMOJI: \"Add emoji\",\n COMPOSER_ATTACH_FILES: \"Attach files\",\n COMPOSER_REMOVE_ATTACHMENT: \"Remove attachment\",\n COMPOSER_PLACEHOLDER: \"Write a comment…\",\n COMPOSER_SEND: \"Send\",\n COMPOSER_TOGGLE_MARK: (format) => {\n switch (format) {\n case \"bold\":\n return \"Bold\";\n case \"italic\":\n return \"Italic\";\n case \"strikethrough\":\n return \"Strikethrough\";\n case \"code\":\n return \"Inline code\";\n default:\n return assertNever(format, \"Unexpected mark\");\n }\n },\n COMMENT_EDITED: \"(edited)\",\n COMMENT_DELETED: \"This comment has been deleted.\",\n COMMENT_MORE: \"More\",\n COMMENT_EDIT: \"Edit comment\",\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: \"Edit comment…\",\n COMMENT_EDIT_COMPOSER_CANCEL: \"Cancel\",\n COMMENT_EDIT_COMPOSER_SAVE: \"Save\",\n COMMENT_DELETE: \"Delete comment\",\n COMMENT_DELETE_ATTACHMENT: \"Delete attachment\",\n COMMENT_ADD_REACTION: \"Add reaction\",\n COMMENT_REACTION_LIST: (list, emoji) => (\n <>\n {list} reacted with <Emoji emoji={emoji} />\n </>\n ),\n COMMENT_REACTION_DESCRIPTION: (emoji, count) =>\n `${count} ${pluralize(count, \"reaction\")}, react with ${emoji}`,\n THREAD_RESOLVE: \"Resolve thread\",\n THREAD_UNRESOLVE: \"Re-open thread\",\n THREAD_SUBSCRIBE: \"Subscribe to thread\",\n THREAD_UNSUBSCRIBE: \"Unsubscribe from thread\",\n THREAD_NEW_INDICATOR: \"New\",\n THREAD_NEW_INDICATOR_DESCRIPTION: \"New comments\",\n THREAD_COMPOSER_PLACEHOLDER: \"Reply to thread…\",\n THREAD_COMPOSER_SEND: \"Reply\",\n INBOX_NOTIFICATION_MORE: \"More\",\n INBOX_NOTIFICATION_MARK_AS_READ: \"Mark as read\",\n INBOX_NOTIFICATION_DELETE: \"Delete notification\",\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode\n ) => (\n <>\n {list} commented\n {room ? <> in {room}</> : <> in a thread</>}\n </>\n ),\n INBOX_NOTIFICATION_THREAD_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n INBOX_NOTIFICATION_TEXT_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n HISTORY_VERSION_PREVIEW_AUTHORS_LIST: (list: ReactNode) => (\n <>Edits from {list}</>\n ),\n HISTORY_VERSION_PREVIEW_RESTORE: \"Restore\",\n HISTORY_VERSION_PREVIEW_EMPTY: \"No content.\",\n HISTORY_VERSION_PREVIEW_ERROR: () =>\n \"There was an error while getting this version.\",\n};\n\nexport const OverridesContext = createContext<Overrides | undefined>(undefined);\n\nexport function useOverrides(overrides?: Partial<Overrides>): Overrides {\n const contextOverrides = useContext(OverridesContext);\n\n return useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...overrides,\n }),\n [contextOverrides, overrides]\n );\n}\n\nexport function OverridesProvider({\n children,\n overrides: providerOverrides,\n}: OverridesProviderProps) {\n const contextOverrides = useContext(OverridesContext);\n const overrides = useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...providerOverrides,\n }),\n [contextOverrides, providerOverrides]\n );\n\n return (\n <OverridesContext.Provider value={overrides}>\n {children}\n </OverridesContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AA2GO;AAAoC;AACjC;AACH;AACM;AACG;AACgB;AACuC;AAExB;AACZ;AACb;AAElB;AAC6B;AAEoB;AAC3B;AACC;AACF;AACA;AACK;AACN;AACP;AAEb;AAAgB;AAEZ;AAAO;AAEP;AAAO;AAEP;AAAO;AAEP;AAAO;AAEP;AAA4C;AAChD;AACF;AACgB;AACC;AACH;AACA;AACqB;AACL;AACF;AACZ;AACW;AACL;AAEpB;AACG;AAAA;AAAK;AAAe;AAAM;AAAc;AAAA;AAC3C;AAGwD;AAC1C;AACE;AACA;AACE;AACE;AACY;AACL;AACP;AACG;AACQ;AACN;AAKzB;AACG;AAAA;AAAK;AACE;AAAE;AAAA;AAAK;AAAA;AAAW;AAAE;AAAY;AAAA;AAC1C;AAGA;AACG;AAAA;AAAK;AAAsB;AAAE;AAAA;AAAK;AAAA;AAAW;AAAA;AAChD;AAGA;AACG;AAAA;AAAK;AAAsB;AAAE;AAAA;AAAK;AAAA;AAAW;AAAA;AAChD;AAGA;AAAE;AAAA;AAAY;AAAA;AAAK;AAEY;AACF;AAGjC;AAEa;AAEN;AACL;AAEA;AAAO;AACE;AACF;AACA;AACA;AACL;AAC4B;AAEhC;AAEO;AAA2B;AAChC;AAEF;AACE;AACA;AAAkB;AACT;AACF;AACA;AACA;AACL;AACoC;AAGtC;AACG;AAAiC;AAC/B;AAGP;;;;;"}
1
+ {"version":3,"file":"overrides.cjs","sources":["../src/overrides.tsx"],"sourcesContent":["\"use client\";\n\nimport { assertNever } from \"@liveblocks/core\";\nimport type { PropsWithChildren, ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\n\nimport { Emoji } from \"./components/internal/Emoji\";\nimport type { ComposerBodyMark, Direction } from \"./types\";\nimport { pluralize } from \"./utils/pluralize\";\n\nexport interface LocalizationOverrides {\n locale: string;\n dir: Direction;\n}\n\nexport interface GlobalOverrides {\n USER_SELF: string;\n USER_UNKNOWN: string;\n LIST_REMAINING: (count: number) => string;\n LIST_REMAINING_USERS: (count: number) => string;\n LIST_REMAINING_COMMENTS: (count: number) => string;\n EMOJI_PICKER_SEARCH_PLACEHOLDER: string;\n EMOJI_PICKER_EMPTY: ReactNode;\n EMOJI_PICKER_ERROR: (error: Error) => ReactNode;\n EMOJI_PICKER_CHANGE_SKIN_TONE: string;\n ATTACHMENT_TOO_LARGE: (maxSize?: string) => string;\n ATTACHMENT_ERROR: (error: Error) => string;\n}\n\nexport interface CommentOverrides {\n COMMENT_EDITED: ReactNode;\n COMMENT_DELETED: ReactNode;\n COMMENT_MORE: string;\n COMMENT_EDIT: string;\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: string;\n COMMENT_EDIT_COMPOSER_CANCEL: string;\n COMMENT_EDIT_COMPOSER_SAVE: string;\n COMMENT_DELETE: string;\n COMMENT_DELETE_ATTACHMENT: string;\n COMMENT_ADD_REACTION: string;\n COMMENT_REACTION_LIST: (\n list: ReactNode,\n emoji: string,\n count: number\n ) => ReactNode;\n COMMENT_REACTION_DESCRIPTION: (emoji: string, count: number) => string;\n}\n\nexport interface ComposerOverrides {\n COMPOSER_INSERT_MENTION: string;\n COMPOSER_INSERT_EMOJI: string;\n COMPOSER_ATTACH_FILES: string;\n COMPOSER_REMOVE_ATTACHMENT: string;\n COMPOSER_PLACEHOLDER: string;\n COMPOSER_SEND: string;\n COMPOSER_TOGGLE_MARK: (mark: ComposerBodyMark) => string;\n}\n\nexport interface ChatComposerOverrides {\n CHAT_COMPOSER_PLACEHOLDER: string;\n CHAT_COMPOSER_SEND: string;\n CHAT_COMPOSER_ATTACH_FILES: string;\n CHAT_COMPOSER_REMOVE_ATTACHMENT: string;\n CHAT_COMPOSER_ABORT: string;\n}\n\nexport interface ChatMessageOverrides {\n CHAT_MESSAGE_DELETED: string;\n CHAT_MESSAGE_THINKING: string;\n CHAT_MESSAGE_COPY: string;\n CHAT_MESSAGE_TRY_AGAIN: string;\n}\n\nexport interface ChatOverrides {\n GET_CHAT_MESSAGES_ERROR: (error: Error) => ReactNode;\n}\n\nexport interface ThreadOverrides {\n THREAD_RESOLVE: string;\n THREAD_UNRESOLVE: string;\n THREAD_SUBSCRIBE: string;\n THREAD_UNSUBSCRIBE: string;\n THREAD_NEW_INDICATOR: string;\n THREAD_NEW_INDICATOR_DESCRIPTION: string;\n THREAD_COMPOSER_PLACEHOLDER: string;\n THREAD_COMPOSER_SEND: string;\n}\n\nexport interface InboxNotificationOverrides {\n INBOX_NOTIFICATION_MORE: string;\n INBOX_NOTIFICATION_MARK_AS_READ: string;\n INBOX_NOTIFICATION_DELETE: string;\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode | undefined,\n count: number\n ) => ReactNode;\n INBOX_NOTIFICATION_THREAD_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n INBOX_NOTIFICATION_TEXT_MENTION: (\n user: ReactNode,\n room: ReactNode | undefined\n ) => ReactNode;\n}\n\nexport interface HistoryVersionPreviewOverrides {\n HISTORY_VERSION_PREVIEW_AUTHORS_LIST: (list: ReactNode) => ReactNode;\n HISTORY_VERSION_PREVIEW_RESTORE: string;\n HISTORY_VERSION_PREVIEW_EMPTY: ReactNode;\n HISTORY_VERSION_PREVIEW_ERROR: (error: Error) => ReactNode;\n}\n\nexport type Overrides = LocalizationOverrides &\n GlobalOverrides &\n ComposerOverrides &\n CommentOverrides &\n ThreadOverrides &\n InboxNotificationOverrides &\n HistoryVersionPreviewOverrides &\n ChatComposerOverrides &\n ChatMessageOverrides &\n ChatOverrides;\n\ntype OverridesProviderProps = PropsWithChildren<{\n overrides?: Partial<Overrides>;\n}>;\n\nexport const defaultOverrides: Overrides = {\n locale: \"en\",\n dir: \"ltr\",\n USER_SELF: \"you\",\n USER_UNKNOWN: \"Anonymous\",\n LIST_REMAINING: (count) => `${count} more`,\n LIST_REMAINING_USERS: (count) => `${count} ${pluralize(count, \"other\")}`,\n LIST_REMAINING_COMMENTS: (count) =>\n `${count} more ${pluralize(count, \"comment\")}`,\n EMOJI_PICKER_SEARCH_PLACEHOLDER: \"Search…\",\n EMOJI_PICKER_EMPTY: \"No emoji found.\",\n EMOJI_PICKER_ERROR: () =>\n \"There was an error while getting the list of emoji.\",\n EMOJI_PICKER_CHANGE_SKIN_TONE: \"Change skin tone\",\n ATTACHMENT_TOO_LARGE: (maxSize) =>\n maxSize ? `The file is larger than ${maxSize}` : \"The file is too large\",\n ATTACHMENT_ERROR: () => \"The file couldn’t be uploaded.\",\n COMPOSER_INSERT_MENTION: \"Mention someone\",\n COMPOSER_INSERT_EMOJI: \"Add emoji\",\n COMPOSER_ATTACH_FILES: \"Attach files\",\n COMPOSER_REMOVE_ATTACHMENT: \"Remove attachment\",\n COMPOSER_PLACEHOLDER: \"Write a comment…\",\n COMPOSER_SEND: \"Send\",\n COMPOSER_TOGGLE_MARK: (format) => {\n switch (format) {\n case \"bold\":\n return \"Bold\";\n case \"italic\":\n return \"Italic\";\n case \"strikethrough\":\n return \"Strikethrough\";\n case \"code\":\n return \"Inline code\";\n default:\n return assertNever(format, \"Unexpected mark\");\n }\n },\n COMMENT_EDITED: \"(edited)\",\n COMMENT_DELETED: \"This comment has been deleted.\",\n COMMENT_MORE: \"More\",\n COMMENT_EDIT: \"Edit comment\",\n COMMENT_EDIT_COMPOSER_PLACEHOLDER: \"Edit comment…\",\n COMMENT_EDIT_COMPOSER_CANCEL: \"Cancel\",\n COMMENT_EDIT_COMPOSER_SAVE: \"Save\",\n COMMENT_DELETE: \"Delete comment\",\n COMMENT_DELETE_ATTACHMENT: \"Delete attachment\",\n COMMENT_ADD_REACTION: \"Add reaction\",\n COMMENT_REACTION_LIST: (list, emoji) => (\n <>\n {list} reacted with <Emoji emoji={emoji} />\n </>\n ),\n COMMENT_REACTION_DESCRIPTION: (emoji, count) =>\n `${count} ${pluralize(count, \"reaction\")}, react with ${emoji}`,\n THREAD_RESOLVE: \"Resolve thread\",\n THREAD_UNRESOLVE: \"Re-open thread\",\n THREAD_SUBSCRIBE: \"Subscribe to thread\",\n THREAD_UNSUBSCRIBE: \"Unsubscribe from thread\",\n THREAD_NEW_INDICATOR: \"New\",\n THREAD_NEW_INDICATOR_DESCRIPTION: \"New comments\",\n THREAD_COMPOSER_PLACEHOLDER: \"Reply to thread…\",\n THREAD_COMPOSER_SEND: \"Reply\",\n INBOX_NOTIFICATION_MORE: \"More\",\n INBOX_NOTIFICATION_MARK_AS_READ: \"Mark as read\",\n INBOX_NOTIFICATION_DELETE: \"Delete notification\",\n INBOX_NOTIFICATION_THREAD_COMMENTS_LIST: (\n list: ReactNode,\n room: ReactNode\n ) => (\n <>\n {list} commented\n {room ? <> in {room}</> : <> in a thread</>}\n </>\n ),\n INBOX_NOTIFICATION_THREAD_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n INBOX_NOTIFICATION_TEXT_MENTION: (user: ReactNode, room: ReactNode) => (\n <>\n {user} mentioned you{room ? <> in {room}</> : null}\n </>\n ),\n HISTORY_VERSION_PREVIEW_AUTHORS_LIST: (list: ReactNode) => (\n <>Edits from {list}</>\n ),\n HISTORY_VERSION_PREVIEW_RESTORE: \"Restore\",\n HISTORY_VERSION_PREVIEW_EMPTY: \"No content.\",\n HISTORY_VERSION_PREVIEW_ERROR: () =>\n \"There was an error while getting this version.\",\n CHAT_COMPOSER_PLACEHOLDER: \"Ask anything…\",\n CHAT_COMPOSER_SEND: \"Send\",\n CHAT_COMPOSER_ATTACH_FILES: \"Attach files\",\n CHAT_COMPOSER_REMOVE_ATTACHMENT: \"Remove attachment\",\n CHAT_COMPOSER_ABORT: \"Abort response.\",\n CHAT_MESSAGE_DELETED: \"This message has been deleted.\",\n CHAT_MESSAGE_THINKING: \"Thinking…\",\n CHAT_MESSAGE_COPY: \"Copy\",\n CHAT_MESSAGE_TRY_AGAIN: \"Try again\",\n GET_CHAT_MESSAGES_ERROR: () => (\n <>There was an error while getting the messages</>\n ),\n};\n\nexport const OverridesContext = createContext<Overrides | undefined>(undefined);\n\nexport function useOverrides(overrides?: Partial<Overrides>): Overrides {\n const contextOverrides = useContext(OverridesContext);\n\n return useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...overrides,\n }),\n [contextOverrides, overrides]\n );\n}\n\nexport function OverridesProvider({\n children,\n overrides: providerOverrides,\n}: OverridesProviderProps) {\n const contextOverrides = useContext(OverridesContext);\n const overrides = useMemo(\n () => ({\n ...defaultOverrides,\n ...contextOverrides,\n ...providerOverrides,\n }),\n [contextOverrides, providerOverrides]\n );\n\n return (\n <OverridesContext.Provider value={overrides}>\n {children}\n </OverridesContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AAiIO;AAAoC;AACjC;AACH;AACM;AACG;AACgB;AACuC;AAExB;AACZ;AACb;AAElB;AAC6B;AAEoB;AAC3B;AACC;AACF;AACA;AACK;AACN;AACP;AAEb;AAAgB;AAEZ;AAAO;AAEP;AAAO;AAEP;AAAO;AAEP;AAAO;AAEP;AAA4C;AAChD;AACF;AACgB;AACC;AACH;AACA;AACqB;AACL;AACF;AACZ;AACW;AACL;AAEpB;AACG;AAAA;AAAK;AAAe;AAAM;AAAc;AAAA;AAC3C;AAGwD;AAC1C;AACE;AACA;AACE;AACE;AACY;AACL;AACP;AACG;AACQ;AACN;AAKzB;AACG;AAAA;AAAK;AACE;AAAE;AAAA;AAAK;AAAA;AAAW;AAAE;AAAY;AAAA;AAC1C;AAGA;AACG;AAAA;AAAK;AAAsB;AAAE;AAAA;AAAK;AAAA;AAAW;AAAA;AAChD;AAGA;AACG;AAAA;AAAK;AAAsB;AAAE;AAAA;AAAK;AAAA;AAAW;AAAA;AAChD;AAGA;AAAE;AAAA;AAAY;AAAA;AAAK;AAEY;AACF;AAE7B;AACyB;AACP;AACQ;AACK;AACZ;AACC;AACC;AACJ;AACK;AAEtB;AAAE;AAEN;AAEa;AAEN;AACL;AAEA;AAAO;AACE;AACF;AACA;AACA;AACL;AAC4B;AAEhC;AAEO;AAA2B;AAChC;AAEF;AACE;AACA;AAAkB;AACT;AACF;AACA;AACA;AACL;AACoC;AAGtC;AACG;AAAiC;AAC/B;AAGP;;;;;"}
package/dist/overrides.js CHANGED
@@ -117,7 +117,19 @@ const defaultOverrides = {
117
117
  }),
118
118
  HISTORY_VERSION_PREVIEW_RESTORE: "Restore",
119
119
  HISTORY_VERSION_PREVIEW_EMPTY: "No content.",
120
- HISTORY_VERSION_PREVIEW_ERROR: () => "There was an error while getting this version."
120
+ HISTORY_VERSION_PREVIEW_ERROR: () => "There was an error while getting this version.",
121
+ CHAT_COMPOSER_PLACEHOLDER: "Ask anything\u2026",
122
+ CHAT_COMPOSER_SEND: "Send",
123
+ CHAT_COMPOSER_ATTACH_FILES: "Attach files",
124
+ CHAT_COMPOSER_REMOVE_ATTACHMENT: "Remove attachment",
125
+ CHAT_COMPOSER_ABORT: "Abort response.",
126
+ CHAT_MESSAGE_DELETED: "This message has been deleted.",
127
+ CHAT_MESSAGE_THINKING: "Thinking\u2026",
128
+ CHAT_MESSAGE_COPY: "Copy",
129
+ CHAT_MESSAGE_TRY_AGAIN: "Try again",
130
+ GET_CHAT_MESSAGES_ERROR: () => /* @__PURE__ */ jsx(Fragment, {
131
+ children: "There was an error while getting the messages"
132
+ })
121
133
  };
122
134
  const OverridesContext = createContext(void 0);
123
135
  function useOverrides(overrides) {