@mieweb/ui 0.9.0-dev.0 → 0.9.0-dev.2

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.
Files changed (50) hide show
  1. package/dist/{chunk-WIAQQNFU.cjs → chunk-2A2FLQJC.cjs} +1138 -12
  2. package/dist/chunk-2A2FLQJC.cjs.map +1 -0
  3. package/dist/{chunk-ODYQYLO2.js → chunk-2KQWEROH.js} +7 -3
  4. package/dist/chunk-2KQWEROH.js.map +1 -0
  5. package/dist/{chunk-5BVFVXHN.cjs → chunk-5VXRKOPR.cjs} +16 -525
  6. package/dist/chunk-5VXRKOPR.cjs.map +1 -0
  7. package/dist/{chunk-6XDPJWSC.cjs → chunk-ADUEASXF.cjs} +7 -3
  8. package/dist/chunk-ADUEASXF.cjs.map +1 -0
  9. package/dist/{chunk-O6GJ4IYS.js → chunk-IF3X2WZP.js} +16 -521
  10. package/dist/chunk-IF3X2WZP.js.map +1 -0
  11. package/dist/{chunk-22CYDCXA.js → chunk-KATEJG2F.js} +1137 -13
  12. package/dist/chunk-KATEJG2F.js.map +1 -0
  13. package/dist/{chunk-DGRXAIWK.js → chunk-KI5ES4GR.js} +17 -2
  14. package/dist/chunk-KI5ES4GR.js.map +1 -0
  15. package/dist/{chunk-FQBTGS3E.cjs → chunk-O425FKDI.cjs} +563 -55
  16. package/dist/chunk-O425FKDI.cjs.map +1 -0
  17. package/dist/{chunk-MXQ7J4BB.js → chunk-RPG2ZP2T.js} +557 -53
  18. package/dist/chunk-RPG2ZP2T.js.map +1 -0
  19. package/dist/{chunk-CXDMZT45.cjs → chunk-XRKBHECB.cjs} +17 -2
  20. package/dist/chunk-XRKBHECB.cjs.map +1 -0
  21. package/dist/components/SuperChat/index.cjs +36 -17
  22. package/dist/components/SuperChat/index.cjs.map +1 -1
  23. package/dist/components/SuperChat/index.d.cts +16 -3
  24. package/dist/components/SuperChat/index.d.ts +16 -3
  25. package/dist/components/SuperChat/index.js +31 -12
  26. package/dist/components/SuperChat/index.js.map +1 -1
  27. package/dist/components/SuperChat/plugins/index.cjs +3 -3
  28. package/dist/components/SuperChat/plugins/index.js +2 -2
  29. package/dist/esheet.cjs +4 -4
  30. package/dist/esheet.js +1 -1
  31. package/dist/index.cjs +1164 -2179
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +9 -2
  34. package/dist/index.d.ts +9 -2
  35. package/dist/index.js +976 -1999
  36. package/dist/index.js.map +1 -1
  37. package/dist/styles.css +1 -1
  38. package/dist/tailwind-preset.cjs +4 -4
  39. package/dist/tailwind-preset.js +1 -1
  40. package/package.json +1 -1
  41. package/dist/chunk-22CYDCXA.js.map +0 -1
  42. package/dist/chunk-5BVFVXHN.cjs.map +0 -1
  43. package/dist/chunk-6XDPJWSC.cjs.map +0 -1
  44. package/dist/chunk-CXDMZT45.cjs.map +0 -1
  45. package/dist/chunk-DGRXAIWK.js.map +0 -1
  46. package/dist/chunk-FQBTGS3E.cjs.map +0 -1
  47. package/dist/chunk-MXQ7J4BB.js.map +0 -1
  48. package/dist/chunk-O6GJ4IYS.js.map +0 -1
  49. package/dist/chunk-ODYQYLO2.js.map +0 -1
  50. package/dist/chunk-WIAQQNFU.cjs.map +0 -1
@@ -19,7 +19,8 @@ interface SuperChatProps {
19
19
  /** Disable the composer. */
20
20
  readOnly?: boolean;
21
21
  /**
22
- * File categories the composer accepts for paste and the paperclip picker.
22
+ * File categories the composer accepts for paste, drag-and-drop, and the
23
+ * file picker in the `+` → “Attach files” menu.
23
24
  * Defaults to `['image', 'video', 'audio', 'pdf']`.
24
25
  */
25
26
  acceptedFileTypes?: AttachmentKind[];
@@ -47,11 +48,17 @@ interface SuperChatProps {
47
48
  defaultCopyFormat?: SuperChatCopyFormat;
48
49
  /** Additional class name. */
49
50
  className?: string;
51
+ /**
52
+ * Fired when the local user sends a message. If the callback returns a
53
+ * promise it is awaited, and a rejected send restores the typed text into
54
+ * the composer (the declared `void` return keeps every previously valid
55
+ * callback assignable).
56
+ */
50
57
  onMessageSent?: (text: string, meta: {
51
58
  conversation: SuperChatConversation;
52
59
  mentions: string[];
53
60
  attachments: ComposerAttachment[];
54
- }) => void;
61
+ }) => void | Promise<void>;
55
62
  /**
56
63
  * Fired when the local user saves an edit to one of their own messages.
57
64
  * Providing this enables the inline "Edit" affordance on self-authored
@@ -110,7 +117,8 @@ interface SuperChatInboxProps {
110
117
  /** Disable the composer. */
111
118
  readOnly?: boolean;
112
119
  /**
113
- * File categories the composer accepts for paste and the paperclip picker.
120
+ * File categories the composer accepts for paste, drag-and-drop, and the
121
+ * file picker in the `+` → “Attach files” menu.
114
122
  * Defaults to `['image', 'video', 'audio', 'pdf']`.
115
123
  */
116
124
  acceptedFileTypes?: AttachmentKind[];
@@ -126,6 +134,11 @@ interface SuperChatInboxProps {
126
134
  defaultCopyFormat?: SuperChatCopyFormat;
127
135
  /** Additional class name. */
128
136
  className?: string;
137
+ /**
138
+ * Fired when the local user sends a message. If the callback returns a
139
+ * promise it is awaited, and a rejected send restores the typed text into
140
+ * the composer (same contract as {@link SuperChatProps.onMessageSent}).
141
+ */
129
142
  onMessageSent?: (text: string, meta: {
130
143
  conversation: SuperChatConversation;
131
144
  mentions: string[];
@@ -19,7 +19,8 @@ interface SuperChatProps {
19
19
  /** Disable the composer. */
20
20
  readOnly?: boolean;
21
21
  /**
22
- * File categories the composer accepts for paste and the paperclip picker.
22
+ * File categories the composer accepts for paste, drag-and-drop, and the
23
+ * file picker in the `+` → “Attach files” menu.
23
24
  * Defaults to `['image', 'video', 'audio', 'pdf']`.
24
25
  */
25
26
  acceptedFileTypes?: AttachmentKind[];
@@ -47,11 +48,17 @@ interface SuperChatProps {
47
48
  defaultCopyFormat?: SuperChatCopyFormat;
48
49
  /** Additional class name. */
49
50
  className?: string;
51
+ /**
52
+ * Fired when the local user sends a message. If the callback returns a
53
+ * promise it is awaited, and a rejected send restores the typed text into
54
+ * the composer (the declared `void` return keeps every previously valid
55
+ * callback assignable).
56
+ */
50
57
  onMessageSent?: (text: string, meta: {
51
58
  conversation: SuperChatConversation;
52
59
  mentions: string[];
53
60
  attachments: ComposerAttachment[];
54
- }) => void;
61
+ }) => void | Promise<void>;
55
62
  /**
56
63
  * Fired when the local user saves an edit to one of their own messages.
57
64
  * Providing this enables the inline "Edit" affordance on self-authored
@@ -110,7 +117,8 @@ interface SuperChatInboxProps {
110
117
  /** Disable the composer. */
111
118
  readOnly?: boolean;
112
119
  /**
113
- * File categories the composer accepts for paste and the paperclip picker.
120
+ * File categories the composer accepts for paste, drag-and-drop, and the
121
+ * file picker in the `+` → “Attach files” menu.
114
122
  * Defaults to `['image', 'video', 'audio', 'pdf']`.
115
123
  */
116
124
  acceptedFileTypes?: AttachmentKind[];
@@ -126,6 +134,11 @@ interface SuperChatInboxProps {
126
134
  defaultCopyFormat?: SuperChatCopyFormat;
127
135
  /** Additional class name. */
128
136
  className?: string;
137
+ /**
138
+ * Fired when the local user sends a message. If the callback returns a
139
+ * promise it is awaited, and a rejected send restores the typed text into
140
+ * the composer (same contract as {@link SuperChatProps.onMessageSent}).
141
+ */
129
142
  onMessageSent?: (text: string, meta: {
130
143
  conversation: SuperChatConversation;
131
144
  mentions: string[];
@@ -1,13 +1,14 @@
1
1
  import { TextRenderContext } from '../../chunk-I6CY5C6A.js';
2
2
  export { TextRenderContext, useTextRenderContext } from '../../chunk-I6CY5C6A.js';
3
- import { ChatBubble, MCPToolCallDisplay, AITypingIndicator, SparklesIcon, CloseIcon } from '../../chunk-22CYDCXA.js';
4
- import { MessageComposer } from '../../chunk-O6GJ4IYS.js';
3
+ import { ChatBubble, MCPToolCallDisplay, AITypingIndicator, SparklesIcon, CloseIcon, ChatComposer } from '../../chunk-KATEJG2F.js';
4
+ import '../../chunk-IF3X2WZP.js';
5
5
  import { Dropdown, DropdownSubmenu, DropdownItem } from '../../chunk-KU3XRHWA.js';
6
6
  import { Avatar } from '../../chunk-HZ4MBUC3.js';
7
7
  import '../../chunk-IQ4KQJAO.js';
8
8
  import '../../chunk-VVDE4CHU.js';
9
9
  import '../../chunk-6NZXWKUE.js';
10
10
  import '../../chunk-3IMM2PM4.js';
11
+ import '../../chunk-BKSPDTX4.js';
11
12
  import { Badge } from '../../chunk-BMSG4NBH.js';
12
13
  import { cn } from '../../chunk-TQONQSJO.js';
13
14
  import '../../chunk-T4ME7QCT.js';
@@ -1158,14 +1159,29 @@ function SuperChat({
1158
1159
  () => acceptTokensFor(acceptedFileTypes),
1159
1160
  [acceptedFileTypes]
1160
1161
  );
1162
+ const [draft, setDraft] = React2.useState("");
1163
+ const draftEpochRef = React2.useRef(0);
1164
+ const handleDraftChange = React2.useCallback((value) => {
1165
+ draftEpochRef.current += 1;
1166
+ setDraft(value);
1167
+ }, []);
1161
1168
  const handleComposerSend = React2.useCallback(
1162
1169
  async (message) => {
1163
- const text = message.content;
1164
- const mentions = detectMentions(text, conversation.participants);
1165
- const attachments = await filesToComposerAttachments(
1166
- message.attachments ?? []
1167
- );
1168
- onMessageSent?.(text, { conversation, mentions, attachments });
1170
+ const epoch = draftEpochRef.current;
1171
+ try {
1172
+ const text = message.content;
1173
+ const mentions = detectMentions(text, conversation.participants);
1174
+ const attachments = await filesToComposerAttachments(
1175
+ message.attachments ?? []
1176
+ );
1177
+ await Promise.resolve(
1178
+ onMessageSent?.(text, { conversation, mentions, attachments })
1179
+ );
1180
+ } catch {
1181
+ if (draftEpochRef.current === epoch) {
1182
+ setDraft(message.content);
1183
+ }
1184
+ }
1169
1185
  },
1170
1186
  [conversation, onMessageSent]
1171
1187
  );
@@ -1297,16 +1313,19 @@ function SuperChat({
1297
1313
  }
1298
1314
  ),
1299
1315
  /* @__PURE__ */ jsx(
1300
- MessageComposer,
1316
+ ChatComposer,
1301
1317
  {
1318
+ value: draft,
1319
+ onValueChange: handleDraftChange,
1302
1320
  onSend: handleComposerSend,
1303
1321
  disabled: readOnly,
1304
1322
  placeholder: readOnly ? "Read-only conversation" : "Type a message\u2026 use @ to address an agent",
1305
1323
  mentionOptions,
1306
- showAttachmentPicker: !readOnly,
1307
- showCameraButton: false,
1324
+ allowAttachments: !readOnly,
1308
1325
  acceptedFileTypes: composerAccept,
1309
- maxLength: 1e5
1326
+ maxFileSize: 25 * 1024 * 1024,
1327
+ maxLength: 1e5,
1328
+ inputLabel: "Message"
1310
1329
  }
1311
1330
  )
1312
1331
  ]