@capillarytech/creatives-library 8.0.359 → 8.0.360-alpha.0

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.
@@ -123,3 +123,178 @@
123
123
  .test-and-preview-button {
124
124
  margin-left: 6.25rem;
125
125
  }
126
+
127
+ .viber-remove-row-btn {
128
+ margin-top: $CAP_SPACE_24;
129
+ }
130
+
131
+ .viber-add-row-btn {
132
+ margin-top: $CAP_SPACE_08;
133
+ color: $FONT_COLOR_05;
134
+ background: transparent;
135
+ border: none;
136
+ box-shadow: none;
137
+
138
+ &:hover,
139
+ &:focus,
140
+ &:active {
141
+ color: $FONT_COLOR_05;
142
+ background: transparent;
143
+ border: none;
144
+ }
145
+ }
146
+
147
+ .viber-carousel-section {
148
+ margin-top: $CAP_SPACE_16;
149
+ }
150
+
151
+ .viber-carousel-card {
152
+ border: 1px solid $CAP_G06;
153
+ border-radius: $CAP_SPACE_04;
154
+ padding: $CAP_SPACE_16;
155
+ margin-bottom: $CAP_SPACE_16;
156
+ }
157
+
158
+ .viber-carousel-card-selector {
159
+ margin-bottom: $CAP_SPACE_16;
160
+ border-bottom: 1px solid $CAP_G07;
161
+ }
162
+
163
+ .viber-carousel-card-selector-btn {
164
+ min-width: 2.5rem;
165
+ padding: $CAP_SPACE_12 $CAP_SPACE_20;
166
+ border: none;
167
+ background: transparent;
168
+ color: $FONT_COLOR_04;
169
+ font-size: $CAP_SPACE_40;
170
+ cursor: pointer;
171
+ border-bottom: 3px solid transparent;
172
+ }
173
+
174
+ .viber-carousel-card-selector-btn.active {
175
+ color: $FONT_COLOR_01;
176
+ border-bottom-color: currentColor;
177
+ }
178
+
179
+ .viber-carousel-add-btn {
180
+ border-left: 1px solid $CAP_G07;
181
+ margin-left: $CAP_SPACE_16;
182
+ padding-left: $CAP_SPACE_24;
183
+ padding-right: $CAP_SPACE_24;
184
+ }
185
+
186
+ .viber-carousel-image-recommendation {
187
+ display: block;
188
+ margin: $CAP_SPACE_08 0 $CAP_SPACE_16 0;
189
+ color: $FONT_COLOR_03;
190
+ }
191
+
192
+ .viber-carousel-card-title-header {
193
+ align-items: center;
194
+ }
195
+
196
+ .viber-carousel-button {
197
+ border-top: 1px dashed $CAP_G06;
198
+ margin-top: $CAP_SPACE_12;
199
+ padding-top: $CAP_SPACE_12;
200
+ }
201
+
202
+ .viber-carousel-button-label {
203
+ margin-top: $CAP_SPACE_16;
204
+ }
205
+
206
+ .viber-carousel-button-title-header {
207
+ align-items: center;
208
+ }
209
+
210
+ .viber-carousel-url-type-select {
211
+ .ant-select-selection-selected-value {
212
+ max-width: none;
213
+ overflow: visible;
214
+ text-overflow: unset;
215
+ }
216
+
217
+ .ant-select-selection__rendered {
218
+ margin-right: $CAP_SPACE_24;
219
+ }
220
+ }
221
+
222
+ .viber-carousel-url-type-dropdown.ant-select-dropdown {
223
+ min-width: 12rem;
224
+ }
225
+
226
+ .viber-carousel-url-type-dropdown .ant-select-dropdown-menu-item {
227
+ white-space: normal;
228
+ word-break: break-word;
229
+ height: auto;
230
+ line-height: 1.25rem;
231
+ padding-top: $CAP_SPACE_06;
232
+ padding-bottom: $CAP_SPACE_06;
233
+ }
234
+
235
+ .viber-carousel-saved-button {
236
+ display: flex;
237
+ align-items: center;
238
+ border: 1px solid $CAP_G06;
239
+ border-radius: $CAP_SPACE_04;
240
+ padding: $CAP_SPACE_12 $CAP_SPACE_16;
241
+ margin-top: $CAP_SPACE_12;
242
+ min-height: 2.75rem;
243
+ box-sizing: border-box;
244
+ }
245
+
246
+ .viber-carousel-saved-button-icon {
247
+ margin-right: $CAP_SPACE_12;
248
+ color: $FONT_COLOR_01;
249
+ flex-shrink: 0;
250
+ line-height: 1;
251
+ }
252
+
253
+ .viber-carousel-saved-button-text {
254
+ flex: 1;
255
+ margin-right: $CAP_SPACE_12;
256
+ min-width: 0;
257
+ line-height: 1.25rem;
258
+ }
259
+
260
+ .viber-carousel-saved-button-actions {
261
+ display: flex;
262
+ align-items: center;
263
+ gap: $CAP_SPACE_24;
264
+ margin-left: auto;
265
+ flex-shrink: 0;
266
+ min-height: 1.5rem;
267
+
268
+ .button-edit-icon {
269
+ margin-left: 0;
270
+ display: flex;
271
+ align-items: center;
272
+ justify-content: center;
273
+ line-height: 1;
274
+ }
275
+ }
276
+
277
+ .viber-carousel-delete-icon {
278
+ margin-left: 0;
279
+ }
280
+
281
+ .viber-carousel-delete-icon-btn {
282
+ margin-left: $CAP_SPACE_08;
283
+ }
284
+
285
+ .viber-carousel-tab-label-disabled {
286
+ color: $FONT_COLOR_04;
287
+ cursor: not-allowed;
288
+ }
289
+
290
+ .viber-carousel-field-length-top {
291
+ display: block;
292
+ text-align: right;
293
+ margin-top: $CAP_SPACE_04;
294
+ }
295
+
296
+ .viber-form-error {
297
+ color: $CAP_RED;
298
+ display: block;
299
+ margin-top: $CAP_SPACE_08;
300
+ }
@@ -154,6 +154,10 @@ export default defineMessages({
154
154
  id: `${scope}.mediaVideo`,
155
155
  defaultMessage: 'Video',
156
156
  },
157
+ mediaCarousel: {
158
+ id: `${scope}.mediaCarousel`,
159
+ defaultMessage: 'Carousel',
160
+ },
157
161
  videoErrorMessage: {
158
162
  id: `${scope}.videoErrorMessage`,
159
163
  defaultMessage: 'Please upload the video with allowed file extension, size, dimension and aspect ratio',
@@ -214,4 +218,116 @@ export default defineMessages({
214
218
  id: `${scope}.assetIdMissingError`,
215
219
  defaultMessage: 'Asset upload initiated but no asset ID was returned from the server. Unable to track processing status.',
216
220
  },
221
+ carouselCardsLabel: {
222
+ id: `${scope}.carouselCardsLabel`,
223
+ defaultMessage: 'Carousel cards',
224
+ },
225
+ carouselCardHeading: {
226
+ id: `${scope}.carouselCardHeading`,
227
+ defaultMessage: 'Card {index}',
228
+ },
229
+ carouselCardTextLabel: {
230
+ id: `${scope}.carouselCardTextLabel`,
231
+ defaultMessage: 'Title',
232
+ },
233
+ carouselCardTextPlaceholder: {
234
+ id: `${scope}.carouselCardTextPlaceholder`,
235
+ defaultMessage: 'Enter title',
236
+ },
237
+ carouselMediaUrlLabel: {
238
+ id: `${scope}.carouselMediaUrlLabel`,
239
+ defaultMessage: 'Card media URL',
240
+ },
241
+ carouselMediaUrlPlaceholder: {
242
+ id: `${scope}.carouselMediaUrlPlaceholder`,
243
+ defaultMessage: 'https://example.com/image.jpg',
244
+ },
245
+ carouselButtonTitleLabel: {
246
+ id: `${scope}.carouselButtonTitleLabel`,
247
+ defaultMessage: 'Button title',
248
+ },
249
+ carouselButtonTitlePlaceholder: {
250
+ id: `${scope}.carouselButtonTitlePlaceholder`,
251
+ defaultMessage: 'Enter button title',
252
+ },
253
+ carouselButtonActionLabel: {
254
+ id: `${scope}.carouselButtonActionLabel`,
255
+ defaultMessage: 'Button action URL',
256
+ },
257
+ carouselButtonUrlTypeLabel: {
258
+ id: `${scope}.carouselButtonUrlTypeLabel`,
259
+ defaultMessage: 'URL type',
260
+ },
261
+ carouselUrlTypeStatic: {
262
+ id: `${scope}.carouselUrlTypeStatic`,
263
+ defaultMessage: 'Static',
264
+ },
265
+ carouselUrlTypeDynamic: {
266
+ id: `${scope}.carouselUrlTypeDynamic`,
267
+ defaultMessage: 'Dynamic',
268
+ },
269
+ carouselButtonActionPlaceholder: {
270
+ id: `${scope}.carouselButtonActionPlaceholder`,
271
+ defaultMessage: 'https://example.com/action',
272
+ },
273
+ addCarouselCard: {
274
+ id: `${scope}.addCarouselCard`,
275
+ defaultMessage: 'Add card',
276
+ },
277
+ removeCarouselCard: {
278
+ id: `${scope}.removeCarouselCard`,
279
+ defaultMessage: 'Remove card',
280
+ },
281
+ addCarouselButton: {
282
+ id: `${scope}.addCarouselButton`,
283
+ defaultMessage: 'Add button',
284
+ },
285
+ removeCarouselButton: {
286
+ id: `${scope}.removeCarouselButton`,
287
+ defaultMessage: 'Remove button',
288
+ },
289
+ carouselCardsLimitError: {
290
+ id: `${scope}.carouselCardsLimitError`,
291
+ defaultMessage: 'Carousel message requires 2 to 5 cards',
292
+ },
293
+ carouselCardError: {
294
+ id: `${scope}.carouselCardError`,
295
+ defaultMessage: 'Each card needs text and a valid media URL',
296
+ },
297
+ carouselButtonError: {
298
+ id: `${scope}.carouselButtonError`,
299
+ defaultMessage: 'Each button needs title and a valid action URL',
300
+ },
301
+ characterLimitExceededError: {
302
+ id: `${scope}.characterLimitExceededError`,
303
+ defaultMessage: 'Character limit exceeded',
304
+ },
305
+ textCannotBeEmptyError: {
306
+ id: `${scope}.textCannotBeEmptyError`,
307
+ defaultMessage: "Text can't be empty",
308
+ },
309
+ urlCannotBeEmptyError: {
310
+ id: `${scope}.urlCannotBeEmptyError`,
311
+ defaultMessage: "URL can't be empty",
312
+ },
313
+ carouselButtonUrlMaxLengthError: {
314
+ id: `${scope}.carouselButtonUrlMaxLengthError`,
315
+ defaultMessage: 'URL can not exceed 1000 characters',
316
+ },
317
+ carouselFirstButtonTitleMaxLengthError: {
318
+ id: `${scope}.carouselFirstButtonTitleMaxLengthError`,
319
+ defaultMessage: 'Button text should not exceed 10',
320
+ },
321
+ carouselSecondButtonTitleMaxLengthError: {
322
+ id: `${scope}.carouselSecondButtonTitleMaxLengthError`,
323
+ defaultMessage: 'Button text should not exceed 12',
324
+ },
325
+ carouselCardTitleMinLengthError: {
326
+ id: `${scope}.carouselCardTitleMinLengthError`,
327
+ defaultMessage: 'Minimum 2 characters required',
328
+ },
329
+ carouselCardTitleMaxLengthError: {
330
+ id: `${scope}.carouselCardTitleMaxLengthError`,
331
+ defaultMessage: 'Title can not be more than 38 characters',
332
+ },
217
333
  });
@@ -383,4 +383,84 @@ describe('Test Viber container', () => {
383
383
  const doneBtn = screen.getByRole('button', { name: /done/i });
384
384
  expect(doneBtn).toBeEnabled();
385
385
  });
386
+
387
+ it('does not show empty URL error on focus or while typing in carousel button action', async () => {
388
+ renderComponent({
389
+ actions: mockActions,
390
+ globalActions: mockGlobalActions,
391
+ templateData: { mode: 'create' },
392
+ viber: {
393
+ uploadedAssetData: {},
394
+ createTemplateInProgress: false,
395
+ },
396
+ location: {
397
+ pathname: '/sms/edit',
398
+ query: { type: false, module: 'default' },
399
+ search: '',
400
+ },
401
+ isFullMode: true,
402
+ handleClose: jest.fn(),
403
+ });
404
+
405
+ fireEvent.click(screen.getByRole('radio', { name: /carousel/i }));
406
+ const actionInput = await screen.findByPlaceholderText('https://example.com/action');
407
+
408
+ fireEvent.focus(actionInput);
409
+ expect(screen.queryByText("URL can't be empty")).not.toBeInTheDocument();
410
+
411
+ fireEvent.change(actionInput, { target: { value: 'https://' } });
412
+ expect(screen.queryByText("URL can't be empty")).not.toBeInTheDocument();
413
+ });
414
+
415
+ it('shows empty URL error on blur when carousel button action is left empty', async () => {
416
+ renderComponent({
417
+ actions: mockActions,
418
+ globalActions: mockGlobalActions,
419
+ templateData: { mode: 'create' },
420
+ viber: {
421
+ uploadedAssetData: {},
422
+ createTemplateInProgress: false,
423
+ },
424
+ location: {
425
+ pathname: '/sms/edit',
426
+ query: { type: false, module: 'default' },
427
+ search: '',
428
+ },
429
+ isFullMode: true,
430
+ handleClose: jest.fn(),
431
+ });
432
+
433
+ fireEvent.click(screen.getByRole('radio', { name: /carousel/i }));
434
+ const actionInput = await screen.findByPlaceholderText('https://example.com/action');
435
+
436
+ fireEvent.focus(actionInput);
437
+ fireEvent.blur(actionInput);
438
+
439
+ expect(await screen.findByText("URL can't be empty")).toBeInTheDocument();
440
+ });
441
+
442
+ it('shows empty URL error on save when carousel button action is empty', async () => {
443
+ renderComponent({
444
+ actions: mockActions,
445
+ globalActions: mockGlobalActions,
446
+ templateData: { mode: 'create' },
447
+ viber: {
448
+ uploadedAssetData: {},
449
+ createTemplateInProgress: false,
450
+ },
451
+ location: {
452
+ pathname: '/sms/edit',
453
+ query: { type: false, module: 'default' },
454
+ search: '',
455
+ },
456
+ isFullMode: true,
457
+ handleClose: jest.fn(),
458
+ });
459
+
460
+ fireEvent.click(screen.getByRole('radio', { name: /carousel/i }));
461
+ await screen.findByPlaceholderText('https://example.com/action');
462
+ fireEvent.click(screen.getByRole('button', { name: /save/i }));
463
+
464
+ expect(await screen.findByText("URL can't be empty")).toBeInTheDocument();
465
+ });
386
466
  });
@@ -3058,8 +3058,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
3058
3058
  whatsappVideoSrcAndPreview?.whatsappVideoPreviewImg;
3059
3059
  break;
3060
3060
  case WHATSAPP_MEDIA_TYPES.DOCUMENT:
3061
- mediaPreview.whatsappDocSource = whatsappDocSource;
3062
- mediaPreview.whatsappDocParams = whatsappDocParams;
3061
+ mediaPreview.docPreview = docPreview;
3063
3062
  break;
3064
3063
  default:
3065
3064
  break;
@@ -3137,9 +3136,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
3137
3136
  whatsappVideoSrcAndPreview?.whatsappVideoPreviewImg;
3138
3137
  break;
3139
3138
  case WHATSAPP_MEDIA_TYPES.DOCUMENT:
3140
- // Intentionally not setting mediaPreview.docPreview = docPreview here — docPreview is JSX
3141
- // and this object is JSON.stringified by CommonTestAndPreview (circular ref crash).
3142
- // whatsappDocParams below carries the raw data; WhatsAppPreviewContent renders from that.
3139
+ mediaPreview.docPreview = docPreview;
3143
3140
  break;
3144
3141
  default:
3145
3142
  break;