@capillarytech/creatives-library 9.0.36-alpha.0 → 9.0.37-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.
Files changed (50) hide show
  1. package/package.json +1 -1
  2. package/translations/en.json +2 -2
  3. package/utils/permissions.js +59 -0
  4. package/utils/tests/permissions.test.js +116 -0
  5. package/v2Components/AccessForbidden/_accessForbidden.scss +14 -0
  6. package/v2Components/AccessForbidden/index.js +5 -3
  7. package/v2Components/AccessForbidden/messages.js +3 -2
  8. package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +15 -108
  9. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -139
  10. package/v2Components/CommonTestAndPreview/index.js +26 -240
  11. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +0 -364
  12. package/v2Components/NoPermissionWrapper/_noPermissionWrapper.scss +12 -0
  13. package/v2Components/NoPermissionWrapper/index.js +26 -0
  14. package/v2Containers/App/constants.js +5 -0
  15. package/v2Containers/Assets/Gallery/_gallery.scss +6 -0
  16. package/v2Containers/Assets/Gallery/index.js +34 -10
  17. package/v2Containers/Cap/index.js +5 -2
  18. package/v2Containers/Cap/messages.js +4 -0
  19. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +2 -2
  20. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +6 -6
  21. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +4 -4
  22. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +32 -32
  23. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +36 -36
  24. package/v2Containers/Rcs/carouselUtils.js +73 -46
  25. package/v2Containers/Rcs/components/CarouselCard.js +9 -6
  26. package/v2Containers/Rcs/constants.js +7 -2
  27. package/v2Containers/Rcs/index.js +126 -72
  28. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +43 -5
  29. package/v2Containers/Rcs/tests/CarouselCard.test.js +2 -1
  30. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +118 -118
  31. package/v2Containers/Rcs/tests/carouselUtils.test.js +15 -15
  32. package/v2Containers/Rcs/tests/index.test.js +232 -10
  33. package/v2Containers/Rcs/tests/utils.test.js +17 -0
  34. package/v2Containers/Rcs/utils.js +51 -12
  35. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +8 -8
  36. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +18 -18
  37. package/v2Containers/Templates/ChannelTypeIllustration.js +10 -1
  38. package/v2Containers/Templates/_templates.scss +6 -114
  39. package/v2Containers/Templates/index.js +151 -190
  40. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +7 -0
  41. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +173 -120
  42. package/v2Containers/TemplatesV2/index.js +16 -5
  43. package/v2Containers/Viber/constants.js +0 -21
  44. package/v2Containers/Viber/index.js +49 -719
  45. package/v2Containers/Viber/index.scss +0 -175
  46. package/v2Containers/Viber/messages.js +0 -121
  47. package/v2Containers/Viber/tests/index.test.js +0 -80
  48. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +268 -268
  49. package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberCarouselPreviewCards.js +0 -132
  50. package/v2Components/CommonTestAndPreview/UnifiedPreview/_viberCarouselPreviewCards.scss +0 -131
@@ -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,131 +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
- width: 100%;
66
- flex-shrink: 0;
67
- }
68
-
69
- .viber-carousel-preview-image {
70
- width: 100%;
71
- height: 10rem;
72
- object-fit: cover;
73
- border-radius: 0;
74
- }
75
-
76
- .viber-carousel-preview-image-placeholder {
77
- width: 100%;
78
- height: 10rem;
79
- border-radius: 0;
80
- background: $CAP_G07;
81
- }
82
-
83
- .viber-carousel-preview-text {
84
- color: $CAP_G01;
85
- line-height: 1.3;
86
- white-space: normal;
87
- word-break: break-word;
88
- display: block;
89
- width: 100%;
90
- margin: 0;
91
- }
92
-
93
- .viber-carousel-preview-text-placeholder {
94
- width: 100%;
95
- height: 0.875rem;
96
- border-radius: $CAP_SPACE_04;
97
- background: $CAP_G07;
98
- min-height: 0.875rem;
99
- display: block;
100
- }
101
-
102
- .viber-carousel-preview-button {
103
- color: $CAP_WHITE;
104
- background: $CAP_PURPLE01;
105
- border-radius: $CAP_SPACE_12;
106
- text-align: center;
107
- width: 100%;
108
- display: flex;
109
- align-items: center;
110
- justify-content: center;
111
- min-height: 1.5rem;
112
- padding: $CAP_SPACE_06 $CAP_SPACE_08;
113
- white-space: normal;
114
- box-sizing: border-box;
115
- }
116
-
117
- .viber-carousel-preview-button-placeholder {
118
- visibility: hidden;
119
- pointer-events: none;
120
- padding: 0;
121
- background: transparent;
122
- border: none;
123
- }
124
-
125
- .viber-carousel-preview-button-secondary {
126
- color: $CAP_PURPLE01;
127
- background: transparent;
128
- border: none;
129
- }
130
- }
131
- }