@capillarytech/creatives-library 8.0.242-alpha.0 → 8.0.242-alpha.2

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 (216) hide show
  1. package/assets/Android.png +0 -0
  2. package/assets/iOS.png +0 -0
  3. package/constants/unified.js +2 -1
  4. package/initialReducer.js +2 -0
  5. package/package.json +1 -1
  6. package/sagas/__tests__/assetPolling.test.js +74 -3
  7. package/sagas/assetPolling.js +8 -1
  8. package/services/api.js +10 -5
  9. package/services/tests/api.test.js +18 -0
  10. package/translations/en.json +0 -1
  11. package/utils/common.js +5 -0
  12. package/utils/commonUtils.js +14 -1
  13. package/utils/tests/commonUtil.test.js +224 -0
  14. package/utils/transformTemplateConfig.js +0 -10
  15. package/utils/transformerUtils.js +0 -42
  16. package/v2Components/CapDeviceContent/index.js +61 -56
  17. package/v2Components/CapImageUpload/constants.js +0 -2
  18. package/v2Components/CapImageUpload/index.js +14 -54
  19. package/v2Components/CapImageUpload/index.scss +1 -4
  20. package/v2Components/CapImageUpload/messages.js +0 -4
  21. package/v2Components/CapTagList/index.js +6 -1
  22. package/v2Components/CapTagListWithInput/index.js +5 -1
  23. package/v2Components/CapTagListWithInput/messages.js +1 -1
  24. package/v2Components/CapWhatsappCTA/tests/index.test.js +5 -0
  25. package/v2Components/ErrorInfoNote/index.js +412 -72
  26. package/v2Components/ErrorInfoNote/messages.js +22 -0
  27. package/v2Components/ErrorInfoNote/style.scss +279 -2
  28. package/v2Components/HtmlEditor/HTMLEditor.js +217 -90
  29. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +1132 -133
  30. package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +17 -12
  31. package/v2Components/HtmlEditor/_htmlEditor.scss +15 -23
  32. package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
  33. package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +13 -101
  34. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +148 -139
  35. package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +2 -1
  36. package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
  37. package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +1 -0
  38. package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
  39. package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +1 -0
  40. package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +4 -7
  41. package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +35 -45
  42. package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +1 -3
  43. package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
  44. package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +7 -6
  45. package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +3 -6
  46. package/v2Components/HtmlEditor/components/PreviewPane/index.js +10 -11
  47. package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
  48. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +87 -62
  49. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +49 -31
  50. package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +254 -0
  51. package/v2Components/HtmlEditor/components/ValidationTabs/index.js +362 -0
  52. package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +51 -0
  53. package/v2Components/HtmlEditor/constants.js +29 -20
  54. package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +373 -16
  55. package/v2Components/HtmlEditor/hooks/useEditorContent.js +5 -2
  56. package/v2Components/HtmlEditor/hooks/useInAppContent.js +88 -146
  57. package/v2Components/HtmlEditor/index.js +1 -1
  58. package/v2Components/HtmlEditor/messages.js +95 -85
  59. package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +99 -101
  60. package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +23 -25
  61. package/v2Components/HtmlEditor/utils/validationAdapter.js +34 -41
  62. package/v2Components/MobilePushPreviewV2/index.js +32 -7
  63. package/v2Components/TemplatePreview/_templatePreview.scss +44 -24
  64. package/v2Components/TemplatePreview/index.js +47 -32
  65. package/v2Components/TemplatePreview/messages.js +4 -0
  66. package/v2Components/TestAndPreviewSlidebox/index.js +31 -25
  67. package/v2Containers/App/constants.js +0 -5
  68. package/v2Containers/BeeEditor/index.js +82 -80
  69. package/v2Containers/BeePopupEditor/constants.js +10 -0
  70. package/v2Containers/BeePopupEditor/index.js +193 -0
  71. package/v2Containers/BeePopupEditor/tests/index.test.js +627 -0
  72. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
  73. package/v2Containers/CreativesContainer/SlideBoxContent.js +148 -120
  74. package/v2Containers/CreativesContainer/SlideBoxFooter.js +9 -3
  75. package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -2
  76. package/v2Containers/CreativesContainer/constants.js +1 -2
  77. package/v2Containers/CreativesContainer/index.js +173 -193
  78. package/v2Containers/CreativesContainer/messages.js +4 -4
  79. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +38 -50
  80. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +36 -0
  81. package/v2Containers/Email/actions.js +7 -0
  82. package/v2Containers/Email/constants.js +5 -1
  83. package/v2Containers/Email/index.js +13 -0
  84. package/v2Containers/Email/messages.js +32 -0
  85. package/v2Containers/Email/reducer.js +12 -1
  86. package/v2Containers/Email/sagas.js +41 -6
  87. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +2 -0
  88. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +1046 -0
  89. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +193 -7
  90. package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +40 -74
  91. package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +2 -67
  92. package/v2Containers/EmailWrapper/constants.js +2 -0
  93. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +436 -67
  94. package/v2Containers/EmailWrapper/index.js +99 -23
  95. package/v2Containers/EmailWrapper/messages.js +61 -1
  96. package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +26 -1
  97. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +111 -77
  98. package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +376 -0
  99. package/v2Containers/InApp/__tests__/sagas.test.js +363 -0
  100. package/v2Containers/InApp/actions.js +7 -0
  101. package/v2Containers/InApp/constants.js +20 -4
  102. package/v2Containers/InApp/index.js +800 -357
  103. package/v2Containers/InApp/index.scss +4 -3
  104. package/v2Containers/InApp/messages.js +7 -3
  105. package/v2Containers/InApp/reducer.js +21 -3
  106. package/v2Containers/InApp/sagas.js +29 -9
  107. package/v2Containers/InApp/selectors.js +25 -5
  108. package/v2Containers/InApp/tests/index.test.js +154 -50
  109. package/v2Containers/InApp/tests/reducer.test.js +34 -0
  110. package/v2Containers/InApp/tests/sagas.test.js +61 -9
  111. package/v2Containers/InApp/tests/selectors.test.js +612 -0
  112. package/v2Containers/InAppWrapper/components/InAppWrapperView.js +162 -0
  113. package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +267 -0
  114. package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +9 -0
  115. package/v2Containers/InAppWrapper/constants.js +16 -0
  116. package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +473 -0
  117. package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +198 -0
  118. package/v2Containers/InAppWrapper/index.js +148 -0
  119. package/v2Containers/InAppWrapper/messages.js +49 -0
  120. package/v2Containers/InappAdvance/index.js +1099 -0
  121. package/v2Containers/InappAdvance/index.scss +10 -0
  122. package/v2Containers/InappAdvance/tests/index.test.js +448 -0
  123. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -3
  124. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -2
  125. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -25
  126. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -18
  127. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -46
  128. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +0 -4
  129. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -8
  130. package/v2Containers/TagList/index.js +67 -1
  131. package/v2Containers/Templates/ChannelTypeIllustration.js +1 -13
  132. package/v2Containers/Templates/_templates.scss +56 -200
  133. package/v2Containers/Templates/actions.js +1 -2
  134. package/v2Containers/Templates/constants.js +0 -1
  135. package/v2Containers/Templates/index.js +124 -277
  136. package/v2Containers/Templates/messages.js +4 -24
  137. package/v2Containers/Templates/reducer.js +0 -2
  138. package/v2Containers/Templates/tests/index.test.js +0 -10
  139. package/v2Containers/TemplatesV2/index.js +2 -3
  140. package/v2Containers/TemplatesV2/messages.js +0 -4
  141. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +35 -132
  142. package/v2Components/CapImageUrlUpload/constants.js +0 -19
  143. package/v2Components/CapImageUrlUpload/index.js +0 -455
  144. package/v2Components/CapImageUrlUpload/index.scss +0 -35
  145. package/v2Components/CapImageUrlUpload/messages.js +0 -47
  146. package/v2Containers/WebPush/Create/components/ButtonForm.js +0 -175
  147. package/v2Containers/WebPush/Create/components/ButtonItem.js +0 -101
  148. package/v2Containers/WebPush/Create/components/ButtonList.js +0 -144
  149. package/v2Containers/WebPush/Create/components/_buttons.scss +0 -246
  150. package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +0 -554
  151. package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +0 -607
  152. package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +0 -633
  153. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +0 -666
  154. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +0 -74
  155. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +0 -80
  156. package/v2Containers/WebPush/Create/index.js +0 -1755
  157. package/v2Containers/WebPush/Create/index.scss +0 -123
  158. package/v2Containers/WebPush/Create/messages.js +0 -199
  159. package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +0 -241
  160. package/v2Containers/WebPush/Create/preview/NotificationContainer.js +0 -290
  161. package/v2Containers/WebPush/Create/preview/PreviewContent.js +0 -81
  162. package/v2Containers/WebPush/Create/preview/PreviewControls.js +0 -240
  163. package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +0 -23
  164. package/v2Containers/WebPush/Create/preview/WebPushPreview.js +0 -144
  165. package/v2Containers/WebPush/Create/preview/assets/Light.svg +0 -53
  166. package/v2Containers/WebPush/Create/preview/assets/Top.svg +0 -5
  167. package/v2Containers/WebPush/Create/preview/assets/chrome-icon.png +0 -0
  168. package/v2Containers/WebPush/Create/preview/assets/edge-icon.png +0 -0
  169. package/v2Containers/WebPush/Create/preview/assets/firefox-icon.svg +0 -106
  170. package/v2Containers/WebPush/Create/preview/assets/iOS.svg +0 -26
  171. package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +0 -18
  172. package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +0 -29
  173. package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +0 -44
  174. package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +0 -110
  175. package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +0 -45
  176. package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +0 -72
  177. package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +0 -55
  178. package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +0 -70
  179. package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +0 -512
  180. package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +0 -77
  181. package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +0 -527
  182. package/v2Containers/WebPush/Create/preview/constants.js +0 -162
  183. package/v2Containers/WebPush/Create/preview/notification-container.scss +0 -104
  184. package/v2Containers/WebPush/Create/preview/preview.scss +0 -409
  185. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +0 -300
  186. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +0 -12
  187. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +0 -12
  188. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +0 -12
  189. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +0 -303
  190. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +0 -11
  191. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +0 -11
  192. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +0 -11
  193. package/v2Containers/WebPush/Create/preview/styles/_base.scss +0 -188
  194. package/v2Containers/WebPush/Create/preview/styles/_ios.scss +0 -106
  195. package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +0 -107
  196. package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +0 -75
  197. package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +0 -174
  198. package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +0 -909
  199. package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +0 -1077
  200. package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +0 -723
  201. package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +0 -943
  202. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +0 -128
  203. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +0 -121
  204. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +0 -144
  205. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +0 -127
  206. package/v2Containers/WebPush/Create/utils/urlValidation.js +0 -116
  207. package/v2Containers/WebPush/Create/utils/urlValidation.test.js +0 -449
  208. package/v2Containers/WebPush/actions.js +0 -60
  209. package/v2Containers/WebPush/constants.js +0 -108
  210. package/v2Containers/WebPush/index.js +0 -2
  211. package/v2Containers/WebPush/reducer.js +0 -104
  212. package/v2Containers/WebPush/sagas.js +0 -119
  213. package/v2Containers/WebPush/selectors.js +0 -65
  214. package/v2Containers/WebPush/tests/reducer.test.js +0 -863
  215. package/v2Containers/WebPush/tests/sagas.test.js +0 -566
  216. package/v2Containers/WebPush/tests/selectors.test.js +0 -960
@@ -1,123 +0,0 @@
1
- @import '~@capillarytech/cap-ui-library/styles/_variables';
2
- @import './components/buttons';
3
-
4
- .webpush-container {
5
- .creatives-webpush-title,
6
- .creatives-webpush-message,
7
- .creatives-webpush-media {
8
- display: flex;
9
- flex-direction: column;
10
- gap: $CAP_SPACE_08;
11
- position: relative;
12
- }
13
-
14
- .creatives-webpush-title {
15
- margin-bottom: $CAP_SPACE_12;
16
- }
17
-
18
- .webpush-title,
19
- .webpush-message,
20
- .webpush-media-type {
21
- font-weight: $FONT_WEIGHT_MEDIUM;
22
- color: $CAP_G16;
23
- margin: 0;
24
- font-size: 14px;
25
- }
26
-
27
- .creatives-webpush-brand-icon {
28
- display: flex;
29
- flex-direction: column;
30
- gap: $CAP_SPACE_08;
31
-
32
- .webpush-brand-icon {
33
- font-weight: $FONT_WEIGHT_MEDIUM;
34
- color: $CAP_G16;
35
- margin: 0;
36
- font-size: 14px;
37
- }
38
- }
39
-
40
- .creatives-webpush-buttons-links {
41
- display: flex;
42
- flex-direction: column;
43
- gap: 0.65rem;
44
-
45
- .webpush-buttons-links {
46
- font-weight: $FONT_WEIGHT_MEDIUM;
47
- color: $CAP_G16;
48
- margin: 0;
49
- font-size: 16px;
50
-
51
- .optional-text {
52
- color: $CAP_G05;
53
- font-size: $FONT_SIZE_M;
54
- font-weight: normal;
55
- padding: 0;
56
- margin: 0.1rem;
57
- }
58
- }
59
-
60
- .webpush-on-click-behaviour {
61
- font-weight: $FONT_WEIGHT_MEDIUM;
62
- color: $CAP_G16;
63
- margin: 0;
64
- font-size: 14px;
65
- }
66
- }
67
-
68
- .creatives-webpush-actions {
69
- margin-bottom: $CAP_SPACE_24;
70
- }
71
-
72
- .webpush-character-count {
73
- position: absolute;
74
- bottom: -0.8rem;
75
- right: 0;
76
- color: $CAP_G05;
77
- pointer-events: none;
78
- }
79
-
80
- .webpush-message-divider {
81
- margin-top: $CAP_SPACE_36;
82
- }
83
-
84
- .webpush-title-taglist,
85
- .webpush-message-taglist {
86
- margin-bottom: -2.5625rem; // approx -41px
87
- }
88
-
89
- .webpush-buttons-section-heading {
90
- font-weight: $FONT_WEIGHT_MEDIUM;
91
- color: $CAP_G16;
92
- margin: 0;
93
- margin-bottom: 0.6rem;
94
- font-size: 14px;
95
- }
96
-
97
- .webpush-image-upload-method {
98
- margin-top: $CAP_SPACE_16;
99
- margin-bottom: $CAP_SPACE_16;
100
- }
101
-
102
- .webpush-image-upload-section,
103
- .webpush-image-url-section {
104
- display: flex;
105
- flex-direction: column;
106
- gap: $CAP_SPACE_12;
107
- margin-top: $CAP_SPACE_16;
108
- }
109
-
110
- .webpush-image-specs {
111
- display: flex;
112
- justify-content: space-between;
113
- margin-top: $CAP_SPACE_08;
114
-
115
- .image-dimension,
116
- .image-size,
117
- .image-format {
118
- color: $CAP_WHITE;
119
- font-size: $FONT_SIZE_S;
120
- }
121
- }
122
- }
123
-
@@ -1,199 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- const scope = 'creatives.containersV2.WebPush';
4
-
5
- export default defineMessages({
6
- creativeName: {
7
- id: `${scope}.creativeName`,
8
- defaultMessage: 'Creative name',
9
- },
10
- creativeNamePlaceholder: {
11
- id: `${scope}.creativeNamePlaceholder`,
12
- defaultMessage: 'Enter creative name',
13
- },
14
- notificationTitle: {
15
- id: `${scope}.notificationTitle`,
16
- defaultMessage: 'Notification Title',
17
- },
18
- notificationTitlePlaceholder: {
19
- id: `${scope}.notificationTitlePlaceholder`,
20
- defaultMessage: 'Enter notification title',
21
- },
22
- message: {
23
- id: `${scope}.message`,
24
- defaultMessage: 'Message',
25
- },
26
- messagePlaceholder: {
27
- id: `${scope}.messagePlaceholder`,
28
- defaultMessage: 'Enter message',
29
- },
30
- mediaType: {
31
- id: `${scope}.mediaType`,
32
- defaultMessage: 'Media Type',
33
- },
34
- emptyTemplateErrorMessage: {
35
- id: `${scope}.emptyTemplateErrorMessage`,
36
- defaultMessage: 'Template name cannot be empty',
37
- },
38
- titleRequired: {
39
- id: `${scope}.titleRequired`,
40
- defaultMessage: 'Title is required',
41
- },
42
- messageRequired: {
43
- id: `${scope}.messageRequired`,
44
- defaultMessage: 'Message is required',
45
- },
46
- saveTemplate: {
47
- id: `${scope}.saveTemplate`,
48
- defaultMessage: 'Save Template',
49
- },
50
- accountRequired: {
51
- id: `${scope}.accountRequired`,
52
- defaultMessage: 'Select an account to create a template',
53
- },
54
- brandIconLogo: {
55
- id: `${scope}.brandIconLogo`,
56
- defaultMessage: 'Brand icon/logo',
57
- },
58
- dontShow: {
59
- id: `${scope}.dontShow`,
60
- defaultMessage: "Don't show",
61
- },
62
- uploadImage: {
63
- id: `${scope}.uploadImage`,
64
- defaultMessage: 'Upload image',
65
- },
66
- addImageUrl: {
67
- id: `${scope}.addImageUrl`,
68
- defaultMessage: 'Add image URL',
69
- },
70
- buttonsAndLinks: {
71
- id: `${scope}.buttonsAndLinks`,
72
- defaultMessage: 'Buttons and links',
73
- },
74
- optional: {
75
- id: `${scope}.optional`,
76
- defaultMessage: '(Optional)',
77
- },
78
- onClickBehaviour: {
79
- id: `${scope}.onClickBehaviour`,
80
- defaultMessage: 'On-click behaviour',
81
- },
82
- openSite: {
83
- id: `${scope}.openSite`,
84
- defaultMessage: 'Open site',
85
- },
86
- redirectToSpecificUrl: {
87
- id: `${scope}.redirectToSpecificUrl`,
88
- defaultMessage: 'Redirect to specific URL',
89
- },
90
- characterCount: {
91
- id: `${scope}.characterCount`,
92
- defaultMessage: 'Character count: {currentLength}/{maxLength}',
93
- },
94
- sizeLimit: {
95
- id: `${scope}.sizeLimit`,
96
- defaultMessage: 'Size upto: 5MB',
97
- },
98
- sizeLimitBrandIcon: {
99
- id: `${scope}.sizeLimitBrandIcon`,
100
- defaultMessage: 'Size upto: 1MB',
101
- },
102
- formatTypes: {
103
- id: `${scope}.formatTypes`,
104
- defaultMessage: 'Format: JPEG, JPG, PNG',
105
- },
106
- enterUrl: {
107
- id: `${scope}.enterUrl`,
108
- defaultMessage: 'Enter URL',
109
- },
110
- urlRequired: {
111
- id: `${scope}.urlRequired`,
112
- defaultMessage: 'URL is required',
113
- },
114
- urlInvalid: {
115
- id: `${scope}.urlInvalid`,
116
- defaultMessage: 'Please enter a valid URL',
117
- },
118
- buttons: {
119
- id: `${scope}.buttons`,
120
- defaultMessage: 'Buttons',
121
- },
122
- addPrimaryButton: {
123
- id: `${scope}.addPrimaryButton`,
124
- defaultMessage: 'Add primary button',
125
- },
126
- addSecondaryButton: {
127
- id: `${scope}.addSecondaryButton`,
128
- defaultMessage: 'Add secondary button',
129
- },
130
- addButton: {
131
- id: `${scope}.addButton`,
132
- defaultMessage: 'Add button',
133
- },
134
- buttonText: {
135
- id: `${scope}.buttonText`,
136
- defaultMessage: 'Button text',
137
- },
138
- buttonTextPlaceholder: {
139
- id: `${scope}.buttonTextPlaceholder`,
140
- defaultMessage: 'Enter button text',
141
- },
142
- buttonUrlLabel: {
143
- id: `${scope}.buttonUrlLabel`,
144
- defaultMessage: 'URL',
145
- },
146
- buttonUrlPlaceholder: {
147
- id: `${scope}.buttonUrlPlaceholder`,
148
- defaultMessage: 'Enter URL',
149
- },
150
- saveButton: {
151
- id: `${scope}.saveButton`,
152
- defaultMessage: 'Save',
153
- },
154
- deleteButton: {
155
- id: `${scope}.deleteButton`,
156
- defaultMessage: 'Delete',
157
- },
158
- cancelButton: {
159
- id: `${scope}.cancelButton`,
160
- defaultMessage: 'Cancel',
161
- },
162
- buttonTextRequired: {
163
- id: `${scope}.buttonTextRequired`,
164
- defaultMessage: 'Button text is required',
165
- },
166
- buttonUrlRequired: {
167
- id: `${scope}.buttonUrlRequired`,
168
- defaultMessage: 'Button URL is required',
169
- },
170
- buttonUrlInvalid: {
171
- id: `${scope}.buttonUrlInvalid`,
172
- defaultMessage: 'Please enter a valid URL',
173
- },
174
- addLabels: {
175
- id: `${scope}.addLabels`,
176
- defaultMessage: 'Add labels',
177
- },
178
- previewInAllDevices: {
179
- id: `${scope}.previewInAllDevices`,
180
- defaultMessage: 'Preview in all devices',
181
- },
182
- webPushNotificationPreview: {
183
- id: `${scope}.webPushNotificationPreview`,
184
- defaultMessage: 'Web push notification preview',
185
- },
186
- operatingSystem: {
187
- id: `${scope}.operatingSystem`,
188
- defaultMessage: 'Operating system',
189
- },
190
- browser: {
191
- id: `${scope}.browser`,
192
- defaultMessage: 'Browser',
193
- },
194
- state: {
195
- id: `${scope}.state`,
196
- defaultMessage: 'State',
197
- },
198
- });
199
-
@@ -1,241 +0,0 @@
1
- import React, { useState, useMemo, useRef, useEffect } 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 PreviewControls from './PreviewControls';
6
- import NotificationContainer from './NotificationContainer';
7
- import {
8
- OS_OPTIONS,
9
- STATE_OPTIONS,
10
- DEFAULT_OS,
11
- DEFAULT_BROWSER,
12
- DEFAULT_STATE,
13
- LAYOUT_MODE,
14
- } from './constants';
15
- import {
16
- getBrowserOptionsForOS,
17
- getResolvedVariant,
18
- coerceStateForVariant,
19
- getSupportedStates,
20
- } from './config/notificationMappings';
21
- // Device frame SVG assets
22
- import topSvg from './assets/Top.svg';
23
- import iosSvg from './assets/iOS.svg';
24
- import lightSvg from './assets/Light.svg';
25
- import './preview.scss';
26
-
27
- /**
28
- * Device-to-Asset Mapping
29
- * Maps OS/Device types to their corresponding device frame SVG assets
30
- */
31
- const DEVICE_ASSET_MAP = {
32
- 'macOS': topSvg,
33
- 'Windows': topSvg,
34
- 'iOS': iosSvg,
35
- 'Android (Mobile)': iosSvg,
36
- 'iPadOS': lightSvg,
37
- 'Android (Tablet)': lightSvg,
38
- };
39
-
40
- /**
41
- * DevicePreviewContent Component
42
- *
43
- * Displays device frame previews with web push notifications positioned
44
- * relative to device frames. This component will be used inside the
45
- * "Preview in all devices" SlideBox.
46
- *
47
- * The component renders:
48
- * - Dropdown controls for OS, Browser, and State selection
49
- * - A background container (100% width, height determined by device frame, #F4F5F7 background)
50
- * - Device frames centered within the container
51
- * - Notification previews positioned relative to device frames (Phase 4)
52
- *
53
- * NOTIFICATION POSITIONING SYSTEM:
54
- *
55
- * The notification position is configured using x, y coordinates relative to the device frame.
56
- * Position is calculated relative to device frame boundaries, not background container.
57
- *
58
- * @param {string} notificationTitle - Title of the notification
59
- * @param {string} notificationBody - Body text of the notification
60
- * @param {string} url - URL for the notification
61
- * @param {string} layoutMode - Layout mode for controls: LAYOUT_MODE.COMPACT, LAYOUT_MODE.INLINE, or LAYOUT_MODE.NEW_ROW (default: LAYOUT_MODE.COMPACT)
62
- */
63
- const DevicePreviewContent = ({
64
- notificationTitle,
65
- notificationBody,
66
- url,
67
- imageSrc,
68
- brandIconSrc,
69
- layoutMode = LAYOUT_MODE.COMPACT,
70
- }) => {
71
- // State for device selection
72
- const [selectedOS, setSelectedOS] = useState(DEFAULT_OS);
73
- const [selectedBrowser, setSelectedBrowser] = useState(DEFAULT_BROWSER);
74
- const [selectedState, setSelectedState] = useState(DEFAULT_STATE);
75
-
76
- // Filtered browser options per OS
77
- const browserOptionsForOS = useMemo(() => getBrowserOptionsForOS(selectedOS), [selectedOS]);
78
-
79
- // Coerce browser when OS changes and current browser is unsupported
80
- useEffect(() => {
81
- const hasBrowser = browserOptionsForOS.some((option) => option.value === selectedBrowser);
82
- if (!hasBrowser && browserOptionsForOS.length) {
83
- setSelectedBrowser(browserOptionsForOS[0].value);
84
- }
85
- }, [browserOptionsForOS, selectedBrowser]);
86
-
87
- // Coerce state when OS/Browser changes and current state is unsupported
88
- useEffect(() => {
89
- const coercedState = coerceStateForVariant(selectedOS, selectedBrowser, selectedState);
90
- if (coercedState && coercedState !== selectedState) {
91
- setSelectedState(coercedState);
92
- }
93
- }, [selectedOS, selectedBrowser, selectedState]);
94
-
95
- const stateOptionsForVariant = useMemo(() => {
96
- const supportedStates = getSupportedStates(selectedOS, selectedBrowser);
97
- if (!supportedStates.length) return STATE_OPTIONS;
98
- return supportedStates.map((state) => ({ value: state, label: state }));
99
- }, [selectedOS, selectedBrowser]);
100
-
101
- // Refs for measuring device frame and notification dimensions
102
- const deviceFrameRef = useRef(null);
103
- const notificationRef = useRef(null);
104
-
105
- // Get the device frame asset for the selected OS
106
- const deviceFrameAsset = useMemo(() => {
107
- return DEVICE_ASSET_MAP[selectedOS] || topSvg;
108
- }, [selectedOS]);
109
-
110
- const resolvedVariant = useMemo(() => {
111
- return getResolvedVariant(selectedOS, selectedBrowser, selectedState);
112
- }, [selectedOS, selectedBrowser, selectedState]);
113
-
114
- // Notification position using x, y coordinates from variant configuration
115
- const notificationPosition = useMemo(() => {
116
- if (resolvedVariant?.stateConfig?.position?.custom) {
117
- return resolvedVariant.stateConfig.position.custom;
118
- }
119
- // Fallback to origin (0, 0) if no position configured
120
- return { x: 0, y: 0 };
121
- }, [resolvedVariant]);
122
-
123
- // Store position in state for Phase 5 (when we'll apply it to notification element)
124
- const [calculatedPosition, setCalculatedPosition] = useState(notificationPosition);
125
-
126
- // Update calculated position when dependencies change
127
- useEffect(() => {
128
- setCalculatedPosition(notificationPosition);
129
- }, [notificationPosition]);
130
-
131
- const handleOSChange = (value) => {
132
- setSelectedOS(value);
133
- };
134
-
135
- const handleBrowserChange = (value) => {
136
- setSelectedBrowser(value);
137
- };
138
-
139
- const handleStateChange = (value) => {
140
- setSelectedState(value);
141
- };
142
-
143
- return (
144
- <CapRow>
145
- <CapColumn span={24}>
146
- {/* Dropdown Controls */}
147
- <PreviewControls
148
- selectedOS={selectedOS}
149
- selectedBrowser={selectedBrowser}
150
- selectedState={selectedState}
151
- osOptions={OS_OPTIONS}
152
- browserOptions={browserOptionsForOS}
153
- stateOptions={stateOptionsForVariant}
154
- onOSChange={handleOSChange}
155
- onBrowserChange={handleBrowserChange}
156
- onStateChange={handleStateChange}
157
- layoutMode={layoutMode}
158
- showStateDropdown={true}
159
- />
160
-
161
- {/* Background Container - Preview Section */}
162
- {/*
163
- Background: #F4F5F7
164
- Padding: 24px 16px 16px 16px
165
- Width: 100% (responsive)
166
- Height: Determined by device frame content
167
- */}
168
- <div className="device-preview-container">
169
- {/* Device Frame Display */}
170
- {/* Device frames are centered horizontally and vertically within the container */}
171
- <div className="device-frame-wrapper">
172
- <div className="device-frame-asset">
173
- <img
174
- ref={deviceFrameRef}
175
- src={deviceFrameAsset}
176
- alt={`${selectedOS} device frame`}
177
- className="device-frame"
178
- />
179
- {/* Notification preview positioned relative to the device frame image */}
180
- {/* Inline styles kept: Dynamic positioning calculated at runtime based on OS/browser/state selection.
181
- These values change with user interaction and cannot be moved to static SCSS.
182
- calculatedPosition is computed from variant configuration and device frame measurements. */}
183
- <div
184
- ref={notificationRef}
185
- className={`device-notification-wrapper ${resolvedVariant ? '' : 'preview-unavailable'}`.trim()}
186
- style={{
187
- position: 'absolute',
188
- left: `${calculatedPosition?.x || 0}px`,
189
- ...(calculatedPosition?.bottom !== undefined
190
- ? { bottom: `${calculatedPosition.bottom}px` }
191
- : { top: `${calculatedPosition?.y || 0}px` }),
192
- zIndex: 10,
193
- }}
194
- >
195
- {resolvedVariant && (
196
- <NotificationContainer
197
- notificationTitle={notificationTitle}
198
- notificationBody={notificationBody}
199
- url={url}
200
- selectedOS={selectedOS}
201
- selectedBrowser={selectedBrowser}
202
- notificationState={resolvedVariant.stateKey}
203
- icon={resolvedVariant.variant.icon}
204
- supportsExpanded={resolvedVariant.stateConfig.supportsExpanded}
205
- enableMedia={resolvedVariant.stateConfig.showMedia}
206
- // CTA buttons intentionally disabled per requirement change; do not enable unless confirmed.
207
- enableCtas={false}
208
- className={resolvedVariant.variant.notificationClassName}
209
- imageSrc={imageSrc}
210
- brandIconSrc={brandIconSrc}
211
- />
212
- )}
213
- </div>
214
- </div>
215
- </div>
216
- </div>
217
- </CapColumn>
218
- </CapRow>
219
- );
220
- };
221
-
222
- DevicePreviewContent.propTypes = {
223
- notificationTitle: PropTypes.string,
224
- notificationBody: PropTypes.string,
225
- url: PropTypes.string,
226
- imageSrc: PropTypes.string,
227
- brandIconSrc: PropTypes.string,
228
- layoutMode: PropTypes.oneOf([LAYOUT_MODE.COMPACT, LAYOUT_MODE.INLINE, LAYOUT_MODE.NEW_ROW]),
229
- };
230
-
231
- DevicePreviewContent.defaultProps = {
232
- notificationTitle: '',
233
- notificationBody: '',
234
- url: '',
235
- imageSrc: '',
236
- brandIconSrc: '',
237
- layoutMode: LAYOUT_MODE.COMPACT,
238
- };
239
-
240
- export default DevicePreviewContent;
241
-