@burdenoff/microfe-comradecircle 2026.704.1 → 2026.704.3

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 (54) hide show
  1. package/dist/comradecircle/components/Avatar.js +52 -17
  2. package/dist/comradecircle/components/Avatar.js.map +1 -1
  3. package/dist/comradecircle/components/AvatarUploadField.js +91 -0
  4. package/dist/comradecircle/components/AvatarUploadField.js.map +1 -0
  5. package/dist/comradecircle/components/CircleCard.js +55 -52
  6. package/dist/comradecircle/components/CircleCard.js.map +1 -1
  7. package/dist/comradecircle/components/CommentThread.js +80 -64
  8. package/dist/comradecircle/components/CommentThread.js.map +1 -1
  9. package/dist/comradecircle/components/CreateCircleDialog.js +74 -63
  10. package/dist/comradecircle/components/CreateCircleDialog.js.map +1 -1
  11. package/dist/comradecircle/components/EventCard.js +84 -58
  12. package/dist/comradecircle/components/EventCard.js.map +1 -1
  13. package/dist/comradecircle/components/FileImage.js +20 -0
  14. package/dist/comradecircle/components/FileImage.js.map +1 -0
  15. package/dist/comradecircle/components/ImageAttachments.js +97 -0
  16. package/dist/comradecircle/components/ImageAttachments.js.map +1 -0
  17. package/dist/comradecircle/components/MemberIdentity.js +4 -2
  18. package/dist/comradecircle/components/MemberIdentity.js.map +1 -1
  19. package/dist/comradecircle/components/PollCard.js +65 -44
  20. package/dist/comradecircle/components/PollCard.js.map +1 -1
  21. package/dist/comradecircle/components/PostCard.js +8 -15
  22. package/dist/comradecircle/components/PostCard.js.map +1 -1
  23. package/dist/comradecircle/components/PostComposer.js +45 -35
  24. package/dist/comradecircle/components/PostComposer.js.map +1 -1
  25. package/dist/comradecircle/components/ReactionBar.js +1 -1
  26. package/dist/comradecircle/components/ReactionBar.js.map +1 -1
  27. package/dist/comradecircle/components/StateViews.js +1 -16
  28. package/dist/comradecircle/components/StateViews.js.map +1 -1
  29. package/dist/comradecircle/components/StatusBadge.js +1 -1
  30. package/dist/comradecircle/components/StatusBadge.js.map +1 -1
  31. package/dist/comradecircle/hooks/index.js +1 -0
  32. package/dist/comradecircle/hooks/useComradeCircleApi.js +244 -241
  33. package/dist/comradecircle/hooks/useComradeCircleApi.js.map +1 -1
  34. package/dist/comradecircle/hooks/useFiles.js +78 -0
  35. package/dist/comradecircle/hooks/useFiles.js.map +1 -0
  36. package/dist/comradecircle/lib/graphql-cache.js +9 -0
  37. package/dist/comradecircle/lib/graphql-cache.js.map +1 -0
  38. package/dist/comradecircle/pages/FeedPage.js +79 -33
  39. package/dist/comradecircle/pages/FeedPage.js.map +1 -1
  40. package/dist/comradecircle/pages/circles/CircleDetailPage.js +354 -242
  41. package/dist/comradecircle/pages/circles/CircleDetailPage.js.map +1 -1
  42. package/dist/comradecircle/pages/circles/CirclesPage.js +97 -47
  43. package/dist/comradecircle/pages/circles/CirclesPage.js.map +1 -1
  44. package/dist/comradecircle/pages/events/EventDetailPage.js +193 -126
  45. package/dist/comradecircle/pages/events/EventDetailPage.js.map +1 -1
  46. package/dist/comradecircle/pages/events/EventsPage.js +74 -34
  47. package/dist/comradecircle/pages/events/EventsPage.js.map +1 -1
  48. package/dist/comradecircle/pages/members/MemberProfilePage.js +154 -81
  49. package/dist/comradecircle/pages/members/MemberProfilePage.js.map +1 -1
  50. package/dist/comradecircle/pages/members/MembersPage.js +141 -71
  51. package/dist/comradecircle/pages/members/MembersPage.js.map +1 -1
  52. package/dist/comradecircle/pages/profile/MyProfilePage.js +298 -191
  53. package/dist/comradecircle/pages/profile/MyProfilePage.js.map +1 -1
  54. package/package.json +1 -1
@@ -0,0 +1,97 @@
1
+ import { cn as e } from "../utils/cn.js";
2
+ import { FILE_FOLDERS as t, uploadImageToFiles as n } from "../hooks/useFiles.js";
3
+ import { FileImage as r } from "./FileImage.js";
4
+ import { describeError as i, notify as a } from "../lib/toast.js";
5
+ import { useRef as o, useState as s } from "react";
6
+ import { ImagePlus as c, Loader2 as l, X as u } from "lucide-react";
7
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
+ //#region src/comradecircle/components/ImageAttachments.tsx
9
+ var p = 10 * 1024 * 1024, m = 6;
10
+ function h({ fileIds: e, onChange: h, disabled: g = !1 }) {
11
+ let _ = o(null), [v, y] = s(!1), [b, x] = s({}), S = async (r) => {
12
+ let o = Array.from(r.target.files ?? []);
13
+ if (r.target.value = "", o.length === 0) return;
14
+ let s = m - e.length;
15
+ if (s <= 0) {
16
+ a.warning("Attachment limit reached", `Up to ${m} images per post.`);
17
+ return;
18
+ }
19
+ y(!0);
20
+ try {
21
+ let r = [], i = {};
22
+ for (let e of o.slice(0, s)) {
23
+ if (!e.type.startsWith("image/")) continue;
24
+ if (e.size > p) {
25
+ a.error("Image too large", `${e.name} exceeds 10 MB.`);
26
+ continue;
27
+ }
28
+ let o = await n(e, t.posts);
29
+ r.push(o.id), i[o.id] = o.url;
30
+ }
31
+ r.length && (x((e) => ({
32
+ ...e,
33
+ ...i
34
+ })), h([...e, ...r]));
35
+ } catch (e) {
36
+ a.error("Upload failed", i(e));
37
+ } finally {
38
+ y(!1);
39
+ }
40
+ }, C = (t) => h(e.filter((e) => e !== t));
41
+ return /* @__PURE__ */ f("div", { children: [
42
+ e.length > 0 && /* @__PURE__ */ d("div", {
43
+ className: "mb-2 flex flex-wrap gap-2",
44
+ children: e.map((e) => /* @__PURE__ */ f("div", {
45
+ className: "relative h-20 w-20 overflow-hidden rounded-lg ring-1 ring-border-seam",
46
+ children: [b[e] ? /* @__PURE__ */ d("img", {
47
+ src: b[e],
48
+ alt: "attachment",
49
+ className: "h-full w-full object-cover"
50
+ }) : /* @__PURE__ */ d(r, {
51
+ fileId: e,
52
+ alt: "attachment",
53
+ className: "h-full w-full"
54
+ }), /* @__PURE__ */ d("button", {
55
+ type: "button",
56
+ onClick: () => C(e),
57
+ "aria-label": "Remove attachment",
58
+ className: "absolute right-0.5 top-0.5 rounded-full bg-bg-canvas/70 p-0.5 text-text-primary hover:bg-bg-canvas",
59
+ children: /* @__PURE__ */ d(u, { className: "h-3.5 w-3.5" })
60
+ })]
61
+ }, e))
62
+ }),
63
+ /* @__PURE__ */ d("input", {
64
+ ref: _,
65
+ type: "file",
66
+ accept: "image/*",
67
+ multiple: !0,
68
+ className: "sr-only",
69
+ onChange: S,
70
+ disabled: g || v
71
+ }),
72
+ /* @__PURE__ */ f("button", {
73
+ type: "button",
74
+ onClick: () => _.current?.click(),
75
+ disabled: g || v || e.length >= m,
76
+ className: "inline-flex items-center gap-1.5 text-xs font-medium text-text-secondary transition-colors hover:text-text-primary disabled:opacity-50",
77
+ children: [v ? /* @__PURE__ */ d(l, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ d(c, { className: "h-4 w-4" }), v ? "Uploading…" : "Add images"]
78
+ })
79
+ ] });
80
+ }
81
+ function g({ fileIds: t, className: n }) {
82
+ return t.length === 0 ? null : /* @__PURE__ */ d("div", {
83
+ className: e("mt-3 grid gap-2", t.length === 1 ? "grid-cols-1" : "grid-cols-2 sm:grid-cols-3", n),
84
+ children: t.map((n) => /* @__PURE__ */ d("div", {
85
+ className: e("overflow-hidden rounded-xl ring-1 ring-border-seam", t.length === 1 ? "max-h-96" : "aspect-square"),
86
+ children: /* @__PURE__ */ d(r, {
87
+ fileId: n,
88
+ alt: "Post attachment",
89
+ className: "h-full w-full"
90
+ })
91
+ }, n))
92
+ });
93
+ }
94
+ //#endregion
95
+ export { g as AttachmentGrid, h as AttachmentPicker };
96
+
97
+ //# sourceMappingURL=ImageAttachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageAttachments.js","names":[],"sources":["../../../src/comradecircle/components/ImageAttachments.tsx"],"sourcesContent":["/**\n * ImageAttachments — attach images to a post + render a post's attachments.\n * @module comradecircle/components\n *\n * Uploads go to wspace-files-svc (reuse, no blob storage here); the composer\n * keeps only file ids, which are persisted as ComPost.attachmentFileIds.\n */\n\nimport { useRef, useState } from 'react';\nimport { ImagePlus, Loader2, X } from 'lucide-react';\nimport { cn } from '../utils/cn';\nimport { FileImage } from './FileImage';\nimport { uploadImageToFiles, FILE_FOLDERS } from '../hooks/useFiles';\nimport { notify, describeError } from '../lib/toast';\n\nconst MAX_BYTES = 10 * 1024 * 1024;\nconst MAX_ATTACHMENTS = 6;\n\n// --- Composer: pick + upload images, expose file ids -----------------------\n\ninterface AttachmentPickerProps {\n fileIds: string[];\n onChange: (fileIds: string[]) => void;\n disabled?: boolean;\n}\n\nexport function AttachmentPicker({ fileIds, onChange, disabled = false }: AttachmentPickerProps) {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const [uploading, setUploading] = useState(false);\n const [previews, setPreviews] = useState<Record<string, string>>({});\n\n const handleSelect = async (event: React.ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n event.target.value = '';\n if (files.length === 0) return;\n const room = MAX_ATTACHMENTS - fileIds.length;\n if (room <= 0) {\n notify.warning('Attachment limit reached', `Up to ${MAX_ATTACHMENTS} images per post.`);\n return;\n }\n setUploading(true);\n try {\n const added: string[] = [];\n const nextPreviews: Record<string, string> = {};\n for (const file of files.slice(0, room)) {\n if (!file.type.startsWith('image/')) continue;\n if (file.size > MAX_BYTES) {\n notify.error('Image too large', `${file.name} exceeds 10 MB.`);\n continue;\n }\n const uploaded = await uploadImageToFiles(file, FILE_FOLDERS.posts);\n added.push(uploaded.id);\n nextPreviews[uploaded.id] = uploaded.url;\n }\n if (added.length) {\n setPreviews((p) => ({ ...p, ...nextPreviews }));\n onChange([...fileIds, ...added]);\n }\n } catch (err) {\n notify.error('Upload failed', describeError(err));\n } finally {\n setUploading(false);\n }\n };\n\n const remove = (id: string) => onChange(fileIds.filter((f) => f !== id));\n\n return (\n <div>\n {fileIds.length > 0 && (\n <div className=\"mb-2 flex flex-wrap gap-2\">\n {fileIds.map((id) => (\n <div\n key={id}\n className=\"relative h-20 w-20 overflow-hidden rounded-lg ring-1 ring-border-seam\"\n >\n {previews[id] ? (\n <img src={previews[id]} alt=\"attachment\" className=\"h-full w-full object-cover\" />\n ) : (\n <FileImage fileId={id} alt=\"attachment\" className=\"h-full w-full\" />\n )}\n <button\n type=\"button\"\n onClick={() => remove(id)}\n aria-label=\"Remove attachment\"\n className=\"absolute right-0.5 top-0.5 rounded-full bg-bg-canvas/70 p-0.5 text-text-primary hover:bg-bg-canvas\"\n >\n <X className=\"h-3.5 w-3.5\" />\n </button>\n </div>\n ))}\n </div>\n )}\n <input\n ref={inputRef}\n type=\"file\"\n accept=\"image/*\"\n multiple\n className=\"sr-only\"\n onChange={handleSelect}\n disabled={disabled || uploading}\n />\n <button\n type=\"button\"\n onClick={() => inputRef.current?.click()}\n disabled={disabled || uploading || fileIds.length >= MAX_ATTACHMENTS}\n className=\"inline-flex items-center gap-1.5 text-xs font-medium text-text-secondary transition-colors hover:text-text-primary disabled:opacity-50\"\n >\n {uploading ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <ImagePlus className=\"h-4 w-4\" />\n )}\n {uploading ? 'Uploading…' : 'Add images'}\n </button>\n </div>\n );\n}\n\n// --- Reader: render a post's attachment grid -------------------------------\n\ninterface AttachmentGridProps {\n fileIds: string[];\n className?: string;\n}\n\nexport function AttachmentGrid({ fileIds, className }: AttachmentGridProps) {\n if (fileIds.length === 0) return null;\n return (\n <div\n className={cn(\n 'mt-3 grid gap-2',\n fileIds.length === 1 ? 'grid-cols-1' : 'grid-cols-2 sm:grid-cols-3',\n className\n )}\n >\n {fileIds.map((id) => (\n <div\n key={id}\n className={cn(\n 'overflow-hidden rounded-xl ring-1 ring-border-seam',\n fileIds.length === 1 ? 'max-h-96' : 'aspect-square'\n )}\n >\n <FileImage fileId={id} alt=\"Post attachment\" className=\"h-full w-full\" />\n </div>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAeA,IAAM,IAAY,KAAK,OAAO,MACxB,IAAkB;AAUxB,SAAgB,EAAiB,EAAE,YAAS,aAAU,cAAW,MAAgC;CAC/F,IAAM,IAAW,EAAgC,KAAK,EAChD,CAAC,GAAW,KAAgB,EAAS,GAAM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,WAAU;KAAkB,CAAA,EAEtE,kBAAC,UAAD;KACE,MAAK;KACL,eAAe,EAAO,EAAG;KACzB,cAAW;KACX,WAAU;eAEV,kBAAC,GAAD,EAAG,WAAU,eAAgB,CAAA;KACtB,CAAA,CACL;MAhBC,EAgBD,CACN;GACE,CAAA;EAER,kBAAC,SAAD;GACE,KAAK;GACL,MAAK;GACL,QAAO;GACP,UAAA;GACA,WAAU;GACV,UAAU;GACV,UAAU,KAAY;GACtB,CAAA;EACF,kBAAC,UAAD;GACE,MAAK;GACL,eAAe,EAAS,SAAS,OAAO;GACxC,UAAU,KAAY,KAAa,EAAQ,UAAU;GACrD,WAAU;aAJZ,CAMG,IACC,kBAAC,GAAD,EAAS,WAAU,wBAAyB,CAAA,GAE5C,kBAAC,GAAD,EAAW,WAAU,WAAY,CAAA,EAElC,IAAY,eAAe,aACrB;;EACL,EAAA,CAAA;;AAWV,SAAgB,EAAe,EAAE,YAAS,gBAAkC;AAE1E,QADI,EAAQ,WAAW,IAAU,OAE/B,kBAAC,OAAD;EACE,WAAW,EACT,mBACA,EAAQ,WAAW,IAAI,gBAAgB,8BACvC,EACD;YAEA,EAAQ,KAAK,MACZ,kBAAC,OAAD;GAEE,WAAW,EACT,sDACA,EAAQ,WAAW,IAAI,aAAa,gBACrC;aAED,kBAAC,GAAD;IAAW,QAAQ;IAAI,KAAI;IAAkB,WAAU;IAAkB,CAAA;GACrE,EAPC,EAOD,CACN;EACE,CAAA"}
@@ -17,8 +17,10 @@ var s = ({ memberId: s, variant: c = "inline", size: l = "sm", suffix: u, showPr
17
17
  className: t("flex items-center gap-2.5 text-left", f && "rounded-lg transition-colors hover:opacity-80", p),
18
18
  children: [/* @__PURE__ */ i(r, {
19
19
  name: v,
20
+ seed: s,
20
21
  size: l,
21
- presence: y
22
+ presence: y,
23
+ fileId: g?.avatar?.id
22
24
  }), /* @__PURE__ */ a("div", {
23
25
  className: "min-w-0",
24
26
  children: [/* @__PURE__ */ a("div", {
@@ -26,7 +28,7 @@ var s = ({ memberId: s, variant: c = "inline", size: l = "sm", suffix: u, showPr
26
28
  children: [/* @__PURE__ */ i("span", {
27
29
  className: "truncate text-sm font-medium text-text-primary",
28
30
  children: _
29
- }), u && c === "inline" && /* @__PURE__ */ a("span", {
31
+ }), u && /* @__PURE__ */ a("span", {
30
32
  className: "shrink-0 text-xs text-text-tertiary",
31
33
  children: ["· ", u]
32
34
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"MemberIdentity.js","names":[],"sources":["../../../src/comradecircle/components/MemberIdentity.tsx"],"sourcesContent":["/**\n * MemberIdentity — resolve a `memberId` to a display name + avatar via the\n * product's own social-identity layer (`ComProfile`).\n * @module comradecircle/components\n *\n * The composed `User` entity resolves `id` only, so we never render a raw actor\n * id. Instead we look up the member's `ComProfile` (cached aggressively). The\n * calling user is labelled \"You\". If a member has not created a profile yet we\n * fall back to a neutral \"Member\" label with initials from the id.\n */\n\nimport type { FC } from 'react';\nimport { cn } from '../utils/cn';\nimport { useComProfile } from '../hooks';\nimport { useComradeCircle } from '../context';\nimport { Avatar } from './Avatar';\nimport type { ComPresence } from '../types';\n\ninterface MemberIdentityProps {\n memberId: string;\n /** Layout: 'inline' = avatar + name only; 'row' = avatar + name + headline. */\n variant?: 'inline' | 'row';\n size?: 'xs' | 'sm' | 'md' | 'lg';\n /** Suffix shown after the name (e.g. a timestamp) in inline variant. */\n suffix?: string;\n showPresence?: boolean;\n onClick?: () => void;\n className?: string;\n}\n\nfunction labelForMember(\n displayName: string | undefined,\n isSelf: boolean\n): { name: string; presence?: ComPresence | null } {\n if (displayName) return { name: isSelf ? `${displayName} (You)` : displayName };\n return { name: isSelf ? 'You' : 'Member' };\n}\n\nexport const MemberIdentity: FC<MemberIdentityProps> = ({\n memberId,\n variant = 'inline',\n size = 'sm',\n suffix,\n showPresence = false,\n onClick,\n className,\n}) => {\n const { currentUser } = useComradeCircle();\n const isSelf = Boolean(currentUser?.id && currentUser.id === memberId);\n const { data: profile } = useComProfile(memberId);\n\n const { name } = labelForMember(profile?.displayName ?? undefined, isSelf);\n const nameForAvatar = profile?.displayName ?? (isSelf ? (currentUser?.name ?? 'You') : memberId);\n const presence = showPresence ? (profile?.presence ?? null) : null;\n\n const Wrapper = onClick ? 'button' : 'div';\n\n return (\n <Wrapper\n type={onClick ? 'button' : undefined}\n onClick={onClick}\n className={cn(\n 'flex items-center gap-2.5 text-left',\n onClick && 'rounded-lg transition-colors hover:opacity-80',\n className\n )}\n >\n <Avatar name={nameForAvatar} size={size} presence={presence} />\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-1.5\">\n <span className=\"truncate text-sm font-medium text-text-primary\">{name}</span>\n {suffix && variant === 'inline' && (\n <span className=\"shrink-0 text-xs text-text-tertiary\">· {suffix}</span>\n )}\n </div>\n {variant === 'row' && profile?.headline && (\n <p className=\"truncate text-xs text-text-secondary\">{profile.headline}</p>\n )}\n </div>\n </Wrapper>\n );\n};\n"],"mappings":";;;;;;;;AA8BA,SAAS,EACP,GACA,GACiD;AAEjD,QADI,IAAoB,EAAE,MAAM,IAAS,GAAG,EAAY,UAAU,GAAa,GACxE,EAAE,MAAM,IAAS,QAAQ,UAAU;;AAG5C,IAAa,KAA2C,EACtD,aACA,aAAU,UACV,UAAO,MACP,WACA,kBAAe,IACf,YACA,mBACI;CACJ,IAAM,EAAE,mBAAgB,GAAkB,EACpC,IAAS,GAAQ,GAAa,MAAM,EAAY,OAAO,IACvD,EAAE,MAAM,MAAY,EAAc,EAAS,EAE3C,EAAE,YAAS,EAAe,GAAS,eAAe,KAAA,GAAW,EAAO,EACpE,IAAgB,GAAS,gBAAgB,IAAU,GAAa,QAAQ,QAAS,IACjF,IAAW,IAAgB,GAAS,YAAY,OAAQ;AAI9D,QACE,kBAHc,IAAU,WAAW,OAGnC;EACE,MAAM,IAAU,WAAW,KAAA;EAClB;EACT,WAAW,EACT,uCACA,KAAW,iDACX,EACD;YAPH,CASE,kBAAC,GAAD;GAAQ,MAAM;GAAqB;GAAgB;GAAY,CAAA,EAC/D,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,QAAD;KAAM,WAAU;eAAkD;KAAY,CAAA,EAC7E,KAAU,MAAY,YACrB,kBAAC,QAAD;KAAM,WAAU;eAAhB,CAAsD,MAAG,EAAc;OAErE;OACL,MAAY,SAAS,GAAS,YAC7B,kBAAC,KAAD;IAAG,WAAU;cAAwC,EAAQ;IAAa,CAAA,CAExE;KACE"}
1
+ {"version":3,"file":"MemberIdentity.js","names":[],"sources":["../../../src/comradecircle/components/MemberIdentity.tsx"],"sourcesContent":["/**\n * MemberIdentity — resolve a `memberId` to a display name + avatar via the\n * product's own social-identity layer (`ComProfile`).\n * @module comradecircle/components\n *\n * The composed `User` entity resolves `id` only, so we never render a raw actor\n * id. Instead we look up the member's `ComProfile` (cached aggressively). The\n * calling user is labelled \"You\". If a member has not created a profile yet we\n * fall back to a neutral \"Member\" label with initials from the id.\n */\n\nimport type { FC } from 'react';\nimport { cn } from '../utils/cn';\nimport { useComProfile } from '../hooks';\nimport { useComradeCircle } from '../context';\nimport { Avatar } from './Avatar';\nimport type { ComPresence } from '../types';\n\ninterface MemberIdentityProps {\n memberId: string;\n /** Layout: 'inline' = avatar + name only; 'row' = avatar + name + headline. */\n variant?: 'inline' | 'row';\n size?: 'xs' | 'sm' | 'md' | 'lg';\n /** Suffix shown after the name (e.g. a timestamp) in inline variant. */\n suffix?: string;\n showPresence?: boolean;\n onClick?: () => void;\n className?: string;\n}\n\nfunction labelForMember(\n displayName: string | undefined,\n isSelf: boolean\n): { name: string; presence?: ComPresence | null } {\n if (displayName) return { name: isSelf ? `${displayName} (You)` : displayName };\n return { name: isSelf ? 'You' : 'Member' };\n}\n\nexport const MemberIdentity: FC<MemberIdentityProps> = ({\n memberId,\n variant = 'inline',\n size = 'sm',\n suffix,\n showPresence = false,\n onClick,\n className,\n}) => {\n const { currentUser } = useComradeCircle();\n const isSelf = Boolean(currentUser?.id && currentUser.id === memberId);\n const { data: profile } = useComProfile(memberId);\n\n const { name } = labelForMember(profile?.displayName ?? undefined, isSelf);\n const nameForAvatar = profile?.displayName ?? (isSelf ? (currentUser?.name ?? 'You') : memberId);\n const presence = showPresence ? (profile?.presence ?? null) : null;\n\n const Wrapper = onClick ? 'button' : 'div';\n\n return (\n <Wrapper\n type={onClick ? 'button' : undefined}\n onClick={onClick}\n className={cn(\n 'flex items-center gap-2.5 text-left',\n onClick && 'rounded-lg transition-colors hover:opacity-80',\n className\n )}\n >\n <Avatar\n name={nameForAvatar}\n seed={memberId}\n size={size}\n presence={presence}\n fileId={profile?.avatar?.id}\n />\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-1.5\">\n <span className=\"truncate text-sm font-medium text-text-primary\">{name}</span>\n {suffix && <span className=\"shrink-0 text-xs text-text-tertiary\">· {suffix}</span>}\n </div>\n {variant === 'row' && profile?.headline && (\n <p className=\"truncate text-xs text-text-secondary\">{profile.headline}</p>\n )}\n </div>\n </Wrapper>\n );\n};\n"],"mappings":";;;;;;;;AA8BA,SAAS,EACP,GACA,GACiD;AAEjD,QADI,IAAoB,EAAE,MAAM,IAAS,GAAG,EAAY,UAAU,GAAa,GACxE,EAAE,MAAM,IAAS,QAAQ,UAAU;;AAG5C,IAAa,KAA2C,EACtD,aACA,aAAU,UACV,UAAO,MACP,WACA,kBAAe,IACf,YACA,mBACI;CACJ,IAAM,EAAE,mBAAgB,GAAkB,EACpC,IAAS,GAAQ,GAAa,MAAM,EAAY,OAAO,IACvD,EAAE,MAAM,MAAY,EAAc,EAAS,EAE3C,EAAE,YAAS,EAAe,GAAS,eAAe,KAAA,GAAW,EAAO,EACpE,IAAgB,GAAS,gBAAgB,IAAU,GAAa,QAAQ,QAAS,IACjF,IAAW,IAAgB,GAAS,YAAY,OAAQ;AAI9D,QACE,kBAHc,IAAU,WAAW,OAGnC;EACE,MAAM,IAAU,WAAW,KAAA;EAClB;EACT,WAAW,EACT,uCACA,KAAW,iDACX,EACD;YAPH,CASE,kBAAC,GAAD;GACE,MAAM;GACN,MAAM;GACA;GACI;GACV,QAAQ,GAAS,QAAQ;GACzB,CAAA,EACF,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,QAAD;KAAM,WAAU;eAAkD;KAAY,CAAA,EAC7E,KAAU,kBAAC,QAAD;KAAM,WAAU;eAAhB,CAAsD,MAAG,EAAc;OAC9E;OACL,MAAY,SAAS,GAAS,YAC7B,kBAAC,KAAD;IAAG,WAAU;cAAwC,EAAQ;IAAa,CAAA,CAExE;KACE"}
@@ -5,54 +5,69 @@ import { describeError as r, notify as i } from "../lib/toast.js";
5
5
  import { formatNumber as a, formatRelativeTime as o } from "../utils/formatters.js";
6
6
  import { StatusBadge as s } from "./StatusBadge.js";
7
7
  import { MiniBar as c } from "./MiniBar.js";
8
- import { CheckCircle2 as l, Lock as u } from "lucide-react";
9
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
10
- import { Button as p, GlassCard as m } from "@burdenoff/fe-libs/ui";
8
+ import { useMemo as l, useState as u } from "react";
9
+ import { CheckCircle2 as d, Crown as f, Lock as p } from "lucide-react";
10
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
11
+ import { Button as g, GlassCard as _ } from "@burdenoff/fe-libs/ui";
11
12
  //#region src/comradecircle/components/PollCard.tsx
12
- function h({ poll: h, canManage: g = !1 }) {
13
- let _ = n(), v = t(), y = h.options.reduce((e, t) => e + t.voteCount, 0), b = h.status === "CLOSED", x = async (e) => {
14
- if (!b) try {
15
- await _.mutateAsync({
16
- pollId: h.id,
13
+ function v({ poll: v, canManage: y = !1 }) {
14
+ let b = n(), x = t(), [S, C] = u(/* @__PURE__ */ new Set()), w = v.options.reduce((e, t) => e + t.voteCount, 0), T = v.status === "CLOSED", E = l(() => v.options.reduce((e, t) => Math.max(e, t.voteCount), 0), [v.options]), D = S.size > 0, O = async (e) => {
15
+ if (!T) try {
16
+ await b.mutateAsync({
17
+ pollId: v.id,
17
18
  optionId: e,
18
- circleId: h.circleId
19
- }), i.success("Vote recorded");
19
+ circleId: v.circleId
20
+ }), C((t) => new Set(t).add(e)), i.success("Vote recorded");
20
21
  } catch (e) {
21
22
  i.error("Could not vote", r(e));
22
23
  }
23
- }, S = async () => {
24
+ }, k = async () => {
24
25
  try {
25
- await v.mutateAsync(h.id), i.success("Poll closed");
26
+ await x.mutateAsync(v.id), i.success("Poll closed");
26
27
  } catch (e) {
27
28
  i.error("Could not close poll", r(e));
28
29
  }
29
30
  };
30
- return /* @__PURE__ */ f(m, {
31
+ return /* @__PURE__ */ h(_, {
31
32
  treatment: "plain",
32
33
  className: "p-5",
33
34
  children: [
34
- /* @__PURE__ */ f("div", {
35
+ /* @__PURE__ */ h("div", {
35
36
  className: "flex items-start justify-between gap-3",
36
- children: [/* @__PURE__ */ d("h3", {
37
+ children: [/* @__PURE__ */ m("h3", {
37
38
  className: "text-base font-semibold text-text-primary",
38
- children: h.question
39
- }), /* @__PURE__ */ d(s, { status: h.status })]
39
+ children: v.question
40
+ }), /* @__PURE__ */ m(s, { status: v.status })]
40
41
  }),
41
- /* @__PURE__ */ d("div", {
42
+ /* @__PURE__ */ m("div", {
42
43
  className: "mt-4 flex flex-col gap-2.5",
43
- children: [...h.options].sort((e, t) => e.position - t.position).map((t) => {
44
- let n = y > 0 ? t.voteCount / y * 100 : 0;
45
- return /* @__PURE__ */ f("button", {
44
+ children: [...v.options].sort((e, t) => e.position - t.position).map((t) => {
45
+ let n = w > 0 ? t.voteCount / w * 100 : 0, r = w > 0 && t.voteCount === E, i = S.has(t.id);
46
+ return /* @__PURE__ */ h("button", {
46
47
  type: "button",
47
- onClick: () => x(t.id),
48
- disabled: b || _.isPending,
49
- className: e("group w-full rounded-xl border border-border-seam px-3 py-2.5 text-left transition-colors", !b && "hover:border-accent hover:bg-bg-sunken/60", b && "cursor-default"),
50
- children: [/* @__PURE__ */ f("div", {
48
+ onClick: () => O(t.id),
49
+ disabled: T || b.isPending,
50
+ "aria-pressed": i,
51
+ className: e("group w-full rounded-xl border px-3 py-2.5 text-left transition-all duration-200", i ? "border-accent bg-[var(--color-accent-soft)]/40" : "border-border-seam", !T && !i && "hover:-translate-y-px hover:border-accent hover:bg-bg-sunken/60", T && "cursor-default"),
52
+ children: [/* @__PURE__ */ h("div", {
51
53
  className: "flex items-center justify-between gap-2",
52
- children: [/* @__PURE__ */ d("span", {
53
- className: "text-sm font-medium text-text-primary",
54
- children: t.label
55
- }), /* @__PURE__ */ f("span", {
54
+ children: [/* @__PURE__ */ h("span", {
55
+ className: "flex min-w-0 items-center gap-1.5",
56
+ children: [
57
+ i && /* @__PURE__ */ m(d, {
58
+ className: "h-4 w-4 shrink-0 text-accent",
59
+ "aria-hidden": "true"
60
+ }),
61
+ /* @__PURE__ */ m("span", {
62
+ className: e("truncate text-sm", r ? "font-semibold text-text-primary" : "font-medium text-text-secondary"),
63
+ children: t.label
64
+ }),
65
+ r && w > 1 && /* @__PURE__ */ m(f, {
66
+ className: "h-3.5 w-3.5 shrink-0 text-status-warning-text",
67
+ "aria-label": "Leading"
68
+ })
69
+ ]
70
+ }), /* @__PURE__ */ h("span", {
56
71
  className: "shrink-0 text-xs tabular-nums text-text-secondary",
57
72
  children: [
58
73
  a(t.voteCount),
@@ -61,37 +76,43 @@ function h({ poll: h, canManage: g = !1 }) {
61
76
  "%"
62
77
  ]
63
78
  })]
64
- }), /* @__PURE__ */ d(c, {
79
+ }), /* @__PURE__ */ m(c, {
65
80
  value: n,
66
- className: "mt-2"
81
+ className: "mt-2",
82
+ barClassName: r ? "bg-gradient-to-r from-accent to-[var(--color-accent-soft)]" : "bg-accent/40"
67
83
  })]
68
84
  }, t.id);
69
85
  })
70
86
  }),
71
- /* @__PURE__ */ f("div", {
87
+ /* @__PURE__ */ h("div", {
72
88
  className: "mt-4 flex items-center justify-between gap-3 border-t border-border-seam pt-3 text-xs text-text-tertiary",
73
- children: [/* @__PURE__ */ f("span", {
74
- className: "inline-flex items-center gap-1.5",
89
+ children: [/* @__PURE__ */ h("span", {
90
+ className: "inline-flex flex-wrap items-center gap-1.5",
75
91
  children: [
76
- h.allowMultiple ? /* @__PURE__ */ d(l, { className: "h-3.5 w-3.5" }) : null,
77
- a(y),
92
+ v.allowMultiple ? /* @__PURE__ */ m(d, { className: "h-3.5 w-3.5" }) : null,
93
+ a(w),
78
94
  " vote",
79
- y === 1 ? "" : "s",
80
- h.isAnonymous ? " · anonymous" : "",
81
- h.closesAt ? ` · closes ${o(h.closesAt)}` : ""
95
+ w === 1 ? "" : "s",
96
+ v.allowMultiple ? " · multiple choice" : "",
97
+ v.isAnonymous ? " · anonymous" : "",
98
+ v.closesAt ? ` · closes ${o(v.closesAt)}` : "",
99
+ D && /* @__PURE__ */ m("span", {
100
+ className: "font-medium text-accent",
101
+ children: "· You voted"
102
+ })
82
103
  ]
83
- }), g && !b && /* @__PURE__ */ f(p, {
104
+ }), y && !T && /* @__PURE__ */ h(g, {
84
105
  size: "sm",
85
106
  variant: "outline",
86
- onClick: S,
87
- disabled: v.isPending,
88
- children: [/* @__PURE__ */ d(u, { className: "mr-1.5 h-3.5 w-3.5" }), " Close"]
107
+ onClick: k,
108
+ disabled: x.isPending,
109
+ children: [/* @__PURE__ */ m(p, { className: "mr-1.5 h-3.5 w-3.5" }), " Close"]
89
110
  })]
90
111
  })
91
112
  ]
92
113
  });
93
114
  }
94
115
  //#endregion
95
- export { h as PollCard };
116
+ export { v as PollCard };
96
117
 
97
118
  //# sourceMappingURL=PollCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PollCard.js","names":[],"sources":["../../../src/comradecircle/components/PollCard.tsx"],"sourcesContent":["/**\n * PollCard — a circle poll with vote + live results.\n * @module comradecircle/components\n *\n * Writes `comVotePoll(pollId, optionId)` and `comClosePoll`. Options render as\n * clickable result bars; a closed poll (or one past its close time) is read-only.\n * The creator can close an open poll.\n */\n\nimport { CheckCircle2, Lock } from 'lucide-react';\nimport { GlassCard, Button } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\nimport { MiniBar } from './MiniBar';\nimport { StatusBadge } from './StatusBadge';\nimport { useComVotePoll, useComClosePoll } from '../hooks';\nimport { formatNumber, formatRelativeTime } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { ComPoll } from '../types';\n\ninterface PollCardProps {\n poll: ComPoll;\n /** Whether the caller may close the poll (creator / circle admin). */\n canManage?: boolean;\n}\n\nexport function PollCard({ poll, canManage = false }: PollCardProps) {\n const vote = useComVotePoll();\n const close = useComClosePoll();\n\n const totalVotes = poll.options.reduce((sum, o) => sum + o.voteCount, 0);\n const isClosed = poll.status === 'CLOSED';\n\n const doVote = async (optionId: string) => {\n if (isClosed) return;\n try {\n await vote.mutateAsync({ pollId: poll.id, optionId, circleId: poll.circleId });\n notify.success('Vote recorded');\n } catch (err) {\n notify.error('Could not vote', describeError(err));\n }\n };\n\n const doClose = async () => {\n try {\n await close.mutateAsync(poll.id);\n notify.success('Poll closed');\n } catch (err) {\n notify.error('Could not close poll', describeError(err));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className=\"p-5\">\n <div className=\"flex items-start justify-between gap-3\">\n <h3 className=\"text-base font-semibold text-text-primary\">{poll.question}</h3>\n <StatusBadge status={poll.status} />\n </div>\n\n <div className=\"mt-4 flex flex-col gap-2.5\">\n {[...poll.options]\n .sort((a, b) => a.position - b.position)\n .map((opt) => {\n const pct = totalVotes > 0 ? (opt.voteCount / totalVotes) * 100 : 0;\n return (\n <button\n key={opt.id}\n type=\"button\"\n onClick={() => doVote(opt.id)}\n disabled={isClosed || vote.isPending}\n className={cn(\n 'group w-full rounded-xl border border-border-seam px-3 py-2.5 text-left transition-colors',\n !isClosed && 'hover:border-accent hover:bg-bg-sunken/60',\n isClosed && 'cursor-default'\n )}\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"text-sm font-medium text-text-primary\">{opt.label}</span>\n <span className=\"shrink-0 text-xs tabular-nums text-text-secondary\">\n {formatNumber(opt.voteCount)} · {Math.round(pct)}%\n </span>\n </div>\n <MiniBar value={pct} className=\"mt-2\" />\n </button>\n );\n })}\n </div>\n\n <div className=\"mt-4 flex items-center justify-between gap-3 border-t border-border-seam pt-3 text-xs text-text-tertiary\">\n <span className=\"inline-flex items-center gap-1.5\">\n {poll.allowMultiple ? <CheckCircle2 className=\"h-3.5 w-3.5\" /> : null}\n {formatNumber(totalVotes)} vote{totalVotes === 1 ? '' : 's'}\n {poll.isAnonymous ? ' · anonymous' : ''}\n {poll.closesAt ? ` · closes ${formatRelativeTime(poll.closesAt)}` : ''}\n </span>\n {canManage && !isClosed && (\n <Button size=\"sm\" variant=\"outline\" onClick={doClose} disabled={close.isPending}>\n <Lock className=\"mr-1.5 h-3.5 w-3.5\" /> Close\n </Button>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;AAyBA,SAAgB,EAAS,EAAE,SAAM,eAAY,MAAwB;CACnE,IAAM,IAAO,GAAgB,EACvB,IAAQ,GAAiB,EAEzB,IAAa,EAAK,QAAQ,QAAQ,GAAK,MAAM,IAAM,EAAE,WAAW,EAAE,EAClE,IAAW,EAAK,WAAW,UAE3B,IAAS,OAAO,MAAqB;AACrC,SACJ,KAAI;AAEF,GADA,MAAM,EAAK,YAAY;IAAE,QAAQ,EAAK;IAAI;IAAU,UAAU,EAAK;IAAU,CAAC,EAC9E,EAAO,QAAQ,gBAAgB;WACxB,GAAK;AACZ,KAAO,MAAM,kBAAkB,EAAc,EAAI,CAAC;;IAIhD,IAAU,YAAY;AAC1B,MAAI;AAEF,GADA,MAAM,EAAM,YAAY,EAAK,GAAG,EAChC,EAAO,QAAQ,cAAc;WACtB,GAAK;AACZ,KAAO,MAAM,wBAAwB,EAAc,EAAI,CAAC;;;AAI5D,QACE,kBAAC,GAAD;EAAW,WAAU;EAAQ,WAAU;YAAvC;GACE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,MA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ard.tsx"],"sourcesContent":["/**\n * PollCard — a circle poll with vote + live results.\n * @module comradecircle/components\n *\n * Writes `comVotePoll(pollId, optionId)` and `comClosePoll`. Options render as\n * clickable result bars; the leading option is emphasised with an accent\n * gradient fill and the caller's own voted option(s) are checkmarked (tracked\n * client-side — the poll query returns aggregate counts, not per-member votes).\n * A closed poll (or one past its close time) is read-only.\n */\n\nimport { useMemo, useState } from 'react';\nimport { CheckCircle2, Lock, Crown } from 'lucide-react';\nimport { GlassCard, Button } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\nimport { MiniBar } from './MiniBar';\nimport { StatusBadge } from './StatusBadge';\nimport { useComVotePoll, useComClosePoll } from '../hooks';\nimport { formatNumber, formatRelativeTime } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { ComPoll } from '../types';\n\ninterface PollCardProps {\n poll: ComPoll;\n /** Whether the caller may close the poll (creator / circle admin). */\n canManage?: boolean;\n}\n\nexport function PollCard({ poll, canManage = false }: PollCardProps) {\n const vote = useComVotePoll();\n const close = useComClosePoll();\n // The poll query returns aggregate voteCounts, not per-member votes, so track\n // the options this caller has voted for in this session for the \"You voted\" cue.\n const [votedIds, setVotedIds] = useState<Set<string>>(new Set());\n\n const totalVotes = poll.options.reduce((sum, o) => sum + o.voteCount, 0);\n const isClosed = poll.status === 'CLOSED';\n const leadingCount = useMemo(\n () => poll.options.reduce((max, o) => Math.max(max, o.voteCount), 0),\n [poll.options]\n );\n const hasVoted = votedIds.size > 0;\n\n const doVote = async (optionId: string) => {\n if (isClosed) return;\n try {\n await vote.mutateAsync({ pollId: poll.id, optionId, circleId: poll.circleId });\n setVotedIds((prev) => new Set(prev).add(optionId));\n notify.success('Vote recorded');\n } catch (err) {\n notify.error('Could not vote', describeError(err));\n }\n };\n\n const doClose = async () => {\n try {\n await close.mutateAsync(poll.id);\n notify.success('Poll closed');\n } catch (err) {\n notify.error('Could not close poll', describeError(err));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className=\"p-5\">\n <div className=\"flex items-start justify-between gap-3\">\n <h3 className=\"text-base font-semibold text-text-primary\">{poll.question}</h3>\n <StatusBadge status={poll.status} />\n </div>\n\n <div className=\"mt-4 flex flex-col gap-2.5\">\n {[...poll.options]\n .sort((a, b) => a.position - b.position)\n .map((opt) => {\n const pct = totalVotes > 0 ? (opt.voteCount / totalVotes) * 100 : 0;\n const isLeading = totalVotes > 0 && opt.voteCount === leadingCount;\n const isMine = votedIds.has(opt.id);\n return (\n <button\n key={opt.id}\n type=\"button\"\n onClick={() => doVote(opt.id)}\n disabled={isClosed || vote.isPending}\n aria-pressed={isMine}\n className={cn(\n 'group w-full rounded-xl border px-3 py-2.5 text-left transition-all duration-200',\n isMine ? 'border-accent bg-[var(--color-accent-soft)]/40' : 'border-border-seam',\n !isClosed &&\n !isMine &&\n 'hover:-translate-y-px hover:border-accent hover:bg-bg-sunken/60',\n isClosed && 'cursor-default'\n )}\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"flex min-w-0 items-center gap-1.5\">\n {isMine && (\n <CheckCircle2 className=\"h-4 w-4 shrink-0 text-accent\" aria-hidden=\"true\" />\n )}\n <span\n className={cn(\n 'truncate text-sm',\n isLeading\n ? 'font-semibold text-text-primary'\n : 'font-medium text-text-secondary'\n )}\n >\n {opt.label}\n </span>\n {isLeading && totalVotes > 1 && (\n <Crown\n className=\"h-3.5 w-3.5 shrink-0 text-status-warning-text\"\n aria-label=\"Leading\"\n />\n )}\n </span>\n <span className=\"shrink-0 text-xs tabular-nums text-text-secondary\">\n {formatNumber(opt.voteCount)} · {Math.round(pct)}%\n </span>\n </div>\n <MiniBar\n value={pct}\n className=\"mt-2\"\n barClassName={\n isLeading\n ? 'bg-gradient-to-r from-accent to-[var(--color-accent-soft)]'\n : 'bg-accent/40'\n }\n />\n </button>\n );\n })}\n </div>\n\n <div className=\"mt-4 flex items-center justify-between gap-3 border-t border-border-seam pt-3 text-xs text-text-tertiary\">\n <span className=\"inline-flex flex-wrap items-center gap-1.5\">\n {poll.allowMultiple ? <CheckCircle2 className=\"h-3.5 w-3.5\" /> : null}\n {formatNumber(totalVotes)} vote{totalVotes === 1 ? '' : 's'}\n {poll.allowMultiple ? ' · multiple choice' : ''}\n {poll.isAnonymous ? ' · anonymous' : ''}\n {poll.closesAt ? ` · closes ${formatRelativeTime(poll.closesAt)}` : ''}\n {hasVoted && <span className=\"font-medium text-accent\">· You voted</span>}\n </span>\n {canManage && !isClosed && (\n <Button size=\"sm\" variant=\"outline\" onClick={doClose} disabled={close.isPending}>\n <Lock className=\"mr-1.5 h-3.5 w-3.5\" /> Close\n </Button>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,SAAgB,EAAS,EAAE,SAAM,eAAY,MAAwB;CACnE,IAAM,IAAO,GAAgB,EACvB,IAAQ,GAAiB,EAGzB,CAAC,GAAU,KAAe,kBAAsB,IAAI,KAAK,CAAC,EAE1D,IAAa,EAAK,QAAQ,QAAQ,GAAK,MAAM,IAAM,EAAE,WAAW,EAAE,EAClE,IAAW,EAAK,WAAW,UAC3B,IAAe,QACb,EAAK,QAAQ,QAAQ,GAAK,MAAM,KAAK,IAAI,GAAK,EAAE,UAAU,EAAE,EAAE,EACpE,CAAC,EAAK,QAAQ,CACf,EACK,IAAW,EAAS,OAAO,GAE3B,IAAS,OAAO,MAAqB;AACrC,SACJ,KAAI;AAGF,GAFA,MAAM,EAAK,YAAY;IAAE,QAAQ,EAAK;IAAI;IAAU,UAAU,EAAK;IAAU,CAAC,EAC9E,GAAa,MAAS,IAAI,IAAI,EAAK,CAAC,IAAI,EAAS,CAAC,EAClD,EAAO,QAAQ,gBAAgB;WACxB,GAAK;AACZ,KAAO,MAAM,kBAAkB,EAAc,EAAI,CAAC;;IAIhD,IAAU,YAAY;AAC1B,MAAI;AAEF,GADA,MAAM,EAAM,YAAY,EAAK,GAAG,EAChC,EAAO,QAAQ,cAAc;WACtB,GAAK;AACZ,KAAO,MAA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AK,WAAU;cAAf,CACE,kBAAC,QAAD;KAAM,WAAU;eAAhB;MACG,EAAK,gBAAgB,kBAAC,GAAD,EAAc,WAAU,eAAgB,CAAA,GAAG;MAChE,EAAa,EAAW;MAAC;MAAM,MAAe,IAAI,KAAK;MACvD,EAAK,gBAAgB,uBAAuB;MAC5C,EAAK,cAAc,iBAAiB;MACpC,EAAK,WAAW,aAAa,EAAmB,EAAK,SAAS,KAAK;MACnE,KAAY,kBAAC,QAAD;OAAM,WAAU;iBAA0B;OAAkB,CAAA;MACpE;QACN,KAAa,CAAC,KACb,kBAAC,GAAD;KAAQ,MAAK;KAAK,SAAQ;KAAU,SAAS;KAAS,UAAU,EAAM;eAAtE,CACE,kBAAC,GAAD,EAAM,WAAU,sBAAuB,CAAA,EAAA,SAChC;OAEP;;GACI"}
@@ -8,16 +8,17 @@ import { describeError as a, notify as o } from "../lib/toast.js";
8
8
  import { ReactionBar as s } from "./ReactionBar.js";
9
9
  import { formatRelativeTime as c } from "../utils/formatters.js";
10
10
  import { CommentThread as l } from "./CommentThread.js";
11
- import { useState as u } from "react";
12
- import { MessageSquare as d, MoreHorizontal as f, Paperclip as p, Pencil as m, Pin as h, Trash2 as g } from "lucide-react";
11
+ import { AttachmentGrid as u } from "./ImageAttachments.js";
12
+ import { useState as d } from "react";
13
+ import { MessageSquare as f, MoreHorizontal as p, Pencil as m, Pin as h, Trash2 as g } from "lucide-react";
13
14
  import { jsx as _, jsxs as v } from "react/jsx-runtime";
14
15
  import { Button as y, DropdownMenu as b, DropdownMenuContent as x, DropdownMenuItem as S, DropdownMenuSeparator as C, DropdownMenuTrigger as w, GlassCard as T, Textarea as E } from "@burdenoff/fe-libs/ui";
15
16
  //#region src/comradecircle/components/PostCard.tsx
16
17
  function D({ post: D, defaultExpanded: O = !1 }) {
17
- let { currentUser: k } = e(), A = r(), j = n(), [M, N] = u(O), [P, F] = u(!1), [I, L] = u(D.body), R = !!(k?.id && k.id === D.authorId);
18
+ let { currentUser: k } = e(), A = r(), j = n(), [M, N] = d(O), [P, F] = d(!1), [I, L] = d(D.body), R = !!(k?.id && k.id === D.authorId);
18
19
  return /* @__PURE__ */ v(T, {
19
20
  treatment: "plain",
20
- className: t("p-4", D.isPinned && "ring-1 ring-accent/40"),
21
+ className: t("p-4 transition-all duration-200 motion-safe:hover:-translate-y-0.5 hover:border-[var(--color-accent-soft)]", D.isPinned && "ring-1 ring-accent/40"),
21
22
  children: [
22
23
  /* @__PURE__ */ v("div", {
23
24
  className: "flex items-start justify-between gap-3",
@@ -38,7 +39,7 @@ function D({ post: D, defaultExpanded: O = !1 }) {
38
39
  type: "button",
39
40
  "aria-label": "Post actions",
40
41
  className: "rounded-lg p-1.5 text-text-tertiary transition-colors hover:bg-bg-sunken hover:text-text-primary",
41
- children: /* @__PURE__ */ _(f, { className: "h-4 w-4" })
42
+ children: /* @__PURE__ */ _(p, { className: "h-4 w-4" })
42
43
  })
43
44
  }), /* @__PURE__ */ v(x, {
44
45
  align: "end",
@@ -131,15 +132,7 @@ function D({ post: D, defaultExpanded: O = !1 }) {
131
132
  children: ["#", e]
132
133
  }, e))
133
134
  }),
134
- D.attachmentFileIds.length > 0 && /* @__PURE__ */ v("div", {
135
- className: "mt-2 inline-flex items-center gap-1.5 text-xs text-text-tertiary",
136
- children: [
137
- /* @__PURE__ */ _(p, { className: "h-3.5 w-3.5" }),
138
- D.attachmentFileIds.length,
139
- " attachment",
140
- D.attachmentFileIds.length === 1 ? "" : "s"
141
- ]
142
- }),
135
+ D.attachmentFileIds.length > 0 && /* @__PURE__ */ _(u, { fileIds: D.attachmentFileIds }),
143
136
  /* @__PURE__ */ v("div", {
144
137
  className: "mt-3 flex items-center justify-between gap-3 border-t border-border-seam pt-3",
145
138
  children: [/* @__PURE__ */ _(s, { post: D }), /* @__PURE__ */ v("button", {
@@ -148,7 +141,7 @@ function D({ post: D, defaultExpanded: O = !1 }) {
148
141
  "aria-expanded": M,
149
142
  className: t("inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium transition-colors", M ? "bg-[var(--color-accent-soft)] text-text-primary" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"),
150
143
  children: [
151
- /* @__PURE__ */ _(d, { className: "h-3.5 w-3.5" }),
144
+ /* @__PURE__ */ _(f, { className: "h-3.5 w-3.5" }),
152
145
  /* @__PURE__ */ _("span", {
153
146
  className: "tabular-nums",
154
147
  children: D.commentCount
@@ -1 +1 @@
1
- {"version":3,"file":"PostCard.js","names":[],"sources":["../../../src/comradecircle/components/PostCard.tsx"],"sourcesContent":["/**\n * PostCard — a single post with reactions and a collapsible comment thread.\n * @module comradecircle/components\n *\n * Reads its data from a `ComPost`; writes via `comUpdatePost` (edit / pin) and\n * `comRemovePost` (delete). Reactions + comments are delegated to\n * {@link ReactionBar} and {@link CommentThread}. Author-only actions (edit, pin,\n * delete) are gated on `authorId === currentUser.id`.\n */\n\nimport { useState } from 'react';\nimport { MessageSquare, MoreHorizontal, Pin, Pencil, Trash2, Paperclip } from 'lucide-react';\nimport {\n GlassCard,\n Button,\n Textarea,\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n} from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\nimport { MemberIdentity } from './MemberIdentity';\nimport { ReactionBar } from './ReactionBar';\nimport { CommentThread } from './CommentThread';\nimport { useComUpdatePost, useComRemovePost } from '../hooks';\nimport { useComradeCircle } from '../context';\nimport { formatRelativeTime } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { ComPost } from '../types';\n\ninterface PostCardProps {\n post: ComPost;\n /** Start with the comment thread open. */\n defaultExpanded?: boolean;\n}\n\nexport function PostCard({ post, defaultExpanded = false }: PostCardProps) {\n const { currentUser } = useComradeCircle();\n const updatePost = useComUpdatePost();\n const removePost = useComRemovePost();\n const [expanded, setExpanded] = useState(defaultExpanded);\n const [editing, setEditing] = useState(false);\n const [draft, setDraft] = useState(post.body);\n\n const isAuthor = Boolean(currentUser?.id && currentUser.id === post.authorId);\n\n const saveEdit = async () => {\n const text = draft.trim();\n if (!text || text === post.body) {\n setEditing(false);\n return;\n }\n try {\n await updatePost.mutateAsync({ id: post.id, input: { body: text } });\n setEditing(false);\n notify.success('Post updated');\n } catch (err) {\n notify.error('Could not update post', describeError(err));\n }\n };\n\n const togglePin = async () => {\n try {\n await updatePost.mutateAsync({ id: post.id, input: { isPinned: !post.isPinned } });\n notify.success(post.isPinned ? 'Post unpinned' : 'Post pinned');\n } catch (err) {\n notify.error('Could not update post', describeError(err));\n }\n };\n\n const remove = async () => {\n try {\n await removePost.mutateAsync({ id: post.id, channelId: post.channelId });\n notify.success('Post removed');\n } catch (err) {\n notify.error('Could not remove post', describeError(err));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className={cn('p-4', post.isPinned && 'ring-1 ring-accent/40')}>\n <div className=\"flex items-start justify-between gap-3\">\n <MemberIdentity\n memberId={post.authorId}\n variant=\"row\"\n size=\"md\"\n suffix={formatRelativeTime(post.createdAt)}\n showPresence\n />\n <div className=\"flex items-center gap-1\">\n {post.isPinned && (\n <span className=\"inline-flex items-center gap-1 rounded-full bg-[var(--color-accent-soft)] px-2 py-0.5 text-xs font-medium text-text-primary\">\n <Pin className=\"h-3 w-3\" /> Pinned\n </span>\n )}\n {isAuthor && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n aria-label=\"Post actions\"\n className=\"rounded-lg p-1.5 text-text-tertiary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n >\n <MoreHorizontal className=\"h-4 w-4\" />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuItem onClick={() => setEditing(true)}>\n <Pencil className=\"mr-2 h-4 w-4\" /> Edit\n </DropdownMenuItem>\n <DropdownMenuItem onClick={togglePin}>\n <Pin className=\"mr-2 h-4 w-4\" /> {post.isPinned ? 'Unpin' : 'Pin'}\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem\n onClick={remove}\n className=\"text-status-error-text focus:text-status-error-text\"\n >\n <Trash2 className=\"mr-2 h-4 w-4\" /> Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n </div>\n\n {editing ? (\n <div className=\"mt-3\">\n <Textarea\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n rows={3}\n className=\"resize-none\"\n />\n <div className=\"mt-2 flex justify-end gap-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n setDraft(post.body);\n setEditing(false);\n }}\n >\n Cancel\n </Button>\n <Button size=\"sm\" onClick={saveEdit} disabled={updatePost.isPending}>\n Save\n </Button>\n </div>\n </div>\n ) : (\n <p className=\"mt-3 whitespace-pre-wrap break-words text-sm text-text-primary\">\n {post.body}\n </p>\n )}\n\n {post.tags.length > 0 && (\n <div className=\"mt-2 flex flex-wrap gap-1.5\">\n {post.tags.map((tag) => (\n <span\n key={tag}\n className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary\"\n >\n #{tag}\n </span>\n ))}\n </div>\n )}\n\n {post.attachmentFileIds.length > 0 && (\n <div className=\"mt-2 inline-flex items-center gap-1.5 text-xs text-text-tertiary\">\n <Paperclip className=\"h-3.5 w-3.5\" />\n {post.attachmentFileIds.length} attachment\n {post.attachmentFileIds.length === 1 ? '' : 's'}\n </div>\n )}\n\n <div className=\"mt-3 flex items-center justify-between gap-3 border-t border-border-seam pt-3\">\n <ReactionBar post={post} />\n <button\n type=\"button\"\n onClick={() => setExpanded((s) => !s)}\n aria-expanded={expanded}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium transition-colors',\n expanded\n ? 'bg-[var(--color-accent-soft)] text-text-primary'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n )}\n >\n <MessageSquare className=\"h-3.5 w-3.5\" />\n <span className=\"tabular-nums\">{post.commentCount}</span>\n <span className=\"hidden sm:inline\">\n {post.commentCount === 1 ? 'comment' : 'comments'}\n </span>\n </button>\n </div>\n\n {expanded && <CommentThread postId={post.id} />}\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsCA,SAAgB,EAAS,EAAE,SAAM,qBAAkB,MAAwB;CACzE,IAAM,EAAE,mBAAgB,GAAkB,EACpC,IAAa,GAAkB,EAC/B,IAAa,GAAkB,EAC/B,CAAC,GAAU,KAAe,EAAS,EAAgB,EACnD,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,CAAC,GAAO,KAAY,EAAS,EAAK,KAAK,EAEvC,IAAW,GAAQ,GAAa,MAAM,EAAY,OAAO,EAAK;AAmCpE,QACE,kBAAC,GAAD;EAAW,WAAU;EAAQ,WAAW,EAAG,OAAO,EAAK,YAAY,wBAAwB;YAA3F;GACE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KACE,UAAU,EAAK;KACf,SAAQ;KACR,MAAK;KACL,QAAQ,EAAmB,EAAK,UAAU;KAC1C,cAAA;KACA,CAAA,EACF,kBAAC,OAAD;KAAK,WAAU;eAAf,CACG,EAAK,YACJ,kBAAC,QAAD;MAAM,WAAU;gBAAhB,CACE,kBAAC,GAAD,EAAK,WAAU,WAAY,CAAA,EAAA,UACtB;SAER,KACC,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;MAAqB,SAAA;gBACnB,kBAAC,UAAD;OACE,MAAK;OACL,cAAW;OACX,WAAU;iBAEV,kBAAC,GAAD,EAAgB,WAAU,WAAY,CAAA;OAC/B,CAAA;MACW,CAAA,EACtB,kBAAC,GAAD;MAAqB,OAAM;gBAA3B;OACE,kBAAC,GAAD;QAAkB,eAAe,EAAW,GAAK;kBAAjD,CACE,kBAAC,GAAD,EAAQ,WAAU,gBAAiB,CAAA,EAAA,QAClB;;OACnB,kBAAC,GAAD;QAAkB,SAjDd,YAAY;AAC5B,aAAI;AAEF,UADA,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QAAQ,eAAe;gBACvB,GAAK;AACZ,UAAO,MAAM,yBAAyB,EAAc,EAAI,CAAC;;;MAwFd,UAAU,EAAW;gBAAW;MAE5D,CAAA,CACL;OACF;QAEN,kBAAC,KAAD;IAAG,WAAU;cACV,EAAK;IACJ,CAAA;GAGL,EAAK,KAAK,SAAS,KAClB,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAK,KAAK,KAAK,MACd,kBAAC,QAAD;KAEE,WAAU;eAFZ,CAGC,KACG,EACG;OAJA,EAIA,CACP;IACE,CAAA;GAGP,EAAK,kBAAkB,SAAS,KAC/B,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,GAAD,EAAW,WAAU,eAAgB,CAAA;KACpC,EAAK,kBAAkB;KAAO;KAC9B,EAAK,kBAAkB,WAAW,IAAI,KAAK;KACxC;;GAGR,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD,EAAmB,SAAQ,CAAA,EAC3B,kBAAC,UAAD;KACE,MAAK;KACL,eAAe,GAAa,MAAM,CAAC,EAAE;KACrC,iBAAe;KACf,WAAW,EACT,mGACA,IACI,oDACA,iEACL;eATH;MAWE,kBAAC,GAAD,EAAe,WAAU,eAAgB,CAAA;MACzC,kBAAC,QAAD;OAAM,WAAU;iBAAgB,EAAK;OAAoB,CAAA;MACzD,kBAAC,QAAD;OAAM,WAAU;iBACb,EAAK,iBAAiB,IAAI,YAAY;OAClC,CAAA;MACA;OACL;;GAEL,KAAY,kBAAC,GAAD,EAAe,QAAQ,EAAK,IAAM,CAAA;GACrC"}
1
+ {"version":3,"file":"PostCard.js","names":[],"sources":["../../../src/comradecircle/components/PostCard.tsx"],"sourcesContent":["/**\n * PostCard — a single post with reactions and a collapsible comment thread.\n * @module comradecircle/components\n *\n * Reads its data from a `ComPost`; writes via `comUpdatePost` (edit / pin) and\n * `comRemovePost` (delete). Reactions + comments are delegated to\n * {@link ReactionBar} and {@link CommentThread}. Author-only actions (edit, pin,\n * delete) are gated on `authorId === currentUser.id`.\n */\n\nimport { useState } from 'react';\nimport { MessageSquare, MoreHorizontal, Pin, Pencil, Trash2 } from 'lucide-react';\nimport {\n GlassCard,\n Button,\n Textarea,\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n} from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\nimport { MemberIdentity } from './MemberIdentity';\nimport { ReactionBar } from './ReactionBar';\nimport { CommentThread } from './CommentThread';\nimport { AttachmentGrid } from './ImageAttachments';\nimport { useComUpdatePost, useComRemovePost } from '../hooks';\nimport { useComradeCircle } from '../context';\nimport { formatRelativeTime } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { ComPost } from '../types';\n\ninterface PostCardProps {\n post: ComPost;\n /** Start with the comment thread open. */\n defaultExpanded?: boolean;\n}\n\nexport function PostCard({ post, defaultExpanded = false }: PostCardProps) {\n const { currentUser } = useComradeCircle();\n const updatePost = useComUpdatePost();\n const removePost = useComRemovePost();\n const [expanded, setExpanded] = useState(defaultExpanded);\n const [editing, setEditing] = useState(false);\n const [draft, setDraft] = useState(post.body);\n\n const isAuthor = Boolean(currentUser?.id && currentUser.id === post.authorId);\n\n const saveEdit = async () => {\n const text = draft.trim();\n if (!text || text === post.body) {\n setEditing(false);\n return;\n }\n try {\n await updatePost.mutateAsync({ id: post.id, input: { body: text } });\n setEditing(false);\n notify.success('Post updated');\n } catch (err) {\n notify.error('Could not update post', describeError(err));\n }\n };\n\n const togglePin = async () => {\n try {\n await updatePost.mutateAsync({ id: post.id, input: { isPinned: !post.isPinned } });\n notify.success(post.isPinned ? 'Post unpinned' : 'Post pinned');\n } catch (err) {\n notify.error('Could not update post', describeError(err));\n }\n };\n\n const remove = async () => {\n try {\n await removePost.mutateAsync({ id: post.id, channelId: post.channelId });\n notify.success('Post removed');\n } catch (err) {\n notify.error('Could not remove post', describeError(err));\n }\n };\n\n return (\n <GlassCard\n treatment=\"plain\"\n className={cn(\n 'p-4 transition-all duration-200 motion-safe:hover:-translate-y-0.5 hover:border-[var(--color-accent-soft)]',\n post.isPinned && 'ring-1 ring-accent/40'\n )}\n >\n <div className=\"flex items-start justify-between gap-3\">\n <MemberIdentity\n memberId={post.authorId}\n variant=\"row\"\n size=\"md\"\n suffix={formatRelativeTime(post.createdAt)}\n showPresence\n />\n <div className=\"flex items-center gap-1\">\n {post.isPinned && (\n <span className=\"inline-flex items-center gap-1 rounded-full bg-[var(--color-accent-soft)] px-2 py-0.5 text-xs font-medium text-text-primary\">\n <Pin className=\"h-3 w-3\" /> Pinned\n </span>\n )}\n {isAuthor && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n aria-label=\"Post actions\"\n className=\"rounded-lg p-1.5 text-text-tertiary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n >\n <MoreHorizontal className=\"h-4 w-4\" />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuItem onClick={() => setEditing(true)}>\n <Pencil className=\"mr-2 h-4 w-4\" /> Edit\n </DropdownMenuItem>\n <DropdownMenuItem onClick={togglePin}>\n <Pin className=\"mr-2 h-4 w-4\" /> {post.isPinned ? 'Unpin' : 'Pin'}\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem\n onClick={remove}\n className=\"text-status-error-text focus:text-status-error-text\"\n >\n <Trash2 className=\"mr-2 h-4 w-4\" /> Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n </div>\n\n {editing ? (\n <div className=\"mt-3\">\n <Textarea\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n rows={3}\n className=\"resize-none\"\n />\n <div className=\"mt-2 flex justify-end gap-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => {\n setDraft(post.body);\n setEditing(false);\n }}\n >\n Cancel\n </Button>\n <Button size=\"sm\" onClick={saveEdit} disabled={updatePost.isPending}>\n Save\n </Button>\n </div>\n </div>\n ) : (\n <p className=\"mt-3 whitespace-pre-wrap break-words text-sm text-text-primary\">\n {post.body}\n </p>\n )}\n\n {post.tags.length > 0 && (\n <div className=\"mt-2 flex flex-wrap gap-1.5\">\n {post.tags.map((tag) => (\n <span\n key={tag}\n className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary\"\n >\n #{tag}\n </span>\n ))}\n </div>\n )}\n\n {post.attachmentFileIds.length > 0 && <AttachmentGrid fileIds={post.attachmentFileIds} />}\n\n <div className=\"mt-3 flex items-center justify-between gap-3 border-t border-border-seam pt-3\">\n <ReactionBar post={post} />\n <button\n type=\"button\"\n onClick={() => setExpanded((s) => !s)}\n aria-expanded={expanded}\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium transition-colors',\n expanded\n ? 'bg-[var(--color-accent-soft)] text-text-primary'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n )}\n >\n <MessageSquare className=\"h-3.5 w-3.5\" />\n <span className=\"tabular-nums\">{post.commentCount}</span>\n <span className=\"hidden sm:inline\">\n {post.commentCount === 1 ? 'comment' : 'comments'}\n </span>\n </button>\n </div>\n\n {expanded && <CommentThread postId={post.id} />}\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,SAAgB,EAAS,EAAE,SAAM,qBAAkB,MAAwB;CACzE,IAAM,EAAE,mBAAgB,GAAkB,EACpC,IAAa,GAAkB,EAC/B,IAAa,GAAkB,EAC/B,CAAC,GAAU,KAAe,EAAS,EAAgB,EACnD,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,CAAC,GAAO,KAAY,EAAS,EAAK,KAAK,EAEvC,IAAW,GAAQ,GAAa,MAAM,EAAY,OAAO,EAAK;AAmCpE,QACE,kBAAC,GAAD;EACE,WAAU;EACV,WAAW,EACT,8GACA,EAAK,YAAY,wBAClB;YALH;GAOE,kBAAC,OAAD;IA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E;KACrC,iBAAe;KACf,WAAW,EACT,mGACA,IACI,oDACA,iEACL;eATH;MAWE,kBAAC,GAAD,EAAe,WAAU,eAAgB,CAAA;MACzC,kBAAC,QAAD;OAAM,WAAU;iBAAgB,EAAK;OAAoB,CAAA;MACzD,kBAAC,QAAD;OAAM,WAAU;iBACb,EAAK,iBAAiB,IAAI,YAAY;OAClC,CAAA;MACA;OACL;;GAEL,KAAY,kBAAC,GAAD,EAAe,QAAQ,EAAK,IAAM,CAAA;GACrC"}
@@ -4,66 +4,76 @@ import { useComCreatePost as t } from "../hooks/useComradeCircleApi.js";
4
4
  import "../hooks/index.js";
5
5
  import { Avatar as n } from "./Avatar.js";
6
6
  import { describeError as r, notify as i } from "../lib/toast.js";
7
- import { TagInput as a } from "./TagInput.js";
8
- import { useState as o } from "react";
9
- import { Send as s } from "lucide-react";
10
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
11
- import { Button as u, GlassCard as d, Textarea as f } from "@burdenoff/fe-libs/ui";
7
+ import { AttachmentPicker as a } from "./ImageAttachments.js";
8
+ import { TagInput as o } from "./TagInput.js";
9
+ import { useState as s } from "react";
10
+ import { Send as c } from "lucide-react";
11
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
12
+ import { Button as d, GlassCard as f, Textarea as p } from "@burdenoff/fe-libs/ui";
12
13
  //#region src/comradecircle/components/PostComposer.tsx
13
- function p({ channelId: p, channelName: m, onPosted: h }) {
14
- let { currentUser: g } = e(), _ = t(), [v, y] = o(""), [b, x] = o([]), [S, C] = o(!1), w = async () => {
15
- let e = v.trim();
16
- if (e) try {
17
- await _.mutateAsync({
18
- channelId: p,
14
+ function m({ channelId: m, channelName: h, onPosted: g }) {
15
+ let { currentUser: _ } = e(), v = t(), [y, b] = s(""), [x, S] = s([]), [C, w] = s(!1), [T, E] = s([]), D = async () => {
16
+ let e = y.trim();
17
+ if (!(!e && T.length === 0)) try {
18
+ await v.mutateAsync({
19
+ channelId: m,
19
20
  body: e,
20
- tags: b.length ? b : null
21
- }), y(""), x([]), C(!1), i.success("Posted", m ? `Shared to #${m}` : void 0), h?.();
21
+ tags: x.length ? x : null,
22
+ attachmentFileIds: T.length ? T : null
23
+ }), b(""), S([]), E([]), w(!1), i.success("Posted", h ? `Shared to #${h}` : void 0), g?.();
22
24
  } catch (e) {
23
25
  i.error("Could not publish post", r(e));
24
26
  }
25
27
  };
26
- return /* @__PURE__ */ c(d, {
28
+ return /* @__PURE__ */ l(f, {
27
29
  treatment: "plain",
28
30
  className: "p-4",
29
- children: /* @__PURE__ */ l("div", {
31
+ children: /* @__PURE__ */ u("div", {
30
32
  className: "flex gap-3",
31
- children: [/* @__PURE__ */ c(n, {
32
- name: g?.name ?? g?.email ?? "You",
33
+ children: [/* @__PURE__ */ l(n, {
34
+ name: _?.name ?? _?.email ?? "You",
33
35
  size: "md"
34
- }), /* @__PURE__ */ l("div", {
36
+ }), /* @__PURE__ */ u("div", {
35
37
  className: "flex-1",
36
38
  children: [
37
- /* @__PURE__ */ c(f, {
38
- value: v,
39
- onChange: (e) => y(e.target.value),
40
- placeholder: m ? `Share something in #${m}…` : "Share something…",
39
+ /* @__PURE__ */ l(p, {
40
+ value: y,
41
+ onChange: (e) => b(e.target.value),
42
+ placeholder: h ? `Share something in #${h}…` : "Share something…",
41
43
  rows: 2,
42
44
  className: "resize-none border-0 bg-transparent px-0 shadow-none focus-visible:ring-0",
43
45
  onKeyDown: (e) => {
44
- e.key === "Enter" && (e.metaKey || e.ctrlKey) && (e.preventDefault(), w());
46
+ e.key === "Enter" && (e.metaKey || e.ctrlKey) && (e.preventDefault(), D());
45
47
  }
46
48
  }),
47
- S && /* @__PURE__ */ c("div", {
49
+ C && /* @__PURE__ */ l("div", {
48
50
  className: "mt-2",
49
- children: /* @__PURE__ */ c(a, {
50
- value: b,
51
- onChange: x,
51
+ children: /* @__PURE__ */ l(o, {
52
+ value: x,
53
+ onChange: S,
52
54
  placeholder: "Add topics…"
53
55
  })
54
56
  }),
55
57
  /* @__PURE__ */ l("div", {
58
+ className: "mt-2",
59
+ children: /* @__PURE__ */ l(a, {
60
+ fileIds: T,
61
+ onChange: E,
62
+ disabled: v.isPending
63
+ })
64
+ }),
65
+ /* @__PURE__ */ u("div", {
56
66
  className: "mt-3 flex items-center justify-between",
57
- children: [/* @__PURE__ */ c("button", {
67
+ children: [/* @__PURE__ */ l("button", {
58
68
  type: "button",
59
- onClick: () => C((e) => !e),
69
+ onClick: () => w((e) => !e),
60
70
  className: "text-xs font-medium text-text-secondary transition-colors hover:text-text-primary",
61
- children: S ? "Hide topics" : "# Add topics"
62
- }), /* @__PURE__ */ l(u, {
71
+ children: C ? "Hide topics" : "# Add topics"
72
+ }), /* @__PURE__ */ u(d, {
63
73
  size: "sm",
64
- onClick: w,
65
- disabled: !v.trim() || _.isPending,
66
- children: [/* @__PURE__ */ c(s, { className: "mr-1.5 h-4 w-4" }), " Post"]
74
+ onClick: D,
75
+ disabled: !y.trim() && T.length === 0 || v.isPending,
76
+ children: [/* @__PURE__ */ l(c, { className: "mr-1.5 h-4 w-4" }), " Post"]
67
77
  })]
68
78
  })
69
79
  ]
@@ -72,6 +82,6 @@ function p({ channelId: p, channelName: m, onPosted: h }) {
72
82
  });
73
83
  }
74
84
  //#endregion
75
- export { p as PostComposer };
85
+ export { m as PostComposer };
76
86
 
77
87
  //# sourceMappingURL=PostComposer.js.map