@openpeepshq/rn-components 0.7.0 → 0.7.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 (462) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +63 -0
  3. package/metro/css-interop-observable.js +41 -0
  4. package/metro/resolve-asset-source.js +19 -0
  5. package/metro.js +67 -0
  6. package/package.json +1 -1
  7. package/react-native.config.js +5 -0
  8. package/src/assets/audio/click-notification.wav +0 -0
  9. package/src/assets/images/audio-container.png +0 -0
  10. package/src/assets/images/black-ambition-2025-hero.png +0 -0
  11. package/src/assets/images/default-group-avatar.png +0 -0
  12. package/src/assets/images/event-placeholder.png +0 -0
  13. package/src/assets/images/group-header-placeholder.png +0 -0
  14. package/src/assets/images/jam-placeholder.png +0 -0
  15. package/src/assets/images/logo.webp +0 -0
  16. package/src/assets/images/profile-background-placeholder.png +0 -0
  17. package/src/assets/images/success.webp +0 -0
  18. package/src/assets/images/welcome-bg.webp +0 -0
  19. package/src/components/CapabilityMatrix.tsx +218 -0
  20. package/src/components/configuration/ConfigMenuButton.tsx +48 -0
  21. package/src/components/configuration/index.ts +1 -0
  22. package/src/components/conversations/ConversationMessageBubble.tsx +51 -0
  23. package/src/components/conversations/ConversationParticipantsModal.tsx +46 -0
  24. package/src/components/conversations/ConversationPreviewCard.tsx +158 -0
  25. package/src/components/conversations/ConversationProfileHeader.tsx +28 -0
  26. package/src/components/conversations/ConversationSettingsSheet.tsx +81 -0
  27. package/src/components/conversations/CreateNewConversationContext.tsx +71 -0
  28. package/src/components/conversations/DirectMessagesHeaderActions.tsx +24 -0
  29. package/src/components/conversations/MessageInThread.tsx +131 -0
  30. package/src/components/conversations/index.ts +8 -0
  31. package/src/components/custom/common/Loader.tsx +67 -0
  32. package/src/components/custom/common/agenda-tabs.tsx +47 -0
  33. package/src/components/custom/common/audio-player.tsx +219 -0
  34. package/src/components/custom/common/cached-image.tsx +34 -0
  35. package/src/components/custom/common/cached-video-player.tsx +497 -0
  36. package/src/components/custom/common/empty-state-container.tsx +58 -0
  37. package/src/components/custom/common/image-grid.tsx +95 -0
  38. package/src/components/custom/common/index.ts +12 -0
  39. package/src/components/custom/common/infinite-scroll-container.tsx +99 -0
  40. package/src/components/custom/common/media-upload-progress.tsx +109 -0
  41. package/src/components/custom/common/participant-avatar.tsx +34 -0
  42. package/src/components/custom/common/popover.tsx +268 -0
  43. package/src/components/custom/common/select.tsx +215 -0
  44. package/src/components/custom/date/formatter.ts +24 -0
  45. package/src/components/custom/date/index.ts +3 -0
  46. package/src/components/custom/date/timespan.tsx +49 -0
  47. package/src/components/custom/date/updating-date.tsx +31 -0
  48. package/src/components/custom/index.ts +4 -0
  49. package/src/components/custom/modals/common/base-sheet.tsx +104 -0
  50. package/src/components/custom/modals/common/index.ts +3 -0
  51. package/src/components/custom/modals/common/sheet-backdrop.tsx +14 -0
  52. package/src/components/custom/modals/common/sheet-footer.tsx +59 -0
  53. package/src/components/custom/modals/index.ts +3 -0
  54. package/src/components/custom/modals/media/alt-text-sheet.tsx +90 -0
  55. package/src/components/custom/modals/media/audio-picker-sheet.tsx +180 -0
  56. package/src/components/custom/modals/media/document-picker-sheet.tsx +384 -0
  57. package/src/components/custom/modals/media/image-picker-sheet.tsx +200 -0
  58. package/src/components/custom/modals/media/index.ts +7 -0
  59. package/src/components/custom/modals/media/record-audio-sheet.tsx +227 -0
  60. package/src/components/custom/modals/media/send-media-sheet.tsx +278 -0
  61. package/src/components/custom/modals/media/video-picker-sheet.tsx +109 -0
  62. package/src/components/custom/modals/settings/edit-notifications-sheet.tsx +184 -0
  63. package/src/components/custom/modals/settings/index.ts +1 -0
  64. package/src/components/custom/navigation/side-menu.tsx +223 -0
  65. package/src/components/form/HeaderAvatarInput.tsx +108 -0
  66. package/src/components/form/ImageInput.tsx +86 -0
  67. package/src/components/form/RadioSelect.tsx +58 -0
  68. package/src/components/form/TimeZoneSelect.tsx +97 -0
  69. package/src/components/form/index.ts +4 -0
  70. package/src/components/groups/AddGroupMemberModal.tsx +58 -0
  71. package/src/components/groups/AddGroupMembersButton.tsx +39 -0
  72. package/src/components/groups/ChangeGroupRolesModal.tsx +121 -0
  73. package/src/components/groups/ConfirmGroupExitModal.tsx +66 -0
  74. package/src/components/groups/ConfirmMemberRemovalModal.tsx +73 -0
  75. package/src/components/groups/DeleteGroupModal.tsx +68 -0
  76. package/src/components/groups/GroupAvatar.tsx +73 -0
  77. package/src/components/groups/GroupCapabilityMatrix.tsx +40 -0
  78. package/src/components/groups/GroupCard.tsx +84 -0
  79. package/src/components/groups/GroupFeed.tsx +25 -0
  80. package/src/components/groups/GroupForm.tsx +148 -0
  81. package/src/components/groups/GroupHeader.tsx +74 -0
  82. package/src/components/groups/GroupMembersList.tsx +194 -0
  83. package/src/components/groups/GroupNameFromId.tsx +17 -0
  84. package/src/components/groups/GroupNotificationSettingsModal.tsx +139 -0
  85. package/src/components/groups/GroupOptionsMenu.tsx +183 -0
  86. package/src/components/groups/GroupShareMenu.tsx +130 -0
  87. package/src/components/groups/JoinGroupButton.tsx +42 -0
  88. package/src/components/groups/index.ts +18 -0
  89. package/src/components/icons/iconWithClassName.ts +12 -0
  90. package/src/components/icons/index.ts +289 -0
  91. package/src/components/icons/types.ts +4 -0
  92. package/src/components/index.ts +12 -0
  93. package/src/components/jams/CreateNewJam.tsx +20 -0
  94. package/src/components/jams/CreateNewJamContext.tsx +36 -0
  95. package/src/components/jams/DeleteJamModal.tsx +69 -0
  96. package/src/components/jams/JamActionsFooter.tsx +85 -0
  97. package/src/components/jams/JamAnimatedEmoji.tsx +112 -0
  98. package/src/components/jams/JamCallParticipant.tsx +348 -0
  99. package/src/components/jams/JamCapacityGate.tsx +88 -0
  100. package/src/components/jams/JamCard.tsx +72 -0
  101. package/src/components/jams/JamChatDrawer.tsx +114 -0
  102. package/src/components/jams/JamChatMessage.tsx +86 -0
  103. package/src/components/jams/JamConference.tsx +69 -0
  104. package/src/components/jams/JamDesktopFooter.tsx +182 -0
  105. package/src/components/jams/JamDetailsDrawer.tsx +187 -0
  106. package/src/components/jams/JamDeviceSelectors.tsx +243 -0
  107. package/src/components/jams/JamDrawer.tsx +37 -0
  108. package/src/components/jams/JamFooter.tsx +241 -0
  109. package/src/components/jams/JamGuestForm.tsx +120 -0
  110. package/src/components/jams/JamLobby.tsx +203 -0
  111. package/src/components/jams/JamObserverShell.tsx +43 -0
  112. package/src/components/jams/JamParticipantConference.tsx +146 -0
  113. package/src/components/jams/JamPeopleDrawer.tsx +183 -0
  114. package/src/components/jams/JamReactionMenu.tsx +120 -0
  115. package/src/components/jams/JamRequestJoin.tsx +46 -0
  116. package/src/components/jams/JamRoom.tsx +194 -0
  117. package/src/components/jams/JamRoomIndicators.tsx +73 -0
  118. package/src/components/jams/JamRoomPanel.tsx +35 -0
  119. package/src/components/jams/JamToolbarButton.tsx +89 -0
  120. package/src/components/jams/JamVideoCall.tsx +50 -0
  121. package/src/components/jams/JamVideoLayout.tsx +401 -0
  122. package/src/components/jams/LeaveCloseButton.tsx +60 -0
  123. package/src/components/jams/LiveJamsSection.tsx +53 -0
  124. package/src/components/jams/index.ts +28 -0
  125. package/src/components/jams/useParticipantConnection.ts +43 -0
  126. package/src/components/layout/AuthLayout.tsx +156 -0
  127. package/src/components/layout/ContentHeader.tsx +62 -0
  128. package/src/components/layout/HeaderActionButton.tsx +23 -0
  129. package/src/components/layout/HeaderMobile.tsx +106 -0
  130. package/src/components/layout/PlusButton.tsx +34 -0
  131. package/src/components/layout/RootLayout.tsx +30 -0
  132. package/src/components/layout/index.ts +13 -0
  133. package/src/components/layout/pageChrome.test.tsx +147 -0
  134. package/src/components/layout/pageChrome.tsx +112 -0
  135. package/src/components/markdown/OpenpeepsMarkdown.tsx +129 -0
  136. package/src/components/markdown/extensions/codeBlock.tsx +63 -0
  137. package/src/components/markdown/extensions/codeInline.tsx +82 -0
  138. package/src/components/markdown/extensions/hashtag.tsx +77 -0
  139. package/src/components/markdown/extensions/html.test.tsx +172 -0
  140. package/src/components/markdown/extensions/html.tsx +116 -0
  141. package/src/components/markdown/extensions/mention.tsx +92 -0
  142. package/src/components/markdown/index.ts +2 -0
  143. package/src/components/markdown/theme.ts +59 -0
  144. package/src/components/markdown/utils.ts +34 -0
  145. package/src/components/navigation/Base.tsx +21 -0
  146. package/src/components/navigation/auth-navigator.tsx +47 -0
  147. package/src/components/navigation/helpers.ts +101 -0
  148. package/src/components/navigation/index.tsx +157 -0
  149. package/src/components/navigation/main-navigator.tsx +176 -0
  150. package/src/components/navigation/nativeRouter.tsx +255 -0
  151. package/src/components/navigation/parent-back.ts +139 -0
  152. package/src/components/navigation/side-menu-drawer.tsx +69 -0
  153. package/src/components/navigation/side-menu-wrapper.tsx +82 -0
  154. package/src/components/navigation/tab-navigator.tsx +254 -0
  155. package/src/components/navigation/types/auth.ts +23 -0
  156. package/src/components/navigation/types/index.ts +4 -0
  157. package/src/components/navigation/types/main.ts +156 -0
  158. package/src/components/navigation/types/root.ts +13 -0
  159. package/src/components/navigation/types/tabs.ts +51 -0
  160. package/src/components/notifications/NotificationErrorBoundary.tsx +40 -0
  161. package/src/components/notifications/NotificationHeaderActions.tsx +55 -0
  162. package/src/components/notifications/NotificationItem.tsx +80 -0
  163. package/src/components/notifications/NotificationWrapper.tsx +57 -0
  164. package/src/components/notifications/NotificationsList.tsx +103 -0
  165. package/src/components/notifications/index.ts +6 -0
  166. package/src/components/notifications/types/Announcement.tsx +51 -0
  167. package/src/components/notifications/types/DirectMessage.tsx +55 -0
  168. package/src/components/notifications/types/Follow.tsx +54 -0
  169. package/src/components/notifications/types/GroupMemberExit.tsx +52 -0
  170. package/src/components/notifications/types/JamModerator.tsx +38 -0
  171. package/src/components/notifications/types/JamSpeaker.tsx +38 -0
  172. package/src/components/notifications/types/JamStarted.tsx +39 -0
  173. package/src/components/notifications/types/Mention.tsx +56 -0
  174. package/src/components/notifications/types/NewGroupInvitation.tsx +53 -0
  175. package/src/components/notifications/types/NewGroupMember.tsx +57 -0
  176. package/src/components/notifications/types/NewGroupPost.tsx +41 -0
  177. package/src/components/notifications/types/NewProfile.tsx +53 -0
  178. package/src/components/notifications/types/PollEnded.tsx +55 -0
  179. package/src/components/notifications/types/PollVote.tsx +50 -0
  180. package/src/components/notifications/types/Reaction.tsx +49 -0
  181. package/src/components/notifications/types/Reply.tsx +52 -0
  182. package/src/components/notifications/types/Repost.tsx +49 -0
  183. package/src/components/notifications/types/Rsvp.tsx +48 -0
  184. package/src/components/notifications/types/RsvpCanceled.tsx +72 -0
  185. package/src/components/notifications/types/index.ts +19 -0
  186. package/src/components/post/CompactReplyParent.tsx +273 -0
  187. package/src/components/post/EventViewSwitch.tsx +42 -0
  188. package/src/components/post/Feed.tsx +110 -0
  189. package/src/components/post/FeedFormatSwitch.tsx +47 -0
  190. package/src/components/post/FeedPost.tsx +115 -0
  191. package/src/components/post/FeedPostContent.tsx +52 -0
  192. package/src/components/post/FullPostLayout.tsx +54 -0
  193. package/src/components/post/Markdown.tsx +8 -0
  194. package/src/components/post/NewEventButton.tsx +61 -0
  195. package/src/components/post/NewNoteButton.tsx +48 -0
  196. package/src/components/post/NewResourceButton.tsx +57 -0
  197. package/src/components/post/PinnedPost.tsx +42 -0
  198. package/src/components/post/PostDetail.tsx +55 -0
  199. package/src/components/post/ReplyBox.tsx +36 -0
  200. package/src/components/post/VideoPlayOverlay.tsx +23 -0
  201. package/src/components/post/feed/events/EventsCalendar.tsx +213 -0
  202. package/src/components/post/feed/events/EventsFeed.tsx +91 -0
  203. package/src/components/post/feed/events/EventsView.tsx +30 -0
  204. package/src/components/post/feed/events/index.ts +3 -0
  205. package/src/components/post/feed/threaded/ThreadPost.tsx +76 -0
  206. package/src/components/post/feed/threaded/ThreadedFeed.tsx +47 -0
  207. package/src/components/post/feed/threaded/index.ts +2 -0
  208. package/src/components/post/helpers.ts +54 -0
  209. package/src/components/post/index.ts +21 -0
  210. package/src/components/post/pieces/Attachments.tsx +153 -0
  211. package/src/components/post/pieces/AudioAttachment.tsx +57 -0
  212. package/src/components/post/pieces/DocumentAttachment.tsx +41 -0
  213. package/src/components/post/pieces/EventLocation.tsx +46 -0
  214. package/src/components/post/pieces/EventMenu.tsx +126 -0
  215. package/src/components/post/pieces/EventOccurrenceList.tsx +131 -0
  216. package/src/components/post/pieces/EventRsvpButton.tsx +177 -0
  217. package/src/components/post/pieces/EventRsvpList.tsx +277 -0
  218. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +238 -0
  219. package/src/components/post/pieces/FeedPostStats.tsx +75 -0
  220. package/src/components/post/pieces/FeedThreadPreview.tsx +88 -0
  221. package/src/components/post/pieces/GalleryModal.tsx +115 -0
  222. package/src/components/post/pieces/ParticipantsCard.tsx +20 -0
  223. package/src/components/post/pieces/PollContent.tsx +219 -0
  224. package/src/components/post/pieces/PostActions.tsx +81 -0
  225. package/src/components/post/pieces/PostInfoHeader.tsx +52 -0
  226. package/src/components/post/pieces/PostMenu.tsx +477 -0
  227. package/src/components/post/pieces/PostReactionHeader.tsx +120 -0
  228. package/src/components/post/pieces/ShareMenu.tsx +127 -0
  229. package/src/components/post/pieces/UnreadPostIndicator.tsx +34 -0
  230. package/src/components/post/pieces/VideoPlayer.tsx +30 -0
  231. package/src/components/post/pieces/VisibilityDisplay.tsx +43 -0
  232. package/src/components/post/pieces/gallery/GalleryAudio.tsx +20 -0
  233. package/src/components/post/pieces/gallery/GalleryDocument.tsx +35 -0
  234. package/src/components/post/pieces/gallery/GalleryImage.tsx +15 -0
  235. package/src/components/post/pieces/gallery/GalleryVideo.tsx +39 -0
  236. package/src/components/post/pieces/gallery/index.ts +4 -0
  237. package/src/components/post/pieces/index.ts +24 -0
  238. package/src/components/post/pieces/modals/CancelEventModal.tsx +60 -0
  239. package/src/components/post/pieces/modals/DeleteEventModal.tsx +60 -0
  240. package/src/components/post/pieces/modals/DeletePostModal.tsx +54 -0
  241. package/src/components/post/pieces/modals/PostOptionsSheet.tsx +59 -0
  242. package/src/components/post/pieces/modals/ReactionsModal.tsx +45 -0
  243. package/src/components/post/pieces/modals/RepostModal.tsx +56 -0
  244. package/src/components/post/pieces/modals/index.ts +6 -0
  245. package/src/components/post/post-form/ArticleForm.tsx +101 -0
  246. package/src/components/post/post-form/ArticlePreviewSheet.tsx +24 -0
  247. package/src/components/post/post-form/AttachmentCard.tsx +119 -0
  248. package/src/components/post/post-form/ComposeAttachments.tsx +126 -0
  249. package/src/components/post/post-form/ComposePreviewLinks.tsx +21 -0
  250. package/src/components/post/post-form/DateSheet.tsx +154 -0
  251. package/src/components/post/post-form/DescriptionEditModal.tsx +58 -0
  252. package/src/components/post/post-form/EditPostModalContext.tsx +49 -0
  253. package/src/components/post/post-form/EventForm.tsx +416 -0
  254. package/src/components/post/post-form/EventTypeSwitcher.tsx +164 -0
  255. package/src/components/post/post-form/Footer.tsx +61 -0
  256. package/src/components/post/post-form/NewPostModalContext.tsx +77 -0
  257. package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +218 -0
  258. package/src/components/post/post-form/PollComposerFields.tsx +141 -0
  259. package/src/components/post/post-form/PostAudienceSelector.tsx +82 -0
  260. package/src/components/post/post-form/PostForm.tsx +187 -0
  261. package/src/components/post/post-form/PostTypeSwitcher.tsx +125 -0
  262. package/src/components/post/post-form/ReplyModal.tsx +40 -0
  263. package/src/components/post/post-form/ReplyModalContext.tsx +24 -0
  264. package/src/components/post/post-form/ResourceForm.tsx +241 -0
  265. package/src/components/post/post-form/VisibilitySelector.tsx +60 -0
  266. package/src/components/post/post-form/VisibilitySheet.tsx +239 -0
  267. package/src/components/post/post-form/constants.ts +47 -0
  268. package/src/components/post/post-form/index.ts +23 -0
  269. package/src/components/post/types/Article.tsx +55 -0
  270. package/src/components/post/types/Event.tsx +79 -0
  271. package/src/components/post/types/Note.tsx +29 -0
  272. package/src/components/post/types/Poll.tsx +34 -0
  273. package/src/components/post/types/article/CardArticle.tsx +44 -0
  274. package/src/components/post/types/article/FullArticle.tsx +56 -0
  275. package/src/components/post/types/article/index.ts +2 -0
  276. package/src/components/post/types/event/CardEvent.tsx +138 -0
  277. package/src/components/post/types/event/FullEvent.tsx +760 -0
  278. package/src/components/post/types/event/ProfileEventRelationship.tsx +56 -0
  279. package/src/components/post/types/event/index.ts +3 -0
  280. package/src/components/post/types/index.ts +9 -0
  281. package/src/components/post/types/note/FullNote.tsx +15 -0
  282. package/src/components/post/types/note/index.ts +1 -0
  283. package/src/components/post/types/poll/FullPoll.tsx +26 -0
  284. package/src/components/post/types/poll/index.ts +1 -0
  285. package/src/components/post/types/resource/FullResource.tsx +177 -0
  286. package/src/components/preview-link/AccessDenied.tsx +44 -0
  287. package/src/components/preview-link/LocalPreviewLink.tsx +40 -0
  288. package/src/components/preview-link/PreviewLink.tsx +27 -0
  289. package/src/components/preview-link/RemotePreviewLink.tsx +76 -0
  290. package/src/components/preview-link/helpers.ts +38 -0
  291. package/src/components/preview-link/index.ts +7 -0
  292. package/src/components/preview-link/local/GroupPreview.tsx +57 -0
  293. package/src/components/preview-link/local/JamPreview.tsx +40 -0
  294. package/src/components/preview-link/local/PostPreview.tsx +40 -0
  295. package/src/components/profile/Avatar.tsx +90 -0
  296. package/src/components/profile/AvatarWithName.tsx +18 -0
  297. package/src/components/profile/EditProfileForm.tsx +380 -0
  298. package/src/components/profile/FollowUnfollowButton.tsx +83 -0
  299. package/src/components/profile/ProfileActivitySummary.tsx +129 -0
  300. package/src/components/profile/ProfileBadge.tsx +52 -0
  301. package/src/components/profile/ProfileCard.tsx +122 -0
  302. package/src/components/profile/ProfileFromId.tsx +23 -0
  303. package/src/components/profile/ProfileHeader.tsx +107 -0
  304. package/src/components/profile/ProfileLink.tsx +35 -0
  305. package/src/components/profile/ProfilePageAction.tsx +193 -0
  306. package/src/components/profile/ProfilePieces.tsx +191 -0
  307. package/src/components/profile/ProfilePostsAndReplies.tsx +108 -0
  308. package/src/components/profile/ProfileSelector.tsx +210 -0
  309. package/src/components/profile/ProfileSheet.tsx +48 -0
  310. package/src/components/profile/ProfileStats.tsx +47 -0
  311. package/src/components/profile/ProfileWithActionCard.tsx +35 -0
  312. package/src/components/profile/ProfilesInput.tsx +81 -0
  313. package/src/components/profile/ReportProfileOrPostModal.tsx +228 -0
  314. package/src/components/profile/index.ts +19 -0
  315. package/src/components/resources/ResourceCard.tsx +289 -0
  316. package/src/components/resources/ResourceLibrary.tsx +371 -0
  317. package/src/components/resources/index.ts +4 -0
  318. package/src/components/ui/alert.tsx +87 -0
  319. package/src/components/ui/avatar.tsx +91 -0
  320. package/src/components/ui/badge.tsx +36 -0
  321. package/src/components/ui/bottom-sheet.tsx +253 -0
  322. package/src/components/ui/button.tsx +101 -0
  323. package/src/components/ui/calendar.tsx +117 -0
  324. package/src/components/ui/card.tsx +87 -0
  325. package/src/components/ui/checkbox.tsx +35 -0
  326. package/src/components/ui/combobox.tsx +229 -0
  327. package/src/components/ui/dropdown-menu.tsx +350 -0
  328. package/src/components/ui/form.tsx +716 -0
  329. package/src/components/ui/index.ts +49 -0
  330. package/src/components/ui/input.tsx +25 -0
  331. package/src/components/ui/label.tsx +33 -0
  332. package/src/components/ui/loading-spinner.tsx +24 -0
  333. package/src/components/ui/popup-menu-button.tsx +99 -0
  334. package/src/components/ui/popup-menu-section.tsx +21 -0
  335. package/src/components/ui/popup-menu-separator.tsx +10 -0
  336. package/src/components/ui/popup-menu.tsx +75 -0
  337. package/src/components/ui/progress.tsx +83 -0
  338. package/src/components/ui/radio-group.tsx +42 -0
  339. package/src/components/ui/select.tsx +200 -0
  340. package/src/components/ui/separator.tsx +28 -0
  341. package/src/components/ui/skeleton.tsx +39 -0
  342. package/src/components/ui/svg-image.tsx +89 -0
  343. package/src/components/ui/switch.tsx +95 -0
  344. package/src/components/ui/tabs.tsx +93 -0
  345. package/src/components/ui/text.tsx +28 -0
  346. package/src/components/ui/textarea.tsx +39 -0
  347. package/src/components/ui/themed-safe-area-view.tsx +25 -0
  348. package/src/components/ui/themed-text.tsx +28 -0
  349. package/src/components/ui/themed-view.tsx +24 -0
  350. package/src/components/ui/tooltip.tsx +41 -0
  351. package/src/contexts/drawer-context.tsx +38 -0
  352. package/src/contexts/openpeeps-provider.tsx +135 -0
  353. package/src/global.css +53 -0
  354. package/src/hooks/helper.ts +26 -0
  355. package/src/hooks/index.ts +5 -0
  356. package/src/hooks/use-cached-media-uri.ts +59 -0
  357. package/src/hooks/use-controlled-sheet.ts +16 -0
  358. package/src/hooks/use-notification-badge-reset.ts +93 -0
  359. package/src/hooks/use-post-view-ref.ts +65 -0
  360. package/src/i18n/index.ts +49 -0
  361. package/src/index.ts +42 -0
  362. package/src/lib/attachmentHelpers.ts +15 -0
  363. package/src/lib/auth.ts +17 -0
  364. package/src/lib/bottom-sheet-ref.ts +30 -0
  365. package/src/lib/constants.ts +14 -0
  366. package/src/lib/credentialsStore.ts +20 -0
  367. package/src/lib/downloadFile.ts +12 -0
  368. package/src/lib/livekit/useStableLiveKitRoom.ts +172 -0
  369. package/src/lib/media-permissions.ts +90 -0
  370. package/src/lib/media-url.ts +51 -0
  371. package/src/lib/mediaUriHelpers.ts +94 -0
  372. package/src/lib/notification-helpers.ts +17 -0
  373. package/src/lib/notifications-screen-state.ts +21 -0
  374. package/src/lib/polyfills/customEvent.ts +40 -0
  375. package/src/lib/post.ts +175 -0
  376. package/src/lib/push-notification-navigation.ts +11 -0
  377. package/src/lib/push-notifications-background.ts +13 -0
  378. package/src/lib/push-notifications.ts +247 -0
  379. package/src/lib/uploadMedia.ts +191 -0
  380. package/src/lib/utils.ts +247 -0
  381. package/src/nativewind-env.d.ts +1 -0
  382. package/src/pages/About.tsx +27 -0
  383. package/src/pages/CodeOfConduct.tsx +24 -0
  384. package/src/pages/Explore.tsx +297 -0
  385. package/src/pages/Members.tsx +118 -0
  386. package/src/pages/NotFound.tsx +36 -0
  387. package/src/pages/Notifications.tsx +39 -0
  388. package/src/pages/PostDetail.tsx +61 -0
  389. package/src/pages/Profile.tsx +77 -0
  390. package/src/pages/Tags.tsx +114 -0
  391. package/src/pages/VideoPlayer.tsx +16 -0
  392. package/src/pages/Welcome.tsx +214 -0
  393. package/src/pages/articles/Edit.tsx +72 -0
  394. package/src/pages/articles/Index.tsx +31 -0
  395. package/src/pages/articles/New.tsx +55 -0
  396. package/src/pages/auth/Login.tsx +148 -0
  397. package/src/pages/auth/Register.tsx +271 -0
  398. package/src/pages/auth/RegisterInvitation.tsx +8 -0
  399. package/src/pages/auth/RequestResetPassword.tsx +102 -0
  400. package/src/pages/auth/ResetPassword.tsx +48 -0
  401. package/src/pages/auth/Success.tsx +104 -0
  402. package/src/pages/auth/ValidateEmail.tsx +80 -0
  403. package/src/pages/auth/Welcome.tsx +64 -0
  404. package/src/pages/conversations/Index.tsx +168 -0
  405. package/src/pages/conversations/Info.tsx +99 -0
  406. package/src/pages/conversations/New.tsx +135 -0
  407. package/src/pages/conversations/NewDraft.tsx +102 -0
  408. package/src/pages/conversations/Show.tsx +261 -0
  409. package/src/pages/events/Edit.tsx +74 -0
  410. package/src/pages/events/Index.tsx +99 -0
  411. package/src/pages/events/My.tsx +60 -0
  412. package/src/pages/events/New.tsx +51 -0
  413. package/src/pages/feeds/Bookmarks.tsx +47 -0
  414. package/src/pages/feeds/Local.tsx +45 -0
  415. package/src/pages/feeds/My.tsx +37 -0
  416. package/src/pages/groups/Edit.tsx +58 -0
  417. package/src/pages/groups/EditInfo.tsx +79 -0
  418. package/src/pages/groups/EditRoles.tsx +84 -0
  419. package/src/pages/groups/Index.tsx +159 -0
  420. package/src/pages/groups/Info.tsx +197 -0
  421. package/src/pages/groups/Members.tsx +55 -0
  422. package/src/pages/groups/New.tsx +80 -0
  423. package/src/pages/groups/Show.tsx +212 -0
  424. package/src/pages/index.ts +66 -0
  425. package/src/pages/jams/Event.tsx +49 -0
  426. package/src/pages/jams/Index.tsx +137 -0
  427. package/src/pages/jams/My.tsx +4 -0
  428. package/src/pages/jams/New.tsx +121 -0
  429. package/src/pages/posts/Edit.tsx +157 -0
  430. package/src/pages/posts/New.tsx +334 -0
  431. package/src/pages/posts/Reply.tsx +351 -0
  432. package/src/pages/profile/Followers.tsx +45 -0
  433. package/src/pages/profile/Following.tsx +44 -0
  434. package/src/pages/resources/Edit.tsx +72 -0
  435. package/src/pages/resources/Index.tsx +25 -0
  436. package/src/pages/resources/New.tsx +55 -0
  437. package/src/pages/settings/AccessTokens.tsx +276 -0
  438. package/src/pages/settings/Account.tsx +272 -0
  439. package/src/pages/settings/Blocked.tsx +81 -0
  440. package/src/pages/settings/Feed.tsx +78 -0
  441. package/src/pages/settings/Index.tsx +75 -0
  442. package/src/pages/settings/Language.tsx +81 -0
  443. package/src/pages/settings/NotificationPreferences.tsx +131 -0
  444. package/src/pages/settings/Notifications.tsx +36 -0
  445. package/src/pages/settings/PublicProfile.tsx +20 -0
  446. package/src/pages/settings/PushEnabledDevices.tsx +151 -0
  447. package/src/pages/settings/Theme.tsx +106 -0
  448. package/src/pages/settings/Timezone.tsx +75 -0
  449. package/src/stores/useAppImagesStore.ts +15 -0
  450. package/src/stores/useLocalPostStore.ts +62 -0
  451. package/src/stores/useNewConversationStore.ts +39 -0
  452. package/src/theme/OpenPeepsThemeProvider.tsx +98 -0
  453. package/src/theme/defaults.ts +40 -0
  454. package/src/theme/types.ts +37 -0
  455. package/src/theme/utils.ts +62 -0
  456. package/src/types/env.d.ts +11 -0
  457. package/src/types/goto.ts +12 -0
  458. package/src/types/markdown-plugin.ts +17 -0
  459. package/src/types/react-native-convert-ph-asset.d.ts +24 -0
  460. package/src/types.ts +56 -0
  461. package/src/utils/media-cache.ts +178 -0
  462. package/tailwind.config.js +128 -0
@@ -0,0 +1,156 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { Pressable, View } from 'react-native';
3
+ import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { getTheme } from '@openpeepshq/common';
6
+ import { useCurrentProfile, useOpenpeeps, useRouter } from '@openpeepshq/react';
7
+ import { useWindowSize } from '../../hooks/index';
8
+ import { BASE_URL, isProduction } from '../../lib/constants';
9
+ import { toAbsoluteMediaUrl } from '../../lib/media-url';
10
+ import { ProfileAvatar } from '../profile/Avatar';
11
+ import { ThemedText } from '../ui/themed-text';
12
+ import { SvgImage } from '../ui/svg-image';
13
+
14
+ export interface AuthLayoutProps {
15
+ children?: ReactNode;
16
+ description?: ReactNode;
17
+ noRedirect?: boolean;
18
+ }
19
+
20
+ const DevBanner = () =>
21
+ !isProduction ? (
22
+ <View className="absolute top-64 z-10 ml-8 mr-8 w-auto rounded-lg bg-white/80 p-4">
23
+ <ThemedText className="text-center text-destructive">
24
+ Test Backend ({BASE_URL})
25
+ </ThemedText>
26
+ </View>
27
+ ) : null;
28
+
29
+ const Logo = ({ uri }: { uri?: string }) => {
30
+ const router = useRouter();
31
+ if (!uri) return null;
32
+ return (
33
+ <Pressable
34
+ onPress={() => router.navigate({ type: 'home' })}
35
+ hitSlop={24}
36
+ className="absolute left-2 top-16 z-10 h-[26px] w-[206px] max-w-fit"
37
+ >
38
+ <SvgImage uri={uri} className="h-[26px] w-[206px] max-w-fit" />
39
+ </Pressable>
40
+ );
41
+ };
42
+
43
+ // Mirror web Auth.tsx: on shell-less auth pages (about/code-of-conduct) show a
44
+ // signed-in user's avatar and a Go-to-community link so navigation back to the
45
+ // app is still available without the side-menu Wrapper.
46
+ const SignedInRow = () => {
47
+ const me = useCurrentProfile();
48
+ const router = useRouter();
49
+ const { t } = useTranslation();
50
+ if (!me) return null;
51
+ const name = me.displayName?.trim() || (me.handle ? `@${me.handle}` : '');
52
+ return (
53
+ <View className="flex-row items-center gap-3 px-2 pb-2 pt-1">
54
+ <ProfileAvatar profile={me} className="size-8 border-0" />
55
+ <View>
56
+ <ThemedText className="text-sm text-muted-foreground">
57
+ {t('auth.signedInAs', { name })}
58
+ </ThemedText>
59
+ <Pressable onPress={() => router.navigate({ type: 'home' })}>
60
+ <ThemedText className="text-sm font-medium text-primary">
61
+ {t('auth.goToCommunity')}
62
+ </ThemedText>
63
+ </Pressable>
64
+ </View>
65
+ </View>
66
+ );
67
+ };
68
+
69
+ const AuthImage = ({ children }: { children?: ReactNode }) => {
70
+ const { openpeepsApi } = useOpenpeeps();
71
+ const { data: serverInfo, isLoading } = openpeepsApi.useServerInfo();
72
+ const resolvedTheme = serverInfo
73
+ ? getTheme(serverInfo.communityConfig)
74
+ : undefined;
75
+ const authBackgroundUri = toAbsoluteMediaUrl(resolvedTheme?.backgroundAuth);
76
+ const resolvedLogoUri = toAbsoluteMediaUrl(resolvedTheme?.logoSmall);
77
+
78
+ const content = (
79
+ <>
80
+ <Logo uri={resolvedLogoUri} />
81
+ <DevBanner />
82
+ {children}
83
+ </>
84
+ );
85
+
86
+ if (authBackgroundUri && !isLoading) {
87
+ return (
88
+ <View className="w-full flex-1 justify-end">
89
+ <SvgImage
90
+ uri={authBackgroundUri}
91
+ className="absolute inset-0"
92
+ resizeMode="stretch"
93
+ />
94
+ {content}
95
+ </View>
96
+ );
97
+ }
98
+
99
+ return (
100
+ <View className="bg-background w-full flex-1 justify-end">{content}</View>
101
+ );
102
+ };
103
+
104
+ const NarrowAuthLayout = ({
105
+ children,
106
+ description,
107
+ }: {
108
+ children?: ReactNode;
109
+ description?: ReactNode;
110
+ }) => (
111
+ <AuthImage>
112
+ <View className="bg-background w-full min-h-[400px] px-2 pb-10 pt-4">
113
+ <SignedInRow />
114
+ {description}
115
+ {children}
116
+ </View>
117
+ </AuthImage>
118
+ );
119
+
120
+ const WideAuthLayout = ({
121
+ children,
122
+ description,
123
+ }: {
124
+ children?: ReactNode;
125
+ description?: ReactNode;
126
+ }) => (
127
+ <View className="flex flex-1 flex-row">
128
+ <View className="flex-1">
129
+ <AuthImage />
130
+ </View>
131
+ <View className="flex flex-1 justify-center p-6">
132
+ <SignedInRow />
133
+ {description}
134
+ {children}
135
+ </View>
136
+ </View>
137
+ );
138
+
139
+ export const AuthLayout = ({ children, description }: AuthLayoutProps) => {
140
+ const { isMediumScreenOrLarger } = useWindowSize();
141
+
142
+ return (
143
+ <KeyboardAwareScrollView
144
+ contentContainerClassName="grow"
145
+ className="bg-background flex w-full"
146
+ >
147
+ {isMediumScreenOrLarger ? (
148
+ <WideAuthLayout description={description}>{children}</WideAuthLayout>
149
+ ) : (
150
+ <NarrowAuthLayout description={description}>
151
+ {children}
152
+ </NarrowAuthLayout>
153
+ )}
154
+ </KeyboardAwareScrollView>
155
+ );
156
+ };
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { Pressable, View } from 'react-native';
3
+ import { useNavigation, useRoute } from '@react-navigation/native';
4
+ import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
5
+ import { useCurrentProfile } from '@openpeepshq/react';
6
+ import { goToParentOrBack } from '../navigation/parent-back';
7
+ import type { MainStackParamList } from '../navigation/types';
8
+ import { ChevronLeftIcon } from '../icons/index';
9
+ import { ThemedText } from '../ui/themed-text';
10
+ import { usePageChrome } from './pageChrome';
11
+
12
+ export const ContentHeader = () => {
13
+ const { header } = usePageChrome();
14
+ const navigation =
15
+ useNavigation<NativeStackNavigationProp<MainStackParamList>>();
16
+ const route = useRoute();
17
+ const me = useCurrentProfile();
18
+
19
+ const title = header?.title;
20
+ const titleIsString = typeof title === 'string';
21
+
22
+ return (
23
+ <View className="border-border flex-row items-center justify-between border-b px-4 py-2">
24
+ <View className="min-w-0 flex-1 flex-row items-center gap-2">
25
+ <Pressable
26
+ accessibilityRole="button"
27
+ accessibilityLabel="Back"
28
+ onPress={() => {
29
+ if (header?.onBack) {
30
+ header.onBack();
31
+ return;
32
+ }
33
+ goToParentOrBack({
34
+ navigation,
35
+ routeName: route.name,
36
+ params: route.params as Record<string, unknown> | undefined,
37
+ profileHandle: me?.handle,
38
+ });
39
+ }}
40
+ className="items-center justify-center p-2"
41
+ >
42
+ <ChevronLeftIcon size={28} className="text-foreground" />
43
+ </Pressable>
44
+ {titleIsString ? (
45
+ <ThemedText
46
+ className="min-w-0 flex-1 text-xl font-semibold"
47
+ numberOfLines={1}
48
+ >
49
+ {title}
50
+ </ThemedText>
51
+ ) : (
52
+ title
53
+ )}
54
+ </View>
55
+ {header?.actions ? (
56
+ <View className="ml-2 shrink-0 flex-row items-center">
57
+ {header.actions}
58
+ </View>
59
+ ) : null}
60
+ </View>
61
+ );
62
+ };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { ActivityIndicator } from 'react-native';
3
+ import { Button } from '../ui/button';
4
+ import { ThemedText } from '../ui/themed-text';
5
+
6
+ export const HeaderActionButton = ({
7
+ title,
8
+ onPress,
9
+ disabled,
10
+ loading,
11
+ }: {
12
+ title: string;
13
+ onPress: () => void;
14
+ disabled?: boolean;
15
+ loading?: boolean;
16
+ }) => (
17
+ <Button disabled={disabled} onPress={onPress}>
18
+ {loading ? <ActivityIndicator size="small" /> : null}
19
+ <ThemedText className="text-primary-foreground text-base font-semibold">
20
+ {title}
21
+ </ThemedText>
22
+ </Button>
23
+ );
@@ -0,0 +1,106 @@
1
+ import React from 'react';
2
+ import {
3
+ Platform,
4
+ StatusBar,
5
+ StyleSheet,
6
+ View,
7
+ useColorScheme,
8
+ } from 'react-native';
9
+ import { SafeAreaView } from 'react-native-safe-area-context';
10
+ import { useNavigation } from '@react-navigation/native';
11
+ import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
12
+ import { useOpenpeeps } from '@openpeepshq/react';
13
+ import { useDrawer } from '../../contexts/drawer-context';
14
+ import { useWindowSize } from '../../hooks/index';
15
+ import { BASE_URL, isProduction } from '../../lib/constants';
16
+ import { toAbsoluteMediaUrl } from '../../lib/media-url';
17
+ import { getTheme } from '@openpeepshq/common';
18
+ import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar';
19
+ import { Button } from '../ui/button';
20
+ import { ThemedText } from '../ui/themed-text';
21
+ import { SvgImage } from '../ui/svg-image';
22
+ import { MessageSquareTextIcon, UserIcon } from '../icons/index';
23
+ import type { MainStackParamList } from '../navigation/types/index';
24
+
25
+ export const HeaderMobile = () => {
26
+ const { openDrawer } = useDrawer();
27
+ const { isMediumScreenOrLarger } = useWindowSize();
28
+ const { openpeepsApi, currentProfile } = useOpenpeeps();
29
+ const navigation =
30
+ useNavigation<NativeStackNavigationProp<MainStackParamList>>();
31
+ const { data: serverInfo } = openpeepsApi.useServerInfo();
32
+ const { data: profileSettings } = openpeepsApi.useCurrentProfileSettings();
33
+
34
+ // Mirrors web HeaderMobile: resolve branding per active theme mode. The
35
+ // system scheme must come from RN: getTheme's default cannot read it.
36
+ const systemColorScheme = useColorScheme();
37
+ const systemScheme = systemColorScheme === 'dark' ? 'dark' : 'light';
38
+ const resolvedTheme = serverInfo
39
+ ? getTheme(serverInfo.communityConfig, profileSettings, systemScheme)
40
+ : undefined;
41
+ const logoUri = toAbsoluteMediaUrl(resolvedTheme?.logoSmall);
42
+ const backgroundUri = toAbsoluteMediaUrl(resolvedTheme?.background);
43
+
44
+ if (isMediumScreenOrLarger) {
45
+ return null;
46
+ }
47
+
48
+ return (
49
+ <View style={styles.header} className="px-4 pb-3">
50
+ {backgroundUri ? (
51
+ <SvgImage
52
+ uri={backgroundUri}
53
+ className="absolute inset-0"
54
+ resizeMode="cover"
55
+ />
56
+ ) : null}
57
+ <SafeAreaView edges={['top']}>
58
+ {!isProduction && (
59
+ <View className="mb-2 w-full rounded-lg bg-white/50 p-2">
60
+ <ThemedText className="text-center text-destructive">
61
+ Test Backend ({BASE_URL})
62
+ </ThemedText>
63
+ </View>
64
+ )}
65
+ <View className="flex-row items-center justify-between">
66
+ <Button
67
+ variant="outline"
68
+ size="icon"
69
+ onPress={openDrawer}
70
+ className="native:px-0 active:bg-none rounded-full bg-black"
71
+ >
72
+ <Avatar alt={(currentProfile?.displayName as string) || 'Profile'}>
73
+ {currentProfile?.avatar ? (
74
+ <AvatarImage source={{ uri: currentProfile.avatar }} />
75
+ ) : (
76
+ <AvatarFallback className="-bottom-2 -right-2 h-6 w-6 bg-black">
77
+ <UserIcon size={20} className="text-muted-foreground" />
78
+ </AvatarFallback>
79
+ )}
80
+ </Avatar>
81
+ </Button>
82
+ <SvgImage uri={logoUri} className="h-[64px] w-[216px]" />
83
+ <Button
84
+ variant="outline"
85
+ size="icon"
86
+ onPress={() =>
87
+ navigation.navigate('TabNavigator', { screen: 'Messages' })
88
+ }
89
+ accessibilityLabel="Messages"
90
+ >
91
+ <MessageSquareTextIcon
92
+ className="text-muted-foreground"
93
+ size={18}
94
+ />
95
+ </Button>
96
+ </View>
97
+ </SafeAreaView>
98
+ </View>
99
+ );
100
+ };
101
+
102
+ const styles = StyleSheet.create({
103
+ header: {
104
+ paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,
105
+ },
106
+ });
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { Pressable } from 'react-native';
3
+ import { PlusIcon } from '../icons/index';
4
+ import { usePageChrome } from './pageChrome';
5
+
6
+ // PlusButton is always fully round — it doesn't use the theme's buttonRadius
7
+ // setting (which is for regular buttons). On web, circular elements have a
8
+ // separate theme token; on RN we use a static 9999px (same as rounded-full).
9
+ const PLUS_BUTTON_RADIUS = 9999;
10
+
11
+ export const PlusButton = () => {
12
+ const { plus } = usePageChrome();
13
+ if (!plus || Array.isArray(plus)) return null;
14
+
15
+ const Icon = plus.icon ?? PlusIcon;
16
+
17
+ const onPress = () => {
18
+ if (typeof plus.action === 'function') {
19
+ void plus.action();
20
+ }
21
+ };
22
+
23
+ return (
24
+ <Pressable
25
+ accessibilityRole="button"
26
+ accessibilityLabel={plus.title || 'New'}
27
+ onPress={onPress}
28
+ style={{ borderRadius: PLUS_BUTTON_RADIUS }}
29
+ className="bg-primary absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-button"
30
+ >
31
+ <Icon size={24} className="text-primary-foreground" />
32
+ </Pressable>
33
+ );
34
+ };
@@ -0,0 +1,30 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { View } from 'react-native';
3
+ import { ThemedView } from '../ui/themed-view';
4
+ import { ContentHeader } from './ContentHeader';
5
+ import { HeaderMobile } from './HeaderMobile';
6
+ import { PageChromeProvider } from './pageChrome';
7
+ import { PlusButton } from './PlusButton';
8
+
9
+ export const RootLayout = ({ children }: { children: ReactNode }) => (
10
+ <PageChromeProvider>
11
+ <ThemedView className="flex-1">
12
+ <HeaderMobile />
13
+ <ContentHeader />
14
+ <View className="min-h-0 flex-1">{children}</View>
15
+ <PlusButton />
16
+ </ThemedView>
17
+ </PageChromeProvider>
18
+ );
19
+
20
+ export const withRootLayout = <P extends object>(
21
+ Screen: React.ComponentType<P>
22
+ ) => {
23
+ const Wrapped = (props: P) => (
24
+ <RootLayout>
25
+ <Screen {...props} />
26
+ </RootLayout>
27
+ );
28
+ Wrapped.displayName = `withRootLayout(${Screen.displayName ?? Screen.name})`;
29
+ return Wrapped;
30
+ };
@@ -0,0 +1,13 @@
1
+ export { HeaderActionButton } from './HeaderActionButton';
2
+ export { AuthLayout } from './AuthLayout';
3
+ export type { AuthLayoutProps } from './AuthLayout';
4
+ export { ContentHeader } from './ContentHeader';
5
+ export { HeaderMobile } from './HeaderMobile';
6
+ export {
7
+ PageChromeProvider,
8
+ usePageChrome,
9
+ useSetPageHeader,
10
+ useSetPlusButtonActions,
11
+ } from './pageChrome';
12
+ export { PlusButton } from './PlusButton';
13
+ export { RootLayout, withRootLayout } from './RootLayout';
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Regression tests for the page-chrome infinite update loop
3
+ * ("Maximum update depth exceeded") that crashed Groups, Jams and Explore
4
+ * (and any other page that registers header or plus actions with fresh,
5
+ * non-memoized values) in @openpeepshq/rn-components 0.3.12.
6
+ *
7
+ * Root cause: useSetPageHeader / useSetPlusButtonActions read their
8
+ * setters from the same context whose value changes whenever the header
9
+ * or plus state changes. A screen that registers a fresh element or
10
+ * object therefore re-renders on every chrome update, re-runs its layout
11
+ * effect and calls setState again.
12
+ */
13
+ import { type ReactNode } from 'react';
14
+ import ReactTestRenderer from 'react-test-renderer';
15
+ import {
16
+ PageChromeProvider,
17
+ usePageChrome,
18
+ useSetPageHeader,
19
+ useSetPlusButtonActions,
20
+ } from './pageChrome';
21
+
22
+ const MAX_RENDER_GUARD = 20;
23
+
24
+ const Text = ({ children }: { children?: ReactNode }) => (
25
+ <text>{children}</text>
26
+ );
27
+
28
+ const View = ({ children }: { children?: ReactNode }) => (
29
+ <view>{children}</view>
30
+ );
31
+
32
+ const render = (ui: ReactNode) => {
33
+ const element = <PageChromeProvider>{ui}</PageChromeProvider>;
34
+ let tree!: ReactTestRenderer.ReactTestRenderer;
35
+ ReactTestRenderer.act(() => {
36
+ tree = ReactTestRenderer.create(element);
37
+ });
38
+ return tree;
39
+ };
40
+
41
+ const UnstableHeaderScreen = ({ onRender }: { onRender: () => void }) => {
42
+ onRender();
43
+ useSetPageHeader(
44
+ 'Jams',
45
+ <View>
46
+ <Text>actions</Text>
47
+ </View>
48
+ );
49
+ return <Text>screen</Text>;
50
+ };
51
+
52
+ const UnstablePlusScreen = ({ onRender }: { onRender: () => void }) => {
53
+ onRender();
54
+ useSetPageHeader('Groups');
55
+ useSetPlusButtonActions({ title: 'New group', action: () => {} });
56
+ return <Text>screen</Text>;
57
+ };
58
+
59
+ const StableScreen = () => {
60
+ useSetPageHeader('Feed');
61
+ return <Text>screen</Text>;
62
+ };
63
+
64
+ const ChromeProbe = ({
65
+ onChrome,
66
+ }: {
67
+ onChrome: (title?: string, plusTitle?: string) => void;
68
+ }) => {
69
+ const { header, plus } = usePageChrome();
70
+ const plusTitle = Array.isArray(plus) ? plus[0]?.title : plus?.title;
71
+ onChrome(
72
+ typeof header?.title === 'string' ? header.title : undefined,
73
+ plusTitle
74
+ );
75
+ return null;
76
+ };
77
+
78
+ test('unstable header actions do not loop (jams/explore)', () => {
79
+ let renders = 0;
80
+ const tree = render(
81
+ <UnstableHeaderScreen
82
+ onRender={() => {
83
+ renders += 1;
84
+ if (renders > MAX_RENDER_GUARD) {
85
+ throw new Error('Maximum update depth exceeded');
86
+ }
87
+ }}
88
+ />
89
+ );
90
+ expect(renders).toBeLessThanOrEqual(MAX_RENDER_GUARD);
91
+ expect(JSON.stringify(tree.toJSON())).toContain('screen');
92
+ tree.unmount();
93
+ });
94
+
95
+ test('unstable plus actions do not loop (groups)', () => {
96
+ let renders = 0;
97
+ const tree = render(
98
+ <UnstablePlusScreen
99
+ onRender={() => {
100
+ renders += 1;
101
+ if (renders > MAX_RENDER_GUARD) {
102
+ throw new Error('Maximum update depth exceeded');
103
+ }
104
+ }}
105
+ />
106
+ );
107
+ expect(renders).toBeLessThanOrEqual(MAX_RENDER_GUARD);
108
+ expect(JSON.stringify(tree.toJSON())).toContain('screen');
109
+ tree.unmount();
110
+ });
111
+
112
+ test('stable title-only header still works', () => {
113
+ const tree = render(<StableScreen />);
114
+ expect(JSON.stringify(tree.toJSON())).toContain('screen');
115
+ tree.unmount();
116
+ });
117
+
118
+ test('display chrome still sees registered header and plus', () => {
119
+ let title: string | undefined;
120
+ let plusTitle: string | undefined;
121
+ const tree = render(
122
+ <View>
123
+ <UnstablePlusScreen onRender={() => {}} />
124
+ <ChromeProbe
125
+ onChrome={(nextTitle, nextPlusTitle) => {
126
+ title = nextTitle;
127
+ plusTitle = nextPlusTitle;
128
+ }}
129
+ />
130
+ </View>
131
+ );
132
+ expect(title).toBe('Groups');
133
+ expect(plusTitle).toBe('New group');
134
+ tree.unmount();
135
+ });
136
+
137
+ test('page chrome hooks throw outside RootLayout', () => {
138
+ const Bare = () => {
139
+ useSetPageHeader('Feed');
140
+ return null;
141
+ };
142
+ expect(() => {
143
+ ReactTestRenderer.act(() => {
144
+ ReactTestRenderer.create(<Bare />);
145
+ });
146
+ }).toThrow('Page chrome hooks must be used within RootLayout');
147
+ });
@@ -0,0 +1,112 @@
1
+ import {
2
+ createContext,
3
+ ComponentType,
4
+ useContext,
5
+ useLayoutEffect,
6
+ useMemo,
7
+ useState,
8
+ type ReactNode,
9
+ } from 'react';
10
+
11
+ export type PlusButtonAction = {
12
+ action: string | (() => Promise<unknown> | unknown);
13
+ icon?: ComponentType<{ size?: number | string; className?: string }>;
14
+ title?: string;
15
+ };
16
+
17
+ export type PlusButtonActions =
18
+ | PlusButtonAction
19
+ | PlusButtonAction[]
20
+ | undefined;
21
+
22
+ export type PageHeaderValue = {
23
+ title?: ReactNode;
24
+ actions?: ReactNode;
25
+ onBack?: () => void;
26
+ };
27
+
28
+ type PageChromeSetters = {
29
+ setHeader: (header: PageHeaderValue | undefined) => void;
30
+ setPlus: (plus: PlusButtonActions) => void;
31
+ };
32
+
33
+ type PageChromeValues = {
34
+ header: PageHeaderValue | undefined;
35
+ plus: PlusButtonActions;
36
+ };
37
+
38
+ /**
39
+ * Stable setters context. Its value never changes, so components that call
40
+ * `useSetPageHeader` / `useSetPlusButtonActions` are not re-rendered when
41
+ * the chrome values change. Keeping the setters out of the value context is
42
+ * what prevents infinite update loops ("Maximum update depth exceeded") for
43
+ * pages that register a fresh, non-memoized header element or plus-actions
44
+ * object on every render.
45
+ */
46
+ const PageChromeSettersContext = createContext<PageChromeSetters | null>(null);
47
+
48
+ /**
49
+ * Chrome values context. Its value changes whenever the header or plus
50
+ * actions change, so it must only be consumed by display components
51
+ * (header/plus button) — never by a component that registers the values.
52
+ */
53
+ const PageChromeValuesContext = createContext<PageChromeValues | null>(null);
54
+
55
+ const MISSING_CHROME_ERROR = 'Page chrome hooks must be used within RootLayout';
56
+
57
+ export const PageChromeProvider = ({ children }: { children: ReactNode }) => {
58
+ const [header, setHeader] = useState<PageHeaderValue | undefined>();
59
+ const [plus, setPlus] = useState<PlusButtonActions>(undefined);
60
+ // useState setters are stable, so this value is created exactly once.
61
+ const setters = useMemo(() => ({ setHeader, setPlus }), [setHeader, setPlus]);
62
+ const values = useMemo(() => ({ header, plus }), [header, plus]);
63
+ return (
64
+ <PageChromeSettersContext.Provider value={setters}>
65
+ <PageChromeValuesContext.Provider value={values}>
66
+ {children}
67
+ </PageChromeValuesContext.Provider>
68
+ </PageChromeSettersContext.Provider>
69
+ );
70
+ };
71
+
72
+ const useSetters = () => {
73
+ const ctx = useContext(PageChromeSettersContext);
74
+ if (!ctx) {
75
+ throw new Error(MISSING_CHROME_ERROR);
76
+ }
77
+ return ctx;
78
+ };
79
+
80
+ const useValues = () => {
81
+ const ctx = useContext(PageChromeValuesContext);
82
+ if (!ctx) {
83
+ throw new Error(MISSING_CHROME_ERROR);
84
+ }
85
+ return ctx;
86
+ };
87
+
88
+ export const usePageChrome = () => {
89
+ const values = useValues();
90
+ const setters = useSetters();
91
+ return { ...values, ...setters };
92
+ };
93
+
94
+ export const useSetPageHeader = (
95
+ title?: ReactNode,
96
+ actions?: ReactNode,
97
+ onBack?: () => void
98
+ ) => {
99
+ const { setHeader } = useSetters();
100
+ useLayoutEffect(() => {
101
+ setHeader({ title, actions, onBack });
102
+ return () => setHeader(undefined);
103
+ }, [actions, onBack, setHeader, title]);
104
+ };
105
+
106
+ export const useSetPlusButtonActions = (actions: PlusButtonActions) => {
107
+ const { setPlus } = useSetters();
108
+ useLayoutEffect(() => {
109
+ setPlus(actions);
110
+ return () => setPlus(undefined);
111
+ }, [actions, setPlus]);
112
+ };