@copilotz/chat-ui 0.9.5 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1246,25 +1246,45 @@ var Message = memo2(({
1246
1246
  ] })
1247
1247
  ] }),
1248
1248
  /* @__PURE__ */ jsxs5("div", { className: `flex-1 min-w-0 ${messageIsUser ? "text-right" : "text-left"} ${horizontalOffsetClass}`, children: [
1249
- /* @__PURE__ */ jsx9("div", { className: `relative overflow-hidden text-left ${messageIsUser ? "ml-auto inline-flex max-w-[85%] flex-col rounded-lg bg-primary p-3 text-primary-foreground" : "flex w-full max-w-full flex-col"}`, children: isEditing ? /* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
1249
+ /* @__PURE__ */ jsx9("div", { className: `relative overflow-hidden text-left ${messageIsUser ? isEditing ? "ml-auto flex w-full max-w-[min(42rem,85%)] flex-col rounded-xl border bg-background p-2 text-foreground shadow-sm" : "ml-auto inline-flex max-w-[85%] flex-col rounded-lg bg-primary p-3 text-primary-foreground" : "flex w-full max-w-full flex-col"}`, children: isEditing ? /* @__PURE__ */ jsxs5("div", { className: "space-y-2", children: [
1250
1250
  /* @__PURE__ */ jsx9(
1251
1251
  Textarea,
1252
1252
  {
1253
1253
  value: editContent,
1254
1254
  onChange: (e) => setEditContent(e.target.value),
1255
- className: "min-h-[100px] resize-none",
1255
+ className: "min-h-28 resize-y bg-muted/30 text-sm leading-6",
1256
1256
  autoFocus: true
1257
1257
  }
1258
1258
  ),
1259
- /* @__PURE__ */ jsxs5("div", { className: "flex gap-2 justify-end", children: [
1260
- /* @__PURE__ */ jsxs5(Button, { variant: "outline", size: "sm", onClick: handleCancelEdit, children: [
1261
- /* @__PURE__ */ jsx9(X, { className: "h-4 w-4 mr-1" }),
1262
- "Cancelar"
1263
- ] }),
1264
- /* @__PURE__ */ jsxs5(Button, { size: "sm", onClick: handleEdit, children: [
1265
- /* @__PURE__ */ jsx9(Check, { className: "h-4 w-4 mr-1" }),
1266
- "Salvar"
1267
- ] })
1259
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-end gap-2", children: [
1260
+ /* @__PURE__ */ jsxs5(
1261
+ Button,
1262
+ {
1263
+ type: "button",
1264
+ variant: "ghost",
1265
+ size: "sm",
1266
+ className: "h-8",
1267
+ onClick: handleCancelEdit,
1268
+ children: [
1269
+ /* @__PURE__ */ jsx9(X, { className: "h-4 w-4 mr-1" }),
1270
+ labels?.cancel || "Cancel"
1271
+ ]
1272
+ }
1273
+ ),
1274
+ /* @__PURE__ */ jsxs5(
1275
+ Button,
1276
+ {
1277
+ type: "button",
1278
+ size: "sm",
1279
+ className: "h-8",
1280
+ onClick: handleEdit,
1281
+ disabled: !editContent.trim() || editContent.trim() === message.content,
1282
+ children: [
1283
+ /* @__PURE__ */ jsx9(Check, { className: "h-4 w-4 mr-1" }),
1284
+ "Save"
1285
+ ]
1286
+ }
1287
+ )
1268
1288
  ] })
1269
1289
  ] }) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
1270
1290
  !messageIsUser && /* @__PURE__ */ jsx9(
@@ -1300,10 +1320,10 @@ var Message = memo2(({
1300
1320
  ) }),
1301
1321
  message.attachments && message.attachments.length > 0 && /* @__PURE__ */ jsx9("div", { className: "mt-3 space-y-2", children: message.attachments.map((attachment, index) => /* @__PURE__ */ jsx9(MediaRenderer, { attachment }, index)) })
1302
1322
  ] }) }),
1303
- !isEditing && (showActions || actionsFocused || copied) && (enableCopy || canEdit) && /* @__PURE__ */ jsxs5(
1323
+ !isEditing && (enableCopy || canEdit) && /* @__PURE__ */ jsxs5(
1304
1324
  "div",
1305
1325
  {
1306
- className: `mt-1 flex items-center gap-1 text-muted-foreground transition-opacity ${messageIsUser ? "justify-end" : "justify-start"}`,
1326
+ className: `mt-1 flex h-7 items-center gap-1 text-muted-foreground transition-opacity duration-150 ${messageIsUser ? "justify-end" : "justify-start"} ${showActions || actionsFocused || copied ? "opacity-100" : "pointer-events-none opacity-0"}`,
1307
1327
  children: [
1308
1328
  canEdit && /* @__PURE__ */ jsxs5(Tooltip, { children: [
1309
1329
  /* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx9(
@@ -2608,6 +2628,33 @@ var ThreadTagEditorBadge = ({
2608
2628
  }
2609
2629
  );
2610
2630
  };
2631
+ var ThreadTagOptionButton = ({
2632
+ tag,
2633
+ assigned,
2634
+ onClick
2635
+ }) => {
2636
+ const color = tagColor(tag);
2637
+ return /* @__PURE__ */ jsxs11(
2638
+ Button,
2639
+ {
2640
+ type: "button",
2641
+ variant: "outline",
2642
+ size: "sm",
2643
+ disabled: assigned,
2644
+ className: "gap-1.5 border font-medium disabled:opacity-70",
2645
+ style: {
2646
+ backgroundColor: color.background,
2647
+ borderColor: color.border,
2648
+ color: color.accent
2649
+ },
2650
+ onClick,
2651
+ children: [
2652
+ /* @__PURE__ */ jsx18(TagDot, { tag }),
2653
+ tag.name
2654
+ ]
2655
+ }
2656
+ );
2657
+ };
2611
2658
  var Sidebar2 = ({
2612
2659
  threads,
2613
2660
  currentThreadId,
@@ -3091,14 +3138,11 @@ var Sidebar2 = ({
3091
3138
  (threadTag) => threadTag.id === tag.id
3092
3139
  );
3093
3140
  return /* @__PURE__ */ jsx18(
3094
- Button,
3141
+ ThreadTagOptionButton,
3095
3142
  {
3096
- type: "button",
3097
- variant: assigned ? "secondary" : "outline",
3098
- size: "sm",
3099
- disabled: assigned,
3100
- onClick: () => addTagToThread(tagDialogThread, tag),
3101
- children: tag.name
3143
+ tag,
3144
+ assigned,
3145
+ onClick: () => addTagToThread(tagDialogThread, tag)
3102
3146
  },
3103
3147
  tag.id
3104
3148
  );
@@ -4560,6 +4604,18 @@ var ChatInput = memo4(function ChatInput2({
4560
4604
  }).slice(0, 6);
4561
4605
  }, [activeMention, mentionAgents]);
4562
4606
  const isMentionMenuOpen = filteredMentionAgents.length > 0;
4607
+ const resizeTextarea = useCallback3(() => {
4608
+ const textarea = textareaRef.current;
4609
+ if (!textarea) return;
4610
+ const viewportWidth = typeof window === "undefined" ? 1024 : window.innerWidth;
4611
+ const maxHeight = viewportWidth > 768 ? 240 : 190;
4612
+ textarea.style.height = "auto";
4613
+ textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
4614
+ textarea.style.overflowY = textarea.scrollHeight > maxHeight ? "auto" : "hidden";
4615
+ }, []);
4616
+ useEffect9(() => {
4617
+ resizeTextarea();
4618
+ }, [resizeTextarea, value]);
4563
4619
  const syncMentionState = useCallback3((nextValue, nextCaret) => {
4564
4620
  const caret = typeof nextCaret === "number" ? nextCaret : textareaRef.current?.selectionStart ?? nextValue.length;
4565
4621
  const nextMatch = getActiveMentionMatch(nextValue, caret);
@@ -5030,7 +5086,7 @@ var ChatInput = memo4(function ChatInput2({
5030
5086
  };
5031
5087
  const canAddMoreAttachments = attachments.length < maxAttachments;
5032
5088
  const showVoiceComposer = enableAudioRecording && isVoiceComposerOpen;
5033
- return /* @__PURE__ */ jsx25(TooltipProvider, { children: /* @__PURE__ */ jsx25("div", { className: `border-t py-0 bg-transparent ${className}`, children: /* @__PURE__ */ jsxs15("div", { className: "px-0 md:p-2 pb-1 space-y-4 bg-transparent", children: [
5089
+ return /* @__PURE__ */ jsx25(TooltipProvider, { children: /* @__PURE__ */ jsx25("div", { className: `border-t bg-background/95 py-2 ${className}`, children: /* @__PURE__ */ jsxs15("div", { className: "mx-auto w-full max-w-3xl space-y-3 px-3 md:px-2", children: [
5034
5090
  uploadProgress.size > 0 && /* @__PURE__ */ jsx25("div", { className: "space-y-2", children: Array.from(uploadProgress.entries()).map(([id, progress]) => /* @__PURE__ */ jsx25(
5035
5091
  FileUploadItem,
5036
5092
  {
@@ -5094,46 +5150,14 @@ var ChatInput = memo4(function ChatInput2({
5094
5150
  void closeVoiceComposer();
5095
5151
  }
5096
5152
  }
5097
- ) }) : /* @__PURE__ */ jsx25("form", { onSubmit: handleSubmit, className: "mb-1 flex justify-center", children: /* @__PURE__ */ jsxs15(
5153
+ ) }) : /* @__PURE__ */ jsx25("form", { onSubmit: handleSubmit, className: "mb-1", children: /* @__PURE__ */ jsxs15(
5098
5154
  "div",
5099
5155
  {
5100
- className: "flex items-end gap-2 p-3 border rounded-lg bg-background w-full md:min-w-3xl max-w-3xl",
5156
+ className: "group/composer flex w-full flex-col gap-2 rounded-3xl border border-border/80 bg-card/95 p-2.5 shadow-sm transition-[border-color,box-shadow,background-color] focus-within:border-ring/60 focus-within:bg-card focus-within:shadow-md focus-within:ring-2 focus-within:ring-ring/15",
5101
5157
  onDrop: handleDrop,
5102
5158
  onDragOver: handleDragOver,
5103
5159
  children: [
5104
- enableFileUpload && canAddMoreAttachments && /* @__PURE__ */ jsxs15(Fragment6, { children: [
5105
- /* @__PURE__ */ jsx25(
5106
- "input",
5107
- {
5108
- ref: fileInputRef,
5109
- type: "file",
5110
- multiple: true,
5111
- accept: acceptedFileTypes.length > 0 ? acceptedFileTypes.join(",") : void 0,
5112
- onChange: handleFileSelect,
5113
- className: "hidden"
5114
- }
5115
- ),
5116
- /* @__PURE__ */ jsxs15(Tooltip, { children: [
5117
- /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5118
- Button,
5119
- {
5120
- type: "button",
5121
- variant: "outline",
5122
- size: "icon",
5123
- className: "h-10 w-10",
5124
- onClick: (e) => {
5125
- e.preventDefault();
5126
- e.stopPropagation();
5127
- fileInputRef.current?.click();
5128
- },
5129
- disabled,
5130
- children: /* @__PURE__ */ jsx25(Paperclip, { className: "h-4 w-4" })
5131
- }
5132
- ) }),
5133
- /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.attachFileTooltip })
5134
- ] })
5135
- ] }),
5136
- /* @__PURE__ */ jsxs15("div", { className: "relative flex-1", children: [
5160
+ /* @__PURE__ */ jsxs15("div", { className: "relative min-w-0", children: [
5137
5161
  /* @__PURE__ */ jsx25(
5138
5162
  Textarea,
5139
5163
  {
@@ -5142,6 +5166,7 @@ var ChatInput = memo4(function ChatInput2({
5142
5166
  onChange: (e) => {
5143
5167
  onChange(e.target.value);
5144
5168
  syncMentionState(e.target.value, e.target.selectionStart ?? e.target.value.length);
5169
+ requestAnimationFrame(resizeTextarea);
5145
5170
  },
5146
5171
  onSelect: (e) => {
5147
5172
  const target = e.target;
@@ -5154,7 +5179,7 @@ var ChatInput = memo4(function ChatInput2({
5154
5179
  onKeyDown: handleKeyDown,
5155
5180
  placeholder,
5156
5181
  disabled,
5157
- className: "max-h-[120px] resize-none border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0",
5182
+ className: "min-h-11 resize-none overflow-hidden rounded-2xl border-0 bg-transparent px-3 py-2.5 text-base leading-6 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 md:text-sm",
5158
5183
  rows: 1
5159
5184
  }
5160
5185
  ),
@@ -5175,48 +5200,84 @@ var ChatInput = memo4(function ChatInput2({
5175
5200
  agent.id
5176
5201
  )) }) })
5177
5202
  ] }),
5178
- enableAudioRecording && canAddMoreAttachments && !value.trim() && /* @__PURE__ */ jsxs15(Tooltip, { children: [
5179
- /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5180
- Button,
5181
- {
5182
- type: "button",
5183
- variant: "outline",
5184
- size: "icon",
5185
- className: "h-10 w-10",
5186
- onClick: () => {
5187
- void startVoiceCapture();
5188
- },
5189
- disabled: disabled || isGenerating,
5190
- children: /* @__PURE__ */ jsx25(Mic2, { className: "h-4 w-4" })
5191
- }
5192
- ) }),
5193
- /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.voiceEnter })
5194
- ] }),
5195
- isGenerating ? /* @__PURE__ */ jsxs15(Tooltip, { children: [
5196
- /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5197
- Button,
5198
- {
5199
- type: "button",
5200
- variant: "outline",
5201
- size: "icon",
5202
- className: "h-10 w-10",
5203
- onClick: onStopGeneration,
5204
- children: /* @__PURE__ */ jsx25(Square2, { className: "h-4 w-4" })
5205
- }
5206
- ) }),
5207
- /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.stopGenerationTooltip })
5208
- ] }) : /* @__PURE__ */ jsxs15(Tooltip, { children: [
5209
- /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5210
- Button,
5211
- {
5212
- type: "submit",
5213
- size: "icon",
5214
- className: "h-10 w-10",
5215
- disabled: disabled || !value.trim() && attachments.length === 0,
5216
- children: disabled ? /* @__PURE__ */ jsx25(Loader22, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx25(Send2, { className: "h-4 w-4" })
5217
- }
5218
- ) }),
5219
- /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.sendMessageTooltip })
5203
+ /* @__PURE__ */ jsxs15("div", { className: "flex min-h-10 items-center justify-between gap-2", children: [
5204
+ /* @__PURE__ */ jsx25("div", { className: "flex min-w-0 items-center gap-1", children: enableFileUpload && canAddMoreAttachments && /* @__PURE__ */ jsxs15(Fragment6, { children: [
5205
+ /* @__PURE__ */ jsx25(
5206
+ "input",
5207
+ {
5208
+ ref: fileInputRef,
5209
+ type: "file",
5210
+ multiple: true,
5211
+ accept: acceptedFileTypes.length > 0 ? acceptedFileTypes.join(",") : void 0,
5212
+ onChange: handleFileSelect,
5213
+ className: "hidden"
5214
+ }
5215
+ ),
5216
+ /* @__PURE__ */ jsxs15(Tooltip, { children: [
5217
+ /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5218
+ Button,
5219
+ {
5220
+ type: "button",
5221
+ variant: "ghost",
5222
+ size: "icon",
5223
+ className: "h-9 w-9 rounded-full text-muted-foreground hover:text-foreground",
5224
+ onClick: (e) => {
5225
+ e.preventDefault();
5226
+ e.stopPropagation();
5227
+ fileInputRef.current?.click();
5228
+ },
5229
+ disabled,
5230
+ children: /* @__PURE__ */ jsx25(Paperclip, { className: "h-4 w-4" })
5231
+ }
5232
+ ) }),
5233
+ /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.attachFileTooltip })
5234
+ ] })
5235
+ ] }) }),
5236
+ /* @__PURE__ */ jsxs15("div", { className: "flex shrink-0 items-center gap-1", children: [
5237
+ enableAudioRecording && canAddMoreAttachments && !value.trim() && /* @__PURE__ */ jsxs15(Tooltip, { children: [
5238
+ /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5239
+ Button,
5240
+ {
5241
+ type: "button",
5242
+ variant: "ghost",
5243
+ size: "icon",
5244
+ className: "h-9 w-9 rounded-full text-muted-foreground hover:text-foreground",
5245
+ onClick: () => {
5246
+ void startVoiceCapture();
5247
+ },
5248
+ disabled: disabled || isGenerating,
5249
+ children: /* @__PURE__ */ jsx25(Mic2, { className: "h-4 w-4" })
5250
+ }
5251
+ ) }),
5252
+ /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.voiceEnter })
5253
+ ] }),
5254
+ isGenerating ? /* @__PURE__ */ jsxs15(Tooltip, { children: [
5255
+ /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5256
+ Button,
5257
+ {
5258
+ type: "button",
5259
+ variant: "secondary",
5260
+ size: "icon",
5261
+ className: "h-9 w-9 rounded-full",
5262
+ onClick: onStopGeneration,
5263
+ children: /* @__PURE__ */ jsx25(Square2, { className: "h-4 w-4" })
5264
+ }
5265
+ ) }),
5266
+ /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.stopGenerationTooltip })
5267
+ ] }) : /* @__PURE__ */ jsxs15(Tooltip, { children: [
5268
+ /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5269
+ Button,
5270
+ {
5271
+ type: "submit",
5272
+ size: "icon",
5273
+ className: "h-9 w-9 rounded-full",
5274
+ disabled: disabled || !value.trim() && attachments.length === 0,
5275
+ children: disabled ? /* @__PURE__ */ jsx25(Loader22, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx25(Send2, { className: "h-4 w-4" })
5276
+ }
5277
+ ) }),
5278
+ /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.sendMessageTooltip })
5279
+ ] })
5280
+ ] })
5220
5281
  ] })
5221
5282
  ]
5222
5283
  }