@pushwoosh/dumb-components 4.5.0 → 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.
- package/ChatPreview/ChatPreview.d.ts +4 -0
- package/ChatPreview/ChatPreview.js +65 -0
- package/ChatPreview/components/ChatCardView/ChatCardView.d.ts +4 -0
- package/ChatPreview/components/ChatCardView/ChatCardView.js +61 -0
- package/ChatPreview/components/ChatCardView/index.d.ts +1 -0
- package/ChatPreview/components/ChatCardView/index.js +1 -0
- package/ChatPreview/components/ChatCardView/styles.d.ts +24 -0
- package/ChatPreview/components/ChatCardView/styles.js +40 -0
- package/ChatPreview/components/ChatCardView/types.d.ts +15 -0
- package/ChatPreview/components/ChatMediaView/ChatMediaView.d.ts +4 -0
- package/ChatPreview/components/ChatMediaView/ChatMediaView.js +49 -0
- package/ChatPreview/components/ChatMediaView/index.d.ts +1 -0
- package/ChatPreview/components/ChatMediaView/index.js +1 -0
- package/ChatPreview/components/ChatMediaView/styles.d.ts +13 -0
- package/ChatPreview/components/ChatMediaView/styles.js +18 -0
- package/ChatPreview/components/ChatMediaView/types.d.ts +8 -0
- package/ChatPreview/components/ChatMediaView/types.js +1 -0
- package/ChatPreview/components/ChatText/ChatText.d.ts +4 -0
- package/ChatPreview/components/ChatText/ChatText.js +18 -0
- package/ChatPreview/components/ChatText/index.d.ts +1 -0
- package/ChatPreview/components/ChatText/index.js +1 -0
- package/ChatPreview/components/ChatText/types.d.ts +8 -0
- package/ChatPreview/components/ChatText/types.js +1 -0
- package/ChatPreview/components/Deliverable/Deliverable.d.ts +4 -0
- package/ChatPreview/components/Deliverable/Deliverable.js +25 -0
- package/ChatPreview/components/Deliverable/index.d.ts +1 -0
- package/ChatPreview/components/Deliverable/index.js +1 -0
- package/ChatPreview/components/Deliverable/styles.d.ts +6 -0
- package/ChatPreview/components/Deliverable/styles.js +10 -0
- package/ChatPreview/components/Deliverable/types.d.ts +8 -0
- package/ChatPreview/components/Deliverable/types.js +1 -0
- package/ChatPreview/components/ListSheet/ListSheet.d.ts +4 -0
- package/ChatPreview/components/ListSheet/ListSheet.js +27 -0
- package/ChatPreview/components/ListSheet/index.d.ts +1 -0
- package/ChatPreview/components/ListSheet/index.js +1 -0
- package/ChatPreview/components/ListSheet/styles.d.ts +13 -0
- package/ChatPreview/components/ListSheet/styles.js +20 -0
- package/ChatPreview/components/ListSheet/types.d.ts +9 -0
- package/ChatPreview/components/ListSheet/types.js +1 -0
- package/ChatPreview/components/MessageBubble/MessageBubble.d.ts +4 -0
- package/ChatPreview/components/MessageBubble/MessageBubble.js +67 -0
- package/ChatPreview/components/MessageBubble/index.d.ts +1 -0
- package/ChatPreview/components/MessageBubble/index.js +1 -0
- package/ChatPreview/components/MessageBubble/styles.d.ts +7 -0
- package/ChatPreview/components/MessageBubble/styles.js +11 -0
- package/ChatPreview/components/MessageBubble/types.d.ts +3 -0
- package/ChatPreview/components/MessageBubble/types.js +1 -0
- package/ChatPreview/components/NativeMessage/NativeMessage.d.ts +4 -0
- package/ChatPreview/components/NativeMessage/NativeMessage.js +55 -0
- package/ChatPreview/components/NativeMessage/index.d.ts +1 -0
- package/ChatPreview/components/NativeMessage/index.js +1 -0
- package/ChatPreview/components/NativeMessage/styles.d.ts +6 -0
- package/ChatPreview/components/NativeMessage/styles.js +11 -0
- package/ChatPreview/components/NativeMessage/types.d.ts +7 -0
- package/ChatPreview/components/NativeMessage/types.js +1 -0
- package/ChatPreview/components/ReplyChips/ReplyChips.d.ts +4 -0
- package/ChatPreview/components/ReplyChips/ReplyChips.js +18 -0
- package/ChatPreview/components/ReplyChips/index.d.ts +1 -0
- package/ChatPreview/components/ReplyChips/index.js +1 -0
- package/ChatPreview/components/ReplyChips/styles.d.ts +7 -0
- package/ChatPreview/components/ReplyChips/styles.js +15 -0
- package/ChatPreview/components/ReplyChips/types.d.ts +3 -0
- package/ChatPreview/components/ReplyChips/types.js +1 -0
- package/ChatPreview/components/StatusNotice/StatusNotice.d.ts +4 -0
- package/ChatPreview/components/StatusNotice/StatusNotice.js +44 -0
- package/ChatPreview/components/StatusNotice/index.d.ts +2 -0
- package/ChatPreview/components/StatusNotice/index.js +2 -0
- package/ChatPreview/components/StatusNotice/styles.d.ts +15 -0
- package/ChatPreview/components/StatusNotice/styles.js +22 -0
- package/ChatPreview/components/StatusNotice/types.d.ts +9 -0
- package/ChatPreview/components/StatusNotice/types.js +1 -0
- package/ChatPreview/components/index.d.ts +4 -0
- package/ChatPreview/components/index.js +3 -0
- package/ChatPreview/components/types.d.ts +13 -0
- package/ChatPreview/components/types.js +1 -0
- package/ChatPreview/constants.d.ts +47 -0
- package/ChatPreview/constants.js +89 -0
- package/ChatPreview/helpers.d.ts +22 -0
- package/ChatPreview/helpers.js +57 -0
- package/ChatPreview/index.d.ts +2 -0
- package/ChatPreview/index.js +1 -0
- package/ChatPreview/polyglot/index.d.ts +2 -0
- package/ChatPreview/polyglot/index.js +34 -0
- package/ChatPreview/polyglot/messages_ar.d.ts +3 -0
- package/ChatPreview/polyglot/messages_ar.js +14 -0
- package/ChatPreview/polyglot/messages_bn.d.ts +3 -0
- package/ChatPreview/polyglot/messages_bn.js +14 -0
- package/ChatPreview/polyglot/messages_de.d.ts +3 -0
- package/ChatPreview/polyglot/messages_de.js +14 -0
- package/ChatPreview/polyglot/messages_en.d.ts +3 -0
- package/ChatPreview/polyglot/messages_en.js +14 -0
- package/ChatPreview/polyglot/messages_es.d.ts +3 -0
- package/ChatPreview/polyglot/messages_es.js +14 -0
- package/ChatPreview/polyglot/messages_fr.d.ts +3 -0
- package/ChatPreview/polyglot/messages_fr.js +14 -0
- package/ChatPreview/polyglot/messages_he.d.ts +3 -0
- package/ChatPreview/polyglot/messages_he.js +14 -0
- package/ChatPreview/polyglot/messages_hi.d.ts +3 -0
- package/ChatPreview/polyglot/messages_hi.js +14 -0
- package/ChatPreview/polyglot/messages_ja.d.ts +3 -0
- package/ChatPreview/polyglot/messages_ja.js +14 -0
- package/ChatPreview/polyglot/messages_ko.d.ts +3 -0
- package/ChatPreview/polyglot/messages_ko.js +14 -0
- package/ChatPreview/polyglot/messages_pt.d.ts +3 -0
- package/ChatPreview/polyglot/messages_pt.js +14 -0
- package/ChatPreview/polyglot/messages_ru.d.ts +3 -0
- package/ChatPreview/polyglot/messages_ru.js +14 -0
- package/ChatPreview/polyglot/messages_th.d.ts +3 -0
- package/ChatPreview/polyglot/messages_th.js +14 -0
- package/ChatPreview/polyglot/messages_zh.d.ts +3 -0
- package/ChatPreview/polyglot/messages_zh.js +14 -0
- package/ChatPreview/polyglot/types.d.ts +17 -0
- package/ChatPreview/polyglot/types.js +1 -0
- package/ChatPreview/styles.d.ts +33 -0
- package/ChatPreview/styles.js +54 -0
- package/ChatPreview/types.d.ts +134 -0
- package/ChatPreview/types.js +1 -0
- package/PageHeader/components/PageHeader/PageHeader.js +3 -6
- package/PageHeader/components/PageHeader/styles.d.ts +3 -0
- package/PageHeader/components/PageHeader/styles.js +10 -6
- package/WhatsAppPreview/components/WhatsAppMessageContent/WhatsAppMessageContent.js +1 -1
- package/WhatsAppPreview/helpers.d.ts +0 -3
- package/WhatsAppPreview/helpers.js +0 -56
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/WhatsAppFormattedText.js +2 -2
- package/shared/whatsAppMarkup/index.d.ts +3 -0
- package/{WhatsAppPreview/components/WhatsAppFormattedText/index.d.ts → shared/whatsAppMarkup/index.js} +1 -0
- package/shared/whatsAppMarkup/parse.d.ts +3 -0
- package/shared/whatsAppMarkup/parse.js +56 -0
- package/shared/whatsAppMarkup/types.js +1 -0
- package/WhatsAppPreview/components/WhatsAppFormattedText/index.js +0 -1
- /package/{WhatsAppPreview/components/WhatsAppFormattedText → ChatPreview/components/ChatCardView}/types.js +0 -0
- /package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/WhatsAppFormattedText.d.ts +0 -0
- /package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/types.d.ts +0 -0
|
@@ -1,60 +1,4 @@
|
|
|
1
1
|
import { WHATSAPP_ATTACHMENT_EXTENSIONS } from './constants';
|
|
2
|
-
const MARKERS = [{
|
|
3
|
-
style: 'mono',
|
|
4
|
-
marker: '```'
|
|
5
|
-
}, {
|
|
6
|
-
style: 'mono',
|
|
7
|
-
marker: '`'
|
|
8
|
-
}, {
|
|
9
|
-
style: 'bold',
|
|
10
|
-
marker: '*'
|
|
11
|
-
}, {
|
|
12
|
-
style: 'italic',
|
|
13
|
-
marker: '_'
|
|
14
|
-
}, {
|
|
15
|
-
style: 'strike',
|
|
16
|
-
marker: '~'
|
|
17
|
-
}];
|
|
18
|
-
function findMarkerAt(text, index) {
|
|
19
|
-
return MARKERS.find(({
|
|
20
|
-
marker
|
|
21
|
-
}) => text.startsWith(marker, index)) || null;
|
|
22
|
-
}
|
|
23
|
-
/** Splits WhatsApp markup (`*bold*`, `_italic_`, `~strike~`, backtick monospace) into a render tree. */
|
|
24
|
-
export function parseWhatsAppMarkup(text) {
|
|
25
|
-
const nodes = [];
|
|
26
|
-
let plain = '';
|
|
27
|
-
let index = 0;
|
|
28
|
-
const flush = () => {
|
|
29
|
-
if (plain) {
|
|
30
|
-
nodes.push({
|
|
31
|
-
text: plain
|
|
32
|
-
});
|
|
33
|
-
plain = '';
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
while (index < text.length) {
|
|
37
|
-
const found = findMarkerAt(text, index);
|
|
38
|
-
const openEnd = found ? index + found.marker.length : index;
|
|
39
|
-
const closeStart = found ? text.indexOf(found.marker, openEnd) : -1;
|
|
40
|
-
if (!found || closeStart <= openEnd) {
|
|
41
|
-
plain += text[index];
|
|
42
|
-
index += 1;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const inner = text.slice(openEnd, closeStart);
|
|
46
|
-
flush();
|
|
47
|
-
nodes.push({
|
|
48
|
-
style: found.style,
|
|
49
|
-
children: found.style === 'mono' ? [{
|
|
50
|
-
text: inner
|
|
51
|
-
}] : parseWhatsAppMarkup(inner)
|
|
52
|
-
});
|
|
53
|
-
index = closeStart + found.marker.length;
|
|
54
|
-
}
|
|
55
|
-
flush();
|
|
56
|
-
return nodes;
|
|
57
|
-
}
|
|
58
2
|
/** File type shown on a document card: the name extension, or the MIME subtype when the name carries none. */
|
|
59
3
|
export function getAttachmentExtension(attachment) {
|
|
60
4
|
const {
|
package/index.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export { PushStoriesPreview, hasStoryButton, normalizeStoryDuration, PUSH_STORIE
|
|
|
37
37
|
export { InboxPreview, resolveInboxLayout, MAX_CAROUSEL_SLIDES, type InboxLayoutType, type InboxPreviewPlatform, type InboxPreviewContent, type InboxPreviewProps, type InboxPreviewSlide, } from './InboxPreview';
|
|
38
38
|
export { WhatsAppPreview } from './WhatsAppPreview';
|
|
39
39
|
export type { WhatsAppAttachment, WhatsAppAttachmentKind, WhatsAppMessage, WhatsAppPreviewProps, } from './WhatsAppPreview';
|
|
40
|
+
export { ChatPreview } from './ChatPreview';
|
|
41
|
+
export type { ChatButton, ChatButtonKind, ChatCard, ChatChannel, ChatCompatibility, ChatContent, ChatContentType, ChatHeader, ChatList, ChatListItem, ChatMedia, ChatMediaKind, ChatPreviewProps, ChatRcsLayout, } from './ChatPreview';
|
|
40
42
|
export { Toast, ToastProvider, useToast } from './Toast';
|
|
41
43
|
export { AutosizeInput, PageHeader, PageHeaderEditable, Rename, } from './PageHeader';
|
|
42
44
|
export { Steps, useSteps } from './Steps';
|
package/index.js
CHANGED
|
@@ -36,6 +36,7 @@ export { PushPreview } from './PushPreview';
|
|
|
36
36
|
export { PushStoriesPreview, hasStoryButton, normalizeStoryDuration, PUSH_STORIES_ASPECT_RATIO, PUSH_STORIES_DEFAULT_DURATION, PUSH_STORIES_MAX_DURATION } from './PushStoriesPreview';
|
|
37
37
|
export { InboxPreview, resolveInboxLayout, MAX_CAROUSEL_SLIDES } from './InboxPreview';
|
|
38
38
|
export { WhatsAppPreview } from './WhatsAppPreview';
|
|
39
|
+
export { ChatPreview } from './ChatPreview';
|
|
39
40
|
export { Toast, ToastProvider, useToast } from './Toast';
|
|
40
41
|
export { AutosizeInput, PageHeader, PageHeaderEditable, Rename } from './PageHeader';
|
|
41
42
|
export { Steps, useSteps } from './Steps';
|
package/package.json
CHANGED
|
@@ -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 {
|
|
4
|
-
import {
|
|
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,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';
|
|
File without changes
|
|
File without changes
|
/package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/types.d.ts
RENAMED
|
File without changes
|