@capillarytech/creatives-library 9.0.13-alpha.1 → 9.0.13-beta.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.
- package/constants/unified.js +3 -0
- package/package.json +1 -1
- package/utils/common.js +8 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +15 -108
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -141
- package/v2Components/CommonTestAndPreview/index.js +26 -244
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +0 -364
- package/v2Components/FormBuilder/Classic.js +4487 -0
- package/v2Components/FormBuilder/Functional/FormBuilderShell.js +369 -0
- package/v2Components/FormBuilder/Functional/channels/registry.js +17 -0
- package/v2Components/FormBuilder/Functional/channels/sms/buildSubmitPayload.js +9 -0
- package/v2Components/FormBuilder/Functional/channels/sms/config.js +30 -0
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +46 -0
- package/v2Components/FormBuilder/Functional/channels/sms/getLiquidContent.js +13 -0
- package/v2Components/FormBuilder/Functional/channels/sms/index.js +22 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +52 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getLiquidContent.test.js +25 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +87 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +89 -0
- package/v2Components/FormBuilder/Functional/constants.js +42 -0
- package/v2Components/FormBuilder/Functional/core/schema/fieldRegistry.js +38 -0
- package/v2Components/FormBuilder/Functional/core/schema/initializeFormState.js +85 -0
- package/v2Components/FormBuilder/Functional/core/store/formReducer.js +81 -0
- package/v2Components/FormBuilder/Functional/core/store/selectors.js +30 -0
- package/v2Components/FormBuilder/Functional/core/store/toLegacyFormData.js +91 -0
- package/v2Components/FormBuilder/Functional/index.js +26 -0
- package/v2Components/FormBuilder/Functional/layout/FieldSlot.js +59 -0
- package/v2Components/FormBuilder/Functional/layout/SchemaForm.js +32 -0
- package/v2Components/FormBuilder/Functional/layout/Section.js +116 -0
- package/v2Components/FormBuilder/Functional/renderers/smsRenderers.js +258 -0
- package/v2Components/FormBuilder/Functional/tests/channelRegistry.test.js +21 -0
- package/v2Components/FormBuilder/Functional/tests/fieldRegistry.test.js +65 -0
- package/v2Components/FormBuilder/Functional/tests/fieldSlot.test.js +97 -0
- package/v2Components/FormBuilder/Functional/tests/fixtures/smsParityCases.js +192 -0
- package/v2Components/FormBuilder/Functional/tests/formReducer.test.js +129 -0
- package/v2Components/FormBuilder/Functional/tests/initializeFormState.test.js +132 -0
- package/v2Components/FormBuilder/Functional/tests/schemaForm.test.js +40 -0
- package/v2Components/FormBuilder/Functional/tests/section.test.js +99 -0
- package/v2Components/FormBuilder/Functional/tests/selectors.test.js +67 -0
- package/v2Components/FormBuilder/Functional/tests/sms.crossFlowParity.test.js +155 -0
- package/v2Components/FormBuilder/Functional/tests/sms.liquid.test.js +172 -0
- package/v2Components/FormBuilder/Functional/tests/sms.rollout.test.js +122 -0
- package/v2Components/FormBuilder/Functional/tests/sms.shell.parity.test.js +329 -0
- package/v2Components/FormBuilder/Functional/tests/smsRenderers.test.js +160 -0
- package/v2Components/FormBuilder/Functional/tests/toLegacyFormData.test.js +95 -0
- package/v2Components/FormBuilder/_formBuilder.scss +5 -0
- package/v2Components/FormBuilder/index.js +41 -4479
- package/v2Components/FormBuilder/tests/__snapshots__/sms.characterization.test.js.snap +114 -0
- package/v2Components/FormBuilder/tests/entryGate.test.js +106 -0
- package/v2Components/FormBuilder/tests/sms.characterization.test.js +336 -0
- package/v2Containers/Templates/_templates.scss +0 -83
- package/v2Containers/Templates/index.js +10 -90
- package/v2Containers/Viber/constants.js +0 -21
- package/v2Containers/Viber/index.js +49 -719
- package/v2Containers/Viber/index.scss +0 -175
- package/v2Containers/Viber/messages.js +0 -121
- package/v2Containers/Viber/tests/index.test.js +0 -80
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberCarouselPreviewCards.js +0 -132
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_viberCarouselPreviewCards.scss +0 -132
|
@@ -106,178 +106,3 @@
|
|
|
106
106
|
.test-and-preview-button {
|
|
107
107
|
margin-left: 6.25rem;
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
.viber-remove-row-btn {
|
|
111
|
-
margin-top: $CAP_SPACE_24;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.viber-add-row-btn {
|
|
115
|
-
margin-top: $CAP_SPACE_08;
|
|
116
|
-
color: $FONT_COLOR_05;
|
|
117
|
-
background: transparent;
|
|
118
|
-
border: none;
|
|
119
|
-
box-shadow: none;
|
|
120
|
-
|
|
121
|
-
&:hover,
|
|
122
|
-
&:focus,
|
|
123
|
-
&:active {
|
|
124
|
-
color: $FONT_COLOR_05;
|
|
125
|
-
background: transparent;
|
|
126
|
-
border: none;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.viber-carousel-section {
|
|
131
|
-
margin-top: $CAP_SPACE_16;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.viber-carousel-card {
|
|
135
|
-
border: 1px solid $CAP_G06;
|
|
136
|
-
border-radius: $CAP_SPACE_04;
|
|
137
|
-
padding: $CAP_SPACE_16;
|
|
138
|
-
margin-bottom: $CAP_SPACE_16;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.viber-carousel-card-selector {
|
|
142
|
-
margin-bottom: $CAP_SPACE_16;
|
|
143
|
-
border-bottom: 1px solid $CAP_G07;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.viber-carousel-card-selector-btn {
|
|
147
|
-
min-width: 2.5rem;
|
|
148
|
-
padding: $CAP_SPACE_12 $CAP_SPACE_20;
|
|
149
|
-
border: none;
|
|
150
|
-
background: transparent;
|
|
151
|
-
color: $FONT_COLOR_04;
|
|
152
|
-
font-size: $CAP_SPACE_40;
|
|
153
|
-
cursor: pointer;
|
|
154
|
-
border-bottom: 3px solid transparent;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.viber-carousel-card-selector-btn.active {
|
|
158
|
-
color: $FONT_COLOR_01;
|
|
159
|
-
border-bottom-color: currentColor;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.viber-carousel-add-btn {
|
|
163
|
-
border-left: 1px solid $CAP_G07;
|
|
164
|
-
margin-left: $CAP_SPACE_16;
|
|
165
|
-
padding-left: $CAP_SPACE_24;
|
|
166
|
-
padding-right: $CAP_SPACE_24;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.viber-carousel-image-recommendation {
|
|
170
|
-
display: block;
|
|
171
|
-
margin: $CAP_SPACE_08 0 $CAP_SPACE_16 0;
|
|
172
|
-
color: $FONT_COLOR_03;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.viber-carousel-card-title-header {
|
|
176
|
-
align-items: center;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.viber-carousel-button {
|
|
180
|
-
border-top: 1px dashed $CAP_G06;
|
|
181
|
-
margin-top: $CAP_SPACE_12;
|
|
182
|
-
padding-top: $CAP_SPACE_12;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.viber-carousel-button-label {
|
|
186
|
-
margin-top: $CAP_SPACE_16;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.viber-carousel-button-title-header {
|
|
190
|
-
align-items: center;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.viber-carousel-url-type-select {
|
|
194
|
-
.ant-select-selection-selected-value {
|
|
195
|
-
max-width: none;
|
|
196
|
-
overflow: visible;
|
|
197
|
-
text-overflow: unset;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.ant-select-selection__rendered {
|
|
201
|
-
margin-right: $CAP_SPACE_24;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.viber-carousel-url-type-dropdown.ant-select-dropdown {
|
|
206
|
-
min-width: 12rem;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.viber-carousel-url-type-dropdown .ant-select-dropdown-menu-item {
|
|
210
|
-
white-space: normal;
|
|
211
|
-
word-break: break-word;
|
|
212
|
-
height: auto;
|
|
213
|
-
line-height: 1.25rem;
|
|
214
|
-
padding-top: $CAP_SPACE_06;
|
|
215
|
-
padding-bottom: $CAP_SPACE_06;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.viber-carousel-saved-button {
|
|
219
|
-
display: flex;
|
|
220
|
-
align-items: center;
|
|
221
|
-
border: 1px solid $CAP_G06;
|
|
222
|
-
border-radius: $CAP_SPACE_04;
|
|
223
|
-
padding: $CAP_SPACE_12 $CAP_SPACE_16;
|
|
224
|
-
margin-top: $CAP_SPACE_12;
|
|
225
|
-
min-height: 2.75rem;
|
|
226
|
-
box-sizing: border-box;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.viber-carousel-saved-button-icon {
|
|
230
|
-
margin-right: $CAP_SPACE_12;
|
|
231
|
-
color: $FONT_COLOR_01;
|
|
232
|
-
flex-shrink: 0;
|
|
233
|
-
line-height: 1;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.viber-carousel-saved-button-text {
|
|
237
|
-
flex: 1;
|
|
238
|
-
margin-right: $CAP_SPACE_12;
|
|
239
|
-
min-width: 0;
|
|
240
|
-
line-height: 1.25rem;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.viber-carousel-saved-button-actions {
|
|
244
|
-
display: flex;
|
|
245
|
-
align-items: center;
|
|
246
|
-
gap: $CAP_SPACE_24;
|
|
247
|
-
margin-left: auto;
|
|
248
|
-
flex-shrink: 0;
|
|
249
|
-
min-height: 1.5rem;
|
|
250
|
-
|
|
251
|
-
.button-edit-icon {
|
|
252
|
-
margin-left: 0;
|
|
253
|
-
display: flex;
|
|
254
|
-
align-items: center;
|
|
255
|
-
justify-content: center;
|
|
256
|
-
line-height: 1;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
.viber-carousel-delete-icon {
|
|
261
|
-
margin-left: 0;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.viber-carousel-delete-icon-btn {
|
|
265
|
-
margin-left: $CAP_SPACE_08;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.viber-carousel-tab-label-disabled {
|
|
269
|
-
color: $FONT_COLOR_04;
|
|
270
|
-
cursor: not-allowed;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
.viber-carousel-field-length-top {
|
|
274
|
-
display: block;
|
|
275
|
-
text-align: right;
|
|
276
|
-
margin-top: $CAP_SPACE_04;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
.viber-form-error {
|
|
280
|
-
color: $CAP_RED;
|
|
281
|
-
display: block;
|
|
282
|
-
margin-top: $CAP_SPACE_08;
|
|
283
|
-
}
|
|
@@ -154,10 +154,6 @@ export default defineMessages({
|
|
|
154
154
|
id: `${scope}.mediaVideo`,
|
|
155
155
|
defaultMessage: 'Video',
|
|
156
156
|
},
|
|
157
|
-
mediaCarousel: {
|
|
158
|
-
id: `${scope}.mediaCarousel`,
|
|
159
|
-
defaultMessage: 'Carousel',
|
|
160
|
-
},
|
|
161
157
|
videoErrorMessage: {
|
|
162
158
|
id: `${scope}.videoErrorMessage`,
|
|
163
159
|
defaultMessage: 'Please upload the video with allowed file extension, size, dimension and aspect ratio',
|
|
@@ -218,121 +214,4 @@ export default defineMessages({
|
|
|
218
214
|
id: `${scope}.assetIdMissingError`,
|
|
219
215
|
defaultMessage: 'Asset upload initiated but no asset ID was returned from the server. Unable to track processing status.',
|
|
220
216
|
},
|
|
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
|
-
carouselImageRecommendation: {
|
|
246
|
-
id: `${scope}.carouselImageRecommendation`,
|
|
247
|
-
defaultMessage:
|
|
248
|
-
'Supported image types are .jpg, .jpeg, .png. Max size: 10 MB. Recommended resolution: 696 px x 600 px.',
|
|
249
|
-
},
|
|
250
|
-
carouselButtonTitleLabel: {
|
|
251
|
-
id: `${scope}.carouselButtonTitleLabel`,
|
|
252
|
-
defaultMessage: 'Button title',
|
|
253
|
-
},
|
|
254
|
-
carouselButtonTitlePlaceholder: {
|
|
255
|
-
id: `${scope}.carouselButtonTitlePlaceholder`,
|
|
256
|
-
defaultMessage: 'Enter button title',
|
|
257
|
-
},
|
|
258
|
-
carouselButtonActionLabel: {
|
|
259
|
-
id: `${scope}.carouselButtonActionLabel`,
|
|
260
|
-
defaultMessage: 'Button action URL',
|
|
261
|
-
},
|
|
262
|
-
carouselButtonUrlTypeLabel: {
|
|
263
|
-
id: `${scope}.carouselButtonUrlTypeLabel`,
|
|
264
|
-
defaultMessage: 'URL type',
|
|
265
|
-
},
|
|
266
|
-
carouselUrlTypeStatic: {
|
|
267
|
-
id: `${scope}.carouselUrlTypeStatic`,
|
|
268
|
-
defaultMessage: 'Static',
|
|
269
|
-
},
|
|
270
|
-
carouselUrlTypeDynamic: {
|
|
271
|
-
id: `${scope}.carouselUrlTypeDynamic`,
|
|
272
|
-
defaultMessage: 'Dynamic',
|
|
273
|
-
},
|
|
274
|
-
carouselButtonActionPlaceholder: {
|
|
275
|
-
id: `${scope}.carouselButtonActionPlaceholder`,
|
|
276
|
-
defaultMessage: 'https://example.com/action',
|
|
277
|
-
},
|
|
278
|
-
addCarouselCard: {
|
|
279
|
-
id: `${scope}.addCarouselCard`,
|
|
280
|
-
defaultMessage: 'Add card',
|
|
281
|
-
},
|
|
282
|
-
removeCarouselCard: {
|
|
283
|
-
id: `${scope}.removeCarouselCard`,
|
|
284
|
-
defaultMessage: 'Remove card',
|
|
285
|
-
},
|
|
286
|
-
addCarouselButton: {
|
|
287
|
-
id: `${scope}.addCarouselButton`,
|
|
288
|
-
defaultMessage: 'Add button',
|
|
289
|
-
},
|
|
290
|
-
removeCarouselButton: {
|
|
291
|
-
id: `${scope}.removeCarouselButton`,
|
|
292
|
-
defaultMessage: 'Remove button',
|
|
293
|
-
},
|
|
294
|
-
carouselCardsLimitError: {
|
|
295
|
-
id: `${scope}.carouselCardsLimitError`,
|
|
296
|
-
defaultMessage: 'Carousel message requires 2 to 5 cards',
|
|
297
|
-
},
|
|
298
|
-
carouselCardError: {
|
|
299
|
-
id: `${scope}.carouselCardError`,
|
|
300
|
-
defaultMessage: 'Each card needs text and a valid media URL',
|
|
301
|
-
},
|
|
302
|
-
carouselButtonError: {
|
|
303
|
-
id: `${scope}.carouselButtonError`,
|
|
304
|
-
defaultMessage: 'Each button needs title and a valid action URL',
|
|
305
|
-
},
|
|
306
|
-
characterLimitExceededError: {
|
|
307
|
-
id: `${scope}.characterLimitExceededError`,
|
|
308
|
-
defaultMessage: 'Character limit exceeded',
|
|
309
|
-
},
|
|
310
|
-
textCannotBeEmptyError: {
|
|
311
|
-
id: `${scope}.textCannotBeEmptyError`,
|
|
312
|
-
defaultMessage: "Text can't be empty",
|
|
313
|
-
},
|
|
314
|
-
urlCannotBeEmptyError: {
|
|
315
|
-
id: `${scope}.urlCannotBeEmptyError`,
|
|
316
|
-
defaultMessage: "URL can't be empty",
|
|
317
|
-
},
|
|
318
|
-
carouselButtonUrlMaxLengthError: {
|
|
319
|
-
id: `${scope}.carouselButtonUrlMaxLengthError`,
|
|
320
|
-
defaultMessage: 'URL can not exceed 1000 characters',
|
|
321
|
-
},
|
|
322
|
-
carouselFirstButtonTitleMaxLengthError: {
|
|
323
|
-
id: `${scope}.carouselFirstButtonTitleMaxLengthError`,
|
|
324
|
-
defaultMessage: 'Button text should not exceed 10',
|
|
325
|
-
},
|
|
326
|
-
carouselSecondButtonTitleMaxLengthError: {
|
|
327
|
-
id: `${scope}.carouselSecondButtonTitleMaxLengthError`,
|
|
328
|
-
defaultMessage: 'Button text should not exceed 12',
|
|
329
|
-
},
|
|
330
|
-
carouselCardTitleMinLengthError: {
|
|
331
|
-
id: `${scope}.carouselCardTitleMinLengthError`,
|
|
332
|
-
defaultMessage: 'Minimum 2 characters required',
|
|
333
|
-
},
|
|
334
|
-
carouselCardTitleMaxLengthError: {
|
|
335
|
-
id: `${scope}.carouselCardTitleMaxLengthError`,
|
|
336
|
-
defaultMessage: 'Title can not be more than 38 characters',
|
|
337
|
-
},
|
|
338
217
|
});
|
|
@@ -389,84 +389,4 @@ describe('Test Viber container', () => {
|
|
|
389
389
|
const doneBtn = screen.getByRole('button', { name: /done/i });
|
|
390
390
|
expect(doneBtn).toBeEnabled();
|
|
391
391
|
});
|
|
392
|
-
|
|
393
|
-
it('does not show empty URL error on focus or while typing in carousel button action', async () => {
|
|
394
|
-
renderComponent({
|
|
395
|
-
actions: mockActions,
|
|
396
|
-
globalActions: mockGlobalActions,
|
|
397
|
-
templateData: { mode: 'create' },
|
|
398
|
-
viber: {
|
|
399
|
-
uploadedAssetData: {},
|
|
400
|
-
createTemplateInProgress: false,
|
|
401
|
-
},
|
|
402
|
-
location: {
|
|
403
|
-
pathname: '/sms/edit',
|
|
404
|
-
query: { type: false, module: 'default' },
|
|
405
|
-
search: '',
|
|
406
|
-
},
|
|
407
|
-
isFullMode: true,
|
|
408
|
-
handleClose: jest.fn(),
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
fireEvent.click(screen.getByRole('radio', { name: /carousel/i }));
|
|
412
|
-
const actionInput = await screen.findByPlaceholderText('https://example.com/action');
|
|
413
|
-
|
|
414
|
-
fireEvent.focus(actionInput);
|
|
415
|
-
expect(screen.queryByText("URL can't be empty")).not.toBeInTheDocument();
|
|
416
|
-
|
|
417
|
-
fireEvent.change(actionInput, { target: { value: 'https://' } });
|
|
418
|
-
expect(screen.queryByText("URL can't be empty")).not.toBeInTheDocument();
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
it('shows empty URL error on blur when carousel button action is left empty', async () => {
|
|
422
|
-
renderComponent({
|
|
423
|
-
actions: mockActions,
|
|
424
|
-
globalActions: mockGlobalActions,
|
|
425
|
-
templateData: { mode: 'create' },
|
|
426
|
-
viber: {
|
|
427
|
-
uploadedAssetData: {},
|
|
428
|
-
createTemplateInProgress: false,
|
|
429
|
-
},
|
|
430
|
-
location: {
|
|
431
|
-
pathname: '/sms/edit',
|
|
432
|
-
query: { type: false, module: 'default' },
|
|
433
|
-
search: '',
|
|
434
|
-
},
|
|
435
|
-
isFullMode: true,
|
|
436
|
-
handleClose: jest.fn(),
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
fireEvent.click(screen.getByRole('radio', { name: /carousel/i }));
|
|
440
|
-
const actionInput = await screen.findByPlaceholderText('https://example.com/action');
|
|
441
|
-
|
|
442
|
-
fireEvent.focus(actionInput);
|
|
443
|
-
fireEvent.blur(actionInput);
|
|
444
|
-
|
|
445
|
-
expect(await screen.findByText("URL can't be empty")).toBeInTheDocument();
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
it('shows empty URL error on save when carousel button action is empty', async () => {
|
|
449
|
-
renderComponent({
|
|
450
|
-
actions: mockActions,
|
|
451
|
-
globalActions: mockGlobalActions,
|
|
452
|
-
templateData: { mode: 'create' },
|
|
453
|
-
viber: {
|
|
454
|
-
uploadedAssetData: {},
|
|
455
|
-
createTemplateInProgress: false,
|
|
456
|
-
},
|
|
457
|
-
location: {
|
|
458
|
-
pathname: '/sms/edit',
|
|
459
|
-
query: { type: false, module: 'default' },
|
|
460
|
-
search: '',
|
|
461
|
-
},
|
|
462
|
-
isFullMode: true,
|
|
463
|
-
handleClose: jest.fn(),
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
fireEvent.click(screen.getByRole('radio', { name: /carousel/i }));
|
|
467
|
-
await screen.findByPlaceholderText('https://example.com/action');
|
|
468
|
-
fireEvent.click(screen.getByRole('button', { name: /save/i }));
|
|
469
|
-
|
|
470
|
-
expect(await screen.findByText("URL can't be empty")).toBeInTheDocument();
|
|
471
|
-
});
|
|
472
392
|
});
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
4
|
-
import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
|
|
5
|
-
import CapImage from '@capillarytech/cap-ui-library/CapImage';
|
|
6
|
-
|
|
7
|
-
const getTrimmedText = (value = '') => (value ?? '').trim();
|
|
8
|
-
const hasTrimmedText = (value = '') => Boolean(getTrimmedText(value));
|
|
9
|
-
|
|
10
|
-
const getCarouselButtonsWithTitles = (card) => (
|
|
11
|
-
(card?.buttons ?? []).filter((button) => hasTrimmedText(button?.title)).slice(0, 2)
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const getCarouselButtonSlotCount = (cards = []) => {
|
|
15
|
-
const buttonCounts = cards.map((card) => getCarouselButtonsWithTitles(card).length);
|
|
16
|
-
return Math.min(2, Math.max(0, ...buttonCounts, 0));
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const ViberCarouselPreviewCards = ({ cards = [] }) => {
|
|
20
|
-
const previewCards = Array.isArray(cards) && cards.length ? cards : [{}];
|
|
21
|
-
const carouselButtonSlotCount = useMemo(
|
|
22
|
-
() => getCarouselButtonSlotCount(previewCards),
|
|
23
|
-
[previewCards],
|
|
24
|
-
);
|
|
25
|
-
const carouselTitleRefs = useRef([]);
|
|
26
|
-
const [carouselTitleLineCount, setCarouselTitleLineCount] = useState(1);
|
|
27
|
-
|
|
28
|
-
carouselTitleRefs.current = previewCards.map(() => null);
|
|
29
|
-
|
|
30
|
-
useLayoutEffect(() => {
|
|
31
|
-
let maxLines = 1;
|
|
32
|
-
carouselTitleRefs.current.forEach((node) => {
|
|
33
|
-
if (!node) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const { lineHeight } = window.getComputedStyle(node);
|
|
37
|
-
const parsedLineHeight = parseFloat(lineHeight) || 18;
|
|
38
|
-
const lines = Math.min(2, Math.max(1, Math.round(node.scrollHeight / parsedLineHeight)));
|
|
39
|
-
if (lines > maxLines) {
|
|
40
|
-
maxLines = lines;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
setCarouselTitleLineCount((prev) => (prev === maxLines ? prev : maxLines));
|
|
44
|
-
}, [previewCards]);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<CapRow type="flex" noWrap className="viber-carousel-preview-scroll">
|
|
48
|
-
{previewCards.map((card, index) => {
|
|
49
|
-
const cardButtons = getCarouselButtonsWithTitles(card);
|
|
50
|
-
const titleLineClass = `viber-carousel-preview-text-wrap--${carouselTitleLineCount}-line`;
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<CapRow type="flex-column" className="viber-carousel-preview-card" key={`viber-carousel-preview-card-${index}`}>
|
|
54
|
-
{hasTrimmedText(card?.mediaUrl) ? (
|
|
55
|
-
<CapImage
|
|
56
|
-
src={card?.mediaUrl}
|
|
57
|
-
className="viber-carousel-preview-image"
|
|
58
|
-
alt="Viber carousel card"
|
|
59
|
-
/>
|
|
60
|
-
) : (
|
|
61
|
-
<CapRow className="viber-carousel-preview-image-placeholder" />
|
|
62
|
-
)}
|
|
63
|
-
<CapRow className="viber-carousel-preview-card-body">
|
|
64
|
-
<CapRow className={`viber-carousel-preview-text-wrap ${titleLineClass}`}>
|
|
65
|
-
{hasTrimmedText(card?.text) ? (
|
|
66
|
-
<CapRow
|
|
67
|
-
className="viber-carousel-preview-text-inner"
|
|
68
|
-
ref={(node) => {
|
|
69
|
-
carouselTitleRefs.current[index] = node;
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
<CapLabel type="label15" className="viber-carousel-preview-text">
|
|
73
|
-
{card?.text}
|
|
74
|
-
</CapLabel>
|
|
75
|
-
</CapRow>
|
|
76
|
-
) : (
|
|
77
|
-
<CapLabel type="label15" className="viber-carousel-preview-text-placeholder" />
|
|
78
|
-
)}
|
|
79
|
-
</CapRow>
|
|
80
|
-
{carouselButtonSlotCount > 0 && (
|
|
81
|
-
<CapRow className="viber-carousel-preview-buttons">
|
|
82
|
-
{Array.from({ length: carouselButtonSlotCount }).map((_, btnIndex) => {
|
|
83
|
-
const cardButton = cardButtons[btnIndex];
|
|
84
|
-
const trimmedCardButtonTitle = cardButton
|
|
85
|
-
? getTrimmedText(cardButton?.title)
|
|
86
|
-
: '';
|
|
87
|
-
|
|
88
|
-
if (!trimmedCardButtonTitle) {
|
|
89
|
-
return (
|
|
90
|
-
<CapRow
|
|
91
|
-
className="viber-carousel-preview-button viber-carousel-preview-button-placeholder"
|
|
92
|
-
key={`viber-carousel-preview-btn-placeholder-${index}-${btnIndex}`}
|
|
93
|
-
aria-hidden="true"
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<CapLabel
|
|
100
|
-
className={`viber-carousel-preview-button ${btnIndex === 1 ? 'viber-carousel-preview-button-secondary' : ''}`}
|
|
101
|
-
key={`viber-carousel-preview-btn-${index}-${btnIndex}-${trimmedCardButtonTitle}`}
|
|
102
|
-
>
|
|
103
|
-
{trimmedCardButtonTitle}
|
|
104
|
-
</CapLabel>
|
|
105
|
-
);
|
|
106
|
-
})}
|
|
107
|
-
</CapRow>
|
|
108
|
-
)}
|
|
109
|
-
</CapRow>
|
|
110
|
-
</CapRow>
|
|
111
|
-
);
|
|
112
|
-
})}
|
|
113
|
-
</CapRow>
|
|
114
|
-
);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
ViberCarouselPreviewCards.propTypes = {
|
|
118
|
-
cards: PropTypes.arrayOf(PropTypes.shape({
|
|
119
|
-
text: PropTypes.string,
|
|
120
|
-
mediaUrl: PropTypes.string,
|
|
121
|
-
buttons: PropTypes.arrayOf(PropTypes.shape({
|
|
122
|
-
title: PropTypes.string,
|
|
123
|
-
action: PropTypes.string,
|
|
124
|
-
})),
|
|
125
|
-
})),
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
ViberCarouselPreviewCards.defaultProps = {
|
|
129
|
-
cards: [],
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export default ViberCarouselPreviewCards;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// Shared Viber carousel card row (Test & Preview device preview)
|
|
2
|
-
.viber-carousel-preview-scroll {
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: row;
|
|
5
|
-
flex-wrap: nowrap;
|
|
6
|
-
align-items: stretch;
|
|
7
|
-
width: 100%;
|
|
8
|
-
max-width: 100%;
|
|
9
|
-
min-width: 0;
|
|
10
|
-
overflow-x: auto;
|
|
11
|
-
overflow-y: hidden;
|
|
12
|
-
padding-right: $CAP_SPACE_12;
|
|
13
|
-
scrollbar-width: none;
|
|
14
|
-
-webkit-overflow-scrolling: touch;
|
|
15
|
-
|
|
16
|
-
&::-webkit-scrollbar {
|
|
17
|
-
display: none;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.viber-carousel-preview-card {
|
|
21
|
-
flex: 0 0 68%;
|
|
22
|
-
min-width: 80%;
|
|
23
|
-
margin-right: $CAP_SPACE_08;
|
|
24
|
-
background: $CAP_G09;
|
|
25
|
-
border: 1px solid $CAP_G07;
|
|
26
|
-
border-radius: $CAP_SPACE_12;
|
|
27
|
-
overflow: hidden;
|
|
28
|
-
display: flex;
|
|
29
|
-
flex-direction: column;
|
|
30
|
-
align-self: stretch;
|
|
31
|
-
|
|
32
|
-
&:last-child {
|
|
33
|
-
margin-right: 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.viber-carousel-preview-card-body {
|
|
37
|
-
flex: 1;
|
|
38
|
-
padding: $CAP_SPACE_08;
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
min-height: 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.viber-carousel-preview-text-wrap {
|
|
45
|
-
flex-shrink: 0;
|
|
46
|
-
width: 100%;
|
|
47
|
-
|
|
48
|
-
&--1-line {
|
|
49
|
-
min-height: 1.3em;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&--2-line {
|
|
53
|
-
min-height: 2.6em;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.viber-carousel-preview-text-inner {
|
|
58
|
-
width: 100%;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.viber-carousel-preview-buttons {
|
|
62
|
-
display: flex;
|
|
63
|
-
flex-direction: column;
|
|
64
|
-
gap: $CAP_SPACE_06;
|
|
65
|
-
margin-top: auto;
|
|
66
|
-
width: 100%;
|
|
67
|
-
flex-shrink: 0;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.viber-carousel-preview-image {
|
|
71
|
-
width: 100%;
|
|
72
|
-
height: 10rem;
|
|
73
|
-
object-fit: cover;
|
|
74
|
-
border-radius: 0;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.viber-carousel-preview-image-placeholder {
|
|
78
|
-
width: 100%;
|
|
79
|
-
height: 10rem;
|
|
80
|
-
border-radius: 0;
|
|
81
|
-
background: $CAP_G07;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.viber-carousel-preview-text {
|
|
85
|
-
color: $CAP_G01;
|
|
86
|
-
line-height: 1.3;
|
|
87
|
-
white-space: normal;
|
|
88
|
-
word-break: break-word;
|
|
89
|
-
display: block;
|
|
90
|
-
width: 100%;
|
|
91
|
-
margin: 0;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.viber-carousel-preview-text-placeholder {
|
|
95
|
-
width: 100%;
|
|
96
|
-
height: 0.875rem;
|
|
97
|
-
border-radius: $CAP_SPACE_04;
|
|
98
|
-
background: $CAP_G07;
|
|
99
|
-
min-height: 0.875rem;
|
|
100
|
-
display: block;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.viber-carousel-preview-button {
|
|
104
|
-
color: $CAP_WHITE;
|
|
105
|
-
background: $CAP_PURPLE01;
|
|
106
|
-
border-radius: $CAP_SPACE_12;
|
|
107
|
-
text-align: center;
|
|
108
|
-
width: 100%;
|
|
109
|
-
display: flex;
|
|
110
|
-
align-items: center;
|
|
111
|
-
justify-content: center;
|
|
112
|
-
min-height: 1.5rem;
|
|
113
|
-
padding: $CAP_SPACE_06 $CAP_SPACE_08;
|
|
114
|
-
white-space: normal;
|
|
115
|
-
box-sizing: border-box;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.viber-carousel-preview-button-placeholder {
|
|
119
|
-
visibility: hidden;
|
|
120
|
-
pointer-events: none;
|
|
121
|
-
padding: 0;
|
|
122
|
-
background: transparent;
|
|
123
|
-
border: none;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.viber-carousel-preview-button-secondary {
|
|
127
|
-
color: $CAP_PURPLE01;
|
|
128
|
-
background: transparent;
|
|
129
|
-
border: none;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|