@capillarytech/creatives-library 8.0.250-alpha.2 → 8.0.251

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/assets/Android.png +0 -0
  2. package/assets/iOS.png +0 -0
  3. package/constants/unified.js +1 -3
  4. package/initialReducer.js +0 -2
  5. package/package.json +1 -1
  6. package/services/api.js +0 -15
  7. package/services/tests/api.test.js +0 -34
  8. package/translations/en.json +3 -4
  9. package/utils/common.js +0 -11
  10. package/utils/commonUtils.js +5 -28
  11. package/utils/tests/commonUtil.test.js +0 -224
  12. package/utils/tests/transformerUtils.test.js +0 -297
  13. package/utils/transformTemplateConfig.js +10 -0
  14. package/utils/transformerUtils.js +0 -40
  15. package/v2Components/CapDeviceContent/index.js +56 -61
  16. package/v2Components/CapImageUpload/constants.js +0 -2
  17. package/v2Components/CapImageUpload/index.js +16 -65
  18. package/v2Components/CapImageUpload/index.scss +1 -4
  19. package/v2Components/CapImageUpload/messages.js +1 -5
  20. package/v2Components/CapTagList/index.js +1 -6
  21. package/v2Components/CapTagListWithInput/index.js +1 -5
  22. package/v2Components/CapTagListWithInput/messages.js +1 -1
  23. package/v2Components/CapWhatsappCTA/tests/index.test.js +0 -5
  24. package/v2Components/ErrorInfoNote/index.js +72 -455
  25. package/v2Components/ErrorInfoNote/messages.js +6 -36
  26. package/v2Components/ErrorInfoNote/style.scss +4 -280
  27. package/v2Components/FormBuilder/tests/index.test.js +4 -13
  28. package/v2Components/HtmlEditor/HTMLEditor.js +94 -547
  29. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +133 -1358
  30. package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +16 -27
  31. package/v2Components/HtmlEditor/_htmlEditor.scss +45 -108
  32. package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
  33. package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +101 -22
  34. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +140 -146
  35. package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +1 -2
  36. package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
  37. package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +0 -9
  38. package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
  39. package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +0 -22
  40. package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +7 -4
  41. package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +45 -35
  42. package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +3 -1
  43. package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
  44. package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +6 -7
  45. package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +6 -3
  46. package/v2Components/HtmlEditor/components/PreviewPane/index.js +34 -24
  47. package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
  48. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +152 -0
  49. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +31 -49
  50. package/v2Components/HtmlEditor/components/ValidationPanel/_validationPanel.scss +34 -50
  51. package/v2Components/HtmlEditor/components/ValidationPanel/index.js +41 -70
  52. package/v2Components/HtmlEditor/constants.js +20 -42
  53. package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +16 -373
  54. package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
  55. package/v2Components/HtmlEditor/hooks/useInAppContent.js +146 -88
  56. package/v2Components/HtmlEditor/hooks/useValidation.js +53 -189
  57. package/v2Components/HtmlEditor/index.js +1 -1
  58. package/v2Components/HtmlEditor/messages.js +85 -95
  59. package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +45 -94
  60. package/v2Components/HtmlEditor/utils/__tests__/validationAdapter.test.js +0 -134
  61. package/v2Components/HtmlEditor/utils/contentSanitizer.js +41 -40
  62. package/v2Components/HtmlEditor/utils/htmlValidator.js +72 -71
  63. package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +102 -134
  64. package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +25 -23
  65. package/v2Components/HtmlEditor/utils/validationAdapter.js +41 -66
  66. package/v2Components/MobilePushPreviewV2/index.js +7 -32
  67. package/v2Components/TemplatePreview/_templatePreview.scss +24 -55
  68. package/v2Components/TemplatePreview/index.js +32 -47
  69. package/v2Components/TemplatePreview/messages.js +0 -4
  70. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +0 -1
  71. package/v2Containers/App/constants.js +0 -5
  72. package/v2Containers/BeeEditor/index.js +90 -172
  73. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +3 -4
  74. package/v2Containers/CreativesContainer/SlideBoxContent.js +53 -184
  75. package/v2Containers/CreativesContainer/SlideBoxFooter.js +13 -163
  76. package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -3
  77. package/v2Containers/CreativesContainer/constants.js +0 -4
  78. package/v2Containers/CreativesContainer/index.js +46 -407
  79. package/v2Containers/CreativesContainer/messages.js +0 -12
  80. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -210
  81. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +2 -11
  82. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +50 -342
  83. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -106
  84. package/v2Containers/Email/actions.js +0 -7
  85. package/v2Containers/Email/constants.js +1 -5
  86. package/v2Containers/Email/index.js +29 -234
  87. package/v2Containers/Email/messages.js +0 -32
  88. package/v2Containers/Email/reducer.js +1 -12
  89. package/v2Containers/Email/sagas.js +7 -61
  90. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +0 -2
  91. package/v2Containers/Email/tests/reducer.test.js +0 -46
  92. package/v2Containers/Email/tests/sagas.test.js +29 -320
  93. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +19 -207
  94. package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +74 -40
  95. package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +67 -2
  96. package/v2Containers/EmailWrapper/constants.js +0 -2
  97. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +77 -629
  98. package/v2Containers/EmailWrapper/index.js +23 -103
  99. package/v2Containers/EmailWrapper/messages.js +1 -61
  100. package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +214 -0
  101. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +77 -594
  102. package/v2Containers/InApp/actions.js +0 -7
  103. package/v2Containers/InApp/constants.js +4 -20
  104. package/v2Containers/InApp/index.js +359 -802
  105. package/v2Containers/InApp/index.scss +3 -4
  106. package/v2Containers/InApp/messages.js +3 -7
  107. package/v2Containers/InApp/reducer.js +3 -21
  108. package/v2Containers/InApp/sagas.js +9 -29
  109. package/v2Containers/InApp/selectors.js +5 -25
  110. package/v2Containers/InApp/tests/index.test.js +50 -154
  111. package/v2Containers/InApp/tests/reducer.test.js +0 -34
  112. package/v2Containers/InApp/tests/sagas.test.js +9 -61
  113. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +9 -15
  114. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +6 -10
  115. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +75 -102
  116. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +54 -81
  117. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +174 -244
  118. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +12 -16
  119. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +36 -52
  120. package/v2Containers/TagList/index.js +19 -62
  121. package/v2Containers/Templates/ChannelTypeIllustration.js +1 -13
  122. package/v2Containers/Templates/_templates.scss +1 -265
  123. package/v2Containers/Templates/actions.js +1 -2
  124. package/v2Containers/Templates/constants.js +0 -1
  125. package/v2Containers/Templates/index.js +38 -363
  126. package/v2Containers/Templates/messages.js +0 -28
  127. package/v2Containers/Templates/reducer.js +0 -4
  128. package/v2Containers/Templates/tests/index.test.js +0 -10
  129. package/v2Containers/TemplatesV2/index.js +7 -15
  130. package/v2Containers/TemplatesV2/messages.js +0 -4
  131. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +486 -682
  132. package/utils/imageUrlUpload.js +0 -141
  133. package/v2Components/CapImageUrlUpload/constants.js +0 -26
  134. package/v2Components/CapImageUrlUpload/index.js +0 -365
  135. package/v2Components/CapImageUrlUpload/index.scss +0 -35
  136. package/v2Components/CapImageUrlUpload/messages.js +0 -47
  137. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +0 -874
  138. package/v2Components/HtmlEditor/components/ValidationPanel/constants.js +0 -6
  139. package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +0 -254
  140. package/v2Components/HtmlEditor/components/ValidationTabs/index.js +0 -364
  141. package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +0 -51
  142. package/v2Components/HtmlEditor/hooks/__tests__/useValidation.apiErrors.test.js +0 -795
  143. package/v2Components/HtmlEditor/utils/validationConstants.js +0 -40
  144. package/v2Containers/BeePopupEditor/_beePopupEditor.scss +0 -14
  145. package/v2Containers/BeePopupEditor/constants.js +0 -10
  146. package/v2Containers/BeePopupEditor/index.js +0 -194
  147. package/v2Containers/BeePopupEditor/tests/index.test.js +0 -627
  148. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1285
  149. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +0 -1870
  150. package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +0 -520
  151. package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +0 -643
  152. package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +0 -376
  153. package/v2Containers/InApp/__tests__/sagas.test.js +0 -363
  154. package/v2Containers/InApp/tests/selectors.test.js +0 -612
  155. package/v2Containers/InAppWrapper/components/InAppWrapperView.js +0 -151
  156. package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +0 -267
  157. package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +0 -23
  158. package/v2Containers/InAppWrapper/constants.js +0 -16
  159. package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +0 -473
  160. package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +0 -198
  161. package/v2Containers/InAppWrapper/index.js +0 -148
  162. package/v2Containers/InAppWrapper/messages.js +0 -49
  163. package/v2Containers/InappAdvance/index.js +0 -1099
  164. package/v2Containers/InappAdvance/index.scss +0 -10
  165. package/v2Containers/InappAdvance/tests/index.test.js +0 -448
  166. package/v2Containers/WebPush/Create/components/BrandIconSection.js +0 -108
  167. package/v2Containers/WebPush/Create/components/ButtonForm.js +0 -172
  168. package/v2Containers/WebPush/Create/components/ButtonItem.js +0 -101
  169. package/v2Containers/WebPush/Create/components/ButtonList.js +0 -107
  170. package/v2Containers/WebPush/Create/components/ButtonsLinksSection.js +0 -160
  171. package/v2Containers/WebPush/Create/components/ButtonsLinksSection.test.js +0 -476
  172. package/v2Containers/WebPush/Create/components/FormActions.js +0 -54
  173. package/v2Containers/WebPush/Create/components/FormActions.test.js +0 -163
  174. package/v2Containers/WebPush/Create/components/MediaSection.js +0 -143
  175. package/v2Containers/WebPush/Create/components/MediaSection.test.js +0 -341
  176. package/v2Containers/WebPush/Create/components/MessageSection.js +0 -103
  177. package/v2Containers/WebPush/Create/components/MessageSection.test.js +0 -268
  178. package/v2Containers/WebPush/Create/components/NotificationTitleSection.js +0 -87
  179. package/v2Containers/WebPush/Create/components/NotificationTitleSection.test.js +0 -210
  180. package/v2Containers/WebPush/Create/components/TemplateNameSection.js +0 -54
  181. package/v2Containers/WebPush/Create/components/TemplateNameSection.test.js +0 -143
  182. package/v2Containers/WebPush/Create/components/__snapshots__/ButtonsLinksSection.test.js.snap +0 -82
  183. package/v2Containers/WebPush/Create/components/__snapshots__/FormActions.test.js.snap +0 -16
  184. package/v2Containers/WebPush/Create/components/__snapshots__/MediaSection.test.js.snap +0 -41
  185. package/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +0 -54
  186. package/v2Containers/WebPush/Create/components/__snapshots__/NotificationTitleSection.test.js.snap +0 -37
  187. package/v2Containers/WebPush/Create/components/__snapshots__/TemplateNameSection.test.js.snap +0 -21
  188. package/v2Containers/WebPush/Create/components/_buttons.scss +0 -246
  189. package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +0 -554
  190. package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +0 -607
  191. package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +0 -515
  192. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +0 -666
  193. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +0 -74
  194. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +0 -46
  195. package/v2Containers/WebPush/Create/hooks/useButtonManagement.js +0 -150
  196. package/v2Containers/WebPush/Create/hooks/useButtonManagement.test.js +0 -406
  197. package/v2Containers/WebPush/Create/hooks/useCharacterCount.js +0 -30
  198. package/v2Containers/WebPush/Create/hooks/useCharacterCount.test.js +0 -151
  199. package/v2Containers/WebPush/Create/hooks/useImageUpload.js +0 -104
  200. package/v2Containers/WebPush/Create/hooks/useImageUpload.test.js +0 -538
  201. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +0 -122
  202. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -633
  203. package/v2Containers/WebPush/Create/index.js +0 -1148
  204. package/v2Containers/WebPush/Create/index.scss +0 -134
  205. package/v2Containers/WebPush/Create/messages.js +0 -203
  206. package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +0 -228
  207. package/v2Containers/WebPush/Create/preview/NotificationContainer.js +0 -294
  208. package/v2Containers/WebPush/Create/preview/PreviewContent.js +0 -90
  209. package/v2Containers/WebPush/Create/preview/PreviewControls.js +0 -305
  210. package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +0 -23
  211. package/v2Containers/WebPush/Create/preview/WebPushPreview.js +0 -155
  212. package/v2Containers/WebPush/Create/preview/assets/Light.svg +0 -53
  213. package/v2Containers/WebPush/Create/preview/assets/Top.svg +0 -5
  214. package/v2Containers/WebPush/Create/preview/assets/android-arrow-down.svg +0 -9
  215. package/v2Containers/WebPush/Create/preview/assets/android-arrow-up.svg +0 -9
  216. package/v2Containers/WebPush/Create/preview/assets/chrome-icon.png +0 -0
  217. package/v2Containers/WebPush/Create/preview/assets/edge-icon.png +0 -0
  218. package/v2Containers/WebPush/Create/preview/assets/firefox-icon.svg +0 -106
  219. package/v2Containers/WebPush/Create/preview/assets/iOS.svg +0 -26
  220. package/v2Containers/WebPush/Create/preview/assets/macos-arrow-down-icon.svg +0 -9
  221. package/v2Containers/WebPush/Create/preview/assets/macos-triple-dot-icon.svg +0 -9
  222. package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +0 -18
  223. package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +0 -29
  224. package/v2Containers/WebPush/Create/preview/assets/windows-close-icon.svg +0 -9
  225. package/v2Containers/WebPush/Create/preview/assets/windows-triple-dot-icon.svg +0 -9
  226. package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +0 -47
  227. package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +0 -141
  228. package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +0 -45
  229. package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +0 -68
  230. package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +0 -61
  231. package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +0 -99
  232. package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +0 -733
  233. package/v2Containers/WebPush/Create/preview/components/tests/WindowsChromeExpanded.test.js +0 -571
  234. package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +0 -81
  235. package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/WindowsChromeExpanded.test.js.snap +0 -81
  236. package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +0 -50
  237. package/v2Containers/WebPush/Create/preview/constants.js +0 -637
  238. package/v2Containers/WebPush/Create/preview/notification-container.scss +0 -79
  239. package/v2Containers/WebPush/Create/preview/preview.scss +0 -351
  240. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +0 -370
  241. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +0 -12
  242. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +0 -12
  243. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +0 -12
  244. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +0 -47
  245. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +0 -11
  246. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +0 -11
  247. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +0 -11
  248. package/v2Containers/WebPush/Create/preview/styles/_base.scss +0 -207
  249. package/v2Containers/WebPush/Create/preview/styles/_ios.scss +0 -153
  250. package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +0 -107
  251. package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +0 -101
  252. package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +0 -229
  253. package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +0 -909
  254. package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +0 -1081
  255. package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +0 -723
  256. package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +0 -1327
  257. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +0 -131
  258. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +0 -112
  259. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +0 -144
  260. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +0 -129
  261. package/v2Containers/WebPush/Create/utils/payloadBuilder.js +0 -96
  262. package/v2Containers/WebPush/Create/utils/payloadBuilder.test.js +0 -396
  263. package/v2Containers/WebPush/Create/utils/previewUtils.js +0 -89
  264. package/v2Containers/WebPush/Create/utils/urlValidation.js +0 -115
  265. package/v2Containers/WebPush/Create/utils/urlValidation.test.js +0 -449
  266. package/v2Containers/WebPush/Create/utils/validation.js +0 -75
  267. package/v2Containers/WebPush/Create/utils/validation.test.js +0 -283
  268. package/v2Containers/WebPush/actions.js +0 -60
  269. package/v2Containers/WebPush/constants.js +0 -132
  270. package/v2Containers/WebPush/index.js +0 -2
  271. package/v2Containers/WebPush/reducer.js +0 -104
  272. package/v2Containers/WebPush/sagas.js +0 -119
  273. package/v2Containers/WebPush/selectors.js +0 -65
  274. package/v2Containers/WebPush/tests/reducer.test.js +0 -863
  275. package/v2Containers/WebPush/tests/sagas.test.js +0 -566
  276. package/v2Containers/WebPush/tests/selectors.test.js +0 -960
@@ -1,172 +0,0 @@
1
- import React, { useState, useCallback } 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 CapInput from '@capillarytech/cap-ui-library/CapInput';
6
- import CapButton from '@capillarytech/cap-ui-library/CapButton';
7
- import CapHeading from '@capillarytech/cap-ui-library/CapHeading';
8
- import messages from '../messages';
9
- import { isValidHttpUrl } from '../utils/urlValidation';
10
- import { WEBPUSH_BUTTON_TYPES, BUTTON_TEXT_MAX_LENGTH } from '../../constants';
11
-
12
- const ButtonForm = ({
13
- buttonType, // 'primary' or 'secondary'
14
- formatMessage,
15
- onSave,
16
- onCancel,
17
- initialData,
18
- isEditMode,
19
- }) => {
20
- const [buttonText, setButtonText] = useState(initialData?.text || '');
21
- const [buttonUrl, setButtonUrl] = useState(initialData?.url || '');
22
- const [buttonTextError, setButtonTextError] = useState('');
23
- const [buttonUrlError, setButtonUrlError] = useState('');
24
-
25
- const validateButtonText = useCallback((value) => {
26
- if (!value || value.trim() === '') {
27
- return formatMessage(messages.buttonTextRequired);
28
- }
29
- return '';
30
- }, [formatMessage]);
31
-
32
- const validateButtonUrl = useCallback((value) => {
33
- if (!value || value.trim() === '') {
34
- return formatMessage(messages.buttonUrlRequired);
35
- }
36
-
37
- if (!isValidHttpUrl(value)) {
38
- return formatMessage(messages.buttonUrlInvalid);
39
- }
40
-
41
- return '';
42
- }, [formatMessage]);
43
-
44
- const handleButtonTextChange = useCallback((e) => {
45
- const { value } = e.target;
46
- setButtonText(value);
47
- const nextError = validateButtonText(value);
48
- setButtonTextError((prev) => (prev === nextError ? prev : nextError));
49
- }, [validateButtonText]);
50
-
51
- const handleButtonUrlChange = useCallback((e) => {
52
- const { value } = e.target;
53
- setButtonUrl(value);
54
- const nextError = validateButtonUrl(value);
55
- setButtonUrlError((prev) => (prev === nextError ? prev : nextError));
56
- }, [validateButtonUrl]);
57
-
58
- const handleSave = useCallback(() => {
59
- const textError = validateButtonText(buttonText);
60
- const urlError = validateButtonUrl(buttonUrl);
61
-
62
- if (textError || urlError) {
63
- setButtonTextError(textError);
64
- setButtonUrlError(urlError);
65
- return;
66
- }
67
-
68
- onSave({
69
- text: buttonText.trim(),
70
- url: buttonUrl.trim(),
71
- type: buttonType,
72
- });
73
- }, [buttonText, buttonUrl, buttonType, onSave, validateButtonText, validateButtonUrl]);
74
-
75
- const handleCancel = useCallback(() => {
76
- onCancel();
77
- }, [onCancel]);
78
-
79
- const isSaveDisabled = !buttonText.trim() || !buttonUrl.trim() || buttonTextError || buttonUrlError;
80
-
81
- const renderCharacterCountSuffix = () => {
82
- const currentLength = buttonText.length;
83
- const maxLength = BUTTON_TEXT_MAX_LENGTH;
84
-
85
- return (
86
- <span className="button-character-count-suffix">
87
- {`${currentLength}/${maxLength}`}
88
- </span>
89
- );
90
- };
91
-
92
- const handleKeyDown = useCallback((e) => {
93
- if (e.key === 'Enter' && !isSaveDisabled) {
94
- e.preventDefault();
95
- handleSave();
96
- }
97
- }, [handleSave, isSaveDisabled]);
98
-
99
- return (
100
- <div className="webpush-button-form" onKeyDown={handleKeyDown}>
101
- <CapRow className="button-form-row">
102
- <CapHeading type="h4" className="button-form-heading">
103
- <FormattedMessage {...messages.buttonText} />
104
- </CapHeading>
105
- <div className="button-form-field">
106
- <CapInput
107
- id={`webpush-button-text-input-${buttonType}`}
108
- placeholder={formatMessage(messages.buttonTextPlaceholder)}
109
- value={buttonText}
110
- onChange={handleButtonTextChange}
111
- maxLength={BUTTON_TEXT_MAX_LENGTH}
112
- size="default"
113
- status={buttonTextError ? 'error' : ''}
114
- help={buttonTextError || ''}
115
- suffix={renderCharacterCountSuffix()}
116
- />
117
- </div>
118
- </CapRow>
119
- <CapRow className="button-form-row">
120
- <CapHeading type="h4" className="button-form-heading">
121
- <FormattedMessage {...messages.buttonUrlLabel} />
122
- </CapHeading>
123
- <CapInput
124
- id={`webpush-button-url-input-${buttonType}`}
125
- placeholder={formatMessage(messages.buttonUrlPlaceholder)}
126
- value={buttonUrl}
127
- onChange={handleButtonUrlChange}
128
- size="default"
129
- status={buttonUrlError ? 'error' : ''}
130
- help={buttonUrlError || ''}
131
- />
132
- </CapRow>
133
- <CapRow className="button-form-actions">
134
- <CapButton
135
- type="primary"
136
- onClick={handleSave}
137
- disabled={isSaveDisabled}
138
- className="button-form-save"
139
- >
140
- <FormattedMessage {...messages.saveButton} />
141
- </CapButton>
142
- <CapButton
143
- type="secondary"
144
- onClick={handleCancel}
145
- className="button-form-cancel"
146
- >
147
- <FormattedMessage {...(isEditMode ? messages.cancelButton : messages.deleteButton)} />
148
- </CapButton>
149
- </CapRow>
150
- </div>
151
- );
152
- };
153
-
154
- ButtonForm.propTypes = {
155
- buttonType: PropTypes.oneOf([WEBPUSH_BUTTON_TYPES.PRIMARY, WEBPUSH_BUTTON_TYPES.SECONDARY]).isRequired,
156
- formatMessage: PropTypes.func.isRequired,
157
- onSave: PropTypes.func.isRequired,
158
- onCancel: PropTypes.func.isRequired,
159
- initialData: PropTypes.shape({
160
- text: PropTypes.string,
161
- url: PropTypes.string,
162
- }),
163
- isEditMode: PropTypes.bool,
164
- };
165
-
166
- ButtonForm.defaultProps = {
167
- initialData: null,
168
- isEditMode: false,
169
- };
170
-
171
- export default ButtonForm;
172
-
@@ -1,101 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import CapRow from '@capillarytech/cap-ui-library/CapRow';
4
- import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
5
- import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
6
-
7
- const ButtonItem = ({
8
- button,
9
- index,
10
- onEdit,
11
- onDelete,
12
- onDragStart,
13
- onDragOver,
14
- onDrop,
15
- onDragEnd,
16
- disabled,
17
- }) => {
18
- const handleDragStart = (e) => {
19
- if (disabled) return;
20
- e.dataTransfer.effectAllowed = 'move';
21
- e.dataTransfer.setData('text/plain', String(index));
22
- onDragStart(index);
23
- };
24
-
25
- const handleDragOver = (e) => {
26
- if (disabled) return;
27
- e.preventDefault();
28
- e.dataTransfer.dropEffect = 'move';
29
- onDragOver(index);
30
- };
31
-
32
- const handleDrop = (e) => {
33
- if (disabled) return;
34
- e.preventDefault();
35
- e.stopPropagation();
36
- onDrop(index);
37
- };
38
-
39
- return (
40
- <div
41
- className={`webpush-button-item ${disabled ? 'disabled' : ''}`}
42
- draggable={!disabled}
43
- onDragStart={handleDragStart}
44
- onDragOver={handleDragOver}
45
- onDrop={handleDrop}
46
- onDragEnd={onDragEnd}
47
- >
48
- <CapRow align="middle" className="button-item-content">
49
- <CapColumn span={1} className="button-item-drag-handle">
50
- <CapIcon type="drag" className="drag-icon" />
51
- </CapColumn>
52
- <CapColumn span={1} className="button-item-icon">
53
- <CapIcon type="link" className="link-icon" />
54
- </CapColumn>
55
- <CapColumn span={14} className="button-item-info">
56
- <div className="button-item-text-row">
57
- <span className="button-item-text">{button.text}</span>
58
- </div>
59
- </CapColumn>
60
- <CapColumn span={8} className="button-item-actions">
61
- <div className="button-item-url">{button.url}</div>
62
- <div className="action-icons">
63
- <CapIcon
64
- type="edit"
65
- className="action-icon"
66
- onClick={() => !disabled && onEdit(index)}
67
- />
68
- <CapIcon
69
- type="delete"
70
- className="action-icon delete-icon"
71
- onClick={() => !disabled && onDelete(index)}
72
- />
73
- </div>
74
- </CapColumn>
75
- </CapRow>
76
- </div>
77
- );
78
- };
79
-
80
- ButtonItem.propTypes = {
81
- button: PropTypes.shape({
82
- text: PropTypes.string.isRequired,
83
- url: PropTypes.string.isRequired,
84
- type: PropTypes.string.isRequired,
85
- }).isRequired,
86
- index: PropTypes.number.isRequired,
87
- onEdit: PropTypes.func.isRequired,
88
- onDelete: PropTypes.func.isRequired,
89
- onDragStart: PropTypes.func.isRequired,
90
- onDragOver: PropTypes.func.isRequired,
91
- onDrop: PropTypes.func.isRequired,
92
- onDragEnd: PropTypes.func.isRequired,
93
- disabled: PropTypes.bool,
94
- };
95
-
96
- ButtonItem.defaultProps = {
97
- disabled: false,
98
- };
99
-
100
- export default ButtonItem;
101
-
@@ -1,107 +0,0 @@
1
- import React, { useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import ButtonItem from './ButtonItem';
4
-
5
- const ButtonList = ({
6
- buttons,
7
- onEdit,
8
- onDelete,
9
- onReorder,
10
- disabled,
11
- disableSecondaryButton,
12
- isInlineFormVisible,
13
- inlineFormIndex,
14
- renderInlineForm,
15
- }) => {
16
- const [draggedIndex, setDraggedIndex] = useState(null);
17
-
18
- const handleDragStart = (index) => {
19
- if (disabled) return;
20
- setDraggedIndex(index);
21
- };
22
-
23
- const handleDragOver = (index) => {
24
- if (disabled) return;
25
- if (draggedIndex === null || draggedIndex === index) return;
26
-
27
- // Reorder buttons
28
- onReorder(draggedIndex, index);
29
- setDraggedIndex(index);
30
- };
31
-
32
- const handleDrop = () => {
33
- if (disabled) return;
34
- };
35
-
36
- const handleDragEnd = () => {
37
- if (disabled) return;
38
- setDraggedIndex(null);
39
- };
40
-
41
- const shouldRenderInlineForm = isInlineFormVisible
42
- && typeof inlineFormIndex === 'number'
43
- && inlineFormIndex >= 0;
44
-
45
- // Don't render the container if there are no buttons
46
- if (buttons.length === 0) {
47
- return null;
48
- }
49
-
50
- return (
51
- <div className="webpush-button-list">
52
- {buttons.map((button, index) => {
53
- if (shouldRenderInlineForm && inlineFormIndex === index && typeof renderInlineForm === 'function') {
54
- return (
55
- <div key={`button-inline-form-${button.id}`} className="button-inline-form">
56
- {renderInlineForm()}
57
- </div>
58
- );
59
- }
60
- // Only disable items that are not being edited
61
- const isItemDisabled = disabled || (isInlineFormVisible && inlineFormIndex !== null && inlineFormIndex !== index);
62
- return (
63
- <ButtonItem
64
- key={button.id}
65
- button={button}
66
- index={index}
67
- onEdit={onEdit}
68
- onDelete={onDelete}
69
- onDragStart={handleDragStart}
70
- onDragOver={handleDragOver}
71
- onDrop={handleDrop}
72
- onDragEnd={handleDragEnd}
73
- disabled={isItemDisabled}
74
- />
75
- );
76
- })}
77
- </div>
78
- );
79
- };
80
-
81
- ButtonList.propTypes = {
82
- buttons: PropTypes.arrayOf(PropTypes.shape({
83
- id: PropTypes.string.isRequired,
84
- text: PropTypes.string.isRequired,
85
- url: PropTypes.string.isRequired,
86
- type: PropTypes.string.isRequired,
87
- })).isRequired,
88
- onEdit: PropTypes.func.isRequired,
89
- onDelete: PropTypes.func.isRequired,
90
- onReorder: PropTypes.func.isRequired,
91
- disabled: PropTypes.bool,
92
- disableSecondaryButton: PropTypes.bool,
93
- isInlineFormVisible: PropTypes.bool,
94
- inlineFormIndex: PropTypes.number,
95
- renderInlineForm: PropTypes.func,
96
- };
97
-
98
- ButtonList.defaultProps = {
99
- disabled: false,
100
- disableSecondaryButton: false,
101
- isInlineFormVisible: false,
102
- inlineFormIndex: null,
103
- renderInlineForm: null,
104
- };
105
-
106
- export default ButtonList;
107
-
@@ -1,160 +0,0 @@
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
- disabled={isAddFlow}
98
- disableSecondaryButton={disableSecondaryAddButton}
99
- isInlineFormVisible={isEditFlow}
100
- inlineFormIndex={isEditFlow ? editingButtonIndex : null}
101
- renderInlineForm={isEditFlow ? () => renderButtonForm(true) : null}
102
- />
103
- {isAddFlow && buttonBeingAdded && renderButtonForm(false)}
104
- {(showAddPrimaryButton || showAddSecondaryButton || showDisabledSecondaryDuringPrimary) && (
105
- <div className="button-add-controls">
106
- {showAddPrimaryButton && (
107
- <CapButton
108
- type="flat"
109
- onClick={handleAddPrimaryButton}
110
- className="add-primary-button button-add-trigger"
111
- icon="plus"
112
- >
113
- <FormattedMessage {...messages.addButton} />
114
- </CapButton>
115
- )}
116
- {showAddSecondaryButton && (
117
- <CapButton
118
- type="flat"
119
- onClick={handleAddSecondaryButton}
120
- className="add-secondary-button button-add-trigger"
121
- icon="plus"
122
- >
123
- <FormattedMessage {...messages.addButton} />
124
- </CapButton>
125
- )}
126
- {showDisabledSecondaryDuringPrimary && (
127
- <CapButton
128
- type="flat"
129
- className="add-secondary-button button-add-trigger"
130
- icon="plus"
131
- disabled
132
- >
133
- <FormattedMessage {...messages.addButton} />
134
- </CapButton>
135
- )}
136
- </div>
137
- )}
138
- </CapRow>
139
- </>
140
- );
141
- };
142
-
143
- ButtonsLinksSection.propTypes = {
144
- onClickBehaviour: PropTypes.string.isRequired,
145
- onClickBehaviourOptions: PropTypes.array.isRequired,
146
- onClickBehaviourChange: PropTypes.func.isRequired,
147
- redirectUrl: PropTypes.string.isRequired,
148
- redirectUrlError: PropTypes.string,
149
- onRedirectUrlChange: PropTypes.func.isRequired,
150
- buttonState: PropTypes.object.isRequired,
151
- formatMessage: PropTypes.func.isRequired,
152
- messages: PropTypes.object.isRequired,
153
- };
154
-
155
- ButtonsLinksSection.defaultProps = {
156
- redirectUrlError: '',
157
- };
158
-
159
- export default ButtonsLinksSection;
160
-