@pushwoosh/websdk-common 6.23.1 → 6.24.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.js +1 -2
- package/package.json +1 -1
- package/web-popups/WebPopupInline.d.ts +2 -2
- package/web-popups/WebPopupInline.js +7 -3
- package/web-popups/WebPopupReader.d.ts +3 -3
- package/web-popups/WebPopupReader.js +50 -18
- package/web-popups/helpers.d.ts +8 -1
- package/web-popups/helpers.js +23 -0
- package/web-popups/index.d.ts +2 -1
- package/web-popups/index.js +1 -0
- package/web-popups/styles.d.ts +2 -0
- package/web-popups/styles.js +2 -0
- package/web-popups/types.d.ts +26 -2
|
@@ -6,7 +6,6 @@ import { InboxWebCell, inboxWidgetPreviewFrame } from './InboxWidgetReader';
|
|
|
6
6
|
const MAIN = '#4B5057';
|
|
7
7
|
const LOCKED = '#767C82';
|
|
8
8
|
const PHANTOM = '#9AA0A6';
|
|
9
|
-
const FROZEN = '#F7F9FA';
|
|
10
9
|
const CLEAR = '#FFFFFF';
|
|
11
10
|
const DIVIDER = '#EBF0F5';
|
|
12
11
|
const BRIGHT = '#00A2FF';
|
|
@@ -349,7 +348,7 @@ function IOSCell(props) {
|
|
|
349
348
|
alignItems: 'flex-start',
|
|
350
349
|
gap: 4,
|
|
351
350
|
padding: 8,
|
|
352
|
-
background:
|
|
351
|
+
background: CLEAR,
|
|
353
352
|
border: `1px solid ${SOFT_LIGHT}`,
|
|
354
353
|
borderRadius: RADIUS
|
|
355
354
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/websdk-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.24.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,8 +1,8 @@
|
|
|
1
1
|
import { type WebPopupInlineProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* An Inline (EMBEDDED) block: one page box at its container's full width (the page width is ignored),
|
|
4
|
-
* without close-action buttons or ✕.
|
|
4
|
+
* without close-action buttons or ✕. Only a subscribe answer removes it, through onRequestRemove; a 'hide-popup' timer does not.
|
|
5
5
|
* `<img>` is capped by a `<style>` scoped to the wrapper's attribute, so the rule never reaches
|
|
6
6
|
* the host page, in a shadow root or in the light DOM. Page navigation is internal.
|
|
7
7
|
*/
|
|
8
|
-
export declare function WebPopupInline({ params, mode, colorScheme, onSubmitForm, onSubmitFormValues, onSubmitChoice, onSubmitRating, onRequestSubscribe, }: WebPopupInlineProps): import("react").JSX.Element | null;
|
|
8
|
+
export declare function WebPopupInline({ params, mode, colorScheme, logger, onSubmitForm, onSubmitFormValues, onSubmitChoice, onSubmitRating, onRequestSubscribe, onRequestRemove, }: WebPopupInlineProps): import("react").JSX.Element | null;
|
|
@@ -7,7 +7,7 @@ import { WEB_POPUP_INLINE_IMAGE_CAP_CSS, WEB_POPUP_INLINE_SCOPE_ATTRIBUTE, WEB_P
|
|
|
7
7
|
import { WebPopupBox } from './WebPopupReader';
|
|
8
8
|
/**
|
|
9
9
|
* An Inline (EMBEDDED) block: one page box at its container's full width (the page width is ignored),
|
|
10
|
-
* without close-action buttons or ✕.
|
|
10
|
+
* without close-action buttons or ✕. Only a subscribe answer removes it, through onRequestRemove; a 'hide-popup' timer does not.
|
|
11
11
|
* `<img>` is capped by a `<style>` scoped to the wrapper's attribute, so the rule never reaches
|
|
12
12
|
* the host page, in a shadow root or in the light DOM. Page navigation is internal.
|
|
13
13
|
*/
|
|
@@ -15,11 +15,13 @@ export function WebPopupInline({
|
|
|
15
15
|
params,
|
|
16
16
|
mode = 'live',
|
|
17
17
|
colorScheme = 'auto',
|
|
18
|
+
logger,
|
|
18
19
|
onSubmitForm,
|
|
19
20
|
onSubmitFormValues,
|
|
20
21
|
onSubmitChoice,
|
|
21
22
|
onSubmitRating,
|
|
22
|
-
onRequestSubscribe
|
|
23
|
+
onRequestSubscribe,
|
|
24
|
+
onRequestRemove
|
|
23
25
|
}) {
|
|
24
26
|
const [pageKey, setPageKey] = useState(null);
|
|
25
27
|
const shown = useMemo(() => webPopupParamsWithoutCloseButtons(params), [params]);
|
|
@@ -42,7 +44,9 @@ export function WebPopupInline({
|
|
|
42
44
|
onSubmitFormValues: onSubmitFormValues,
|
|
43
45
|
onSubmitChoice: onSubmitChoice,
|
|
44
46
|
onSubmitRating: onSubmitRating,
|
|
45
|
-
onRequestSubscribe: onRequestSubscribe
|
|
47
|
+
onRequestSubscribe: onRequestSubscribe,
|
|
48
|
+
onSubscribeClose: onRequestRemove,
|
|
49
|
+
logger: logger
|
|
46
50
|
})]
|
|
47
51
|
});
|
|
48
52
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type WebPopupBoxProps, type WebPopupReaderProps, type WebPopupSlotViewProps } from './types';
|
|
2
|
-
export declare function WebPopupSlotView({ slot, align, inverse, colors, mode, onRequestClose, onPageChange, onSubmitForm, onSubmitChoice, onSubmitRating, onRequestSubscribe, }: WebPopupSlotViewProps): import("react").JSX.Element;
|
|
3
|
-
export declare function WebPopupBox({ page, params, mode, colorScheme, leafRenderers, animatePage, onRequestClose, onPageChange, onSubmitForm, onSubmitFormValues, onSubmitChoice, onSubmitRating, onRequestSubscribe, }: WebPopupBoxProps): import("react").JSX.Element;
|
|
4
|
-
export declare function WebPopupReader({ params, mode, colorScheme, onRequestClose, onSubmitForm, onSubmitFormValues, onSubmitChoice, onSubmitRating, onRequestSubscribe, leafRenderers, }: WebPopupReaderProps): import("react").JSX.Element | null;
|
|
2
|
+
export declare function WebPopupSlotView({ slot, align, inverse, colors, mode, onRequestClose, onPageChange, onSubmitForm, onSubmitChoice, onSubmitRating, onRequestSubscribe, onSubscribeClose, logger, }: WebPopupSlotViewProps): import("react").JSX.Element;
|
|
3
|
+
export declare function WebPopupBox({ page, params, mode, colorScheme, leafRenderers, animatePage, onRequestClose, onPageChange, onSubmitForm, onSubmitFormValues, onSubmitChoice, onSubmitRating, onRequestSubscribe, onSubscribeClose, logger, }: WebPopupBoxProps): import("react").JSX.Element;
|
|
4
|
+
export declare function WebPopupReader({ params, mode, colorScheme, onRequestClose, onSubmitForm, onSubmitFormValues, onSubmitChoice, onSubmitRating, onRequestSubscribe, logger, leafRenderers, }: WebPopupReaderProps): import("react").JSX.Element | null;
|
|
@@ -5,9 +5,10 @@ import { webPopupButtonPillStyle, webPopupFormInputStyle, webPopupRatingScores,
|
|
|
5
5
|
import { ConsentSlotView, EmailInputSlotView, SubmitSlotView, TagInputSlotView } from './form-slots';
|
|
6
6
|
import { useWebPopupFormSession, WebPopupFormSessionContext } from './formSession';
|
|
7
7
|
import { WEB_POPUP_GLYPH_PATHS, WEB_POPUP_THUMB_UP_PATH } from './glyphs';
|
|
8
|
-
import { placementMaxSize, resolveWebPopupPages, safeUrl, sanitizeWebPopupHtml, startPageOf, webPopupLinkTargetAttrs } from './helpers';
|
|
8
|
+
import { applyWebPopupSubscribeOutcome, placementMaxSize, resolveWebPopupPages, safeUrl, sanitizeWebPopupHtml, startPageOf, webPopupLinkTargetAttrs } from './helpers';
|
|
9
9
|
import { webPopupBackgroundImageStyle, webPopupContainerStyle, webPopupScrimGradient } from './layout';
|
|
10
10
|
import { resolveWebPopupBoxChrome, resolveWebPopupColors, webPopupColorAlpha, webPopupDarkEnabled, webPopupImageSrc } from './palette';
|
|
11
|
+
import { WEB_POPUP_CLOSE_ATTRIBUTE } from './styles';
|
|
11
12
|
import { webPopupTimerLabels, webPopupTimerRemaining } from './timer';
|
|
12
13
|
// Renders a popup from its model by interpreting each page's embedded layout
|
|
13
14
|
// tree — the same node vocabulary the editor's canvas builds from: container
|
|
@@ -46,9 +47,11 @@ function TextSlotView({
|
|
|
46
47
|
function ButtonSlotView({
|
|
47
48
|
slot,
|
|
48
49
|
colors,
|
|
50
|
+
logger,
|
|
49
51
|
onRequestClose,
|
|
50
52
|
onPageChange,
|
|
51
|
-
onRequestSubscribe
|
|
53
|
+
onRequestSubscribe,
|
|
54
|
+
onSubscribeClose
|
|
52
55
|
}) {
|
|
53
56
|
const form = useContext(WebPopupFormSessionContext);
|
|
54
57
|
const [askPhase, setAskPhase] = useState('idle');
|
|
@@ -78,6 +81,9 @@ function ButtonSlotView({
|
|
|
78
81
|
});
|
|
79
82
|
}
|
|
80
83
|
if (slot.action.type === 'subscribe') {
|
|
84
|
+
const {
|
|
85
|
+
action
|
|
86
|
+
} = slot;
|
|
81
87
|
// 'asking' guards the double click (one prompt, one registerDevice);
|
|
82
88
|
// 'denied' stays disabled because the browser grants no second prompt.
|
|
83
89
|
const spent = askPhase !== 'idle';
|
|
@@ -85,13 +91,15 @@ function ButtonSlotView({
|
|
|
85
91
|
if (!onRequestSubscribe || spent) return;
|
|
86
92
|
setAskPhase('asking');
|
|
87
93
|
onRequestSubscribe().then(result => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
if (result === 'default') {
|
|
95
|
+
setAskPhase('idle');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (applyWebPopupSubscribeOutcome(action, result, logger)) {
|
|
99
|
+
onSubscribeClose?.();
|
|
92
100
|
return;
|
|
93
101
|
}
|
|
94
|
-
setAskPhase(
|
|
102
|
+
setAskPhase('denied');
|
|
95
103
|
}).catch(() => setAskPhase('idle'));
|
|
96
104
|
};
|
|
97
105
|
return _jsx("div", {
|
|
@@ -812,7 +820,9 @@ export function WebPopupSlotView({
|
|
|
812
820
|
onSubmitForm,
|
|
813
821
|
onSubmitChoice,
|
|
814
822
|
onSubmitRating,
|
|
815
|
-
onRequestSubscribe
|
|
823
|
+
onRequestSubscribe,
|
|
824
|
+
onSubscribeClose,
|
|
825
|
+
logger
|
|
816
826
|
}) {
|
|
817
827
|
// A page jump nobody handles is a no-op, not a crash — the editor canvas
|
|
818
828
|
// and the previews mount this without any navigation of their own.
|
|
@@ -831,7 +841,9 @@ export function WebPopupSlotView({
|
|
|
831
841
|
colors: colors,
|
|
832
842
|
onRequestClose: onRequestClose,
|
|
833
843
|
onPageChange: pageChange,
|
|
834
|
-
onRequestSubscribe: onRequestSubscribe
|
|
844
|
+
onRequestSubscribe: onRequestSubscribe,
|
|
845
|
+
onSubscribeClose: onSubscribeClose,
|
|
846
|
+
logger: logger
|
|
835
847
|
});
|
|
836
848
|
case 'email-subscription-form':
|
|
837
849
|
return _jsx(FormSlotView, {
|
|
@@ -913,7 +925,9 @@ function ContentNodeView({
|
|
|
913
925
|
onSubmitForm,
|
|
914
926
|
onSubmitChoice,
|
|
915
927
|
onSubmitRating,
|
|
916
|
-
onRequestSubscribe
|
|
928
|
+
onRequestSubscribe,
|
|
929
|
+
onSubscribeClose,
|
|
930
|
+
logger
|
|
917
931
|
}) {
|
|
918
932
|
const zone = page.contents.find(z => z.key === node.props.content);
|
|
919
933
|
if (!zone) return null;
|
|
@@ -949,7 +963,9 @@ function ContentNodeView({
|
|
|
949
963
|
onSubmitForm: onSubmitForm,
|
|
950
964
|
onSubmitChoice: onSubmitChoice,
|
|
951
965
|
onSubmitRating: onSubmitRating,
|
|
952
|
-
onRequestSubscribe: onRequestSubscribe
|
|
966
|
+
onRequestSubscribe: onRequestSubscribe,
|
|
967
|
+
onSubscribeClose: onSubscribeClose,
|
|
968
|
+
logger: logger
|
|
953
969
|
})
|
|
954
970
|
}, slot.key);
|
|
955
971
|
})
|
|
@@ -1066,7 +1082,9 @@ function LayoutNodeView({
|
|
|
1066
1082
|
onSubmitForm,
|
|
1067
1083
|
onSubmitChoice,
|
|
1068
1084
|
onSubmitRating,
|
|
1069
|
-
onRequestSubscribe
|
|
1085
|
+
onRequestSubscribe,
|
|
1086
|
+
onSubscribeClose,
|
|
1087
|
+
logger
|
|
1070
1088
|
}) {
|
|
1071
1089
|
if (node.type === 'Content') {
|
|
1072
1090
|
return _jsx(ContentNodeView, {
|
|
@@ -1081,7 +1099,9 @@ function LayoutNodeView({
|
|
|
1081
1099
|
onSubmitForm: onSubmitForm,
|
|
1082
1100
|
onSubmitChoice: onSubmitChoice,
|
|
1083
1101
|
onSubmitRating: onSubmitRating,
|
|
1084
|
-
onRequestSubscribe: onRequestSubscribe
|
|
1102
|
+
onRequestSubscribe: onRequestSubscribe,
|
|
1103
|
+
onSubscribeClose: onSubscribeClose,
|
|
1104
|
+
logger: logger
|
|
1085
1105
|
});
|
|
1086
1106
|
}
|
|
1087
1107
|
if (node.type === 'Image') {
|
|
@@ -1115,7 +1135,9 @@ function LayoutNodeView({
|
|
|
1115
1135
|
onSubmitForm: onSubmitForm,
|
|
1116
1136
|
onSubmitChoice: onSubmitChoice,
|
|
1117
1137
|
onSubmitRating: onSubmitRating,
|
|
1118
|
-
onRequestSubscribe: onRequestSubscribe
|
|
1138
|
+
onRequestSubscribe: onRequestSubscribe,
|
|
1139
|
+
onSubscribeClose: onSubscribeClose,
|
|
1140
|
+
logger: logger
|
|
1119
1141
|
}, index));
|
|
1120
1142
|
if (bgVideo && background) {
|
|
1121
1143
|
// A background video can't ride the css background property, so it paints
|
|
@@ -1197,7 +1219,9 @@ export function WebPopupBox({
|
|
|
1197
1219
|
onSubmitFormValues,
|
|
1198
1220
|
onSubmitChoice,
|
|
1199
1221
|
onSubmitRating,
|
|
1200
|
-
onRequestSubscribe
|
|
1222
|
+
onRequestSubscribe,
|
|
1223
|
+
onSubscribeClose,
|
|
1224
|
+
logger
|
|
1201
1225
|
}) {
|
|
1202
1226
|
const formSession = useWebPopupFormSession(params, page.key, onPageChange, onSubmitFormValues);
|
|
1203
1227
|
const colors = resolveWebPopupColors(params, colorScheme);
|
|
@@ -1251,7 +1275,9 @@ export function WebPopupBox({
|
|
|
1251
1275
|
onSubmitForm: onSubmitForm,
|
|
1252
1276
|
onSubmitChoice: onSubmitChoice,
|
|
1253
1277
|
onSubmitRating: onSubmitRating,
|
|
1254
|
-
onRequestSubscribe: onRequestSubscribe
|
|
1278
|
+
onRequestSubscribe: onRequestSubscribe,
|
|
1279
|
+
onSubscribeClose: onSubscribeClose,
|
|
1280
|
+
logger: logger
|
|
1255
1281
|
})
|
|
1256
1282
|
}, page.key)
|
|
1257
1283
|
})
|
|
@@ -1264,6 +1290,7 @@ function CloseButton({
|
|
|
1264
1290
|
return _jsx("button", {
|
|
1265
1291
|
type: "button",
|
|
1266
1292
|
"aria-label": "Close",
|
|
1293
|
+
[WEB_POPUP_CLOSE_ATTRIBUTE]: '',
|
|
1267
1294
|
onClick: onRequestClose,
|
|
1268
1295
|
style: {
|
|
1269
1296
|
position: 'absolute',
|
|
@@ -1336,6 +1363,7 @@ export function WebPopupReader({
|
|
|
1336
1363
|
onSubmitChoice,
|
|
1337
1364
|
onSubmitRating,
|
|
1338
1365
|
onRequestSubscribe,
|
|
1366
|
+
logger,
|
|
1339
1367
|
leafRenderers
|
|
1340
1368
|
}) {
|
|
1341
1369
|
// null = never navigated: show the start page. Guarded against keys that
|
|
@@ -1383,7 +1411,9 @@ export function WebPopupReader({
|
|
|
1383
1411
|
onSubmitFormValues: onSubmitFormValues,
|
|
1384
1412
|
onSubmitChoice: onSubmitChoice,
|
|
1385
1413
|
onSubmitRating: onSubmitRating,
|
|
1386
|
-
onRequestSubscribe: onRequestSubscribe
|
|
1414
|
+
onRequestSubscribe: onRequestSubscribe,
|
|
1415
|
+
onSubscribeClose: onRequestClose,
|
|
1416
|
+
logger: logger
|
|
1387
1417
|
})]
|
|
1388
1418
|
});
|
|
1389
1419
|
}
|
|
@@ -1418,7 +1448,9 @@ export function WebPopupReader({
|
|
|
1418
1448
|
onSubmitFormValues: onSubmitFormValues,
|
|
1419
1449
|
onSubmitChoice: onSubmitChoice,
|
|
1420
1450
|
onSubmitRating: onSubmitRating,
|
|
1421
|
-
onRequestSubscribe: onRequestSubscribe
|
|
1451
|
+
onRequestSubscribe: onRequestSubscribe,
|
|
1452
|
+
onSubscribeClose: onRequestClose,
|
|
1453
|
+
logger: logger
|
|
1422
1454
|
}), _jsx(CloseButton, {
|
|
1423
1455
|
colors: resolveWebPopupColors(params, scheme),
|
|
1424
1456
|
onRequestClose: onRequestClose
|
package/web-popups/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type WebPopupColors, type WebPopupDark, type WebPopupJson, type WebPopupPageParams, type WebPopupParams, type WebPopupPlacement, type WebPopupResolvedPage, type WebPopupValueParam } from './types';
|
|
1
|
+
import { type WebPopupButtonAction, type WebPopupColors, type WebPopupDark, type WebPopupJson, type WebPopupLogger, type WebPopupPageParams, type WebPopupParams, type WebPopupPlacement, type WebPopupResolvedPage, type WebPopupValueParam } from './types';
|
|
2
2
|
export declare function safeUrl(url: string | undefined): string | undefined;
|
|
3
3
|
/**
|
|
4
4
|
* The target/rel pair a popup link renders with: only an exact '_self' opts
|
|
@@ -10,6 +10,13 @@ export declare function webPopupLinkTargetAttrs(target: string | null | undefine
|
|
|
10
10
|
target: '_blank' | '_self';
|
|
11
11
|
rel?: 'noreferrer';
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Carries out a subscribe button's setting for the visitor's answer; true = the content closes.
|
|
15
|
+
* A new tab opens with noopener, so `window.open` returns null and a blocked tab goes unnoticed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyWebPopupSubscribeOutcome(action: Extract<WebPopupButtonAction, {
|
|
18
|
+
type: 'subscribe';
|
|
19
|
+
}>, result: 'granted' | 'denied', logger: WebPopupLogger | undefined): boolean;
|
|
13
20
|
/**
|
|
14
21
|
* Sanitize a text slot's html before it's injected into the page. The editor
|
|
15
22
|
* only ever writes inline formatting, but the json travels through a public
|
package/web-popups/helpers.js
CHANGED
|
@@ -26,6 +26,29 @@ export function webPopupLinkTargetAttrs(target) {
|
|
|
26
26
|
rel: 'noreferrer'
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Carries out a subscribe button's setting for the visitor's answer; true = the content closes.
|
|
31
|
+
* A new tab opens with noopener, so `window.open` returns null and a blocked tab goes unnoticed.
|
|
32
|
+
*/
|
|
33
|
+
export function applyWebPopupSubscribeOutcome(action, result, logger) {
|
|
34
|
+
const outcome = result === 'granted' ? action.onGranted : action.onDenied;
|
|
35
|
+
if (outcome?.type === 'href') openWebPopupSubscribeLink(outcome, logger);
|
|
36
|
+
// Granted always closes, as before the setting; denied closes only when set to.
|
|
37
|
+
if (result === 'granted') return true;
|
|
38
|
+
return outcome?.type === 'close';
|
|
39
|
+
}
|
|
40
|
+
function openWebPopupSubscribeLink(outcome, logger) {
|
|
41
|
+
const href = typeof outcome.url === 'string' ? safeUrl(outcome.url) : undefined;
|
|
42
|
+
if (!href) {
|
|
43
|
+
logger?.warn('Subscribe button: the link to open after the answer is empty or unsafe, it was not opened');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (outcome.target === '_self') {
|
|
47
|
+
window.location.assign(href);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
window.open(href, '_blank', 'noopener,noreferrer');
|
|
51
|
+
}
|
|
29
52
|
const SANITIZE_ALLOWED_TAGS = new Set(['STRONG', 'B', 'EM', 'I', 'U', 'BR', 'A']);
|
|
30
53
|
function copySanitized(from, to, doc) {
|
|
31
54
|
for (const child of Array.from(from.childNodes)) {
|
package/web-popups/index.d.ts
CHANGED
|
@@ -1,5 +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
4
|
export { WEB_POPUP_TEMPLATES, findWebPopupTemplate } from './templates';
|
|
4
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';
|
|
5
6
|
export { webPopupHasForm } from './form';
|
|
@@ -8,4 +9,4 @@ export { normalizeWebPopupLayout, substituteWebPopupLayoutValues, WEB_POPUP_VALU
|
|
|
8
9
|
export { WEB_POPUP_VERSION, WEB_POPUP_FONT_STACK, WEB_POPUP_TEXT_COLOR, WEB_POPUP_TEXT_SECONDARY_COLOR, WEB_POPUP_ACCENT_COLOR, WEB_POPUP_BACKGROUND_COLOR, WEB_POPUP_DEFAULT_COLORS, webPopupTextColor, WEB_POPUP_TEXT_VARIANT_STYLES, WEB_POPUP_BG_SECTION_FALLBACK, WEB_POPUP_TEXT_SLOT_PADDING, WEB_POPUP_BUTTON_SLOT_PADDING, webPopupSlotGap, webPopupSlotRole, type WebPopupSlotRole, WEB_POPUP_DEFAULT_WIDTH, WEB_POPUP_INLINE_IMAGE_MAX_HEIGHT, WEB_POPUP_LAYOUT_MAX_DEPTH, WEB_POPUP_LAYOUT_MAX_NODES, webPopupButtonPillStyle, webPopupFormInputStyle, WEB_POPUP_FORM_INPUT_BORDER, WEB_POPUP_FORM_ERROR_COLOR, WEB_POPUP_FORM_ERROR_COLOR_DARK, WEB_POPUP_ON_ACCENT_COLOR, WEB_POPUP_FORM_DEFAULTS, WEB_POPUP_CHOICE_DEFAULTS, WEB_POPUP_MAX_CHOICE_OPTIONS, WEB_POPUP_RATING_DEFAULTS, WEB_POPUP_RETRY_ERROR, WEB_POPUP_EMAIL_INPUT_DEFAULTS, WEB_POPUP_TAG_INPUT_DEFAULTS, WEB_POPUP_CONSENT_DEFAULTS, WEB_POPUP_SUBMIT_DEFAULTS, webPopupRatingScores, } from './constants';
|
|
9
10
|
export { resolveWebPopupBoxChrome, resolveWebPopupColors, autoDarkWebPopupColors, webPopupColorAlpha, webPopupDarkColors, webPopupDarkEnabled, webPopupEffectiveScheme, webPopupImageSrc, webPopupMixColor, webPopupShiftColor, } from './palette';
|
|
10
11
|
export { WEB_POPUP_GLYPH_NAMES, WEB_POPUP_GLYPH_PATHS, WEB_POPUP_GLYPH_SIZES, WEB_POPUP_THUMB_UP_PATH, } from './glyphs';
|
|
11
|
-
export { type WebPopupJson, type WebPopupKind, type WebPopupParams, type WebPopupColors, type WebPopupChrome, type WebPopupPageParams, type WebPopupResolvedPage, type WebPopupDark, type WebPopupResolvedColors, type WebPopupColorScheme, type WebPopupColorSchemePref, type WebPopupSlot, type WebPopupImage, type WebPopupVideo, type WebPopupPlacement, type WebPopupOverlay, type WebPopupAnimation, type WebPopupButtonAction, type WebPopupButtonVariant, type WebPopupTextVariant, type WebPopupTextAlign, type WebPopupVAnchor, type WebPopupHAnchor, type WebPopupReaderMode, type WebPopupReaderProps, type WebPopupLeafRenderers, type WebPopupBoxProps, type WebPopupInlineProps, type WebPopupLayoutNode, type WebPopupContainerNode, type WebPopupContentNode, type WebPopupImageNode, type WebPopupContainerType, type WebPopupContainerProps, type WebPopupContentZone, type WebPopupContentTone, type WebPopupCssLength, type WebPopupBoxSides, type WebPopupAlignItems, type WebPopupJustifyContent, type WebPopupValueParam, type WebPopupValueControl, type WebPopupLengthUnit, type WebPopupLengthRange, type WebPopupValueRef, type WebPopupTemplate, type WebPopupFormField, type WebPopupFormFieldKind, type WebPopupFormPrivacy, type WebPopupFormSubmitPayload, type WebPopupFormSubmitResult, type WebPopupFormSubmitHandler, type WebPopupEmailInputSlot, type WebPopupTagInputSlot, type WebPopupConsentSlot, type WebPopupSubmitSlot, type WebPopupFormValues, type WebPopupFormValuesSubmitResult, type WebPopupFormValuesSubmitHandler, type WebPopupTimerSlot, type WebPopupTimerExpireAction, type WebPopupTimerRemaining, type WebPopupChoiceSlot, type WebPopupChoiceOption, type WebPopupChoiceControl, type WebPopupChoiceSubmitPayload, type WebPopupChoiceSubmitHandler, type WebPopupRatingSlot, type WebPopupRatingScale, type WebPopupRatingSubmitMode, type WebPopupRatingSubmitPayload, type WebPopupRatingSubmitHandler, type WebPopupSubscribeResult, type WebPopupGlyphSlot, type WebPopupGlyphName, type WebPopupGlyphSize, type WebPopupSlotViewProps, } from './types';
|
|
12
|
+
export { type WebPopupJson, type WebPopupKind, type WebPopupParams, type WebPopupColors, type WebPopupChrome, type WebPopupPageParams, type WebPopupResolvedPage, type WebPopupDark, type WebPopupResolvedColors, type WebPopupColorScheme, type WebPopupColorSchemePref, type WebPopupSlot, type WebPopupImage, type WebPopupVideo, type WebPopupPlacement, type WebPopupOverlay, type WebPopupAnimation, type WebPopupButtonAction, type WebPopupButtonVariant, type WebPopupTextVariant, type WebPopupTextAlign, type WebPopupVAnchor, type WebPopupHAnchor, type WebPopupReaderMode, type WebPopupReaderProps, type WebPopupLeafRenderers, type WebPopupBoxProps, type WebPopupInlineProps, type WebPopupLayoutNode, type WebPopupContainerNode, type WebPopupContentNode, type WebPopupImageNode, type WebPopupContainerType, type WebPopupContainerProps, type WebPopupContentZone, type WebPopupContentTone, type WebPopupCssLength, type WebPopupBoxSides, type WebPopupAlignItems, type WebPopupJustifyContent, type WebPopupValueParam, type WebPopupValueControl, type WebPopupLengthUnit, type WebPopupLengthRange, type WebPopupValueRef, type WebPopupTemplate, type WebPopupFormField, type WebPopupFormFieldKind, type WebPopupFormPrivacy, type WebPopupFormSubmitPayload, type WebPopupFormSubmitResult, type WebPopupFormSubmitHandler, type WebPopupEmailInputSlot, type WebPopupTagInputSlot, type WebPopupConsentSlot, type WebPopupSubmitSlot, type WebPopupFormValues, type WebPopupFormValuesSubmitResult, type WebPopupFormValuesSubmitHandler, type WebPopupTimerSlot, type WebPopupTimerExpireAction, type WebPopupTimerRemaining, type WebPopupChoiceSlot, type WebPopupChoiceOption, type WebPopupChoiceControl, type WebPopupChoiceSubmitPayload, type WebPopupChoiceSubmitHandler, type WebPopupRatingSlot, type WebPopupRatingScale, type WebPopupRatingSubmitMode, type WebPopupRatingSubmitPayload, type WebPopupRatingSubmitHandler, type WebPopupSubscribeResult, type WebPopupSubscribeOutcome, type WebPopupLogger, type WebPopupGlyphSlot, type WebPopupGlyphName, type WebPopupGlyphSize, type WebPopupSlotViewProps, } from './types';
|
package/web-popups/index.js
CHANGED
|
@@ -1,5 +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
4
|
export { WEB_POPUP_TEMPLATES, findWebPopupTemplate } from './templates';
|
|
4
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';
|
|
5
6
|
export { webPopupHasForm } from './form';
|
package/web-popups/styles.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type CSSProperties } from 'react';
|
|
2
2
|
/** Marks an Inline block's wrapper; the image cap is scoped to it so it never reaches the host page. */
|
|
3
3
|
export declare const WEB_POPUP_INLINE_SCOPE_ATTRIBUTE = "data-pw-web-popup-inline";
|
|
4
|
+
/** Marks the reader's ✕, so a host can tell it from the content's own buttons. */
|
|
5
|
+
export declare const WEB_POPUP_CLOSE_ATTRIBUTE = "data-pw-close";
|
|
4
6
|
/** An Inline block fills its container: the page's own width only sizes a floating popup. */
|
|
5
7
|
export declare const WEB_POPUP_INLINE_WRAPPER_STYLE: CSSProperties;
|
|
6
8
|
/** Image-cap stylesheet of an Inline block, scoped by WEB_POPUP_INLINE_SCOPE_ATTRIBUTE. */
|
package/web-popups/styles.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { WEB_POPUP_INLINE_IMAGE_MAX_HEIGHT } from './constants';
|
|
2
2
|
/** Marks an Inline block's wrapper; the image cap is scoped to it so it never reaches the host page. */
|
|
3
3
|
export const WEB_POPUP_INLINE_SCOPE_ATTRIBUTE = 'data-pw-web-popup-inline';
|
|
4
|
+
/** Marks the reader's ✕, so a host can tell it from the content's own buttons. */
|
|
5
|
+
export const WEB_POPUP_CLOSE_ATTRIBUTE = 'data-pw-close';
|
|
4
6
|
/** An Inline block fills its container: the page's own width only sizes a floating popup. */
|
|
5
7
|
export const WEB_POPUP_INLINE_WRAPPER_STYLE = {
|
|
6
8
|
width: '100%'
|
package/web-popups/types.d.ts
CHANGED
|
@@ -19,12 +19,22 @@ export type WebPopupButtonAction =
|
|
|
19
19
|
type: 'page';
|
|
20
20
|
page: string;
|
|
21
21
|
}
|
|
22
|
-
/** Ask
|
|
22
|
+
/** Ask for push permission; without `onGranted` / `onDenied` 'granted' closes and 'denied' disables the button. */
|
|
23
23
|
| {
|
|
24
24
|
type: 'subscribe';
|
|
25
|
+
onGranted?: WebPopupSubscribeOutcome;
|
|
26
|
+
onDenied?: WebPopupSubscribeOutcome;
|
|
25
27
|
};
|
|
28
|
+
/** What the subscribe button does once the visitor answered. */
|
|
29
|
+
export type WebPopupSubscribeOutcome = Extract<WebPopupButtonAction, {
|
|
30
|
+
type: 'close' | 'href';
|
|
31
|
+
}>;
|
|
26
32
|
/** What the host's subscribe handler settled on — the browser's permission after the ask. */
|
|
27
33
|
export type WebPopupSubscribeResult = 'granted' | 'denied' | 'default';
|
|
34
|
+
/** Where the renderer reports what it could not do, e.g. an unsafe link; absent = silent. */
|
|
35
|
+
export interface WebPopupLogger {
|
|
36
|
+
warn(message: string): void;
|
|
37
|
+
}
|
|
28
38
|
/**
|
|
29
39
|
* Input kinds an email-subscription-form slot renders — the same set the
|
|
30
40
|
* subscription-form service accepts in a submission ('custom' entries land in
|
|
@@ -668,6 +678,8 @@ export type WebPopupReaderProps = {
|
|
|
668
678
|
onSubmitRating?: WebPopupRatingSubmitHandler;
|
|
669
679
|
/** `subscribe`-action buttons; absent = they render inert (previews, editor). */
|
|
670
680
|
onRequestSubscribe?: () => Promise<WebPopupSubscribeResult>;
|
|
681
|
+
/** Reports of what the renderer could not do; absent = silent (previews, editor). */
|
|
682
|
+
logger?: WebPopupLogger;
|
|
671
683
|
/** Editor-only leaf overrides — see WebPopupLeafRenderers. */
|
|
672
684
|
leafRenderers?: WebPopupLeafRenderers;
|
|
673
685
|
};
|
|
@@ -687,6 +699,10 @@ export type WebPopupSlotViewProps = {
|
|
|
687
699
|
onSubmitRating?: WebPopupRatingSubmitHandler;
|
|
688
700
|
/** `subscribe`-action buttons; absent = they render inert (previews, editor). */
|
|
689
701
|
onRequestSubscribe?: () => Promise<WebPopupSubscribeResult>;
|
|
702
|
+
/** Closes the content after a subscribe answer; absent = the answer closes nothing. */
|
|
703
|
+
onSubscribeClose?: () => void;
|
|
704
|
+
/** Reports of what the renderer could not do; absent = silent. */
|
|
705
|
+
logger?: WebPopupLogger;
|
|
690
706
|
};
|
|
691
707
|
/** Props of WebPopupBox — one resolved page's box, no viewport chrome. */
|
|
692
708
|
export type WebPopupBoxProps = {
|
|
@@ -713,8 +729,12 @@ export type WebPopupBoxProps = {
|
|
|
713
729
|
onSubmitRating?: WebPopupRatingSubmitHandler;
|
|
714
730
|
/** `subscribe`-action buttons; absent = they render inert (previews, editor). */
|
|
715
731
|
onRequestSubscribe?: () => Promise<WebPopupSubscribeResult>;
|
|
732
|
+
/** Closes the content after a subscribe answer; absent = the answer closes nothing. */
|
|
733
|
+
onSubscribeClose?: () => void;
|
|
734
|
+
/** Reports of what the renderer could not do; absent = silent. */
|
|
735
|
+
logger?: WebPopupLogger;
|
|
716
736
|
};
|
|
717
|
-
/** Props of WebPopupInline — an Inline (EMBEDDED) block: full container width,
|
|
737
|
+
/** Props of WebPopupInline — an Inline (EMBEDDED) block: full container width, only a subscribe answer removes it. */
|
|
718
738
|
export type WebPopupInlineProps = {
|
|
719
739
|
params: WebPopupParams;
|
|
720
740
|
/** Default 'live'; 'preview' reaches the leaves: no autoplay, no interval. */
|
|
@@ -731,4 +751,8 @@ export type WebPopupInlineProps = {
|
|
|
731
751
|
onSubmitRating?: WebPopupRatingSubmitHandler;
|
|
732
752
|
/** `subscribe`-action buttons; absent = they render inert. */
|
|
733
753
|
onRequestSubscribe?: () => Promise<WebPopupSubscribeResult>;
|
|
754
|
+
/** Removal asked by a subscribe answer only; a 'hide-popup' timer never calls it. */
|
|
755
|
+
onRequestRemove?: () => void;
|
|
756
|
+
/** Reports of what the renderer could not do; absent = silent. */
|
|
757
|
+
logger?: WebPopupLogger;
|
|
734
758
|
};
|