@arbidocs/react 0.4.48 → 0.4.50

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.d.cts CHANGED
@@ -203,6 +203,12 @@ interface ChatBubbleProps {
203
203
  * raw string.
204
204
  */
205
205
  formatTimestamp?: (timestamp: string) => string;
206
+ /**
207
+ * Rendered inside the bubble under the text — e.g. a message's attached
208
+ * files. The host owns fetching and decrypting them. A message with
209
+ * attachments and no text shows only these.
210
+ */
211
+ attachments?: ReactNode;
206
212
  /** Marks the message row, including the deleted tombstone. */
207
213
  'data-testid'?: string;
208
214
  }
@@ -1089,6 +1095,7 @@ declare function useActivity(options?: {
1089
1095
  workspace_ext_id?: string | null | undefined;
1090
1096
  dm_context_only: boolean;
1091
1097
  content?: string | null | undefined;
1098
+ attachments?: string | null | undefined;
1092
1099
  conversation_ext_id?: string | null | undefined;
1093
1100
  message_ext_id?: string | null | undefined;
1094
1101
  read: boolean;
@@ -4035,6 +4042,7 @@ declare function useWorkNotifications(options: {
4035
4042
  workspace_ext_id?: string | null | undefined;
4036
4043
  dm_context_only: boolean;
4037
4044
  content?: string | null | undefined;
4045
+ attachments?: string | null | undefined;
4038
4046
  conversation_ext_id?: string | null | undefined;
4039
4047
  message_ext_id?: string | null | undefined;
4040
4048
  read: boolean;
@@ -4089,6 +4097,7 @@ declare function useWorkNotifications(options: {
4089
4097
  workspace_ext_id?: string | null | undefined;
4090
4098
  dm_context_only: boolean;
4091
4099
  content?: string | null | undefined;
4100
+ attachments?: string | null | undefined;
4092
4101
  conversation_ext_id?: string | null | undefined;
4093
4102
  message_ext_id?: string | null | undefined;
4094
4103
  read: boolean;
@@ -4122,6 +4131,7 @@ declare function useWorkNotifications(options: {
4122
4131
  workspace_ext_id?: string | null | undefined;
4123
4132
  dm_context_only: boolean;
4124
4133
  content?: string | null | undefined;
4134
+ attachments?: string | null | undefined;
4125
4135
  conversation_ext_id?: string | null | undefined;
4126
4136
  message_ext_id?: string | null | undefined;
4127
4137
  read: boolean;
@@ -4156,6 +4166,7 @@ declare function useWorkNotifications(options: {
4156
4166
  workspace_ext_id?: string | null | undefined;
4157
4167
  dm_context_only: boolean;
4158
4168
  content?: string | null | undefined;
4169
+ attachments?: string | null | undefined;
4159
4170
  conversation_ext_id?: string | null | undefined;
4160
4171
  message_ext_id?: string | null | undefined;
4161
4172
  read: boolean;
@@ -4210,6 +4221,7 @@ declare function useWorkNotifications(options: {
4210
4221
  workspace_ext_id?: string | null | undefined;
4211
4222
  dm_context_only: boolean;
4212
4223
  content?: string | null | undefined;
4224
+ attachments?: string | null | undefined;
4213
4225
  conversation_ext_id?: string | null | undefined;
4214
4226
  message_ext_id?: string | null | undefined;
4215
4227
  read: boolean;
@@ -4243,6 +4255,7 @@ declare function useWorkNotifications(options: {
4243
4255
  workspace_ext_id?: string | null | undefined;
4244
4256
  dm_context_only: boolean;
4245
4257
  content?: string | null | undefined;
4258
+ attachments?: string | null | undefined;
4246
4259
  conversation_ext_id?: string | null | undefined;
4247
4260
  message_ext_id?: string | null | undefined;
4248
4261
  read: boolean;
@@ -4300,6 +4313,7 @@ declare function useWorkNotifications(options: {
4300
4313
  workspace_ext_id?: string | null | undefined;
4301
4314
  dm_context_only: boolean;
4302
4315
  content?: string | null | undefined;
4316
+ attachments?: string | null | undefined;
4303
4317
  conversation_ext_id?: string | null | undefined;
4304
4318
  message_ext_id?: string | null | undefined;
4305
4319
  read: boolean;
@@ -4333,6 +4347,7 @@ declare function useWorkNotifications(options: {
4333
4347
  workspace_ext_id?: string | null | undefined;
4334
4348
  dm_context_only: boolean;
4335
4349
  content?: string | null | undefined;
4350
+ attachments?: string | null | undefined;
4336
4351
  conversation_ext_id?: string | null | undefined;
4337
4352
  message_ext_id?: string | null | undefined;
4338
4353
  read: boolean;
@@ -4390,6 +4405,7 @@ declare function useWorkNotifications(options: {
4390
4405
  workspace_ext_id?: string | null | undefined;
4391
4406
  dm_context_only: boolean;
4392
4407
  content?: string | null | undefined;
4408
+ attachments?: string | null | undefined;
4393
4409
  conversation_ext_id?: string | null | undefined;
4394
4410
  message_ext_id?: string | null | undefined;
4395
4411
  read: boolean;
@@ -4423,6 +4439,7 @@ declare function useWorkNotifications(options: {
4423
4439
  workspace_ext_id?: string | null | undefined;
4424
4440
  dm_context_only: boolean;
4425
4441
  content?: string | null | undefined;
4442
+ attachments?: string | null | undefined;
4426
4443
  conversation_ext_id?: string | null | undefined;
4427
4444
  message_ext_id?: string | null | undefined;
4428
4445
  read: boolean;
@@ -4480,6 +4497,7 @@ declare function useWorkNotifications(options: {
4480
4497
  workspace_ext_id?: string | null | undefined;
4481
4498
  dm_context_only: boolean;
4482
4499
  content?: string | null | undefined;
4500
+ attachments?: string | null | undefined;
4483
4501
  conversation_ext_id?: string | null | undefined;
4484
4502
  message_ext_id?: string | null | undefined;
4485
4503
  read: boolean;
@@ -4513,6 +4531,7 @@ declare function useWorkNotifications(options: {
4513
4531
  workspace_ext_id?: string | null | undefined;
4514
4532
  dm_context_only: boolean;
4515
4533
  content?: string | null | undefined;
4534
+ attachments?: string | null | undefined;
4516
4535
  conversation_ext_id?: string | null | undefined;
4517
4536
  message_ext_id?: string | null | undefined;
4518
4537
  read: boolean;
@@ -4547,6 +4566,7 @@ declare function useWorkNotifications(options: {
4547
4566
  workspace_ext_id?: string | null | undefined;
4548
4567
  dm_context_only: boolean;
4549
4568
  content?: string | null | undefined;
4569
+ attachments?: string | null | undefined;
4550
4570
  conversation_ext_id?: string | null | undefined;
4551
4571
  message_ext_id?: string | null | undefined;
4552
4572
  read: boolean;
@@ -4601,6 +4621,7 @@ declare function useWorkNotifications(options: {
4601
4621
  workspace_ext_id?: string | null | undefined;
4602
4622
  dm_context_only: boolean;
4603
4623
  content?: string | null | undefined;
4624
+ attachments?: string | null | undefined;
4604
4625
  conversation_ext_id?: string | null | undefined;
4605
4626
  message_ext_id?: string | null | undefined;
4606
4627
  read: boolean;
@@ -4634,6 +4655,7 @@ declare function useWorkNotifications(options: {
4634
4655
  workspace_ext_id?: string | null | undefined;
4635
4656
  dm_context_only: boolean;
4636
4657
  content?: string | null | undefined;
4658
+ attachments?: string | null | undefined;
4637
4659
  conversation_ext_id?: string | null | undefined;
4638
4660
  message_ext_id?: string | null | undefined;
4639
4661
  read: boolean;
@@ -4846,15 +4868,21 @@ interface DmComposerProps {
4846
4868
  * Enter.
4847
4869
  */
4848
4870
  busy?: boolean;
4849
- /** Called with the trimmed text when the user sends. May reject if the send fails. */
4850
- onSend: (text: string) => void | Promise<void>;
4871
+ /**
4872
+ * Called with the trimmed text and any attached files when the user sends.
4873
+ * The text may be empty when files are attached. May reject if the send
4874
+ * fails, in which case the text and files are given back.
4875
+ */
4876
+ onSend: (text: string, files: File[]) => void | Promise<void>;
4877
+ /** Offer attaching files (button, paste, drag-and-drop). Off by default. */
4878
+ allowAttachments?: boolean;
4851
4879
  /** Shown under the box when the last send failed. */
4852
4880
  error?: string | null;
4853
4881
  /** Extra content between the box and the border (e.g. a peer-specific action). */
4854
4882
  children?: React.ReactNode;
4855
4883
  classNames?: Pick<DmClassNames, 'sendButton'>;
4856
4884
  }
4857
- declare function DmComposer({ placeholder, disabled, busy, onSend, error, children, classNames, }: DmComposerProps): React$1.JSX.Element;
4885
+ declare function DmComposer({ placeholder, disabled, busy, onSend, allowAttachments, error, children, classNames, }: DmComposerProps): React$1.JSX.Element;
4858
4886
 
4859
4887
  interface DmAvatarProps {
4860
4888
  user: DmUser;
@@ -5003,10 +5031,12 @@ interface ImageCropperProps {
5003
5031
  minZoom?: number;
5004
5032
  maxZoom?: number;
5005
5033
  className?: string;
5034
+ /** Classes for the image area, e.g. a taller height than the default `h-72`. */
5035
+ cropAreaClassName?: string;
5006
5036
  /** The crop rectangle (source pixels) + the active aspect, on every change. */
5007
5037
  onCropComplete?: (area: CropArea, aspect: number) => void;
5008
5038
  }
5009
- declare function ImageCropper({ image, aspect, aspectOptions, cropShape, minZoom, maxZoom, className, onCropComplete, }: ImageCropperProps): React$1.JSX.Element;
5039
+ declare function ImageCropper({ image, aspect, aspectOptions, cropShape, minZoom, maxZoom, className, cropAreaClassName, onCropComplete, }: ImageCropperProps): React$1.JSX.Element;
5010
5040
 
5011
5041
  interface ImageCropModalProps {
5012
5042
  open: boolean;
package/dist/index.d.ts CHANGED
@@ -203,6 +203,12 @@ interface ChatBubbleProps {
203
203
  * raw string.
204
204
  */
205
205
  formatTimestamp?: (timestamp: string) => string;
206
+ /**
207
+ * Rendered inside the bubble under the text — e.g. a message's attached
208
+ * files. The host owns fetching and decrypting them. A message with
209
+ * attachments and no text shows only these.
210
+ */
211
+ attachments?: ReactNode;
206
212
  /** Marks the message row, including the deleted tombstone. */
207
213
  'data-testid'?: string;
208
214
  }
@@ -1089,6 +1095,7 @@ declare function useActivity(options?: {
1089
1095
  workspace_ext_id?: string | null | undefined;
1090
1096
  dm_context_only: boolean;
1091
1097
  content?: string | null | undefined;
1098
+ attachments?: string | null | undefined;
1092
1099
  conversation_ext_id?: string | null | undefined;
1093
1100
  message_ext_id?: string | null | undefined;
1094
1101
  read: boolean;
@@ -4035,6 +4042,7 @@ declare function useWorkNotifications(options: {
4035
4042
  workspace_ext_id?: string | null | undefined;
4036
4043
  dm_context_only: boolean;
4037
4044
  content?: string | null | undefined;
4045
+ attachments?: string | null | undefined;
4038
4046
  conversation_ext_id?: string | null | undefined;
4039
4047
  message_ext_id?: string | null | undefined;
4040
4048
  read: boolean;
@@ -4089,6 +4097,7 @@ declare function useWorkNotifications(options: {
4089
4097
  workspace_ext_id?: string | null | undefined;
4090
4098
  dm_context_only: boolean;
4091
4099
  content?: string | null | undefined;
4100
+ attachments?: string | null | undefined;
4092
4101
  conversation_ext_id?: string | null | undefined;
4093
4102
  message_ext_id?: string | null | undefined;
4094
4103
  read: boolean;
@@ -4122,6 +4131,7 @@ declare function useWorkNotifications(options: {
4122
4131
  workspace_ext_id?: string | null | undefined;
4123
4132
  dm_context_only: boolean;
4124
4133
  content?: string | null | undefined;
4134
+ attachments?: string | null | undefined;
4125
4135
  conversation_ext_id?: string | null | undefined;
4126
4136
  message_ext_id?: string | null | undefined;
4127
4137
  read: boolean;
@@ -4156,6 +4166,7 @@ declare function useWorkNotifications(options: {
4156
4166
  workspace_ext_id?: string | null | undefined;
4157
4167
  dm_context_only: boolean;
4158
4168
  content?: string | null | undefined;
4169
+ attachments?: string | null | undefined;
4159
4170
  conversation_ext_id?: string | null | undefined;
4160
4171
  message_ext_id?: string | null | undefined;
4161
4172
  read: boolean;
@@ -4210,6 +4221,7 @@ declare function useWorkNotifications(options: {
4210
4221
  workspace_ext_id?: string | null | undefined;
4211
4222
  dm_context_only: boolean;
4212
4223
  content?: string | null | undefined;
4224
+ attachments?: string | null | undefined;
4213
4225
  conversation_ext_id?: string | null | undefined;
4214
4226
  message_ext_id?: string | null | undefined;
4215
4227
  read: boolean;
@@ -4243,6 +4255,7 @@ declare function useWorkNotifications(options: {
4243
4255
  workspace_ext_id?: string | null | undefined;
4244
4256
  dm_context_only: boolean;
4245
4257
  content?: string | null | undefined;
4258
+ attachments?: string | null | undefined;
4246
4259
  conversation_ext_id?: string | null | undefined;
4247
4260
  message_ext_id?: string | null | undefined;
4248
4261
  read: boolean;
@@ -4300,6 +4313,7 @@ declare function useWorkNotifications(options: {
4300
4313
  workspace_ext_id?: string | null | undefined;
4301
4314
  dm_context_only: boolean;
4302
4315
  content?: string | null | undefined;
4316
+ attachments?: string | null | undefined;
4303
4317
  conversation_ext_id?: string | null | undefined;
4304
4318
  message_ext_id?: string | null | undefined;
4305
4319
  read: boolean;
@@ -4333,6 +4347,7 @@ declare function useWorkNotifications(options: {
4333
4347
  workspace_ext_id?: string | null | undefined;
4334
4348
  dm_context_only: boolean;
4335
4349
  content?: string | null | undefined;
4350
+ attachments?: string | null | undefined;
4336
4351
  conversation_ext_id?: string | null | undefined;
4337
4352
  message_ext_id?: string | null | undefined;
4338
4353
  read: boolean;
@@ -4390,6 +4405,7 @@ declare function useWorkNotifications(options: {
4390
4405
  workspace_ext_id?: string | null | undefined;
4391
4406
  dm_context_only: boolean;
4392
4407
  content?: string | null | undefined;
4408
+ attachments?: string | null | undefined;
4393
4409
  conversation_ext_id?: string | null | undefined;
4394
4410
  message_ext_id?: string | null | undefined;
4395
4411
  read: boolean;
@@ -4423,6 +4439,7 @@ declare function useWorkNotifications(options: {
4423
4439
  workspace_ext_id?: string | null | undefined;
4424
4440
  dm_context_only: boolean;
4425
4441
  content?: string | null | undefined;
4442
+ attachments?: string | null | undefined;
4426
4443
  conversation_ext_id?: string | null | undefined;
4427
4444
  message_ext_id?: string | null | undefined;
4428
4445
  read: boolean;
@@ -4480,6 +4497,7 @@ declare function useWorkNotifications(options: {
4480
4497
  workspace_ext_id?: string | null | undefined;
4481
4498
  dm_context_only: boolean;
4482
4499
  content?: string | null | undefined;
4500
+ attachments?: string | null | undefined;
4483
4501
  conversation_ext_id?: string | null | undefined;
4484
4502
  message_ext_id?: string | null | undefined;
4485
4503
  read: boolean;
@@ -4513,6 +4531,7 @@ declare function useWorkNotifications(options: {
4513
4531
  workspace_ext_id?: string | null | undefined;
4514
4532
  dm_context_only: boolean;
4515
4533
  content?: string | null | undefined;
4534
+ attachments?: string | null | undefined;
4516
4535
  conversation_ext_id?: string | null | undefined;
4517
4536
  message_ext_id?: string | null | undefined;
4518
4537
  read: boolean;
@@ -4547,6 +4566,7 @@ declare function useWorkNotifications(options: {
4547
4566
  workspace_ext_id?: string | null | undefined;
4548
4567
  dm_context_only: boolean;
4549
4568
  content?: string | null | undefined;
4569
+ attachments?: string | null | undefined;
4550
4570
  conversation_ext_id?: string | null | undefined;
4551
4571
  message_ext_id?: string | null | undefined;
4552
4572
  read: boolean;
@@ -4601,6 +4621,7 @@ declare function useWorkNotifications(options: {
4601
4621
  workspace_ext_id?: string | null | undefined;
4602
4622
  dm_context_only: boolean;
4603
4623
  content?: string | null | undefined;
4624
+ attachments?: string | null | undefined;
4604
4625
  conversation_ext_id?: string | null | undefined;
4605
4626
  message_ext_id?: string | null | undefined;
4606
4627
  read: boolean;
@@ -4634,6 +4655,7 @@ declare function useWorkNotifications(options: {
4634
4655
  workspace_ext_id?: string | null | undefined;
4635
4656
  dm_context_only: boolean;
4636
4657
  content?: string | null | undefined;
4658
+ attachments?: string | null | undefined;
4637
4659
  conversation_ext_id?: string | null | undefined;
4638
4660
  message_ext_id?: string | null | undefined;
4639
4661
  read: boolean;
@@ -4846,15 +4868,21 @@ interface DmComposerProps {
4846
4868
  * Enter.
4847
4869
  */
4848
4870
  busy?: boolean;
4849
- /** Called with the trimmed text when the user sends. May reject if the send fails. */
4850
- onSend: (text: string) => void | Promise<void>;
4871
+ /**
4872
+ * Called with the trimmed text and any attached files when the user sends.
4873
+ * The text may be empty when files are attached. May reject if the send
4874
+ * fails, in which case the text and files are given back.
4875
+ */
4876
+ onSend: (text: string, files: File[]) => void | Promise<void>;
4877
+ /** Offer attaching files (button, paste, drag-and-drop). Off by default. */
4878
+ allowAttachments?: boolean;
4851
4879
  /** Shown under the box when the last send failed. */
4852
4880
  error?: string | null;
4853
4881
  /** Extra content between the box and the border (e.g. a peer-specific action). */
4854
4882
  children?: React.ReactNode;
4855
4883
  classNames?: Pick<DmClassNames, 'sendButton'>;
4856
4884
  }
4857
- declare function DmComposer({ placeholder, disabled, busy, onSend, error, children, classNames, }: DmComposerProps): React$1.JSX.Element;
4885
+ declare function DmComposer({ placeholder, disabled, busy, onSend, allowAttachments, error, children, classNames, }: DmComposerProps): React$1.JSX.Element;
4858
4886
 
4859
4887
  interface DmAvatarProps {
4860
4888
  user: DmUser;
@@ -5003,10 +5031,12 @@ interface ImageCropperProps {
5003
5031
  minZoom?: number;
5004
5032
  maxZoom?: number;
5005
5033
  className?: string;
5034
+ /** Classes for the image area, e.g. a taller height than the default `h-72`. */
5035
+ cropAreaClassName?: string;
5006
5036
  /** The crop rectangle (source pixels) + the active aspect, on every change. */
5007
5037
  onCropComplete?: (area: CropArea, aspect: number) => void;
5008
5038
  }
5009
- declare function ImageCropper({ image, aspect, aspectOptions, cropShape, minZoom, maxZoom, className, onCropComplete, }: ImageCropperProps): React$1.JSX.Element;
5039
+ declare function ImageCropper({ image, aspect, aspectOptions, cropShape, minZoom, maxZoom, className, cropAreaClassName, onCropComplete, }: ImageCropperProps): React$1.JSX.Element;
5010
5040
 
5011
5041
  interface ImageCropModalProps {
5012
5042
  open: boolean;
package/dist/index.js CHANGED
@@ -15,9 +15,9 @@ import { useArbi } from './chunk-J4MX2W4H.js';
15
15
  export { ArbiProvider, useArbi } from './chunk-J4MX2W4H.js';
16
16
  import React, { memo, useState, createContext, useMemo, useCallback, useEffect, useRef, useLayoutEffect, useContext, useId, Fragment as Fragment$1 } from 'react';
17
17
  import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
18
- import { resolveCitations, summarizeCitations, connectWithReconnect } from '@arbidocs/sdk/browser';
18
+ import { resolveCitations, summarizeCitations, formatFileSize, connectWithReconnect, dm } from '@arbidocs/sdk/browser';
19
19
  export { Arbi, ArbiError } from '@arbidocs/sdk/browser';
20
- import { Link, Trash2, CheckCheck, Check, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Image as Image$1, Search, CornerDownLeft, X, ArrowLeft, Send, Tags, Crown, Info, Activity, Gauge, Gift, PartyPopper, UserCheck, AtSign, MessageCircleMore, FileX2, FileCheck2, Pencil, FolderPlus, SquareArrowOutUpRight, MessagesSquare, ArrowRight, MoreHorizontal, SquarePen, Mic, Pause, Play, Square, RotateCcw, Camera, Circle } from 'lucide-react';
20
+ import { Link, Trash2, CheckCheck, Check, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Image as Image$1, Search, CornerDownLeft, X, ArrowLeft, Send, Tags, Crown, Info, Activity, Gauge, Gift, PartyPopper, UserCheck, AtSign, MessageCircleMore, FileX2, FileCheck2, Pencil, FolderPlus, SquareArrowOutUpRight, MessagesSquare, Paperclip, ArrowRight, MoreHorizontal, SquarePen, Mic, Pause, Play, Square, RotateCcw, Camera, Circle } from 'lucide-react';
21
21
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
22
22
  import { isMessageType, passwordChangeErrorMessage } from '@arbidocs/client';
23
23
  export { isMessageType } from '@arbidocs/client';
@@ -1066,6 +1066,7 @@ var ChatBubble = memo(function ChatBubble2({
1066
1066
  classNames,
1067
1067
  renderMessage = (m) => m,
1068
1068
  formatTimestamp = (t) => t,
1069
+ attachments,
1069
1070
  "data-testid": testId
1070
1071
  }) {
1071
1072
  const [isHovered, setIsHovered] = useState(false);
@@ -1143,7 +1144,8 @@ var ChatBubble = memo(function ChatBubble2({
1143
1144
  highlightClass
1144
1145
  ),
1145
1146
  children: [
1146
- /* @__PURE__ */ jsx("div", { className: "text-sm [&_.markdown-content]:space-y-1.5 [&_pre]:max-w-full [&_pre]:overflow-x-auto", children: renderMessage(message) }),
1147
+ (message || !attachments) && /* @__PURE__ */ jsx("div", { className: "text-sm [&_.markdown-content]:space-y-1.5 [&_pre]:max-w-full [&_pre]:overflow-x-auto", children: renderMessage(message) }),
1148
+ attachments && /* @__PURE__ */ jsx("div", { className: cn(message && "mt-1.5"), children: attachments }),
1147
1149
  isLastOfRun && /* @__PURE__ */ jsxs(
1148
1150
  "div",
1149
1151
  {
@@ -4332,21 +4334,45 @@ function DmComposer({
4332
4334
  disabled,
4333
4335
  busy,
4334
4336
  onSend,
4337
+ allowAttachments,
4335
4338
  error,
4336
4339
  children,
4337
4340
  classNames
4338
4341
  }) {
4339
4342
  const [draft, setDraft] = useState("");
4343
+ const [files, setFiles] = useState([]);
4344
+ const [attachError, setAttachError] = useState(null);
4345
+ const [dragging, setDragging] = useState(false);
4340
4346
  const inputRef = useRef(null);
4347
+ const fileInputRef = useRef(null);
4348
+ const addFiles = (added) => {
4349
+ if (!allowAttachments || added.length === 0) return;
4350
+ const next = [...files, ...added];
4351
+ try {
4352
+ dm.checkDmAttachmentLimits(next);
4353
+ setFiles(next);
4354
+ setAttachError(null);
4355
+ } catch (err) {
4356
+ setAttachError(err instanceof Error ? err.message : "Could not attach the file");
4357
+ }
4358
+ };
4359
+ const removeFile = (index) => {
4360
+ setFiles((current) => current.filter((_, i) => i !== index));
4361
+ setAttachError(null);
4362
+ };
4341
4363
  const submit = async () => {
4342
4364
  const text = draft.trim();
4343
- if (!text || disabled || busy) return;
4365
+ if (!text && files.length === 0 || disabled || busy) return;
4366
+ const sending = files;
4344
4367
  setDraft("");
4368
+ setFiles([]);
4369
+ setAttachError(null);
4345
4370
  try {
4346
- await onSend(text);
4371
+ await onSend(text, sending);
4347
4372
  inputRef.current?.focus();
4348
4373
  } catch {
4349
4374
  setDraft(text);
4375
+ setFiles(sending);
4350
4376
  }
4351
4377
  };
4352
4378
  const onKeyDown = (e) => {
@@ -4355,41 +4381,143 @@ function DmComposer({
4355
4381
  void submit();
4356
4382
  }
4357
4383
  };
4358
- return /* @__PURE__ */ jsxs("div", { className: "border-t border-border p-3", children: [
4359
- children,
4360
- /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
4361
- /* @__PURE__ */ jsx(
4362
- Textarea,
4363
- {
4364
- ref: inputRef,
4365
- value: draft,
4366
- onChange: (e) => setDraft(e.target.value),
4367
- onKeyDown,
4368
- placeholder,
4369
- rows: 1,
4370
- disabled,
4371
- className: "max-h-40 min-h-[44px] resize-none",
4372
- "data-testid": "arbi-dm-input"
4373
- }
4384
+ const onPaste = (e) => {
4385
+ if (!allowAttachments) return;
4386
+ const pasted = Array.from(e.clipboardData?.files ?? []);
4387
+ if (pasted.length === 0) return;
4388
+ e.preventDefault();
4389
+ addFiles(pasted);
4390
+ };
4391
+ const hasFiles = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
4392
+ const dropHandlers = allowAttachments ? {
4393
+ onDragOver: (e) => {
4394
+ if (!hasFiles(e) || disabled) return;
4395
+ e.preventDefault();
4396
+ setDragging(true);
4397
+ },
4398
+ onDragLeave: (e) => {
4399
+ if (e.currentTarget.contains(e.relatedTarget)) return;
4400
+ setDragging(false);
4401
+ },
4402
+ onDrop: (e) => {
4403
+ setDragging(false);
4404
+ const dropped = Array.from(e.dataTransfer?.files ?? []);
4405
+ if (dropped.length === 0 || disabled) return;
4406
+ e.preventDefault();
4407
+ addFiles(dropped);
4408
+ }
4409
+ } : {};
4410
+ return /* @__PURE__ */ jsxs(
4411
+ "div",
4412
+ {
4413
+ className: cn(
4414
+ "border-t border-border p-3",
4415
+ dragging && "bg-muted/60 outline-dashed outline-2 -outline-offset-4 outline-primary"
4374
4416
  ),
4375
- /* @__PURE__ */ jsxs(
4376
- Button,
4377
- {
4378
- type: "button",
4379
- onClick: () => void submit(),
4380
- disabled: disabled || busy || !draft.trim(),
4381
- className: cn(classNames?.sendButton),
4382
- "data-testid": "arbi-dm-send",
4383
- "aria-label": "Send message",
4384
- children: [
4385
- busy ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "size-4" }),
4386
- " Send"
4387
- ]
4388
- }
4389
- )
4390
- ] }),
4391
- error && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-destructive", "data-testid": "arbi-dm-error", children: error })
4392
- ] });
4417
+ "data-testid": "arbi-dm-composer",
4418
+ ...dropHandlers,
4419
+ children: [
4420
+ children,
4421
+ files.length > 0 && /* @__PURE__ */ jsx("ul", { className: "mb-2 flex flex-wrap gap-2", "aria-label": "Attached files", children: files.map((f, index) => /* @__PURE__ */ jsxs(
4422
+ "li",
4423
+ {
4424
+ "data-testid": "arbi-dm-attachment-chip",
4425
+ className: "flex max-w-full items-center gap-2 rounded-md border border-border/70 bg-muted/30 px-2.5 py-1.5 text-xs",
4426
+ children: [
4427
+ /* @__PURE__ */ jsx(Paperclip, { className: "size-3 shrink-0", "aria-hidden": "true" }),
4428
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: f.name }),
4429
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground", children: formatFileSize(f.size) }),
4430
+ /* @__PURE__ */ jsx(
4431
+ "button",
4432
+ {
4433
+ type: "button",
4434
+ disabled: busy,
4435
+ "aria-label": `Remove ${f.name}`,
4436
+ onClick: () => removeFile(index),
4437
+ className: "shrink-0 rounded focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
4438
+ children: /* @__PURE__ */ jsx(X, { className: "size-3" })
4439
+ }
4440
+ )
4441
+ ]
4442
+ },
4443
+ `${f.name}-${index}`
4444
+ )) }),
4445
+ /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
4446
+ allowAttachments && /* @__PURE__ */ jsxs(Fragment, { children: [
4447
+ /* @__PURE__ */ jsx(
4448
+ Button,
4449
+ {
4450
+ type: "button",
4451
+ variant: "ghost",
4452
+ size: "icon",
4453
+ disabled: disabled || busy,
4454
+ onClick: () => fileInputRef.current?.click(),
4455
+ "aria-label": "Attach files",
4456
+ title: "Attach files (or paste / drop them here)",
4457
+ "data-testid": "arbi-dm-attach",
4458
+ className: "min-h-[44px] shrink-0",
4459
+ children: /* @__PURE__ */ jsx(Paperclip, { className: "size-4" })
4460
+ }
4461
+ ),
4462
+ /* @__PURE__ */ jsx(
4463
+ "input",
4464
+ {
4465
+ ref: fileInputRef,
4466
+ type: "file",
4467
+ multiple: true,
4468
+ hidden: true,
4469
+ "data-testid": "arbi-dm-file-input",
4470
+ onChange: (e) => {
4471
+ addFiles(Array.from(e.target.files ?? []));
4472
+ e.target.value = "";
4473
+ }
4474
+ }
4475
+ )
4476
+ ] }),
4477
+ /* @__PURE__ */ jsx(
4478
+ Textarea,
4479
+ {
4480
+ ref: inputRef,
4481
+ value: draft,
4482
+ onChange: (e) => setDraft(e.target.value),
4483
+ onKeyDown,
4484
+ onPaste,
4485
+ placeholder,
4486
+ rows: 1,
4487
+ disabled,
4488
+ className: "max-h-40 min-h-[44px] resize-none",
4489
+ "data-testid": "arbi-dm-input"
4490
+ }
4491
+ ),
4492
+ /* @__PURE__ */ jsxs(
4493
+ Button,
4494
+ {
4495
+ type: "button",
4496
+ onClick: () => void submit(),
4497
+ disabled: disabled || busy || !draft.trim() && files.length === 0,
4498
+ className: cn(classNames?.sendButton),
4499
+ "data-testid": "arbi-dm-send",
4500
+ "aria-label": "Send message",
4501
+ children: [
4502
+ busy ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "size-4" }),
4503
+ " Send"
4504
+ ]
4505
+ }
4506
+ )
4507
+ ] }),
4508
+ attachError && /* @__PURE__ */ jsx(
4509
+ "p",
4510
+ {
4511
+ className: "mt-2 text-xs text-destructive",
4512
+ role: "alert",
4513
+ "data-testid": "arbi-dm-attach-error",
4514
+ children: attachError
4515
+ }
4516
+ ),
4517
+ error && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-destructive", "data-testid": "arbi-dm-error", children: error })
4518
+ ]
4519
+ }
4520
+ );
4393
4521
  }
4394
4522
  var DEFAULT_START_BY_EMAIL_LABELS = {
4395
4523
  email: "Email address",
@@ -4609,6 +4737,7 @@ function ImageCropper({
4609
4737
  minZoom = 1,
4610
4738
  maxZoom = 3,
4611
4739
  className,
4740
+ cropAreaClassName,
4612
4741
  onCropComplete
4613
4742
  }) {
4614
4743
  const [crop, setCrop] = useState({ x: 0, y: 0 });
@@ -4624,21 +4753,30 @@ function ImageCropper({
4624
4753
  [onCropComplete, activeAspect]
4625
4754
  );
4626
4755
  return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-3", className), children: [
4627
- /* @__PURE__ */ jsx("div", { className: "relative h-72 w-full overflow-hidden rounded-md bg-foreground/95", children: /* @__PURE__ */ jsx(
4628
- Cropper,
4756
+ /* @__PURE__ */ jsx(
4757
+ "div",
4629
4758
  {
4630
- image,
4631
- crop,
4632
- zoom,
4633
- aspect: activeAspect,
4634
- cropShape,
4635
- showGrid: cropShape === "rect",
4636
- onCropChange: setCrop,
4637
- onZoomChange: setZoom,
4638
- onCropComplete: handleComplete,
4639
- objectFit: "contain"
4759
+ className: cn(
4760
+ "relative h-72 w-full overflow-hidden rounded-md bg-foreground/95",
4761
+ cropAreaClassName
4762
+ ),
4763
+ children: /* @__PURE__ */ jsx(
4764
+ Cropper,
4765
+ {
4766
+ image,
4767
+ crop,
4768
+ zoom,
4769
+ aspect: activeAspect,
4770
+ cropShape,
4771
+ showGrid: cropShape === "rect",
4772
+ onCropChange: setCrop,
4773
+ onZoomChange: setZoom,
4774
+ onCropComplete: handleComplete,
4775
+ objectFit: "contain"
4776
+ }
4777
+ )
4640
4778
  }
4641
- ) }),
4779
+ ),
4642
4780
  aspectOptions && aspectOptions.length > 1 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1", "data-testid": "image-cropper-aspects", children: [
4643
4781
  /* @__PURE__ */ jsx("span", { className: "mr-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Ratio" }),
4644
4782
  aspectOptions.map((opt) => {