@pushwoosh/websdk-common 6.22.0 → 6.22.1
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/package.json +1 -1
- package/web-popups/form.d.ts +6 -2
- package/web-popups/form.js +11 -1
- package/web-popups/index.d.ts +1 -0
- package/web-popups/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/websdk-common",
|
|
3
|
-
"version": "6.22.
|
|
3
|
+
"version": "6.22.1",
|
|
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",
|
package/web-popups/form.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type WebPopupConsentSlot, type WebPopupEmailInputSlot, type WebPopupFormValues, type WebPopupResolvedPage, type WebPopupTagInputSlot } from './types';
|
|
1
|
+
import { type WebPopupConsentSlot, type WebPopupEmailInputSlot, type WebPopupFormValues, type WebPopupParams, type WebPopupResolvedPage, type WebPopupTagInputSlot } from './types';
|
|
2
|
+
type WebPopupFormFieldSlot = WebPopupEmailInputSlot | WebPopupTagInputSlot | WebPopupConsentSlot;
|
|
2
3
|
/** A Form field with the page it sits on; `id` is unique across the popup. */
|
|
3
4
|
export type WebPopupFormFieldEntry = {
|
|
4
5
|
id: string;
|
|
5
6
|
pageKey: string;
|
|
6
|
-
slot:
|
|
7
|
+
slot: WebPopupFormFieldSlot;
|
|
7
8
|
};
|
|
8
9
|
/** What the visitor has entered so far, by field id. */
|
|
9
10
|
export type WebPopupFormInput = {
|
|
@@ -14,7 +15,10 @@ export type WebPopupFormInput = {
|
|
|
14
15
|
export declare function webPopupFormFieldId(pageKey: string, slotKey: string): string;
|
|
15
16
|
/** Every Form field of the popup, in page and stack order. */
|
|
16
17
|
export declare function collectWebPopupFormFields(pages: WebPopupResolvedPage[]): WebPopupFormFieldEntry[];
|
|
18
|
+
/** Does any page carry a FORM slot (`email-input`, `tag-input`, `consent`, `submit`)? */
|
|
19
|
+
export declare function webPopupHasForm(params: WebPopupParams): boolean;
|
|
17
20
|
/** The block text of every field that blocks a submit, by field id; empty = the Form can be sent. */
|
|
18
21
|
export declare function validateWebPopupForm(fields: WebPopupFormFieldEntry[], input: WebPopupFormInput): Record<string, string>;
|
|
19
22
|
/** The values a valid Form submits (contracts §10). */
|
|
20
23
|
export declare function webPopupFormValues(fields: WebPopupFormFieldEntry[], input: WebPopupFormInput): WebPopupFormValues;
|
|
24
|
+
export {};
|
package/web-popups/form.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { WEB_POPUP_EMAIL_PATTERN } from './constants';
|
|
2
|
+
import { resolveWebPopupPages } from './helpers';
|
|
3
|
+
const FORM_FIELD_SLOT_TYPES = new Set(['email-input', 'tag-input', 'consent']);
|
|
4
|
+
const FORM_SLOT_TYPES = new Set([...FORM_FIELD_SLOT_TYPES, 'submit']);
|
|
5
|
+
function isFormFieldSlot(slot) {
|
|
6
|
+
return FORM_FIELD_SLOT_TYPES.has(slot.type);
|
|
7
|
+
}
|
|
2
8
|
/** A field id: slot keys are unique within a page, not across pages. */
|
|
3
9
|
export function webPopupFormFieldId(pageKey, slotKey) {
|
|
4
10
|
return `${pageKey}/${slotKey}`;
|
|
@@ -9,7 +15,7 @@ export function collectWebPopupFormFields(pages) {
|
|
|
9
15
|
for (const page of pages) {
|
|
10
16
|
for (const zone of page.contents) {
|
|
11
17
|
for (const slot of zone.slots) {
|
|
12
|
-
if (slot
|
|
18
|
+
if (!isFormFieldSlot(slot)) continue;
|
|
13
19
|
out.push({
|
|
14
20
|
id: webPopupFormFieldId(page.key, slot.key),
|
|
15
21
|
pageKey: page.key,
|
|
@@ -20,6 +26,10 @@ export function collectWebPopupFormFields(pages) {
|
|
|
20
26
|
}
|
|
21
27
|
return out;
|
|
22
28
|
}
|
|
29
|
+
/** Does any page carry a FORM slot (`email-input`, `tag-input`, `consent`, `submit`)? */
|
|
30
|
+
export function webPopupHasForm(params) {
|
|
31
|
+
return resolveWebPopupPages(params).some(page => page.contents.some(zone => zone.slots.some(slot => FORM_SLOT_TYPES.has(slot.type))));
|
|
32
|
+
}
|
|
23
33
|
function fieldError(field, input) {
|
|
24
34
|
const {
|
|
25
35
|
slot
|
package/web-popups/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { WebPopupReader, WebPopupBox, WebPopupSlotView } from './WebPopupReader'
|
|
|
2
2
|
export { WebPopupInline } from './WebPopupInline';
|
|
3
3
|
export { WEB_POPUP_TEMPLATES, findWebPopupTemplate } from './templates';
|
|
4
4
|
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
|
+
export { webPopupHasForm } from './form';
|
|
5
6
|
export { webPopupTimerLabels, webPopupTimerRemaining, webPopupTimeZoneSupported, webPopupWallClockMs, type WebPopupTimerLabels, } from './timer';
|
|
6
7
|
export { normalizeWebPopupLayout, substituteWebPopupLayoutValues, WEB_POPUP_VALUE_KEY_PATTERN, webPopupBackgroundImageStyle, webPopupContainerStyle, webPopupCssLength, webPopupPaddingValue, webPopupTracksValue, } from './layout';
|
|
7
8
|
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';
|
package/web-popups/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { WebPopupReader, WebPopupBox, WebPopupSlotView } from './WebPopupReader'
|
|
|
2
2
|
export { WebPopupInline } from './WebPopupInline';
|
|
3
3
|
export { WEB_POPUP_TEMPLATES, findWebPopupTemplate } from './templates';
|
|
4
4
|
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
|
+
export { webPopupHasForm } from './form';
|
|
5
6
|
export { webPopupTimerLabels, webPopupTimerRemaining, webPopupTimeZoneSupported, webPopupWallClockMs } from './timer';
|
|
6
7
|
export { normalizeWebPopupLayout, substituteWebPopupLayoutValues, WEB_POPUP_VALUE_KEY_PATTERN, webPopupBackgroundImageStyle, webPopupContainerStyle, webPopupCssLength, webPopupPaddingValue, webPopupTracksValue } from './layout';
|
|
7
8
|
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, 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';
|