@openpeepshq/react 0.10.0 → 0.11.1

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 (277) hide show
  1. package/dist/components/RelationCapabilitiesEditor.js +3 -3
  2. package/dist/components/RoleCapabilityMatrix.js +2 -2
  3. package/dist/components/accounts/SignUpLoginModal.js +1 -1
  4. package/dist/components/configuration/ConfigurationList.js +2 -2
  5. package/dist/components/conversations/ConversationMessageBubble.js +8 -1
  6. package/dist/components/conversations/CreateNewConversation.js +34 -17
  7. package/dist/components/form/ImageEditModal.js +2 -2
  8. package/dist/components/groups/ChangeGroupRolesModal.js +1 -1
  9. package/dist/components/groups/ConfirmGroupExitModal.js +1 -1
  10. package/dist/components/groups/ConfirmMemberRemovalModal.js +1 -1
  11. package/dist/components/groups/DeleteGroupModal.js +1 -1
  12. package/dist/components/groups/GroupForm.js +2 -2
  13. package/dist/components/groups/GroupNotificationSettingsModal.js +2 -2
  14. package/dist/components/jams/JamCallParticipant.js +4 -3
  15. package/dist/components/jams/JamGuestForm.js +1 -1
  16. package/dist/components/jams/jamEventActions.d.ts +10 -0
  17. package/dist/components/jams/jamEventActions.js +13 -0
  18. package/dist/components/navigation/ContentHeader.js +1 -1
  19. package/dist/components/navigation/FooterMobile.js +1 -1
  20. package/dist/components/navigation/SideBar.js +1 -1
  21. package/dist/components/post/FullPostLayout.js +1 -1
  22. package/dist/components/post/index.d.ts +1 -0
  23. package/dist/components/post/index.js +1 -0
  24. package/dist/components/post/pieces/EventRsvpList.js +1 -1
  25. package/dist/components/post/pieces/EventRsvpScopeDialog.js +2 -2
  26. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +1 -1
  27. package/dist/components/post/pieces/GalleryModal.js +1 -1
  28. package/dist/components/post/pieces/modals/DeletePostModal.js +2 -2
  29. package/dist/components/post/post-form/ComposeAttachments.d.ts +2 -0
  30. package/dist/components/post/post-form/ComposeAttachments.js +8 -0
  31. package/dist/components/post/post-form/DescriptionEditModal.js +1 -1
  32. package/dist/components/post/post-form/EditPostModal.js +2 -2
  33. package/dist/components/post/post-form/EventForm.js +4 -26
  34. package/dist/components/post/post-form/PostAudienceSelector.js +2 -2
  35. package/dist/components/post/post-form/ReplyModal.js +1 -1
  36. package/dist/components/post/types/event/FullEvent.js +3 -3
  37. package/dist/components/post/types/resource/FullResource.js +2 -1
  38. package/dist/components/preview-link/RemotePreviewLink.js +32 -4
  39. package/dist/components/preview-link/RemotePreviewLink.test.d.ts +1 -0
  40. package/dist/components/preview-link/RemotePreviewLink.test.js +118 -0
  41. package/dist/components/profile/ProfileActivitySummary.js +4 -4
  42. package/dist/components/profile/ProfileBadge.js +1 -1
  43. package/dist/components/profile/ProfilePageAction.js +1 -1
  44. package/dist/components/profile/ProfilePostsAndReplies.js +1 -1
  45. package/dist/components/profile/ProfileSelector.js +1 -1
  46. package/dist/components/profile/ReportProfileOrPostModal.js +4 -2
  47. package/dist/components/resources/CategoryPathPicker.js +1 -1
  48. package/dist/components/resources/ResourceCard.js +5 -3
  49. package/dist/components/resources/ResourceLibrary.js +61 -8
  50. package/dist/components/resources/ResourceLibrary.test.d.ts +1 -0
  51. package/dist/components/resources/ResourceLibrary.test.js +122 -0
  52. package/dist/components/server-data/context.d.ts +24 -16
  53. package/dist/contexts/openpeeps/hooks/admin.d.ts +2 -2
  54. package/dist/contexts/openpeeps/hooks/auth.d.ts +1 -1
  55. package/dist/contexts/router/index.d.ts +8 -0
  56. package/dist/contexts/router/index.js +27 -2
  57. package/dist/hooks/conversations/dmMessage.d.ts +15 -0
  58. package/dist/hooks/conversations/dmMessage.js +12 -0
  59. package/dist/hooks/conversations/useCreateConversation.d.ts +40 -0
  60. package/dist/hooks/conversations/useCreateConversation.js +6 -0
  61. package/dist/hooks/events/useEventForm.d.ts +3 -0
  62. package/dist/hooks/events/useEventForm.js +31 -2
  63. package/dist/hooks/events/useEventForm.test.d.ts +1 -0
  64. package/dist/hooks/events/useEventForm.test.js +107 -0
  65. package/dist/hooks/index.d.ts +3 -1
  66. package/dist/hooks/index.js +3 -1
  67. package/dist/hooks/posts/useFeedPostActions.js +4 -15
  68. package/dist/hooks/posts/usePostReactionToggle.d.ts +14 -0
  69. package/dist/hooks/posts/usePostReactionToggle.js +46 -0
  70. package/dist/hooks/resources/useResourceLibrary.d.ts +8 -1
  71. package/dist/hooks/resources/useResourceLibrary.js +5 -5
  72. package/dist/hooks/settings/useAccessTokens.d.ts +3 -3
  73. package/dist/hooks/settings/useAccessTokens.js +1 -0
  74. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -0
  75. package/dist/hooks/settings/useNotificationPreferences.js +7 -2
  76. package/dist/lib/downloadUrl.d.ts +6 -0
  77. package/dist/lib/downloadUrl.js +6 -0
  78. package/dist/navigation/menuItems.js +4 -4
  79. package/dist/pages/Explore.js +1 -1
  80. package/dist/pages/admin/ApiKeys.js +17 -9
  81. package/dist/pages/admin/ConfigEditor.js +1 -1
  82. package/dist/pages/admin/ConfigurationCommunityFeed.js +2 -2
  83. package/dist/pages/admin/ConfigurationCommunityLanguage.js +2 -2
  84. package/dist/pages/admin/ConfigurationCommunityTimezone.js +2 -2
  85. package/dist/pages/admin/ConfigurationEmail.js +4 -4
  86. package/dist/pages/admin/ConfigurationI18n.js +1 -1
  87. package/dist/pages/admin/ConfigurationSso.js +2 -2
  88. package/dist/pages/admin/ConfigurationSsoNew.js +1 -1
  89. package/dist/pages/admin/Dashboard.js +1 -1
  90. package/dist/pages/admin/Db.js +4 -4
  91. package/dist/pages/admin/DiagnosticsEmail.js +3 -3
  92. package/dist/pages/admin/DiagnosticsJob.js +2 -2
  93. package/dist/pages/admin/DiagnosticsLivekit.js +1 -1
  94. package/dist/pages/admin/DiagnosticsLogs.js +2 -2
  95. package/dist/pages/admin/DiagnosticsPerformance.js +1 -1
  96. package/dist/pages/admin/GroupMembers.js +5 -5
  97. package/dist/pages/admin/Groups.js +2 -2
  98. package/dist/pages/admin/Invites.js +3 -3
  99. package/dist/pages/admin/Media.js +2 -2
  100. package/dist/pages/admin/MemberDetail.js +7 -7
  101. package/dist/pages/admin/Members.js +2 -2
  102. package/dist/pages/admin/analytics/AnalyticsLayout.js +3 -1
  103. package/dist/pages/admin/analytics/Content.js +1 -1
  104. package/dist/pages/admin/analytics/Engagement.js +1 -1
  105. package/dist/pages/admin/analytics/Groups.js +1 -1
  106. package/dist/pages/admin/analytics/ReportSettings.js +1 -1
  107. package/dist/pages/admin/community/CommunityAccess.js +1 -1
  108. package/dist/pages/admin/community/CommunityFavicons.js +1 -1
  109. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +2 -2
  110. package/dist/pages/admin/community/CommunityInfo.js +1 -1
  111. package/dist/pages/admin/community/CommunityLinks.js +1 -1
  112. package/dist/pages/admin/community/CommunityMarkdownPage.js +1 -1
  113. package/dist/pages/admin/community/CommunityProfileFields.js +2 -2
  114. package/dist/pages/admin/community/CommunityRoles.js +7 -7
  115. package/dist/pages/admin/community/CommunityTheme.js +3 -2
  116. package/dist/pages/admin/community/ThemeColorPreview.d.ts +8 -0
  117. package/dist/pages/admin/community/ThemeColorPreview.js +46 -0
  118. package/dist/pages/admin/community/ThemeColorPreview.test.d.ts +1 -0
  119. package/dist/pages/admin/community/ThemeColorPreview.test.js +49 -0
  120. package/dist/pages/admin/components/AdminGroupCard.js +1 -1
  121. package/dist/pages/admin/components/EditInviteLinkModal.js +1 -1
  122. package/dist/pages/admin/components/InviteWithEmailModal.js +2 -2
  123. package/dist/pages/admin/components/InviteWithLinkModal.js +3 -3
  124. package/dist/pages/admin/components/ProfileRowActions.js +4 -4
  125. package/dist/pages/admin/components/RestoreBackupModal.js +2 -2
  126. package/dist/pages/admin/components/RestoreTestBackupModal.js +1 -1
  127. package/dist/pages/auth/Login.js +1 -1
  128. package/dist/pages/auth/Register.js +3 -3
  129. package/dist/pages/auth/RequestResetPassword.js +2 -2
  130. package/dist/pages/conversations/Info.js +1 -1
  131. package/dist/pages/conversations/Show.js +45 -15
  132. package/dist/pages/events/Index.js +1 -1
  133. package/dist/pages/feeds/Bookmarks.js +1 -1
  134. package/dist/pages/groups/EditInfo.js +1 -1
  135. package/dist/pages/groups/EditRoles.js +1 -1
  136. package/dist/pages/groups/Index.js +1 -1
  137. package/dist/pages/groups/Members.js +2 -2
  138. package/dist/pages/groups/New.js +1 -1
  139. package/dist/pages/groups/Show.js +2 -2
  140. package/dist/pages/settings/AccessTokens.js +4 -4
  141. package/dist/pages/settings/Account.js +1 -1
  142. package/dist/pages/settings/Feed.js +1 -1
  143. package/dist/pages/settings/Language.js +1 -1
  144. package/dist/pages/settings/NotificationPreferences.js +7 -3
  145. package/dist/pages/settings/NotificationPreferences.test.d.ts +1 -0
  146. package/dist/pages/settings/NotificationPreferences.test.js +119 -0
  147. package/dist/pages/settings/PublicProfile.js +3 -3
  148. package/dist/pages/settings/PushEnabledDevices.js +1 -1
  149. package/dist/pages/settings/Theme.js +1 -1
  150. package/dist/pages/settings/Timezone.js +1 -1
  151. package/dist/react-native.d.ts +1 -1
  152. package/dist/react-native.js +1 -1
  153. package/package.json +9 -9
  154. package/src/components/RelationCapabilitiesEditor.tsx +3 -3
  155. package/src/components/RoleCapabilityMatrix.tsx +2 -2
  156. package/src/components/accounts/SignUpLoginModal.tsx +1 -1
  157. package/src/components/configuration/ConfigurationList.tsx +2 -2
  158. package/src/components/conversations/ConversationMessageBubble.tsx +24 -0
  159. package/src/components/conversations/CreateNewConversation.tsx +114 -78
  160. package/src/components/form/ImageEditModal.tsx +2 -2
  161. package/src/components/groups/ChangeGroupRolesModal.tsx +1 -1
  162. package/src/components/groups/ConfirmGroupExitModal.tsx +1 -1
  163. package/src/components/groups/ConfirmMemberRemovalModal.tsx +2 -2
  164. package/src/components/groups/DeleteGroupModal.tsx +2 -2
  165. package/src/components/groups/GroupForm.tsx +2 -2
  166. package/src/components/groups/GroupNotificationSettingsModal.tsx +2 -2
  167. package/src/components/jams/JamCallParticipant.tsx +4 -3
  168. package/src/components/jams/JamGuestForm.tsx +1 -1
  169. package/src/components/jams/jamEventActions.ts +21 -0
  170. package/src/components/navigation/ContentHeader.tsx +3 -3
  171. package/src/components/navigation/FooterMobile.tsx +1 -1
  172. package/src/components/navigation/SideBar.tsx +3 -3
  173. package/src/components/post/FullPostLayout.tsx +1 -1
  174. package/src/components/post/index.ts +1 -0
  175. package/src/components/post/pieces/EventRsvpList.tsx +1 -1
  176. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +2 -2
  177. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +1 -1
  178. package/src/components/post/pieces/GalleryModal.tsx +1 -1
  179. package/src/components/post/pieces/modals/DeletePostModal.tsx +2 -2
  180. package/src/components/post/post-form/ComposeAttachments.tsx +10 -0
  181. package/src/components/post/post-form/DescriptionEditModal.tsx +1 -1
  182. package/src/components/post/post-form/EditPostModal.tsx +2 -2
  183. package/src/components/post/post-form/EventForm.tsx +10 -28
  184. package/src/components/post/post-form/PostAudienceSelector.tsx +2 -2
  185. package/src/components/post/post-form/ReplyModal.tsx +1 -1
  186. package/src/components/post/types/event/FullEvent.tsx +3 -3
  187. package/src/components/post/types/resource/FullResource.tsx +2 -1
  188. package/src/components/preview-link/RemotePreviewLink.tsx +92 -25
  189. package/src/components/profile/ProfileActivitySummary.tsx +4 -4
  190. package/src/components/profile/ProfileBadge.tsx +1 -1
  191. package/src/components/profile/ProfilePageAction.tsx +1 -1
  192. package/src/components/profile/ProfilePostsAndReplies.tsx +2 -2
  193. package/src/components/profile/ProfileSelector.tsx +1 -1
  194. package/src/components/profile/ReportProfileOrPostModal.tsx +4 -2
  195. package/src/components/resources/CategoryPathPicker.tsx +1 -1
  196. package/src/components/resources/ResourceCard.tsx +5 -3
  197. package/src/components/resources/ResourceLibrary.tsx +79 -4
  198. package/src/contexts/router/index.tsx +40 -1
  199. package/src/hooks/conversations/dmMessage.ts +26 -0
  200. package/src/hooks/conversations/useCreateConversation.ts +7 -0
  201. package/src/hooks/events/useEventForm.ts +32 -1
  202. package/src/hooks/index.ts +10 -1
  203. package/src/hooks/posts/useFeedPostActions.ts +4 -18
  204. package/src/hooks/posts/usePostReactionToggle.ts +60 -0
  205. package/src/hooks/resources/useResourceLibrary.ts +20 -5
  206. package/src/hooks/settings/useAccessTokens.ts +1 -0
  207. package/src/hooks/settings/useNotificationPreferences.ts +12 -1
  208. package/src/lib/downloadUrl.ts +7 -0
  209. package/src/navigation/menuItems.ts +4 -4
  210. package/src/pages/Explore.tsx +4 -4
  211. package/src/pages/admin/ApiKeys.tsx +24 -13
  212. package/src/pages/admin/ConfigEditor.tsx +1 -1
  213. package/src/pages/admin/ConfigurationCommunityFeed.tsx +2 -2
  214. package/src/pages/admin/ConfigurationCommunityLanguage.tsx +2 -2
  215. package/src/pages/admin/ConfigurationCommunityTimezone.tsx +2 -2
  216. package/src/pages/admin/ConfigurationEmail.tsx +4 -4
  217. package/src/pages/admin/ConfigurationI18n.tsx +1 -1
  218. package/src/pages/admin/ConfigurationSso.tsx +3 -2
  219. package/src/pages/admin/ConfigurationSsoNew.tsx +1 -1
  220. package/src/pages/admin/Dashboard.tsx +1 -1
  221. package/src/pages/admin/Db.tsx +6 -6
  222. package/src/pages/admin/DiagnosticsEmail.tsx +5 -5
  223. package/src/pages/admin/DiagnosticsJob.tsx +2 -2
  224. package/src/pages/admin/DiagnosticsLivekit.tsx +3 -3
  225. package/src/pages/admin/DiagnosticsLogs.tsx +4 -4
  226. package/src/pages/admin/DiagnosticsPerformance.tsx +1 -1
  227. package/src/pages/admin/GroupMembers.tsx +6 -6
  228. package/src/pages/admin/Groups.tsx +2 -2
  229. package/src/pages/admin/Invites.tsx +4 -4
  230. package/src/pages/admin/Media.tsx +2 -2
  231. package/src/pages/admin/MemberDetail.tsx +7 -7
  232. package/src/pages/admin/Members.tsx +2 -2
  233. package/src/pages/admin/analytics/AnalyticsLayout.tsx +5 -1
  234. package/src/pages/admin/analytics/Content.tsx +1 -1
  235. package/src/pages/admin/analytics/Engagement.tsx +1 -1
  236. package/src/pages/admin/analytics/Groups.tsx +1 -1
  237. package/src/pages/admin/analytics/ReportSettings.tsx +1 -1
  238. package/src/pages/admin/community/CommunityAccess.tsx +1 -1
  239. package/src/pages/admin/community/CommunityFavicons.tsx +1 -1
  240. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +2 -2
  241. package/src/pages/admin/community/CommunityInfo.tsx +1 -1
  242. package/src/pages/admin/community/CommunityLinks.tsx +1 -1
  243. package/src/pages/admin/community/CommunityMarkdownPage.tsx +1 -1
  244. package/src/pages/admin/community/CommunityProfileFields.tsx +5 -5
  245. package/src/pages/admin/community/CommunityRoles.tsx +9 -9
  246. package/src/pages/admin/community/CommunityTheme.tsx +26 -23
  247. package/src/pages/admin/community/ThemeColorPreview.tsx +141 -0
  248. package/src/pages/admin/components/AdminGroupCard.tsx +2 -2
  249. package/src/pages/admin/components/EditInviteLinkModal.tsx +2 -2
  250. package/src/pages/admin/components/InviteWithEmailModal.tsx +2 -2
  251. package/src/pages/admin/components/InviteWithLinkModal.tsx +3 -3
  252. package/src/pages/admin/components/ProfileRowActions.tsx +6 -6
  253. package/src/pages/admin/components/RestoreBackupModal.tsx +2 -2
  254. package/src/pages/admin/components/RestoreTestBackupModal.tsx +1 -1
  255. package/src/pages/auth/Login.tsx +1 -1
  256. package/src/pages/auth/Register.tsx +3 -3
  257. package/src/pages/auth/RequestResetPassword.tsx +2 -2
  258. package/src/pages/conversations/Info.tsx +1 -1
  259. package/src/pages/conversations/Show.tsx +94 -33
  260. package/src/pages/events/Index.tsx +1 -1
  261. package/src/pages/feeds/Bookmarks.tsx +3 -1
  262. package/src/pages/groups/EditInfo.tsx +1 -1
  263. package/src/pages/groups/EditRoles.tsx +1 -1
  264. package/src/pages/groups/Index.tsx +1 -1
  265. package/src/pages/groups/Members.tsx +2 -2
  266. package/src/pages/groups/New.tsx +1 -1
  267. package/src/pages/groups/Show.tsx +4 -4
  268. package/src/pages/settings/AccessTokens.tsx +4 -4
  269. package/src/pages/settings/Account.tsx +1 -1
  270. package/src/pages/settings/Feed.tsx +1 -1
  271. package/src/pages/settings/Language.tsx +1 -1
  272. package/src/pages/settings/NotificationPreferences.tsx +38 -12
  273. package/src/pages/settings/PublicProfile.tsx +3 -3
  274. package/src/pages/settings/PushEnabledDevices.tsx +3 -6
  275. package/src/pages/settings/Theme.tsx +1 -1
  276. package/src/pages/settings/Timezone.tsx +1 -1
  277. package/src/react-native.ts +1 -0
@@ -19,8 +19,7 @@ const TIMEZONES = typeof Intl !== 'undefined' && 'supportedValuesOf' in Intl
19
19
  export const EventForm = ({ postData, onChange, isEdit = false, occurrenceEdit = false, showNotify = false, notify = false, onNotifyChange, }) => {
20
20
  const t = useT();
21
21
  const [audienceOpen, setAudienceOpen] = useState(false);
22
- const [endBeforeStart, setEndBeforeStart] = useState(false);
23
- const { event, eventTimeZone, showEndDate, repeatFreq, repeatEnd, preview, patchEvent, setEvent, setAudience, applyFreq, toggleWeekday, applyRepeatEnd, setRepeatUntil, setRepeatCount, toggleEndDate, setTimeZone, } = useEventForm(postData, onChange);
22
+ const { event, eventTimeZone, showEndDate, repeatFreq, repeatEnd, preview, endBeforeStart, changeStart, changeEnd, patchEvent, setEvent, setAudience, applyFreq, toggleWeekday, applyRepeatEnd, setRepeatUntil, setRepeatCount, toggleEndDate, setTimeZone, } = useEventForm(postData, onChange);
24
23
  return (_jsxs("div", { "data-testid": "events-form-basic-details", children: [_jsx(ImageInput, { usage: "event-header-image", url: event.image, onChange: (image) => patchEvent({ image }), aspectRatio: EVENT_HEADER_ASPECT_RATIO, className: "aspect-video !h-auto", text: t('events.form.imageDescription', {
25
24
  defaultValue: 'Upload an image for your event',
26
25
  }), specsText: t('events.form.imageSpecs', {
@@ -31,30 +30,9 @@ export const EventForm = ({ postData, onChange, isEdit = false, occurrenceEdit =
31
30
  defaultValue: 'Describe your event',
32
31
  }) }), _jsx(ComposePreviewLinks, { content: event.content }), _jsx("h2", { className: "text-lg", children: t('events.form.dateAndTimeTitle', {
33
32
  defaultValue: 'Date and Time',
34
- }) }), _jsx(Label, { title: t('events.form.startDate', { defaultValue: 'Start Date' }), htmlFor: "event-start", children: _jsx(Input, { id: "event-start", type: "datetime-local", step: 60, value: dateToInputValue(event.start, eventTimeZone), onChange: (e) => {
35
- const start = toIso(e.target.value, eventTimeZone);
36
- if (start) {
37
- if (event.end && new Date(event.end) <= new Date(start)) {
38
- setEndBeforeStart(true);
39
- }
40
- else {
41
- setEndBeforeStart(false);
42
- }
43
- patchEvent({ start });
44
- }
45
- }, "data-testid": "events-start-input" }) }), _jsx(Label, { description: t('events.form.addEndDate', {
33
+ }) }), _jsx(Label, { title: t('events.startDate', { defaultValue: 'Start Date' }), htmlFor: "event-start", children: _jsx(Input, { id: "event-start", type: "datetime-local", step: 60, value: dateToInputValue(event.start, eventTimeZone), onChange: (e) => changeStart(toIso(e.target.value, eventTimeZone)), "data-testid": "events-start-input" }) }), _jsx(Label, { description: t('events.form.addEndDate', {
46
34
  defaultValue: 'Add end date and time',
47
- }), forCheckbox: true, children: _jsx("input", { type: "checkbox", checked: showEndDate, onChange: (e) => toggleEndDate(e.target.checked) }) }), showEndDate ? (_jsxs(_Fragment, { children: [_jsx(Label, { title: t('events.form.endDate', { defaultValue: 'End Date' }), htmlFor: "event-end", children: _jsx(Input, { id: "event-end", type: "datetime-local", step: 60, value: dateToInputValue(event.end, eventTimeZone), onChange: (e) => {
48
- const newEnd = toIso(e.target.value, eventTimeZone);
49
- if (newEnd &&
50
- event.start &&
51
- new Date(newEnd) <= new Date(event.start)) {
52
- setEndBeforeStart(true);
53
- return;
54
- }
55
- setEndBeforeStart(false);
56
- patchEvent({ end: newEnd });
57
- } }) }), endBeforeStart ? (_jsx("p", { className: "text-destructive text-sm", children: t('events.form.endBeforeStart', {
35
+ }), forCheckbox: true, children: _jsx("input", { type: "checkbox", checked: showEndDate, onChange: (e) => toggleEndDate(e.target.checked) }) }), showEndDate ? (_jsxs(_Fragment, { children: [_jsx(Label, { title: t('events.endDate', { defaultValue: 'End Date' }), htmlFor: "event-end", children: _jsx(Input, { id: "event-end", type: "datetime-local", step: 60, value: dateToInputValue(event.end, eventTimeZone), onChange: (e) => changeEnd(toIso(e.target.value, eventTimeZone)) }) }), endBeforeStart ? (_jsx("p", { className: "text-destructive text-sm", children: t('events.form.endBeforeStart', {
58
36
  defaultValue: 'The end date and time must be after the start date and time.',
59
37
  }) })) : null] })) : null, _jsx(Label, { title: t('events.form.timezone', { defaultValue: 'Timezone' }), htmlFor: "event-timezone", children: _jsx("select", { id: "event-timezone", className: "bg-background w-full rounded-md border px-3 py-2 text-sm", value: eventTimeZone, onChange: (e) => setTimeZone(e.target.value), children: TIMEZONES.map((tz) => (_jsx("option", { value: tz, children: tz }, tz))) }) }), !occurrenceEdit ? (_jsxs(_Fragment, { children: [_jsx(Label, { title: t('events.form.repeat.title', { defaultValue: 'Repeat' }), htmlFor: "event-repeat", children: _jsxs("select", { id: "event-repeat", className: "bg-background w-full rounded-md border px-3 py-2 text-sm", value: repeatFreq, onChange: (e) => applyFreq(e.target.value), "data-testid": "events-repeat-input", children: [_jsx("option", { value: "none", children: t('events.form.repeat.none', {
60
38
  defaultValue: 'Does not repeat',
@@ -86,7 +64,7 @@ export const EventForm = ({ postData, onChange, isEdit = false, occurrenceEdit =
86
64
  day: 'numeric',
87
65
  }))
88
66
  .join(', '),
89
- }) })) : null] })) : null] })) : null, _jsx("h2", { className: "text-lg", children: t('events.form.location', { defaultValue: 'Location' }) }), _jsx(EventTypeSwitcher, { event: event, isEdit: isEdit, onChange: setEvent }), _jsx("h2", { className: "text-lg", children: t('events.form.people', { defaultValue: 'People' }) }), _jsx(Label, { title: t('events.form.visibility', { defaultValue: 'Visibility' }), description: t('events.form.visibilityNotChangeable', {
67
+ }) })) : null] })) : null] })) : null, _jsx("h2", { className: "text-lg", children: t('events.form.location', { defaultValue: 'Location' }) }), _jsx(EventTypeSwitcher, { event: event, isEdit: isEdit, onChange: setEvent }), _jsx("h2", { className: "text-lg", children: t('events.form.people', { defaultValue: 'People' }) }), _jsx(Label, { title: t('common.labels.visibility', { defaultValue: 'Visibility' }), description: t('events.form.visibilityNotChangeable', {
90
68
  defaultValue: "Note: The event visibility cannot be changed once the event is published. Make sure you're adding the right people or group.",
91
69
  }), children: _jsx(VisibilitySelector, { postData: postData, onClick: () => setAudienceOpen(true), disabled: isEdit, showDirect: true }) }), showNotify ? (_jsxs("div", { className: "flex w-full items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Megaphone, { className: "size-5" }), _jsx("p", { className: "text-base", children: t('posts.form.notifyEveryone', {
92
70
  defaultValue: 'Notify everyone',
@@ -72,8 +72,8 @@ export const PostAudienceSelector = ({ open, onClose, type = 'note', visibility,
72
72
  ?.displayName ??
73
73
  groups.find((g) => g.id === draftGroupId)?.handle })) : null, choice.value === 'direct' && draftAudience.length ? (_jsx("span", { className: "mt-1 flex flex-wrap gap-1", children: draftAudience.map((profile) => (_jsx(ProfileBadge, { profile: profile, onRemove: () => setDraftAudience((current) => current.filter((p) => p.id !== profile.id)) }, profile.id))) })) : null] })] }, choice.value));
74
74
  }) })), _jsx(DialogActions, { cancelLabel: view !== 'main'
75
- ? t('navigation.back', { defaultValue: 'Back' })
76
- : t('common.cancel', { defaultValue: 'Cancel' }), onCancel: view !== 'main' ? () => setView('main') : onClose, actionLabel: t('common.done', { defaultValue: 'Done' }), onAction: confirm })] }) }), _jsx(ProfileSelector, { open: open && view === 'audience', onOpenChange: (next) => {
75
+ ? t('common.actions.back', { defaultValue: 'Back' })
76
+ : t('common.actions.cancel', { defaultValue: 'Cancel' }), onCancel: view !== 'main' ? () => setView('main') : onClose, actionLabel: t('common.done', { defaultValue: 'Done' }), onAction: confirm })] }) }), _jsx(ProfileSelector, { open: open && view === 'audience', onOpenChange: (next) => {
77
77
  if (!next)
78
78
  setView('main');
79
79
  }, mode: "multiple", selectedProfiles: draftAudience, banlist: me ? [me] : [], onConfirm: (profiles) => {
@@ -202,7 +202,7 @@ export function ReplyModal({ post, onClose }) {
202
202
  defaultValue: 'Add audio',
203
203
  }), action: composeAttachments.openAudioPicker, children: _jsx(AudioLines, { className: "size-5" }) }), _jsx(Button, { compact: true, variant: "ghost", title: t('posts.form.addAttachment', {
204
204
  defaultValue: 'Add attachment',
205
- }), action: composeAttachments.openDocumentPicker, children: _jsx(Paperclip, { className: "size-5" }) })] })) : null, _jsx(PostTypeSwitcher, { type: composerType, onSelect: setComposerType, onClose: onClose, showEventType: false, showArticleType: false })] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "ghost", action: onClose, children: t('common.cancel', { defaultValue: 'Cancel' }) }), _jsx(Button, { variant: "default", action: publish, disabled: !canSubmit, children: submitting
205
+ }), action: composeAttachments.openDocumentPicker, children: _jsx(Paperclip, { className: "size-5" }) })] })) : null, _jsx(PostTypeSwitcher, { type: composerType, onSelect: setComposerType, onClose: onClose, showEventType: false, showArticleType: false })] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "ghost", action: onClose, children: t('common.actions.cancel', { defaultValue: 'Cancel' }) }), _jsx(Button, { variant: "default", action: publish, disabled: !canSubmit, children: submitting
206
206
  ? t('common.posting', { defaultValue: 'Posting…' })
207
207
  : t('posts.reply', { defaultValue: 'Reply' }) })] })] }) })] }) }), composeAttachments.inputs] }));
208
208
  }
@@ -106,7 +106,7 @@ export function FullEvent({ post, occurrence }) {
106
106
  profileName: `${profileName(post.profile)}${myEvent ? ' · You' : ''}`,
107
107
  }) })] }), times.start ? (_jsx(EventWhenBlock, { iso: times.start, label: t('events.startDate', { defaultValue: 'Starts' }), timeZone: event.timeZone })) : null, times.end ? (_jsx(EventWhenBlock, { iso: times.end, label: t('events.endDate', { defaultValue: 'Ends' }), timeZone: event.timeZone })) : null, _jsx(EventLocation, { post: post, preview: false, occurrence: occurrenceId }), event.recurrence ? (_jsx(EventOccurrenceList, { post: post, postId: post.id, occurrences: upcomingOccurrences, currentOccurrenceId: occurrenceId, recurrenceLabel: recurrenceLabel })) : null, _jsx(EventRsvpButton, { post: post, recurrenceId: occurrenceId }), event.jam && (myEvent || iAmModerator) ? (livekitEnabled ? (jamState?.active ? (_jsx(Button, { variant: "default", className: "mt-2 w-full", action: jamLink, children: t('jam.join.submit', { defaultValue: 'Join Jam' }) })) : (_jsx(Button, { variant: "default", className: "mt-2 w-full", action: jamLink, children: t('events.jam.start', { defaultValue: 'Start jam' }) }))) : (_jsx("p", { role: "status", className: "text-destructive mt-2 text-sm", children: t('jams.unavailable.message', {
108
108
  defaultValue: 'Jams are unavailable because LiveKit is not connected.',
109
- }) }))) : null, _jsxs("nav", { "aria-label": t('events.tabs.label', { defaultValue: 'Event sections' }), className: "mt-4 flex flex-wrap gap-2 border-b", children: [event.content ? (_jsx(TabButton, { active: tab === 'description', onClick: () => setTab('description'), children: t('events.tabs.description', { defaultValue: 'Description' }) })) : null, _jsx(TabButton, { active: tab === 'replies', onClick: () => setTab('replies'), children: t('events.tabs.discussion', { defaultValue: 'Discussion' }) }), _jsx(TabButton, { active: tab === 'rsvps', onClick: () => setTab('rsvps'), children: t('events.tabs.rsvps', { defaultValue: 'RSVPs' }) }), showJamAttendeesTab ? (_jsx(TabButton, { active: tab === 'attendees', onClick: () => setTab('attendees'), children: t('events.tabs.jamAttendees', { defaultValue: 'Jam attendees' }) })) : null, event.jam ? (_jsx(TabButton, { active: tab === 'recordings', onClick: () => setTab('recordings'), children: t('events.tabs.recordings', { defaultValue: 'Recordings' }) })) : null] }), tab === 'description' && event.content ? (_jsx(OpenpeepsMarkdown, { source: event.content, mentions: post.mentions })) : null, tab === 'replies' ? (_jsxs(_Fragment, { children: [_jsx(ReplyBox, { post: post }), contextQuery.isLoading ? (_jsx("div", { className: "text-muted-foreground py-4 text-sm", children: _jsx(LoadingSpinner, {}) })) : (descendentThreads.map((thread) => (_jsx(ThreadedFeed, { thread: thread }, thread.id))))] })) : null, tab === 'rsvps' ? (_jsxs(_Fragment, { children: [canManageRsvps ? (_jsx("div", { className: "flex justify-end py-2", children: _jsxs(Button, { variant: "outline", compact: true, action: exportRsvps, children: [_jsx(Download, { className: "mr-1 h-4 w-4" }), t('events.exportRsvps', { defaultValue: 'Export RSVPs' })] }) })) : null, _jsx(EventRsvpList, { post: post, occurrenceId: occurrenceId, occurrences: upcomingOccurrences, currentProfile: profile, canManageRsvps: canManageRsvps, onMessage: (target) => openCreateConversation({
109
+ }) }))) : null, _jsxs("nav", { "aria-label": t('events.tabs.label', { defaultValue: 'Event sections' }), className: "mt-4 flex flex-wrap gap-2 border-b", children: [event.content ? (_jsx(TabButton, { active: tab === 'description', onClick: () => setTab('description'), children: t('common.labels.description', { defaultValue: 'Description' }) })) : null, _jsx(TabButton, { active: tab === 'replies', onClick: () => setTab('replies'), children: t('events.tabs.discussion', { defaultValue: 'Discussion' }) }), _jsx(TabButton, { active: tab === 'rsvps', onClick: () => setTab('rsvps'), children: t('events.tabs.rsvps', { defaultValue: 'RSVPs' }) }), showJamAttendeesTab ? (_jsx(TabButton, { active: tab === 'attendees', onClick: () => setTab('attendees'), children: t('events.tabs.jamAttendees', { defaultValue: 'Jam attendees' }) })) : null, event.jam ? (_jsx(TabButton, { active: tab === 'recordings', onClick: () => setTab('recordings'), children: t('events.tabs.recordings', { defaultValue: 'Recordings' }) })) : null] }), tab === 'description' && event.content ? (_jsx(OpenpeepsMarkdown, { source: event.content, mentions: post.mentions })) : null, tab === 'replies' ? (_jsxs(_Fragment, { children: [_jsx(ReplyBox, { post: post }), contextQuery.isLoading ? (_jsx("div", { className: "text-muted-foreground py-4 text-sm", children: _jsx(LoadingSpinner, {}) })) : (descendentThreads.map((thread) => (_jsx(ThreadedFeed, { thread: thread }, thread.id))))] })) : null, tab === 'rsvps' ? (_jsxs(_Fragment, { children: [canManageRsvps ? (_jsx("div", { className: "flex justify-end py-2", children: _jsxs(Button, { variant: "outline", compact: true, action: exportRsvps, children: [_jsx(Download, { className: "mr-1 h-4 w-4" }), t('events.exportRsvps', { defaultValue: 'Export RSVPs' })] }) })) : null, _jsx(EventRsvpList, { post: post, occurrenceId: occurrenceId, occurrences: upcomingOccurrences, currentProfile: profile, canManageRsvps: canManageRsvps, onMessage: (target) => openCreateConversation({
110
110
  profiles: [target],
111
111
  skipProfileSelection: true,
112
112
  }), onManage: (response, profileId, recurrenceId) => rsvpManage({ response, recurrenceId }, { id: post.id, profileId }) })] })) : null, tab === 'attendees' && showJamAttendeesTab ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex justify-end py-2", children: _jsxs(Button, { variant: "outline", compact: true, action: exportAttendees, children: [_jsx(Download, { className: "mr-1 h-4 w-4" }), t('events.exportAttendees', {
@@ -174,9 +174,9 @@ function JamRecordingItem({ post, recording, canManage, }) {
174
174
  defaultValue: 'Delete recording',
175
175
  }) }) }), _jsx("p", { className: "text-sm", children: t('events.deleteRecordingConfirm', {
176
176
  defaultValue: 'Delete this recording permanently?',
177
- }) }), _jsx(DialogActions, { cancelLabel: t('posts.deleteModal.cancel', {
177
+ }) }), _jsx(DialogActions, { cancelLabel: t('common.actions.cancel', {
178
178
  defaultValue: 'Cancel',
179
- }), onCancel: () => setConfirmOpen(false), actionLabel: t('posts.deleteModal.delete', {
179
+ }), onCancel: () => setConfirmOpen(false), actionLabel: t('common.actions.delete', {
180
180
  defaultValue: 'Delete',
181
181
  }), onAction: handleDelete, actionVariant: "destructive" })] }) })] })) : null] })] }));
182
182
  }
@@ -10,6 +10,7 @@ import { ResourceCard } from '../../../resources/ResourceCard.js';
10
10
  import { VideoPlayer } from '../../pieces/VideoPlayer.js';
11
11
  import { AudioAttachment } from '../../pieces/AudioAttachment.js';
12
12
  import { GalleryModal } from '../../pieces/GalleryModal.js';
13
+ import { asDownloadUrl } from '../../../../lib/downloadUrl.js';
13
14
  export const FullResource = ({ post }) => {
14
15
  const t = useT();
15
16
  const resource = post.data?.type === 'resource' ? post.data : null;
@@ -29,7 +30,7 @@ export const FullResource = ({ post }) => {
29
30
  case 'file': {
30
31
  const att = resource.attachments?.find((a) => attachmentMediaKind(a) === 'file');
31
32
  if (att?.url)
32
- window.open(att.url, '_blank');
33
+ window.location.assign(asDownloadUrl(att.url));
33
34
  break;
34
35
  }
35
36
  case 'link':
@@ -1,10 +1,29 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Play } from 'lucide-react';
4
+ import { videoEmbedForUrl } from '@openpeepshq/common/lib';
2
5
  import { LoadingSpinner } from '@openpeepshq/react-ui';
6
+ import { useT } from '../../i18n/index.js';
3
7
  import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
4
8
  import { recordOutboundClick } from '../../lib/analyticsClicks.js';
9
+ // Same safety set as the markdown iframe path (see
10
+ // injectIframeSafetyAttrs in @openpeepshq/common/lib); `allow` is trimmed
11
+ // to what video players need.
12
+ const EMBED_SANDBOX = 'allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-presentation';
13
+ const EMBED_ALLOW = 'autoplay; encrypted-media; picture-in-picture; fullscreen';
5
14
  export function RemotePreviewLink({ url }) {
15
+ const t = useT();
6
16
  const { openpeepsApi } = useOpenpeeps();
17
+ const embed = videoEmbedForUrl(url);
18
+ // Click-to-load: the server-fetched OG card (no third-party request) is
19
+ // the default view; the player mounts only after an explicit action.
20
+ const [loadedUrl, setLoadedUrl] = useState(null);
7
21
  const previewQuery = openpeepsApi.usePreviewLink(url);
22
+ if (embed && loadedUrl === url) {
23
+ return (_jsx("div", { className: "mb-2 w-full", children: _jsx("iframe", { src: embed.embedUrl, title: t('previewLink.embeddedVideo', {
24
+ defaultValue: 'Embedded video',
25
+ }), className: "aspect-video w-full rounded-md border-0", sandbox: EMBED_SANDBOX, allow: EMBED_ALLOW, allowFullScreen: true, referrerPolicy: "no-referrer" }) }));
26
+ }
8
27
  if (previewQuery.isLoading) {
9
28
  return (_jsx("div", { className: "text-muted-foreground py-2 text-sm", children: _jsx(LoadingSpinner, {}) }));
10
29
  }
@@ -18,8 +37,17 @@ export function RemotePreviewLink({ url }) {
18
37
  catch {
19
38
  /* keep url */
20
39
  }
21
- return (_jsx("a", { href: url, target: "_blank", rel: "noreferrer", className: "hover:bg-surface mb-2 block w-full min-w-0 max-w-full overflow-hidden rounded-md border no-underline", onClick: (e) => {
22
- e.stopPropagation();
23
- recordOutboundClick(url);
24
- }, children: _jsxs("div", { className: "flex w-full min-w-0 flex-row items-center gap-4 p-2", children: [data.image ? (_jsx("div", { className: "flex h-24 w-24 shrink-0 items-center justify-center", children: _jsx("img", { src: data.image, alt: data.title ?? '', className: "h-full w-full rounded-md object-cover" }) })) : null, _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [_jsx("p", { className: "text-muted-foreground truncate text-xs", children: hostname }), data.title ? (_jsx("p", { className: "truncate font-semibold", children: data.title })) : null, data.description ? (_jsx("p", { className: "text-muted-foreground truncate text-sm", children: data.description })) : null] })] }) }));
40
+ const card = (_jsxs("div", { className: "flex w-full min-w-0 flex-row items-center gap-4 p-2", children: [data.image || embed ? (_jsxs("div", { className: "relative flex h-24 w-24 shrink-0 items-center justify-center", children: [data.image ? (_jsx("img", { src: data.image, alt: data.title ?? '', className: "h-full w-full rounded-md object-cover" })) : null, embed ? (_jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: _jsx("div", { className: "flex size-10 items-center justify-center rounded-full bg-black/60", children: _jsx(Play, { className: "size-5 text-white", "aria-hidden": true }) }) })) : null] })) : null, _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [_jsx("p", { className: "text-muted-foreground truncate text-xs", children: hostname }), data.title ? (_jsx("p", { className: "truncate font-semibold", children: data.title })) : null, data.description ? (_jsx("p", { className: "text-muted-foreground truncate text-sm", children: data.description })) : null] })] }));
41
+ if (!embed) {
42
+ return (_jsx("a", { href: url, target: "_blank", rel: "noreferrer", className: "hover:bg-surface mb-2 block w-full min-w-0 max-w-full overflow-hidden rounded-md border no-underline", onClick: (e) => {
43
+ e.stopPropagation();
44
+ recordOutboundClick(url);
45
+ }, children: card }));
46
+ }
47
+ return (_jsx("div", { role: "button", tabIndex: 0, "aria-label": t('previewLink.playVideo', { defaultValue: 'Play video' }), className: "hover:bg-surface mb-2 block w-full min-w-0 max-w-full cursor-pointer overflow-hidden rounded-md border", onClick: () => setLoadedUrl(url), onKeyDown: (e) => {
48
+ if (e.key === 'Enter' || e.key === ' ') {
49
+ e.preventDefault();
50
+ setLoadedUrl(url);
51
+ }
52
+ }, children: card }));
25
53
  }
@@ -0,0 +1,118 @@
1
+ /** @vitest-environment jsdom */
2
+ import { act, createElement } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import { RemotePreviewLink } from './RemotePreviewLink.js';
6
+ const state = {
7
+ preview: {
8
+ isLoading: false,
9
+ data: {
10
+ data: {
11
+ title: 'Test video',
12
+ description: 'A test video',
13
+ image: 'https://example.com/thumb.jpg',
14
+ },
15
+ },
16
+ },
17
+ previewLinkCalls: [],
18
+ };
19
+ vi.mock('../../i18n', () => ({
20
+ useT: () => (key, opts) => opts?.defaultValue ?? key,
21
+ }));
22
+ vi.mock('../../contexts/openpeeps', () => ({
23
+ useOpenpeeps: () => ({
24
+ openpeepsApi: {
25
+ usePreviewLink: (url) => {
26
+ state.previewLinkCalls.push(url);
27
+ return state.preview;
28
+ },
29
+ },
30
+ }),
31
+ }));
32
+ vi.mock('../../lib/analyticsClicks', () => ({
33
+ recordOutboundClick: () => { },
34
+ }));
35
+ const YOUTUBE_URL = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
36
+ const YOUTUBE_EMBED = 'https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ';
37
+ describe('RemotePreviewLink', () => {
38
+ let root;
39
+ let container;
40
+ beforeEach(() => {
41
+ globalThis.IS_REACT_ACT_ENVIRONMENT = true;
42
+ state.preview = {
43
+ isLoading: false,
44
+ data: {
45
+ data: {
46
+ title: 'Test video',
47
+ description: 'A test video',
48
+ image: 'https://example.com/thumb.jpg',
49
+ },
50
+ },
51
+ };
52
+ state.previewLinkCalls = [];
53
+ });
54
+ afterEach(() => {
55
+ act(() => {
56
+ root?.unmount();
57
+ });
58
+ container?.remove();
59
+ root = undefined;
60
+ container = undefined;
61
+ });
62
+ const render = (url) => {
63
+ container = document.createElement('div');
64
+ document.body.appendChild(container);
65
+ root = createRoot(container);
66
+ act(() => {
67
+ root?.render(createElement(RemotePreviewLink, { url }));
68
+ });
69
+ };
70
+ const click = async (element) => {
71
+ await act(async () => {
72
+ element.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
73
+ });
74
+ };
75
+ it('renders the link card for non-video URLs without a player', () => {
76
+ render('https://example.com/article');
77
+ const anchor = container?.querySelector('a');
78
+ expect(anchor?.getAttribute('href')).toBe('https://example.com/article');
79
+ expect(container?.textContent).toContain('Test video');
80
+ expect(container?.querySelector('iframe')).toBeNull();
81
+ expect(container?.querySelector('[role="button"]')).toBeNull();
82
+ });
83
+ it('shows the card with a play affordance for video URLs and no player yet', () => {
84
+ render(YOUTUBE_URL);
85
+ const play = container?.querySelector('[role="button"]');
86
+ expect(play?.getAttribute('aria-label')).toBe('Play video');
87
+ expect(container?.textContent).toContain('Test video');
88
+ // The server-fetched OG card is the default view, so the preview
89
+ // query stays enabled for embeddable URLs.
90
+ expect(state.previewLinkCalls).toContain(YOUTUBE_URL);
91
+ expect(container?.querySelector('iframe')).toBeNull();
92
+ });
93
+ it('mounts a sandboxed player only after the card is activated', async () => {
94
+ render(YOUTUBE_URL);
95
+ const play = container?.querySelector('[role="button"]');
96
+ expect(play).toBeTruthy();
97
+ await click(play);
98
+ const iframe = container?.querySelector('iframe');
99
+ expect(iframe?.getAttribute('src')).toBe(YOUTUBE_EMBED);
100
+ expect(iframe?.getAttribute('sandbox')).toBe('allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-presentation');
101
+ expect(iframe?.getAttribute('allow')).toBe('autoplay; encrypted-media; picture-in-picture; fullscreen');
102
+ expect(iframe?.getAttribute('referrerpolicy')).toBe('no-referrer');
103
+ expect(container?.querySelector('[role="button"]')).toBeNull();
104
+ });
105
+ it('mounts the player on Enter key', async () => {
106
+ render(YOUTUBE_URL);
107
+ const play = container?.querySelector('[role="button"]');
108
+ expect(play).toBeTruthy();
109
+ await act(async () => {
110
+ play.dispatchEvent(new KeyboardEvent('keydown', {
111
+ key: 'Enter',
112
+ bubbles: true,
113
+ cancelable: true,
114
+ }));
115
+ });
116
+ expect(container?.querySelector('iframe')?.getAttribute('src')).toBe(YOUTUBE_EMBED);
117
+ });
118
+ });
@@ -10,17 +10,17 @@ const SummaryBody = ({ summary }) => {
10
10
  const t = useT();
11
11
  return (_jsxs("div", { className: "flex flex-col", "data-testid": "profile-activity-summary", children: [_jsxs(CountSection, { title: t('profile.activity.yourContent', {
12
12
  defaultValue: 'Your posts',
13
- }), children: [_jsx(CountCard, { value: summary.postsCount, label: t('profile.activity.postsCount', { defaultValue: 'Posts' }), testId: "profile-activity-posts-count" }), _jsx(CountCard, { value: summary.repliesCount, label: t('profile.activity.repliesCount', {
13
+ }), children: [_jsx(CountCard, { value: summary.postsCount, label: t('common.entities.posts', { defaultValue: 'Posts' }), testId: "profile-activity-posts-count" }), _jsx(CountCard, { value: summary.repliesCount, label: t('profile.activity.repliesCount', {
14
14
  defaultValue: 'Replies',
15
- }), testId: "profile-activity-replies-count" }), _jsx(CountCard, { value: summary.eventsCount, label: t('profile.activity.eventsCount', { defaultValue: 'Events' }), testId: "profile-activity-events-count" })] }), _jsxs(CountSection, { title: t('profile.activity.yourActions', {
15
+ }), testId: "profile-activity-replies-count" }), _jsx(CountCard, { value: summary.eventsCount, label: t('common.entities.events', { defaultValue: 'Events' }), testId: "profile-activity-events-count" })] }), _jsxs(CountSection, { title: t('profile.activity.yourActions', {
16
16
  defaultValue: 'Your actions',
17
17
  }), children: [_jsx(CountCard, { value: summary.reactionsGiven, label: t('profile.activity.reactionsGiven', {
18
18
  defaultValue: 'Reactions',
19
19
  }), testId: "profile-activity-reactions-given" }), _jsx(CountCard, { value: summary.repostsCount, label: t('profile.activity.repostsCount', {
20
20
  defaultValue: 'Reposts',
21
- }), testId: "profile-activity-reposts-count" }), _jsx(CountCard, { value: summary.rsvpsCount, label: t('profile.activity.rsvpsCount', { defaultValue: 'RSVPs' }), testId: "profile-activity-rsvps-count" }), _jsx(CountCard, { value: summary.bookmarksCount, label: t('profile.activity.bookmarksCount', {
21
+ }), testId: "profile-activity-reposts-count" }), _jsx(CountCard, { value: summary.rsvpsCount, label: t('profile.activity.rsvpsCount', { defaultValue: 'RSVPs' }), testId: "profile-activity-rsvps-count" }), _jsx(CountCard, { value: summary.bookmarksCount, label: t('common.entities.bookmarks', {
22
22
  defaultValue: 'Bookmarks',
23
- }), testId: "profile-activity-bookmarks-count" }), _jsx(CountCard, { value: summary.groupsCount, label: t('profile.activity.groupsCount', { defaultValue: 'Groups' }), testId: "profile-activity-groups-count" })] }), _jsxs(CountSection, { title: t('profile.activity.received', {
23
+ }), testId: "profile-activity-bookmarks-count" }), _jsx(CountCard, { value: summary.groupsCount, label: t('common.entities.groups', { defaultValue: 'Groups' }), testId: "profile-activity-groups-count" })] }), _jsxs(CountSection, { title: t('profile.activity.received', {
24
24
  defaultValue: 'Received',
25
25
  }), children: [_jsx(CountCard, { value: summary.reactionsReceived, label: t('profile.activity.reactionsReceived', {
26
26
  defaultValue: 'Reactions',
@@ -5,7 +5,7 @@ import { useT } from '../../i18n/index.js';
5
5
  import { Avatar } from './Avatar.js';
6
6
  export const ProfileBadge = ({ profile, onRemove, className, }) => {
7
7
  const t = useT();
8
- return (_jsxs("div", { className: `border-secondary bg-background text-primary flex items-center gap-1.5 rounded-md border px-2 py-1 text-sm ${className ?? ''}`, children: [_jsx(Avatar, { profile: profile, size: 0.75, borderless: true }), _jsx("span", { className: "max-w-40 truncate font-medium", children: profileName(profile) }), onRemove ? (_jsx("button", { type: "button", className: "hover:bg-secondary ml-0.5 rounded-full p-0.5 transition-colors", title: t('profile.selector.remove', { defaultValue: 'Remove' }), onClick: (e) => {
8
+ return (_jsxs("div", { className: `border-secondary bg-background text-primary flex items-center gap-1.5 rounded-md border px-2 py-1 text-sm ${className ?? ''}`, children: [_jsx(Avatar, { profile: profile, size: 0.75, borderless: true }), _jsx("span", { className: "max-w-40 truncate font-medium", children: profileName(profile) }), onRemove ? (_jsx("button", { type: "button", className: "hover:bg-secondary ml-0.5 rounded-full p-0.5 transition-colors", title: t('common.actions.remove', { defaultValue: 'Remove' }), onClick: (e) => {
9
9
  e.stopPropagation();
10
10
  onRemove();
11
11
  }, children: _jsx(X, { className: "size-3" }) })) : null] }));
@@ -73,5 +73,5 @@ export function ProfilePageAction({ profile, isCurrentProfile = false, }) {
73
73
  }) }) }), _jsx("p", { className: "text-muted-foreground text-sm", children: t('profile.block.description', {
74
74
  defaultValue: 'Are you sure you want to block @{{handle}}? You will no longer see each other or each other’s posts.',
75
75
  handle: profile.handle,
76
- }) }), _jsx(DialogActions, { cancelLabel: t('common.cancel', { defaultValue: 'Cancel' }), onCancel: () => setBlockOpen(false), actionLabel: t('profile.block.confirm', { defaultValue: 'Block' }), onAction: () => void confirmBlock(), disabled: blocking, actionVariant: "destructive" })] }) })] }));
76
+ }) }), _jsx(DialogActions, { cancelLabel: t('common.actions.cancel', { defaultValue: 'Cancel' }), onCancel: () => setBlockOpen(false), actionLabel: t('profile.block.confirm', { defaultValue: 'Block' }), onAction: () => void confirmBlock(), disabled: blocking, actionVariant: "destructive" })] }) })] }));
77
77
  }
@@ -23,7 +23,7 @@ export function ProfilePostsAndReplies({ profile, isCurrentProfile = false, }) {
23
23
  const activeTab = tab === 'activity' && !isCurrentProfile ? 'posts' : tab;
24
24
  return (_jsxs("div", { children: [_jsxs("nav", { "aria-label": t('profile.tabs.label', {
25
25
  defaultValue: 'Profile sections',
26
- }), className: "flex border-b", children: [_jsx("button", { type: "button", className: `flex-1 px-4 py-3 text-sm font-medium ${activeTab === 'posts' ? 'border-primary border-b-2' : 'text-muted-foreground'}`, onClick: () => setTab('posts'), children: t('profile.posts', { defaultValue: 'Posts' }) }), isCurrentProfile ? (_jsx("button", { type: "button", className: `flex-1 px-4 py-3 text-sm font-medium ${activeTab === 'activity' ? 'border-primary border-b-2' : 'text-muted-foreground'}`, onClick: () => setTab('activity'), "data-testid": "profile-activity-tab", children: t('profile.activity.tab', { defaultValue: 'Activity' }) })) : null, _jsx("button", { type: "button", className: `flex-1 px-4 py-3 text-sm font-medium ${activeTab === 'groups' ? 'border-primary border-b-2' : 'text-muted-foreground'}`, onClick: () => setTab('groups'), children: t('profile.groups.tabName', { defaultValue: 'Groups' }) })] }), activeTab === 'posts' ? (_jsx(Feed, { query: postsQuery, pinnedPostId: profile.pinnedPostId })) : activeTab === 'activity' ? (_jsx(ProfileActivitySummary, { profile: profile })) : (_jsxs(AccessDeniedLoader, { queries: [commonGroupsQuery], children: [(commonGroupsQuery.data ?? []).map((group) => (_jsx(GroupCard, { group: group, onSelect: () => navigate({ type: 'group', handle: group.handle }) }, group.id))), !commonGroupsQuery.data?.length ? (_jsxs("div", { className: "flex h-[60vh] w-full flex-col items-center justify-center gap-y-6", children: [_jsx(Users, { size: 60 }), _jsx("p", { children: t('profile.groups.noCommonGroups', {
26
+ }), className: "flex border-b", children: [_jsx("button", { type: "button", className: `flex-1 px-4 py-3 text-sm font-medium ${activeTab === 'posts' ? 'border-primary border-b-2' : 'text-muted-foreground'}`, onClick: () => setTab('posts'), children: t('common.entities.posts', { defaultValue: 'Posts' }) }), isCurrentProfile ? (_jsx("button", { type: "button", className: `flex-1 px-4 py-3 text-sm font-medium ${activeTab === 'activity' ? 'border-primary border-b-2' : 'text-muted-foreground'}`, onClick: () => setTab('activity'), "data-testid": "profile-activity-tab", children: t('profile.activity.tab', { defaultValue: 'Activity' }) })) : null, _jsx("button", { type: "button", className: `flex-1 px-4 py-3 text-sm font-medium ${activeTab === 'groups' ? 'border-primary border-b-2' : 'text-muted-foreground'}`, onClick: () => setTab('groups'), children: t('common.entities.groups', { defaultValue: 'Groups' }) })] }), activeTab === 'posts' ? (_jsx(Feed, { query: postsQuery, pinnedPostId: profile.pinnedPostId })) : activeTab === 'activity' ? (_jsx(ProfileActivitySummary, { profile: profile })) : (_jsxs(AccessDeniedLoader, { queries: [commonGroupsQuery], children: [(commonGroupsQuery.data ?? []).map((group) => (_jsx(GroupCard, { group: group, onSelect: () => navigate({ type: 'group', handle: group.handle }) }, group.id))), !commonGroupsQuery.data?.length ? (_jsxs("div", { className: "flex h-[60vh] w-full flex-col items-center justify-center gap-y-6", children: [_jsx(Users, { size: 60 }), _jsx("p", { children: t('profile.groups.noCommonGroups', {
27
27
  defaultValue: 'No groups in common',
28
28
  }) })] })) : null] }))] }));
29
29
  }
@@ -68,5 +68,5 @@ export const ProfileSelector = ({ open, onOpenChange, mode, selectedProfiles, on
68
68
  ? profile.id === singleSelectionId || isSelected(profile.id)
69
69
  : isSelected(profile.id);
70
70
  return (_jsxs("button", { type: "button", className: `hover:bg-surface rounded-button flex w-full items-center gap-3 p-2 text-left ${selected ? 'bg-secondary/40' : ''}`, onClick: () => toggleProfile(profile), children: [_jsx(Avatar, { profile: profile, size: 2.5, borderless: true }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate text-sm font-medium", children: profileName(profile) }), profile.handle ? (_jsxs("span", { className: "text-muted-foreground block truncate text-xs", children: ["@", profile.handle] })) : null] }), selected ? (_jsx(Check, { className: "text-primary size-4 shrink-0" })) : null] }, profile.id));
71
- }))) : null }), mode === 'multiple' ? (_jsx(DialogActions, { cancelLabel: t('common.cancel', { defaultValue: 'Cancel' }), onCancel: () => onOpenChange(false), actionLabel: t('profile.selector.confirm', { defaultValue: 'OK' }), onAction: confirmMultiple })) : null] }) }));
71
+ }))) : null }), mode === 'multiple' ? (_jsx(DialogActions, { cancelLabel: t('common.actions.cancel', { defaultValue: 'Cancel' }), onCancel: () => onOpenChange(false), actionLabel: t('profile.selector.confirm', { defaultValue: 'OK' }), onAction: confirmMultiple })) : null] }) }));
72
72
  };
@@ -62,7 +62,9 @@ export function ReportProfileOrPostModal({ reportType, profile, post, open, onCl
62
62
  defaultValue: 'Help moderators understand what is wrong.',
63
63
  }) }), _jsx("div", { className: "space-y-2 py-2", children: categories.map((item) => (_jsxs("label", { className: "flex cursor-pointer items-center gap-2", children: [_jsx("input", { type: "radio", name: "category", checked: category === item.value, onChange: () => setCategory(item.value) }), _jsx("span", { className: "text-sm", children: item.label })] }, item.value))) }), _jsx(Textarea, { rows: 4, value: comment, onChange: (e) => setComment(e.target.value), placeholder: t(`reports.create.${reportType}.anythingElse`, {
64
64
  defaultValue: 'Anything else we should know?',
65
- }) }), _jsx(DialogActions, { cancelLabel: t('common.cancel', { defaultValue: 'Cancel' }), onCancel: onClose, actionLabel: t(`reports.create.${reportType}.continue`, {
65
+ }) }), _jsx(DialogActions, { cancelLabel: t('common.actions.cancel', {
66
+ defaultValue: 'Cancel',
67
+ }), onCancel: onClose, actionLabel: t(`reports.create.${reportType}.continue`, {
66
68
  defaultValue: 'Continue',
67
69
  }), onAction: () => setStep(2) })] })) : (_jsxs(_Fragment, { children: [_jsx("h3", { className: "font-semibold", children: t(`reports.create.${reportType}.confirmMessageHeading`, {
68
70
  defaultValue: 'Send report?',
@@ -71,7 +73,7 @@ export function ReportProfileOrPostModal({ reportType, profile, post, open, onCl
71
73
  defaultValue: 'Moderators at {{community}} will review this report.',
72
74
  handle: profile?.handle,
73
75
  community: communityName,
74
- }) })) : null, _jsx(DialogActions, { cancelLabel: t('reports.create.back', { defaultValue: 'Back' }), onCancel: () => setStep(1), actionLabel: t('reports.create.sendReport', {
76
+ }) })) : null, _jsx(DialogActions, { cancelLabel: t('common.actions.back', { defaultValue: 'Back' }), onCancel: () => setStep(1), actionLabel: t('reports.create.sendReport', {
75
77
  defaultValue: 'Send report',
76
78
  }), onAction: submit, actionVariant: "destructive", disabled: submitting })] }))] }) }));
77
79
  }
@@ -22,5 +22,5 @@ export const CategoryPathPicker = ({ path, tree, onChange, }) => {
22
22
  return;
23
23
  onChange([...path, name]);
24
24
  setLevel('');
25
- }, children: t('resources.form.addLevelAction', { defaultValue: 'Add' }) }), path.length ? (_jsx(Button, { variant: "ghost", action: () => onChange([]), children: t('resources.form.clearPath', { defaultValue: 'Clear' }) })) : null] })] }));
25
+ }, children: t('common.actions.add', { defaultValue: 'Add' }) }), path.length ? (_jsx(Button, { variant: "ghost", action: () => onChange([]), children: t('resources.form.clearPath', { defaultValue: 'Clear' }) })) : null] })] }));
26
26
  };
@@ -9,6 +9,7 @@ import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
9
9
  import { useCurrentProfile } from '../layout/IdentityContext.js';
10
10
  import { VideoPlayOverlay } from '../post/VideoPlayOverlay.js';
11
11
  import { TruncatedMarkdown } from '../post/TruncatedMarkdown.js';
12
+ import { asDownloadUrl } from '../../lib/downloadUrl.js';
12
13
  // Audio attachments render their generated waveform preview like any other
13
14
  // visual; without one they fall back to the kind placeholder below.
14
15
  const visualAttachments = (attachments) => attachments.filter((att) => attachmentMediaKind(att) !== 'audio' || !!att.previewUrl);
@@ -59,7 +60,7 @@ const ResourceSaveButton = ({ postId, className, }) => {
59
60
  toggleBookmark();
60
61
  }, disabled: !me, className: className, title: isBookmarked
61
62
  ? t('resources.actions.saved', { defaultValue: 'Saved' })
62
- : t('resources.actions.save', { defaultValue: 'Save' }), children: isBookmarked ? (_jsx(BookmarkCheck, { className: "text-primary size-4" })) : (_jsx(BookmarkPlus, { className: "size-4" })) }));
63
+ : t('common.actions.save', { defaultValue: 'Save' }), children: isBookmarked ? (_jsx(BookmarkCheck, { className: "text-primary size-4" })) : (_jsx(BookmarkPlus, { className: "size-4" })) }));
63
64
  };
64
65
  /**
65
66
  * Clickable hashtag chip. Child component like ResourceSaveButton so the
@@ -143,9 +144,10 @@ export const ResourceCard = ({ post, layout = 'card', preview, showDescription =
143
144
  }, [resource, visuals, attachments, t]);
144
145
  if (!resource)
145
146
  return null;
146
- const downloadUrl = resource.resourceKind === 'file'
147
+ const fileUrl = resource.resourceKind === 'file'
147
148
  ? attachments.find((att) => attachmentMediaKind(att) === 'file')?.url
148
- : null;
149
+ : undefined;
150
+ const downloadUrl = fileUrl ? asDownloadUrl(fileUrl) : null;
149
151
  const renderSaveButton = (className) => staticRender ? null : (_jsx(ResourceSaveButton, { postId: post.id, className: className }));
150
152
  const renderGroupLabel = () => {
151
153
  if (!group || !groupLabel || inGroup)
@@ -2,26 +2,74 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { LayoutList, LayoutGrid, BookmarkIcon, ChevronDown, ChevronRight, } from 'lucide-react';
3
3
  import { RESOURCE_KINDS } from '@openpeepshq/common/lib';
4
4
  import { Button, Input, LoadingSpinner } from '@openpeepshq/react-ui';
5
- import { useMemo, useState } from 'react';
5
+ import { useEffect, useMemo, useRef, useState } from 'react';
6
6
  import { useT } from '../../i18n/index.js';
7
- import { useHrefOf } from '../../contexts/router/index.js';
8
- import { useResourceLibrary } from '../../hooks/index.js';
7
+ import { useHrefOf, useRouter, useSearchParams } from '../../contexts/router/index.js';
8
+ import { useResourceLibrary, } from '../../hooks/index.js';
9
9
  import { ResourceCard } from './ResourceCard.js';
10
10
  const COLLECTION_LIMIT = 5;
11
- const Tree = ({ nodes, selected, onSelect, counts, expanded, onToggle, }) => (_jsx("ul", { className: "space-y-1", children: nodes.map((node) => {
11
+ const parseKindFilter = (value) => value && RESOURCE_KINDS.includes(value)
12
+ ? value
13
+ : 'all';
14
+ const Tree = ({ nodes, selected, onSelect, counts, expanded, onToggle, t, }) => (_jsx("ul", { className: "space-y-1", children: nodes.map((node) => {
12
15
  const nodeKey = node.path.join('/');
13
16
  const nodeCount = counts.get(nodeKey) ?? 0;
14
17
  const isExpanded = expanded.has(nodeKey);
15
18
  const isSelected = selected.join('/') === nodeKey;
16
19
  const hasChildren = node.children.length > 0;
17
- return (_jsxs("li", { children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { type: "button", className: `text-muted-foreground hover:text-foreground ${hasChildren ? '' : 'invisible'}`, onClick: hasChildren ? () => onToggle(nodeKey) : undefined, children: _jsx(ChevronRight, { className: `size-3 transition-transform ${isExpanded ? 'rotate-90' : ''}` }) }), _jsxs("button", { type: "button", className: `text-sm ${isSelected
20
+ return (_jsxs("li", { children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { type: "button", className: `text-muted-foreground hover:text-foreground ${hasChildren ? '' : 'invisible'}`, onClick: hasChildren ? () => onToggle(nodeKey) : undefined, "aria-label": isExpanded
21
+ ? t('resources.library.collapseFolder', {
22
+ defaultValue: 'Collapse folder',
23
+ })
24
+ : t('resources.library.expandFolder', {
25
+ defaultValue: 'Expand folder',
26
+ }), children: _jsx(ChevronRight, { className: `size-3 transition-transform ${isExpanded ? 'rotate-90' : ''}` }) }), _jsxs("button", { type: "button", className: `text-sm ${isSelected
18
27
  ? 'font-semibold'
19
- : 'text-muted-foreground hover:text-foreground'}`, onClick: () => onSelect(node.path), children: [node.name, nodeCount > 0 ? (_jsxs("span", { className: "text-xs opacity-60", children: ["(", nodeCount, ")"] })) : null] })] }), hasChildren && isExpanded ? (_jsx("div", { className: "ml-4", children: _jsx(Tree, { nodes: node.children, selected: selected, onSelect: onSelect, counts: counts, expanded: expanded, onToggle: onToggle }) })) : null] }, nodeKey));
28
+ : 'text-muted-foreground hover:text-foreground'}`, onClick: () => onSelect(node.path), children: [node.name, nodeCount > 0 ? (_jsxs("span", { className: "text-xs opacity-60", children: ["(", nodeCount, ")"] })) : null] })] }), hasChildren && isExpanded ? (_jsx("div", { className: "ml-4", children: _jsx(Tree, { nodes: node.children, selected: selected, onSelect: onSelect, counts: counts, expanded: expanded, onToggle: onToggle, t: t }) })) : null] }, nodeKey));
20
29
  }) }));
21
30
  export const ResourceLibrary = ({ groupId }) => {
22
31
  const t = useT();
23
32
  const hrefOf = useHrefOf();
24
- const library = useResourceLibrary(groupId);
33
+ const router = useRouter();
34
+ const searchParams = useSearchParams();
35
+ // Read the URL once on mount: it seeds the filter state, after which the
36
+ // hook state is the source of truth and the URL a shareable mirror of it.
37
+ const initialFilters = useMemo(() => ({
38
+ kind: parseKindFilter(searchParams.get('kind')),
39
+ tags: searchParams.get('tags')?.split(',').filter(Boolean),
40
+ search: searchParams.get('q') ?? undefined,
41
+ }), []);
42
+ const library = useResourceLibrary(groupId, undefined, initialFilters);
43
+ // Keep a fresh view of the URL so the write-back below can skip no-ops.
44
+ const latestSearch = useRef(searchParams);
45
+ useEffect(() => {
46
+ latestSearch.current = searchParams;
47
+ });
48
+ // Shareable filters (?kind= &tags=a,b &q=): merged into the existing params
49
+ // so unrelated ones (e.g. ?category=) and the tab hash survive, written
50
+ // with replace so filter changes don't spam the history stack, and
51
+ // debounced so typing a search doesn't re-route on every keystroke.
52
+ useEffect(() => {
53
+ const timer = setTimeout(() => {
54
+ const prev = latestSearch.current;
55
+ const next = new URLSearchParams(prev);
56
+ next.delete('kind');
57
+ next.delete('tags');
58
+ next.delete('q');
59
+ if (library.kind !== 'all')
60
+ next.set('kind', library.kind);
61
+ if (library.selectedTags.length > 0) {
62
+ next.set('tags', library.selectedTags.join(','));
63
+ }
64
+ const q = library.search.trim();
65
+ if (q)
66
+ next.set('q', q);
67
+ if (next.toString() === prev.toString())
68
+ return;
69
+ router.setSearchParams(next, { replace: true });
70
+ }, 250);
71
+ return () => clearTimeout(timer);
72
+ }, [library.kind, library.selectedTags, library.search, router]);
25
73
  const [expanded, setExpanded] = useState(new Set());
26
74
  const toggleNode = (nodeKey) => {
27
75
  setExpanded((prev) => {
@@ -71,13 +119,18 @@ export const ResourceLibrary = ({ groupId }) => {
71
119
  ? sortedTags
72
120
  : sortedTags.slice(0, COLLECTION_LIMIT);
73
121
  const hasMoreTags = sortedTags.length > COLLECTION_LIMIT;
122
+ const folderTreeLabel = t(library.hierarchy
123
+ ? 'resources.library.hideFolderTree'
124
+ : 'resources.library.showFolderTree', {
125
+ defaultValue: library.hierarchy ? 'Hide folder tree' : 'Show folder tree',
126
+ });
74
127
  return (_jsxs("div", { children: [_jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Input, { className: "flex-1", value: library.search, onChange: (event) => library.setSearch(event.target.value), placeholder: t('resources.library.search', {
75
128
  defaultValue: 'Search resources',
76
129
  }), "data-testid": "resources-search" }), _jsxs("div", { className: "ml-auto flex gap-1", children: [_jsx(Button, { compact: true, size: "sm", variant: library.view === 'list' ? 'default' : 'outline', action: () => library.setView('list'), "data-testid": "resources-view-list", title: t('resources.library.viewList', {
77
130
  defaultValue: 'List view',
78
131
  }), children: _jsx(LayoutList, { className: "size-4" }) }), _jsx(Button, { compact: true, size: "sm", variant: library.view === 'cards' ? 'default' : 'outline', action: () => library.setView('cards'), "data-testid": "resources-view-cards", title: t('resources.library.viewCards', {
79
132
  defaultValue: 'Cards view',
80
- }), children: _jsx(LayoutGrid, { className: "size-4" }) }), _jsxs(Button, { compact: true, size: "sm", variant: library.saved ? 'default' : 'outline', action: () => library.setSaved(!library.saved), "data-testid": "resources-saved", title: t('resources.library.saved', { defaultValue: 'Saved' }), children: [_jsx(BookmarkIcon, { className: "size-4" }), t('resources.library.saved', { defaultValue: 'Saved' })] })] })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { compact: true, variant: library.kind === 'all' ? 'default' : 'outline', action: () => library.setKind('all'), children: t('resources.library.allKinds', { defaultValue: 'All' }) }), RESOURCE_KINDS.map((kind) => (_jsx(Button, { compact: true, variant: library.kind === kind ? 'default' : 'outline', action: () => library.setKind(kind), children: t(`resources.kinds.${kind}`, { defaultValue: kind }) }, kind)))] }), _jsxs("div", { children: [_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx("button", { type: "button", className: "text-muted-foreground hover:text-foreground", onClick: () => library.setPathPrefix([]), children: "All" }), library.pathPrefix.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-muted-foreground", children: "/" }), _jsx("span", { className: "text-muted-foreground", children: library.pathPrefix.join(' / ') })] })) : null, _jsx("button", { type: "button", className: "text-muted-foreground hover:text-foreground ml-auto", onClick: () => library.setHierarchy(!library.hierarchy), children: library.hierarchy ? (_jsx(ChevronDown, { className: "size-4" })) : (_jsx(ChevronRight, { className: "size-4" })) })] }), library.hierarchy ? (_jsx("div", { className: "border-border mt-2 rounded-md border p-3", children: treeNodes.length ? (_jsx(Tree, { nodes: treeNodes, selected: library.pathPrefix, onSelect: library.setPathPrefix, counts: collectionCounts, expanded: expanded, onToggle: toggleNode })) : null })) : null] }), library.tags.length ? (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("div", { className: "flex flex-wrap gap-1", children: visibleTags.map((entry) => {
133
+ }), children: _jsx(LayoutGrid, { className: "size-4" }) }), _jsxs(Button, { compact: true, size: "sm", variant: library.saved ? 'default' : 'outline', action: () => library.setSaved(!library.saved), "data-testid": "resources-saved", title: t('resources.library.saved', { defaultValue: 'Saved' }), children: [_jsx(BookmarkIcon, { className: "size-4" }), t('resources.library.saved', { defaultValue: 'Saved' })] })] })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { compact: true, variant: library.kind === 'all' ? 'default' : 'outline', action: () => library.setKind('all'), children: t('resources.library.allKinds', { defaultValue: 'All' }) }), RESOURCE_KINDS.map((kind) => (_jsx(Button, { compact: true, variant: library.kind === kind ? 'default' : 'outline', action: () => library.setKind(kind), children: t(`resources.kinds.${kind}`, { defaultValue: kind }) }, kind)))] }), _jsxs("div", { children: [_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx("button", { type: "button", className: "text-muted-foreground hover:text-foreground", onClick: () => library.setPathPrefix([]), children: "All" }), library.pathPrefix.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-muted-foreground", children: "/" }), _jsx("span", { className: "text-muted-foreground", children: library.pathPrefix.join(' / ') })] })) : null, _jsx("button", { type: "button", className: "text-muted-foreground hover:text-foreground ml-auto", onClick: () => library.setHierarchy(!library.hierarchy), title: folderTreeLabel, "aria-label": folderTreeLabel, children: library.hierarchy ? (_jsx(ChevronDown, { className: "size-4" })) : (_jsx(ChevronRight, { className: "size-4" })) })] }), library.hierarchy ? (_jsx("div", { className: "border-border mt-2 rounded-md border p-3", children: treeNodes.length ? (_jsx(Tree, { nodes: treeNodes, selected: library.pathPrefix, onSelect: library.setPathPrefix, counts: collectionCounts, expanded: expanded, onToggle: toggleNode, t: t })) : null })) : null] }), library.tags.length ? (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("div", { className: "flex flex-wrap gap-1", children: visibleTags.map((entry) => {
81
134
  const isSelected = library.selectedTags.includes(entry.name);
82
135
  return (_jsxs("button", { type: "button", className: `rounded-full px-2 py-0.5 text-xs ${isSelected
83
136
  ? 'bg-primary text-primary-foreground'