@pushwoosh/dumb-components 4.5.1 → 4.6.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 (133) hide show
  1. package/ChatPreview/ChatPreview.d.ts +4 -0
  2. package/ChatPreview/ChatPreview.js +65 -0
  3. package/ChatPreview/components/ChatCardView/ChatCardView.d.ts +4 -0
  4. package/ChatPreview/components/ChatCardView/ChatCardView.js +61 -0
  5. package/ChatPreview/components/ChatCardView/index.d.ts +1 -0
  6. package/ChatPreview/components/ChatCardView/index.js +1 -0
  7. package/ChatPreview/components/ChatCardView/styles.d.ts +24 -0
  8. package/ChatPreview/components/ChatCardView/styles.js +40 -0
  9. package/ChatPreview/components/ChatCardView/types.d.ts +15 -0
  10. package/ChatPreview/components/ChatMediaView/ChatMediaView.d.ts +4 -0
  11. package/ChatPreview/components/ChatMediaView/ChatMediaView.js +49 -0
  12. package/ChatPreview/components/ChatMediaView/index.d.ts +1 -0
  13. package/ChatPreview/components/ChatMediaView/index.js +1 -0
  14. package/ChatPreview/components/ChatMediaView/styles.d.ts +13 -0
  15. package/ChatPreview/components/ChatMediaView/styles.js +18 -0
  16. package/ChatPreview/components/ChatMediaView/types.d.ts +8 -0
  17. package/ChatPreview/components/ChatMediaView/types.js +1 -0
  18. package/ChatPreview/components/ChatText/ChatText.d.ts +4 -0
  19. package/ChatPreview/components/ChatText/ChatText.js +18 -0
  20. package/ChatPreview/components/ChatText/index.d.ts +1 -0
  21. package/ChatPreview/components/ChatText/index.js +1 -0
  22. package/ChatPreview/components/ChatText/types.d.ts +8 -0
  23. package/ChatPreview/components/ChatText/types.js +1 -0
  24. package/ChatPreview/components/Deliverable/Deliverable.d.ts +4 -0
  25. package/ChatPreview/components/Deliverable/Deliverable.js +25 -0
  26. package/ChatPreview/components/Deliverable/index.d.ts +1 -0
  27. package/ChatPreview/components/Deliverable/index.js +1 -0
  28. package/ChatPreview/components/Deliverable/styles.d.ts +6 -0
  29. package/ChatPreview/components/Deliverable/styles.js +10 -0
  30. package/ChatPreview/components/Deliverable/types.d.ts +8 -0
  31. package/ChatPreview/components/Deliverable/types.js +1 -0
  32. package/ChatPreview/components/ListSheet/ListSheet.d.ts +4 -0
  33. package/ChatPreview/components/ListSheet/ListSheet.js +27 -0
  34. package/ChatPreview/components/ListSheet/index.d.ts +1 -0
  35. package/ChatPreview/components/ListSheet/index.js +1 -0
  36. package/ChatPreview/components/ListSheet/styles.d.ts +13 -0
  37. package/ChatPreview/components/ListSheet/styles.js +20 -0
  38. package/ChatPreview/components/ListSheet/types.d.ts +9 -0
  39. package/ChatPreview/components/ListSheet/types.js +1 -0
  40. package/ChatPreview/components/MessageBubble/MessageBubble.d.ts +4 -0
  41. package/ChatPreview/components/MessageBubble/MessageBubble.js +67 -0
  42. package/ChatPreview/components/MessageBubble/index.d.ts +1 -0
  43. package/ChatPreview/components/MessageBubble/index.js +1 -0
  44. package/ChatPreview/components/MessageBubble/styles.d.ts +7 -0
  45. package/ChatPreview/components/MessageBubble/styles.js +11 -0
  46. package/ChatPreview/components/MessageBubble/types.d.ts +3 -0
  47. package/ChatPreview/components/MessageBubble/types.js +1 -0
  48. package/ChatPreview/components/NativeMessage/NativeMessage.d.ts +4 -0
  49. package/ChatPreview/components/NativeMessage/NativeMessage.js +55 -0
  50. package/ChatPreview/components/NativeMessage/index.d.ts +1 -0
  51. package/ChatPreview/components/NativeMessage/index.js +1 -0
  52. package/ChatPreview/components/NativeMessage/styles.d.ts +6 -0
  53. package/ChatPreview/components/NativeMessage/styles.js +11 -0
  54. package/ChatPreview/components/NativeMessage/types.d.ts +7 -0
  55. package/ChatPreview/components/NativeMessage/types.js +1 -0
  56. package/ChatPreview/components/ReplyChips/ReplyChips.d.ts +4 -0
  57. package/ChatPreview/components/ReplyChips/ReplyChips.js +18 -0
  58. package/ChatPreview/components/ReplyChips/index.d.ts +1 -0
  59. package/ChatPreview/components/ReplyChips/index.js +1 -0
  60. package/ChatPreview/components/ReplyChips/styles.d.ts +7 -0
  61. package/ChatPreview/components/ReplyChips/styles.js +15 -0
  62. package/ChatPreview/components/ReplyChips/types.d.ts +3 -0
  63. package/ChatPreview/components/ReplyChips/types.js +1 -0
  64. package/ChatPreview/components/StatusNotice/StatusNotice.d.ts +4 -0
  65. package/ChatPreview/components/StatusNotice/StatusNotice.js +44 -0
  66. package/ChatPreview/components/StatusNotice/index.d.ts +2 -0
  67. package/ChatPreview/components/StatusNotice/index.js +2 -0
  68. package/ChatPreview/components/StatusNotice/styles.d.ts +15 -0
  69. package/ChatPreview/components/StatusNotice/styles.js +22 -0
  70. package/ChatPreview/components/StatusNotice/types.d.ts +9 -0
  71. package/ChatPreview/components/StatusNotice/types.js +1 -0
  72. package/ChatPreview/components/index.d.ts +4 -0
  73. package/ChatPreview/components/index.js +3 -0
  74. package/ChatPreview/components/types.d.ts +13 -0
  75. package/ChatPreview/components/types.js +1 -0
  76. package/ChatPreview/constants.d.ts +47 -0
  77. package/ChatPreview/constants.js +89 -0
  78. package/ChatPreview/helpers.d.ts +22 -0
  79. package/ChatPreview/helpers.js +57 -0
  80. package/ChatPreview/index.d.ts +2 -0
  81. package/ChatPreview/index.js +1 -0
  82. package/ChatPreview/polyglot/index.d.ts +2 -0
  83. package/ChatPreview/polyglot/index.js +34 -0
  84. package/ChatPreview/polyglot/messages_ar.d.ts +3 -0
  85. package/ChatPreview/polyglot/messages_ar.js +14 -0
  86. package/ChatPreview/polyglot/messages_bn.d.ts +3 -0
  87. package/ChatPreview/polyglot/messages_bn.js +14 -0
  88. package/ChatPreview/polyglot/messages_de.d.ts +3 -0
  89. package/ChatPreview/polyglot/messages_de.js +14 -0
  90. package/ChatPreview/polyglot/messages_en.d.ts +3 -0
  91. package/ChatPreview/polyglot/messages_en.js +14 -0
  92. package/ChatPreview/polyglot/messages_es.d.ts +3 -0
  93. package/ChatPreview/polyglot/messages_es.js +14 -0
  94. package/ChatPreview/polyglot/messages_fr.d.ts +3 -0
  95. package/ChatPreview/polyglot/messages_fr.js +14 -0
  96. package/ChatPreview/polyglot/messages_he.d.ts +3 -0
  97. package/ChatPreview/polyglot/messages_he.js +14 -0
  98. package/ChatPreview/polyglot/messages_hi.d.ts +3 -0
  99. package/ChatPreview/polyglot/messages_hi.js +14 -0
  100. package/ChatPreview/polyglot/messages_ja.d.ts +3 -0
  101. package/ChatPreview/polyglot/messages_ja.js +14 -0
  102. package/ChatPreview/polyglot/messages_ko.d.ts +3 -0
  103. package/ChatPreview/polyglot/messages_ko.js +14 -0
  104. package/ChatPreview/polyglot/messages_pt.d.ts +3 -0
  105. package/ChatPreview/polyglot/messages_pt.js +14 -0
  106. package/ChatPreview/polyglot/messages_ru.d.ts +3 -0
  107. package/ChatPreview/polyglot/messages_ru.js +14 -0
  108. package/ChatPreview/polyglot/messages_th.d.ts +3 -0
  109. package/ChatPreview/polyglot/messages_th.js +14 -0
  110. package/ChatPreview/polyglot/messages_zh.d.ts +3 -0
  111. package/ChatPreview/polyglot/messages_zh.js +14 -0
  112. package/ChatPreview/polyglot/types.d.ts +17 -0
  113. package/ChatPreview/polyglot/types.js +1 -0
  114. package/ChatPreview/styles.d.ts +33 -0
  115. package/ChatPreview/styles.js +54 -0
  116. package/ChatPreview/types.d.ts +134 -0
  117. package/ChatPreview/types.js +1 -0
  118. package/WhatsAppPreview/components/WhatsAppMessageContent/WhatsAppMessageContent.js +1 -1
  119. package/WhatsAppPreview/helpers.d.ts +0 -3
  120. package/WhatsAppPreview/helpers.js +0 -56
  121. package/index.d.ts +2 -0
  122. package/index.js +1 -0
  123. package/package.json +1 -1
  124. package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/WhatsAppFormattedText.js +2 -2
  125. package/shared/whatsAppMarkup/index.d.ts +3 -0
  126. package/{WhatsAppPreview/components/WhatsAppFormattedText/index.d.ts → shared/whatsAppMarkup/index.js} +1 -0
  127. package/shared/whatsAppMarkup/parse.d.ts +3 -0
  128. package/shared/whatsAppMarkup/parse.js +56 -0
  129. package/shared/whatsAppMarkup/types.js +1 -0
  130. package/WhatsAppPreview/components/WhatsAppFormattedText/index.js +0 -1
  131. /package/{WhatsAppPreview/components/WhatsAppFormattedText → ChatPreview/components/ChatCardView}/types.js +0 -0
  132. /package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/WhatsAppFormattedText.d.ts +0 -0
  133. /package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/types.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Text } from '@pushwoosh/kit-typography';
3
- import { DynamicContentText } from '../../../shared/dynamicContent';
4
- import { parseWhatsAppMarkup } from '../../helpers';
3
+ import { parseWhatsAppMarkup } from './parse';
4
+ import { DynamicContentText } from '../dynamicContent';
5
5
  const TAGS = {
6
6
  bold: 'b',
7
7
  italic: 'i',
@@ -0,0 +1,3 @@
1
+ export { WhatsAppFormattedText } from './WhatsAppFormattedText';
2
+ export { parseWhatsAppMarkup } from './parse';
3
+ export type { WhatsAppFormattedTextProps, WhatsAppTextNode, WhatsAppTextStyle } from './types';
@@ -1 +1,2 @@
1
1
  export { WhatsAppFormattedText } from './WhatsAppFormattedText';
2
+ export { parseWhatsAppMarkup } from './parse';
@@ -0,0 +1,3 @@
1
+ import type { WhatsAppTextNode } from './types';
2
+ /** Splits WhatsApp markup (`*bold*`, `_italic_`, `~strike~`, backtick monospace) into a render tree. */
3
+ export declare function parseWhatsAppMarkup(text: string): WhatsAppTextNode[];
@@ -0,0 +1,56 @@
1
+ const MARKERS = [{
2
+ style: 'mono',
3
+ marker: '```'
4
+ }, {
5
+ style: 'mono',
6
+ marker: '`'
7
+ }, {
8
+ style: 'bold',
9
+ marker: '*'
10
+ }, {
11
+ style: 'italic',
12
+ marker: '_'
13
+ }, {
14
+ style: 'strike',
15
+ marker: '~'
16
+ }];
17
+ function findMarkerAt(text, index) {
18
+ return MARKERS.find(({
19
+ marker
20
+ }) => text.startsWith(marker, index)) || null;
21
+ }
22
+ /** Splits WhatsApp markup (`*bold*`, `_italic_`, `~strike~`, backtick monospace) into a render tree. */
23
+ export function parseWhatsAppMarkup(text) {
24
+ const nodes = [];
25
+ let plain = '';
26
+ let index = 0;
27
+ const flush = () => {
28
+ if (plain) {
29
+ nodes.push({
30
+ text: plain
31
+ });
32
+ plain = '';
33
+ }
34
+ };
35
+ while (index < text.length) {
36
+ const found = findMarkerAt(text, index);
37
+ const openEnd = found ? index + found.marker.length : index;
38
+ const closeStart = found ? text.indexOf(found.marker, openEnd) : -1;
39
+ if (!found || closeStart <= openEnd) {
40
+ plain += text[index];
41
+ index += 1;
42
+ continue;
43
+ }
44
+ const inner = text.slice(openEnd, closeStart);
45
+ flush();
46
+ nodes.push({
47
+ style: found.style,
48
+ children: found.style === 'mono' ? [{
49
+ text: inner
50
+ }] : parseWhatsAppMarkup(inner)
51
+ });
52
+ index = closeStart + found.marker.length;
53
+ }
54
+ flush();
55
+ return nodes;
56
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +0,0 @@
1
- export { WhatsAppFormattedText } from './WhatsAppFormattedText';