@capillarytech/creatives-library 8.0.266-alpha.0 → 8.0.266
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/assets/Android.png +0 -0
- package/assets/iOS.png +0 -0
- package/constants/unified.js +2 -2
- package/initialReducer.js +0 -2
- package/package.json +1 -1
- package/services/api.js +5 -10
- package/services/tests/api.test.js +0 -34
- package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +35 -17
- package/tests/integration/TemplateCreation/api-response.js +1 -31
- package/tests/integration/TemplateCreation/msw-handler.js +0 -2
- package/utils/common.js +6 -5
- package/utils/commonUtils.js +5 -28
- package/utils/imageUrlUpload.js +141 -0
- package/utils/tests/commonUtil.test.js +0 -224
- package/utils/tests/transformerUtils.test.js +297 -0
- package/utils/transformTemplateConfig.js +10 -0
- package/utils/transformerUtils.js +40 -0
- package/v2Components/CapDeviceContent/index.js +56 -61
- package/v2Components/CapImageUpload/constants.js +2 -0
- package/v2Components/CapImageUpload/index.js +65 -16
- package/v2Components/CapImageUpload/index.scss +4 -1
- package/v2Components/CapImageUpload/messages.js +5 -1
- package/v2Components/CapImageUrlUpload/constants.js +26 -0
- package/v2Components/CapImageUrlUpload/index.js +365 -0
- package/v2Components/CapImageUrlUpload/index.scss +35 -0
- package/v2Components/CapImageUrlUpload/messages.js +47 -0
- package/v2Components/CapTagList/index.js +1 -6
- package/v2Components/CapTagListWithInput/index.js +1 -5
- package/v2Components/CapTagListWithInput/messages.js +1 -1
- package/v2Components/CapWhatsappCTA/tests/index.test.js +0 -5
- package/v2Components/ErrorInfoNote/index.js +72 -402
- package/v2Components/ErrorInfoNote/messages.js +6 -32
- package/v2Components/ErrorInfoNote/style.scss +6 -278
- package/v2Components/FormBuilder/tests/index.test.js +4 -13
- package/v2Components/HtmlEditor/HTMLEditor.js +99 -418
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +133 -1882
- package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +16 -27
- package/v2Components/HtmlEditor/_htmlEditor.scss +45 -108
- package/v2Components/HtmlEditor/_index.lazy.scss +1 -0
- package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +102 -23
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +140 -148
- package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +1 -2
- package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
- package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +1 -9
- package/v2Components/HtmlEditor/components/EditorToolbar/index.js +6 -31
- package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +0 -22
- package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +7 -4
- package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +45 -35
- package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +3 -1
- package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
- package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +6 -7
- package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +10 -7
- package/v2Components/HtmlEditor/components/PreviewPane/index.js +43 -22
- package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +152 -0
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/_validationErrorDisplay.scss +0 -18
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +31 -36
- package/v2Components/HtmlEditor/components/ValidationPanel/_validationPanel.scss +34 -46
- package/v2Components/HtmlEditor/components/ValidationPanel/index.js +46 -52
- package/v2Components/HtmlEditor/constants.js +20 -45
- package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +16 -373
- package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +16 -351
- package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
- package/v2Components/HtmlEditor/hooks/useInAppContent.js +146 -88
- package/v2Components/HtmlEditor/hooks/useValidation.js +56 -213
- package/v2Components/HtmlEditor/index.js +1 -1
- package/v2Components/HtmlEditor/messages.js +94 -102
- package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +45 -214
- package/v2Components/HtmlEditor/utils/__tests__/validationAdapter.test.js +0 -134
- package/v2Components/HtmlEditor/utils/contentSanitizer.js +41 -40
- package/v2Components/HtmlEditor/utils/htmlValidator.js +72 -71
- package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +124 -158
- package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +25 -23
- package/v2Components/HtmlEditor/utils/validationAdapter.js +41 -66
- package/v2Components/MobilePushPreviewV2/index.js +7 -33
- package/v2Components/TemplatePreview/_templatePreview.scss +24 -55
- package/v2Components/TemplatePreview/index.js +32 -47
- package/v2Components/TemplatePreview/messages.js +0 -4
- package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +0 -1
- package/v2Containers/App/constants.js +5 -0
- package/v2Containers/BeeEditor/index.js +90 -172
- package/v2Containers/CreativesContainer/SlideBoxContent.js +108 -129
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +13 -163
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -2
- package/v2Containers/CreativesContainer/constants.js +3 -1
- package/v2Containers/CreativesContainer/index.js +214 -240
- package/v2Containers/CreativesContainer/messages.js +4 -8
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +210 -0
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +2 -11
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +354 -38
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -103
- package/v2Containers/Email/actions.js +0 -7
- package/v2Containers/Email/constants.js +1 -5
- package/v2Containers/Email/index.js +29 -234
- package/v2Containers/Email/messages.js +0 -32
- package/v2Containers/Email/reducer.js +1 -12
- package/v2Containers/Email/sagas.js +7 -61
- package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +0 -2
- package/v2Containers/Email/tests/reducer.test.js +0 -46
- package/v2Containers/Email/tests/sagas.test.js +29 -320
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +21 -211
- package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +74 -40
- package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +67 -2
- package/v2Containers/EmailWrapper/constants.js +0 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +77 -629
- package/v2Containers/EmailWrapper/index.js +23 -103
- package/v2Containers/EmailWrapper/messages.js +1 -65
- package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +214 -0
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +77 -594
- package/v2Containers/InApp/actions.js +0 -7
- package/v2Containers/InApp/constants.js +4 -20
- package/v2Containers/InApp/index.js +359 -802
- package/v2Containers/InApp/index.scss +3 -4
- package/v2Containers/InApp/messages.js +3 -7
- package/v2Containers/InApp/reducer.js +3 -21
- package/v2Containers/InApp/sagas.js +9 -29
- package/v2Containers/InApp/selectors.js +5 -25
- package/v2Containers/InApp/tests/index.test.js +50 -154
- package/v2Containers/InApp/tests/reducer.test.js +0 -34
- package/v2Containers/InApp/tests/sagas.test.js +9 -61
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -2
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -9
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -12
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -4
- package/v2Containers/TagList/index.js +19 -62
- package/v2Containers/Templates/ChannelTypeIllustration.js +13 -1
- package/v2Containers/Templates/_templates.scss +202 -56
- package/v2Containers/Templates/actions.js +2 -1
- package/v2Containers/Templates/constants.js +1 -0
- package/v2Containers/Templates/index.js +278 -123
- package/v2Containers/Templates/messages.js +24 -4
- package/v2Containers/Templates/reducer.js +2 -0
- package/v2Containers/Templates/tests/index.test.js +10 -0
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +2 -4
- package/v2Containers/TemplatesV2/index.js +15 -7
- package/v2Containers/TemplatesV2/messages.js +4 -0
- package/v2Containers/WebPush/Create/components/BrandIconSection.js +108 -0
- package/v2Containers/WebPush/Create/components/ButtonForm.js +172 -0
- package/v2Containers/WebPush/Create/components/ButtonItem.js +101 -0
- package/v2Containers/WebPush/Create/components/ButtonList.js +145 -0
- package/v2Containers/WebPush/Create/components/ButtonsLinksSection.js +164 -0
- package/v2Containers/WebPush/Create/components/ButtonsLinksSection.test.js +463 -0
- package/v2Containers/WebPush/Create/components/FormActions.js +54 -0
- package/v2Containers/WebPush/Create/components/FormActions.test.js +163 -0
- package/v2Containers/WebPush/Create/components/MediaSection.js +142 -0
- package/v2Containers/WebPush/Create/components/MediaSection.test.js +341 -0
- package/v2Containers/WebPush/Create/components/MessageSection.js +103 -0
- package/v2Containers/WebPush/Create/components/MessageSection.test.js +268 -0
- package/v2Containers/WebPush/Create/components/NotificationTitleSection.js +87 -0
- package/v2Containers/WebPush/Create/components/NotificationTitleSection.test.js +210 -0
- package/v2Containers/WebPush/Create/components/TemplateNameSection.js +54 -0
- package/v2Containers/WebPush/Create/components/TemplateNameSection.test.js +143 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/ButtonsLinksSection.test.js.snap +86 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/FormActions.test.js.snap +16 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/MediaSection.test.js.snap +41 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +54 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/NotificationTitleSection.test.js.snap +37 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/TemplateNameSection.test.js.snap +21 -0
- package/v2Containers/WebPush/Create/components/_buttons.scss +246 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +554 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +607 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +633 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +666 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +74 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +78 -0
- package/v2Containers/WebPush/Create/hooks/useButtonManagement.js +138 -0
- package/v2Containers/WebPush/Create/hooks/useButtonManagement.test.js +406 -0
- package/v2Containers/WebPush/Create/hooks/useCharacterCount.js +30 -0
- package/v2Containers/WebPush/Create/hooks/useCharacterCount.test.js +151 -0
- package/v2Containers/WebPush/Create/hooks/useImageUpload.js +104 -0
- package/v2Containers/WebPush/Create/hooks/useImageUpload.test.js +538 -0
- package/v2Containers/WebPush/Create/hooks/useTagManagement.js +122 -0
- package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +633 -0
- package/v2Containers/WebPush/Create/index.js +1148 -0
- package/v2Containers/WebPush/Create/index.scss +134 -0
- package/v2Containers/WebPush/Create/messages.js +211 -0
- package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +228 -0
- package/v2Containers/WebPush/Create/preview/NotificationContainer.js +294 -0
- package/v2Containers/WebPush/Create/preview/PreviewContent.js +90 -0
- package/v2Containers/WebPush/Create/preview/PreviewControls.js +305 -0
- package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +25 -0
- package/v2Containers/WebPush/Create/preview/WebPushPreview.js +156 -0
- package/v2Containers/WebPush/Create/preview/assets/Light.svg +53 -0
- package/v2Containers/WebPush/Create/preview/assets/Top.svg +5 -0
- package/v2Containers/WebPush/Create/preview/assets/android-arrow-down.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/android-arrow-up.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/chrome-icon.png +0 -0
- package/v2Containers/WebPush/Create/preview/assets/edge-icon.png +0 -0
- package/v2Containers/WebPush/Create/preview/assets/firefox-icon.svg +106 -0
- package/v2Containers/WebPush/Create/preview/assets/iOS.svg +26 -0
- package/v2Containers/WebPush/Create/preview/assets/macos-arrow-down-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/macos-triple-dot-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +18 -0
- package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +29 -0
- package/v2Containers/WebPush/Create/preview/assets/windows-close-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/windows-triple-dot-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +51 -0
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +145 -0
- package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +45 -0
- package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +68 -0
- package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +61 -0
- package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +99 -0
- package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +733 -0
- package/v2Containers/WebPush/Create/preview/components/tests/WindowsChromeExpanded.test.js +571 -0
- package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +85 -0
- package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/WindowsChromeExpanded.test.js.snap +81 -0
- package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +50 -0
- package/v2Containers/WebPush/Create/preview/constants.js +637 -0
- package/v2Containers/WebPush/Create/preview/notification-container.scss +79 -0
- package/v2Containers/WebPush/Create/preview/preview.scss +358 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +370 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +47 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_base.scss +207 -0
- package/v2Containers/WebPush/Create/preview/styles/_ios.scss +153 -0
- package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +107 -0
- package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +101 -0
- package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +229 -0
- package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +906 -0
- package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +1081 -0
- package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +723 -0
- package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +1327 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +131 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +112 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +144 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +129 -0
- package/v2Containers/WebPush/Create/utils/payloadBuilder.js +96 -0
- package/v2Containers/WebPush/Create/utils/payloadBuilder.test.js +396 -0
- package/v2Containers/WebPush/Create/utils/previewUtils.js +89 -0
- package/v2Containers/WebPush/Create/utils/urlValidation.js +115 -0
- package/v2Containers/WebPush/Create/utils/urlValidation.test.js +449 -0
- package/v2Containers/WebPush/Create/utils/validation.js +75 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +283 -0
- package/v2Containers/WebPush/actions.js +60 -0
- package/v2Containers/WebPush/constants.js +132 -0
- package/v2Containers/WebPush/index.js +2 -0
- package/v2Containers/WebPush/reducer.js +104 -0
- package/v2Containers/WebPush/sagas.js +119 -0
- package/v2Containers/WebPush/selectors.js +65 -0
- package/v2Containers/WebPush/tests/reducer.test.js +863 -0
- package/v2Containers/WebPush/tests/sagas.test.js +566 -0
- package/v2Containers/WebPush/tests/selectors.test.js +960 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +0 -34
- package/v2Components/ErrorInfoNote/constants.js +0 -1
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +0 -870
- package/v2Components/HtmlEditor/components/ValidationPanel/constants.js +0 -6
- package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +0 -277
- package/v2Components/HtmlEditor/components/ValidationTabs/index.js +0 -295
- package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +0 -51
- package/v2Components/HtmlEditor/utils/validationConstants.js +0 -38
- package/v2Components/MobilePushPreviewV2/constants.js +0 -6
- package/v2Containers/BeePopupEditor/_beePopupEditor.scss +0 -14
- package/v2Containers/BeePopupEditor/constants.js +0 -10
- package/v2Containers/BeePopupEditor/index.js +0 -194
- package/v2Containers/BeePopupEditor/tests/index.test.js +0 -627
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1246
- package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +0 -2472
- package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +0 -520
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +0 -956
- package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +0 -376
- package/v2Containers/InApp/__tests__/sagas.test.js +0 -363
- package/v2Containers/InApp/tests/selectors.test.js +0 -612
- package/v2Containers/InAppWrapper/components/InAppWrapperView.js +0 -151
- package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +0 -267
- package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +0 -23
- package/v2Containers/InAppWrapper/constants.js +0 -16
- package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +0 -473
- package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +0 -198
- package/v2Containers/InAppWrapper/index.js +0 -148
- package/v2Containers/InAppWrapper/messages.js +0 -49
- package/v2Containers/InappAdvance/index.js +0 -1099
- package/v2Containers/InappAdvance/index.scss +0 -10
- package/v2Containers/InappAdvance/tests/index.test.js +0 -448
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
5
|
+
import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
6
|
+
import ButtonItem from './ButtonItem';
|
|
7
|
+
import messages from '../messages';
|
|
8
|
+
|
|
9
|
+
const ButtonList = ({
|
|
10
|
+
buttons,
|
|
11
|
+
onEdit,
|
|
12
|
+
onDelete,
|
|
13
|
+
onReorder,
|
|
14
|
+
onAddPrimary,
|
|
15
|
+
onAddSecondary,
|
|
16
|
+
showAddPrimary,
|
|
17
|
+
showAddSecondary,
|
|
18
|
+
disabled,
|
|
19
|
+
disableSecondaryButton,
|
|
20
|
+
isInlineFormVisible,
|
|
21
|
+
inlineFormIndex,
|
|
22
|
+
renderInlineForm,
|
|
23
|
+
}) => {
|
|
24
|
+
const [draggedIndex, setDraggedIndex] = useState(null);
|
|
25
|
+
|
|
26
|
+
const handleDragStart = (index) => {
|
|
27
|
+
if (disabled) return;
|
|
28
|
+
setDraggedIndex(index);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const handleDragOver = (index) => {
|
|
32
|
+
if (disabled) return;
|
|
33
|
+
if (draggedIndex === null || draggedIndex === index) return;
|
|
34
|
+
|
|
35
|
+
// Reorder buttons
|
|
36
|
+
onReorder(draggedIndex, index);
|
|
37
|
+
setDraggedIndex(index);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleDrop = () => {
|
|
41
|
+
if (disabled) return;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const handleDragEnd = () => {
|
|
45
|
+
if (disabled) return;
|
|
46
|
+
setDraggedIndex(null);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const shouldRenderInlineForm = isInlineFormVisible
|
|
50
|
+
&& typeof inlineFormIndex === 'number'
|
|
51
|
+
&& inlineFormIndex >= 0;
|
|
52
|
+
|
|
53
|
+
// Don't render the container if there are no buttons
|
|
54
|
+
if (buttons.length === 0) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="webpush-button-list">
|
|
60
|
+
{buttons.map((button, index) => {
|
|
61
|
+
if (shouldRenderInlineForm && inlineFormIndex === index && typeof renderInlineForm === 'function') {
|
|
62
|
+
return (
|
|
63
|
+
<div key={`button-inline-form-${button.id}`} className="button-inline-form">
|
|
64
|
+
{renderInlineForm()}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
// Only disable items that are not being edited
|
|
69
|
+
const isItemDisabled = disabled || (isInlineFormVisible && inlineFormIndex !== null && inlineFormIndex !== index);
|
|
70
|
+
return (
|
|
71
|
+
<ButtonItem
|
|
72
|
+
key={button.id}
|
|
73
|
+
button={button}
|
|
74
|
+
index={index}
|
|
75
|
+
onEdit={onEdit}
|
|
76
|
+
onDelete={onDelete}
|
|
77
|
+
onDragStart={handleDragStart}
|
|
78
|
+
onDragOver={handleDragOver}
|
|
79
|
+
onDrop={handleDrop}
|
|
80
|
+
onDragEnd={handleDragEnd}
|
|
81
|
+
disabled={isItemDisabled}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
})}
|
|
85
|
+
{showAddPrimary && (
|
|
86
|
+
<CapRow className="button-list-add-button">
|
|
87
|
+
<CapButton
|
|
88
|
+
type="flat"
|
|
89
|
+
onClick={onAddPrimary}
|
|
90
|
+
className="add-primary-button button-add-trigger"
|
|
91
|
+
icon="plus"
|
|
92
|
+
disabled={disabled}
|
|
93
|
+
>
|
|
94
|
+
<FormattedMessage {...messages.addPrimaryButton} />
|
|
95
|
+
</CapButton>
|
|
96
|
+
</CapRow>
|
|
97
|
+
)}
|
|
98
|
+
{showAddSecondary && (
|
|
99
|
+
<CapRow className="button-list-add-button">
|
|
100
|
+
<CapButton
|
|
101
|
+
type="flat"
|
|
102
|
+
onClick={onAddSecondary}
|
|
103
|
+
className="add-secondary-button button-add-trigger"
|
|
104
|
+
icon="plus"
|
|
105
|
+
disabled={disableSecondaryButton || disabled}
|
|
106
|
+
>
|
|
107
|
+
<FormattedMessage {...messages.addSecondaryButton} />
|
|
108
|
+
</CapButton>
|
|
109
|
+
</CapRow>
|
|
110
|
+
)}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
ButtonList.propTypes = {
|
|
116
|
+
buttons: PropTypes.arrayOf(PropTypes.shape({
|
|
117
|
+
id: PropTypes.string.isRequired,
|
|
118
|
+
text: PropTypes.string.isRequired,
|
|
119
|
+
url: PropTypes.string.isRequired,
|
|
120
|
+
type: PropTypes.string.isRequired,
|
|
121
|
+
})).isRequired,
|
|
122
|
+
onEdit: PropTypes.func.isRequired,
|
|
123
|
+
onDelete: PropTypes.func.isRequired,
|
|
124
|
+
onReorder: PropTypes.func.isRequired,
|
|
125
|
+
onAddPrimary: PropTypes.func.isRequired,
|
|
126
|
+
onAddSecondary: PropTypes.func.isRequired,
|
|
127
|
+
showAddPrimary: PropTypes.bool.isRequired,
|
|
128
|
+
showAddSecondary: PropTypes.bool.isRequired,
|
|
129
|
+
disabled: PropTypes.bool,
|
|
130
|
+
disableSecondaryButton: PropTypes.bool,
|
|
131
|
+
isInlineFormVisible: PropTypes.bool,
|
|
132
|
+
inlineFormIndex: PropTypes.number,
|
|
133
|
+
renderInlineForm: PropTypes.func,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
ButtonList.defaultProps = {
|
|
137
|
+
disabled: false,
|
|
138
|
+
disableSecondaryButton: false,
|
|
139
|
+
isInlineFormVisible: false,
|
|
140
|
+
inlineFormIndex: null,
|
|
141
|
+
renderInlineForm: null,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export default ButtonList;
|
|
145
|
+
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
5
|
+
import CapHeading from '@capillarytech/cap-ui-library/CapHeading';
|
|
6
|
+
import CapRadioGroup from '@capillarytech/cap-ui-library/CapRadioGroup';
|
|
7
|
+
import CapInput from '@capillarytech/cap-ui-library/CapInput';
|
|
8
|
+
import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
9
|
+
import ButtonList from './ButtonList';
|
|
10
|
+
import ButtonForm from './ButtonForm';
|
|
11
|
+
import { ON_CLICK_BEHAVIOUR_OPTIONS } from '../../constants';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* ButtonsLinksSection component - On-click behavior and CTA buttons management
|
|
15
|
+
*/
|
|
16
|
+
export const ButtonsLinksSection = ({
|
|
17
|
+
onClickBehaviour,
|
|
18
|
+
onClickBehaviourOptions,
|
|
19
|
+
onClickBehaviourChange,
|
|
20
|
+
redirectUrl,
|
|
21
|
+
redirectUrlError,
|
|
22
|
+
onRedirectUrlChange,
|
|
23
|
+
buttonState,
|
|
24
|
+
formatMessage,
|
|
25
|
+
messages,
|
|
26
|
+
}) => {
|
|
27
|
+
const {
|
|
28
|
+
buttons,
|
|
29
|
+
isAddingButton,
|
|
30
|
+
buttonBeingAdded,
|
|
31
|
+
editingButtonIndex,
|
|
32
|
+
handleAddPrimaryButton,
|
|
33
|
+
handleAddSecondaryButton,
|
|
34
|
+
handleButtonSave,
|
|
35
|
+
handleButtonCancel,
|
|
36
|
+
handleButtonEdit,
|
|
37
|
+
handleButtonDelete,
|
|
38
|
+
handleButtonReorder,
|
|
39
|
+
isAddFlow,
|
|
40
|
+
isEditFlow,
|
|
41
|
+
showAddPrimaryButton,
|
|
42
|
+
showAddSecondaryButton,
|
|
43
|
+
showDisabledSecondaryDuringPrimary,
|
|
44
|
+
disableSecondaryAddButton,
|
|
45
|
+
} = buttonState;
|
|
46
|
+
|
|
47
|
+
const renderButtonForm = (isEditMode) => (
|
|
48
|
+
<ButtonForm
|
|
49
|
+
buttonType={buttonBeingAdded}
|
|
50
|
+
formatMessage={formatMessage}
|
|
51
|
+
onSave={handleButtonSave}
|
|
52
|
+
onCancel={handleButtonCancel}
|
|
53
|
+
initialData={isEditMode && editingButtonIndex !== null ? buttons[editingButtonIndex] : null}
|
|
54
|
+
isEditMode={isEditMode}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
<CapRow className="creatives-webpush-buttons-links">
|
|
61
|
+
<CapHeading type="h4" className="webpush-buttons-links">
|
|
62
|
+
<FormattedMessage {...messages.buttonsAndLinks} />
|
|
63
|
+
</CapHeading>
|
|
64
|
+
<CapHeading type="h5" className="webpush-on-click-behaviour">
|
|
65
|
+
<FormattedMessage {...messages.onClickBehaviour} />
|
|
66
|
+
</CapHeading>
|
|
67
|
+
<CapRadioGroup
|
|
68
|
+
options={onClickBehaviourOptions}
|
|
69
|
+
value={onClickBehaviour}
|
|
70
|
+
onChange={onClickBehaviourChange}
|
|
71
|
+
/>
|
|
72
|
+
{onClickBehaviour === ON_CLICK_BEHAVIOUR_OPTIONS.REDIRECT_TO_URL && (
|
|
73
|
+
<CapInput
|
|
74
|
+
id="webpush-redirect-url-input"
|
|
75
|
+
className="webpush-redirect-url-input"
|
|
76
|
+
placeholder={formatMessage(messages.enterUrl)}
|
|
77
|
+
value={redirectUrl}
|
|
78
|
+
onChange={onRedirectUrlChange}
|
|
79
|
+
size="default"
|
|
80
|
+
status={redirectUrlError ? 'error' : ''}
|
|
81
|
+
help={redirectUrlError || ''}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
</CapRow>
|
|
85
|
+
<CapRow className="creatives-webpush-buttons-section">
|
|
86
|
+
<CapHeading type="h5" className="webpush-buttons-section-heading">
|
|
87
|
+
<FormattedMessage {...messages.buttons} />{' '}
|
|
88
|
+
<span className="optional-text">
|
|
89
|
+
<FormattedMessage {...messages.optional} />
|
|
90
|
+
</span>
|
|
91
|
+
</CapHeading>
|
|
92
|
+
<ButtonList
|
|
93
|
+
buttons={buttons}
|
|
94
|
+
onEdit={handleButtonEdit}
|
|
95
|
+
onDelete={handleButtonDelete}
|
|
96
|
+
onReorder={handleButtonReorder}
|
|
97
|
+
onAddPrimary={handleAddPrimaryButton}
|
|
98
|
+
onAddSecondary={handleAddSecondaryButton}
|
|
99
|
+
showAddPrimary={false}
|
|
100
|
+
showAddSecondary={false}
|
|
101
|
+
disabled={isAddFlow}
|
|
102
|
+
disableSecondaryButton={disableSecondaryAddButton}
|
|
103
|
+
isInlineFormVisible={isEditFlow}
|
|
104
|
+
inlineFormIndex={isEditFlow ? editingButtonIndex : null}
|
|
105
|
+
renderInlineForm={isEditFlow ? () => renderButtonForm(true) : null}
|
|
106
|
+
/>
|
|
107
|
+
{isAddFlow && buttonBeingAdded && renderButtonForm(false)}
|
|
108
|
+
{(showAddPrimaryButton || showAddSecondaryButton || showDisabledSecondaryDuringPrimary) && (
|
|
109
|
+
<div className="button-add-controls">
|
|
110
|
+
{showAddPrimaryButton && (
|
|
111
|
+
<CapButton
|
|
112
|
+
type="flat"
|
|
113
|
+
onClick={handleAddPrimaryButton}
|
|
114
|
+
className="add-primary-button button-add-trigger"
|
|
115
|
+
icon="plus"
|
|
116
|
+
>
|
|
117
|
+
<FormattedMessage {...messages.addButton} />
|
|
118
|
+
</CapButton>
|
|
119
|
+
)}
|
|
120
|
+
{showAddSecondaryButton && (
|
|
121
|
+
<CapButton
|
|
122
|
+
type="flat"
|
|
123
|
+
onClick={handleAddSecondaryButton}
|
|
124
|
+
className="add-secondary-button button-add-trigger"
|
|
125
|
+
icon="plus"
|
|
126
|
+
>
|
|
127
|
+
<FormattedMessage {...messages.addButton} />
|
|
128
|
+
</CapButton>
|
|
129
|
+
)}
|
|
130
|
+
{showDisabledSecondaryDuringPrimary && (
|
|
131
|
+
<CapButton
|
|
132
|
+
type="flat"
|
|
133
|
+
className="add-secondary-button button-add-trigger"
|
|
134
|
+
icon="plus"
|
|
135
|
+
disabled
|
|
136
|
+
>
|
|
137
|
+
<FormattedMessage {...messages.addButton} />
|
|
138
|
+
</CapButton>
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
142
|
+
</CapRow>
|
|
143
|
+
</>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
ButtonsLinksSection.propTypes = {
|
|
148
|
+
onClickBehaviour: PropTypes.string.isRequired,
|
|
149
|
+
onClickBehaviourOptions: PropTypes.array.isRequired,
|
|
150
|
+
onClickBehaviourChange: PropTypes.func.isRequired,
|
|
151
|
+
redirectUrl: PropTypes.string.isRequired,
|
|
152
|
+
redirectUrlError: PropTypes.string,
|
|
153
|
+
onRedirectUrlChange: PropTypes.func.isRequired,
|
|
154
|
+
buttonState: PropTypes.object.isRequired,
|
|
155
|
+
formatMessage: PropTypes.func.isRequired,
|
|
156
|
+
messages: PropTypes.object.isRequired,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
ButtonsLinksSection.defaultProps = {
|
|
160
|
+
redirectUrlError: '',
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export default ButtonsLinksSection;
|
|
164
|
+
|