@selfcommunity/react-ui 0.7.0-alpha.335 → 0.7.0-alpha.337

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 (316) hide show
  1. package/lib/cjs/components/BottomNavigation/BottomNavigation.js +8 -11
  2. package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +22 -0
  3. package/lib/cjs/components/Composer/Attributes/Attributes.js +41 -0
  4. package/lib/cjs/components/Composer/Attributes/index.d.ts +3 -0
  5. package/lib/cjs/components/Composer/{Poll → Attributes}/index.js +2 -2
  6. package/lib/cjs/components/Composer/Composer.d.ts +61 -84
  7. package/lib/cjs/components/Composer/Composer.js +265 -441
  8. package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.d.ts +32 -0
  9. package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +53 -0
  10. package/lib/cjs/components/Composer/Content/ContentDiscussion/index.d.ts +3 -0
  11. package/lib/cjs/components/Composer/Content/ContentDiscussion/index.js +5 -0
  12. package/lib/cjs/components/Composer/Content/ContentPoll/ContentPoll.d.ts +26 -0
  13. package/lib/cjs/components/Composer/Content/ContentPoll/ContentPoll.js +129 -0
  14. package/lib/cjs/components/Composer/Content/ContentPoll/index.d.ts +3 -0
  15. package/lib/cjs/components/Composer/Content/ContentPoll/index.js +5 -0
  16. package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.d.ts +32 -0
  17. package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +51 -0
  18. package/lib/cjs/components/Composer/Content/ContentPost/index.d.ts +3 -0
  19. package/lib/cjs/components/Composer/Content/ContentPost/index.js +5 -0
  20. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +11 -0
  21. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +74 -0
  22. package/lib/cjs/components/Composer/Layer/AudienceLayer/index.d.ts +3 -0
  23. package/lib/cjs/components/Composer/Layer/AudienceLayer/index.js +5 -0
  24. package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +9 -0
  25. package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.js +41 -0
  26. package/lib/cjs/components/Composer/Layer/CategoryLayer/index.d.ts +3 -0
  27. package/lib/cjs/components/Composer/Layer/CategoryLayer/index.js +5 -0
  28. package/lib/cjs/components/Composer/Layer/CloseLayer/CloseLayer.d.ts +7 -0
  29. package/lib/cjs/components/Composer/Layer/CloseLayer/CloseLayer.js +41 -0
  30. package/lib/cjs/components/Composer/Layer/CloseLayer/index.d.ts +3 -0
  31. package/lib/cjs/components/Composer/{Audience → Layer/CloseLayer}/index.js +2 -2
  32. package/lib/cjs/components/Composer/Layer/LocationLayer/LocationLayer.d.ts +9 -0
  33. package/lib/cjs/components/Composer/Layer/LocationLayer/LocationLayer.js +41 -0
  34. package/lib/cjs/components/Composer/Layer/LocationLayer/index.d.ts +3 -0
  35. package/lib/cjs/components/Composer/Layer/LocationLayer/index.js +5 -0
  36. package/lib/cjs/components/Composer/Skeleton.d.ts +0 -4
  37. package/lib/cjs/components/Composer/Skeleton.js +10 -72
  38. package/lib/cjs/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.d.ts +6 -0
  39. package/lib/cjs/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.js +47 -0
  40. package/lib/cjs/components/Composer/TypeSwitchButtonGroup/index.d.ts +3 -0
  41. package/lib/cjs/components/Composer/TypeSwitchButtonGroup/index.js +5 -0
  42. package/lib/cjs/components/Composer/constants.d.ts +1 -0
  43. package/lib/cjs/components/Composer/constants.js +4 -0
  44. package/lib/cjs/components/Composer/index.d.ts +2 -3
  45. package/lib/cjs/components/Composer/index.js +1 -6
  46. package/lib/cjs/components/ComposerIconButton/ComposerIconButton.d.ts +2 -1
  47. package/lib/cjs/components/ComposerIconButton/ComposerIconButton.js +8 -8
  48. package/lib/cjs/components/Editor/Editor.js +14 -5
  49. package/lib/cjs/components/Feed/prefetchedData.d.ts +2 -368
  50. package/lib/cjs/components/Feed/prefetchedData.js +17 -16
  51. package/lib/cjs/components/FeedObject/Actions/Share/Share.js +2 -2
  52. package/lib/cjs/components/FeedObject/FeedObject.d.ts +2 -2
  53. package/lib/cjs/components/FeedObject/FeedObject.js +5 -5
  54. package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +38 -0
  55. package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +66 -0
  56. package/lib/cjs/components/FeedObjectMediaPreview/index.d.ts +3 -0
  57. package/lib/cjs/components/FeedObjectMediaPreview/index.js +5 -0
  58. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +25 -33
  59. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +34 -67
  60. package/lib/cjs/components/InlineComposerWidget/Skeleton.d.ts +4 -5
  61. package/lib/cjs/components/InlineComposerWidget/Skeleton.js +17 -37
  62. package/lib/cjs/components/InlineComposerWidget/constants.d.ts +1 -0
  63. package/lib/cjs/components/InlineComposerWidget/constants.js +4 -0
  64. package/lib/cjs/components/LocationAutocomplete/LocationAutocomplete.d.ts +2 -2
  65. package/lib/cjs/components/LocationAutocomplete/LocationAutocomplete.js +4 -2
  66. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +1 -1
  67. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +0 -5
  68. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +19 -30
  69. package/lib/cjs/components/NavigationToolbarMobile/Skeleton.js +5 -6
  70. package/lib/cjs/components/NavigationToolbarMobile/constants.d.ts +1 -0
  71. package/lib/cjs/components/NavigationToolbarMobile/constants.js +4 -0
  72. package/lib/cjs/constants/Composer.d.ts +2 -0
  73. package/lib/cjs/constants/Composer.js +4 -2
  74. package/lib/cjs/index.d.ts +12 -12
  75. package/lib/cjs/index.js +14 -17
  76. package/lib/cjs/shared/Lightbox/Lightbox.js +2 -2
  77. package/lib/{esm/shared/Media/Image/PreviewComponent.d.ts → cjs/shared/Media/File/DisplayComponent.d.ts} +1 -11
  78. package/lib/cjs/shared/Media/{Image/PreviewComponent.js → File/DisplayComponent.js} +55 -145
  79. package/lib/{esm/shared/Media/Image/PreviewImage → cjs/shared/Media/File/Lightbox}/index.d.ts +4 -3
  80. package/lib/cjs/shared/Media/File/Lightbox/index.js +37 -0
  81. package/lib/cjs/shared/Media/File/PreviewComponent.d.ts +9 -0
  82. package/lib/cjs/shared/Media/File/PreviewComponent.js +51 -0
  83. package/lib/cjs/shared/Media/File/TriggerButton.d.ts +12 -0
  84. package/lib/cjs/shared/Media/File/TriggerButton.js +112 -0
  85. package/lib/cjs/shared/Media/File/asUploadButton.d.ts +7 -0
  86. package/lib/cjs/shared/Media/File/asUploadButton.js +30 -0
  87. package/lib/cjs/shared/Media/File/constants.d.ts +1 -0
  88. package/lib/cjs/shared/Media/File/constants.js +4 -0
  89. package/lib/cjs/shared/Media/File/filter.d.ts +3 -0
  90. package/lib/cjs/shared/Media/File/filter.js +4 -0
  91. package/lib/cjs/shared/Media/File/index.d.ts +3 -0
  92. package/lib/cjs/shared/Media/File/index.js +16 -0
  93. package/lib/cjs/shared/Media/Link/DisplayComponent.d.ts +20 -0
  94. package/lib/cjs/shared/Media/Link/DisplayComponent.js +69 -0
  95. package/lib/cjs/shared/Media/Link/LayerComponent.d.ts +9 -0
  96. package/lib/cjs/shared/Media/Link/LayerComponent.js +46 -0
  97. package/lib/cjs/shared/Media/Link/PreviewComponent.d.ts +7 -21
  98. package/lib/cjs/shared/Media/Link/PreviewComponent.js +28 -56
  99. package/lib/cjs/shared/Media/Link/TriggerButton.d.ts +4 -0
  100. package/lib/cjs/shared/Media/Link/TriggerButton.js +21 -0
  101. package/lib/cjs/shared/Media/Link/UrlTextField/index.js +1 -2
  102. package/lib/cjs/shared/Media/Link/constants.d.ts +1 -0
  103. package/lib/cjs/shared/Media/Link/constants.js +4 -0
  104. package/lib/cjs/shared/Media/Link/filter.d.ts +3 -0
  105. package/lib/cjs/shared/Media/Link/filter.js +4 -0
  106. package/lib/cjs/shared/Media/Link/index.js +9 -8
  107. package/lib/cjs/shared/Media/Share/DisplayComponent.d.ts +11 -0
  108. package/lib/cjs/shared/Media/Share/DisplayComponent.js +31 -0
  109. package/lib/cjs/shared/Media/Share/constants.d.ts +1 -0
  110. package/lib/cjs/shared/Media/Share/constants.js +4 -0
  111. package/lib/cjs/shared/Media/Share/filter.d.ts +3 -0
  112. package/lib/cjs/shared/Media/Share/filter.js +4 -0
  113. package/lib/cjs/shared/Media/Share/index.js +7 -7
  114. package/lib/cjs/shared/Media/index.d.ts +2 -4
  115. package/lib/cjs/shared/Media/index.js +3 -7
  116. package/lib/cjs/types/composer.d.ts +15 -0
  117. package/lib/cjs/types/composer.js +2 -0
  118. package/lib/cjs/types/media.d.ts +9 -5
  119. package/lib/esm/components/BottomNavigation/BottomNavigation.js +8 -11
  120. package/lib/esm/components/Composer/Attributes/Attributes.d.ts +22 -0
  121. package/lib/esm/components/Composer/Attributes/Attributes.js +38 -0
  122. package/lib/esm/components/Composer/Attributes/index.d.ts +3 -0
  123. package/lib/esm/components/Composer/Attributes/index.js +2 -0
  124. package/lib/esm/components/Composer/Composer.d.ts +61 -84
  125. package/lib/esm/components/Composer/Composer.js +262 -437
  126. package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.d.ts +32 -0
  127. package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +50 -0
  128. package/lib/esm/components/Composer/Content/ContentDiscussion/index.d.ts +3 -0
  129. package/lib/esm/components/Composer/Content/ContentDiscussion/index.js +2 -0
  130. package/lib/esm/components/Composer/Content/ContentPoll/ContentPoll.d.ts +26 -0
  131. package/lib/esm/components/Composer/Content/ContentPoll/ContentPoll.js +127 -0
  132. package/lib/esm/components/Composer/Content/ContentPoll/index.d.ts +3 -0
  133. package/lib/esm/components/Composer/Content/ContentPoll/index.js +2 -0
  134. package/lib/esm/components/Composer/Content/ContentPost/ContentPost.d.ts +32 -0
  135. package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +49 -0
  136. package/lib/esm/components/Composer/Content/ContentPost/index.d.ts +3 -0
  137. package/lib/esm/components/Composer/Content/ContentPost/index.js +2 -0
  138. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +11 -0
  139. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +72 -0
  140. package/lib/esm/components/Composer/Layer/AudienceLayer/index.d.ts +3 -0
  141. package/lib/esm/components/Composer/Layer/AudienceLayer/index.js +2 -0
  142. package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +9 -0
  143. package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.js +39 -0
  144. package/lib/esm/components/Composer/Layer/CategoryLayer/index.d.ts +3 -0
  145. package/lib/esm/components/Composer/Layer/CategoryLayer/index.js +2 -0
  146. package/lib/esm/components/Composer/Layer/CloseLayer/CloseLayer.d.ts +7 -0
  147. package/lib/esm/components/Composer/Layer/CloseLayer/CloseLayer.js +39 -0
  148. package/lib/esm/components/Composer/Layer/CloseLayer/index.d.ts +3 -0
  149. package/lib/esm/components/Composer/Layer/CloseLayer/index.js +2 -0
  150. package/lib/esm/components/Composer/Layer/LocationLayer/LocationLayer.d.ts +9 -0
  151. package/lib/esm/components/Composer/Layer/LocationLayer/LocationLayer.js +39 -0
  152. package/lib/esm/components/Composer/Layer/LocationLayer/index.d.ts +3 -0
  153. package/lib/esm/components/Composer/Layer/LocationLayer/index.js +2 -0
  154. package/lib/esm/components/Composer/Skeleton.d.ts +0 -4
  155. package/lib/esm/components/Composer/Skeleton.js +6 -68
  156. package/lib/esm/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.d.ts +6 -0
  157. package/lib/esm/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.js +44 -0
  158. package/lib/esm/components/Composer/TypeSwitchButtonGroup/index.d.ts +3 -0
  159. package/lib/esm/components/Composer/TypeSwitchButtonGroup/index.js +2 -0
  160. package/lib/esm/components/Composer/constants.d.ts +1 -0
  161. package/lib/esm/components/Composer/constants.js +1 -0
  162. package/lib/esm/components/Composer/index.d.ts +2 -3
  163. package/lib/esm/components/Composer/index.js +1 -3
  164. package/lib/esm/components/ComposerIconButton/ComposerIconButton.d.ts +2 -1
  165. package/lib/esm/components/ComposerIconButton/ComposerIconButton.js +8 -8
  166. package/lib/esm/components/Editor/Editor.js +16 -7
  167. package/lib/esm/components/Feed/Feed.js +4 -4
  168. package/lib/esm/components/Feed/prefetchedData.d.ts +2 -368
  169. package/lib/esm/components/Feed/prefetchedData.js +17 -16
  170. package/lib/esm/components/FeedObject/Actions/Share/Share.js +4 -4
  171. package/lib/esm/components/FeedObject/FeedObject.d.ts +2 -2
  172. package/lib/esm/components/FeedObject/FeedObject.js +8 -8
  173. package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +38 -0
  174. package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +64 -0
  175. package/lib/esm/components/FeedObjectMediaPreview/index.d.ts +3 -0
  176. package/lib/esm/components/FeedObjectMediaPreview/index.js +2 -0
  177. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +25 -33
  178. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +31 -64
  179. package/lib/esm/components/InlineComposerWidget/Skeleton.d.ts +4 -5
  180. package/lib/esm/components/InlineComposerWidget/Skeleton.js +15 -35
  181. package/lib/esm/components/InlineComposerWidget/constants.d.ts +1 -0
  182. package/lib/esm/components/InlineComposerWidget/constants.js +1 -0
  183. package/lib/esm/components/LocationAutocomplete/LocationAutocomplete.d.ts +2 -2
  184. package/lib/esm/components/LocationAutocomplete/LocationAutocomplete.js +4 -2
  185. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +1 -1
  186. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  187. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +0 -5
  188. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +12 -23
  189. package/lib/esm/components/NavigationToolbarMobile/Skeleton.js +3 -4
  190. package/lib/esm/components/NavigationToolbarMobile/constants.d.ts +1 -0
  191. package/lib/esm/components/NavigationToolbarMobile/constants.js +1 -0
  192. package/lib/esm/constants/Composer.d.ts +2 -0
  193. package/lib/esm/constants/Composer.js +3 -1
  194. package/lib/esm/index.d.ts +12 -12
  195. package/lib/esm/index.js +33 -33
  196. package/lib/esm/shared/Lightbox/Lightbox.js +2 -2
  197. package/lib/{cjs/shared/Media/Image/PreviewComponent.d.ts → esm/shared/Media/File/DisplayComponent.d.ts} +1 -11
  198. package/lib/esm/shared/Media/{Image/PreviewComponent.js → File/DisplayComponent.js} +50 -140
  199. package/lib/{cjs/shared/Media/Image/PreviewImage → esm/shared/Media/File/Lightbox}/index.d.ts +4 -3
  200. package/lib/esm/shared/Media/File/Lightbox/index.js +34 -0
  201. package/lib/esm/shared/Media/File/PreviewComponent.d.ts +9 -0
  202. package/lib/esm/shared/Media/File/PreviewComponent.js +49 -0
  203. package/lib/esm/shared/Media/File/TriggerButton.d.ts +12 -0
  204. package/lib/esm/shared/Media/File/TriggerButton.js +110 -0
  205. package/lib/esm/shared/Media/File/asUploadButton.d.ts +7 -0
  206. package/lib/esm/shared/Media/File/asUploadButton.js +28 -0
  207. package/lib/esm/shared/Media/File/constants.d.ts +1 -0
  208. package/lib/esm/shared/Media/File/constants.js +1 -0
  209. package/lib/esm/shared/Media/File/filter.d.ts +3 -0
  210. package/lib/esm/shared/Media/File/filter.js +2 -0
  211. package/lib/esm/shared/Media/File/index.d.ts +3 -0
  212. package/lib/esm/shared/Media/File/index.js +13 -0
  213. package/lib/esm/shared/Media/Link/DisplayComponent.d.ts +20 -0
  214. package/lib/esm/shared/Media/Link/DisplayComponent.js +67 -0
  215. package/lib/esm/shared/Media/Link/LayerComponent.d.ts +9 -0
  216. package/lib/esm/shared/Media/Link/LayerComponent.js +44 -0
  217. package/lib/esm/shared/Media/Link/PreviewComponent.d.ts +7 -21
  218. package/lib/esm/shared/Media/Link/PreviewComponent.js +27 -54
  219. package/lib/esm/shared/Media/Link/TriggerButton.d.ts +4 -0
  220. package/lib/esm/shared/Media/Link/TriggerButton.js +19 -0
  221. package/lib/esm/shared/Media/Link/UrlTextField/index.js +2 -3
  222. package/lib/esm/shared/Media/Link/constants.d.ts +1 -0
  223. package/lib/esm/shared/Media/Link/constants.js +1 -0
  224. package/lib/esm/shared/Media/Link/filter.d.ts +3 -0
  225. package/lib/esm/shared/Media/Link/filter.js +2 -0
  226. package/lib/esm/shared/Media/Link/index.js +9 -8
  227. package/lib/esm/shared/Media/Share/DisplayComponent.d.ts +11 -0
  228. package/lib/esm/shared/Media/Share/DisplayComponent.js +29 -0
  229. package/lib/esm/shared/Media/Share/constants.d.ts +1 -0
  230. package/lib/esm/shared/Media/Share/constants.js +1 -0
  231. package/lib/esm/shared/Media/Share/filter.d.ts +3 -0
  232. package/lib/esm/shared/Media/Share/filter.js +2 -0
  233. package/lib/esm/shared/Media/Share/index.js +7 -7
  234. package/lib/esm/shared/Media/index.d.ts +2 -4
  235. package/lib/esm/shared/Media/index.js +2 -4
  236. package/lib/esm/types/composer.d.ts +15 -0
  237. package/lib/esm/types/composer.js +1 -0
  238. package/lib/esm/types/media.d.ts +9 -5
  239. package/lib/umd/react-ui.js +1 -1
  240. package/package.json +7 -7
  241. package/lib/cjs/components/Composer/Audience/Audience.d.ts +0 -71
  242. package/lib/cjs/components/Composer/Audience/Audience.js +0 -69
  243. package/lib/cjs/components/Composer/Audience/index.d.ts +0 -3
  244. package/lib/cjs/components/Composer/Poll/Poll.d.ts +0 -31
  245. package/lib/cjs/components/Composer/Poll/Poll.js +0 -151
  246. package/lib/cjs/components/Composer/Poll/index.d.ts +0 -3
  247. package/lib/cjs/shared/Media/Document/EditButton.d.ts +0 -2
  248. package/lib/cjs/shared/Media/Document/EditButton.js +0 -10
  249. package/lib/cjs/shared/Media/Document/EditComponent.d.ts +0 -3
  250. package/lib/cjs/shared/Media/Document/EditComponent.js +0 -103
  251. package/lib/cjs/shared/Media/Document/PreviewComponent.d.ts +0 -3
  252. package/lib/cjs/shared/Media/Document/PreviewComponent.js +0 -43
  253. package/lib/cjs/shared/Media/Document/index.d.ts +0 -3
  254. package/lib/cjs/shared/Media/Document/index.js +0 -16
  255. package/lib/cjs/shared/Media/Image/EditButton.d.ts +0 -2
  256. package/lib/cjs/shared/Media/Image/EditButton.js +0 -10
  257. package/lib/cjs/shared/Media/Image/EditComponent.d.ts +0 -3
  258. package/lib/cjs/shared/Media/Image/EditComponent.js +0 -102
  259. package/lib/cjs/shared/Media/Image/PreviewImage/index.js +0 -41
  260. package/lib/cjs/shared/Media/Image/index.d.ts +0 -3
  261. package/lib/cjs/shared/Media/Image/index.js +0 -16
  262. package/lib/cjs/shared/Media/Link/EditButton.d.ts +0 -2
  263. package/lib/cjs/shared/Media/Link/EditButton.js +0 -10
  264. package/lib/cjs/shared/Media/Link/EditComponent.d.ts +0 -3
  265. package/lib/cjs/shared/Media/Link/EditComponent.js +0 -46
  266. package/lib/cjs/shared/Media/Share/PreviewComponent.d.ts +0 -7
  267. package/lib/cjs/shared/Media/Share/PreviewComponent.js +0 -32
  268. package/lib/cjs/shared/Media/Video/EditButton.d.ts +0 -2
  269. package/lib/cjs/shared/Media/Video/EditButton.js +0 -10
  270. package/lib/cjs/shared/Media/Video/EditComponent.d.ts +0 -3
  271. package/lib/cjs/shared/Media/Video/EditComponent.js +0 -89
  272. package/lib/cjs/shared/Media/Video/PreviewComponent.d.ts +0 -19
  273. package/lib/cjs/shared/Media/Video/PreviewComponent.js +0 -37
  274. package/lib/cjs/shared/Media/Video/index.d.ts +0 -3
  275. package/lib/cjs/shared/Media/Video/index.js +0 -16
  276. package/lib/cjs/shared/MediasPreview/index.d.ts +0 -18
  277. package/lib/cjs/shared/MediasPreview/index.js +0 -44
  278. package/lib/esm/components/Composer/Audience/Audience.d.ts +0 -71
  279. package/lib/esm/components/Composer/Audience/Audience.js +0 -66
  280. package/lib/esm/components/Composer/Audience/index.d.ts +0 -3
  281. package/lib/esm/components/Composer/Audience/index.js +0 -2
  282. package/lib/esm/components/Composer/Poll/Poll.d.ts +0 -31
  283. package/lib/esm/components/Composer/Poll/Poll.js +0 -149
  284. package/lib/esm/components/Composer/Poll/index.d.ts +0 -3
  285. package/lib/esm/components/Composer/Poll/index.js +0 -2
  286. package/lib/esm/shared/Media/Document/EditButton.d.ts +0 -2
  287. package/lib/esm/shared/Media/Document/EditButton.js +0 -7
  288. package/lib/esm/shared/Media/Document/EditComponent.d.ts +0 -3
  289. package/lib/esm/shared/Media/Document/EditComponent.js +0 -101
  290. package/lib/esm/shared/Media/Document/PreviewComponent.d.ts +0 -3
  291. package/lib/esm/shared/Media/Document/PreviewComponent.js +0 -41
  292. package/lib/esm/shared/Media/Document/index.d.ts +0 -3
  293. package/lib/esm/shared/Media/Document/index.js +0 -13
  294. package/lib/esm/shared/Media/Image/EditButton.d.ts +0 -2
  295. package/lib/esm/shared/Media/Image/EditButton.js +0 -7
  296. package/lib/esm/shared/Media/Image/EditComponent.d.ts +0 -3
  297. package/lib/esm/shared/Media/Image/EditComponent.js +0 -100
  298. package/lib/esm/shared/Media/Image/PreviewImage/index.js +0 -38
  299. package/lib/esm/shared/Media/Image/index.d.ts +0 -3
  300. package/lib/esm/shared/Media/Image/index.js +0 -13
  301. package/lib/esm/shared/Media/Link/EditButton.d.ts +0 -2
  302. package/lib/esm/shared/Media/Link/EditButton.js +0 -7
  303. package/lib/esm/shared/Media/Link/EditComponent.d.ts +0 -3
  304. package/lib/esm/shared/Media/Link/EditComponent.js +0 -43
  305. package/lib/esm/shared/Media/Share/PreviewComponent.d.ts +0 -7
  306. package/lib/esm/shared/Media/Share/PreviewComponent.js +0 -29
  307. package/lib/esm/shared/Media/Video/EditButton.d.ts +0 -2
  308. package/lib/esm/shared/Media/Video/EditButton.js +0 -7
  309. package/lib/esm/shared/Media/Video/EditComponent.d.ts +0 -3
  310. package/lib/esm/shared/Media/Video/EditComponent.js +0 -87
  311. package/lib/esm/shared/Media/Video/PreviewComponent.d.ts +0 -19
  312. package/lib/esm/shared/Media/Video/PreviewComponent.js +0 -34
  313. package/lib/esm/shared/Media/Video/index.d.ts +0 -3
  314. package/lib/esm/shared/Media/Video/index.js +0 -13
  315. package/lib/esm/shared/MediasPreview/index.d.ts +0 -18
  316. package/lib/esm/shared/MediasPreview/index.js +0 -42
@@ -1,109 +1,66 @@
1
1
  import { __rest } from "tslib";
2
- import React, { forwardRef, useEffect, useMemo, useReducer, useRef, useState } from 'react';
3
- import { SCFeatureName } from '@selfcommunity/types';
2
+ import React, { forwardRef, useCallback, useEffect, useMemo, useReducer, useRef, useState, } from 'react';
3
+ import { SCContributionType, SCFeatureName, } from '@selfcommunity/types';
4
4
  import { Endpoints, formatHttpErrorCode, http } from '@selfcommunity/api-services';
5
- import { SCPreferences, UserUtils, useSCFetchAddressingTagList, useSCPreferences, useSCUser, } from '@selfcommunity/react-core';
5
+ import { SCPreferences, UserUtils, useSCPreferences, useSCUser, } from '@selfcommunity/react-core';
6
6
  import { FormattedMessage } from 'react-intl';
7
7
  import Icon from '@mui/material/Icon';
8
- import { Alert, AlertTitle, Avatar, Badge, Box, Chip, Dialog, DialogActions, DialogContent, DialogTitle, Fade, FormControl, IconButton, InputBase, MenuItem, Select, Stack, Tab, Tabs, TextField, Tooltip, Typography, useMediaQuery } from '@mui/material';
8
+ import { Alert, AlertTitle, Box, Dialog, DialogActions, DialogContent, DialogTitle, Fade, IconButton, Slide, useMediaQuery, } from '@mui/material';
9
9
  import { styled, useTheme } from '@mui/material/styles';
10
- import { COMPOSER_POLL_MIN_CHOICES, COMPOSER_TITLE_MAX_LENGTH, COMPOSER_TYPE_DISCUSSION, COMPOSER_TYPE_POST } from '../../constants/Composer';
10
+ import { COMPOSER_POLL_MIN_CHOICES, COMPOSER_TITLE_MAX_LENGTH, COMPOSER_TYPE_POLL } from '../../constants/Composer';
11
11
  import { MEDIA_TYPE_SHARE } from '../../constants/Media';
12
12
  import LoadingButton from '@mui/lab/LoadingButton';
13
- import Audience from './Audience';
14
- import CategoryAutocomplete from '../CategoryAutocomplete';
15
- import { iOS, isObject, random, stripHtml } from '@selfcommunity/utils';
13
+ import AudienceLayer from './Layer/AudienceLayer';
14
+ import { iOS, random, stripHtml } from '@selfcommunity/utils';
16
15
  import classNames from 'classnames';
17
- import PollPreview from '../FeedObject/Poll';
18
- import Editor from '../Editor';
19
- import { Document, Image, Link, Share } from '../../shared/Media';
20
- import MediasPreview from '../../shared/MediasPreview';
21
- import Poll from './Poll';
22
- import LocationAutocomplete from '../LocationAutocomplete';
23
- import TagChip from '../../shared/TagChip';
24
- import { ComposerSkeleton } from './index';
16
+ import ContentPoll from './Content/ContentPoll';
25
17
  import { useSnackbar } from 'notistack';
26
18
  import { useThemeProps } from '@mui/system';
27
19
  import { extractHashtags } from '../../utils/editor';
20
+ import TypeSwitchButtonGroup from './TypeSwitchButtonGroup';
21
+ import ContentPost from './Content/ContentPost';
22
+ import CategoryLayer from './Layer/CategoryLayer';
23
+ import LocationLayer from './Layer/LocationLayer';
24
+ import ContentDiscussion from './Content/ContentDiscussion';
25
+ import { File, Link, Share } from '../../shared/Media';
26
+ import Attributes from './Attributes';
27
+ import { PREFIX } from './constants';
28
+ import ComposerSkeleton from './Skeleton';
29
+ import CloseLayer from './Layer/CloseLayer';
28
30
  const DialogTransition = forwardRef(function Transition(props, ref) {
29
31
  return React.createElement(Fade, Object.assign({ ref: ref }, props));
30
32
  });
31
- const TypeInput = styled(InputBase, {
32
- slot: 'Root',
33
- overridesResolver: (props, styles) => styles.root
34
- })(({ theme }) => ({
35
- '&.Mui-InputBase-root': {
36
- 'label + &': {
37
- marginTop: theme.spacing(3)
38
- }
39
- },
40
- '& .Mui-InputBase-input': {
41
- position: 'relative',
42
- backgroundColor: theme.palette.background.paper,
43
- border: 0,
44
- padding: '10px 26px 10px 12px'
45
- }
46
- }));
47
- const PREFIX = 'SCComposer';
48
33
  const classes = {
49
34
  root: `${PREFIX}-root`,
50
35
  ios: `${PREFIX}-ios`,
51
- writing: `${PREFIX}-writing`,
52
36
  title: `${PREFIX}-title`,
53
- titleDense: `${PREFIX}-title-dense`,
54
37
  types: `${PREFIX}-types`,
55
- avatar: `${PREFIX}-avatar`,
56
38
  content: `${PREFIX}-content`,
57
- mediaContent: `${PREFIX}-mediaContent`,
58
- audienceContent: `${PREFIX}-audienceContent`,
59
- locationContent: `${PREFIX}-locationContent`,
60
- block: `${PREFIX}-block`,
61
- editor: `${PREFIX}-editor`,
62
- divider: `${PREFIX}-divider`,
39
+ attributes: `${PREFIX}-attributes`,
63
40
  medias: `${PREFIX}-medias`,
64
- location: `${PREFIX}-location`,
65
- audience: `${PREFIX}-audience`,
66
- mediasActions: `${PREFIX}-mediasActions`,
67
- mediasActionsTitle: `${PREFIX}-mediasActionsTitle`,
68
- mediasActionsActions: `${PREFIX}-mediasActionsActions`,
69
- sortableMedia: `${PREFIX}-sortableMedia`,
70
- sortableMediaCover: `${PREFIX}-sortableMediaCover`,
71
- links: `${PREFIX}-links`,
72
41
  actions: `${PREFIX}-actions`,
73
- mediaActions: `${PREFIX}-media-actions`,
74
- filterActions: `${PREFIX}-filter-actions`,
75
- actionInput: `${PREFIX}-actionInput`,
76
- badgeError: `${PREFIX}-badgeError`
42
+ layerTransitionRoot: `${PREFIX}-layer-transition-root`
77
43
  };
78
44
  const Root = styled(Dialog, {
79
45
  name: PREFIX,
80
46
  slot: 'Root',
81
47
  overridesResolver: (props, styles) => styles.root
82
48
  })(() => ({}));
83
- export const MAIN_VIEW = 'main';
84
- export const AUDIENCE_VIEW = 'audience';
85
- export const POLL_VIEW = 'poll';
86
- export const LOCATION_VIEW = 'location';
87
- const AUDIENCE_ALL = 'all';
88
- const AUDIENCE_TAG = 'tag';
89
- const PREFERENCES = [
90
- SCPreferences.CONFIGURATIONS_POST_TYPE_ENABLED,
91
- SCPreferences.CONFIGURATIONS_DISCUSSION_TYPE_ENABLED,
92
- SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED,
93
- SCPreferences.ADDONS_POLLS_ENABLED,
94
- SCPreferences.ADDONS_VIDEO_UPLOAD_ENABLED
95
- ];
49
+ const LayerTransitionRoot = styled(Slide, {
50
+ name: PREFIX,
51
+ slot: 'LayerTransitionRoot',
52
+ overridesResolver: (props, styles) => styles.layerTransitionRoot
53
+ })(({ theme }) => ({}));
96
54
  const COMPOSER_INITIAL_STATE = {
97
55
  id: null,
98
56
  type: null,
99
57
  title: '',
100
58
  titleError: null,
101
- text: '',
102
- textError: null,
59
+ html: '',
60
+ htmlError: null,
103
61
  categories: [],
104
62
  categoriesError: null,
105
- audience: AUDIENCE_ALL,
106
- addressing: [],
63
+ addressing: null,
107
64
  addressingError: null,
108
65
  medias: [],
109
66
  poll: null,
@@ -125,6 +82,14 @@ const reducer = (state, action) => {
125
82
  *
126
83
  *
127
84
  * The Composer component contains the logic around the creation of [Post](https://developers.selfcommunity.com/docs/apireference/v2/post/create_a_post) and [Discussion](https://developers.selfcommunity.com/docs/apireference/v2/discussion/create_a_discussion) objects.
85
+ *
86
+ *
87
+ :::info
88
+ To prevent the editor toolbar and action botton bar being hidden underneath the Virtual Keyboard you need to set the `interactive-widget=resizes-content` on meta viewport.
89
+ This works on chrome for android.
90
+ For iOS devices there is a lack of support of this meta so we force the blur event when the user start dragging.
91
+ [More information](https://bram.us/2021/09/13/prevent-items-from-being-hidden-underneath-the-virtual-keyboard-by-means-of-the-virtualkeyboard-api/)
92
+ :::
128
93
 
129
94
  #### Import
130
95
  ```jsx
@@ -138,30 +103,14 @@ const reducer = (state, action) => {
138
103
  |Rule Name|Global class|Description|
139
104
  |---|---|---|
140
105
  |root|.SCComposer-root|Styles applied to the root element.|
141
- |writing|.SCComposer-writing|Styles applied to the root element when user is writing in the editor.|
106
+ |ios|.SCComposer-ios|Styles applied to the root element when the device is ios.|
142
107
  |title|.SCComposer-title|Styles applied to the title element.|
143
- |titleDense|.SCComposer-title-dense|Styles applied to the dense title element.|
144
108
  |types|.SCComposer-types|Styles applied to the types element.|
145
- |avatar|.SCComposer-avatar|Styles applied to the avatar element.|
146
109
  |content|.SCComposer-content|Styles applied to the content.|
147
- |mediaContent|.SCComposer-mediaContent|Styles applied to the media content.|
148
- |audienceContent|.SCComposer-audienceContent|Styles applied to the audience content.|
149
- |locationContent|.SCComposer-locationContent|Styles applied to the location content.|
150
- |block|.SCComposer-block|Styles applied to the block element.|
151
- |editor|.SCComposer-editor|Styles applied to the editor element.|
152
- |divider|.SCComposer-divider|Styles applied to the divider element.|
110
+ |attributes|.SCComposer-attributes|Styles applied to the attributes.|
153
111
  |medias|.SCComposer-medias|Styles applied to the medias.|
154
- |location|.SCComposer-location|Styles applied to the location element.|
155
- |audience|.SCComposer-audience|Styles applied to the audience element.|
156
- |mediasActions|.SCComposer-mediasActions|Styles applied to the medias actions section.|
157
- |sortableMedia|.SCComposer-sortableMedia|Styles applied to the sortable media element.|
158
- |sortableMediaCover|.SCComposer-sortableMediaCover|Styles applied to the sortable media cover element.|
159
- |links|.SCComposer-links|Styles applied to the links element.|
160
112
  |actions|.SCComposer-actions|Styles applied to the actions section.|
161
- |mediaActions|.SCComposer-media-actions|Styles applied to the media actions section.|
162
- |filterActions|.SCComposer-filter-actions|Styles applied to the filter actions section.|
163
- |actionInput|.SCComposer-actionInput|Styles applied to the action input element.|
164
- |badgeError|.SCComposer-badgeError|Styles applied to the badge error element.|
113
+ |layerTransitionRoot|.SCComposer-layer-transition-root|Styles applied to the overlay layers (eg. location).|
165
114
 
166
115
 
167
116
  * @param inProps
@@ -172,31 +121,24 @@ export default function Composer(inProps) {
172
121
  props: inProps,
173
122
  name: PREFIX
174
123
  });
175
- const { feedObjectId = null, feedObjectType = null, feedObject = null, defaultValue = {}, view = MAIN_VIEW, mediaObjectTypes = [Image, Document, Link, Share], EditorProps = null, onClose = null, onSuccess = null, maxWidth } = props, rest = __rest(props, ["feedObjectId", "feedObjectType", "feedObject", "defaultValue", "view", "mediaObjectTypes", "EditorProps", "onClose", "onSuccess", "maxWidth"]);
124
+ const { feedObjectId = null, feedObjectType = null, feedObject = null, defaultValue = {}, mediaObjectTypes = [File, Link, Share], EditorProps = {}, onClose = null, onSuccess = null, maxWidth } = props, rest = __rest(props, ["feedObjectId", "feedObjectType", "feedObject", "defaultValue", "mediaObjectTypes", "EditorProps", "onClose", "onSuccess", "maxWidth"]);
176
125
  // Context
177
- const scPrefernces = useSCPreferences();
126
+ const { preferences, features } = useSCPreferences();
178
127
  const scUserContext = useSCUser();
179
128
  const { enqueueSnackbar } = useSnackbar();
180
129
  // HOOKS
181
- const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: rest.open });
182
130
  const theme = useTheme();
183
131
  const fullScreen = useMediaQuery(theme.breakpoints.down('md'), { noSsr: typeof window !== 'undefined' });
184
132
  // State variables
185
133
  const [isSubmitting, setIsSubmitting] = useState(false);
186
- const [_view, setView] = useState(view);
187
- const [composerTypes, setComposerTypes] = useState([]);
188
- const [mediaChunks, setMediaChunks] = useState([]);
189
- const [editorFocused, setEditorFocused] = useState(false);
190
- const [state, dispatch] = useReducer(reducer, Object.assign(Object.assign(Object.assign({}, COMPOSER_INITIAL_STATE), defaultValue), { view, key: random() }));
191
- const { key, id, type, title, titleError, text, categories, addressing, audience, medias, poll, pollError, location, error } = state;
192
- const addMedia = (media) => {
193
- dispatch({ type: 'medias', value: [...medias, media] });
194
- };
134
+ const [layer, setLayer] = useState();
135
+ const [state, dispatch] = useReducer(reducer, Object.assign(Object.assign(Object.assign({}, COMPOSER_INITIAL_STATE), defaultValue), { key: random() }));
136
+ const { key, id, type, title, titleError, html, categories, addressing, audience, medias, poll, pollError, location, error } = state;
195
137
  const destructureFeedObject = (_feedObject) => {
196
- if (_feedObject.type === COMPOSER_TYPE_POST) {
138
+ if (_feedObject.type === SCContributionType.POST) {
197
139
  _feedObject = _feedObject;
198
140
  }
199
- else if (_feedObject.type === COMPOSER_TYPE_DISCUSSION) {
141
+ else if (_feedObject.type === SCContributionType.DISCUSSION) {
200
142
  _feedObject = _feedObject;
201
143
  }
202
144
  else {
@@ -207,11 +149,10 @@ export default function Composer(inProps) {
207
149
  type: 'multiple',
208
150
  value: {
209
151
  id: _feedObject.id,
210
- type: _feedObject.type,
152
+ type: _feedObject.poll ? COMPOSER_TYPE_POLL : feedObject.type,
211
153
  title: _feedObject.title,
212
- text: _feedObject.html,
154
+ html: _feedObject.html,
213
155
  categories: _feedObject.categories,
214
- audience: _feedObject.addressing ? AUDIENCE_TAG : AUDIENCE_ALL,
215
156
  addressing: _feedObject.addressing,
216
157
  medias: _feedObject.medias,
217
158
  poll: _feedObject.poll,
@@ -225,43 +166,25 @@ export default function Composer(inProps) {
225
166
  }
226
167
  };
227
168
  // Edit state variables
228
- const editMode = Boolean((feedObjectId && feedObjectType) || feedObject);
169
+ const editMode = useMemo(() => Boolean((feedObjectId && feedObjectType) || feedObject), [feedObjectId, feedObjectType, feedObject]);
229
170
  const [isLoading, setIsLoading] = useState(editMode);
230
171
  const [loadError, setLoadError] = useState(false);
231
172
  // REFS
173
+ const dialogRef = useRef();
232
174
  const unloadRef = useRef(false);
233
- let titleRef = useRef();
234
- let editorRef = useRef();
235
- // Create a ref for medias becaouse of state update error on chunk upload
236
- const mediasRef = useRef({ medias, mediaChunks, addMedia, setMediaChunks });
237
- mediasRef.current = { medias, mediaChunks, addMedia, setMediaChunks };
238
- /*
239
- * Compute preferences
240
- */
241
- const preferences = useMemo(() => {
242
- const _preferences = {};
243
- PREFERENCES.map((p) => (_preferences[p] = p in scPrefernces.preferences ? scPrefernces.preferences[p].value : null));
244
- return _preferences;
245
- }, [scPrefernces.preferences]);
246
- /*
247
- * Compose the enabled types of posts that can be created based on preferences
248
- */
249
- const setEnabledComposerTypes = () => {
250
- const types = [];
251
- if (preferences[SCPreferences.CONFIGURATIONS_POST_TYPE_ENABLED]) {
252
- types.push(COMPOSER_TYPE_POST);
253
- }
254
- if (preferences[SCPreferences.CONFIGURATIONS_DISCUSSION_TYPE_ENABLED]) {
255
- types.push(COMPOSER_TYPE_DISCUSSION);
256
- }
257
- if (!type) {
258
- dispatch({ type: 'type', value: preferences[SCPreferences.CONFIGURATIONS_POST_TYPE_ENABLED] ? COMPOSER_TYPE_POST : COMPOSER_TYPE_DISCUSSION });
259
- }
260
- if (JSON.stringify(composerTypes) !== JSON.stringify(types)) {
261
- setComposerTypes(types);
262
- }
263
- };
264
- setEnabledComposerTypes();
175
+ // Create a ref for medias because of state update error on chunk upload
176
+ const mediasRef = useRef({ medias });
177
+ mediasRef.current = { medias };
178
+ // MEMO
179
+ const hasPoll = useMemo(() => {
180
+ return poll && poll.title.length > 0 && poll.title.length < COMPOSER_TITLE_MAX_LENGTH && poll.choices.length >= COMPOSER_POLL_MIN_CHOICES;
181
+ }, [poll]);
182
+ const canSubmit = useMemo(() => {
183
+ return !isLoading && ((type === SCContributionType.DISCUSSION && title.length > 0 && title.length < COMPOSER_TITLE_MAX_LENGTH) ||
184
+ (type === SCContributionType.POST && (stripHtml(html).length > 0 || medias.length > 0 || hasPoll)) ||
185
+ (type === COMPOSER_TYPE_POLL && hasPoll));
186
+ }, [isLoading, type, title, html, medias, hasPoll]);
187
+ const isIOS = useMemo(() => iOS(), []);
265
188
  // Load feed object
266
189
  useEffect(() => {
267
190
  if (!editMode) {
@@ -285,11 +208,9 @@ export default function Composer(inProps) {
285
208
  })
286
209
  .then(() => setIsLoading(false));
287
210
  }, [editMode]);
288
- // Props update
289
- useEffect(() => setView(view), [view]);
290
211
  // Prevent unload
291
212
  useEffect(() => {
292
- if (!unloadRef.current && canSubmit()) {
213
+ if (!unloadRef.current && canSubmit) {
293
214
  unloadRef.current = true;
294
215
  const onUnload = (event) => {
295
216
  event.preventDefault();
@@ -297,129 +218,135 @@ export default function Composer(inProps) {
297
218
  };
298
219
  window.onbeforeunload = onUnload;
299
220
  }
300
- else if (unloadRef.current && !canSubmit()) {
221
+ else if (unloadRef.current && !canSubmit) {
301
222
  unloadRef.current = false;
302
223
  window.onbeforeunload = null;
303
224
  }
304
- }, [state]);
305
- // Autofocus
225
+ }, [state, canSubmit]);
306
226
  useEffect(() => {
307
- if (!rest.open || fullScreen) {
227
+ if (!dialogRef.current || !isIOS) {
308
228
  return;
309
229
  }
310
- if (type === COMPOSER_TYPE_DISCUSSION) {
311
- titleRef.current && titleRef.current.focus();
312
- }
313
- else {
314
- editorRef.current && editorRef.current.focus();
315
- }
316
- }, [fullScreen, rest.open, type, editorRef]);
317
- // CHECKS
318
- const hasPoll = () => {
319
- return poll && poll.title.length > 0 && poll.title.length < COMPOSER_TITLE_MAX_LENGTH && poll.choices.length >= COMPOSER_POLL_MIN_CHOICES;
320
- };
321
- const canSubmit = () => {
322
- return ((type === COMPOSER_TYPE_DISCUSSION && title.length > 0 && title.length < COMPOSER_TITLE_MAX_LENGTH) ||
323
- (type === COMPOSER_TYPE_POST && (stripHtml(text).length > 0 || medias.length > 0 || hasPoll())));
324
- };
325
- /* Handlers */
326
- const handleChangeView = (view) => {
327
- return (event) => {
328
- setView(view);
230
+ const handleBlur = () => {
231
+ dialogRef.current.focus();
329
232
  };
330
- };
331
- const handleChangeType = (event, child) => {
332
- const target = event.target;
333
- dispatch({ type: 'type', value: target.value });
334
- };
335
- const handleChangeText = (value) => {
336
- dispatch({ type: 'text', value });
337
- };
338
- const handleChangePoll = (poll) => {
233
+ dialogRef.current.addEventListener("touchstart", handleBlur);
234
+ return () => { var _a; return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("touchstart", handleBlur); };
235
+ }, [dialogRef.current, isIOS]);
236
+ /* Handlers */
237
+ const handleAddLayer = useCallback((layer) => setLayer(layer), []);
238
+ const handleRemoveLayer = useCallback(() => setLayer(null), []);
239
+ const handleChangeType = useCallback((value) => {
240
+ dispatch({ type: 'type', value });
241
+ }, []);
242
+ const handleChangePoll = useCallback((content) => {
339
243
  dispatch({
340
244
  type: 'multiple',
341
- value: {
342
- poll: poll,
343
- pollError: poll.title.length > COMPOSER_TITLE_MAX_LENGTH
245
+ value: Object.assign(Object.assign({}, content), { pollError: content.poll.title.length > COMPOSER_TITLE_MAX_LENGTH
344
246
  ? { titleError: React.createElement(FormattedMessage, { id: "ui.composer.title.error.maxlength", defaultMessage: "ui.composer.title.error.maxlength" }) }
345
- : null
346
- }
247
+ : null })
347
248
  });
348
- };
349
- const handleChange = (prop) => (event, data) => {
350
- let target = null;
351
- switch (prop) {
352
- case 'title':
353
- target = event.target;
354
- dispatch({
355
- type: 'multiple',
356
- value: {
357
- title: target.value,
358
- titleError: target.value.length > COMPOSER_TITLE_MAX_LENGTH ? (React.createElement(FormattedMessage, { id: "ui.composer.title.error.maxlength", defaultMessage: "ui.composer.title.error.maxlength" })) : null
359
- }
360
- });
361
- break;
362
- case 'categories':
363
- case 'addressing':
364
- dispatch({ type: prop, value: event });
365
- break;
366
- case 'location':
367
- const value = event && isObject(event)
368
- ? event['location']
369
- ? { location: event['location'], lat: event['lat'], lng: event['lng'] }
370
- : { location: event['full_address'], lat: event['lat'], lng: event['lng'] }
371
- : null;
372
- dispatch({ type: prop, value });
373
- break;
374
- case 'audience':
375
- data !== null && dispatch({ type: 'multiple', value: { audience: data, addressing: audience === AUDIENCE_ALL ? [] : audience } });
376
- break;
377
- default:
378
- target = event.target;
379
- dispatch({ type: prop, value: target.value });
380
- break;
249
+ }, []);
250
+ const handleChangeDiscussion = useCallback((content) => {
251
+ dispatch({
252
+ type: 'multiple',
253
+ value: Object.assign(Object.assign({}, content), { titleError: content.title.length > COMPOSER_TITLE_MAX_LENGTH ? (React.createElement(FormattedMessage, { id: "ui.composer.title.error.maxlength", defaultMessage: "ui.composer.title.error.maxlength" })) : null })
254
+ });
255
+ }, []);
256
+ const handleChangePost = useCallback((content) => {
257
+ dispatch({
258
+ type: 'multiple',
259
+ value: Object.assign({}, content)
260
+ });
261
+ }, []);
262
+ const handleChangeCategories = useCallback((value) => {
263
+ dispatch({ type: 'categories', value });
264
+ setLayer(null);
265
+ }, []);
266
+ const handleAddCategoryLayer = useCallback(() => handleAddLayer({
267
+ name: 'category',
268
+ Component: CategoryLayer,
269
+ ComponentProps: {
270
+ onClose: handleRemoveLayer,
271
+ onSave: handleChangeCategories,
272
+ defaultValue: categories
381
273
  }
382
- };
383
- const handleClose = (event) => {
384
- if (unloadRef.current) {
385
- window.onbeforeunload = null;
274
+ }), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
275
+ const handleChangeAudience = useCallback((value) => {
276
+ dispatch({ type: 'addressing', value });
277
+ setLayer(null);
278
+ }, []);
279
+ const handleAddAudienceLayer = useCallback(() => handleAddLayer({
280
+ name: 'audience',
281
+ Component: AudienceLayer,
282
+ ComponentProps: {
283
+ onClose: handleRemoveLayer,
284
+ onSave: handleChangeAudience,
285
+ defaultValue: addressing
386
286
  }
387
- onClose && onClose(event);
388
- };
389
- const handleDeletePoll = (event) => {
390
- dispatch({ type: 'poll', value: null });
391
- setView(MAIN_VIEW);
392
- };
393
- const handleDeleteLocation = (event) => {
394
- dispatch({ type: 'location', value: null });
395
- };
396
- const handleDeleteTag = (id) => (event) => {
397
- const _addressing = addressing.filter((t) => t.id !== id);
398
- dispatch({ type: 'multiple', value: { audience: _addressing.length === 0 ? AUDIENCE_ALL : AUDIENCE_TAG, addressing: _addressing } });
399
- };
400
- const handleDeleteMedia = (id, mediaObjectType) => {
401
- return (event) => {
402
- if (id) {
403
- dispatch({ type: 'medias', value: medias.filter((m) => m.id != id) });
404
- }
405
- else if (mediaObjectType) {
406
- dispatch({ type: 'medias', value: medias.filter((m) => !mediaObjectType.filter(m)) });
407
- }
408
- };
409
- };
410
- const handleMediaProgress = (chunks) => {
411
- mediasRef.current.setMediaChunks(chunks);
412
- };
413
- const handleAddMedia = (media) => {
414
- mediasRef.current.addMedia(media);
415
- };
416
- const handleSortMedia = (newSort) => {
287
+ }), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing]);
288
+ const handleChangeLocation = useCallback((value) => {
289
+ dispatch({ type: 'location', value });
290
+ setLayer(null);
291
+ }, []);
292
+ const handleAddLocationLayer = useCallback(() => handleAddLayer({
293
+ name: 'location',
294
+ Component: LocationLayer,
295
+ ComponentProps: {
296
+ onClose: handleRemoveLayer,
297
+ onSave: handleChangeLocation,
298
+ defaultValue: location
299
+ }
300
+ }), [handleAddLayer, handleRemoveLayer, handleChangeLocation, location]);
301
+ const handleChangeMedias = useCallback((value) => {
302
+ const _medias = [...value];
417
303
  dispatch({
418
304
  type: 'medias',
419
- value: [...medias.filter((media) => newSort.findIndex((m) => m.id === media.id) === -1), ...newSort]
305
+ value: [...value]
420
306
  });
421
- };
422
- const handleSubmit = (event) => {
307
+ mediasRef.current.medias = _medias;
308
+ setLayer(null);
309
+ }, []);
310
+ const handleAddMedia = useCallback((media) => {
311
+ const _medias = [...mediasRef.current.medias, media];
312
+ dispatch({
313
+ type: 'medias',
314
+ value: _medias
315
+ });
316
+ mediasRef.current.medias = _medias;
317
+ }, []);
318
+ const handleMediaTriggerClick = useCallback((mediaObjectType) => (event) => {
319
+ if (mediaObjectType.layerComponent) {
320
+ handleAddLayer({
321
+ name: mediaObjectType.name,
322
+ Component: mediaObjectType.layerComponent,
323
+ ComponentProps: {
324
+ onClose: handleRemoveLayer,
325
+ onSave: handleChangeMedias,
326
+ defaultValue: medias
327
+ }
328
+ });
329
+ }
330
+ }, [handleAddLayer, handleRemoveLayer, handleChangeMedias, medias]);
331
+ const handleChangeAttributes = useCallback((content) => {
332
+ dispatch({
333
+ type: 'multiple',
334
+ value: Object.assign({}, content)
335
+ });
336
+ }, []);
337
+ const handleClickAttributes = useCallback((attr) => {
338
+ switch (attr) {
339
+ case 'categories':
340
+ handleAddCategoryLayer();
341
+ break;
342
+ case 'addressing':
343
+ handleAddAudienceLayer();
344
+ break;
345
+ }
346
+ }, [handleAddCategoryLayer, handleAddAudienceLayer]);
347
+ const handleSubmit = useCallback((event) => {
348
+ event.preventDefault();
349
+ event.stopPropagation();
423
350
  if (UserUtils.isBlocked(scUserContext.user)) {
424
351
  // deny submit action if authenticated user is blocked
425
352
  enqueueSnackbar(React.createElement(FormattedMessage, { id: "ui.common.userBlocked", defaultMessage: "ui.common.userBlocked" }), {
@@ -429,32 +356,29 @@ export default function Composer(inProps) {
429
356
  return;
430
357
  }
431
358
  // Extract hashtags and add to categories
432
- const _categories = [...categories.map((c) => c.id), ...extractHashtags(text)];
359
+ const _categories = [...categories.map((c) => c.id), ...extractHashtags(html)];
433
360
  const data = {
434
361
  title,
435
- text,
362
+ text: html,
436
363
  medias: medias.map((m) => m.id),
437
364
  categories: _categories.filter((item, index) => _categories.indexOf(item) === index)
438
365
  };
439
- if (preferences[SCPreferences.ADDONS_POLLS_ENABLED] && hasPoll()) {
366
+ if (preferences[SCPreferences.ADDONS_POLLS_ENABLED].value && hasPoll) {
440
367
  data.poll = poll;
441
368
  }
442
- if (preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED] && location) {
443
- data.location = {
444
- location: location.location,
445
- lat: location.lat,
446
- lng: location.lng
447
- };
369
+ if (preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED].value && location) {
370
+ data.location = location;
448
371
  }
449
- if (scPrefernces.features.includes(SCFeatureName.TAGGING) && audience === AUDIENCE_TAG) {
372
+ if (features.includes(SCFeatureName.TAGGING) && addressing !== null) {
450
373
  data.addressing = addressing.map((t) => t.id);
451
374
  }
452
375
  setIsSubmitting(true);
453
376
  // Finding right url
454
- let url = Endpoints.Composer.url({ type });
377
+ const _type = type === COMPOSER_TYPE_POLL ? SCContributionType.POST : type;
378
+ let url = Endpoints.Composer.url({ type: _type });
455
379
  let method = Endpoints.Composer.method;
456
380
  if (editMode) {
457
- url = Endpoints.ComposerEdit.url({ type, id });
381
+ url = Endpoints.ComposerEdit.url({ type: feedObjectType ? feedObjectType : _type, id });
458
382
  method = Endpoints.ComposerEdit.method;
459
383
  }
460
384
  // Perform request
@@ -475,184 +399,85 @@ export default function Composer(inProps) {
475
399
  dispatch({ type: 'multiple', value: formatHttpErrorCode(error) });
476
400
  })
477
401
  .then(() => setIsSubmitting(false));
478
- };
479
- // MEMO
480
- const _EditorProps = useMemo(() => (EditorProps ? EditorProps : { toolbar: true, uploadImage: true }), [EditorProps, type]);
481
- const isIOS = useMemo(() => iOS(), []);
402
+ }, [scUserContext.user, feedObjectType, id, type, title, html, categories, addressing, audience, medias, poll, location, hasPoll]);
403
+ const handleClose = useCallback((event) => {
404
+ if (unloadRef.current) {
405
+ window.onbeforeunload = null;
406
+ }
407
+ onClose && onClose(event);
408
+ setLayer(null);
409
+ dispatch({ type: 'reset' });
410
+ }, [onClose]);
411
+ const handleClosePrompt = useCallback((event) => {
412
+ if (canSubmit) {
413
+ handleAddLayer({
414
+ name: 'close',
415
+ Component: CloseLayer,
416
+ ComponentProps: {
417
+ onClose: handleRemoveLayer,
418
+ onSave: handleClose
419
+ }
420
+ });
421
+ }
422
+ else {
423
+ handleClose(event);
424
+ }
425
+ }, [canSubmit, handleAddLayer, handleRemoveLayer, handleClose]);
482
426
  // RENDER
483
427
  const hasMediaShare = useMemo(() => medias.findIndex((m) => m.type === MEDIA_TYPE_SHARE) !== -1, [medias]);
484
- const renderMediaAdornment = (mediaObjectType) => {
485
- return (React.createElement(Box, { className: classes.mediasActions },
486
- React.createElement(Typography, { className: classes.mediasActionsTitle },
487
- React.createElement(FormattedMessage, { id: `ui.composer.media.${mediaObjectType.name}.edit`, defaultMessage: `ui.composer.media.${mediaObjectType.name}.edit` })),
488
- React.createElement(Typography, { className: classes.mediasActionsActions },
489
- React.createElement(Tooltip, { title: React.createElement(FormattedMessage, { id: "ui.composer.edit", defaultMessage: "ui.composer.edit" }) },
490
- React.createElement(IconButton, { onClick: handleChangeView(mediaObjectType.name), color: "inherit" },
491
- React.createElement(Icon, null, "edit"))),
492
- React.createElement(Tooltip, { title: React.createElement(FormattedMessage, { id: "ui.composer.delete", defaultMessage: "ui.composer.delete" }) },
493
- React.createElement(IconButton, { onClick: handleDeleteMedia(null, mediaObjectType), color: "inherit" },
494
- React.createElement(Icon, null, "delete"))))));
495
- };
496
- const renderAudienceView = () => {
497
- return (React.createElement(React.Fragment, null,
498
- React.createElement(DialogTitle, { className: classes.title },
499
- React.createElement(Typography, { component: "div" },
500
- React.createElement(IconButton, { onClick: handleChangeView(MAIN_VIEW) },
501
- React.createElement(Icon, null, "arrow_back"))),
502
- React.createElement(Box, null,
503
- React.createElement(FormattedMessage, { id: "ui.composer.audience.title", defaultMessage: "ui.composer.audience.title" })),
504
- React.createElement(Box, null,
505
- React.createElement(Tooltip, { title: React.createElement(FormattedMessage, { id: "ui.composer.done", defaultMessage: "ui.composer.done" }) },
506
- React.createElement(IconButton, { onClick: handleChangeView(MAIN_VIEW), color: "inherit" },
507
- React.createElement(Icon, null, "check"))))),
508
- React.createElement(DialogContent, { className: classNames(classes.content, classes.audienceContent) },
509
- React.createElement(Tabs, { value: audience, onChange: handleChange('audience'), "aria-label": "audience type" },
510
- React.createElement(Tab, { value: AUDIENCE_ALL, icon: React.createElement(Icon, null, "public"), label: React.createElement(FormattedMessage, { id: "ui.composer.audience.all", defaultMessage: "ui.composer.audience.all" }) }),
511
- React.createElement(Tab, { value: AUDIENCE_TAG, icon: React.createElement(Icon, null, "label"), label: React.createElement(FormattedMessage, { id: "ui.composer.audience.tag", defaultMessage: "ui.composer.audience.tag" }) })),
512
- React.createElement(Typography, { align: "center", className: classes.block },
513
- audience === AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.audience.all.message", defaultMessage: "ui.composer.audience.all.message" })),
514
- audience === AUDIENCE_TAG && (React.createElement(FormattedMessage, { id: "ui.composer.audience.tag.message", defaultMessage: "ui.composer.audience.tag.message" }))),
515
- audience === AUDIENCE_TAG && React.createElement(Audience, { onChange: handleChange('addressing'), defaultValue: addressing, tags: scAddressingTags }))));
516
- };
517
- const renderMediaView = (mediaObjectType) => {
518
- return () => {
519
- return (React.createElement(React.Fragment, null,
520
- React.createElement(DialogTitle, { className: classes.title },
521
- React.createElement(Typography, { component: "div" },
522
- React.createElement("span", null,
523
- React.createElement(IconButton, { onClick: handleChangeView(MAIN_VIEW), disabled: mediasRef.current.mediaChunks.length > 0 },
524
- React.createElement(Icon, null, "arrow_back")))),
525
- React.createElement(Box, null,
526
- React.createElement(FormattedMessage, { id: `ui.composer.media.${mediaObjectType.name}.edit`, defaultMessage: `ui.composer.media.${mediaObjectType.name}.edit` })),
527
- React.createElement(Box, null,
528
- React.createElement(Tooltip, { title: React.createElement(FormattedMessage, { id: "ui.composer.done", defaultMessage: "ui.composer.done" }) },
529
- React.createElement("span", null,
530
- React.createElement(IconButton, { onClick: handleChangeView(MAIN_VIEW), color: "inherit", disabled: mediasRef.current.mediaChunks.length > 0 },
531
- React.createElement(Icon, null, "check")))))),
532
- React.createElement(DialogContent, { className: classNames(classes.content, classes.mediaContent) }, React.createElement(mediaObjectType.editComponent, { medias: medias.filter(mediaObjectType.filter), onProgress: handleMediaProgress, onSuccess: handleAddMedia, onSort: handleSortMedia, onDelete: handleDeleteMedia }))));
533
- };
534
- };
535
- const renderPollView = () => {
536
- return (React.createElement(React.Fragment, null,
537
- React.createElement(DialogTitle, { className: classes.title },
538
- React.createElement(Typography, { component: "div" },
539
- React.createElement(IconButton, { onClick: handleChangeView(MAIN_VIEW) },
540
- React.createElement(Icon, null, "arrow_back"))),
541
- React.createElement(Box, null,
542
- React.createElement(FormattedMessage, { id: "ui.composer.poll", defaultMessage: "ui.composer.poll" })),
543
- React.createElement(Stack, { spacing: 2, direction: "row" },
544
- React.createElement(React.Fragment, null,
545
- React.createElement(Tooltip, { title: React.createElement(FormattedMessage, { id: "ui.composer.delete", defaultMessage: "ui.composer.delete" }) },
546
- React.createElement("span", null,
547
- React.createElement(IconButton, { onClick: handleDeletePoll, color: "inherit", disabled: !hasPoll() },
548
- React.createElement(Icon, null, "delete")))),
549
- React.createElement(Tooltip, { title: React.createElement(FormattedMessage, { id: "ui.composer.done", defaultMessage: "ui.composer.done" }) },
550
- React.createElement("span", null,
551
- React.createElement(IconButton, { onClick: handleChangeView(MAIN_VIEW), color: "inherit", disabled: !hasPoll() },
552
- React.createElement(Icon, null, "check"))))))),
553
- React.createElement(DialogContent, { className: classes.content },
554
- React.createElement(Poll, { onChange: handleChangePoll, value: poll, error: pollError }))));
555
- };
556
- const renderLocationView = () => {
557
- return (React.createElement(React.Fragment, null,
558
- React.createElement(DialogTitle, { className: classes.title },
559
- React.createElement(Typography, { component: "div" },
560
- React.createElement(IconButton, { onClick: handleChangeView(MAIN_VIEW) },
561
- React.createElement(Icon, null, "arrow_back"))),
562
- React.createElement(Box, null,
563
- React.createElement(FormattedMessage, { id: "ui.locationAutocomplete.title", defaultMessage: "ui.locationAutocomplete.title" })),
564
- React.createElement(Box, null,
565
- React.createElement(Tooltip, { title: React.createElement(FormattedMessage, { id: "ui.composer.done", defaultMessage: "ui.composer.done" }) },
566
- React.createElement(IconButton, { onClick: handleChangeView(MAIN_VIEW), color: "inherit" },
567
- React.createElement(Icon, null, "check"))))),
568
- React.createElement(DialogContent, { className: classNames(classes.content, classes.locationContent) },
569
- React.createElement(LocationAutocomplete, { onChange: handleChange('location'), defaultValue: location ? { full_address: location.location } : '' }))));
570
- };
571
- const renderMainView = () => {
572
- return (React.createElement(React.Fragment, null,
573
- React.createElement(DialogTitle, { className: classes.title },
574
- React.createElement(Box, null,
575
- React.createElement(FormControl, { className: classes.types },
576
- React.createElement(Select, { value: type, onChange: handleChangeType, input: React.createElement(TypeInput, null), disabled: editMode }, composerTypes.map((t) => (React.createElement(MenuItem, { value: t, key: t },
577
- React.createElement(FormattedMessage, { id: `ui.composer.type.${t}`, defaultMessage: `ui.composer.type.${t}` }))))))),
578
- React.createElement(Box, null, !scUserContext.user ? React.createElement(Avatar, { className: classes.avatar }) : React.createElement(Avatar, { className: classes.avatar, src: scUserContext.user.avatar })),
579
- React.createElement(Box, null,
580
- React.createElement(IconButton, { onClick: handleClose },
581
- React.createElement(Icon, null, "close")))),
582
- React.createElement(DialogContent, { className: classes.content },
583
- type === COMPOSER_TYPE_DISCUSSION && (React.createElement("div", { className: classes.block },
584
- React.createElement(TextField, { inputRef: titleRef, label: React.createElement(FormattedMessage, { id: "ui.composer.title.label", defaultMessage: "ui.composer.title.label" }), fullWidth: true, variant: "outlined", value: title, multiline: true, onChange: handleChange('title'), InputProps: {
585
- endAdornment: React.createElement(Typography, { variant: "body2" }, COMPOSER_TITLE_MAX_LENGTH - title.length)
586
- }, error: Boolean(titleError), helperText: titleError, disabled: isSubmitting }))),
587
- React.createElement(Editor, Object.assign({ ref: editorRef }, _EditorProps, { key: `${key}-editor`, className: classNames(classes.block, classes.editor), onChange: handleChangeText, onFocus: () => setEditorFocused(true), defaultValue: text, editable: !isSubmitting })),
588
- React.createElement(Box, { className: classes.medias },
589
- React.createElement(MediasPreview, { medias: medias, mediaObjectTypes: mediaObjectTypes.map((mediaObjectType) => {
590
- return Object.assign(Object.assign({}, mediaObjectType), { previewProps: { adornment: mediaObjectType.editButton !== null ? renderMediaAdornment(mediaObjectType) : null, gallery: false } });
591
- }) })),
592
- poll && React.createElement(PollPreview, { pollObject: poll }),
593
- React.createElement(Stack, { spacing: 2, className: classes.audience, direction: "row" },
594
- location && (React.createElement(Chip, { icon: React.createElement(Icon, null, "add_location_alt"), label: location.location, onDelete: handleDeleteLocation, onClick: handleChangeView(LOCATION_VIEW) })),
595
- audience === AUDIENCE_TAG &&
596
- addressing &&
597
- addressing.map((t) => (React.createElement(TagChip, { key: t.id, tag: t, onDelete: handleDeleteTag(t.id), icon: React.createElement(Icon, null, "label"), onClick: handleChangeView(AUDIENCE_VIEW) })))),
598
- React.createElement("div", { className: classes.block },
599
- React.createElement(CategoryAutocomplete, { multiple: true, key: `${key}-categories`, onChange: handleChange('categories'), defaultValue: categories, disabled: isSubmitting })),
600
- error && (React.createElement(Typography, { className: classes.block, color: "error" },
601
- React.createElement(FormattedMessage, { id: "ui.composer.error.generic", defaultMessage: "ui.composer.error.generic" })))),
602
- React.createElement(DialogActions, { className: classes.actions, onClick: () => setEditorFocused(false) },
603
- React.createElement(Typography, { className: classes.mediaActions },
604
- mediaObjectTypes
605
- .filter((mediaObjectType) => mediaObjectType.editButton !== null)
606
- .map((mediaObjectType) => (React.createElement(mediaObjectType.editButton, { key: mediaObjectType.name, onClick: handleChangeView(mediaObjectType.name), disabled: isSubmitting || hasMediaShare, color: medias.filter(mediaObjectType.filter).length > 0 ? 'primary' : 'default' }))),
607
- (preferences[SCPreferences.ADDONS_POLLS_ENABLED] || UserUtils.isStaff(scUserContext.user)) && (React.createElement(IconButton, { "aria-label": "add poll", color: poll ? 'primary' : 'default', disabled: isSubmitting, onClick: handleChangeView(POLL_VIEW) },
608
- React.createElement(Badge, { className: classes.badgeError, badgeContent: pollError ? ' ' : null, color: "error" },
609
- React.createElement(Icon, null, "bar_chart"))))),
610
- React.createElement(Typography, { className: classes.filterActions },
611
- preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED] && (React.createElement(IconButton, { disabled: isSubmitting, onClick: handleChangeView(LOCATION_VIEW), color: location !== null ? 'primary' : 'default' },
612
- React.createElement(Icon, null, "add_location_alt"))),
613
- scPrefernces.features.includes(SCFeatureName.TAGGING) && scAddressingTags.length > 0 && (React.createElement(IconButton, { disabled: isSubmitting, onClick: handleChangeView(AUDIENCE_VIEW) }, audience === AUDIENCE_TAG ? React.createElement(Icon, null, "label") : React.createElement(Icon, null, "public")))),
614
- React.createElement(LoadingButton, { onClick: handleSubmit, color: "primary", variant: "contained", disabled: !canSubmit(), loading: isSubmitting },
615
- React.createElement(FormattedMessage, { id: "ui.composer.submit", defaultMessage: "ui.composer.submit" })))));
616
- };
617
- let child = null;
618
- switch (_view) {
619
- case MAIN_VIEW:
620
- child = renderMainView;
621
- break;
622
- case POLL_VIEW:
623
- child = renderPollView;
624
- break;
625
- case AUDIENCE_VIEW:
626
- child = renderAudienceView;
627
- break;
628
- case LOCATION_VIEW:
629
- child = renderLocationView;
630
- break;
631
- default:
632
- const media = mediaObjectTypes
633
- .filter((mediaObjectType) => mediaObjectType.editComponent !== null)
634
- .find((mv) => mv.name === _view);
635
- child = media ? renderMediaView(media) : renderMainView;
636
- }
637
- if (editMode && isLoading) {
638
- child = () => React.createElement(ComposerSkeleton, null);
639
- }
640
- else if (editMode && loadError) {
641
- child = () => (React.createElement(Alert, { severity: "error", onClose: handleClose },
642
- React.createElement(AlertTitle, null,
643
- React.createElement(FormattedMessage, { id: "ui.composer.edit.error.title", defaultMessage: "ui.composer.edit.error.title" })),
644
- React.createElement(FormattedMessage, { id: "ui.composer.edit.error.content", defaultMessage: "ui.composer.edit.error.content" })));
645
- }
646
- const _maxWidth = useMemo(() => (maxWidth ? maxWidth : type === COMPOSER_TYPE_DISCUSSION ? 'md' : 'sm'), [maxWidth, type]);
428
+ const content = useMemo(() => {
429
+ if (editMode && isLoading) {
430
+ return React.createElement(ComposerSkeleton, null);
431
+ }
432
+ else if (editMode && loadError) {
433
+ return (React.createElement(Alert, { severity: "error", onClose: handleClose },
434
+ React.createElement(AlertTitle, null,
435
+ React.createElement(FormattedMessage, { id: "ui.composer.edit.error.title", defaultMessage: "ui.composer.edit.error.title" })),
436
+ React.createElement(FormattedMessage, { id: "ui.composer.edit.error.content", defaultMessage: "ui.composer.edit.error.content" })));
437
+ }
438
+ switch (type) {
439
+ case COMPOSER_TYPE_POLL:
440
+ return React.createElement(ContentPoll, { key: key, onChange: handleChangePoll, value: { html, categories, addressing, medias, poll, location }, error: pollError, disabled: isSubmitting });
441
+ case SCContributionType.DISCUSSION:
442
+ return React.createElement(ContentDiscussion, { key: key, value: { title, html, categories, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) });
443
+ default:
444
+ return React.createElement(ContentPost, { key: key, value: { html, categories, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) });
445
+ }
446
+ }, [key, type, title, html, categories, addressing, medias, poll, pollError, location, error, handleChangePoll, handleChangePost, isSubmitting]);
647
447
  if (!scUserContext.user && !(scUserContext.loading && open)) {
648
448
  return null;
649
449
  }
650
- return (React.createElement(Root, Object.assign({ maxWidth: _maxWidth, TransitionComponent: DialogTransition, keepMounted: true, onClose: handleClose }, rest, { className: classNames(classes.root, { [classes.writing]: editorFocused, [classes.ios]: isIOS }), fullScreen: fullScreen }),
651
- editorFocused && fullScreen && (React.createElement(Box, { className: classes.titleDense },
652
- React.createElement(IconButton, { onClick: () => setEditorFocused(false) },
653
- React.createElement(Tooltip, { title: React.createElement(FormattedMessage, { id: "ui.composer.editorFullScreen.close", defaultMessage: "ui.composer.editorFullScreen.close" }) },
654
- React.createElement(Icon, null, "zoom_out_map"))),
655
- React.createElement(IconButton, { onClick: handleClose },
656
- React.createElement(Icon, null, "close")))),
657
- child()));
450
+ return (React.createElement(Root, Object.assign({ ref: dialogRef, TransitionComponent: DialogTransition, keepMounted: true, onClose: handleClose }, rest, { className: classNames(classes.root, { [classes.ios]: isIOS }), scroll: "body", fullScreen: fullScreen, tabIndex: -1 }),
451
+ React.createElement("form", { onSubmit: handleSubmit, method: "post" },
452
+ React.createElement(DialogTitle, { className: classes.title },
453
+ React.createElement(IconButton, { onClick: handleClosePrompt },
454
+ React.createElement(Icon, null, "close")),
455
+ React.createElement(LoadingButton, { size: "small", type: "submit", color: "secondary", variant: "contained", disabled: !canSubmit, loading: isSubmitting },
456
+ React.createElement(FormattedMessage, { id: "ui.composer.submit", defaultMessage: "ui.composer.submit" }))),
457
+ React.createElement(DialogContent, { className: classes.content },
458
+ React.createElement(Attributes, { value: { categories, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
459
+ content,
460
+ medias && medias.length > 0 && React.createElement(Box, { className: classes.medias }, mediaObjectTypes.map((mediaObjectType) => {
461
+ if (mediaObjectType.previewComponent) {
462
+ return React.createElement(mediaObjectType.previewComponent, { key: mediaObjectType.name, value: medias, onChange: handleChangeMedias });
463
+ }
464
+ else if (mediaObjectType.displayComponent) {
465
+ return React.createElement(mediaObjectType.displayComponent, { key: mediaObjectType.name, value: medias });
466
+ }
467
+ }))),
468
+ !canSubmit && !editMode && React.createElement(TypeSwitchButtonGroup, { className: classes.types, onChange: handleChangeType, size: "small", value: type }),
469
+ React.createElement(DialogActions, { className: classes.actions },
470
+ mediaObjectTypes
471
+ .filter((mediaObjectType) => mediaObjectType.triggerButton !== null)
472
+ .map((mediaObjectType) => {
473
+ const props = mediaObjectType.layerComponent ? { onClick: handleMediaTriggerClick(mediaObjectType) } : { onAdd: handleAddMedia };
474
+ return (React.createElement(mediaObjectType.triggerButton, Object.assign({ key: mediaObjectType.name, disabled: isSubmitting || hasMediaShare, color: medias.filter(mediaObjectType.filter).length > 0 ? 'primary' : 'default' }, props)));
475
+ }),
476
+ React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddCategoryLayer },
477
+ React.createElement(Icon, null, "category")),
478
+ React.createElement(IconButton, { disabled: isSubmitting || !features.includes(SCFeatureName.TAGGING), onClick: handleAddAudienceLayer }, addressing === null || addressing.length === 0 ? React.createElement(Icon, null, "public") : React.createElement(Icon, null, "label")),
479
+ preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED] && (React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddLocationLayer, color: location !== null ? 'primary' : 'default' },
480
+ React.createElement(Icon, null, "add_location_alt"))))),
481
+ layer && React.createElement(LayerTransitionRoot, { className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" },
482
+ React.createElement(layer.Component, Object.assign({}, layer.ComponentProps)))));
658
483
  }