@capillarytech/creatives-library 8.0.353-alpha.5 → 8.0.353

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 (23) hide show
  1. package/package.json +1 -1
  2. package/v2Components/CommonTestAndPreview/UnifiedPreview/PreviewHeader.js +0 -17
  3. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +0 -70
  4. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +5 -44
  5. package/v2Components/CommonTestAndPreview/constants.js +0 -2
  6. package/v2Components/CommonTestAndPreview/index.js +2 -51
  7. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/PreviewHeader.test.js +0 -159
  8. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +0 -255
  9. package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -2
  10. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -194
  11. package/v2Components/FormBuilder/index.js +162 -52
  12. package/v2Components/TestAndPreviewSlidebox/index.js +2 -2
  13. package/v2Containers/App/constants.js +0 -3
  14. package/v2Containers/CreativesContainer/index.js +60 -24
  15. package/v2Containers/Templates/index.js +2 -68
  16. package/v2Containers/WebPush/Create/index.js +8 -91
  17. package/v2Containers/WebPush/Create/index.scss +0 -7
  18. package/v2Components/CommonTestAndPreview/UnifiedPreview/WebPushPreviewContent.js +0 -169
  19. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WebPushPreviewContent.test.js +0 -522
  20. package/v2Containers/App/tests/constants.test.js +0 -61
  21. package/v2Containers/Templates/tests/webpush.test.js +0 -375
  22. package/v2Containers/WebPush/Create/tests/getTemplateContent.test.js +0 -338
  23. package/v2Containers/WebPush/Create/tests/testAndPreviewIntegration.test.js +0 -325
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.353-alpha.5",
4
+ "version": "8.0.353",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -23,7 +23,6 @@ const PreviewHeader = ({
23
23
  showDeviceToggle,
24
24
  onDeviceChange,
25
25
  channel,
26
- setIsFullscreenOpen,
27
26
  }) => {
28
27
  // Determine if this is SMS, WhatsApp, RCS, InApp, MobilePush, or Viber channel (uses Android/iOS) or other channels (uses Desktop/Mobile)
29
28
  const isSmsChannel = channel === CHANNELS.SMS;
@@ -32,13 +31,8 @@ const PreviewHeader = ({
32
31
  const isInAppChannel = channel === CHANNELS.INAPP;
33
32
  const isMobilePushChannel = channel === CHANNELS.MOBILEPUSH;
34
33
  const isViberChannel = channel === CHANNELS.VIBER;
35
- const isWebPushChannel = channel === CHANNELS.WEBPUSH;
36
34
  const isAndroidIosToggle = isSmsChannel || isWhatsappChannel || isRcsChannel || isInAppChannel || isMobilePushChannel || isViberChannel;
37
35
 
38
- const handleOpenFullscreen = () => {
39
- setIsFullscreenOpen(true);
40
- };
41
-
42
36
  return (
43
37
  <CapRow className="preview-chrome">
44
38
  <div className="preview-header">
@@ -86,13 +80,6 @@ const PreviewHeader = ({
86
80
  )}
87
81
  </CapRow>
88
82
  )}
89
- {isWebPushChannel && (
90
- <CapIcon
91
- type="expander"
92
- className={device === MOBILE ? ACTIVE : ''}
93
- onClick={() => handleOpenFullscreen()}
94
- />
95
- )}
96
83
  </div>
97
84
  </CapRow>
98
85
  );
@@ -108,8 +95,6 @@ PreviewHeader.propTypes = {
108
95
  showDeviceToggle: PropTypes.bool,
109
96
  onDeviceChange: PropTypes.func,
110
97
  channel: PropTypes.string,
111
- isFullscreenOpen: PropTypes.bool,
112
- setIsFullscreenOpen: PropTypes.func,
113
98
  };
114
99
 
115
100
  PreviewHeader.defaultProps = {
@@ -118,8 +103,6 @@ PreviewHeader.defaultProps = {
118
103
  showDeviceToggle: false,
119
104
  onDeviceChange: () => {},
120
105
  channel: null,
121
- isFullscreenOpen: () => {},
122
- setIsFullscreenOpen: () => false,
123
106
  };
124
107
 
125
108
  export default PreviewHeader;
@@ -2350,76 +2350,6 @@
2350
2350
  }
2351
2351
  }
2352
2352
 
2353
- // WebPush Test & Preview Styles
2354
- .webpush-test-preview-container {
2355
- width: 100%;
2356
- position: relative;
2357
- padding-left: $CAP_SPACE_16;
2358
- padding-right: $CAP_SPACE_16;
2359
- }
2360
-
2361
- .webpush-preview-panel {
2362
- position: relative;
2363
- width: 100%;
2364
- }
2365
-
2366
- .webpush-expand-btn {
2367
- position: absolute;
2368
- top: 8px;
2369
- right: 8px;
2370
- z-index: 10;
2371
- padding: 4px;
2372
- display: flex;
2373
- align-items: center;
2374
- justify-content: center;
2375
-
2376
- &:hover {
2377
- background-color: rgba(0, 0, 0, 0.06);
2378
- border-radius: 4px;
2379
- }
2380
- }
2381
-
2382
- .webpush-fullscreen-modal {
2383
- .webpush-fullscreen-divider {
2384
- margin-top: 0;
2385
- margin-bottom: $CAP_SPACE_16;
2386
- }
2387
- .ant-modal.cap-modal-v2 {
2388
- width: 90%;
2389
- max-width: 100%;
2390
- margin-top: $CAP_SPACE_40;
2391
- }
2392
- // Preview Chrome wrapper (matches old TestAndPreviewSlidebox design)
2393
- .webpush-preview-header {
2394
- background: $CAP_WHITE;
2395
- overflow: hidden;
2396
-
2397
- .preview-divider {
2398
- margin: 0;
2399
- }
2400
-
2401
- .webpush-heading-container {
2402
- display: flex;
2403
- justify-content: space-between;
2404
- align-items: center;
2405
- padding: $CAP_SPACE_16 0 $CAP_SPACE_16 0;
2406
-
2407
- .preview-for {
2408
- gap: $CAP_SPACE_04;
2409
- align-items: center;
2410
- b {
2411
- margin-left: $CAP_SPACE_08;
2412
- }
2413
- }
2414
-
2415
- .webpush-fullscreen-close-icon {
2416
- width: $CAP_SPACE_24;
2417
- height: $CAP_SPACE_24;
2418
- }
2419
- }
2420
- }
2421
- }
2422
-
2423
2353
  // Responsive adjustments
2424
2354
  @media (max-width: 85.714rem) {
2425
2355
  .unified-preview {
@@ -6,7 +6,7 @@
6
6
  * Routes to channel-specific preview content components
7
7
  */
8
8
 
9
- import React, { useState } from 'react';
9
+ import React from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import CapRow from '@capillarytech/cap-ui-library/CapRow';
12
12
  import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
@@ -21,7 +21,6 @@ import InAppPreviewContent from './InAppPreviewContent';
21
21
  import MobilePushPreviewContent from './MobilePushPreviewContent';
22
22
  import ViberPreviewContent from './ViberPreviewContent';
23
23
  import ZaloPreviewContent from './ZaloPreviewContent';
24
- import WebPushPreviewContent from './WebPushPreviewContent';
25
24
  import { CHANNELS, DESKTOP, TABLET, MOBILE, ANDROID, IOS } from '../constants';
26
25
  import messages from '../messages';
27
26
  import './_unifiedPreview.scss';
@@ -45,7 +44,6 @@ const UnifiedPreview = ({
45
44
  * For Phase 5, we'll render placeholders
46
45
  * Phase 6+ will implement actual content components
47
46
  */
48
- const [isFullscreenOpen, setIsFullscreenOpen] = useState(false);
49
47
  const renderChannelContent = () => {
50
48
  // Phase 5: Placeholder content for all channels
51
49
  // Phase 6+: Import and render actual channel-specific components
@@ -199,40 +197,6 @@ const UnifiedPreview = ({
199
197
  );
200
198
  }
201
199
 
202
- case CHANNELS.WEBPUSH: {
203
- // WebPush content arrives as a JSON string (from getCurrentContent or preview API response)
204
- let webPushOuter = {};
205
- try {
206
- webPushOuter = typeof content === 'string' ? JSON.parse(content) : (typeof content === 'object' && content !== null ? content : {});
207
- } catch (e) {
208
- webPushOuter = {};
209
- }
210
- const webPushInner = webPushOuter?.content || {};
211
- const webPushExpandable = webPushInner?.expandableDetails || {};
212
- const webPushMedia = webPushExpandable?.media || [];
213
- const webPushCtas = webPushExpandable?.ctas || [];
214
- const webPushButtons = webPushCtas.map((cta) => ({
215
- text: cta?.title || '',
216
- url: cta?.actionLink || '',
217
- type: cta?.type || '',
218
- }));
219
- return (
220
- <WebPushPreviewContent
221
- notificationTitle={webPushInner?.title || ''}
222
- notificationBody={webPushInner?.message || ''}
223
- imageSrc={webPushMedia[0]?.url || ''}
224
- brandIconSrc={webPushInner?.iconImageUrl || ''}
225
- buttons={webPushButtons}
226
- url={webPushInner?.cta?.actionLink || ''}
227
- isUpdating={isUpdating}
228
- error={error}
229
- isFullscreenOpen={isFullscreenOpen}
230
- setIsFullscreenOpen={setIsFullscreenOpen}
231
- selectedCustomer={selectedCustomer}
232
- />
233
- );
234
- }
235
-
236
200
  default:
237
201
  return (
238
202
  <div className="channel-preview-placeholder">
@@ -258,10 +222,9 @@ const UnifiedPreview = ({
258
222
  <PreviewHeader
259
223
  selectedCustomer={selectedCustomer}
260
224
  device={device}
261
- showDeviceToggle={channel !== CHANNELS.WEBPUSH && showDeviceToggle}
225
+ showDeviceToggle={showDeviceToggle}
262
226
  onDeviceChange={onDeviceChange}
263
227
  channel={channel}
264
- setIsFullscreenOpen={setIsFullscreenOpen}
265
228
  />
266
229
  )}
267
230
  <CapRow className="preview-loading-container">
@@ -284,10 +247,9 @@ const UnifiedPreview = ({
284
247
  <PreviewHeader
285
248
  selectedCustomer={selectedCustomer}
286
249
  device={device}
287
- showDeviceToggle={channel !== CHANNELS.WEBPUSH && showDeviceToggle}
250
+ showDeviceToggle={showDeviceToggle}
288
251
  onDeviceChange={onDeviceChange}
289
252
  channel={channel}
290
- setIsFullscreenOpen={setIsFullscreenOpen}
291
253
  />
292
254
  )}
293
255
  <CapRow className="preview-error-container">
@@ -313,16 +275,15 @@ const UnifiedPreview = ({
313
275
  <PreviewHeader
314
276
  selectedCustomer={selectedCustomer}
315
277
  device={device}
316
- showDeviceToggle={channel !== CHANNELS.WEBPUSH && showDeviceToggle}
278
+ showDeviceToggle={showDeviceToggle}
317
279
  onDeviceChange={onDeviceChange}
318
280
  channel={channel}
319
- setIsFullscreenOpen={setIsFullscreenOpen}
320
281
  />
321
282
  )}
322
283
 
323
284
  {/* Channel-specific preview content */}
324
285
  <CapRow className={`preview-content-container ${!showHeader ? 'preview-content-container-no-header' : ''}`}>
325
- {[CHANNELS.EMAIL, CHANNELS.SMS, CHANNELS.WHATSAPP, CHANNELS.RCS, CHANNELS.INAPP, CHANNELS.MOBILEPUSH, CHANNELS.VIBER, CHANNELS.WEBPUSH].includes(channel) ? (
286
+ {[CHANNELS.EMAIL, CHANNELS.SMS, CHANNELS.WHATSAPP, CHANNELS.RCS, CHANNELS.INAPP, CHANNELS.MOBILEPUSH, CHANNELS.VIBER].includes(channel) ? (
326
287
  renderChannelContent()
327
288
  ) : (
328
289
  <DeviceFrame device={device || DESKTOP}>
@@ -85,7 +85,6 @@ export const CHANNELS = {
85
85
  MOBILEPUSH: 'MOBILEPUSH',
86
86
  VIBER: 'VIBER',
87
87
  ZALO: 'ZALO',
88
- WEBPUSH: 'WEBPUSH',
89
88
  };
90
89
  export const CHANNELS_USING_ANDROID_PREVIEW_DEVICE = [CHANNELS.SMS, CHANNELS.RCS, CHANNELS.WHATSAPP, CHANNELS.VIBER, CHANNELS.ZALO, CHANNELS.INAPP, CHANNELS.MOBILEPUSH];
91
90
 
@@ -204,7 +203,6 @@ export const DYNAMIC_URL = 'DYNAMIC_URL';
204
203
  export const IMAGE = 'IMAGE';
205
204
  export const VIDEO = 'VIDEO';
206
205
  export const URL = 'URL';
207
- export const DAYS = 'DAYS';
208
206
 
209
207
  // Initial Payload Template (for reference)
210
208
  export const INITIAL_PAYLOAD = {
@@ -81,8 +81,7 @@ import {
81
81
  IMAGE,
82
82
  VIDEO,
83
83
  URL,
84
- CHANNELS_USING_ANDROID_PREVIEW_DEVICE,
85
- DAYS,
84
+ CHANNELS_USING_ANDROID_PREVIEW_DEVICE
86
85
  } from './constants';
87
86
 
88
87
  // Import utilities
@@ -611,12 +610,6 @@ const CommonTestAndPreview = (props) => {
611
610
  messageBody: contentStr,
612
611
  };
613
612
 
614
- case CHANNELS.WEBPUSH:
615
- return {
616
- ...basePayload,
617
- messageBody: contentStr,
618
- };
619
-
620
613
  default:
621
614
  return basePayload;
622
615
  }
@@ -669,12 +662,6 @@ const CommonTestAndPreview = (props) => {
669
662
  templateContent: contentStr,
670
663
  };
671
664
 
672
- case CHANNELS.WEBPUSH:
673
- return {
674
- templateSubject: formDataObj?.content?.title || '',
675
- templateContent: contentStr,
676
- };
677
-
678
665
  case CHANNELS.ZALO: {
679
666
  // For Zalo, extract content from templateListParams array
680
667
  // Combine all variable values into a single string for tag extraction
@@ -1814,42 +1801,6 @@ const CommonTestAndPreview = (props) => {
1814
1801
  };
1815
1802
  }
1816
1803
 
1817
- case CHANNELS.WEBPUSH: {
1818
- const webpushData = (typeof formDataObj === 'object' && formDataObj !== null)
1819
- ? formDataObj
1820
- : {};
1821
- const innerContent = webpushData?.content || {};
1822
-
1823
- const resolvedTitle = resolveTagsInText(innerContent?.title || '', customValuesObj);
1824
- const resolvedMessage = resolveTagsInText(innerContent?.message || '', customValuesObj);
1825
-
1826
- return {
1827
- ...basePayload,
1828
- webPushMessageContent: {
1829
- channel: CHANNELS.WEBPUSH,
1830
- accountId: webpushData?.accountId || null,
1831
- content: {
1832
- title: resolvedTitle,
1833
- message: resolvedMessage,
1834
- ...(innerContent?.iconImageUrl && { iconImageUrl: innerContent.iconImageUrl }),
1835
- ...(innerContent?.cta && { cta: innerContent.cta }),
1836
- ...(innerContent?.expandableDetails && { expandableDetails: innerContent.expandableDetails }),
1837
- },
1838
- messageSubject: webpushData?.messageSubject || resolvedTitle || '',
1839
- },
1840
- webPushDeliverySettings: {
1841
- channelSettings: {
1842
- channel: CHANNELS.WEBPUSH,
1843
- notificationTtl: {
1844
- duration: 7,
1845
- timeUnit: DAYS,
1846
- },
1847
- },
1848
- additionalSettings: {},
1849
- },
1850
- };
1851
- }
1852
-
1853
1804
  default:
1854
1805
  return basePayload;
1855
1806
  }
@@ -1881,7 +1832,7 @@ const CommonTestAndPreview = (props) => {
1881
1832
  contentObj = hasPreviewCallBeenMade && previewDataHtml?.resolvedBody
1882
1833
  ? previewDataHtml.resolvedBody
1883
1834
  : getCurrentContent || '';
1884
- } else if (channel === CHANNELS.WHATSAPP || channel === CHANNELS.WEBPUSH) {
1835
+ } else if (channel === CHANNELS.WHATSAPP) {
1885
1836
  // For WhatsApp, content is an object with templateMsg, media, CTA, etc.
1886
1837
  // Content comes from WhatsApp component state, passed via content prop
1887
1838
  let resolvedContent = null;
@@ -514,163 +514,4 @@ describe('PreviewHeader', () => {
514
514
  consoleSpy.mockRestore();
515
515
  });
516
516
  });
517
-
518
- describe('WEBPUSH channel - Fullscreen expander', () => {
519
- it('should render expander icon for WEBPUSH channel', () => {
520
- const setIsFullscreenOpen = jest.fn();
521
- const props = {
522
- ...defaultProps,
523
- channel: CHANNELS.WEBPUSH,
524
- setIsFullscreenOpen,
525
- };
526
-
527
- const { container } = render(
528
- <TestWrapper>
529
- <PreviewHeader {...props} />
530
- </TestWrapper>
531
- );
532
-
533
- // expander icon should be present for WEBPUSH
534
- const expanderIcon = container.querySelector('[class*="expander"], [aria-label*="expander"], .anticon');
535
- expect(expanderIcon).toBeTruthy();
536
- });
537
-
538
- it('should NOT render expander icon for non-WEBPUSH channels', () => {
539
- const setIsFullscreenOpen = jest.fn();
540
- const props = {
541
- ...defaultProps,
542
- channel: CHANNELS.EMAIL,
543
- setIsFullscreenOpen,
544
- showDeviceToggle: false,
545
- };
546
-
547
- const { container } = render(
548
- <TestWrapper>
549
- <PreviewHeader {...props} />
550
- </TestWrapper>
551
- );
552
-
553
- // No expander icon for EMAIL channel (only device toggle icons may appear)
554
- const expanderIcon = container.querySelector('[class*="expander"]');
555
- expect(expanderIcon).toBeNull();
556
- });
557
-
558
- it('should call setIsFullscreenOpen(true) when expander icon is clicked', () => {
559
- const setIsFullscreenOpen = jest.fn();
560
- const props = {
561
- ...defaultProps,
562
- channel: CHANNELS.WEBPUSH,
563
- setIsFullscreenOpen,
564
- };
565
-
566
- const { container } = render(
567
- <TestWrapper>
568
- <PreviewHeader {...props} />
569
- </TestWrapper>
570
- );
571
-
572
- const expanderIcon = container.querySelector('[class*="expander"]') ||
573
- container.querySelector('.anticon');
574
- if (expanderIcon) {
575
- fireEvent.click(expanderIcon);
576
- expect(setIsFullscreenOpen).toHaveBeenCalledWith(true);
577
- }
578
- });
579
-
580
- it('should render expander icon with ACTIVE class when device is MOBILE', () => {
581
- const setIsFullscreenOpen = jest.fn();
582
- const props = {
583
- ...defaultProps,
584
- channel: CHANNELS.WEBPUSH,
585
- device: MOBILE,
586
- setIsFullscreenOpen,
587
- };
588
-
589
- const { container } = render(
590
- <TestWrapper>
591
- <PreviewHeader {...props} />
592
- </TestWrapper>
593
- );
594
-
595
- // MOBILE device should give ACTIVE class to expander
596
- const activeEl = container.querySelector('.active');
597
- expect(activeEl).toBeTruthy();
598
- });
599
-
600
- it('should render expander icon without ACTIVE class when device is DESKTOP', () => {
601
- const setIsFullscreenOpen = jest.fn();
602
- const props = {
603
- ...defaultProps,
604
- channel: CHANNELS.WEBPUSH,
605
- device: DESKTOP,
606
- setIsFullscreenOpen,
607
- };
608
-
609
- const { container } = render(
610
- <TestWrapper>
611
- <PreviewHeader {...props} />
612
- </TestWrapper>
613
- );
614
-
615
- // DESKTOP device should NOT give ACTIVE class to expander
616
- const activeEl = container.querySelector('.active');
617
- expect(activeEl).toBeNull();
618
- });
619
-
620
- it('should render expander icon alongside device content for WEBPUSH', () => {
621
- // Note: suppression of showDeviceToggle for WEBPUSH is done in UnifiedPreview (parent),
622
- // not in PreviewHeader itself. PreviewHeader only adds the expander icon for WEBPUSH.
623
- const setIsFullscreenOpen = jest.fn();
624
- const props = {
625
- ...defaultProps,
626
- channel: CHANNELS.WEBPUSH,
627
- setIsFullscreenOpen,
628
- showDeviceToggle: false,
629
- };
630
-
631
- const { container } = render(
632
- <TestWrapper>
633
- <PreviewHeader {...props} />
634
- </TestWrapper>
635
- );
636
-
637
- // expander icon should be present for WEBPUSH
638
- const expanderIcon = container.querySelector('[class*="expander"]') ||
639
- container.querySelector('.anticon');
640
- expect(expanderIcon).toBeTruthy();
641
- });
642
-
643
- it('should accept isFullscreenOpen and setIsFullscreenOpen as props', () => {
644
- const setIsFullscreenOpen = jest.fn();
645
- const props = {
646
- ...defaultProps,
647
- channel: CHANNELS.WEBPUSH,
648
- isFullscreenOpen: false,
649
- setIsFullscreenOpen,
650
- };
651
-
652
- expect(() =>
653
- render(
654
- <TestWrapper>
655
- <PreviewHeader {...props} />
656
- </TestWrapper>
657
- )
658
- ).not.toThrow();
659
- });
660
-
661
- it('should use default setIsFullscreenOpen when not provided', () => {
662
- const props = {
663
- ...defaultProps,
664
- channel: CHANNELS.WEBPUSH,
665
- };
666
-
667
- expect(() =>
668
- render(
669
- <TestWrapper>
670
- <PreviewHeader {...props} />
671
- </TestWrapper>
672
- )
673
- ).not.toThrow();
674
- });
675
- });
676
517
  });