@copilotz/chat-ui 0.9.6 → 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
@@ -4604,6 +4604,18 @@ var ChatInput = memo4(function ChatInput2({
4604
4604
  }).slice(0, 6);
4605
4605
  }, [activeMention, mentionAgents]);
4606
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]);
4607
4619
  const syncMentionState = useCallback3((nextValue, nextCaret) => {
4608
4620
  const caret = typeof nextCaret === "number" ? nextCaret : textareaRef.current?.selectionStart ?? nextValue.length;
4609
4621
  const nextMatch = getActiveMentionMatch(nextValue, caret);
@@ -5074,7 +5086,7 @@ var ChatInput = memo4(function ChatInput2({
5074
5086
  };
5075
5087
  const canAddMoreAttachments = attachments.length < maxAttachments;
5076
5088
  const showVoiceComposer = enableAudioRecording && isVoiceComposerOpen;
5077
- 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: [
5078
5090
  uploadProgress.size > 0 && /* @__PURE__ */ jsx25("div", { className: "space-y-2", children: Array.from(uploadProgress.entries()).map(([id, progress]) => /* @__PURE__ */ jsx25(
5079
5091
  FileUploadItem,
5080
5092
  {
@@ -5138,46 +5150,14 @@ var ChatInput = memo4(function ChatInput2({
5138
5150
  void closeVoiceComposer();
5139
5151
  }
5140
5152
  }
5141
- ) }) : /* @__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(
5142
5154
  "div",
5143
5155
  {
5144
- 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",
5145
5157
  onDrop: handleDrop,
5146
5158
  onDragOver: handleDragOver,
5147
5159
  children: [
5148
- enableFileUpload && canAddMoreAttachments && /* @__PURE__ */ jsxs15(Fragment6, { children: [
5149
- /* @__PURE__ */ jsx25(
5150
- "input",
5151
- {
5152
- ref: fileInputRef,
5153
- type: "file",
5154
- multiple: true,
5155
- accept: acceptedFileTypes.length > 0 ? acceptedFileTypes.join(",") : void 0,
5156
- onChange: handleFileSelect,
5157
- className: "hidden"
5158
- }
5159
- ),
5160
- /* @__PURE__ */ jsxs15(Tooltip, { children: [
5161
- /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5162
- Button,
5163
- {
5164
- type: "button",
5165
- variant: "outline",
5166
- size: "icon",
5167
- className: "h-10 w-10",
5168
- onClick: (e) => {
5169
- e.preventDefault();
5170
- e.stopPropagation();
5171
- fileInputRef.current?.click();
5172
- },
5173
- disabled,
5174
- children: /* @__PURE__ */ jsx25(Paperclip, { className: "h-4 w-4" })
5175
- }
5176
- ) }),
5177
- /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.attachFileTooltip })
5178
- ] })
5179
- ] }),
5180
- /* @__PURE__ */ jsxs15("div", { className: "relative flex-1", children: [
5160
+ /* @__PURE__ */ jsxs15("div", { className: "relative min-w-0", children: [
5181
5161
  /* @__PURE__ */ jsx25(
5182
5162
  Textarea,
5183
5163
  {
@@ -5186,6 +5166,7 @@ var ChatInput = memo4(function ChatInput2({
5186
5166
  onChange: (e) => {
5187
5167
  onChange(e.target.value);
5188
5168
  syncMentionState(e.target.value, e.target.selectionStart ?? e.target.value.length);
5169
+ requestAnimationFrame(resizeTextarea);
5189
5170
  },
5190
5171
  onSelect: (e) => {
5191
5172
  const target = e.target;
@@ -5198,7 +5179,7 @@ var ChatInput = memo4(function ChatInput2({
5198
5179
  onKeyDown: handleKeyDown,
5199
5180
  placeholder,
5200
5181
  disabled,
5201
- 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",
5202
5183
  rows: 1
5203
5184
  }
5204
5185
  ),
@@ -5219,48 +5200,84 @@ var ChatInput = memo4(function ChatInput2({
5219
5200
  agent.id
5220
5201
  )) }) })
5221
5202
  ] }),
5222
- enableAudioRecording && canAddMoreAttachments && !value.trim() && /* @__PURE__ */ jsxs15(Tooltip, { children: [
5223
- /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5224
- Button,
5225
- {
5226
- type: "button",
5227
- variant: "outline",
5228
- size: "icon",
5229
- className: "h-10 w-10",
5230
- onClick: () => {
5231
- void startVoiceCapture();
5232
- },
5233
- disabled: disabled || isGenerating,
5234
- children: /* @__PURE__ */ jsx25(Mic2, { className: "h-4 w-4" })
5235
- }
5236
- ) }),
5237
- /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.voiceEnter })
5238
- ] }),
5239
- isGenerating ? /* @__PURE__ */ jsxs15(Tooltip, { children: [
5240
- /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5241
- Button,
5242
- {
5243
- type: "button",
5244
- variant: "outline",
5245
- size: "icon",
5246
- className: "h-10 w-10",
5247
- onClick: onStopGeneration,
5248
- children: /* @__PURE__ */ jsx25(Square2, { className: "h-4 w-4" })
5249
- }
5250
- ) }),
5251
- /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.stopGenerationTooltip })
5252
- ] }) : /* @__PURE__ */ jsxs15(Tooltip, { children: [
5253
- /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5254
- Button,
5255
- {
5256
- type: "submit",
5257
- size: "icon",
5258
- className: "h-10 w-10",
5259
- disabled: disabled || !value.trim() && attachments.length === 0,
5260
- children: disabled ? /* @__PURE__ */ jsx25(Loader22, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx25(Send2, { className: "h-4 w-4" })
5261
- }
5262
- ) }),
5263
- /* @__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
+ ] })
5264
5281
  ] })
5265
5282
  ]
5266
5283
  }