@pushwoosh/websdk-common 6.24.0 → 6.26.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/inbox/InboxCellPreview.d.ts +3 -1
- package/inbox/InboxCellPreview.js +55 -3
- package/inbox/types.d.ts +1 -1
- package/package.json +1 -1
- package/web-popups/form-slots/SubmitSlotView/SubmitSlotView.js +2 -0
- package/web-popups/index.d.ts +1 -1
- package/web-popups/index.js +1 -1
- package/web-popups/styles.d.ts +5 -0
- package/web-popups/styles.js +5 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
import { type InboxCellPreviewProps } from './types';
|
|
3
|
+
/** Plain text with every `{Tag|modifier}` token drawn as a tag chip. */
|
|
4
|
+
export declare function renderInboxTags(text: string): ReactNode;
|
|
3
5
|
/** One inbox cell drawn the way the SDK of `platform` draws it; the web skin is the WebSDK widget cell itself. A known layout is kept as chosen, with placeholders for its missing media. */
|
|
4
6
|
export declare function InboxCellPreview(props: InboxCellPreviewProps): ReactElement;
|
|
@@ -10,6 +10,8 @@ const CLEAR = '#FFFFFF';
|
|
|
10
10
|
const DIVIDER = '#EBF0F5';
|
|
11
11
|
const BRIGHT = '#00A2FF';
|
|
12
12
|
const BRIGHT_LIGHT = '#80B7FF33';
|
|
13
|
+
const EXCEPTIONAL = '#B255E0';
|
|
14
|
+
const EXCEPTIONAL_LIGHT = '#DE9BFF24';
|
|
13
15
|
const SOFT_LIGHT = '#889EB81A';
|
|
14
16
|
const RADIUS = '8px';
|
|
15
17
|
const FONT = 'Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
|
|
@@ -51,6 +53,54 @@ const ELLIPSIS = {
|
|
|
51
53
|
textOverflow: 'ellipsis',
|
|
52
54
|
whiteSpace: 'nowrap'
|
|
53
55
|
};
|
|
56
|
+
// `{{key|text}}` is a localization placeholder, not a tag, so it is matched first and kept literal.
|
|
57
|
+
const TAG_TOKEN = /(\{\{[^{}]*\}\}|\{(?=[^{}]*\|)[^{}]*\})/;
|
|
58
|
+
const TAG = {
|
|
59
|
+
display: 'inline-flex',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
gap: 1,
|
|
62
|
+
height: 16,
|
|
63
|
+
padding: 2,
|
|
64
|
+
boxSizing: 'border-box',
|
|
65
|
+
borderRadius: 4,
|
|
66
|
+
background: EXCEPTIONAL_LIGHT,
|
|
67
|
+
verticalAlign: 'middle',
|
|
68
|
+
whiteSpace: 'nowrap'
|
|
69
|
+
};
|
|
70
|
+
const TAG_BRACKET = {
|
|
71
|
+
fontSize: 13,
|
|
72
|
+
lineHeight: '18px',
|
|
73
|
+
fontWeight: 500,
|
|
74
|
+
color: EXCEPTIONAL
|
|
75
|
+
};
|
|
76
|
+
const TAG_NAME = {
|
|
77
|
+
fontSize: 10,
|
|
78
|
+
lineHeight: 1.2,
|
|
79
|
+
fontWeight: 400,
|
|
80
|
+
color: MAIN
|
|
81
|
+
};
|
|
82
|
+
/** Plain text with every `{Tag|modifier}` token drawn as a tag chip. */
|
|
83
|
+
export function renderInboxTags(text) {
|
|
84
|
+
return text.split(TAG_TOKEN).map((part, index) => {
|
|
85
|
+
if (index % 2 === 0 || part.startsWith('{{')) {
|
|
86
|
+
return part;
|
|
87
|
+
}
|
|
88
|
+
return _jsxs("span", {
|
|
89
|
+
"data-inbox-tag": true,
|
|
90
|
+
style: TAG,
|
|
91
|
+
children: [_jsx("span", {
|
|
92
|
+
style: TAG_BRACKET,
|
|
93
|
+
children: '{'
|
|
94
|
+
}), _jsx("span", {
|
|
95
|
+
style: TAG_NAME,
|
|
96
|
+
children: part.slice(1, -1).split('|')[0]
|
|
97
|
+
}), _jsx("span", {
|
|
98
|
+
style: TAG_BRACKET,
|
|
99
|
+
children: '}'
|
|
100
|
+
})]
|
|
101
|
+
}, index);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
54
104
|
const AVATAR = {
|
|
55
105
|
ios: {
|
|
56
106
|
size: 30,
|
|
@@ -454,7 +504,7 @@ export function InboxCellPreview(props) {
|
|
|
454
504
|
isLoading = false,
|
|
455
505
|
emptyTitle = 'Message preview',
|
|
456
506
|
emptyDescription = 'Enter text of your inbox message to see the preview',
|
|
457
|
-
renderText =
|
|
507
|
+
renderText = renderInboxTags,
|
|
458
508
|
iconPlaceholder = false,
|
|
459
509
|
width = '100%'
|
|
460
510
|
} = props;
|
|
@@ -502,14 +552,16 @@ export function InboxCellPreview(props) {
|
|
|
502
552
|
children: _jsx("ul", {
|
|
503
553
|
className: "pw-inbox_list",
|
|
504
554
|
children: _jsx(InboxWebCell, {
|
|
505
|
-
body: isEmpty ? emptyDescription : picked.body,
|
|
555
|
+
body: isEmpty ? emptyDescription : picked.body && renderText(picked.body),
|
|
506
556
|
content: picked,
|
|
507
557
|
isActionPerformed: !unread,
|
|
508
558
|
isRead: !unread,
|
|
509
559
|
layout: layout,
|
|
510
560
|
placeholder: isEmpty || (layout === 'classic' ? isIconPending : !hasMedia(picked, layout)),
|
|
511
561
|
timeLabel: formatInboxMessageTime(sendDate || new Date().toISOString()),
|
|
512
|
-
title: isEmpty ? emptyTitle : picked.title
|
|
562
|
+
title: isEmpty ? emptyTitle : picked.title && _jsx("span", {
|
|
563
|
+
children: renderText(picked.title)
|
|
564
|
+
})
|
|
513
565
|
})
|
|
514
566
|
})
|
|
515
567
|
})]
|
package/inbox/types.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ export interface InboxCellPreviewProps {
|
|
|
117
117
|
emptyTitle?: ReactNode;
|
|
118
118
|
/** Description of the empty placeholder. */
|
|
119
119
|
emptyDescription?: ReactNode;
|
|
120
|
-
/** Renders the title/body of
|
|
120
|
+
/** Renders the title/body of every cell (e.g. a rich-text viewer); by default tags are drawn as chips. */
|
|
121
121
|
renderText?: (text: string) => ReactNode;
|
|
122
122
|
/** Appearance of the web cell. */
|
|
123
123
|
appearance?: Partial<InboxWidgetAppearance>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/websdk-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.26.0",
|
|
4
4
|
"description": "Code shared by the Pushwoosh WebSDK and the Control Panel, one entry point per module (web-popups: web popup model and renderer; subscription-widget: push subscription widget model and renderer; inbox: web inbox widget and inbox cell previews)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { WebPopupFormSessionContext } from '../../formSession';
|
|
4
|
+
import { WEB_POPUP_SUBMIT_ATTRIBUTE } from '../../styles';
|
|
4
5
|
import { errorStyle } from '../styles';
|
|
5
6
|
import { pillStyle, slotStyle } from './styles';
|
|
6
7
|
/** A Form's Submit: sends every field of the popup; shows errorMessage after a refusal. */
|
|
@@ -15,6 +16,7 @@ export function SubmitSlotView({
|
|
|
15
16
|
style: slotStyle,
|
|
16
17
|
children: [_jsx("button", {
|
|
17
18
|
type: "button",
|
|
19
|
+
[WEB_POPUP_SUBMIT_ATTRIBUTE]: '',
|
|
18
20
|
disabled: submitting,
|
|
19
21
|
style: pillStyle(slot.variant, colors, submitting),
|
|
20
22
|
onClick: session.submit,
|
package/web-popups/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { WebPopupReader, WebPopupBox, WebPopupSlotView } from './WebPopupReader';
|
|
2
2
|
export { WebPopupInline } from './WebPopupInline';
|
|
3
|
-
export { WEB_POPUP_CLOSE_ATTRIBUTE } from './styles';
|
|
3
|
+
export { WEB_POPUP_CLOSE_ATTRIBUTE, WEB_POPUP_SUBMIT_ATTRIBUTE } from './styles';
|
|
4
4
|
export { WEB_POPUP_TEMPLATES, findWebPopupTemplate } from './templates';
|
|
5
5
|
export { parseWebPopupJson, stringifyWebPopup, resolveWebPopupPages, resolveWebPopupPageSize, startPageOf, safeUrl, sanitizeWebPopupHtml, normalizeWebPopupColors, normalizeWebPopupValues, webPopupValuesMap, collectWebPopupFormCodes, webPopupExpired, normalizeWebPopupDark, WEB_POPUP_MAX_SIZE_PX, isWebPopupCloseButton, webPopupPageWithoutCloseButtons, webPopupParamsWithoutCloseButtons, } from './helpers';
|
|
6
6
|
export { webPopupHasForm } from './form';
|
package/web-popups/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { WebPopupReader, WebPopupBox, WebPopupSlotView } from './WebPopupReader';
|
|
2
2
|
export { WebPopupInline } from './WebPopupInline';
|
|
3
|
-
export { WEB_POPUP_CLOSE_ATTRIBUTE } from './styles';
|
|
3
|
+
export { WEB_POPUP_CLOSE_ATTRIBUTE, WEB_POPUP_SUBMIT_ATTRIBUTE } from './styles';
|
|
4
4
|
export { WEB_POPUP_TEMPLATES, findWebPopupTemplate } from './templates';
|
|
5
5
|
export { parseWebPopupJson, stringifyWebPopup, resolveWebPopupPages, resolveWebPopupPageSize, startPageOf, safeUrl, sanitizeWebPopupHtml, normalizeWebPopupColors, normalizeWebPopupValues, webPopupValuesMap, collectWebPopupFormCodes, webPopupExpired, normalizeWebPopupDark, WEB_POPUP_MAX_SIZE_PX, isWebPopupCloseButton, webPopupPageWithoutCloseButtons, webPopupParamsWithoutCloseButtons } from './helpers';
|
|
6
6
|
export { webPopupHasForm } from './form';
|
package/web-popups/styles.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { type CSSProperties } from 'react';
|
|
|
3
3
|
export declare const WEB_POPUP_INLINE_SCOPE_ATTRIBUTE = "data-pw-web-popup-inline";
|
|
4
4
|
/** Marks the reader's ✕, so a host can tell it from the content's own buttons. */
|
|
5
5
|
export declare const WEB_POPUP_CLOSE_ATTRIBUTE = "data-pw-close";
|
|
6
|
+
/**
|
|
7
|
+
* Marks the FORM content Submit: its send already counts in the campaign's Submits, so the host skips it as a click.
|
|
8
|
+
* Email-subscription-form, choice and rating sends don't reach Submits, so their clicks stay interactions.
|
|
9
|
+
*/
|
|
10
|
+
export declare const WEB_POPUP_SUBMIT_ATTRIBUTE = "data-pw-submit";
|
|
6
11
|
/** An Inline block fills its container: the page's own width only sizes a floating popup. */
|
|
7
12
|
export declare const WEB_POPUP_INLINE_WRAPPER_STYLE: CSSProperties;
|
|
8
13
|
/** Image-cap stylesheet of an Inline block, scoped by WEB_POPUP_INLINE_SCOPE_ATTRIBUTE. */
|
package/web-popups/styles.js
CHANGED
|
@@ -3,6 +3,11 @@ import { WEB_POPUP_INLINE_IMAGE_MAX_HEIGHT } from './constants';
|
|
|
3
3
|
export const WEB_POPUP_INLINE_SCOPE_ATTRIBUTE = 'data-pw-web-popup-inline';
|
|
4
4
|
/** Marks the reader's ✕, so a host can tell it from the content's own buttons. */
|
|
5
5
|
export const WEB_POPUP_CLOSE_ATTRIBUTE = 'data-pw-close';
|
|
6
|
+
/**
|
|
7
|
+
* Marks the FORM content Submit: its send already counts in the campaign's Submits, so the host skips it as a click.
|
|
8
|
+
* Email-subscription-form, choice and rating sends don't reach Submits, so their clicks stay interactions.
|
|
9
|
+
*/
|
|
10
|
+
export const WEB_POPUP_SUBMIT_ATTRIBUTE = 'data-pw-submit';
|
|
6
11
|
/** An Inline block fills its container: the page's own width only sizes a floating popup. */
|
|
7
12
|
export const WEB_POPUP_INLINE_WRAPPER_STYLE = {
|
|
8
13
|
width: '100%'
|