@liveblocks/react-ui 3.14.0-types2 → 3.15.0-components1

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 (137) hide show
  1. package/README.md +1 -1
  2. package/dist/_private/index.cjs +5 -5
  3. package/dist/_private/index.d.cts +14 -4
  4. package/dist/_private/index.d.ts +14 -4
  5. package/dist/_private/index.js +3 -2
  6. package/dist/_private/index.js.map +1 -1
  7. package/dist/components/AvatarStack.cjs +115 -0
  8. package/dist/components/AvatarStack.cjs.map +1 -0
  9. package/dist/components/AvatarStack.js +113 -0
  10. package/dist/components/AvatarStack.js.map +1 -0
  11. package/dist/components/Comment.cjs +10 -28
  12. package/dist/components/Comment.cjs.map +1 -1
  13. package/dist/components/Comment.js +12 -11
  14. package/dist/components/Comment.js.map +1 -1
  15. package/dist/components/CommentPin.cjs +27 -0
  16. package/dist/components/CommentPin.cjs.map +1 -0
  17. package/dist/components/CommentPin.js +25 -0
  18. package/dist/components/CommentPin.js.map +1 -0
  19. package/dist/components/Composer.cjs +2 -4
  20. package/dist/components/Composer.cjs.map +1 -1
  21. package/dist/components/Composer.js +3 -5
  22. package/dist/components/Composer.js.map +1 -1
  23. package/dist/components/Cursor.cjs +40 -0
  24. package/dist/components/Cursor.cjs.map +1 -0
  25. package/dist/components/Cursor.js +38 -0
  26. package/dist/components/Cursor.js.map +1 -0
  27. package/dist/components/Cursors.cjs +252 -0
  28. package/dist/components/Cursors.cjs.map +1 -0
  29. package/dist/components/Cursors.js +250 -0
  30. package/dist/components/Cursors.js.map +1 -0
  31. package/dist/components/FloatingComposer.cjs +82 -0
  32. package/dist/components/FloatingComposer.cjs.map +1 -0
  33. package/dist/components/FloatingComposer.js +80 -0
  34. package/dist/components/FloatingComposer.js.map +1 -0
  35. package/dist/components/FloatingThread.cjs +82 -0
  36. package/dist/components/FloatingThread.cjs.map +1 -0
  37. package/dist/components/FloatingThread.js +80 -0
  38. package/dist/components/FloatingThread.js.map +1 -0
  39. package/dist/components/InboxNotification.cjs +4 -6
  40. package/dist/components/InboxNotification.cjs.map +1 -1
  41. package/dist/components/InboxNotification.js +5 -7
  42. package/dist/components/InboxNotification.js.map +1 -1
  43. package/dist/components/Thread.cjs +19 -26
  44. package/dist/components/Thread.cjs.map +1 -1
  45. package/dist/components/Thread.js +19 -7
  46. package/dist/components/Thread.js.map +1 -1
  47. package/dist/components/internal/AiComposer.cjs +1 -2
  48. package/dist/components/internal/AiComposer.cjs.map +1 -1
  49. package/dist/components/internal/AiComposer.js +1 -2
  50. package/dist/components/internal/AiComposer.js.map +1 -1
  51. package/dist/components/internal/CodeBlock.cjs +1 -2
  52. package/dist/components/internal/CodeBlock.cjs.map +1 -1
  53. package/dist/components/internal/CodeBlock.js +1 -2
  54. package/dist/components/internal/CodeBlock.js.map +1 -1
  55. package/dist/components/internal/Dropdown.cjs +7 -28
  56. package/dist/components/internal/Dropdown.cjs.map +1 -1
  57. package/dist/components/internal/Dropdown.js +7 -7
  58. package/dist/components/internal/Dropdown.js.map +1 -1
  59. package/dist/components/internal/EmojiPicker.cjs +6 -27
  60. package/dist/components/internal/EmojiPicker.cjs.map +1 -1
  61. package/dist/components/internal/EmojiPicker.js +6 -6
  62. package/dist/components/internal/EmojiPicker.js.map +1 -1
  63. package/dist/components/internal/List.cjs +2 -2
  64. package/dist/components/internal/List.cjs.map +1 -1
  65. package/dist/components/internal/List.js +2 -2
  66. package/dist/components/internal/List.js.map +1 -1
  67. package/dist/components/internal/Tooltip.cjs +7 -28
  68. package/dist/components/internal/Tooltip.cjs.map +1 -1
  69. package/dist/components/internal/Tooltip.js +7 -7
  70. package/dist/components/internal/Tooltip.js.map +1 -1
  71. package/dist/index.cjs +12 -0
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.cts +214 -125
  74. package/dist/index.d.ts +214 -125
  75. package/dist/index.js +6 -0
  76. package/dist/index.js.map +1 -1
  77. package/dist/primitives/AiComposer/index.cjs +9 -6
  78. package/dist/primitives/AiComposer/index.cjs.map +1 -1
  79. package/dist/primitives/AiComposer/index.js +9 -6
  80. package/dist/primitives/AiComposer/index.js.map +1 -1
  81. package/dist/primitives/AiMessage/index.cjs +2 -2
  82. package/dist/primitives/AiMessage/index.cjs.map +1 -1
  83. package/dist/primitives/AiMessage/index.js +2 -2
  84. package/dist/primitives/AiMessage/index.js.map +1 -1
  85. package/dist/primitives/Collapsible/index.cjs +4 -4
  86. package/dist/primitives/Collapsible/index.cjs.map +1 -1
  87. package/dist/primitives/Collapsible/index.js +4 -4
  88. package/dist/primitives/Collapsible/index.js.map +1 -1
  89. package/dist/primitives/Comment/index.cjs +4 -4
  90. package/dist/primitives/Comment/index.cjs.map +1 -1
  91. package/dist/primitives/Comment/index.js +4 -4
  92. package/dist/primitives/Comment/index.js.map +1 -1
  93. package/dist/primitives/Composer/index.cjs +27 -42
  94. package/dist/primitives/Composer/index.cjs.map +1 -1
  95. package/dist/primitives/Composer/index.js +27 -23
  96. package/dist/primitives/Composer/index.js.map +1 -1
  97. package/dist/primitives/Duration.cjs +2 -2
  98. package/dist/primitives/Duration.cjs.map +1 -1
  99. package/dist/primitives/Duration.js +2 -2
  100. package/dist/primitives/Duration.js.map +1 -1
  101. package/dist/primitives/FileSize.cjs +2 -2
  102. package/dist/primitives/FileSize.cjs.map +1 -1
  103. package/dist/primitives/FileSize.js +2 -2
  104. package/dist/primitives/FileSize.js.map +1 -1
  105. package/dist/primitives/Markdown.cjs +2 -2
  106. package/dist/primitives/Markdown.cjs.map +1 -1
  107. package/dist/primitives/Markdown.js +2 -2
  108. package/dist/primitives/Markdown.js.map +1 -1
  109. package/dist/primitives/Timestamp.cjs +2 -2
  110. package/dist/primitives/Timestamp.cjs.map +1 -1
  111. package/dist/primitives/Timestamp.js +2 -2
  112. package/dist/primitives/Timestamp.js.map +1 -1
  113. package/dist/utils/Portal.cjs +6 -3
  114. package/dist/utils/Portal.cjs.map +1 -1
  115. package/dist/utils/Portal.js +6 -3
  116. package/dist/utils/Portal.js.map +1 -1
  117. package/dist/utils/animation-loop.cjs +44 -0
  118. package/dist/utils/animation-loop.cjs.map +1 -0
  119. package/dist/utils/animation-loop.js +42 -0
  120. package/dist/utils/animation-loop.js.map +1 -0
  121. package/dist/utils/use-pre-resolve-user.cjs +18 -0
  122. package/dist/utils/use-pre-resolve-user.cjs.map +1 -0
  123. package/dist/utils/use-pre-resolve-user.js +16 -0
  124. package/dist/utils/use-pre-resolve-user.js.map +1 -0
  125. package/dist/version.cjs +1 -1
  126. package/dist/version.cjs.map +1 -1
  127. package/dist/version.js +1 -1
  128. package/dist/version.js.map +1 -1
  129. package/package.json +9 -13
  130. package/src/styles/dark/index.css +1 -1
  131. package/src/styles/index.css +252 -4
  132. package/styles/dark/attributes.css +1 -1
  133. package/styles/dark/attributes.css.map +1 -1
  134. package/styles/dark/media-query.css +1 -1
  135. package/styles/dark/media-query.css.map +1 -1
  136. package/styles.css +1 -1
  137. package/styles.css.map +1 -1
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ComponentPropsWithoutRef, ElementType, ReactNode, ComponentProps, FormEvent, RefAttributes, MouseEvent, PropsWithChildren } from 'react';
3
- import { CommentAttachment, AiReasoningPart, AiRetrievalPart, Relax, WithNavigation, AiAssistantMessage, CopilotId, AiKnowledgeSource, AiOpaqueToolDefinition, AiToolTypePack, JsonObject, AiToolExecuteCallback, NoInfr, CommentBody, MentionData, BaseMetadata, DTM, DCM, Patchable, CommentData, HistoryVersion, InboxNotificationData, InboxNotificationThreadData, InboxNotificationTextMentionData, InboxNotificationCustomData, KDAD, ThreadData } from '@liveblocks/core';
3
+ import { CommentAttachment, AiReasoningPart, AiRetrievalPart, Relax, WithNavigation, AiAssistantMessage, CopilotId, AiKnowledgeSource, AiOpaqueToolDefinition, AiToolTypePack, JsonObject, AiToolExecuteCallback, NoInfr, CommentBody, MentionData, BaseMetadata, DTM, DCM, Patchable, CommentData, ThreadData, HistoryVersion, InboxNotificationData, InboxNotificationThreadData, InboxNotificationTextMentionData, InboxNotificationCustomData, KDAD } from '@liveblocks/core';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { Popover } from 'radix-ui';
5
6
 
6
7
  interface GlobalComponents {
7
8
  Anchor: ComponentType<ComponentPropsWithoutRef<"a">> | "a";
@@ -809,6 +810,25 @@ declare const AiTool: react.ForwardRefExoticComponent<Omit<AiToolProps, "ref"> &
809
810
  Confirmation: typeof AiToolConfirmation;
810
811
  };
811
812
 
813
+ interface AvatarStackProps extends ComponentPropsWithoutRef<"div"> {
814
+ /**
815
+ * Optional additional user IDs to include in the stack.
816
+ */
817
+ userIds?: string[];
818
+ /**
819
+ * The maximum number of visible avatars.
820
+ */
821
+ max?: number;
822
+ /**
823
+ * Override the component's strings.
824
+ */
825
+ overrides?: Partial<GlobalOverrides>;
826
+ }
827
+ /**
828
+ * Displays a stack of avatars for the users currently present in the room.
829
+ */
830
+ declare const AvatarStack: react.ForwardRefExoticComponent<AvatarStackProps & react.RefAttributes<HTMLDivElement>>;
831
+
812
832
  interface ComposerEditorMentionProps {
813
833
  /**
814
834
  * Whether the mention is selected.
@@ -1122,6 +1142,198 @@ declare const Comment: react.ForwardRefExoticComponent<CommentProps & react.RefA
1122
1142
  DropdownItem: react.ForwardRefExoticComponent<CommentDropdownItemProps & react.RefAttributes<HTMLDivElement>>;
1123
1143
  };
1124
1144
 
1145
+ interface CommentPinProps extends ComponentPropsWithoutRef<"button"> {
1146
+ /**
1147
+ * The corner that points to the comment position.
1148
+ */
1149
+ corner?: "top-left" | "top-right" | "bottom-right" | "bottom-left";
1150
+ /**
1151
+ * The user ID to optionally display an avatar for.
1152
+ */
1153
+ userId?: string;
1154
+ }
1155
+ /**
1156
+ * Displays a comment pin that can be used as a trigger
1157
+ * for `FloatingComposer` and `FloatingThread`.
1158
+ */
1159
+ declare const CommentPin: react.ForwardRefExoticComponent<CommentPinProps & react.RefAttributes<HTMLButtonElement>>;
1160
+
1161
+ interface CursorProps extends ComponentPropsWithoutRef<"div"> {
1162
+ /**
1163
+ * A floating label to display next to the cursor.
1164
+ */
1165
+ label?: ReactNode;
1166
+ /**
1167
+ * The color of the cursor.
1168
+ */
1169
+ color?: string;
1170
+ }
1171
+ /**
1172
+ * Displays a multiplayer cursor.
1173
+ */
1174
+ declare const Cursor: react.ForwardRefExoticComponent<CursorProps & react.RefAttributes<HTMLDivElement>>;
1175
+
1176
+ interface CursorsProps extends ComponentPropsWithoutRef<"div"> {
1177
+ /**
1178
+ * The key used to store the cursors in users' Presence.
1179
+ * This can be used to have multiple `Cursors` in a single room.
1180
+ */
1181
+ presenceKey?: string;
1182
+ }
1183
+ /**
1184
+ * Displays multiplayer cursors.
1185
+ */
1186
+ declare const Cursors: react.ForwardRefExoticComponent<CursorsProps & react.RefAttributes<HTMLDivElement>>;
1187
+
1188
+ interface FloatingComposerProps<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> extends Omit<ComposerProps<TM, CM>, "collapsed" | "onCollapsedChange" | "defaultCollapsed">, Relax<Pick<Popover.PopoverProps, "defaultOpen" | "open" | "onOpenChange"> & Pick<Popover.PopoverContentProps, "side" | "sideOffset" | "align" | "alignOffset">> {
1189
+ /**
1190
+ * The element which opens the floating composer.
1191
+ */
1192
+ children: ReactNode;
1193
+ }
1194
+ /**
1195
+ * Displays a floating composer attached to a trigger element.
1196
+ */
1197
+ declare const FloatingComposer: <TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM>(props: FloatingComposerProps<TM, CM> & RefAttributes<HTMLFormElement>) => JSX.Element;
1198
+
1199
+ interface ThreadProps<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> extends ComponentPropsWithoutRef<"div"> {
1200
+ /**
1201
+ * The thread to display.
1202
+ */
1203
+ thread: ThreadData<TM, CM>;
1204
+ /**
1205
+ * How to show or hide the composer to reply to the thread.
1206
+ */
1207
+ showComposer?: boolean | "collapsed";
1208
+ /**
1209
+ * Whether to show the action to resolve the thread.
1210
+ */
1211
+ showResolveAction?: boolean;
1212
+ /**
1213
+ * How to show or hide the actions.
1214
+ */
1215
+ showActions?: CommentProps["showActions"];
1216
+ /**
1217
+ * Whether to show reactions.
1218
+ */
1219
+ showReactions?: CommentProps["showReactions"];
1220
+ /**
1221
+ * Whether to show the composer's formatting controls.
1222
+ */
1223
+ showComposerFormattingControls?: ComposerProps["showFormattingControls"];
1224
+ /**
1225
+ * Add (or change) items to display in a comment's dropdown.
1226
+ */
1227
+ commentDropdownItems?: ReactNode | ((props: PropsWithChildren<{
1228
+ comment: CommentData;
1229
+ }>) => ReactNode);
1230
+ /**
1231
+ * The maximum number of comments to show.
1232
+ *
1233
+ * The first and last comments are always shown and by default if some comments
1234
+ * are hidden, only the first comment will be shown before the "show more" button
1235
+ * and after it will be shown all the newest comments to fit the limit set.
1236
+ *
1237
+ * It's possible to customize this by setting `maxVisibleComments` to an object:
1238
+ *
1239
+ * @example
1240
+ * // Only show the last comment, and all the older ones to fit the limit.
1241
+ * <Thread maxVisibleComments={{ max: 5, show: "oldest" }} />
1242
+ *
1243
+ * @example
1244
+ * // Show as many old comments as new ones to fit the limit.
1245
+ * <Thread maxVisibleComments={{ max: 5, show: "both" }} />
1246
+ */
1247
+ maxVisibleComments?: number | {
1248
+ max: number;
1249
+ show: "oldest" | "both" | "newest";
1250
+ };
1251
+ /**
1252
+ * Whether to blur the composer editor when the composer is submitted.
1253
+ */
1254
+ blurComposerOnSubmit?: ComposerProps["blurOnSubmit"];
1255
+ /**
1256
+ * Whether to indent the comments' content.
1257
+ */
1258
+ indentCommentContent?: CommentProps["indentContent"];
1259
+ /**
1260
+ * Whether to show deleted comments.
1261
+ */
1262
+ showDeletedComments?: CommentProps["showDeleted"];
1263
+ /**
1264
+ * Whether to show attachments.
1265
+ */
1266
+ showAttachments?: boolean;
1267
+ /**
1268
+ * The event handler called when changing the resolved status.
1269
+ */
1270
+ onResolvedChange?: (resolved: boolean) => void;
1271
+ /**
1272
+ * The event handler called when a comment is edited.
1273
+ */
1274
+ onCommentEdit?: CommentProps["onCommentEdit"];
1275
+ /**
1276
+ * The event handler called when a comment is deleted.
1277
+ */
1278
+ onCommentDelete?: CommentProps["onCommentDelete"];
1279
+ /**
1280
+ * The event handler called when the thread is deleted.
1281
+ * A thread is deleted when all its comments are deleted.
1282
+ */
1283
+ onThreadDelete?: (thread: ThreadData<TM, CM>) => void;
1284
+ /**
1285
+ * The event handler called when clicking on a comment's author.
1286
+ */
1287
+ onAuthorClick?: CommentProps["onAuthorClick"];
1288
+ /**
1289
+ * The event handler called when clicking on a mention.
1290
+ */
1291
+ onMentionClick?: CommentProps["onMentionClick"];
1292
+ /**
1293
+ * The event handler called when clicking on a comment's attachment.
1294
+ */
1295
+ onAttachmentClick?: CommentProps["onAttachmentClick"];
1296
+ /**
1297
+ * The event handler called when the composer is submitted.
1298
+ */
1299
+ onComposerSubmit?: ComposerProps["onComposerSubmit"];
1300
+ /**
1301
+ * Whether to focus the composer on mount.
1302
+ */
1303
+ autoFocus?: ComposerProps["autoFocus"];
1304
+ /**
1305
+ * Override the component's strings.
1306
+ */
1307
+ overrides?: Partial<GlobalOverrides & ThreadOverrides & CommentOverrides & ComposerOverrides>;
1308
+ /**
1309
+ * Override the component's components.
1310
+ */
1311
+ components?: Partial<GlobalComponents>;
1312
+ }
1313
+ /**
1314
+ * Displays a thread of comments, with a composer to reply
1315
+ * to it.
1316
+ *
1317
+ * @example
1318
+ * <>
1319
+ * {threads.map((thread) => (
1320
+ * <Thread key={thread.id} thread={thread} />
1321
+ * ))}
1322
+ * </>
1323
+ */
1324
+ declare const Thread: <TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM>(props: ThreadProps<TM, CM> & RefAttributes<HTMLDivElement>) => JSX.Element;
1325
+
1326
+ interface FloatingThreadProps<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> extends ThreadProps<TM, CM>, Relax<Pick<Popover.PopoverProps, "defaultOpen" | "open" | "onOpenChange"> & Pick<Popover.PopoverContentProps, "side" | "sideOffset" | "align" | "alignOffset">> {
1327
+ /**
1328
+ * The element which opens the floating thread.
1329
+ */
1330
+ children: ReactNode;
1331
+ }
1332
+ /**
1333
+ * Displays a floating thread attached to a trigger element.
1334
+ */
1335
+ declare const FloatingThread: <TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM>(props: FloatingThreadProps<TM, CM> & RefAttributes<HTMLDivElement>) => JSX.Element;
1336
+
1125
1337
  interface HistoryVersionSummaryProps extends ComponentPropsWithoutRef<"button"> {
1126
1338
  version: HistoryVersion;
1127
1339
  selected?: boolean;
@@ -1317,129 +1529,6 @@ interface InboxNotificationListProps extends ComponentPropsWithoutRef<"ol"> {
1317
1529
  */
1318
1530
  declare const InboxNotificationList: react.ForwardRefExoticComponent<InboxNotificationListProps & react.RefAttributes<HTMLOListElement>>;
1319
1531
 
1320
- interface ThreadProps<TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM> extends ComponentPropsWithoutRef<"div"> {
1321
- /**
1322
- * The thread to display.
1323
- */
1324
- thread: ThreadData<TM, CM>;
1325
- /**
1326
- * How to show or hide the composer to reply to the thread.
1327
- */
1328
- showComposer?: boolean | "collapsed";
1329
- /**
1330
- * Whether to show the action to resolve the thread.
1331
- */
1332
- showResolveAction?: boolean;
1333
- /**
1334
- * How to show or hide the actions.
1335
- */
1336
- showActions?: CommentProps["showActions"];
1337
- /**
1338
- * Whether to show reactions.
1339
- */
1340
- showReactions?: CommentProps["showReactions"];
1341
- /**
1342
- * Whether to show the composer's formatting controls.
1343
- */
1344
- showComposerFormattingControls?: ComposerProps["showFormattingControls"];
1345
- /**
1346
- * Add (or change) items to display in a comment's dropdown.
1347
- */
1348
- commentDropdownItems?: ReactNode | ((props: PropsWithChildren<{
1349
- comment: CommentData;
1350
- }>) => ReactNode);
1351
- /**
1352
- * The maximum number of comments to show.
1353
- *
1354
- * The first and last comments are always shown and by default if some comments
1355
- * are hidden, only the first comment will be shown before the "show more" button
1356
- * and after it will be shown all the newest comments to fit the limit set.
1357
- *
1358
- * It's possible to customize this by setting `maxVisibleComments` to an object:
1359
- *
1360
- * @example
1361
- * // Only show the last comment, and all the older ones to fit the limit.
1362
- * <Thread maxVisibleComments={{ max: 5, show: "oldest" }} />
1363
- *
1364
- * @example
1365
- * // Show as many old comments as new ones to fit the limit.
1366
- * <Thread maxVisibleComments={{ max: 5, show: "both" }} />
1367
- */
1368
- maxVisibleComments?: number | {
1369
- max: number;
1370
- show: "oldest" | "both" | "newest";
1371
- };
1372
- /**
1373
- * Whether to blur the composer editor when the composer is submitted.
1374
- */
1375
- blurComposerOnSubmit?: ComposerProps["blurOnSubmit"];
1376
- /**
1377
- * Whether to indent the comments' content.
1378
- */
1379
- indentCommentContent?: CommentProps["indentContent"];
1380
- /**
1381
- * Whether to show deleted comments.
1382
- */
1383
- showDeletedComments?: CommentProps["showDeleted"];
1384
- /**
1385
- * Whether to show attachments.
1386
- */
1387
- showAttachments?: boolean;
1388
- /**
1389
- * The event handler called when changing the resolved status.
1390
- */
1391
- onResolvedChange?: (resolved: boolean) => void;
1392
- /**
1393
- * The event handler called when a comment is edited.
1394
- */
1395
- onCommentEdit?: CommentProps["onCommentEdit"];
1396
- /**
1397
- * The event handler called when a comment is deleted.
1398
- */
1399
- onCommentDelete?: CommentProps["onCommentDelete"];
1400
- /**
1401
- * The event handler called when the thread is deleted.
1402
- * A thread is deleted when all its comments are deleted.
1403
- */
1404
- onThreadDelete?: (thread: ThreadData<TM, CM>) => void;
1405
- /**
1406
- * The event handler called when clicking on a comment's author.
1407
- */
1408
- onAuthorClick?: CommentProps["onAuthorClick"];
1409
- /**
1410
- * The event handler called when clicking on a mention.
1411
- */
1412
- onMentionClick?: CommentProps["onMentionClick"];
1413
- /**
1414
- * The event handler called when clicking on a comment's attachment.
1415
- */
1416
- onAttachmentClick?: CommentProps["onAttachmentClick"];
1417
- /**
1418
- * The event handler called when the composer is submitted.
1419
- */
1420
- onComposerSubmit?: ComposerProps["onComposerSubmit"];
1421
- /**
1422
- * Override the component's strings.
1423
- */
1424
- overrides?: Partial<GlobalOverrides & ThreadOverrides & CommentOverrides & ComposerOverrides>;
1425
- /**
1426
- * Override the component's components.
1427
- */
1428
- components?: Partial<GlobalComponents>;
1429
- }
1430
- /**
1431
- * Displays a thread of comments, with a composer to reply
1432
- * to it.
1433
- *
1434
- * @example
1435
- * <>
1436
- * {threads.map((thread) => (
1437
- * <Thread key={thread.id} thread={thread} />
1438
- * ))}
1439
- * </>
1440
- */
1441
- declare const Thread: <TM extends BaseMetadata = DTM, CM extends BaseMetadata = DCM>(props: ThreadProps<TM, CM> & RefAttributes<HTMLDivElement>) => JSX.Element;
1442
-
1443
1532
  type LiveblocksUiConfigProps = PropsWithChildren<{
1444
1533
  /**
1445
1534
  * Override the components' strings.
@@ -1639,4 +1728,4 @@ declare namespace icon {
1639
1728
  };
1640
1729
  }
1641
1730
 
1642
- export { AiChat, AiChatComponents, AiChatComponentsEmptyProps, AiChatComponentsLoadingProps, AiChatProps, AiComposerSubmitMessage, AiTool, AiToolIconProps, AiToolProps, Comment, CommentAttachmentArgs, CommentDropdownItemProps, CommentOverrides, CommentProps, Composer, ComposerBodyMark, ComposerBodyMarks, ComposerOverrides, ComposerProps, ComposerSubmitComment, GlobalOverrides, HistoryVersionSummary, HistoryVersionSummaryList, HistoryVersionSummaryListProps, HistoryVersionSummaryProps, icon as Icon, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationInspectorProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationOverrides, InboxNotificationProps, InboxNotificationTextMentionKindProps, InboxNotificationTextMentionProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUiConfig, LocalizationOverrides, Overrides, Thread, ThreadOverrides, ThreadProps, useOverrides };
1731
+ export { AiChat, AiChatComponents, AiChatComponentsEmptyProps, AiChatComponentsLoadingProps, AiChatProps, AiComposerSubmitMessage, AiTool, AiToolIconProps, AiToolProps, AvatarStack, AvatarStackProps, Comment, CommentAttachmentArgs, CommentDropdownItemProps, CommentOverrides, CommentPin, CommentPinProps, CommentProps, Composer, ComposerBodyMark, ComposerBodyMarks, ComposerOverrides, ComposerProps, ComposerSubmitComment, Cursor, CursorProps, Cursors, CursorsProps, FloatingComposer, FloatingComposerProps, FloatingThread, FloatingThreadProps, GlobalOverrides, HistoryVersionSummary, HistoryVersionSummaryList, HistoryVersionSummaryListProps, HistoryVersionSummaryProps, icon as Icon, InboxNotification, InboxNotificationAvatarProps, InboxNotificationCustomKindProps, InboxNotificationCustomProps, InboxNotificationIconProps, InboxNotificationInspectorProps, InboxNotificationList, InboxNotificationListProps, InboxNotificationOverrides, InboxNotificationProps, InboxNotificationTextMentionKindProps, InboxNotificationTextMentionProps, InboxNotificationThreadKindProps, InboxNotificationThreadProps, LiveblocksUiConfig, LocalizationOverrides, Overrides, Thread, ThreadOverrides, ThreadProps, useOverrides };
package/dist/index.js CHANGED
@@ -2,8 +2,14 @@ import { detectDupes } from '@liveblocks/core';
2
2
  import { PKG_NAME, PKG_VERSION, PKG_FORMAT } from './version.js';
3
3
  export { AiChat } from './components/AiChat.js';
4
4
  export { AiTool } from './components/AiTool.js';
5
+ export { AvatarStack } from './components/AvatarStack.js';
5
6
  export { Comment } from './components/Comment.js';
7
+ export { CommentPin } from './components/CommentPin.js';
6
8
  export { Composer } from './components/Composer.js';
9
+ export { Cursor } from './components/Cursor.js';
10
+ export { Cursors } from './components/Cursors.js';
11
+ export { FloatingComposer } from './components/FloatingComposer.js';
12
+ export { FloatingThread } from './components/FloatingThread.js';
7
13
  export { HistoryVersionSummary } from './components/HistoryVersionSummary.js';
8
14
  export { HistoryVersionSummaryList } from './components/HistoryVersionSummaryList.js';
9
15
  export { InboxNotification } from './components/InboxNotification.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 {\n AiChatComponents,\n AiChatComponentsEmptyProps,\n AiChatComponentsLoadingProps,\n AiChatProps,\n} from \"./components/AiChat\";\nexport { AiChat } from \"./components/AiChat\";\nexport type { AiToolIconProps, AiToolProps } from \"./components/AiTool\";\nexport { AiTool } from \"./components/AiTool\";\nexport type {\n CommentDropdownItemProps,\n CommentProps,\n} 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 InboxNotificationInspectorProps,\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 {\n AiComposerSubmitMessage,\n ComposerSubmitComment,\n} 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 type {\n AiChatComponents,\n AiChatComponentsEmptyProps,\n AiChatComponentsLoadingProps,\n AiChatProps,\n} from \"./components/AiChat\";\nexport { AiChat } from \"./components/AiChat\";\nexport type { AiToolIconProps, AiToolProps } from \"./components/AiTool\";\nexport { AiTool } from \"./components/AiTool\";\nexport type { AvatarStackProps } from \"./components/AvatarStack\";\nexport { AvatarStack } from \"./components/AvatarStack\";\nexport type {\n CommentDropdownItemProps,\n CommentProps,\n} from \"./components/Comment\";\nexport { Comment } from \"./components/Comment\";\nexport type { CommentPinProps } from \"./components/CommentPin\";\nexport { CommentPin } from \"./components/CommentPin\";\nexport type { ComposerProps } from \"./components/Composer\";\nexport { Composer } from \"./components/Composer\";\nexport type { CursorProps } from \"./components/Cursor\";\nexport { Cursor } from \"./components/Cursor\";\nexport type { CursorsProps } from \"./components/Cursors\";\nexport { Cursors } from \"./components/Cursors\";\nexport type { FloatingComposerProps } from \"./components/FloatingComposer\";\nexport { FloatingComposer } from \"./components/FloatingComposer\";\nexport type { FloatingThreadProps } from \"./components/FloatingThread\";\nexport { FloatingThread } from \"./components/FloatingThread\";\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 InboxNotificationInspectorProps,\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 {\n AiComposerSubmitMessage,\n ComposerSubmitComment,\n} from \"./primitives\";\nexport type {\n CommentAttachmentArgs,\n ComposerBodyMark,\n ComposerBodyMarks,\n} from \"./types\";\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,WAAY,CAAA,QAAA,EAAU,aAAa,UAAU,CAAA"}
@@ -4,7 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
4
4
  var core = require('@liveblocks/core');
5
5
  var react$1 = require('@liveblocks/react');
6
6
  var _private = require('@liveblocks/react/_private');
7
- var reactSlot = require('@radix-ui/react-slot');
7
+ var radixUi = require('radix-ui');
8
8
  var react = require('react');
9
9
  var slate = require('slate');
10
10
  var slateHistory = require('slate-history');
@@ -43,7 +43,7 @@ const AiComposerForm = react.forwardRef(
43
43
  asChild,
44
44
  ...props
45
45
  }, forwardedRef) => {
46
- const Component = asChild ? reactSlot.Slot : "form";
46
+ const Component = asChild ? radixUi.Slot.Slot : "form";
47
47
  const client = react$1.useClient();
48
48
  const formRef = react.useRef(null);
49
49
  const editor = useInitial.useInitial(
@@ -278,9 +278,11 @@ const AiComposerEditor = react.forwardRef(
278
278
  [editor]
279
279
  );
280
280
  _private.useLayoutEffect(() => {
281
- if (autoFocus) {
282
- focus();
281
+ if (!autoFocus) {
282
+ return;
283
283
  }
284
+ const timeout = setTimeout(() => focus(), 0);
285
+ return () => clearTimeout(timeout);
284
286
  }, [autoFocus, editor, focus]);
285
287
  _private.useLayoutEffect(() => {
286
288
  if (isFocused && editor.selection === null) {
@@ -300,6 +302,7 @@ const AiComposerEditor = react.forwardRef(
300
302
  slateReact.Editable,
301
303
  {
302
304
  dir,
305
+ tabIndex: isDisabled ? -1 : 0,
303
306
  enterKeyHint: "send",
304
307
  autoCapitalize: "sentences",
305
308
  "aria-label": "Composer editor",
@@ -319,7 +322,7 @@ const AiComposerEditor = react.forwardRef(
319
322
  }
320
323
  );
321
324
  const AiComposerSubmit = react.forwardRef(({ disabled, asChild, ...props }, forwardedRef) => {
322
- const Component = asChild ? reactSlot.Slot : "button";
325
+ const Component = asChild ? radixUi.Slot.Slot : "button";
323
326
  const { isDisabled: isComposerDisabled, canSubmit } = contexts.useAiComposer();
324
327
  const isDisabled = isComposerDisabled || disabled || !canSubmit;
325
328
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -333,7 +336,7 @@ const AiComposerSubmit = react.forwardRef(({ disabled, asChild, ...props }, forw
333
336
  );
334
337
  });
335
338
  const AiComposerAbort = react.forwardRef(({ disabled, onClick, asChild, ...props }, forwardedRef) => {
336
- const Component = asChild ? reactSlot.Slot : "button";
339
+ const Component = asChild ? radixUi.Slot.Slot : "button";
337
340
  const { isDisabled: isComposerDisabled, canAbort, abort } = contexts.useAiComposer();
338
341
  const isDisabled = isComposerDisabled || disabled || !canAbort;
339
342
  const handleClick = react.useCallback(
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/primitives/AiComposer/index.tsx"],"sourcesContent":["import {\n type AiChatMessage,\n kInternal,\n Signal,\n type WithNavigation,\n} from \"@liveblocks/core\";\nimport { useClient } from \"@liveblocks/react\";\nimport { useLayoutEffect, useSignal } from \"@liveblocks/react/_private\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport type { FocusEvent, FormEvent, KeyboardEvent, MouseEvent } from \"react\";\nimport {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n createEditor,\n Editor as SlateEditor,\n Transforms as SlateTransforms,\n} from \"slate\";\nimport { withHistory } from \"slate-history\";\nimport {\n Editable,\n ReactEditor,\n type RenderPlaceholderProps,\n Slate,\n withReact,\n} from \"slate-react\";\n\nimport type { AiComposerBody } from \"../../types\";\nimport { requestSubmit } from \"../../utils/request-submit\";\nimport { useInitial } from \"../../utils/use-initial\";\nimport { withNormalize } from \"../slate/plugins/normalize\";\nimport { getDOMRange } from \"../slate/utils/get-dom-range\";\nimport { isEmpty } from \"../slate/utils/is-empty\";\nimport {\n AiComposerContext,\n AiComposerEditorContext,\n useAiComposer,\n useAiComposerEditorContext,\n} from \"./contexts\";\nimport type {\n AiComposerEditorProps,\n AiComposerFormProps,\n AiComposerSubmitProps,\n} from \"./types\";\n\nconst AI_COMPOSER_SUBMIT_NAME = \"AiComposerSubmit\";\nconst AI_COMPOSER_ABORT_NAME = \"AiComposerAbort\";\nconst AI_COMPOSER_EDITOR_NAME = \"AiComposerEditor\";\nconst AI_COMPOSER_FORM_NAME = \"AiComposerForm\";\n\ntype UiChatMessage = WithNavigation<AiChatMessage>;\n\n/* -------------------------------------------------------------------------------------------------\n * Form\n * -----------------------------------------------------------------------------------------------*/\n\nconst emptyMessagesΣ = new Signal<UiChatMessage[]>([]);\n\nfunction getLastMessageId(messages: UiChatMessage[]) {\n const lastMessage = messages[messages.length - 1];\n\n if (lastMessage === undefined) {\n return null;\n }\n\n return lastMessage.id;\n}\n\nfunction getAbortableMessageId(messages: UiChatMessage[]) {\n return messages.find(\n (message) =>\n message.role === \"assistant\" &&\n (message.status === \"generating\" || message.status === \"awaiting-tool\")\n )?.id;\n}\n\n/**\n * Surrounds the AI composer's content and handles submissions.\n *\n * @example\n * <AiComposer.Form onComposerSubmit={({ text }) => {}}>\n *\t <AiComposer.Editor />\n * <AiComposer.Submit />\n * </AiComposer.Form>\n */\nexport const AiComposerForm = forwardRef<HTMLFormElement, AiComposerFormProps>(\n (\n {\n onComposerSubmit,\n onSubmit,\n disabled,\n chatId,\n branchId,\n asChild,\n ...props\n },\n forwardedRef\n ) => {\n const Component = asChild ? Slot : \"form\";\n const client = useClient();\n const formRef = useRef<HTMLFormElement | null>(null);\n const editor = useInitial(() =>\n withNormalize(withHistory(withReact(createEditor())))\n );\n const [isEditorEmpty, setEditorEmpty] = useState(true);\n const [isSubmitting, setSubmitting] = useState(false);\n const [isFocused, setFocused] = useState(false);\n const messagesΣ = chatId\n ? client[kInternal].ai.signals.getChatMessagesForBranchΣ(chatId, branchId)\n : emptyMessagesΣ;\n const lastMessageId = useSignal(messagesΣ, getLastMessageId);\n const abortableMessageId = useSignal(messagesΣ, getAbortableMessageId);\n const isAvailable = useSignal(\n // Subscribe to connection status signal\n client[kInternal].ai.signals.statusΣ,\n // \"Disconnected\" means the AI service is not available\n // as it represents a final error status.\n (status) => status !== \"disconnected\"\n );\n\n const isDisabled = isSubmitting || disabled === true;\n\n const canAbort = isAvailable && abortableMessageId !== undefined;\n const canSubmit = isAvailable && !isEditorEmpty && !canAbort;\n\n const clear = useCallback(() => {\n SlateTransforms.delete(editor, {\n at: {\n anchor: SlateEditor.start(editor, []),\n focus: SlateEditor.end(editor, []),\n },\n });\n }, [editor]);\n\n const select = useCallback(() => {\n SlateTransforms.select(editor, SlateEditor.end(editor, []));\n }, [editor]);\n\n const focus = useCallback(\n (resetSelection = true) => {\n try {\n // Slate's `ReactEditor.focus` method can use `setTimeout` internally\n // which prevents us from catching errors, so this is a reimplementation.\n // https://github.com/ianstormtaylor/slate/blob/main/packages/slate-dom/src/plugin/dom-editor.ts\n if (!ReactEditor.isFocused(editor)) {\n SlateTransforms.select(\n editor,\n resetSelection || !editor.selection\n ? SlateEditor.end(editor, [])\n : editor.selection\n );\n\n const element = ReactEditor.toDOMNode(editor, editor);\n\n if (editor.selection) {\n const domSelection = window.getSelection();\n const domRange = getDOMRange(editor, editor.selection);\n\n if (domRange) {\n domSelection?.removeAllRanges();\n domSelection?.addRange(domRange);\n }\n }\n\n element.focus({ preventScroll: true });\n }\n } catch {\n // Slate's DOM-specific methods will throw if the editor's DOM\n // node no longer exists. This action doesn't make sense on an\n // unmounted editor so we can safely ignore it.\n }\n },\n [editor]\n );\n\n const blur = useCallback(() => {\n try {\n ReactEditor.blur(editor);\n } catch {\n // Slate's DOM-specific methods will throw if the editor's DOM\n // node no longer exists. This action doesn't make sense on an\n // unmounted editor so we can safely ignore it.\n }\n }, [editor]);\n\n const onSubmitEnd = useCallback(() => {\n clear();\n setSubmitting(false);\n }, [clear]);\n\n const handleSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n if (disabled) {\n return;\n }\n\n // In some situations (e.g. pressing Enter while composing diacritics), it's possible\n // for the form to be submitted as empty even though we already checked whether the\n // editor was empty when handling the key press.\n const isEditorEmpty = isEmpty(editor, editor.children);\n\n // We even prevent the user's `onSubmit` handler from being called if the editor is empty.\n if (isEditorEmpty) {\n event.preventDefault();\n\n return;\n }\n\n onSubmit?.(event);\n\n if (onComposerSubmit === undefined || event.isDefaultPrevented()) {\n event.preventDefault();\n return;\n }\n\n // Extract the text content from the editor.\n const content = editor.children\n .map((block) => {\n if (\"type\" in block && block.type === \"paragraph\") {\n return block.children\n .map((child) => {\n if (\"text\" in child) {\n return child.text;\n }\n return \"\";\n })\n .join(\"\");\n }\n return \"\";\n })\n .join(\"\\n\");\n\n const promise = onComposerSubmit(\n { text: content, lastMessageId },\n event\n );\n\n event.preventDefault();\n\n if (promise) {\n setSubmitting(true);\n promise.then(onSubmitEnd);\n } else {\n onSubmitEnd();\n }\n },\n [disabled, editor, onSubmit, onComposerSubmit, onSubmitEnd, lastMessageId]\n );\n\n useLayoutEffect(() => {\n setEditorEmpty(isEmpty(editor, editor.children));\n }, [editor]);\n\n const handleEditorValueChange = useCallback(() => {\n setEditorEmpty(isEmpty(editor, editor.children));\n }, [editor]);\n\n const submit = useCallback(() => {\n if (!canSubmit) {\n return;\n }\n\n // We need to wait for the next frame in some cases like when composing diacritics,\n // we want any native handling to be done first while still being handled on `keydown`.\n requestAnimationFrame(() => {\n if (formRef.current) {\n requestSubmit(formRef.current);\n }\n });\n }, [canSubmit]);\n\n const abort = useCallback(() => {\n if (!canAbort || !abortableMessageId) {\n return;\n }\n\n client[kInternal].ai.abort(abortableMessageId);\n }, [canAbort, abortableMessageId, client]);\n\n useImperativeHandle<HTMLFormElement | null, HTMLFormElement | null>(\n forwardedRef,\n () => formRef.current,\n []\n );\n\n return (\n <AiComposerEditorContext.Provider\n value={{\n editor,\n onEditorValueChange: handleEditorValueChange,\n abortableMessageId,\n setFocused,\n }}\n >\n <AiComposerContext.Provider\n value={{\n isDisabled,\n isEmpty: isEditorEmpty,\n isFocused,\n canSubmit,\n canAbort,\n submit,\n abort,\n clear,\n focus,\n blur,\n select,\n }}\n >\n <Component onSubmit={handleSubmit} {...props} ref={formRef} />\n </AiComposerContext.Provider>\n </AiComposerEditorContext.Provider>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Editor\n * -----------------------------------------------------------------------------------------------*/\n\nfunction AiComposerEditorPlaceholder({\n attributes,\n children,\n}: RenderPlaceholderProps) {\n const { opacity: _opacity, ...style } = attributes.style;\n\n return (\n <span {...attributes} style={style} data-placeholder=\"\">\n {children}\n </span>\n );\n}\n\n/**\n * Displays the AI composer's editor.\n *\n * @example\n * <AiComposer.Editor placeholder=\"Write a message…\" />\n */\nconst AiComposerEditor = forwardRef<HTMLDivElement, AiComposerEditorProps>(\n (\n {\n defaultValue = \"\",\n onKeyDown,\n onFocus,\n onBlur,\n disabled,\n autoFocus,\n dir,\n ...props\n },\n forwardedRef\n ) => {\n const { editor, onEditorValueChange, setFocused } =\n useAiComposerEditorContext();\n const {\n submit,\n isDisabled: isComposerDisabled,\n isFocused,\n focus,\n blur,\n select,\n } = useAiComposer();\n const isDisabled = disabled || isComposerDisabled;\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.isDefaultPrevented()) return;\n\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n submit();\n } else if (event.key === \"Enter\" && event.shiftKey) {\n event.preventDefault();\n editor.insertBreak();\n } else if (event.key === \"Escape\") {\n blur();\n }\n },\n [editor, onKeyDown, submit, blur]\n );\n\n const handleFocus = useCallback(\n (event: FocusEvent<HTMLDivElement>) => {\n onFocus?.(event);\n\n if (!event.isDefaultPrevented()) {\n setFocused(true);\n }\n },\n [onFocus, setFocused]\n );\n\n const handleBlur = useCallback(\n (event: FocusEvent<HTMLDivElement>) => {\n onBlur?.(event);\n\n if (!event.isDefaultPrevented()) {\n setFocused(false);\n }\n },\n [onBlur, setFocused]\n );\n\n useImperativeHandle(\n forwardedRef,\n () => ReactEditor.toDOMNode(editor, editor) as HTMLDivElement,\n [editor]\n );\n\n // Manually focus the editor when `autoFocus` is true\n useLayoutEffect(() => {\n if (autoFocus) {\n focus();\n }\n }, [autoFocus, editor, focus]);\n\n // Manually add a selection in the editor if the selection\n // is still empty after being focused\n useLayoutEffect(() => {\n if (isFocused && editor.selection === null) {\n select();\n }\n }, [editor, select, isFocused]);\n\n const initialValue: AiComposerBody = useMemo(() => {\n return defaultValue\n .split(\"\\n\")\n .map((text) => ({ type: \"paragraph\", children: [{ text }] }));\n }, [defaultValue]);\n\n return (\n <Slate\n editor={editor}\n initialValue={initialValue}\n onValueChange={onEditorValueChange}\n >\n <Editable\n dir={dir}\n enterKeyHint=\"send\"\n autoCapitalize=\"sentences\"\n aria-label=\"Composer editor\"\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\n data-focused={isFocused || undefined}\n data-disabled={isDisabled || undefined}\n {...props}\n readOnly={isDisabled}\n disabled={isDisabled}\n renderPlaceholder={AiComposerEditorPlaceholder}\n />\n </Slate>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Submit\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * A button to submit the AI composer's content.\n *\n * @example\n * <AiComposer.Submit>Send</AiComposer.Submit>\n */\nexport const AiComposerSubmit = forwardRef<\n HTMLButtonElement,\n AiComposerSubmitProps\n>(({ disabled, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? Slot : \"button\";\n const { isDisabled: isComposerDisabled, canSubmit } = useAiComposer();\n const isDisabled = isComposerDisabled || disabled || !canSubmit;\n\n return (\n <Component\n type=\"submit\"\n {...props}\n ref={forwardedRef}\n disabled={isDisabled}\n />\n );\n});\n\n/* -------------------------------------------------------------------------------------------------\n * Abort\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * A button to abort a response related to the AI composer.\n *\n * @example\n * <AiComposer.Abort>Cancel</AiComposer.Abort>\n */\nexport const AiComposerAbort = forwardRef<\n HTMLButtonElement,\n AiComposerSubmitProps\n>(({ disabled, onClick, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? Slot : \"button\";\n const { isDisabled: isComposerDisabled, canAbort, abort } = useAiComposer();\n const isDisabled = isComposerDisabled || disabled || !canAbort;\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n abort();\n },\n [abort, onClick]\n );\n\n return (\n <Component\n type=\"button\"\n {...props}\n ref={forwardedRef}\n disabled={isDisabled}\n onClick={handleClick}\n />\n );\n});\n\nif (process.env.NODE_ENV !== \"production\") {\n AiComposerEditor.displayName = AI_COMPOSER_EDITOR_NAME;\n AiComposerForm.displayName = AI_COMPOSER_FORM_NAME;\n AiComposerSubmit.displayName = AI_COMPOSER_SUBMIT_NAME;\n AiComposerAbort.displayName = AI_COMPOSER_ABORT_NAME;\n}\n\n// NOTE: Every export from this file will be available publicly as AiComposer.*\nexport {\n AiComposerAbort as Abort,\n AiComposerEditor as Editor,\n AiComposerForm as Form,\n AiComposerSubmit as Submit,\n};\n"],"names":["Signal","forwardRef","Slot","useClient","useRef","useInitial","withNormalize","withHistory","withReact","createEditor","useState","kInternal","useSignal","useCallback","SlateTransforms","SlateEditor","ReactEditor","getDOMRange","isEditorEmpty","isEmpty","useLayoutEffect","requestSubmit","useImperativeHandle","jsx","AiComposerEditorContext","AiComposerContext","useAiComposerEditorContext","useAiComposer","useMemo","Slate","Editable"],"mappings":";;;;;;;;;;;;;;;;;;AAkDA,MAAM,uBAA0B,GAAA,kBAAA,CAAA;AAChC,MAAM,sBAAyB,GAAA,iBAAA,CAAA;AAC/B,MAAM,uBAA0B,GAAA,kBAAA,CAAA;AAChC,MAAM,qBAAwB,GAAA,gBAAA,CAAA;AAQ9B,MAAM,mBAAiB,GAAA,IAAIA,WAAwB,CAAA,EAAE,CAAA,CAAA;AAErD,SAAS,iBAAiB,QAA2B,EAAA;AACnD,EAAA,MAAM,WAAc,GAAA,QAAA,CAAS,QAAS,CAAA,MAAA,GAAS,CAAC,CAAA,CAAA;AAEhD,EAAA,IAAI,gBAAgB,KAAW,CAAA,EAAA;AAC7B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,OAAO,WAAY,CAAA,EAAA,CAAA;AACrB,CAAA;AAEA,SAAS,sBAAsB,QAA2B,EAAA;AACxD,EAAA,OAAO,QAAS,CAAA,IAAA;AAAA,IACd,CAAC,YACC,OAAQ,CAAA,IAAA,KAAS,gBAChB,OAAQ,CAAA,MAAA,KAAW,YAAgB,IAAA,OAAA,CAAQ,MAAW,KAAA,eAAA,CAAA;AAAA,GACxD,EAAA,EAAA,CAAA;AACL,CAAA;AAWO,MAAM,cAAiB,GAAAC,gBAAA;AAAA,EAC5B,CACE;AAAA,IACE,gBAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,GAAG,KAAA;AAAA,KAE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;AAEA,EACE,uBAAAU,cAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,IAAK,EAAA,QAAA;AAAA,MACJ,GAAG,KAAA;AAAA,MACJ,GAAK,EAAA,YAAA;AAAA,MACL,QAAU,EAAA,UAAA;AAAA,MACV,OAAS,EAAA,WAAA;AAAA,KAAA;AAAA,GACX,CAAA;AAEJ,CAAC,EAAA;AAED,IAAI,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,YAAc,EAAA;AACzC,EAAA,gBAAA,CAAiB,WAAc,GAAA,uBAAA,CAAA;AAC/B,EAAA,cAAA,CAAe,WAAc,GAAA,qBAAA,CAAA;AAC7B,EAAA,gBAAA,CAAiB,WAAc,GAAA,uBAAA,CAAA;AAC/B,EAAA,eAAA,CAAgB,WAAc,GAAA,sBAAA,CAAA;AAChC;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/primitives/AiComposer/index.tsx"],"sourcesContent":["import {\n type AiChatMessage,\n kInternal,\n Signal,\n type WithNavigation,\n} from \"@liveblocks/core\";\nimport { useClient } from \"@liveblocks/react\";\nimport { useLayoutEffect, useSignal } from \"@liveblocks/react/_private\";\nimport { Slot as SlotPrimitive } from \"radix-ui\";\nimport type { FocusEvent, FormEvent, KeyboardEvent, MouseEvent } from \"react\";\nimport {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n createEditor,\n Editor as SlateEditor,\n Transforms as SlateTransforms,\n} from \"slate\";\nimport { withHistory } from \"slate-history\";\nimport {\n Editable,\n ReactEditor,\n type RenderPlaceholderProps,\n Slate,\n withReact,\n} from \"slate-react\";\n\nimport type { AiComposerBody } from \"../../types\";\nimport { requestSubmit } from \"../../utils/request-submit\";\nimport { useInitial } from \"../../utils/use-initial\";\nimport { withNormalize } from \"../slate/plugins/normalize\";\nimport { getDOMRange } from \"../slate/utils/get-dom-range\";\nimport { isEmpty } from \"../slate/utils/is-empty\";\nimport {\n AiComposerContext,\n AiComposerEditorContext,\n useAiComposer,\n useAiComposerEditorContext,\n} from \"./contexts\";\nimport type {\n AiComposerEditorProps,\n AiComposerFormProps,\n AiComposerSubmitProps,\n} from \"./types\";\n\nconst AI_COMPOSER_SUBMIT_NAME = \"AiComposerSubmit\";\nconst AI_COMPOSER_ABORT_NAME = \"AiComposerAbort\";\nconst AI_COMPOSER_EDITOR_NAME = \"AiComposerEditor\";\nconst AI_COMPOSER_FORM_NAME = \"AiComposerForm\";\n\ntype UiChatMessage = WithNavigation<AiChatMessage>;\n\n/* -------------------------------------------------------------------------------------------------\n * Form\n * -----------------------------------------------------------------------------------------------*/\n\nconst emptyMessagesΣ = new Signal<UiChatMessage[]>([]);\n\nfunction getLastMessageId(messages: UiChatMessage[]) {\n const lastMessage = messages[messages.length - 1];\n\n if (lastMessage === undefined) {\n return null;\n }\n\n return lastMessage.id;\n}\n\nfunction getAbortableMessageId(messages: UiChatMessage[]) {\n return messages.find(\n (message) =>\n message.role === \"assistant\" &&\n (message.status === \"generating\" || message.status === \"awaiting-tool\")\n )?.id;\n}\n\n/**\n * Surrounds the AI composer's content and handles submissions.\n *\n * @example\n * <AiComposer.Form onComposerSubmit={({ text }) => {}}>\n *\t <AiComposer.Editor />\n * <AiComposer.Submit />\n * </AiComposer.Form>\n */\nexport const AiComposerForm = forwardRef<HTMLFormElement, AiComposerFormProps>(\n (\n {\n onComposerSubmit,\n onSubmit,\n disabled,\n chatId,\n branchId,\n asChild,\n ...props\n },\n forwardedRef\n ) => {\n const Component = asChild ? SlotPrimitive.Slot : \"form\";\n const client = useClient();\n const formRef = useRef<HTMLFormElement | null>(null);\n const editor = useInitial(() =>\n withNormalize(withHistory(withReact(createEditor())))\n );\n const [isEditorEmpty, setEditorEmpty] = useState(true);\n const [isSubmitting, setSubmitting] = useState(false);\n const [isFocused, setFocused] = useState(false);\n const messagesΣ = chatId\n ? client[kInternal].ai.signals.getChatMessagesForBranchΣ(chatId, branchId)\n : emptyMessagesΣ;\n const lastMessageId = useSignal(messagesΣ, getLastMessageId);\n const abortableMessageId = useSignal(messagesΣ, getAbortableMessageId);\n const isAvailable = useSignal(\n // Subscribe to connection status signal\n client[kInternal].ai.signals.statusΣ,\n // \"Disconnected\" means the AI service is not available\n // as it represents a final error status.\n (status) => status !== \"disconnected\"\n );\n\n const isDisabled = isSubmitting || disabled === true;\n\n const canAbort = isAvailable && abortableMessageId !== undefined;\n const canSubmit = isAvailable && !isEditorEmpty && !canAbort;\n\n const clear = useCallback(() => {\n SlateTransforms.delete(editor, {\n at: {\n anchor: SlateEditor.start(editor, []),\n focus: SlateEditor.end(editor, []),\n },\n });\n }, [editor]);\n\n const select = useCallback(() => {\n SlateTransforms.select(editor, SlateEditor.end(editor, []));\n }, [editor]);\n\n const focus = useCallback(\n (resetSelection = true) => {\n try {\n // Slate's `ReactEditor.focus` method can use `setTimeout` internally\n // which prevents us from catching errors, so this is a reimplementation.\n // https://github.com/ianstormtaylor/slate/blob/main/packages/slate-dom/src/plugin/dom-editor.ts\n if (!ReactEditor.isFocused(editor)) {\n SlateTransforms.select(\n editor,\n resetSelection || !editor.selection\n ? SlateEditor.end(editor, [])\n : editor.selection\n );\n\n const element = ReactEditor.toDOMNode(editor, editor);\n\n if (editor.selection) {\n const domSelection = window.getSelection();\n const domRange = getDOMRange(editor, editor.selection);\n\n if (domRange) {\n domSelection?.removeAllRanges();\n domSelection?.addRange(domRange);\n }\n }\n\n element.focus({ preventScroll: true });\n }\n } catch {\n // Slate's DOM-specific methods will throw if the editor's DOM\n // node no longer exists. This action doesn't make sense on an\n // unmounted editor so we can safely ignore it.\n }\n },\n [editor]\n );\n\n const blur = useCallback(() => {\n try {\n ReactEditor.blur(editor);\n } catch {\n // Slate's DOM-specific methods will throw if the editor's DOM\n // node no longer exists. This action doesn't make sense on an\n // unmounted editor so we can safely ignore it.\n }\n }, [editor]);\n\n const onSubmitEnd = useCallback(() => {\n clear();\n setSubmitting(false);\n }, [clear]);\n\n const handleSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n if (disabled) {\n return;\n }\n\n // In some situations (e.g. pressing Enter while composing diacritics), it's possible\n // for the form to be submitted as empty even though we already checked whether the\n // editor was empty when handling the key press.\n const isEditorEmpty = isEmpty(editor, editor.children);\n\n // We even prevent the user's `onSubmit` handler from being called if the editor is empty.\n if (isEditorEmpty) {\n event.preventDefault();\n\n return;\n }\n\n onSubmit?.(event);\n\n if (onComposerSubmit === undefined || event.isDefaultPrevented()) {\n event.preventDefault();\n return;\n }\n\n // Extract the text content from the editor.\n const content = editor.children\n .map((block) => {\n if (\"type\" in block && block.type === \"paragraph\") {\n return block.children\n .map((child) => {\n if (\"text\" in child) {\n return child.text;\n }\n return \"\";\n })\n .join(\"\");\n }\n return \"\";\n })\n .join(\"\\n\");\n\n const promise = onComposerSubmit(\n { text: content, lastMessageId },\n event\n );\n\n event.preventDefault();\n\n if (promise) {\n setSubmitting(true);\n promise.then(onSubmitEnd);\n } else {\n onSubmitEnd();\n }\n },\n [disabled, editor, onSubmit, onComposerSubmit, onSubmitEnd, lastMessageId]\n );\n\n useLayoutEffect(() => {\n setEditorEmpty(isEmpty(editor, editor.children));\n }, [editor]);\n\n const handleEditorValueChange = useCallback(() => {\n setEditorEmpty(isEmpty(editor, editor.children));\n }, [editor]);\n\n const submit = useCallback(() => {\n if (!canSubmit) {\n return;\n }\n\n // We need to wait for the next frame in some cases like when composing diacritics,\n // we want any native handling to be done first while still being handled on `keydown`.\n requestAnimationFrame(() => {\n if (formRef.current) {\n requestSubmit(formRef.current);\n }\n });\n }, [canSubmit]);\n\n const abort = useCallback(() => {\n if (!canAbort || !abortableMessageId) {\n return;\n }\n\n client[kInternal].ai.abort(abortableMessageId);\n }, [canAbort, abortableMessageId, client]);\n\n useImperativeHandle<HTMLFormElement | null, HTMLFormElement | null>(\n forwardedRef,\n () => formRef.current,\n []\n );\n\n return (\n <AiComposerEditorContext.Provider\n value={{\n editor,\n onEditorValueChange: handleEditorValueChange,\n abortableMessageId,\n setFocused,\n }}\n >\n <AiComposerContext.Provider\n value={{\n isDisabled,\n isEmpty: isEditorEmpty,\n isFocused,\n canSubmit,\n canAbort,\n submit,\n abort,\n clear,\n focus,\n blur,\n select,\n }}\n >\n <Component onSubmit={handleSubmit} {...props} ref={formRef} />\n </AiComposerContext.Provider>\n </AiComposerEditorContext.Provider>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Editor\n * -----------------------------------------------------------------------------------------------*/\n\nfunction AiComposerEditorPlaceholder({\n attributes,\n children,\n}: RenderPlaceholderProps) {\n const { opacity: _opacity, ...style } = attributes.style;\n\n return (\n <span {...attributes} style={style} data-placeholder=\"\">\n {children}\n </span>\n );\n}\n\n/**\n * Displays the AI composer's editor.\n *\n * @example\n * <AiComposer.Editor placeholder=\"Write a message…\" />\n */\nconst AiComposerEditor = forwardRef<HTMLDivElement, AiComposerEditorProps>(\n (\n {\n defaultValue = \"\",\n onKeyDown,\n onFocus,\n onBlur,\n disabled,\n autoFocus,\n dir,\n ...props\n },\n forwardedRef\n ) => {\n const { editor, onEditorValueChange, setFocused } =\n useAiComposerEditorContext();\n const {\n submit,\n isDisabled: isComposerDisabled,\n isFocused,\n focus,\n blur,\n select,\n } = useAiComposer();\n const isDisabled = disabled || isComposerDisabled;\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.isDefaultPrevented()) return;\n\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n submit();\n } else if (event.key === \"Enter\" && event.shiftKey) {\n event.preventDefault();\n editor.insertBreak();\n } else if (event.key === \"Escape\") {\n blur();\n }\n },\n [editor, onKeyDown, submit, blur]\n );\n\n const handleFocus = useCallback(\n (event: FocusEvent<HTMLDivElement>) => {\n onFocus?.(event);\n\n if (!event.isDefaultPrevented()) {\n setFocused(true);\n }\n },\n [onFocus, setFocused]\n );\n\n const handleBlur = useCallback(\n (event: FocusEvent<HTMLDivElement>) => {\n onBlur?.(event);\n\n if (!event.isDefaultPrevented()) {\n setFocused(false);\n }\n },\n [onBlur, setFocused]\n );\n\n useImperativeHandle(\n forwardedRef,\n () => ReactEditor.toDOMNode(editor, editor) as HTMLDivElement,\n [editor]\n );\n\n // Manually focus the editor when `autoFocus` is true\n useLayoutEffect(() => {\n if (!autoFocus) {\n return;\n }\n\n // `focus` needs to be synchronous to ensure its errors can be caught\n // but the triggering of `focus` on mount itself can be asynchronous.\n // This brings back the same timing behavior as Slate's `ReactEditor.focus`\n // (which uses `setTimeout` internally) while still allowing us to catch errors.\n const timeout = setTimeout(() => focus(), 0);\n\n return () => clearTimeout(timeout);\n }, [autoFocus, editor, focus]);\n\n // Manually add a selection in the editor if the selection\n // is still empty after being focused\n useLayoutEffect(() => {\n if (isFocused && editor.selection === null) {\n select();\n }\n }, [editor, select, isFocused]);\n\n const initialValue: AiComposerBody = useMemo(() => {\n return defaultValue\n .split(\"\\n\")\n .map((text) => ({ type: \"paragraph\", children: [{ text }] }));\n }, [defaultValue]);\n\n return (\n <Slate\n editor={editor}\n initialValue={initialValue}\n onValueChange={onEditorValueChange}\n >\n <Editable\n dir={dir}\n tabIndex={isDisabled ? -1 : 0}\n enterKeyHint=\"send\"\n autoCapitalize=\"sentences\"\n aria-label=\"Composer editor\"\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\n data-focused={isFocused || undefined}\n data-disabled={isDisabled || undefined}\n {...props}\n readOnly={isDisabled}\n disabled={isDisabled}\n renderPlaceholder={AiComposerEditorPlaceholder}\n />\n </Slate>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Submit\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * A button to submit the AI composer's content.\n *\n * @example\n * <AiComposer.Submit>Send</AiComposer.Submit>\n */\nexport const AiComposerSubmit = forwardRef<\n HTMLButtonElement,\n AiComposerSubmitProps\n>(({ disabled, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? SlotPrimitive.Slot : \"button\";\n const { isDisabled: isComposerDisabled, canSubmit } = useAiComposer();\n const isDisabled = isComposerDisabled || disabled || !canSubmit;\n\n return (\n <Component\n type=\"submit\"\n {...props}\n ref={forwardedRef}\n disabled={isDisabled}\n />\n );\n});\n\n/* -------------------------------------------------------------------------------------------------\n * Abort\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * A button to abort a response related to the AI composer.\n *\n * @example\n * <AiComposer.Abort>Cancel</AiComposer.Abort>\n */\nexport const AiComposerAbort = forwardRef<\n HTMLButtonElement,\n AiComposerSubmitProps\n>(({ disabled, onClick, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? SlotPrimitive.Slot : \"button\";\n const { isDisabled: isComposerDisabled, canAbort, abort } = useAiComposer();\n const isDisabled = isComposerDisabled || disabled || !canAbort;\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n abort();\n },\n [abort, onClick]\n );\n\n return (\n <Component\n type=\"button\"\n {...props}\n ref={forwardedRef}\n disabled={isDisabled}\n onClick={handleClick}\n />\n );\n});\n\nif (process.env.NODE_ENV !== \"production\") {\n AiComposerEditor.displayName = AI_COMPOSER_EDITOR_NAME;\n AiComposerForm.displayName = AI_COMPOSER_FORM_NAME;\n AiComposerSubmit.displayName = AI_COMPOSER_SUBMIT_NAME;\n AiComposerAbort.displayName = AI_COMPOSER_ABORT_NAME;\n}\n\n// NOTE: Every export from this file will be available publicly as AiComposer.*\nexport {\n AiComposerAbort as Abort,\n AiComposerEditor as Editor,\n AiComposerForm as Form,\n AiComposerSubmit as Submit,\n};\n"],"names":["Signal","forwardRef","SlotPrimitive","useClient","useRef","useInitial","withNormalize","withHistory","withReact","createEditor","useState","kInternal","useSignal","useCallback","SlateTransforms","SlateEditor","ReactEditor","getDOMRange","isEditorEmpty","isEmpty","useLayoutEffect","requestSubmit","useImperativeHandle","jsx","AiComposerEditorContext","AiComposerContext","useAiCom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AAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,IAAK,EAAA,QAAA;AAAA,MACJ,GAAG,KAAA;AAAA,MACJ,GAAK,EAAA,YAAA;AAAA,MACL,QAAU,EAAA,UAAA;AAAA,MACV,OAAS,EAAA,WAAA;AAAA,KAAA;AAAA,GACX,CAAA;AAEJ,CAAC,EAAA;AAED,IAAI,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,YAAc,EAAA;AACzC,EAAA,gBAAA,CAAiB,WAAc,GAAA,uBAAA,CAAA;AAC/B,EAAA,cAAA,CAAe,WAAc,GAAA,qBAAA,CAAA;AAC7B,EAAA,gBAAA,CAAiB,WAAc,GAAA,uBAAA,CAAA;AAC/B,EAAA,eAAA,CAAgB,WAAc,GAAA,sBAAA,CAAA;AAChC;;;;;;;;;;"}
@@ -2,7 +2,7 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import { Signal, kInternal } from '@liveblocks/core';
3
3
  import { useClient } from '@liveblocks/react';
4
4
  import { useSignal, useLayoutEffect } from '@liveblocks/react/_private';
5
- import { Slot } from '@radix-ui/react-slot';
5
+ import { Slot } from 'radix-ui';
6
6
  import { forwardRef, useRef, useState, useCallback, useImperativeHandle, useMemo } from 'react';
7
7
  import { createEditor, Transforms, Editor } from 'slate';
8
8
  import { withHistory } from 'slate-history';
@@ -41,7 +41,7 @@ const AiComposerForm = forwardRef(
41
41
  asChild,
42
42
  ...props
43
43
  }, forwardedRef) => {
44
- const Component = asChild ? Slot : "form";
44
+ const Component = asChild ? Slot.Slot : "form";
45
45
  const client = useClient();
46
46
  const formRef = useRef(null);
47
47
  const editor = useInitial(
@@ -276,9 +276,11 @@ const AiComposerEditor = forwardRef(
276
276
  [editor]
277
277
  );
278
278
  useLayoutEffect(() => {
279
- if (autoFocus) {
280
- focus();
279
+ if (!autoFocus) {
280
+ return;
281
281
  }
282
+ const timeout = setTimeout(() => focus(), 0);
283
+ return () => clearTimeout(timeout);
282
284
  }, [autoFocus, editor, focus]);
283
285
  useLayoutEffect(() => {
284
286
  if (isFocused && editor.selection === null) {
@@ -298,6 +300,7 @@ const AiComposerEditor = forwardRef(
298
300
  Editable,
299
301
  {
300
302
  dir,
303
+ tabIndex: isDisabled ? -1 : 0,
301
304
  enterKeyHint: "send",
302
305
  autoCapitalize: "sentences",
303
306
  "aria-label": "Composer editor",
@@ -317,7 +320,7 @@ const AiComposerEditor = forwardRef(
317
320
  }
318
321
  );
319
322
  const AiComposerSubmit = forwardRef(({ disabled, asChild, ...props }, forwardedRef) => {
320
- const Component = asChild ? Slot : "button";
323
+ const Component = asChild ? Slot.Slot : "button";
321
324
  const { isDisabled: isComposerDisabled, canSubmit } = useAiComposer();
322
325
  const isDisabled = isComposerDisabled || disabled || !canSubmit;
323
326
  return /* @__PURE__ */ jsx(
@@ -331,7 +334,7 @@ const AiComposerSubmit = forwardRef(({ disabled, asChild, ...props }, forwardedR
331
334
  );
332
335
  });
333
336
  const AiComposerAbort = forwardRef(({ disabled, onClick, asChild, ...props }, forwardedRef) => {
334
- const Component = asChild ? Slot : "button";
337
+ const Component = asChild ? Slot.Slot : "button";
335
338
  const { isDisabled: isComposerDisabled, canAbort, abort } = useAiComposer();
336
339
  const isDisabled = isComposerDisabled || disabled || !canAbort;
337
340
  const handleClick = useCallback(