@assistant-ui/react 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -522,7 +522,7 @@ var useActionBarCopy = ({
522
522
  const hasCopyableContent = useCombinedStore(
523
523
  [useMessage, useEditComposer],
524
524
  (m, c) => {
525
- return !c.isEditing && m.message.content.some((c2) => c2.type === "text");
525
+ return !c.isEditing && m.message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
526
526
  }
527
527
  );
528
528
  const callback = useCallback4(() => {
@@ -695,7 +695,7 @@ var useContentPartText = () => {
695
695
  throw new Error(
696
696
  "ContentPartText can only be used inside text content parts."
697
697
  );
698
- return c.part.text;
698
+ return c;
699
699
  });
700
700
  return text;
701
701
  };
@@ -871,6 +871,7 @@ var ActionBarPrimitiveEdit = createActionButton(
871
871
  // src/primitives/assistantModal/index.ts
872
872
  var assistantModal_exports = {};
873
873
  __export(assistantModal_exports, {
874
+ Anchor: () => AssistantModalPrimitiveAnchor,
874
875
  Content: () => AssistantModalPrimitiveContent,
875
876
  Root: () => AssistantModalPrimitiveRoot,
876
877
  Trigger: () => AssistantModalPrimitiveTrigger
@@ -977,6 +978,21 @@ var AssistantModalPrimitiveContent = forwardRef4(
977
978
  );
978
979
  AssistantModalPrimitiveContent.displayName = "AssistantModalPrimitive.Content";
979
980
 
981
+ // src/primitives/assistantModal/AssistantModalAnchor.tsx
982
+ import { forwardRef as forwardRef5 } from "react";
983
+ import * as PopoverPrimitive5 from "@radix-ui/react-popover";
984
+ import { jsx as jsx9 } from "react/jsx-runtime";
985
+ var AssistantModalPrimitiveAnchor = forwardRef5(
986
+ ({
987
+ __scopeAssistantModal,
988
+ ...rest
989
+ }, ref) => {
990
+ const scope = usePopoverScope(__scopeAssistantModal);
991
+ return /* @__PURE__ */ jsx9(PopoverPrimitive5.Anchor, { ...scope, ...rest, ref });
992
+ }
993
+ );
994
+ AssistantModalPrimitiveAnchor.displayName = "AssistantModalPrimitive.Anchor";
995
+
980
996
  // src/primitives/branchPicker/index.ts
981
997
  var branchPicker_exports = {};
982
998
  __export(branchPicker_exports, {
@@ -1000,24 +1016,24 @@ var BranchPickerPrevious = createActionButton(
1000
1016
  );
1001
1017
 
1002
1018
  // src/primitives/branchPicker/BranchPickerCount.tsx
1003
- import { Fragment, jsx as jsx9 } from "react/jsx-runtime";
1019
+ import { Fragment, jsx as jsx10 } from "react/jsx-runtime";
1004
1020
  var BranchPickerPrimitiveCount = () => {
1005
1021
  const branchCount = useBranchPickerCount();
1006
- return /* @__PURE__ */ jsx9(Fragment, { children: branchCount });
1022
+ return /* @__PURE__ */ jsx10(Fragment, { children: branchCount });
1007
1023
  };
1008
1024
  BranchPickerPrimitiveCount.displayName = "BranchPickerPrimitive.Count";
1009
1025
 
1010
1026
  // src/primitives/branchPicker/BranchPickerNumber.tsx
1011
- import { Fragment as Fragment2, jsx as jsx10 } from "react/jsx-runtime";
1027
+ import { Fragment as Fragment2, jsx as jsx11 } from "react/jsx-runtime";
1012
1028
  var BranchPickerPrimitiveNumber = () => {
1013
1029
  const branchNumber = useBranchPickerNumber();
1014
- return /* @__PURE__ */ jsx10(Fragment2, { children: branchNumber });
1030
+ return /* @__PURE__ */ jsx11(Fragment2, { children: branchNumber });
1015
1031
  };
1016
1032
  BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
1017
1033
 
1018
1034
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1019
1035
  import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
1020
- import { forwardRef as forwardRef8 } from "react";
1036
+ import { forwardRef as forwardRef9 } from "react";
1021
1037
 
1022
1038
  // src/primitives/message/index.ts
1023
1039
  var message_exports = {};
@@ -1029,28 +1045,60 @@ __export(message_exports, {
1029
1045
  });
1030
1046
 
1031
1047
  // src/primitives/message/MessageRoot.tsx
1032
- import { composeEventHandlers as composeEventHandlers4 } from "@radix-ui/primitive";
1033
1048
  import { Primitive as Primitive3 } from "@radix-ui/react-primitive";
1034
- import { forwardRef as forwardRef5 } from "react";
1035
- import { jsx as jsx11 } from "react/jsx-runtime";
1036
- var MessagePrimitiveRoot = forwardRef5(({ onMouseEnter, onMouseLeave, ...rest }, ref) => {
1049
+ import {
1050
+ forwardRef as forwardRef6,
1051
+ useCallback as useCallback14
1052
+ } from "react";
1053
+
1054
+ // src/utils/hooks/useManagedRef.ts
1055
+ import { useCallback as useCallback13, useRef as useRef3 } from "react";
1056
+ var useManagedRef = (callback) => {
1057
+ const cleanupRef = useRef3();
1058
+ const ref = useCallback13(
1059
+ (el) => {
1060
+ if (cleanupRef.current) {
1061
+ cleanupRef.current();
1062
+ }
1063
+ if (el) {
1064
+ cleanupRef.current = callback(el);
1065
+ }
1066
+ },
1067
+ [callback]
1068
+ );
1069
+ return ref;
1070
+ };
1071
+
1072
+ // src/primitives/message/MessageRoot.tsx
1073
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
1074
+ import { jsx as jsx12 } from "react/jsx-runtime";
1075
+ var useIsHoveringRef = () => {
1037
1076
  const { useMessageUtils } = useMessageContext();
1038
- const setIsHovering = useMessageUtils((s) => s.setIsHovering);
1039
- const handleMouseEnter = () => {
1040
- setIsHovering(true);
1041
- };
1042
- const handleMouseLeave = () => {
1043
- setIsHovering(false);
1044
- };
1045
- return /* @__PURE__ */ jsx11(
1046
- Primitive3.div,
1047
- {
1048
- ...rest,
1049
- ref,
1050
- onMouseEnter: composeEventHandlers4(onMouseEnter, handleMouseEnter),
1051
- onMouseLeave: composeEventHandlers4(onMouseLeave, handleMouseLeave)
1052
- }
1077
+ const callbackRef = useCallback14(
1078
+ (el) => {
1079
+ const setIsHovering = useMessageUtils.getState().setIsHovering;
1080
+ const handleMouseEnter = () => {
1081
+ setIsHovering(true);
1082
+ };
1083
+ const handleMouseLeave = () => {
1084
+ setIsHovering(false);
1085
+ };
1086
+ el.addEventListener("mouseenter", handleMouseEnter);
1087
+ el.addEventListener("mouseleave", handleMouseLeave);
1088
+ return () => {
1089
+ el.removeEventListener("mouseenter", handleMouseEnter);
1090
+ el.removeEventListener("mouseleave", handleMouseLeave);
1091
+ setIsHovering(false);
1092
+ };
1093
+ },
1094
+ [useMessageUtils]
1053
1095
  );
1096
+ return useManagedRef(callbackRef);
1097
+ };
1098
+ var MessagePrimitiveRoot = forwardRef6(({ onMouseEnter, onMouseLeave, ...rest }, forwardRef15) => {
1099
+ const isHoveringRef = useIsHoveringRef();
1100
+ const ref = useComposedRefs(forwardRef15, isHoveringRef);
1101
+ return /* @__PURE__ */ jsx12(Primitive3.div, { ...rest, ref });
1054
1102
  });
1055
1103
  MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
1056
1104
 
@@ -1070,7 +1118,7 @@ import { memo as memo2 } from "react";
1070
1118
  // src/context/providers/ContentPartProvider.tsx
1071
1119
  import { useEffect as useEffect7, useState as useState4 } from "react";
1072
1120
  import { create as create9 } from "zustand";
1073
- import { jsx as jsx12 } from "react/jsx-runtime";
1121
+ import { jsx as jsx13 } from "react/jsx-runtime";
1074
1122
  var syncContentPart = ({ message }, useContentPart, partIndex) => {
1075
1123
  const part = message.content[partIndex];
1076
1124
  if (!part) return;
@@ -1107,9 +1155,32 @@ var ContentPartProvider = ({
1107
1155
  children
1108
1156
  }) => {
1109
1157
  const context = useContentPartContext2(partIndex);
1110
- return /* @__PURE__ */ jsx12(ContentPartContext.Provider, { value: context, children });
1158
+ return /* @__PURE__ */ jsx13(ContentPartContext.Provider, { value: context, children });
1111
1159
  };
1112
1160
 
1161
+ // src/primitives/contentPart/ContentPartText.tsx
1162
+ import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
1163
+ import { forwardRef as forwardRef7 } from "react";
1164
+ import { jsx as jsx14 } from "react/jsx-runtime";
1165
+ var ContentPartPrimitiveText = forwardRef7((props, forwardedRef) => {
1166
+ const {
1167
+ part: { text },
1168
+ status
1169
+ } = useContentPartText();
1170
+ return /* @__PURE__ */ jsx14(Primitive4.span, { "data-status": status, ...props, ref: forwardedRef, children: text });
1171
+ });
1172
+ ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
1173
+
1174
+ // src/primitives/contentPart/ContentPartImage.tsx
1175
+ import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
1176
+ import { forwardRef as forwardRef8 } from "react";
1177
+ import { jsx as jsx15 } from "react/jsx-runtime";
1178
+ var ContentPartPrimitiveImage = forwardRef8((props, forwardedRef) => {
1179
+ const image = useContentPartImage();
1180
+ return /* @__PURE__ */ jsx15(Primitive5.img, { src: image, ...props, ref: forwardedRef });
1181
+ });
1182
+ ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
1183
+
1113
1184
  // src/primitives/contentPart/ContentPartDisplay.tsx
1114
1185
  var ContentPartPrimitiveDisplay = () => {
1115
1186
  const display = useContentPartDisplay();
@@ -1117,54 +1188,24 @@ var ContentPartPrimitiveDisplay = () => {
1117
1188
  };
1118
1189
  ContentPartPrimitiveDisplay.displayName = "ContentPartPrimitive.Display";
1119
1190
 
1120
- // src/utils/OutPortal.tsx
1121
- import { useLayoutEffect, useRef as useRef3 } from "react";
1122
- import { jsx as jsx13 } from "react/jsx-runtime";
1123
- var OutPortal = ({ node }) => {
1124
- const parentRef = useRef3(null);
1125
- useLayoutEffect(() => {
1126
- const parent = parentRef.current;
1127
- if (!parent || !node) return;
1128
- parent.appendChild(node);
1129
- return () => {
1130
- parent.removeChild(node);
1131
- };
1132
- }, [node]);
1133
- if (!node) return null;
1134
- return /* @__PURE__ */ jsx13("span", { ref: parentRef });
1135
- };
1136
-
1137
- // src/primitives/contentPart/ContentPartInProgressIndicator.tsx
1138
- import { jsx as jsx14 } from "react/jsx-runtime";
1139
- var ContentPartPrimitiveInProgressIndicator = () => {
1140
- const { useMessageUtils } = useMessageContext();
1191
+ // src/primitives/contentPart/ContentPartInProgress.tsx
1192
+ var ContentPartPrimitiveInProgress = ({
1193
+ children
1194
+ }) => {
1141
1195
  const { useContentPart } = useContentPartContext();
1142
- const indicator = useCombinedStore(
1143
- [useMessageUtils, useContentPart],
1144
- (m, c) => c.status === "in_progress" ? m.inProgressIndicator : null
1145
- );
1146
- return /* @__PURE__ */ jsx14(OutPortal, { node: indicator });
1196
+ const isInProgress = useContentPart((c) => c.status === "in_progress");
1197
+ return isInProgress ? children : null;
1147
1198
  };
1148
- ContentPartPrimitiveInProgressIndicator.displayName = "ContentPartPrimitive.InProgressIndicator";
1149
-
1150
- // src/primitives/contentPart/ContentPartText.tsx
1151
- import { Primitive as Primitive4 } from "@radix-ui/react-primitive";
1152
- import { forwardRef as forwardRef6 } from "react";
1153
- import { jsx as jsx15 } from "react/jsx-runtime";
1154
- var ContentPartPrimitiveText = forwardRef6((props, forwardedRef) => {
1155
- const text = useContentPartText();
1156
- return /* @__PURE__ */ jsx15(Primitive4.span, { ...props, ref: forwardedRef, children: text });
1157
- });
1158
- ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
1199
+ ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
1159
1200
 
1160
1201
  // src/primitives/message/MessageContent.tsx
1161
1202
  import { jsx as jsx16, jsxs as jsxs2 } from "react/jsx-runtime";
1162
1203
  var defaultComponents = {
1163
1204
  Text: () => /* @__PURE__ */ jsxs2("p", { style: { whiteSpace: "pre-line" }, children: [
1164
1205
  /* @__PURE__ */ jsx16(ContentPartPrimitiveText, {}),
1165
- /* @__PURE__ */ jsx16(ContentPartPrimitiveInProgressIndicator, {})
1206
+ /* @__PURE__ */ jsx16(ContentPartPrimitiveInProgress, { children: " \u25CF" })
1166
1207
  ] }),
1167
- Image: () => null,
1208
+ Image: () => /* @__PURE__ */ jsx16(ContentPartPrimitiveImage, {}),
1168
1209
  UI: () => /* @__PURE__ */ jsx16(ContentPartPrimitiveDisplay, {}),
1169
1210
  tools: {
1170
1211
  Fallback: (props) => {
@@ -1234,21 +1275,15 @@ var MessagePrimitiveContent = ({
1234
1275
  MessagePrimitiveContent.displayName = "MessagePrimitive.Content";
1235
1276
 
1236
1277
  // src/primitives/message/MessageInProgress.tsx
1237
- import { createPortal } from "react-dom";
1238
- import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
1239
- import { forwardRef as forwardRef7 } from "react";
1240
- import { jsx as jsx17 } from "react/jsx-runtime";
1241
- var MessagePrimitiveInProgress = forwardRef7((props, ref) => {
1242
- const { useMessageUtils } = useMessageContext();
1243
- const portalNode = useMessageUtils((s) => s.inProgressIndicator);
1244
- return createPortal(/* @__PURE__ */ jsx17(Primitive5.span, { ...props, ref }), portalNode);
1245
- });
1278
+ var MessagePrimitiveInProgress = () => {
1279
+ return null;
1280
+ };
1246
1281
  MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
1247
1282
 
1248
1283
  // src/primitives/branchPicker/BranchPickerRoot.tsx
1249
- import { jsx as jsx18 } from "react/jsx-runtime";
1250
- var BranchPickerPrimitiveRoot = forwardRef8(({ hideWhenSingleBranch, ...rest }, ref) => {
1251
- return /* @__PURE__ */ jsx18(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ jsx18(Primitive6.div, { ...rest, ref }) });
1284
+ import { jsx as jsx17 } from "react/jsx-runtime";
1285
+ var BranchPickerPrimitiveRoot = forwardRef9(({ hideWhenSingleBranch, ...rest }, ref) => {
1286
+ return /* @__PURE__ */ jsx17(MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ jsx17(Primitive6.div, { ...rest, ref }) });
1252
1287
  });
1253
1288
  BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
1254
1289
 
@@ -1263,44 +1298,44 @@ __export(composer_exports, {
1263
1298
  });
1264
1299
 
1265
1300
  // src/primitives/composer/ComposerRoot.tsx
1266
- import { composeEventHandlers as composeEventHandlers5 } from "@radix-ui/primitive";
1301
+ import { composeEventHandlers as composeEventHandlers4 } from "@radix-ui/primitive";
1267
1302
  import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
1268
1303
  import {
1269
- forwardRef as forwardRef9
1304
+ forwardRef as forwardRef10
1270
1305
  } from "react";
1271
- import { jsx as jsx19 } from "react/jsx-runtime";
1272
- var ComposerPrimitiveRoot = forwardRef9(({ onSubmit, ...rest }, forwardedRef) => {
1306
+ import { jsx as jsx18 } from "react/jsx-runtime";
1307
+ var ComposerPrimitiveRoot = forwardRef10(({ onSubmit, ...rest }, forwardedRef) => {
1273
1308
  const send = useComposerSend();
1274
1309
  const handleSubmit = (e) => {
1275
1310
  e.preventDefault();
1276
1311
  if (!send) return;
1277
1312
  send();
1278
1313
  };
1279
- return /* @__PURE__ */ jsx19(
1314
+ return /* @__PURE__ */ jsx18(
1280
1315
  Primitive7.form,
1281
1316
  {
1282
1317
  ...rest,
1283
1318
  ref: forwardedRef,
1284
- onSubmit: composeEventHandlers5(onSubmit, handleSubmit)
1319
+ onSubmit: composeEventHandlers4(onSubmit, handleSubmit)
1285
1320
  }
1286
1321
  );
1287
1322
  });
1288
1323
  ComposerPrimitiveRoot.displayName = "ComposerPrimitive.Root";
1289
1324
 
1290
1325
  // src/primitives/composer/ComposerInput.tsx
1291
- import { composeEventHandlers as composeEventHandlers6 } from "@radix-ui/primitive";
1292
- import { useComposedRefs } from "@radix-ui/react-compose-refs";
1326
+ import { composeEventHandlers as composeEventHandlers5 } from "@radix-ui/primitive";
1327
+ import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
1293
1328
  import { Slot } from "@radix-ui/react-slot";
1294
1329
  import {
1295
- forwardRef as forwardRef10,
1296
- useCallback as useCallback13,
1330
+ forwardRef as forwardRef11,
1331
+ useCallback as useCallback15,
1297
1332
  useEffect as useEffect8,
1298
1333
  useRef as useRef4
1299
1334
  } from "react";
1300
1335
  import TextareaAutosize from "react-textarea-autosize";
1301
1336
  import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
1302
- import { jsx as jsx20 } from "react/jsx-runtime";
1303
- var ComposerPrimitiveInput = forwardRef10(
1337
+ import { jsx as jsx19 } from "react/jsx-runtime";
1338
+ var ComposerPrimitiveInput = forwardRef11(
1304
1339
  ({ autoFocus = false, asChild, disabled, onChange, onKeyDown, ...rest }, forwardedRef) => {
1305
1340
  const { useThread } = useThreadContext();
1306
1341
  const { useComposer, type } = useComposerContext();
@@ -1310,7 +1345,7 @@ var ComposerPrimitiveInput = forwardRef10(
1310
1345
  });
1311
1346
  const Component = asChild ? Slot : TextareaAutosize;
1312
1347
  const textareaRef = useRef4(null);
1313
- const ref = useComposedRefs(forwardedRef, textareaRef);
1348
+ const ref = useComposedRefs2(forwardedRef, textareaRef);
1314
1349
  useEscapeKeydown((e) => {
1315
1350
  const composer = useComposer.getState();
1316
1351
  if (composer.cancel()) {
@@ -1328,7 +1363,7 @@ var ComposerPrimitiveInput = forwardRef10(
1328
1363
  }
1329
1364
  };
1330
1365
  const autoFocusEnabled = autoFocus && !disabled;
1331
- const focus = useCallback13(() => {
1366
+ const focus = useCallback15(() => {
1332
1367
  const textarea = textareaRef.current;
1333
1368
  if (!textarea || !autoFocusEnabled) return;
1334
1369
  textarea.focus({ preventScroll: true });
@@ -1343,19 +1378,20 @@ var ComposerPrimitiveInput = forwardRef10(
1343
1378
  focus();
1344
1379
  }
1345
1380
  });
1346
- return /* @__PURE__ */ jsx20(
1381
+ return /* @__PURE__ */ jsx19(
1347
1382
  Component,
1348
1383
  {
1384
+ name: "input",
1349
1385
  value,
1350
1386
  ...rest,
1351
1387
  ref,
1352
1388
  disabled,
1353
- onChange: composeEventHandlers6(onChange, (e) => {
1389
+ onChange: composeEventHandlers5(onChange, (e) => {
1354
1390
  const composerState = useComposer.getState();
1355
1391
  if (!composerState.isEditing) return;
1356
1392
  return composerState.setValue(e.target.value);
1357
1393
  }),
1358
- onKeyDown: composeEventHandlers6(onKeyDown, handleKeyPress)
1394
+ onKeyDown: composeEventHandlers5(onKeyDown, handleKeyPress)
1359
1395
  }
1360
1396
  );
1361
1397
  }
@@ -1363,13 +1399,13 @@ var ComposerPrimitiveInput = forwardRef10(
1363
1399
  ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
1364
1400
 
1365
1401
  // src/primitives/composer/ComposerSend.tsx
1366
- import { forwardRef as forwardRef11 } from "react";
1402
+ import { forwardRef as forwardRef12 } from "react";
1367
1403
  import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
1368
- import { jsx as jsx21 } from "react/jsx-runtime";
1369
- var ComposerPrimitiveSend = forwardRef11(({ disabled, ...rest }, ref) => {
1404
+ import { jsx as jsx20 } from "react/jsx-runtime";
1405
+ var ComposerPrimitiveSend = forwardRef12(({ disabled, ...rest }, ref) => {
1370
1406
  const { useComposer } = useComposerContext();
1371
1407
  const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
1372
- return /* @__PURE__ */ jsx21(
1408
+ return /* @__PURE__ */ jsx20(
1373
1409
  Primitive8.button,
1374
1410
  {
1375
1411
  type: "submit",
@@ -1402,20 +1438,10 @@ var contentPart_exports = {};
1402
1438
  __export(contentPart_exports, {
1403
1439
  Display: () => ContentPartPrimitiveDisplay,
1404
1440
  Image: () => ContentPartPrimitiveImage,
1405
- InProgressIndicator: () => ContentPartPrimitiveInProgressIndicator,
1441
+ InProgress: () => ContentPartPrimitiveInProgress,
1406
1442
  Text: () => ContentPartPrimitiveText
1407
1443
  });
1408
1444
 
1409
- // src/primitives/contentPart/ContentPartImage.tsx
1410
- import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
1411
- import { forwardRef as forwardRef12 } from "react";
1412
- import { jsx as jsx22 } from "react/jsx-runtime";
1413
- var ContentPartPrimitiveImage = forwardRef12((props, forwardedRef) => {
1414
- const image = useContentPartImage();
1415
- return /* @__PURE__ */ jsx22(Primitive9.img, { src: image, ...props, ref: forwardedRef });
1416
- });
1417
- ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
1418
-
1419
1445
  // src/primitives/thread/index.ts
1420
1446
  var thread_exports = {};
1421
1447
  __export(thread_exports, {
@@ -1429,11 +1455,11 @@ __export(thread_exports, {
1429
1455
  });
1430
1456
 
1431
1457
  // src/primitives/thread/ThreadRoot.tsx
1432
- import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
1458
+ import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
1433
1459
  import { forwardRef as forwardRef13 } from "react";
1434
- import { jsx as jsx23 } from "react/jsx-runtime";
1460
+ import { jsx as jsx21 } from "react/jsx-runtime";
1435
1461
  var ThreadPrimitiveRoot = forwardRef13((props, ref) => {
1436
- return /* @__PURE__ */ jsx23(Primitive10.div, { ...props, ref });
1462
+ return /* @__PURE__ */ jsx21(Primitive9.div, { ...props, ref });
1437
1463
  });
1438
1464
  ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
1439
1465
 
@@ -1457,40 +1483,20 @@ var ThreadPrimitiveIf = ({
1457
1483
  ThreadPrimitiveIf.displayName = "ThreadPrimitive.If";
1458
1484
 
1459
1485
  // src/primitives/thread/ThreadViewport.tsx
1460
- import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
1461
- import { Primitive as Primitive11 } from "@radix-ui/react-primitive";
1486
+ import { useComposedRefs as useComposedRefs4 } from "@radix-ui/react-compose-refs";
1487
+ import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
1462
1488
  import { forwardRef as forwardRef14 } from "react";
1463
1489
 
1464
1490
  // src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
1465
- import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
1466
- import { useRef as useRef6 } from "react";
1491
+ import { useComposedRefs as useComposedRefs3 } from "@radix-ui/react-compose-refs";
1492
+ import { useRef as useRef5 } from "react";
1467
1493
 
1468
1494
  // src/utils/hooks/useOnResizeContent.tsx
1469
1495
  import { useCallbackRef as useCallbackRef2 } from "@radix-ui/react-use-callback-ref";
1470
- import { useCallback as useCallback15 } from "react";
1471
-
1472
- // src/utils/hooks/useManagedRef.ts
1473
- import { useCallback as useCallback14, useRef as useRef5 } from "react";
1474
- var useManagedRef = (callback) => {
1475
- const cleanupRef = useRef5();
1476
- const ref = useCallback14(
1477
- (el) => {
1478
- if (cleanupRef.current) {
1479
- cleanupRef.current();
1480
- }
1481
- if (el) {
1482
- cleanupRef.current = callback(el);
1483
- }
1484
- },
1485
- [callback]
1486
- );
1487
- return ref;
1488
- };
1489
-
1490
- // src/utils/hooks/useOnResizeContent.tsx
1496
+ import { useCallback as useCallback16 } from "react";
1491
1497
  var useOnResizeContent = (callback) => {
1492
1498
  const callbackRef = useCallbackRef2(callback);
1493
- const refCallback = useCallback15(
1499
+ const refCallback = useCallback16(
1494
1500
  (el) => {
1495
1501
  const resizeObserver = new ResizeObserver(() => {
1496
1502
  callbackRef();
@@ -1542,11 +1548,11 @@ var useOnScrollToBottom = (callback) => {
1542
1548
  var useThreadViewportAutoScroll = ({
1543
1549
  autoScroll = true
1544
1550
  }) => {
1545
- const divRef = useRef6(null);
1551
+ const divRef = useRef5(null);
1546
1552
  const { useViewport } = useThreadContext();
1547
- const firstRenderRef = useRef6(true);
1548
- const lastScrollTop = useRef6(0);
1549
- const isScrollingToBottomRef = useRef6(false);
1553
+ const firstRenderRef = useRef5(true);
1554
+ const lastScrollTop = useRef5(0);
1555
+ const isScrollingToBottomRef = useRef5(false);
1550
1556
  const scrollToBottom = () => {
1551
1557
  const div = divRef.current;
1552
1558
  if (!div || !autoScroll) return;
@@ -1584,7 +1590,7 @@ var useThreadViewportAutoScroll = ({
1584
1590
  el.removeEventListener("scroll", handleScroll);
1585
1591
  };
1586
1592
  });
1587
- const autoScrollRef = useComposedRefs2(resizeRef, scrollRef, divRef);
1593
+ const autoScrollRef = useComposedRefs3(resizeRef, scrollRef, divRef);
1588
1594
  useOnScrollToBottom(() => {
1589
1595
  scrollToBottom();
1590
1596
  });
@@ -1592,13 +1598,13 @@ var useThreadViewportAutoScroll = ({
1592
1598
  };
1593
1599
 
1594
1600
  // src/primitives/thread/ThreadViewport.tsx
1595
- import { jsx as jsx24 } from "react/jsx-runtime";
1601
+ import { jsx as jsx22 } from "react/jsx-runtime";
1596
1602
  var ThreadPrimitiveViewport = forwardRef14(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
1597
1603
  const autoScrollRef = useThreadViewportAutoScroll({
1598
1604
  autoScroll
1599
1605
  });
1600
- const ref = useComposedRefs3(forwardedRef, autoScrollRef);
1601
- return /* @__PURE__ */ jsx24(Primitive11.div, { ...rest, ref, children });
1606
+ const ref = useComposedRefs4(forwardedRef, autoScrollRef);
1607
+ return /* @__PURE__ */ jsx22(Primitive10.div, { ...rest, ref, children });
1602
1608
  });
1603
1609
  ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
1604
1610
 
@@ -1636,7 +1642,6 @@ var makeEditComposerStore = ({
1636
1642
  // src/context/stores/MessageUtils.ts
1637
1643
  import { create as create11 } from "zustand";
1638
1644
  var makeMessageUtilsStore = () => create11((set) => ({
1639
- inProgressIndicator: document.createElement("span"),
1640
1645
  isCopied: false,
1641
1646
  setIsCopied: (value) => {
1642
1647
  set({ isCopied: value });
@@ -1648,7 +1653,7 @@ var makeMessageUtilsStore = () => create11((set) => ({
1648
1653
  }));
1649
1654
 
1650
1655
  // src/context/providers/MessageProvider.tsx
1651
- import { jsx as jsx25 } from "react/jsx-runtime";
1656
+ import { jsx as jsx23 } from "react/jsx-runtime";
1652
1657
  var getIsLast = (messages, message) => {
1653
1658
  return messages[messages.length - 1]?.id === message.id;
1654
1659
  };
@@ -1724,11 +1729,11 @@ var MessageProvider = ({
1724
1729
  children
1725
1730
  }) => {
1726
1731
  const context = useMessageContext2(messageIndex);
1727
- return /* @__PURE__ */ jsx25(MessageContext.Provider, { value: context, children });
1732
+ return /* @__PURE__ */ jsx23(MessageContext.Provider, { value: context, children });
1728
1733
  };
1729
1734
 
1730
1735
  // src/primitives/thread/ThreadMessages.tsx
1731
- import { jsx as jsx26, jsxs as jsxs3 } from "react/jsx-runtime";
1736
+ import { jsx as jsx24, jsxs as jsxs3 } from "react/jsx-runtime";
1732
1737
  var getComponents = (components) => {
1733
1738
  return {
1734
1739
  EditComposer: components.EditComposer ?? components.UserMessage ?? components.Message,
@@ -1743,10 +1748,10 @@ var ThreadMessageImpl = ({
1743
1748
  const { UserMessage, EditComposer, AssistantMessage } = getComponents(components);
1744
1749
  return /* @__PURE__ */ jsxs3(MessageProvider, { messageIndex, children: [
1745
1750
  /* @__PURE__ */ jsxs3(MessagePrimitiveIf, { user: true, children: [
1746
- /* @__PURE__ */ jsx26(ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ jsx26(UserMessage, {}) }),
1747
- /* @__PURE__ */ jsx26(ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ jsx26(EditComposer, {}) })
1751
+ /* @__PURE__ */ jsx24(ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ jsx24(UserMessage, {}) }),
1752
+ /* @__PURE__ */ jsx24(ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ jsx24(EditComposer, {}) })
1748
1753
  ] }),
1749
- /* @__PURE__ */ jsx26(MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ jsx26(AssistantMessage, {}) })
1754
+ /* @__PURE__ */ jsx24(MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ jsx24(AssistantMessage, {}) })
1750
1755
  ] });
1751
1756
  };
1752
1757
  var ThreadMessage = memo3(
@@ -1761,7 +1766,7 @@ var ThreadPrimitiveMessages = ({
1761
1766
  if (messagesLength === 0) return null;
1762
1767
  return new Array(messagesLength).fill(null).map((_, idx) => {
1763
1768
  const messageIndex = idx;
1764
- return /* @__PURE__ */ jsx26(
1769
+ return /* @__PURE__ */ jsx24(
1765
1770
  ThreadMessage,
1766
1771
  {
1767
1772
  messageIndex,