@capillarytech/creatives-library 9.0.46 → 9.0.47

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 (30) hide show
  1. package/constants/unified.js +0 -1
  2. package/package.json +1 -1
  3. package/v2Components/CommonTestAndPreview/UnifiedPreview/SmsPreviewContent.js +1 -21
  4. package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +15 -106
  5. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -144
  6. package/v2Components/CommonTestAndPreview/constants.js +0 -2
  7. package/v2Components/CommonTestAndPreview/index.js +26 -240
  8. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/SmsPreviewContent.test.js +0 -32
  9. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +0 -364
  10. package/v2Components/CommonTestAndPreview/tests/utils.test.js +0 -49
  11. package/v2Components/CommonTestAndPreview/utils.js +0 -20
  12. package/v2Components/SmsFallback/constants.js +0 -19
  13. package/v2Components/SmsFallback/index.js +3 -0
  14. package/v2Containers/SmsTrai/Edit/constants.js +0 -2
  15. package/v2Containers/SmsTrai/Edit/index.js +96 -206
  16. package/v2Containers/SmsTrai/Edit/index.scss +1 -117
  17. package/v2Containers/SmsTrai/Edit/messages.js +0 -40
  18. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4591 -21196
  19. package/v2Containers/Templates/_templates.scss +1 -202
  20. package/v2Containers/Templates/index.js +42 -193
  21. package/v2Containers/Templates/messages.js +0 -12
  22. package/v2Containers/Viber/constants.js +0 -21
  23. package/v2Containers/Viber/index.js +49 -719
  24. package/v2Containers/Viber/index.scss +0 -175
  25. package/v2Containers/Viber/messages.js +0 -121
  26. package/v2Containers/Viber/tests/index.test.js +0 -80
  27. package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberCarouselPreviewCards.js +0 -127
  28. package/v2Components/CommonTestAndPreview/UnifiedPreview/_viberCarouselPreviewCards.scss +0 -133
  29. package/v2Containers/SmsTrai/Edit/dltVarTypes.js +0 -88
  30. package/v2Containers/SmsTrai/Edit/tests/dltVarTypes.test.js +0 -100
@@ -1,88 +0,0 @@
1
- export const DLT_VAR_TYPE_KEYS = [
2
- 'numeric',
3
- 'alphanumeric',
4
- 'url',
5
- 'urlott',
6
- 'cbn',
7
- 'email',
8
- ];
9
-
10
- export const DLT_VAR_TYPE_META = {
11
- numeric: {
12
- short: '{#num#}',
13
- long: '{#numeric#}',
14
- charLimit: 40,
15
- placeholderKey: 'dltVarPlaceholderNumeric',
16
- },
17
- alphanumeric: {
18
- short: '{#alp#}',
19
- long: '{#alphanumeric#}',
20
- charLimit: 40,
21
- placeholderKey: 'dltVarPlaceholderAlphanumeric',
22
- },
23
- url: {
24
- short: '{#urg#}',
25
- long: '{#url#}',
26
- charLimit: 120,
27
- placeholderKey: 'dltVarPlaceholderUrl',
28
- },
29
- urlott: {
30
- short: '{#uro#}',
31
- long: '{#urlott#}',
32
- charLimit: 120,
33
- placeholderKey: 'dltVarPlaceholderUrlott',
34
- },
35
- cbn: {
36
- short: '{#cbn#}',
37
- long: '{#cbn#}',
38
- charLimit: 14,
39
- placeholderKey: 'dltVarPlaceholderCbn',
40
- },
41
- email: {
42
- short: '{#eml#}',
43
- long: '{#email#}',
44
- charLimit: 40,
45
- placeholderKey: 'dltVarPlaceholderEmail',
46
- },
47
- };
48
-
49
- export const DLT_LEGACY_VAR_TOKEN = '{#var#}';
50
-
51
- const TOKEN_TO_TYPE = (() => {
52
- const map = {};
53
- DLT_VAR_TYPE_KEYS.forEach((key) => {
54
- const meta = DLT_VAR_TYPE_META[key];
55
- map[meta.short.toLowerCase()] = key;
56
- map[meta.long.toLowerCase()] = key;
57
- });
58
- map[DLT_LEGACY_VAR_TOKEN] = 'alphanumeric';
59
- return map;
60
- })();
61
-
62
- export const ANY_DLT_HASH_TOKEN_REGEX = /^\{#\s*[^#]*\s*#\}$/;
63
- export const ANY_DLT_HASH_TOKEN_GLOBAL_REGEX = /\{#\s*[^#]*\s*#\}/g;
64
- export const ANY_DLT_HASH_TOKEN_PROBE_REGEX = /\{#[^#]*#\}/;
65
- export const DLT_LEGACY_VAR_REGEX = /\{#\s*var\s*#\}/i;
66
- export const DLT_HASH_TOKEN_SPLIT_REGEX = /(\{#[^#]*#\})/g;
67
-
68
- export function isAnyDltVarToken(candidate) {
69
- return typeof candidate === 'string' && ANY_DLT_HASH_TOKEN_REGEX.test(candidate);
70
- }
71
-
72
- function normaliseToken(token) {
73
- if (typeof token !== 'string') return '';
74
- return token.replace(/\s+/g, '').toLowerCase();
75
- }
76
-
77
- export function getDltVarTypeKey(token) {
78
- return TOKEN_TO_TYPE[normaliseToken(token)] || null;
79
- }
80
-
81
- export function getDltVarTypeMeta(token) {
82
- const key = getDltVarTypeKey(token);
83
- return key ? DLT_VAR_TYPE_META[key] : null;
84
- }
85
-
86
- export function getDltVarCharLimit(token, fallback = 40) {
87
- return getDltVarTypeMeta(token)?.charLimit ?? fallback;
88
- }
@@ -1,100 +0,0 @@
1
- import {
2
- DLT_VAR_TYPE_KEYS,
3
- DLT_VAR_TYPE_META,
4
- DLT_LEGACY_VAR_TOKEN,
5
- DLT_LEGACY_VAR_REGEX,
6
- ANY_DLT_HASH_TOKEN_PROBE_REGEX,
7
- isAnyDltVarToken,
8
- getDltVarTypeKey,
9
- getDltVarTypeMeta,
10
- getDltVarCharLimit,
11
- } from '../dltVarTypes';
12
-
13
- describe('dltVarTypes', () => {
14
- it('exposes the six DLT types with short + long syntax + char limit', () => {
15
- expect(DLT_VAR_TYPE_KEYS).toEqual([
16
- 'numeric', 'alphanumeric', 'url', 'urlott', 'cbn', 'email',
17
- ]);
18
- DLT_VAR_TYPE_KEYS.forEach((key) => {
19
- const meta = DLT_VAR_TYPE_META[key];
20
- expect(meta.short).toMatch(/^\{#[^#]+#\}$/);
21
- expect(meta.long).toMatch(/^\{#[^#]+#\}$/);
22
- expect(typeof meta.charLimit).toBe('number');
23
- });
24
- });
25
-
26
- describe('isAnyDltVarToken', () => {
27
- it('accepts short and long DLT token forms', () => {
28
- expect(isAnyDltVarToken('{#num#}')).toBe(true);
29
- expect(isAnyDltVarToken('{#numeric#}')).toBe(true);
30
- expect(isAnyDltVarToken('{#var#}')).toBe(true);
31
- expect(isAnyDltVarToken('{# alp #}')).toBe(true);
32
- });
33
-
34
- it('rejects non-DLT strings and non-strings', () => {
35
- expect(isAnyDltVarToken('{{mustache}}')).toBe(false);
36
- expect(isAnyDltVarToken('plain text')).toBe(false);
37
- expect(isAnyDltVarToken('')).toBe(false);
38
- expect(isAnyDltVarToken(null)).toBe(false);
39
- expect(isAnyDltVarToken(undefined)).toBe(false);
40
- expect(isAnyDltVarToken(42)).toBe(false);
41
- });
42
- });
43
-
44
- describe('getDltVarTypeKey', () => {
45
- it('resolves short and long spellings + legacy {#var#} to a type key', () => {
46
- expect(getDltVarTypeKey('{#num#}')).toBe('numeric');
47
- expect(getDltVarTypeKey('{#numeric#}')).toBe('numeric');
48
- expect(getDltVarTypeKey('{#ALP#}')).toBe('alphanumeric');
49
- expect(getDltVarTypeKey('{# url #}')).toBe('url');
50
- expect(getDltVarTypeKey(DLT_LEGACY_VAR_TOKEN)).toBe('alphanumeric');
51
- });
52
-
53
- it('returns null for unknown / non-string tokens', () => {
54
- expect(getDltVarTypeKey('{#foobar#}')).toBe(null);
55
- expect(getDltVarTypeKey('')).toBe(null);
56
- expect(getDltVarTypeKey(null)).toBe(null);
57
- expect(getDltVarTypeKey(undefined)).toBe(null);
58
- });
59
- });
60
-
61
- describe('getDltVarTypeMeta', () => {
62
- it('returns the full meta object for a valid token', () => {
63
- const meta = getDltVarTypeMeta('{#url#}');
64
- expect(meta.charLimit).toBe(120);
65
- expect(meta.placeholderKey).toBe('dltVarPlaceholderUrl');
66
- });
67
-
68
- it('returns null for an unknown token', () => {
69
- expect(getDltVarTypeMeta('{#nope#}')).toBe(null);
70
- });
71
- });
72
-
73
- describe('getDltVarCharLimit', () => {
74
- it('returns the type-specific char limit for known tokens', () => {
75
- expect(getDltVarCharLimit('{#num#}')).toBe(40);
76
- expect(getDltVarCharLimit('{#url#}')).toBe(120);
77
- expect(getDltVarCharLimit('{#cbn#}')).toBe(14);
78
- });
79
-
80
- it('falls back to the supplied default when the token is unknown', () => {
81
- expect(getDltVarCharLimit('{#nope#}', 40)).toBe(40);
82
- expect(getDltVarCharLimit('{#nope#}', 99)).toBe(99);
83
- expect(getDltVarCharLimit(null)).toBe(40);
84
- });
85
- });
86
-
87
- describe('exported regexes', () => {
88
- it('DLT_LEGACY_VAR_REGEX matches only the legacy generic token', () => {
89
- expect(DLT_LEGACY_VAR_REGEX.test('body {#var#} tail')).toBe(true);
90
- expect(DLT_LEGACY_VAR_REGEX.test('body {#VAR#} tail')).toBe(true);
91
- expect(DLT_LEGACY_VAR_REGEX.test('body {#num#} tail')).toBe(false);
92
- });
93
-
94
- it('ANY_DLT_HASH_TOKEN_PROBE_REGEX detects any hash token safely across calls', () => {
95
- expect(ANY_DLT_HASH_TOKEN_PROBE_REGEX.test('hi {#alp#} there')).toBe(true);
96
- expect(ANY_DLT_HASH_TOKEN_PROBE_REGEX.test('hi {#url#} again')).toBe(true);
97
- expect(ANY_DLT_HASH_TOKEN_PROBE_REGEX.test('plain')).toBe(false);
98
- });
99
- });
100
- });