@selfcommunity/react-ui 0.7.0-alpha.334 → 0.7.0-alpha.336
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/BottomNavigation/BottomNavigation.js +8 -11
- package/lib/cjs/components/BroadcastMessages/Message.js +14 -5
- package/lib/cjs/components/CommentsObject/CommentsObject.js +1 -22
- package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +22 -0
- package/lib/cjs/components/Composer/Attributes/Attributes.js +41 -0
- package/lib/cjs/components/Composer/Attributes/index.d.ts +3 -0
- package/lib/cjs/components/Composer/{Poll → Attributes}/index.js +2 -2
- package/lib/cjs/components/Composer/Composer.d.ts +53 -84
- package/lib/cjs/components/Composer/Composer.js +249 -443
- package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.d.ts +32 -0
- package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +53 -0
- package/lib/cjs/components/Composer/Content/ContentDiscussion/index.d.ts +3 -0
- package/lib/cjs/components/Composer/Content/ContentDiscussion/index.js +5 -0
- package/lib/cjs/components/Composer/Content/ContentPoll/ContentPoll.d.ts +26 -0
- package/lib/cjs/components/Composer/Content/ContentPoll/ContentPoll.js +129 -0
- package/lib/cjs/components/Composer/Content/ContentPoll/index.d.ts +3 -0
- package/lib/cjs/components/Composer/Content/ContentPoll/index.js +5 -0
- package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.d.ts +32 -0
- package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +51 -0
- package/lib/cjs/components/Composer/Content/ContentPost/index.d.ts +3 -0
- package/lib/cjs/components/Composer/Content/ContentPost/index.js +5 -0
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +11 -0
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +74 -0
- package/lib/cjs/components/Composer/Layer/AudienceLayer/index.d.ts +3 -0
- package/lib/cjs/components/Composer/Layer/AudienceLayer/index.js +5 -0
- package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +9 -0
- package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.js +41 -0
- package/lib/cjs/components/Composer/Layer/CategoryLayer/index.d.ts +3 -0
- package/lib/cjs/components/Composer/Layer/CategoryLayer/index.js +5 -0
- package/lib/cjs/components/Composer/Layer/CloseLayer/CloseLayer.d.ts +7 -0
- package/lib/cjs/components/Composer/Layer/CloseLayer/CloseLayer.js +41 -0
- package/lib/cjs/components/Composer/Layer/CloseLayer/index.d.ts +3 -0
- package/lib/cjs/components/Composer/{Audience → Layer/CloseLayer}/index.js +2 -2
- package/lib/cjs/components/Composer/Layer/LocationLayer/LocationLayer.d.ts +9 -0
- package/lib/cjs/components/Composer/Layer/LocationLayer/LocationLayer.js +41 -0
- package/lib/cjs/components/Composer/Layer/LocationLayer/index.d.ts +3 -0
- package/lib/cjs/components/Composer/Layer/LocationLayer/index.js +5 -0
- package/lib/cjs/components/Composer/Skeleton.d.ts +0 -4
- package/lib/cjs/components/Composer/Skeleton.js +10 -72
- package/lib/cjs/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.d.ts +6 -0
- package/lib/cjs/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.js +47 -0
- package/lib/cjs/components/Composer/TypeSwitchButtonGroup/index.d.ts +3 -0
- package/lib/cjs/components/Composer/TypeSwitchButtonGroup/index.js +5 -0
- package/lib/cjs/components/Composer/constants.d.ts +1 -0
- package/lib/cjs/components/Composer/constants.js +4 -0
- package/lib/cjs/components/Composer/index.d.ts +2 -3
- package/lib/cjs/components/Composer/index.js +1 -6
- package/lib/cjs/components/ComposerIconButton/ComposerIconButton.d.ts +2 -1
- package/lib/cjs/components/ComposerIconButton/ComposerIconButton.js +8 -8
- package/lib/cjs/components/Editor/Editor.js +14 -5
- package/lib/cjs/components/Feed/prefetchedData.d.ts +2 -368
- package/lib/cjs/components/Feed/prefetchedData.js +17 -16
- package/lib/cjs/components/FeedObject/Actions/Share/Share.js +2 -2
- package/lib/cjs/components/FeedObject/FeedObject.d.ts +2 -2
- package/lib/cjs/components/FeedObject/FeedObject.js +8 -7
- package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +38 -0
- package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +66 -0
- package/lib/cjs/components/FeedObjectMediaPreview/index.d.ts +3 -0
- package/lib/cjs/components/FeedObjectMediaPreview/index.js +5 -0
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +25 -33
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +34 -67
- package/lib/cjs/components/InlineComposerWidget/Skeleton.d.ts +4 -5
- package/lib/cjs/components/InlineComposerWidget/Skeleton.js +17 -37
- package/lib/cjs/components/InlineComposerWidget/constants.d.ts +1 -0
- package/lib/cjs/components/InlineComposerWidget/constants.js +4 -0
- package/lib/cjs/components/LocationAutocomplete/LocationAutocomplete.d.ts +2 -2
- package/lib/cjs/components/LocationAutocomplete/LocationAutocomplete.js +4 -2
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +1 -1
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +0 -5
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +19 -30
- package/lib/cjs/components/NavigationToolbarMobile/Skeleton.js +5 -6
- package/lib/cjs/components/NavigationToolbarMobile/constants.d.ts +1 -0
- package/lib/cjs/components/NavigationToolbarMobile/constants.js +4 -0
- package/lib/cjs/constants/Composer.d.ts +2 -0
- package/lib/cjs/constants/Composer.js +4 -2
- package/lib/cjs/index.d.ts +12 -12
- package/lib/cjs/index.js +14 -17
- package/lib/cjs/shared/Lightbox/Lightbox.js +2 -2
- package/lib/{esm/shared/Media/Image/PreviewComponent.d.ts → cjs/shared/Media/File/DisplayComponent.d.ts} +1 -11
- package/lib/cjs/shared/Media/{Image/PreviewComponent.js → File/DisplayComponent.js} +55 -145
- package/lib/{esm/shared/Media/Image/PreviewImage → cjs/shared/Media/File/Lightbox}/index.d.ts +4 -3
- package/lib/cjs/shared/Media/File/Lightbox/index.js +37 -0
- package/lib/cjs/shared/Media/File/PreviewComponent.d.ts +9 -0
- package/lib/cjs/shared/Media/File/PreviewComponent.js +51 -0
- package/lib/cjs/shared/Media/File/TriggerButton.d.ts +12 -0
- package/lib/cjs/shared/Media/File/TriggerButton.js +112 -0
- package/lib/cjs/shared/Media/File/asUploadButton.d.ts +7 -0
- package/lib/cjs/shared/Media/File/asUploadButton.js +30 -0
- package/lib/cjs/shared/Media/File/constants.d.ts +1 -0
- package/lib/cjs/shared/Media/File/constants.js +4 -0
- package/lib/cjs/shared/Media/File/filter.d.ts +3 -0
- package/lib/cjs/shared/Media/File/filter.js +4 -0
- package/lib/cjs/shared/Media/File/index.d.ts +3 -0
- package/lib/cjs/shared/Media/File/index.js +16 -0
- package/lib/cjs/shared/Media/Link/DisplayComponent.d.ts +20 -0
- package/lib/cjs/shared/Media/Link/DisplayComponent.js +69 -0
- package/lib/cjs/shared/Media/Link/LayerComponent.d.ts +9 -0
- package/lib/cjs/shared/Media/Link/LayerComponent.js +46 -0
- package/lib/cjs/shared/Media/Link/PreviewComponent.d.ts +7 -21
- package/lib/cjs/shared/Media/Link/PreviewComponent.js +28 -56
- package/lib/cjs/shared/Media/Link/TriggerButton.d.ts +4 -0
- package/lib/cjs/shared/Media/Link/TriggerButton.js +21 -0
- package/lib/cjs/shared/Media/Link/UrlTextField/index.js +1 -2
- package/lib/cjs/shared/Media/Link/constants.d.ts +1 -0
- package/lib/cjs/shared/Media/Link/constants.js +4 -0
- package/lib/cjs/shared/Media/Link/filter.d.ts +3 -0
- package/lib/cjs/shared/Media/Link/filter.js +4 -0
- package/lib/cjs/shared/Media/Link/index.js +9 -8
- package/lib/cjs/shared/Media/Share/DisplayComponent.d.ts +11 -0
- package/lib/cjs/shared/Media/Share/DisplayComponent.js +31 -0
- package/lib/cjs/shared/Media/Share/constants.d.ts +1 -0
- package/lib/cjs/shared/Media/Share/constants.js +4 -0
- package/lib/cjs/shared/Media/Share/filter.d.ts +3 -0
- package/lib/cjs/shared/Media/Share/filter.js +4 -0
- package/lib/cjs/shared/Media/Share/index.js +7 -7
- package/lib/cjs/shared/Media/index.d.ts +2 -4
- package/lib/cjs/shared/Media/index.js +3 -7
- package/lib/cjs/types/composer.d.ts +15 -0
- package/lib/cjs/types/composer.js +2 -0
- package/lib/cjs/types/media.d.ts +9 -5
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +8 -11
- package/lib/esm/components/BroadcastMessages/Message.js +14 -5
- package/lib/esm/components/CommentsObject/CommentsObject.js +1 -22
- package/lib/esm/components/Composer/Attributes/Attributes.d.ts +22 -0
- package/lib/esm/components/Composer/Attributes/Attributes.js +38 -0
- package/lib/esm/components/Composer/Attributes/index.d.ts +3 -0
- package/lib/esm/components/Composer/Attributes/index.js +2 -0
- package/lib/esm/components/Composer/Composer.d.ts +53 -84
- package/lib/esm/components/Composer/Composer.js +246 -439
- package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.d.ts +32 -0
- package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +50 -0
- package/lib/esm/components/Composer/Content/ContentDiscussion/index.d.ts +3 -0
- package/lib/esm/components/Composer/Content/ContentDiscussion/index.js +2 -0
- package/lib/esm/components/Composer/Content/ContentPoll/ContentPoll.d.ts +26 -0
- package/lib/esm/components/Composer/Content/ContentPoll/ContentPoll.js +127 -0
- package/lib/esm/components/Composer/Content/ContentPoll/index.d.ts +3 -0
- package/lib/esm/components/Composer/Content/ContentPoll/index.js +2 -0
- package/lib/esm/components/Composer/Content/ContentPost/ContentPost.d.ts +32 -0
- package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +49 -0
- package/lib/esm/components/Composer/Content/ContentPost/index.d.ts +3 -0
- package/lib/esm/components/Composer/Content/ContentPost/index.js +2 -0
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +11 -0
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +72 -0
- package/lib/esm/components/Composer/Layer/AudienceLayer/index.d.ts +3 -0
- package/lib/esm/components/Composer/Layer/AudienceLayer/index.js +2 -0
- package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +9 -0
- package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.js +39 -0
- package/lib/esm/components/Composer/Layer/CategoryLayer/index.d.ts +3 -0
- package/lib/esm/components/Composer/Layer/CategoryLayer/index.js +2 -0
- package/lib/esm/components/Composer/Layer/CloseLayer/CloseLayer.d.ts +7 -0
- package/lib/esm/components/Composer/Layer/CloseLayer/CloseLayer.js +39 -0
- package/lib/esm/components/Composer/Layer/CloseLayer/index.d.ts +3 -0
- package/lib/esm/components/Composer/Layer/CloseLayer/index.js +2 -0
- package/lib/esm/components/Composer/Layer/LocationLayer/LocationLayer.d.ts +9 -0
- package/lib/esm/components/Composer/Layer/LocationLayer/LocationLayer.js +39 -0
- package/lib/esm/components/Composer/Layer/LocationLayer/index.d.ts +3 -0
- package/lib/esm/components/Composer/Layer/LocationLayer/index.js +2 -0
- package/lib/esm/components/Composer/Skeleton.d.ts +0 -4
- package/lib/esm/components/Composer/Skeleton.js +6 -68
- package/lib/esm/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.d.ts +6 -0
- package/lib/esm/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.js +44 -0
- package/lib/esm/components/Composer/TypeSwitchButtonGroup/index.d.ts +3 -0
- package/lib/esm/components/Composer/TypeSwitchButtonGroup/index.js +2 -0
- package/lib/esm/components/Composer/constants.d.ts +1 -0
- package/lib/esm/components/Composer/constants.js +1 -0
- package/lib/esm/components/Composer/index.d.ts +2 -3
- package/lib/esm/components/Composer/index.js +1 -3
- package/lib/esm/components/ComposerIconButton/ComposerIconButton.d.ts +2 -1
- package/lib/esm/components/ComposerIconButton/ComposerIconButton.js +8 -8
- package/lib/esm/components/Editor/Editor.js +16 -7
- package/lib/esm/components/Feed/Feed.js +4 -4
- package/lib/esm/components/Feed/prefetchedData.d.ts +2 -368
- package/lib/esm/components/Feed/prefetchedData.js +17 -16
- package/lib/esm/components/FeedObject/Actions/Share/Share.js +4 -4
- package/lib/esm/components/FeedObject/FeedObject.d.ts +2 -2
- package/lib/esm/components/FeedObject/FeedObject.js +11 -10
- package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +38 -0
- package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +64 -0
- package/lib/esm/components/FeedObjectMediaPreview/index.d.ts +3 -0
- package/lib/esm/components/FeedObjectMediaPreview/index.js +2 -0
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +25 -33
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +31 -64
- package/lib/esm/components/InlineComposerWidget/Skeleton.d.ts +4 -5
- package/lib/esm/components/InlineComposerWidget/Skeleton.js +15 -35
- package/lib/esm/components/InlineComposerWidget/constants.d.ts +1 -0
- package/lib/esm/components/InlineComposerWidget/constants.js +1 -0
- package/lib/esm/components/LocationAutocomplete/LocationAutocomplete.d.ts +2 -2
- package/lib/esm/components/LocationAutocomplete/LocationAutocomplete.js +4 -2
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +1 -1
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +0 -5
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +12 -23
- package/lib/esm/components/NavigationToolbarMobile/Skeleton.js +3 -4
- package/lib/esm/components/NavigationToolbarMobile/constants.d.ts +1 -0
- package/lib/esm/components/NavigationToolbarMobile/constants.js +1 -0
- package/lib/esm/constants/Composer.d.ts +2 -0
- package/lib/esm/constants/Composer.js +3 -1
- package/lib/esm/index.d.ts +12 -12
- package/lib/esm/index.js +33 -33
- package/lib/esm/shared/Lightbox/Lightbox.js +2 -2
- package/lib/{cjs/shared/Media/Image/PreviewComponent.d.ts → esm/shared/Media/File/DisplayComponent.d.ts} +1 -11
- package/lib/esm/shared/Media/{Image/PreviewComponent.js → File/DisplayComponent.js} +50 -140
- package/lib/{cjs/shared/Media/Image/PreviewImage → esm/shared/Media/File/Lightbox}/index.d.ts +4 -3
- package/lib/esm/shared/Media/File/Lightbox/index.js +34 -0
- package/lib/esm/shared/Media/File/PreviewComponent.d.ts +9 -0
- package/lib/esm/shared/Media/File/PreviewComponent.js +49 -0
- package/lib/esm/shared/Media/File/TriggerButton.d.ts +12 -0
- package/lib/esm/shared/Media/File/TriggerButton.js +110 -0
- package/lib/esm/shared/Media/File/asUploadButton.d.ts +7 -0
- package/lib/esm/shared/Media/File/asUploadButton.js +28 -0
- package/lib/esm/shared/Media/File/constants.d.ts +1 -0
- package/lib/esm/shared/Media/File/constants.js +1 -0
- package/lib/esm/shared/Media/File/filter.d.ts +3 -0
- package/lib/esm/shared/Media/File/filter.js +2 -0
- package/lib/esm/shared/Media/File/index.d.ts +3 -0
- package/lib/esm/shared/Media/File/index.js +13 -0
- package/lib/esm/shared/Media/Link/DisplayComponent.d.ts +20 -0
- package/lib/esm/shared/Media/Link/DisplayComponent.js +67 -0
- package/lib/esm/shared/Media/Link/LayerComponent.d.ts +9 -0
- package/lib/esm/shared/Media/Link/LayerComponent.js +44 -0
- package/lib/esm/shared/Media/Link/PreviewComponent.d.ts +7 -21
- package/lib/esm/shared/Media/Link/PreviewComponent.js +27 -54
- package/lib/esm/shared/Media/Link/TriggerButton.d.ts +4 -0
- package/lib/esm/shared/Media/Link/TriggerButton.js +19 -0
- package/lib/esm/shared/Media/Link/UrlTextField/index.js +2 -3
- package/lib/esm/shared/Media/Link/constants.d.ts +1 -0
- package/lib/esm/shared/Media/Link/constants.js +1 -0
- package/lib/esm/shared/Media/Link/filter.d.ts +3 -0
- package/lib/esm/shared/Media/Link/filter.js +2 -0
- package/lib/esm/shared/Media/Link/index.js +9 -8
- package/lib/esm/shared/Media/Share/DisplayComponent.d.ts +11 -0
- package/lib/esm/shared/Media/Share/DisplayComponent.js +29 -0
- package/lib/esm/shared/Media/Share/constants.d.ts +1 -0
- package/lib/esm/shared/Media/Share/constants.js +1 -0
- package/lib/esm/shared/Media/Share/filter.d.ts +3 -0
- package/lib/esm/shared/Media/Share/filter.js +2 -0
- package/lib/esm/shared/Media/Share/index.js +7 -7
- package/lib/esm/shared/Media/index.d.ts +2 -4
- package/lib/esm/shared/Media/index.js +2 -4
- package/lib/esm/types/composer.d.ts +15 -0
- package/lib/esm/types/composer.js +1 -0
- package/lib/esm/types/media.d.ts +9 -5
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
- package/lib/cjs/components/Composer/Audience/Audience.d.ts +0 -71
- package/lib/cjs/components/Composer/Audience/Audience.js +0 -69
- package/lib/cjs/components/Composer/Audience/index.d.ts +0 -3
- package/lib/cjs/components/Composer/Poll/Poll.d.ts +0 -31
- package/lib/cjs/components/Composer/Poll/Poll.js +0 -151
- package/lib/cjs/components/Composer/Poll/index.d.ts +0 -3
- package/lib/cjs/shared/Media/Document/EditButton.d.ts +0 -2
- package/lib/cjs/shared/Media/Document/EditButton.js +0 -10
- package/lib/cjs/shared/Media/Document/EditComponent.d.ts +0 -3
- package/lib/cjs/shared/Media/Document/EditComponent.js +0 -103
- package/lib/cjs/shared/Media/Document/PreviewComponent.d.ts +0 -3
- package/lib/cjs/shared/Media/Document/PreviewComponent.js +0 -43
- package/lib/cjs/shared/Media/Document/index.d.ts +0 -3
- package/lib/cjs/shared/Media/Document/index.js +0 -16
- package/lib/cjs/shared/Media/Image/EditButton.d.ts +0 -2
- package/lib/cjs/shared/Media/Image/EditButton.js +0 -10
- package/lib/cjs/shared/Media/Image/EditComponent.d.ts +0 -3
- package/lib/cjs/shared/Media/Image/EditComponent.js +0 -102
- package/lib/cjs/shared/Media/Image/PreviewImage/index.js +0 -41
- package/lib/cjs/shared/Media/Image/index.d.ts +0 -3
- package/lib/cjs/shared/Media/Image/index.js +0 -16
- package/lib/cjs/shared/Media/Link/EditButton.d.ts +0 -2
- package/lib/cjs/shared/Media/Link/EditButton.js +0 -10
- package/lib/cjs/shared/Media/Link/EditComponent.d.ts +0 -3
- package/lib/cjs/shared/Media/Link/EditComponent.js +0 -46
- package/lib/cjs/shared/Media/Share/PreviewComponent.d.ts +0 -7
- package/lib/cjs/shared/Media/Share/PreviewComponent.js +0 -32
- package/lib/cjs/shared/Media/Video/EditButton.d.ts +0 -2
- package/lib/cjs/shared/Media/Video/EditButton.js +0 -10
- package/lib/cjs/shared/Media/Video/EditComponent.d.ts +0 -3
- package/lib/cjs/shared/Media/Video/EditComponent.js +0 -89
- package/lib/cjs/shared/Media/Video/PreviewComponent.d.ts +0 -19
- package/lib/cjs/shared/Media/Video/PreviewComponent.js +0 -37
- package/lib/cjs/shared/Media/Video/index.d.ts +0 -3
- package/lib/cjs/shared/Media/Video/index.js +0 -16
- package/lib/cjs/shared/MediasPreview/index.d.ts +0 -18
- package/lib/cjs/shared/MediasPreview/index.js +0 -44
- package/lib/esm/components/Composer/Audience/Audience.d.ts +0 -71
- package/lib/esm/components/Composer/Audience/Audience.js +0 -66
- package/lib/esm/components/Composer/Audience/index.d.ts +0 -3
- package/lib/esm/components/Composer/Audience/index.js +0 -2
- package/lib/esm/components/Composer/Poll/Poll.d.ts +0 -31
- package/lib/esm/components/Composer/Poll/Poll.js +0 -149
- package/lib/esm/components/Composer/Poll/index.d.ts +0 -3
- package/lib/esm/components/Composer/Poll/index.js +0 -2
- package/lib/esm/shared/Media/Document/EditButton.d.ts +0 -2
- package/lib/esm/shared/Media/Document/EditButton.js +0 -7
- package/lib/esm/shared/Media/Document/EditComponent.d.ts +0 -3
- package/lib/esm/shared/Media/Document/EditComponent.js +0 -101
- package/lib/esm/shared/Media/Document/PreviewComponent.d.ts +0 -3
- package/lib/esm/shared/Media/Document/PreviewComponent.js +0 -41
- package/lib/esm/shared/Media/Document/index.d.ts +0 -3
- package/lib/esm/shared/Media/Document/index.js +0 -13
- package/lib/esm/shared/Media/Image/EditButton.d.ts +0 -2
- package/lib/esm/shared/Media/Image/EditButton.js +0 -7
- package/lib/esm/shared/Media/Image/EditComponent.d.ts +0 -3
- package/lib/esm/shared/Media/Image/EditComponent.js +0 -100
- package/lib/esm/shared/Media/Image/PreviewImage/index.js +0 -38
- package/lib/esm/shared/Media/Image/index.d.ts +0 -3
- package/lib/esm/shared/Media/Image/index.js +0 -13
- package/lib/esm/shared/Media/Link/EditButton.d.ts +0 -2
- package/lib/esm/shared/Media/Link/EditButton.js +0 -7
- package/lib/esm/shared/Media/Link/EditComponent.d.ts +0 -3
- package/lib/esm/shared/Media/Link/EditComponent.js +0 -43
- package/lib/esm/shared/Media/Share/PreviewComponent.d.ts +0 -7
- package/lib/esm/shared/Media/Share/PreviewComponent.js +0 -29
- package/lib/esm/shared/Media/Video/EditButton.d.ts +0 -2
- package/lib/esm/shared/Media/Video/EditButton.js +0 -7
- package/lib/esm/shared/Media/Video/EditComponent.d.ts +0 -3
- package/lib/esm/shared/Media/Video/EditComponent.js +0 -87
- package/lib/esm/shared/Media/Video/PreviewComponent.d.ts +0 -19
- package/lib/esm/shared/Media/Video/PreviewComponent.js +0 -34
- package/lib/esm/shared/Media/Video/index.d.ts +0 -3
- package/lib/esm/shared/Media/Video/index.js +0 -13
- package/lib/esm/shared/MediasPreview/index.d.ts +0 -18
- 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,
|
|
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,
|
|
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,
|
|
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
|
|
14
|
-
import
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
102
|
-
|
|
59
|
+
html: '',
|
|
60
|
+
htmlError: null,
|
|
103
61
|
categories: [],
|
|
104
62
|
categoriesError: null,
|
|
105
|
-
|
|
106
|
-
addressing: [],
|
|
63
|
+
addressing: null,
|
|
107
64
|
addressingError: null,
|
|
108
65
|
medias: [],
|
|
109
66
|
poll: null,
|
|
@@ -138,30 +95,14 @@ const reducer = (state, action) => {
|
|
|
138
95
|
|Rule Name|Global class|Description|
|
|
139
96
|
|---|---|---|
|
|
140
97
|
|root|.SCComposer-root|Styles applied to the root element.|
|
|
141
|
-
|
|
|
98
|
+
|ios|.SCComposer-ios|Styles applied to the root element when the device is ios.|
|
|
142
99
|
|title|.SCComposer-title|Styles applied to the title element.|
|
|
143
|
-
|titleDense|.SCComposer-title-dense|Styles applied to the dense title element.|
|
|
144
100
|
|types|.SCComposer-types|Styles applied to the types element.|
|
|
145
|
-
|avatar|.SCComposer-avatar|Styles applied to the avatar element.|
|
|
146
101
|
|content|.SCComposer-content|Styles applied to the content.|
|
|
147
|
-
|
|
|
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.|
|
|
102
|
+
|attributes|.SCComposer-attributes|Styles applied to the attributes.|
|
|
153
103
|
|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
104
|
|actions|.SCComposer-actions|Styles applied to the actions section.|
|
|
161
|
-
|
|
|
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.|
|
|
105
|
+
|layerTransitionRoot|.SCComposer-layer-transition-root|Styles applied to the overlay layers (eg. location).|
|
|
165
106
|
|
|
166
107
|
|
|
167
108
|
* @param inProps
|
|
@@ -172,31 +113,24 @@ export default function Composer(inProps) {
|
|
|
172
113
|
props: inProps,
|
|
173
114
|
name: PREFIX
|
|
174
115
|
});
|
|
175
|
-
const { feedObjectId = null, feedObjectType = null, feedObject = null, defaultValue = {},
|
|
116
|
+
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
117
|
// Context
|
|
177
|
-
const
|
|
118
|
+
const { preferences, features } = useSCPreferences();
|
|
178
119
|
const scUserContext = useSCUser();
|
|
179
120
|
const { enqueueSnackbar } = useSnackbar();
|
|
180
121
|
// HOOKS
|
|
181
|
-
const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: rest.open });
|
|
182
122
|
const theme = useTheme();
|
|
183
123
|
const fullScreen = useMediaQuery(theme.breakpoints.down('md'), { noSsr: typeof window !== 'undefined' });
|
|
184
124
|
// State variables
|
|
185
125
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
186
|
-
const [
|
|
187
|
-
const [
|
|
188
|
-
const
|
|
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
|
-
};
|
|
126
|
+
const [layer, setLayer] = useState();
|
|
127
|
+
const [state, dispatch] = useReducer(reducer, Object.assign(Object.assign(Object.assign({}, COMPOSER_INITIAL_STATE), defaultValue), { key: random() }));
|
|
128
|
+
const { key, id, type, title, titleError, html, categories, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
195
129
|
const destructureFeedObject = (_feedObject) => {
|
|
196
|
-
if (_feedObject.type ===
|
|
130
|
+
if (_feedObject.type === SCContributionType.POST) {
|
|
197
131
|
_feedObject = _feedObject;
|
|
198
132
|
}
|
|
199
|
-
else if (_feedObject.type ===
|
|
133
|
+
else if (_feedObject.type === SCContributionType.DISCUSSION) {
|
|
200
134
|
_feedObject = _feedObject;
|
|
201
135
|
}
|
|
202
136
|
else {
|
|
@@ -207,11 +141,10 @@ export default function Composer(inProps) {
|
|
|
207
141
|
type: 'multiple',
|
|
208
142
|
value: {
|
|
209
143
|
id: _feedObject.id,
|
|
210
|
-
type: _feedObject.type,
|
|
144
|
+
type: _feedObject.poll ? COMPOSER_TYPE_POLL : feedObject.type,
|
|
211
145
|
title: _feedObject.title,
|
|
212
|
-
|
|
146
|
+
html: _feedObject.html,
|
|
213
147
|
categories: _feedObject.categories,
|
|
214
|
-
audience: _feedObject.addressing ? AUDIENCE_TAG : AUDIENCE_ALL,
|
|
215
148
|
addressing: _feedObject.addressing,
|
|
216
149
|
medias: _feedObject.medias,
|
|
217
150
|
poll: _feedObject.poll,
|
|
@@ -225,43 +158,24 @@ export default function Composer(inProps) {
|
|
|
225
158
|
}
|
|
226
159
|
};
|
|
227
160
|
// Edit state variables
|
|
228
|
-
const editMode = Boolean((feedObjectId && feedObjectType) || feedObject);
|
|
161
|
+
const editMode = useMemo(() => Boolean((feedObjectId && feedObjectType) || feedObject), [feedObjectId, feedObjectType, feedObject]);
|
|
229
162
|
const [isLoading, setIsLoading] = useState(editMode);
|
|
230
163
|
const [loadError, setLoadError] = useState(false);
|
|
231
164
|
// REFS
|
|
165
|
+
const dialogRef = useRef();
|
|
232
166
|
const unloadRef = useRef(false);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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();
|
|
167
|
+
// Create a ref for medias because of state update error on chunk upload
|
|
168
|
+
const mediasRef = useRef({ medias });
|
|
169
|
+
mediasRef.current = { medias };
|
|
170
|
+
// MEMO
|
|
171
|
+
const hasPoll = useMemo(() => {
|
|
172
|
+
return poll && poll.title.length > 0 && poll.title.length < COMPOSER_TITLE_MAX_LENGTH && poll.choices.length >= COMPOSER_POLL_MIN_CHOICES;
|
|
173
|
+
}, [poll]);
|
|
174
|
+
const canSubmit = useMemo(() => {
|
|
175
|
+
return !isLoading && ((type === SCContributionType.DISCUSSION && title.length > 0 && title.length < COMPOSER_TITLE_MAX_LENGTH) ||
|
|
176
|
+
(type === SCContributionType.POST && (stripHtml(html).length > 0 || medias.length > 0 || hasPoll)) ||
|
|
177
|
+
(type === COMPOSER_TYPE_POLL && hasPoll));
|
|
178
|
+
}, [isLoading, type, title, html, medias, hasPoll]);
|
|
265
179
|
// Load feed object
|
|
266
180
|
useEffect(() => {
|
|
267
181
|
if (!editMode) {
|
|
@@ -285,11 +199,9 @@ export default function Composer(inProps) {
|
|
|
285
199
|
})
|
|
286
200
|
.then(() => setIsLoading(false));
|
|
287
201
|
}, [editMode]);
|
|
288
|
-
// Props update
|
|
289
|
-
useEffect(() => setView(view), [view]);
|
|
290
202
|
// Prevent unload
|
|
291
203
|
useEffect(() => {
|
|
292
|
-
if (!unloadRef.current && canSubmit
|
|
204
|
+
if (!unloadRef.current && canSubmit) {
|
|
293
205
|
unloadRef.current = true;
|
|
294
206
|
const onUnload = (event) => {
|
|
295
207
|
event.preventDefault();
|
|
@@ -297,129 +209,125 @@ export default function Composer(inProps) {
|
|
|
297
209
|
};
|
|
298
210
|
window.onbeforeunload = onUnload;
|
|
299
211
|
}
|
|
300
|
-
else if (unloadRef.current && !canSubmit
|
|
212
|
+
else if (unloadRef.current && !canSubmit) {
|
|
301
213
|
unloadRef.current = false;
|
|
302
214
|
window.onbeforeunload = null;
|
|
303
215
|
}
|
|
304
|
-
}, [state]);
|
|
305
|
-
// Autofocus
|
|
306
|
-
useEffect(() => {
|
|
307
|
-
if (!rest.open || fullScreen) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
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
|
-
};
|
|
216
|
+
}, [state, canSubmit]);
|
|
325
217
|
/* Handlers */
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
};
|
|
330
|
-
};
|
|
331
|
-
const
|
|
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) => {
|
|
218
|
+
const handleAddLayer = useCallback((layer) => setLayer(layer), []);
|
|
219
|
+
const handleRemoveLayer = useCallback(() => setLayer(null), []);
|
|
220
|
+
const handleChangeType = useCallback((value) => {
|
|
221
|
+
dispatch({ type: 'type', value });
|
|
222
|
+
}, []);
|
|
223
|
+
const handleChangePoll = useCallback((content) => {
|
|
339
224
|
dispatch({
|
|
340
225
|
type: 'multiple',
|
|
341
|
-
value: {
|
|
342
|
-
poll: poll,
|
|
343
|
-
pollError: poll.title.length > COMPOSER_TITLE_MAX_LENGTH
|
|
226
|
+
value: Object.assign(Object.assign({}, content), { pollError: content.poll.title.length > COMPOSER_TITLE_MAX_LENGTH
|
|
344
227
|
? { titleError: React.createElement(FormattedMessage, { id: "ui.composer.title.error.maxlength", defaultMessage: "ui.composer.title.error.maxlength" }) }
|
|
345
|
-
: null
|
|
346
|
-
}
|
|
228
|
+
: null })
|
|
347
229
|
});
|
|
348
|
-
};
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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;
|
|
230
|
+
}, []);
|
|
231
|
+
const handleChangeDiscussion = useCallback((content) => {
|
|
232
|
+
dispatch({
|
|
233
|
+
type: 'multiple',
|
|
234
|
+
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 })
|
|
235
|
+
});
|
|
236
|
+
}, []);
|
|
237
|
+
const handleChangePost = useCallback((content) => {
|
|
238
|
+
dispatch({
|
|
239
|
+
type: 'multiple',
|
|
240
|
+
value: Object.assign({}, content)
|
|
241
|
+
});
|
|
242
|
+
}, []);
|
|
243
|
+
const handleChangeCategories = useCallback((value) => {
|
|
244
|
+
dispatch({ type: 'categories', value });
|
|
245
|
+
setLayer(null);
|
|
246
|
+
}, []);
|
|
247
|
+
const handleAddCategoryLayer = useCallback(() => handleAddLayer({
|
|
248
|
+
name: 'category',
|
|
249
|
+
Component: CategoryLayer,
|
|
250
|
+
ComponentProps: {
|
|
251
|
+
onClose: handleRemoveLayer,
|
|
252
|
+
onSave: handleChangeCategories,
|
|
253
|
+
defaultValue: categories
|
|
381
254
|
}
|
|
382
|
-
};
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
255
|
+
}), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
|
|
256
|
+
const handleChangeAudience = useCallback((value) => {
|
|
257
|
+
dispatch({ type: 'addressing', value });
|
|
258
|
+
setLayer(null);
|
|
259
|
+
}, []);
|
|
260
|
+
const handleAddAudienceLayer = useCallback(() => handleAddLayer({
|
|
261
|
+
name: 'audience',
|
|
262
|
+
Component: AudienceLayer,
|
|
263
|
+
ComponentProps: {
|
|
264
|
+
onClose: handleRemoveLayer,
|
|
265
|
+
onSave: handleChangeAudience,
|
|
266
|
+
defaultValue: addressing
|
|
386
267
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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) => {
|
|
268
|
+
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing]);
|
|
269
|
+
const handleChangeLocation = useCallback((value) => {
|
|
270
|
+
dispatch({ type: 'location', value });
|
|
271
|
+
setLayer(null);
|
|
272
|
+
}, []);
|
|
273
|
+
const handleAddLocationLayer = useCallback(() => handleAddLayer({
|
|
274
|
+
name: 'location',
|
|
275
|
+
Component: LocationLayer,
|
|
276
|
+
ComponentProps: {
|
|
277
|
+
onClose: handleRemoveLayer,
|
|
278
|
+
onSave: handleChangeLocation,
|
|
279
|
+
defaultValue: location
|
|
280
|
+
}
|
|
281
|
+
}), [handleAddLayer, handleRemoveLayer, handleChangeLocation, location]);
|
|
282
|
+
const handleChangeMedias = useCallback((value) => {
|
|
283
|
+
const _medias = [...value];
|
|
417
284
|
dispatch({
|
|
418
285
|
type: 'medias',
|
|
419
|
-
value: [...
|
|
286
|
+
value: [...value]
|
|
420
287
|
});
|
|
421
|
-
|
|
422
|
-
|
|
288
|
+
mediasRef.current.medias = _medias;
|
|
289
|
+
setLayer(null);
|
|
290
|
+
}, []);
|
|
291
|
+
const handleAddMedia = useCallback((media) => {
|
|
292
|
+
const _medias = [...mediasRef.current.medias, media];
|
|
293
|
+
dispatch({
|
|
294
|
+
type: 'medias',
|
|
295
|
+
value: _medias
|
|
296
|
+
});
|
|
297
|
+
mediasRef.current.medias = _medias;
|
|
298
|
+
}, []);
|
|
299
|
+
const handleMediaTriggerClick = useCallback((mediaObjectType) => (event) => {
|
|
300
|
+
if (mediaObjectType.layerComponent) {
|
|
301
|
+
handleAddLayer({
|
|
302
|
+
name: mediaObjectType.name,
|
|
303
|
+
Component: mediaObjectType.layerComponent,
|
|
304
|
+
ComponentProps: {
|
|
305
|
+
onClose: handleRemoveLayer,
|
|
306
|
+
onSave: handleChangeMedias,
|
|
307
|
+
defaultValue: medias
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}, [handleAddLayer, handleRemoveLayer, handleChangeMedias, medias]);
|
|
312
|
+
const handleChangeAttributes = useCallback((content) => {
|
|
313
|
+
dispatch({
|
|
314
|
+
type: 'multiple',
|
|
315
|
+
value: Object.assign({}, content)
|
|
316
|
+
});
|
|
317
|
+
}, []);
|
|
318
|
+
const handleClickAttributes = useCallback((attr) => {
|
|
319
|
+
switch (attr) {
|
|
320
|
+
case 'categories':
|
|
321
|
+
handleAddCategoryLayer();
|
|
322
|
+
break;
|
|
323
|
+
case 'addressing':
|
|
324
|
+
handleAddAudienceLayer();
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}, [handleAddCategoryLayer, handleAddAudienceLayer]);
|
|
328
|
+
const handleSubmit = useCallback((event) => {
|
|
329
|
+
event.preventDefault();
|
|
330
|
+
event.stopPropagation();
|
|
423
331
|
if (UserUtils.isBlocked(scUserContext.user)) {
|
|
424
332
|
// deny submit action if authenticated user is blocked
|
|
425
333
|
enqueueSnackbar(React.createElement(FormattedMessage, { id: "ui.common.userBlocked", defaultMessage: "ui.common.userBlocked" }), {
|
|
@@ -429,32 +337,29 @@ export default function Composer(inProps) {
|
|
|
429
337
|
return;
|
|
430
338
|
}
|
|
431
339
|
// Extract hashtags and add to categories
|
|
432
|
-
const _categories = [...categories.map((c) => c.id), ...extractHashtags(
|
|
340
|
+
const _categories = [...categories.map((c) => c.id), ...extractHashtags(html)];
|
|
433
341
|
const data = {
|
|
434
342
|
title,
|
|
435
|
-
text,
|
|
343
|
+
text: html,
|
|
436
344
|
medias: medias.map((m) => m.id),
|
|
437
345
|
categories: _categories.filter((item, index) => _categories.indexOf(item) === index)
|
|
438
346
|
};
|
|
439
|
-
if (preferences[SCPreferences.ADDONS_POLLS_ENABLED] && hasPoll
|
|
347
|
+
if (preferences[SCPreferences.ADDONS_POLLS_ENABLED].value && hasPoll) {
|
|
440
348
|
data.poll = poll;
|
|
441
349
|
}
|
|
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
|
-
};
|
|
350
|
+
if (preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED].value && location) {
|
|
351
|
+
data.location = location;
|
|
448
352
|
}
|
|
449
|
-
if (
|
|
353
|
+
if (features.includes(SCFeatureName.TAGGING) && addressing !== null) {
|
|
450
354
|
data.addressing = addressing.map((t) => t.id);
|
|
451
355
|
}
|
|
452
356
|
setIsSubmitting(true);
|
|
453
357
|
// Finding right url
|
|
454
|
-
|
|
358
|
+
const _type = type === COMPOSER_TYPE_POLL ? SCContributionType.POST : type;
|
|
359
|
+
let url = Endpoints.Composer.url({ type: _type });
|
|
455
360
|
let method = Endpoints.Composer.method;
|
|
456
361
|
if (editMode) {
|
|
457
|
-
url = Endpoints.ComposerEdit.url({ type, id });
|
|
362
|
+
url = Endpoints.ComposerEdit.url({ type: feedObjectType ? feedObjectType : _type, id });
|
|
458
363
|
method = Endpoints.ComposerEdit.method;
|
|
459
364
|
}
|
|
460
365
|
// Perform request
|
|
@@ -475,184 +380,86 @@ export default function Composer(inProps) {
|
|
|
475
380
|
dispatch({ type: 'multiple', value: formatHttpErrorCode(error) });
|
|
476
381
|
})
|
|
477
382
|
.then(() => setIsSubmitting(false));
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
|
|
383
|
+
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, addressing, audience, medias, poll, location, hasPoll]);
|
|
384
|
+
const handleClose = useCallback((event) => {
|
|
385
|
+
if (unloadRef.current) {
|
|
386
|
+
window.onbeforeunload = null;
|
|
387
|
+
}
|
|
388
|
+
onClose && onClose(event);
|
|
389
|
+
setLayer(null);
|
|
390
|
+
dispatch({ type: 'reset' });
|
|
391
|
+
}, [onClose]);
|
|
392
|
+
const handleClosePrompt = useCallback((event) => {
|
|
393
|
+
if (canSubmit) {
|
|
394
|
+
handleAddLayer({
|
|
395
|
+
name: 'close',
|
|
396
|
+
Component: CloseLayer,
|
|
397
|
+
ComponentProps: {
|
|
398
|
+
onClose: handleRemoveLayer,
|
|
399
|
+
onSave: handleClose
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
handleClose(event);
|
|
405
|
+
}
|
|
406
|
+
}, [canSubmit, handleAddLayer, handleRemoveLayer, handleClose]);
|
|
481
407
|
const isIOS = useMemo(() => iOS(), []);
|
|
482
408
|
// RENDER
|
|
483
409
|
const hasMediaShare = useMemo(() => medias.findIndex((m) => m.type === MEDIA_TYPE_SHARE) !== -1, [medias]);
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
React.createElement(
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
React.createElement(
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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]);
|
|
410
|
+
const content = useMemo(() => {
|
|
411
|
+
if (editMode && isLoading) {
|
|
412
|
+
return React.createElement(ComposerSkeleton, null);
|
|
413
|
+
}
|
|
414
|
+
else if (editMode && loadError) {
|
|
415
|
+
return (React.createElement(Alert, { severity: "error", onClose: handleClose },
|
|
416
|
+
React.createElement(AlertTitle, null,
|
|
417
|
+
React.createElement(FormattedMessage, { id: "ui.composer.edit.error.title", defaultMessage: "ui.composer.edit.error.title" })),
|
|
418
|
+
React.createElement(FormattedMessage, { id: "ui.composer.edit.error.content", defaultMessage: "ui.composer.edit.error.content" })));
|
|
419
|
+
}
|
|
420
|
+
switch (type) {
|
|
421
|
+
case COMPOSER_TYPE_POLL:
|
|
422
|
+
return React.createElement(ContentPoll, { key: key, onChange: handleChangePoll, value: { html, categories, addressing, medias, poll, location }, error: pollError, disabled: isSubmitting });
|
|
423
|
+
case SCContributionType.DISCUSSION:
|
|
424
|
+
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) });
|
|
425
|
+
default:
|
|
426
|
+
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) });
|
|
427
|
+
}
|
|
428
|
+
}, [key, type, title, html, categories, addressing, medias, poll, pollError, location, error, handleChangePoll, handleChangePost, isSubmitting]);
|
|
647
429
|
if (!scUserContext.user && !(scUserContext.loading && open)) {
|
|
648
430
|
return null;
|
|
649
431
|
}
|
|
650
|
-
return (React.createElement(Root, Object.assign({
|
|
651
|
-
|
|
652
|
-
React.createElement(
|
|
653
|
-
React.createElement(
|
|
654
|
-
React.createElement(Icon, null, "
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
432
|
+
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 }),
|
|
433
|
+
React.createElement("form", { onSubmit: handleSubmit, method: "post" },
|
|
434
|
+
React.createElement(DialogTitle, { className: classes.title },
|
|
435
|
+
React.createElement(IconButton, { onClick: handleClosePrompt },
|
|
436
|
+
React.createElement(Icon, null, "close")),
|
|
437
|
+
React.createElement(LoadingButton, { size: "small", type: "submit", color: "secondary", variant: "contained", disabled: !canSubmit, loading: isSubmitting },
|
|
438
|
+
React.createElement(FormattedMessage, { id: "ui.composer.submit", defaultMessage: "ui.composer.submit" }))),
|
|
439
|
+
React.createElement(DialogContent, { className: classes.content },
|
|
440
|
+
React.createElement(Attributes, { value: { categories, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
441
|
+
content,
|
|
442
|
+
medias && medias.length > 0 && React.createElement(Box, { className: classes.medias }, mediaObjectTypes.map((mediaObjectType) => {
|
|
443
|
+
if (mediaObjectType.previewComponent) {
|
|
444
|
+
return React.createElement(mediaObjectType.previewComponent, { key: mediaObjectType.name, value: medias, onChange: handleChangeMedias });
|
|
445
|
+
}
|
|
446
|
+
else if (mediaObjectType.displayComponent) {
|
|
447
|
+
return React.createElement(mediaObjectType.displayComponent, { key: mediaObjectType.name, value: medias });
|
|
448
|
+
}
|
|
449
|
+
}))),
|
|
450
|
+
!canSubmit && !editMode && React.createElement(TypeSwitchButtonGroup, { className: classes.types, onChange: handleChangeType, size: "small", value: type }),
|
|
451
|
+
React.createElement(DialogActions, { className: classes.actions },
|
|
452
|
+
mediaObjectTypes
|
|
453
|
+
.filter((mediaObjectType) => mediaObjectType.triggerButton !== null)
|
|
454
|
+
.map((mediaObjectType) => {
|
|
455
|
+
const props = mediaObjectType.layerComponent ? { onClick: handleMediaTriggerClick(mediaObjectType) } : { onAdd: handleAddMedia };
|
|
456
|
+
return (React.createElement(mediaObjectType.triggerButton, Object.assign({ key: mediaObjectType.name, disabled: isSubmitting || hasMediaShare, color: medias.filter(mediaObjectType.filter).length > 0 ? 'primary' : 'default' }, props)));
|
|
457
|
+
}),
|
|
458
|
+
React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddCategoryLayer },
|
|
459
|
+
React.createElement(Icon, null, "category")),
|
|
460
|
+
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")),
|
|
461
|
+
preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED] && (React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddLocationLayer, color: location !== null ? 'primary' : 'default' },
|
|
462
|
+
React.createElement(Icon, null, "add_location_alt"))))),
|
|
463
|
+
layer && React.createElement(LayerTransitionRoot, { className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" },
|
|
464
|
+
React.createElement(layer.Component, Object.assign({}, layer.ComponentProps)))));
|
|
658
465
|
}
|