@capillarytech/creatives-library 8.0.358 → 8.0.359-alpha.1

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 (125) hide show
  1. package/constants/unified.js +29 -0
  2. package/package.json +1 -1
  3. package/services/tests/api.test.js +35 -20
  4. package/utils/commonUtils.js +19 -1
  5. package/utils/rcsPayloadUtils.js +92 -0
  6. package/utils/templateVarUtils.js +201 -0
  7. package/utils/tests/rcsPayloadUtils.test.js +226 -0
  8. package/utils/tests/templateVarUtils.test.js +204 -0
  9. package/v2Components/CapActionButton/constants.js +7 -0
  10. package/v2Components/CapActionButton/index.js +166 -108
  11. package/v2Components/CapActionButton/index.scss +157 -6
  12. package/v2Components/CapActionButton/messages.js +19 -3
  13. package/v2Components/CapActionButton/tests/index.test.js +41 -17
  14. package/v2Components/CapImageUpload/index.js +2 -2
  15. package/v2Components/CapTagList/index.js +10 -0
  16. package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +72 -49
  17. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +8 -2
  18. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +214 -21
  19. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +16 -0
  20. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +83 -9
  21. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +30 -0
  22. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +79 -11
  23. package/v2Components/CommonTestAndPreview/SendTestMessage.js +10 -5
  24. package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +157 -15
  25. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +346 -76
  26. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +150 -4
  27. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +11 -0
  28. package/v2Components/CommonTestAndPreview/constants.js +38 -2
  29. package/v2Components/CommonTestAndPreview/index.js +810 -222
  30. package/v2Components/CommonTestAndPreview/messages.js +45 -3
  31. package/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
  32. package/v2Components/CommonTestAndPreview/sagas.js +25 -6
  33. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +308 -284
  34. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +231 -65
  35. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +118 -5
  36. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +341 -0
  37. package/v2Components/CommonTestAndPreview/tests/PreviewSection.test.js +8 -1
  38. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +34 -13
  39. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +281 -283
  40. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
  41. package/v2Components/CommonTestAndPreview/tests/index.test.js +133 -4
  42. package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
  43. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +31 -24
  44. package/v2Components/FormBuilder/index.js +5 -4
  45. package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +91 -0
  46. package/v2Components/SmsFallback/constants.js +73 -0
  47. package/v2Components/SmsFallback/index.js +956 -0
  48. package/v2Components/SmsFallback/index.scss +265 -0
  49. package/v2Components/SmsFallback/messages.js +78 -0
  50. package/v2Components/SmsFallback/smsFallbackUtils.js +119 -0
  51. package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
  52. package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
  53. package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
  54. package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +223 -0
  55. package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +309 -0
  56. package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
  57. package/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
  58. package/v2Components/TemplatePreview/_templatePreview.scss +37 -22
  59. package/v2Components/TemplatePreview/constants.js +2 -0
  60. package/v2Components/TemplatePreview/index.js +143 -31
  61. package/v2Components/TemplatePreview/tests/index.test.js +142 -0
  62. package/v2Components/TestAndPreviewSlidebox/index.js +13 -1
  63. package/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
  64. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
  65. package/v2Components/VarSegmentMessageEditor/constants.js +2 -0
  66. package/v2Components/VarSegmentMessageEditor/index.js +125 -0
  67. package/v2Components/VarSegmentMessageEditor/index.scss +46 -0
  68. package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +17 -0
  69. package/v2Containers/CreativesContainer/SlideBoxContent.js +36 -4
  70. package/v2Containers/CreativesContainer/SlideBoxFooter.js +14 -5
  71. package/v2Containers/CreativesContainer/SlideBoxHeader.js +36 -5
  72. package/v2Containers/CreativesContainer/constants.js +9 -0
  73. package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +79 -0
  74. package/v2Containers/CreativesContainer/index.js +322 -103
  75. package/v2Containers/CreativesContainer/index.scss +83 -1
  76. package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
  77. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +79 -34
  78. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +79 -16
  79. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +8 -0
  80. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +357 -98
  81. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +20 -15
  82. package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
  83. package/v2Containers/CreativesContainer/tests/index.test.js +71 -9
  84. package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
  85. package/v2Containers/MobilePush/Create/test/saga.test.js +2 -2
  86. package/v2Containers/Rcs/constants.js +120 -11
  87. package/v2Containers/Rcs/index.js +2577 -812
  88. package/v2Containers/Rcs/index.scss +281 -8
  89. package/v2Containers/Rcs/messages.js +34 -3
  90. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +225 -0
  91. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +98036 -70145
  92. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
  93. package/v2Containers/Rcs/tests/index.test.js +152 -121
  94. package/v2Containers/Rcs/tests/mockData.js +38 -0
  95. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +318 -0
  96. package/v2Containers/Rcs/tests/utils.test.js +646 -30
  97. package/v2Containers/Rcs/utils.js +478 -11
  98. package/v2Containers/Sms/Create/index.js +106 -40
  99. package/v2Containers/Sms/smsFormDataHelpers.js +67 -0
  100. package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
  101. package/v2Containers/SmsTrai/Create/index.js +9 -4
  102. package/v2Containers/SmsTrai/Edit/constants.js +2 -0
  103. package/v2Containers/SmsTrai/Edit/index.js +640 -130
  104. package/v2Containers/SmsTrai/Edit/index.scss +121 -0
  105. package/v2Containers/SmsTrai/Edit/messages.js +14 -4
  106. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4328 -2375
  107. package/v2Containers/SmsWrapper/index.js +37 -8
  108. package/v2Containers/TagList/index.js +6 -0
  109. package/v2Containers/Templates/TemplatesActionBar.js +101 -0
  110. package/v2Containers/Templates/_templates.scss +166 -9
  111. package/v2Containers/Templates/actions.js +11 -0
  112. package/v2Containers/Templates/constants.js +2 -0
  113. package/v2Containers/Templates/index.js +121 -53
  114. package/v2Containers/Templates/sagas.js +56 -12
  115. package/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
  116. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1062 -1017
  117. package/v2Containers/Templates/tests/sagas.test.js +199 -16
  118. package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
  119. package/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
  120. package/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
  121. package/v2Containers/TemplatesV2/index.js +86 -23
  122. package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
  123. package/v2Containers/WeChat/MapTemplates/test/saga.test.js +9 -9
  124. package/v2Containers/Whatsapp/index.js +3 -20
  125. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +578 -34
@@ -22,8 +22,21 @@ import MobilePushPreviewContent from './MobilePushPreviewContent';
22
22
  import ViberPreviewContent from './ViberPreviewContent';
23
23
  import ZaloPreviewContent from './ZaloPreviewContent';
24
24
  import WebPushPreviewContent from './WebPushPreviewContent';
25
- import { CHANNELS, DESKTOP, TABLET, MOBILE, ANDROID, IOS } from '../constants';
25
+ import CapTab from '@capillarytech/cap-ui-library/CapTab';
26
+ import {
27
+ CHANNELS,
28
+ DESKTOP,
29
+ TABLET,
30
+ MOBILE,
31
+ ANDROID,
32
+ IOS,
33
+ PREVIEW_TAB_RCS,
34
+ PREVIEW_TAB_SMS_FALLBACK,
35
+ PREVIEW_TAB_KEYS,
36
+ RCS_SMS_FALLBACK_VAR_MAPPED_PROP,
37
+ } from '../constants';
26
38
  import messages from '../messages';
39
+ import { getFallbackResolvedContent } from '../../../utils/templateVarUtils';
27
40
  import './_unifiedPreview.scss';
28
41
 
29
42
  const UnifiedPreview = ({
@@ -39,7 +52,24 @@ const UnifiedPreview = ({
39
52
  lastModified,
40
53
  updatedByName,
41
54
  showHeader, // Default to true for Test and Preview flow, false for channel component previews
55
+ smsFallbackContent,
56
+ smsFallbackResolvedText,
57
+ activePreviewTab,
58
+ onPreviewTabChange,
42
59
  }) => {
60
+ const hasFallbackSmsTemplate = !!(smsFallbackContent?.templateContent || smsFallbackContent?.content);
61
+ const showRcsSmsFallbackTabs = channel === CHANNELS.RCS && hasFallbackSmsTemplate;
62
+ const rawFallbackTemplate = smsFallbackContent?.templateContent ?? smsFallbackContent?.content ?? '';
63
+ const rcsFallbackVarMapped = smsFallbackContent?.[RCS_SMS_FALLBACK_VAR_MAPPED_PROP] ?? {};
64
+ const hasRcsFallbackVarMapped = Object.keys(rcsFallbackVarMapped).length > 0;
65
+ // When no varmap is present, show raw template so {{tags}} remain visible in the preview.
66
+ // Only apply slot substitution when varmap entries exist or a resolved text is available.
67
+ const smsFallbackDisplayContent =
68
+ smsFallbackResolvedText != null && smsFallbackResolvedText !== ''
69
+ ? smsFallbackResolvedText
70
+ : hasRcsFallbackVarMapped
71
+ ? getFallbackResolvedContent(rawFallbackTemplate, rcsFallbackVarMapped)
72
+ : rawFallbackTemplate;
43
73
  /**
44
74
  * Render channel-specific preview content
45
75
  * For Phase 5, we'll render placeholders
@@ -126,6 +156,21 @@ const UnifiedPreview = ({
126
156
  case CHANNELS.RCS: {
127
157
  // RCS content is an object with rcsTitle, rcsDesc, rcsImageSrc, suggestions, etc.
128
158
  const rcsContent = typeof content === 'object' ? content : {};
159
+
160
+ if (showRcsSmsFallbackTabs && activePreviewTab === PREVIEW_TAB_SMS_FALLBACK) {
161
+ return (
162
+ <SmsPreviewContent
163
+ content={smsFallbackDisplayContent}
164
+ device={ANDROID}
165
+ isUpdating={isUpdating}
166
+ error={error}
167
+ formatMessage={formatMessage}
168
+ senderId={smsFallbackContent?.senderId}
169
+ showHeader={showHeader}
170
+ />
171
+ );
172
+ }
173
+
129
174
  return (
130
175
  <RcsPreviewContent
131
176
  content={rcsContent}
@@ -313,6 +358,96 @@ const UnifiedPreview = ({
313
358
  * PreviewHeader is shown only when showHeader is true (for Test and Preview flow)
314
359
  * Channel-specific content will be in separate files in future phases
315
360
  */
361
+ if (showRcsSmsFallbackTabs) {
362
+ const renderPane = ({ paneChannel, paneDevice, paneShowDeviceToggle, paneContent }) => (
363
+ <CapRow className="unified-preview-tab-pane">
364
+ {showHeader && (
365
+ <PreviewHeader
366
+ selectedCustomer={selectedCustomer}
367
+ device={paneDevice}
368
+ showDeviceToggle={paneShowDeviceToggle}
369
+ onDeviceChange={onDeviceChange}
370
+ channel={paneChannel}
371
+ />
372
+ )}
373
+
374
+ <CapRow className={`preview-content-container ${!showHeader ? 'preview-content-container-no-header' : ''}`}>
375
+ {paneContent}
376
+ </CapRow>
377
+
378
+
379
+ </CapRow>
380
+ );
381
+
382
+ return (
383
+ <CapRow className="unified-preview unified-preview-rcs-tabs">
384
+ <CapTab
385
+ activeKey={activePreviewTab}
386
+ onChange={onPreviewTabChange}
387
+ panes={[
388
+ {
389
+ tab: formatMessage(messages.rcsTab),
390
+ key: PREVIEW_TAB_RCS,
391
+ content: renderPane({
392
+ paneChannel: CHANNELS.RCS,
393
+ paneDevice: device,
394
+ paneShowDeviceToggle: showDeviceToggle,
395
+ paneContent: (
396
+ <RcsPreviewContent
397
+ content={typeof content === 'object' ? content : {}}
398
+ device={device}
399
+ isUpdating={isUpdating}
400
+ error={error}
401
+ formatMessage={formatMessage}
402
+ senderId={content?.senderId}
403
+ showHeader={showHeader}
404
+ />
405
+ ),
406
+ }),
407
+ },
408
+ {
409
+ tab: formatMessage(messages.smsFallbackTab),
410
+ key: PREVIEW_TAB_SMS_FALLBACK,
411
+ content: renderPane({
412
+ paneChannel: CHANNELS.SMS,
413
+ paneDevice: device,
414
+ paneShowDeviceToggle: showDeviceToggle,
415
+ paneContent: (
416
+ <SmsPreviewContent
417
+ content={smsFallbackDisplayContent}
418
+ device={device}
419
+ isUpdating={isUpdating}
420
+ error={error}
421
+ formatMessage={formatMessage}
422
+ senderId={smsFallbackContent?.senderId}
423
+ showHeader={showHeader}
424
+ />
425
+ ),
426
+ }),
427
+ },
428
+ ]}
429
+ />
430
+ {(lastModified || updatedByName) && (
431
+ <CapRow className="preview-metadata">
432
+ {lastModified && (
433
+ <span className="metadata-item">
434
+ {formatMessage(messages.lastModified)}
435
+ :
436
+ {' '}
437
+ {lastModified}
438
+ </span>
439
+ )}
440
+ {updatedByName && (
441
+ <span className="metadata-item">
442
+ {formatMessage(messages.byAuthor, { name: updatedByName })}
443
+ </span>
444
+ )}
445
+ </CapRow>
446
+ )}
447
+ </CapRow>
448
+ );
449
+ }
450
+
316
451
  return (
317
452
  <CapRow className="unified-preview">
318
453
  {/* PreviewHeader - shown only in Test and Preview flow, hidden in channel component previews */}
@@ -351,9 +486,7 @@ const UnifiedPreview = ({
351
486
  )}
352
487
  {updatedByName && (
353
488
  <span className="metadata-item">
354
- {formatMessage(messages.by)}
355
- {' '}
356
- {updatedByName}
489
+ {formatMessage(messages.byAuthor, { name: updatedByName })}
357
490
  </span>
358
491
  )}
359
492
  </CapRow>
@@ -394,6 +527,15 @@ UnifiedPreview.propTypes = {
394
527
 
395
528
  // Header display
396
529
  showHeader: PropTypes.bool, // Show PreviewHeader (true for Test and Preview flow, false for channel component previews)
530
+
531
+ // RCS: SMS fallback preview support (same shape as SmsFallback / RCS smsFallbackData)
532
+ smsFallbackContent: PropTypes.shape({
533
+ templateContent: PropTypes.string,
534
+ senderId: PropTypes.string,
535
+ templateName: PropTypes.string,
536
+ }),
537
+ activePreviewTab: PropTypes.oneOf(PREVIEW_TAB_KEYS),
538
+ onPreviewTabChange: PropTypes.func,
397
539
  };
398
540
 
399
541
  UnifiedPreview.defaultProps = {
@@ -406,6 +548,10 @@ UnifiedPreview.defaultProps = {
406
548
  lastModified: null,
407
549
  updatedByName: null,
408
550
  showHeader: true, // Default to true for Test and Preview flow
551
+ smsFallbackContent: null,
552
+ smsFallbackResolvedText: undefined,
553
+ activePreviewTab: PREVIEW_TAB_RCS,
554
+ onPreviewTabChange: () => {},
409
555
  };
410
556
 
411
557
  export default UnifiedPreview;
@@ -213,6 +213,10 @@
213
213
  margin-right: 0.5rem;
214
214
  }
215
215
 
216
+ .cap-slide-box-v2.common-test-and-preview-slidebox .cap-slide-box-v2-container {
217
+ z-index: 10030;
218
+ }
219
+
216
220
  .common-test-and-preview-slidebox {
217
221
 
218
222
  .ant-modal-mask,
@@ -486,6 +490,13 @@
486
490
  }
487
491
  }
488
492
 
493
+ .tags-section-title {
494
+ margin: $CAP_SPACE_12 0;
495
+ display: block;
496
+ color: $CAP_G01;
497
+ font-weight: $FONT_WEIGHT_MEDIUM;
498
+ }
499
+
489
500
  .values-table {
490
501
  margin-bottom: $CAP_SPACE_16;
491
502
  border: $CAP_SPACE_01 solid $CAP_G12;
@@ -66,7 +66,6 @@ export const GET_WECRM_ACCOUNTS_REQUESTED = 'app/CommonTestAndPreview/GET_WECRM_
66
66
  export const GET_WECRM_ACCOUNTS_SUCCESS = 'app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_SUCCESS';
67
67
  export const GET_WECRM_ACCOUNTS_FAILURE = 'app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_FAILURE';
68
68
 
69
-
70
69
  // ============================================
71
70
  // CUSTOMER MODAL TYPE (test customer addition)
72
71
  // ============================================
@@ -87,7 +86,44 @@ export const CHANNELS = {
87
86
  ZALO: 'ZALO',
88
87
  WEBPUSH: 'WEBPUSH',
89
88
  };
90
- export const CHANNELS_USING_ANDROID_PREVIEW_DEVICE = [CHANNELS.SMS, CHANNELS.RCS, CHANNELS.WHATSAPP, CHANNELS.VIBER, CHANNELS.ZALO, CHANNELS.INAPP, CHANNELS.MOBILEPUSH];
89
+
90
+ /** Unified preview tab keys when RCS shows RCS + SMS fallback panes. */
91
+ export const PREVIEW_TAB_RCS = 'rcs';
92
+ export const PREVIEW_TAB_SMS_FALLBACK = 'smsFallback';
93
+ export const PREVIEW_TAB_KEYS = [PREVIEW_TAB_RCS, PREVIEW_TAB_SMS_FALLBACK];
94
+
95
+ /** Channels whose Test & Preview defaults to Android/iOS device frame (not desktop). */
96
+ export const CHANNELS_USING_ANDROID_PREVIEW_DEVICE = [
97
+ CHANNELS.SMS,
98
+ CHANNELS.WHATSAPP,
99
+ CHANNELS.RCS,
100
+ CHANNELS.INAPP,
101
+ CHANNELS.MOBILEPUSH,
102
+ CHANNELS.VIBER,
103
+ ];
104
+
105
+ /** RCS createMessageMeta test payload — rich card envelope literals. */
106
+ export const RCS_TEST_META_CONTENT_TYPE_RICHCARD = 'RICHCARD';
107
+ export const RCS_TEST_META_CARD_TYPE_STANDALONE = 'STANDALONE';
108
+ export const RCS_TEST_META_CARD_ORIENTATION_VERTICAL = 'VERTICAL';
109
+ export const RCS_TEST_META_CARD_WIDTH_SMALL = 'SMALL';
110
+
111
+ /** React key fallback when a custom-values section has no `key` or title id. */
112
+ export const CUSTOM_VALUES_EDITOR_SECTION_FALLBACK_KEY = 'section';
113
+
114
+ /**
115
+ * Matches at least one `{{variableName}}` token in SMS / RCS fallback template text.
116
+ */
117
+ export const SMS_MUSTACHE_TAG_PATTERN = /\{\{[^}]+\}\}/;
118
+
119
+ /** TRAI DLT `{#…#}` placeholders (same idea as `COMBINED_SMS_TEMPLATE_VAR_REGEX` in unified constants). */
120
+ export const SMS_DLT_HASH_TAG_PATTERN = /\{\#[^#]*\#\}/;
121
+
122
+ /**
123
+ * Key on `smsFallbackContent` passed into Test & Preview — RCS slot map from SmsTraiEdit
124
+ * (`onRcsFallbackEditorStateChange`), merged before tag extraction like the embedded SMS editor.
125
+ */
126
+ export const RCS_SMS_FALLBACK_VAR_MAPPED_PROP = 'rcsSmsFallbackVarMapped';
91
127
 
92
128
  // ============================================
93
129
  // DEVICE CONSTANTS