@poolse/react-ui 0.2.0-alpha.7 → 1.0.0-beta.0

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
@@ -652,8 +652,9 @@ function MessageBubble({
652
652
  hour: "2-digit",
653
653
  minute: "2-digit"
654
654
  }) : "";
655
+ const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
655
656
  return /* @__PURE__ */ jsxs("div", { className, children: [
656
- message.quoted_message && /* @__PURE__ */ jsx(
657
+ showQuoteCard === "full" && /* @__PURE__ */ jsx(
657
658
  QuotedCard,
658
659
  {
659
660
  quoted: message.quoted_message,
@@ -662,6 +663,7 @@ function MessageBubble({
662
663
  ...onQuotedClick ? { onClick: onQuotedClick } : {}
663
664
  }
664
665
  ),
666
+ showQuoteCard === "placeholder" && /* @__PURE__ */ jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
665
667
  message.deleted_at ? /* @__PURE__ */ jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : /* @__PURE__ */ jsx("span", { children: message.body ?? "" }),
666
668
  /* @__PURE__ */ jsxs("span", { className: "poolse-message__meta", children: [
667
669
  /* @__PURE__ */ jsx("span", { children: time }),
@@ -677,6 +679,22 @@ function MessageBubble({
677
679
  ] })
678
680
  ] });
679
681
  }
682
+ function QuotedPlaceholder({
683
+ isSelf,
684
+ quotedMessageId: _quotedMessageId
685
+ }) {
686
+ return /* @__PURE__ */ jsxs(
687
+ "div",
688
+ {
689
+ className: `poolse-quote poolse-quote--placeholder ${isSelf ? "poolse-quote--self" : "poolse-quote--other"}`,
690
+ "aria-label": "Quoted message",
691
+ children: [
692
+ /* @__PURE__ */ jsx("span", { className: "poolse-quote__sender", children: "Replying to a message" }),
693
+ /* @__PURE__ */ jsx("span", { className: "poolse-quote__body", children: "Loading preview\u2026" })
694
+ ]
695
+ }
696
+ );
697
+ }
680
698
  function QuotedCard({
681
699
  quoted,
682
700
  isSelf,
@@ -963,80 +981,87 @@ function MessageRow({
963
981
  const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
964
982
  const handleSave = onSaveEdit ?? (async () => void 0);
965
983
  const handleCancel = onCancelEdit ?? (() => void 0);
966
- return /* @__PURE__ */ jsxs("div", { className: `poolse-message-row ${isSelf ? "poolse-message-row--right" : ""}`, children: [
967
- editing ? /* @__PURE__ */ jsx(
968
- EditableMessageBubble,
969
- {
970
- message: msg,
971
- currentUserId: meId,
972
- ...readState ? { readState } : {},
973
- editing: true,
974
- onSave: handleSave,
975
- onCancel: handleCancel
976
- }
977
- ) : /* @__PURE__ */ jsx(
978
- MessageBubble,
979
- {
980
- message: msg,
981
- currentUserId: meId,
982
- ...readState ? { readState } : {},
983
- ...labelFor ? { labelFor } : {},
984
- ...onQuotedClick ? { onQuotedClick } : {}
985
- }
986
- ),
987
- showAttachments && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsx(AttachmentPreview, { attachment: att }, att.id)) }),
988
- showReactions && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsx(
989
- InlineReactions,
990
- {
991
- reactions: reactionsHook.reactions,
992
- currentUserId: meId,
993
- onAdd: (e) => void reactionsHook.addReaction(e),
994
- onRemove: (e) => void reactionsHook.removeReaction(e)
995
- }
996
- ) }),
997
- showThreadPill && /* @__PURE__ */ jsxs(
998
- "button",
999
- {
1000
- type: "button",
1001
- className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
1002
- onClick: onOpenThread,
1003
- "aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
1004
- children: [
1005
- /* @__PURE__ */ jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
1006
- /* @__PURE__ */ jsxs("span", { children: [
1007
- replyCount,
1008
- " ",
1009
- replyCount === 1 ? "reply" : "replies"
1010
- ] })
1011
- ]
1012
- }
1013
- ),
1014
- showActions && /* @__PURE__ */ jsx(
1015
- "div",
1016
- {
1017
- className: `poolse-message-row__actions ${isSelf ? "poolse-message-row__actions--right" : "poolse-message-row__actions--left"}`,
1018
- children: /* @__PURE__ */ jsx(
1019
- MessageActions,
984
+ return /* @__PURE__ */ jsxs(
985
+ "div",
986
+ {
987
+ className: `poolse-message-row ${isSelf ? "poolse-message-row--right" : ""}`,
988
+ "data-message-id": msg.id,
989
+ children: [
990
+ editing ? /* @__PURE__ */ jsx(
991
+ EditableMessageBubble,
1020
992
  {
1021
- ...reactions ? {
1022
- onReact: (emoji) => {
1023
- void reactionsHook.addReaction(emoji);
1024
- }
1025
- } : {},
1026
- ...threads && onOpenThread ? { onReply: onOpenThread } : {},
1027
- ...quotations && onQuote ? { onQuote } : {},
1028
- ...msg.body ? {
1029
- onCopy: () => {
1030
- void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
993
+ message: msg,
994
+ currentUserId: meId,
995
+ ...readState ? { readState } : {},
996
+ editing: true,
997
+ onSave: handleSave,
998
+ onCancel: handleCancel
999
+ }
1000
+ ) : /* @__PURE__ */ jsx(
1001
+ MessageBubble,
1002
+ {
1003
+ message: msg,
1004
+ currentUserId: meId,
1005
+ ...readState ? { readState } : {},
1006
+ ...labelFor ? { labelFor } : {},
1007
+ ...onQuotedClick ? { onQuotedClick } : {}
1008
+ }
1009
+ ),
1010
+ showAttachments && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsx(AttachmentPreview, { attachment: att }, att.id)) }),
1011
+ showReactions && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsx(
1012
+ InlineReactions,
1013
+ {
1014
+ reactions: reactionsHook.reactions,
1015
+ currentUserId: meId,
1016
+ onAdd: (e) => void reactionsHook.addReaction(e),
1017
+ onRemove: (e) => void reactionsHook.removeReaction(e)
1018
+ }
1019
+ ) }),
1020
+ showThreadPill && /* @__PURE__ */ jsxs(
1021
+ "button",
1022
+ {
1023
+ type: "button",
1024
+ className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
1025
+ onClick: onOpenThread,
1026
+ "aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
1027
+ children: [
1028
+ /* @__PURE__ */ jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
1029
+ /* @__PURE__ */ jsxs("span", { children: [
1030
+ replyCount,
1031
+ " ",
1032
+ replyCount === 1 ? "reply" : "replies"
1033
+ ] })
1034
+ ]
1035
+ }
1036
+ ),
1037
+ showActions && /* @__PURE__ */ jsx(
1038
+ "div",
1039
+ {
1040
+ className: `poolse-message-row__actions ${isSelf ? "poolse-message-row__actions--right" : "poolse-message-row__actions--left"}`,
1041
+ children: /* @__PURE__ */ jsx(
1042
+ MessageActions,
1043
+ {
1044
+ ...reactions ? {
1045
+ onReact: (emoji) => {
1046
+ void reactionsHook.addReaction(emoji);
1047
+ }
1048
+ } : {},
1049
+ ...threads && onOpenThread ? { onReply: onOpenThread } : {},
1050
+ ...quotations && onQuote ? { onQuote } : {},
1051
+ ...msg.body ? {
1052
+ onCopy: () => {
1053
+ void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
1054
+ }
1055
+ } : {},
1056
+ ...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
1057
+ ...isSelf && onDelete ? { onDelete } : {}
1031
1058
  }
1032
- } : {},
1033
- ...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
1034
- ...isSelf && onDelete ? { onDelete } : {}
1059
+ )
1035
1060
  }
1036
1061
  )
1037
- }
1038
- )
1039
- ] });
1062
+ ]
1063
+ }
1064
+ );
1040
1065
  }
1041
1066
  function InlineReactions({
1042
1067
  reactions,
@@ -1342,7 +1367,7 @@ function ConversationView({
1342
1367
  })() : msg;
1343
1368
  const isSelf = me !== null && msg.sender_id === me.id;
1344
1369
  const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
1345
- return /* @__PURE__ */ jsx("div", { "data-message-id": msg.id, children: /* @__PURE__ */ jsx(
1370
+ return /* @__PURE__ */ jsx(
1346
1371
  MessageRow,
1347
1372
  {
1348
1373
  msg: enriched,
@@ -1365,8 +1390,9 @@ function ConversationView({
1365
1390
  onOpenThread: () => setThreadRootId(msg.id),
1366
1391
  onQuote: () => setReplyingTo(msg),
1367
1392
  onQuotedClick: scrollToOriginal
1368
- }
1369
- ) }, msg.id);
1393
+ },
1394
+ msg.id
1395
+ );
1370
1396
  }),
1371
1397
  error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
1372
1398
  "Failed to load: ",