@copilotz/chat-ui 0.9.6 → 0.9.8

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
@@ -3369,7 +3369,8 @@ var TargetAgentSelector = memo3(({
3369
3369
  onTargetChange,
3370
3370
  label = "Target",
3371
3371
  placeholder = "Select agent",
3372
- disabled = false
3372
+ disabled = false,
3373
+ compact = false
3373
3374
  }) => {
3374
3375
  const agentsWithColors = useMemo4(() => assignAgentColors(agents), [agents]);
3375
3376
  const selectedAgent = useMemo4(
@@ -3381,7 +3382,7 @@ var TargetAgentSelector = memo3(({
3381
3382
  Button,
3382
3383
  {
3383
3384
  variant: "ghost",
3384
- className: "h-9 px-3 gap-1.5 font-medium text-base hover:bg-accent/50",
3385
+ className: `gap-1.5 font-medium hover:bg-accent/50 ${compact ? "h-9 rounded-full px-2 text-sm text-muted-foreground hover:text-foreground" : "h-9 px-3 text-base"}`,
3385
3386
  disabled,
3386
3387
  children: [
3387
3388
  /* @__PURE__ */ jsx20(AtSign, { className: "h-4 w-4 text-muted-foreground" }),
@@ -4556,6 +4557,9 @@ var ChatInput = memo4(function ChatInput2({
4556
4557
  className = "",
4557
4558
  config,
4558
4559
  mentionAgents = [],
4560
+ targetAgentId = null,
4561
+ showTargetAgentSelector = false,
4562
+ targetAgentSelectorPlaceholder,
4559
4563
  onTargetAgentChange
4560
4564
  }) {
4561
4565
  const voiceDefaultMode = config?.voiceCompose?.defaultMode ?? "text";
@@ -4604,6 +4608,18 @@ var ChatInput = memo4(function ChatInput2({
4604
4608
  }).slice(0, 6);
4605
4609
  }, [activeMention, mentionAgents]);
4606
4610
  const isMentionMenuOpen = filteredMentionAgents.length > 0;
4611
+ const resizeTextarea = useCallback3(() => {
4612
+ const textarea = textareaRef.current;
4613
+ if (!textarea) return;
4614
+ const viewportWidth = typeof window === "undefined" ? 1024 : window.innerWidth;
4615
+ const maxHeight = viewportWidth > 768 ? 240 : 190;
4616
+ textarea.style.height = "auto";
4617
+ textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
4618
+ textarea.style.overflowY = textarea.scrollHeight > maxHeight ? "auto" : "hidden";
4619
+ }, []);
4620
+ useEffect9(() => {
4621
+ resizeTextarea();
4622
+ }, [resizeTextarea, value]);
4607
4623
  const syncMentionState = useCallback3((nextValue, nextCaret) => {
4608
4624
  const caret = typeof nextCaret === "number" ? nextCaret : textareaRef.current?.selectionStart ?? nextValue.length;
4609
4625
  const nextMatch = getActiveMentionMatch(nextValue, caret);
@@ -5074,7 +5090,7 @@ var ChatInput = memo4(function ChatInput2({
5074
5090
  };
5075
5091
  const canAddMoreAttachments = attachments.length < maxAttachments;
5076
5092
  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: [
5093
+ return /* @__PURE__ */ jsx25(TooltipProvider, { children: /* @__PURE__ */ jsx25("div", { className: `bg-transparent py-0 ${className}`, children: /* @__PURE__ */ jsxs15("div", { className: "mx-auto w-full max-w-3xl space-y-3 px-3 md:px-2", children: [
5078
5094
  uploadProgress.size > 0 && /* @__PURE__ */ jsx25("div", { className: "space-y-2", children: Array.from(uploadProgress.entries()).map(([id, progress]) => /* @__PURE__ */ jsx25(
5079
5095
  FileUploadItem,
5080
5096
  {
@@ -5138,46 +5154,14 @@ var ChatInput = memo4(function ChatInput2({
5138
5154
  void closeVoiceComposer();
5139
5155
  }
5140
5156
  }
5141
- ) }) : /* @__PURE__ */ jsx25("form", { onSubmit: handleSubmit, className: "mb-1 flex justify-center", children: /* @__PURE__ */ jsxs15(
5157
+ ) }) : /* @__PURE__ */ jsx25("form", { onSubmit: handleSubmit, className: "mb-1", children: /* @__PURE__ */ jsxs15(
5142
5158
  "div",
5143
5159
  {
5144
- className: "flex items-end gap-2 p-3 border rounded-lg bg-background w-full md:min-w-3xl max-w-3xl",
5160
+ 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
5161
  onDrop: handleDrop,
5146
5162
  onDragOver: handleDragOver,
5147
5163
  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: [
5164
+ /* @__PURE__ */ jsxs15("div", { className: "relative min-w-0", children: [
5181
5165
  /* @__PURE__ */ jsx25(
5182
5166
  Textarea,
5183
5167
  {
@@ -5186,6 +5170,7 @@ var ChatInput = memo4(function ChatInput2({
5186
5170
  onChange: (e) => {
5187
5171
  onChange(e.target.value);
5188
5172
  syncMentionState(e.target.value, e.target.selectionStart ?? e.target.value.length);
5173
+ requestAnimationFrame(resizeTextarea);
5189
5174
  },
5190
5175
  onSelect: (e) => {
5191
5176
  const target = e.target;
@@ -5198,7 +5183,7 @@ var ChatInput = memo4(function ChatInput2({
5198
5183
  onKeyDown: handleKeyDown,
5199
5184
  placeholder,
5200
5185
  disabled,
5201
- className: "max-h-[120px] resize-none border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0",
5186
+ 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
5187
  rows: 1
5203
5188
  }
5204
5189
  ),
@@ -5219,48 +5204,97 @@ var ChatInput = memo4(function ChatInput2({
5219
5204
  agent.id
5220
5205
  )) }) })
5221
5206
  ] }),
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 })
5207
+ /* @__PURE__ */ jsxs15("div", { className: "flex min-h-10 items-center justify-between gap-2", children: [
5208
+ /* @__PURE__ */ jsxs15("div", { className: "flex min-w-0 items-center gap-1", children: [
5209
+ enableFileUpload && canAddMoreAttachments && /* @__PURE__ */ jsxs15(Fragment6, { children: [
5210
+ /* @__PURE__ */ jsx25(
5211
+ "input",
5212
+ {
5213
+ ref: fileInputRef,
5214
+ type: "file",
5215
+ multiple: true,
5216
+ accept: acceptedFileTypes.length > 0 ? acceptedFileTypes.join(",") : void 0,
5217
+ onChange: handleFileSelect,
5218
+ className: "hidden"
5219
+ }
5220
+ ),
5221
+ /* @__PURE__ */ jsxs15(Tooltip, { children: [
5222
+ /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5223
+ Button,
5224
+ {
5225
+ type: "button",
5226
+ variant: "ghost",
5227
+ size: "icon",
5228
+ className: "h-9 w-9 rounded-full text-muted-foreground hover:text-foreground",
5229
+ onClick: (e) => {
5230
+ e.preventDefault();
5231
+ e.stopPropagation();
5232
+ fileInputRef.current?.click();
5233
+ },
5234
+ disabled,
5235
+ children: /* @__PURE__ */ jsx25(Paperclip, { className: "h-4 w-4" })
5236
+ }
5237
+ ) }),
5238
+ /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.attachFileTooltip })
5239
+ ] })
5240
+ ] }),
5241
+ showTargetAgentSelector && onTargetAgentChange && mentionAgents.length > 0 && /* @__PURE__ */ jsx25(
5242
+ TargetAgentSelector,
5243
+ {
5244
+ agents: mentionAgents,
5245
+ targetAgentId,
5246
+ onTargetChange: onTargetAgentChange,
5247
+ placeholder: targetAgentSelectorPlaceholder || "Select agent",
5248
+ disabled: disabled || isGenerating,
5249
+ compact: true
5250
+ }
5251
+ )
5252
+ ] }),
5253
+ /* @__PURE__ */ jsxs15("div", { className: "flex shrink-0 items-center gap-1", children: [
5254
+ enableAudioRecording && canAddMoreAttachments && !value.trim() && /* @__PURE__ */ jsxs15(Tooltip, { children: [
5255
+ /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5256
+ Button,
5257
+ {
5258
+ type: "button",
5259
+ variant: "ghost",
5260
+ size: "icon",
5261
+ className: "h-9 w-9 rounded-full text-muted-foreground hover:text-foreground",
5262
+ onClick: () => {
5263
+ void startVoiceCapture();
5264
+ },
5265
+ disabled: disabled || isGenerating,
5266
+ children: /* @__PURE__ */ jsx25(Mic2, { className: "h-4 w-4" })
5267
+ }
5268
+ ) }),
5269
+ /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.voiceEnter })
5270
+ ] }),
5271
+ isGenerating ? /* @__PURE__ */ jsxs15(Tooltip, { children: [
5272
+ /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5273
+ Button,
5274
+ {
5275
+ type: "button",
5276
+ variant: "secondary",
5277
+ size: "icon",
5278
+ className: "h-9 w-9 rounded-full",
5279
+ onClick: onStopGeneration,
5280
+ children: /* @__PURE__ */ jsx25(Square2, { className: "h-4 w-4" })
5281
+ }
5282
+ ) }),
5283
+ /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.stopGenerationTooltip })
5284
+ ] }) : /* @__PURE__ */ jsxs15(Tooltip, { children: [
5285
+ /* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
5286
+ Button,
5287
+ {
5288
+ type: "submit",
5289
+ size: "icon",
5290
+ className: "h-9 w-9 rounded-full",
5291
+ disabled: disabled || !value.trim() && attachments.length === 0,
5292
+ children: disabled ? /* @__PURE__ */ jsx25(Loader22, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx25(Send2, { className: "h-4 w-4" })
5293
+ }
5294
+ ) }),
5295
+ /* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.sendMessageTooltip })
5296
+ ] })
5297
+ ] })
5264
5298
  ] })
5265
5299
  ]
5266
5300
  }
@@ -6510,50 +6544,41 @@ var ChatUI = ({
6510
6544
  ] })
6511
6545
  }
6512
6546
  ),
6513
- /* @__PURE__ */ jsxs18("div", { className: "bg-background pb-[env(safe-area-inset-bottom)]", children: [
6514
- isMultiAgentMode && shouldShowAgentSelector && onTargetAgentChange && /* @__PURE__ */ jsx28("div", { className: "px-4 pt-1", children: /* @__PURE__ */ jsx28(
6515
- TargetAgentSelector,
6516
- {
6517
- agents: participantIds && participantIds.length > 0 ? agentOptions.filter(
6518
- (a) => participantIds.includes(a.id)
6519
- ) : agentOptions,
6520
- targetAgentId,
6521
- onTargetChange: onTargetAgentChange,
6522
- placeholder: config.agentSelector?.label || "Select agent",
6523
- disabled: isGenerating
6524
- }
6525
- ) }),
6526
- /* @__PURE__ */ jsx28(
6527
- ChatInput,
6528
- {
6529
- value: inputValue,
6530
- onChange: (value) => {
6531
- setInputValue(value);
6532
- if (initialInputApplied.current && !initialInputConsumedRef.current) {
6533
- initialInputConsumedRef.current = true;
6534
- onInitialInputConsumed?.();
6535
- }
6536
- },
6537
- onSubmit: handleSendMessage,
6538
- attachments,
6539
- onAttachmentsChange: setAttachments,
6540
- placeholder: config.labels.inputPlaceholder,
6541
- disabled: false,
6542
- isGenerating,
6543
- onStopGeneration: callbacks.onStopGeneration,
6544
- enableFileUpload: config.features.enableFileUpload,
6545
- enableAudioRecording: config.features.enableAudioRecording,
6546
- maxAttachments: config.features.maxAttachments,
6547
- maxFileSize: config.features.maxFileSize,
6548
- acceptedFileTypes: config.features.acceptedFileTypes,
6549
- config,
6550
- mentionAgents: participantIds && participantIds.length > 0 ? agentOptions.filter(
6551
- (a) => participantIds.includes(a.id)
6552
- ) : agentOptions,
6553
- onTargetAgentChange
6554
- }
6555
- )
6556
- ] })
6547
+ /* @__PURE__ */ jsx28("div", { className: "-mt-8 bg-gradient-to-t from-background via-background/95 to-transparent px-0 pb-[env(safe-area-inset-bottom)] pt-10", children: /* @__PURE__ */ jsx28(
6548
+ ChatInput,
6549
+ {
6550
+ value: inputValue,
6551
+ onChange: (value) => {
6552
+ setInputValue(value);
6553
+ if (initialInputApplied.current && !initialInputConsumedRef.current) {
6554
+ initialInputConsumedRef.current = true;
6555
+ onInitialInputConsumed?.();
6556
+ }
6557
+ },
6558
+ onSubmit: handleSendMessage,
6559
+ attachments,
6560
+ onAttachmentsChange: setAttachments,
6561
+ placeholder: config.labels.inputPlaceholder,
6562
+ disabled: false,
6563
+ isGenerating,
6564
+ onStopGeneration: callbacks.onStopGeneration,
6565
+ enableFileUpload: config.features.enableFileUpload,
6566
+ enableAudioRecording: config.features.enableAudioRecording,
6567
+ maxAttachments: config.features.maxAttachments,
6568
+ maxFileSize: config.features.maxFileSize,
6569
+ acceptedFileTypes: config.features.acceptedFileTypes,
6570
+ config,
6571
+ mentionAgents: participantIds && participantIds.length > 0 ? agentOptions.filter(
6572
+ (a) => participantIds.includes(a.id)
6573
+ ) : agentOptions,
6574
+ targetAgentId,
6575
+ showTargetAgentSelector: Boolean(
6576
+ isMultiAgentMode && shouldShowAgentSelector && onTargetAgentChange
6577
+ ),
6578
+ targetAgentSelectorPlaceholder: config.agentSelector?.label || "Select agent",
6579
+ onTargetAgentChange
6580
+ }
6581
+ ) })
6557
6582
  ] }),
6558
6583
  config?.customComponent?.component && !isMobile && /* @__PURE__ */ jsx28(
6559
6584
  "div",