@pushwoosh/dumb-components 4.19.0 → 4.20.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/AppScreenPlaceholder/AppScreenPlaceholder.d.ts +7 -0
- package/AppScreenPlaceholder/AppScreenPlaceholder.js +29 -0
- package/AppScreenPlaceholder/constants.d.ts +20 -0
- package/AppScreenPlaceholder/constants.js +37 -0
- package/AppScreenPlaceholder/index.d.ts +2 -0
- package/AppScreenPlaceholder/index.js +1 -0
- package/AppScreenPlaceholder/types.d.ts +10 -0
- package/AppScreenPlaceholder/types.js +1 -0
- package/InlineBannerPreview/InlineBannerPreview.d.ts +7 -0
- package/InlineBannerPreview/InlineBannerPreview.js +43 -0
- package/InlineBannerPreview/constants.d.ts +5 -0
- package/InlineBannerPreview/constants.js +5 -0
- package/InlineBannerPreview/index.d.ts +2 -0
- package/InlineBannerPreview/index.js +1 -0
- package/InlineBannerPreview/styles.d.ts +2 -0
- package/InlineBannerPreview/styles.js +7 -0
- package/InlineBannerPreview/types.d.ts +7 -0
- package/InlineBannerPreview/types.js +1 -0
- package/RichmediaPreview/RichmediaPreview.js +18 -7
- package/RichmediaPreview/types.d.ts +2 -0
- package/SandboxedHtmlFrame/SandboxedHtmlFrame.d.ts +2 -1
- package/SandboxedHtmlFrame/SandboxedHtmlFrame.js +21 -2
- package/SandboxedHtmlFrame/constants.d.ts +7 -0
- package/SandboxedHtmlFrame/constants.js +64 -0
- package/SandboxedHtmlFrame/types.d.ts +6 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { AppScreenPlaceholderProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Stand-in for the content of an app screen around an inline banner slot: bars of text and blocks.
|
|
5
|
+
* Render one above the slot (`side="top"`) and one below it (`side="bottom"`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function AppScreenPlaceholder({ side, size }: AppScreenPlaceholderProps): ReactElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { BARS, SIZES } from './constants';
|
|
5
|
+
/**
|
|
6
|
+
* Stand-in for the content of an app screen around an inline banner slot: bars of text and blocks.
|
|
7
|
+
* Render one above the slot (`side="top"`) and one below it (`side="bottom"`).
|
|
8
|
+
*/
|
|
9
|
+
export function AppScreenPlaceholder({
|
|
10
|
+
side,
|
|
11
|
+
size
|
|
12
|
+
}) {
|
|
13
|
+
const metrics = SIZES[size];
|
|
14
|
+
return _jsx(Vertical, {
|
|
15
|
+
"$gap": metrics.gap,
|
|
16
|
+
"aria-hidden": true,
|
|
17
|
+
children: BARS[side].map(({
|
|
18
|
+
kind,
|
|
19
|
+
width
|
|
20
|
+
}, index) => _jsx(Vertical
|
|
21
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
22
|
+
, {
|
|
23
|
+
"$width": width,
|
|
24
|
+
"$height": metrics[kind],
|
|
25
|
+
"$borderRadius": kind === 'block' ? metrics.blockRadius : metrics.lineRadius,
|
|
26
|
+
"$bgColor": Color.SOFT_LIGHT
|
|
27
|
+
}, index))
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AppScreenPlaceholderBar } from './types';
|
|
2
|
+
export declare const SIZES: {
|
|
3
|
+
small: {
|
|
4
|
+
gap: number;
|
|
5
|
+
title: number;
|
|
6
|
+
line: number;
|
|
7
|
+
block: number;
|
|
8
|
+
lineRadius: number;
|
|
9
|
+
blockRadius: number;
|
|
10
|
+
};
|
|
11
|
+
large: {
|
|
12
|
+
gap: number;
|
|
13
|
+
title: number;
|
|
14
|
+
line: number;
|
|
15
|
+
block: number;
|
|
16
|
+
lineRadius: number;
|
|
17
|
+
blockRadius: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const BARS: Record<'top' | 'bottom', AppScreenPlaceholderBar[]>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const SIZES = {
|
|
2
|
+
small: {
|
|
3
|
+
gap: 8,
|
|
4
|
+
title: 14,
|
|
5
|
+
line: 8,
|
|
6
|
+
block: 70,
|
|
7
|
+
lineRadius: 4,
|
|
8
|
+
blockRadius: 8
|
|
9
|
+
},
|
|
10
|
+
large: {
|
|
11
|
+
gap: 12,
|
|
12
|
+
title: 22,
|
|
13
|
+
line: 13,
|
|
14
|
+
block: 104,
|
|
15
|
+
lineRadius: 6,
|
|
16
|
+
blockRadius: 12
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const BARS = {
|
|
20
|
+
top: [{
|
|
21
|
+
kind: 'title',
|
|
22
|
+
width: '50%'
|
|
23
|
+
}, {
|
|
24
|
+
kind: 'line',
|
|
25
|
+
width: '80%'
|
|
26
|
+
}],
|
|
27
|
+
bottom: [{
|
|
28
|
+
kind: 'line'
|
|
29
|
+
}, {
|
|
30
|
+
kind: 'line',
|
|
31
|
+
width: '70%'
|
|
32
|
+
}, {
|
|
33
|
+
kind: 'block'
|
|
34
|
+
}, {
|
|
35
|
+
kind: 'block'
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AppScreenPlaceholder } from './AppScreenPlaceholder';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AppScreenPlaceholderProps {
|
|
2
|
+
/** Which part of the screen to stand in for: the content above the slot or below it. */
|
|
3
|
+
side: 'top' | 'bottom';
|
|
4
|
+
/** `small` fits a phone preview, `large` a full-width canvas. */
|
|
5
|
+
size: 'small' | 'large';
|
|
6
|
+
}
|
|
7
|
+
export type AppScreenPlaceholderBar = {
|
|
8
|
+
kind: 'title' | 'line' | 'block';
|
|
9
|
+
width?: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { InlineBannerPreviewProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Inline banner in a slot of an app screen: the banner, as tall as its content, between two
|
|
5
|
+
* {@link AppScreenPlaceholder}. The HTML runs in an isolated {@link SandboxedHtmlFrame}.
|
|
6
|
+
*/
|
|
7
|
+
export declare function InlineBannerPreview({ html, title }: InlineBannerPreviewProps): ReactElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
4
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
5
|
+
import { AppScreenPlaceholder } from '../AppScreenPlaceholder';
|
|
6
|
+
import { SLOT_MIN_HEIGHT, SLOT_SCALE, SLOT_VIEWPORT_HEIGHT } from './constants';
|
|
7
|
+
import { SlotFrame } from './styles';
|
|
8
|
+
/**
|
|
9
|
+
* Inline banner in a slot of an app screen: the banner, as tall as its content, between two
|
|
10
|
+
* {@link AppScreenPlaceholder}. The HTML runs in an isolated {@link SandboxedHtmlFrame}.
|
|
11
|
+
*/
|
|
12
|
+
export function InlineBannerPreview({
|
|
13
|
+
html,
|
|
14
|
+
title
|
|
15
|
+
}) {
|
|
16
|
+
const [contentHeight, setContentHeight] = useState(0);
|
|
17
|
+
return _jsxs(Vertical, {
|
|
18
|
+
"$gap": 16,
|
|
19
|
+
children: [_jsx(AppScreenPlaceholder, {
|
|
20
|
+
side: "top",
|
|
21
|
+
size: "small"
|
|
22
|
+
}), _jsx(Vertical, {
|
|
23
|
+
"$border": `1px solid ${Color.FORM}`,
|
|
24
|
+
"$borderRadius": 12,
|
|
25
|
+
"$bgColor": Color.CLEAR,
|
|
26
|
+
"$overflow": "hidden",
|
|
27
|
+
children: _jsx(Vertical, {
|
|
28
|
+
"$position": "relative",
|
|
29
|
+
"$height": Math.min(contentHeight, SLOT_VIEWPORT_HEIGHT) * SLOT_SCALE,
|
|
30
|
+
"$minHeight": SLOT_MIN_HEIGHT,
|
|
31
|
+
children: _jsx(SlotFrame, {
|
|
32
|
+
mode: "isolated",
|
|
33
|
+
title: title,
|
|
34
|
+
html: html,
|
|
35
|
+
onContentHeight: setContentHeight
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
}), _jsx(AppScreenPlaceholder, {
|
|
39
|
+
side: "bottom",
|
|
40
|
+
size: "small"
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const SLOT_SCALE = 0.5;
|
|
2
|
+
/** Height of the frame viewport: like the SDK, the banner shows its top part up to it. */
|
|
3
|
+
export declare const SLOT_VIEWPORT_HEIGHT = 800;
|
|
4
|
+
/** A frame clipped to nothing is not rendered by the browser and never reports its height: the slot always shows a strip of it. */
|
|
5
|
+
export declare const SLOT_MIN_HEIGHT = 1;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const SLOT_SCALE = 0.5;
|
|
2
|
+
/** Height of the frame viewport: like the SDK, the banner shows its top part up to it. */
|
|
3
|
+
export const SLOT_VIEWPORT_HEIGHT = 800;
|
|
4
|
+
/** A frame clipped to nothing is not rendered by the browser and never reports its height: the slot always shows a strip of it. */
|
|
5
|
+
export const SLOT_MIN_HEIGHT = 1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InlineBannerPreview } from './InlineBannerPreview';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { SandboxedHtmlFrame } from '../SandboxedHtmlFrame';
|
|
2
|
+
export declare const SlotFrame: import("styled-components/dist/types").IStyledComponentBase<"web", import("..").SandboxedHtmlFrameProps & import("styled-components/dist/types").BaseObject> & string & Omit<typeof SandboxedHtmlFrame, keyof import("react").Component<any, {}, any>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { SandboxedHtmlFrame } from '../SandboxedHtmlFrame';
|
|
3
|
+
import { SLOT_SCALE, SLOT_VIEWPORT_HEIGHT } from './constants';
|
|
4
|
+
export const SlotFrame = styled(SandboxedHtmlFrame).withConfig({
|
|
5
|
+
displayName: "SlotFrame",
|
|
6
|
+
componentId: "sc-1of1618-0"
|
|
7
|
+
})(["position:absolute;top:0;left:0;width:", "%;height:", "px;border:0;transform:scale(", ");transform-origin:0 0;"], 100 / SLOT_SCALE, SLOT_VIEWPORT_HEIGHT, SLOT_SCALE);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { InlineBannerPreview } from '../InlineBannerPreview';
|
|
3
5
|
import { Spinner } from '../Spinner';
|
|
4
6
|
import { useRichmediaHtml } from './hooks';
|
|
5
7
|
import { RichMediaPreviewContainer, RichMediaPreviewIframe } from './styles';
|
|
@@ -23,7 +25,8 @@ export function RichmediaPreview(props) {
|
|
|
23
25
|
baseUrl = '',
|
|
24
26
|
width = 304,
|
|
25
27
|
height = 480,
|
|
26
|
-
isLoading = false
|
|
28
|
+
isLoading = false,
|
|
29
|
+
inline = false
|
|
27
30
|
} = props;
|
|
28
31
|
const richmediaHtml = useRichmediaHtml({
|
|
29
32
|
content,
|
|
@@ -32,19 +35,27 @@ export function RichmediaPreview(props) {
|
|
|
32
35
|
defaultLanguage,
|
|
33
36
|
baseUrl
|
|
34
37
|
});
|
|
35
|
-
|
|
38
|
+
const isInlineScreen = inline && !isLoading;
|
|
39
|
+
return _jsxs(RichMediaPreviewContainer, {
|
|
36
40
|
...LIGHT_ISLAND_PROPS,
|
|
37
41
|
"$width": width,
|
|
38
42
|
"$height": height,
|
|
39
43
|
"$isLoading": isLoading,
|
|
40
|
-
"$
|
|
41
|
-
|
|
44
|
+
"$alignItems": isInlineScreen ? 'start' : 'center',
|
|
45
|
+
"$justifyItems": isInlineScreen ? 'stretch' : 'center',
|
|
46
|
+
children: [isLoading && _jsx(Spinner, {
|
|
42
47
|
size: "medium",
|
|
43
48
|
color: Color.LOCKED
|
|
44
|
-
})
|
|
49
|
+
}), isInlineScreen && _jsx(Vertical, {
|
|
50
|
+
"$padding": "16px 8px 0",
|
|
51
|
+
children: _jsx(InlineBannerPreview, {
|
|
52
|
+
title: name,
|
|
53
|
+
html: richmediaHtml
|
|
54
|
+
})
|
|
55
|
+
}), !isLoading && !inline && _jsx(RichMediaPreviewIframe, {
|
|
45
56
|
mode: "isolated",
|
|
46
57
|
title: name,
|
|
47
58
|
html: richmediaHtml
|
|
48
|
-
})
|
|
59
|
+
})]
|
|
49
60
|
});
|
|
50
61
|
}
|
|
@@ -30,4 +30,6 @@ export type RichmediaPreviewProps = BuildRichmediaHtmlArgs & {
|
|
|
30
30
|
height?: string | number;
|
|
31
31
|
/** Show the loading spinner. */
|
|
32
32
|
isLoading?: boolean;
|
|
33
|
+
/** Draw the template as an inline banner in a slot of an app screen, not as a full-screen popup. */
|
|
34
|
+
inline?: boolean;
|
|
33
35
|
};
|
|
@@ -5,7 +5,8 @@ import type { SandboxedHtmlFrameProps } from './types';
|
|
|
5
5
|
* boundary so scripts and same-origin access can never be granted together:
|
|
6
6
|
*
|
|
7
7
|
* - `isolated` — `sandbox="allow-scripts"`; scripts run in an opaque origin and cannot
|
|
8
|
-
* touch the embedding page. The parent gets no DOM access
|
|
8
|
+
* touch the embedding page. The parent gets no DOM access; with `onContentHeight` the frame
|
|
9
|
+
* reports the height of its content instead.
|
|
9
10
|
* - `inspectable` — `sandbox="allow-same-origin"`; scripts are disabled, but the parent
|
|
10
11
|
* keeps read access to the frame document via `onReady`.
|
|
11
12
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { CONTENT_HEIGHT_MESSAGE, CONTENT_HEIGHT_SCRIPT } from './constants';
|
|
3
4
|
const SANDBOX = {
|
|
4
5
|
isolated: 'allow-scripts',
|
|
5
6
|
inspectable: 'allow-same-origin'
|
|
@@ -9,7 +10,8 @@ const SANDBOX = {
|
|
|
9
10
|
* boundary so scripts and same-origin access can never be granted together:
|
|
10
11
|
*
|
|
11
12
|
* - `isolated` — `sandbox="allow-scripts"`; scripts run in an opaque origin and cannot
|
|
12
|
-
* touch the embedding page. The parent gets no DOM access
|
|
13
|
+
* touch the embedding page. The parent gets no DOM access; with `onContentHeight` the frame
|
|
14
|
+
* reports the height of its content instead.
|
|
13
15
|
* - `inspectable` — `sandbox="allow-same-origin"`; scripts are disabled, but the parent
|
|
14
16
|
* keeps read access to the frame document via `onReady`.
|
|
15
17
|
*
|
|
@@ -25,6 +27,7 @@ export function SandboxedHtmlFrame(props) {
|
|
|
25
27
|
className
|
|
26
28
|
} = props;
|
|
27
29
|
const onReady = mode === 'inspectable' ? props.onReady : undefined;
|
|
30
|
+
const onContentHeight = mode === 'isolated' ? props.onContentHeight : undefined;
|
|
28
31
|
const $ref = useRef(null);
|
|
29
32
|
const [isReady, setIsReady] = useState(false);
|
|
30
33
|
const htmlDeps = [html];
|
|
@@ -46,11 +49,27 @@ export function SandboxedHtmlFrame(props) {
|
|
|
46
49
|
}
|
|
47
50
|
return onReady(frameDocument);
|
|
48
51
|
}, [isReady, onReady]);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!onContentHeight) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const handleMessage = event => {
|
|
57
|
+
if (event.source !== $ref.current?.contentWindow || event.data?.type !== CONTENT_HEIGHT_MESSAGE) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const height = Number(event.data.height);
|
|
61
|
+
if (Number.isFinite(height) && height >= 0) {
|
|
62
|
+
onContentHeight(height);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
window.addEventListener('message', handleMessage);
|
|
66
|
+
return () => window.removeEventListener('message', handleMessage);
|
|
67
|
+
}, [onContentHeight]);
|
|
49
68
|
return _jsx("iframe", {
|
|
50
69
|
ref: $ref,
|
|
51
70
|
className: className,
|
|
52
71
|
title: title,
|
|
53
|
-
srcDoc: html,
|
|
72
|
+
srcDoc: onContentHeight ? `${html}${CONTENT_HEIGHT_SCRIPT}` : html,
|
|
54
73
|
sandbox: SANDBOX[mode],
|
|
55
74
|
onLoad: handleLoad
|
|
56
75
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** `type` of the message an isolated frame posts to the embedding page with its content height. */
|
|
2
|
+
export declare const CONTENT_HEIGHT_MESSAGE = "pushwooshSandboxedFrameHeight";
|
|
3
|
+
/**
|
|
4
|
+
* Appended to an isolated frame document: posts the content height the way the mobile SDK measures
|
|
5
|
+
* an inline banner, so a preview is as tall as the banner on a device.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CONTENT_HEIGHT_SCRIPT = "<script>\n(function() {\n var root = document.documentElement, reported = -1;\n function bottomOf(rect, bottom) {\n return rect.width || rect.height ? Math.max(bottom, rect.bottom) : bottom;\n }\n function quirksBottom(body) {\n var range = document.createRange(), bottom = 0;\n for (var i = 0; i < body.childNodes.length; i++) {\n var node = body.childNodes[i];\n if (node.nodeType === 1) {\n bottom = bottomOf(node.getBoundingClientRect(), bottom);\n } else if (node.nodeType === 3) {\n range.selectNode(node);\n bottom = bottomOf(range.getBoundingClientRect(), bottom);\n }\n }\n if (!bottom) return 0;\n var style = getComputedStyle(body);\n return bottom + parseFloat(style.paddingBottom) + parseFloat(style.borderBottomWidth) +\n parseFloat(style.marginBottom);\n }\n function positionedBottom(body) {\n var bottom = 0, nodes = body.getElementsByTagName('*');\n for (var i = 0; i < nodes.length; i++) {\n var position = getComputedStyle(nodes[i]).position;\n if (position === 'absolute' || position === 'fixed') {\n bottom = bottomOf(nodes[i].getBoundingClientRect(), bottom);\n }\n }\n return bottom;\n }\n function report() {\n var body = document.body, height = 0;\n if (document.compatMode === 'CSS1Compat') {\n height = root.getBoundingClientRect().height;\n } else if (body) {\n height = quirksBottom(body);\n }\n if (body) height = Math.max(height, positionedBottom(body));\n height = Math.ceil(height + window.scrollY);\n if (height !== reported) {\n reported = height;\n parent.postMessage({ type: 'pushwooshSandboxedFrameHeight', height: height }, '*');\n }\n }\n var resizes = new ResizeObserver(report);\n function observe() {\n resizes.observe(root);\n var nodes = root.getElementsByTagName('*');\n for (var i = 0; i < nodes.length; i++) resizes.observe(nodes[i]);\n }\n new MutationObserver(function() { observe(); report(); }).observe(root, { childList: true, subtree: true });\n window.addEventListener('load', report);\n observe();\n report();\n})();\n</script>";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** `type` of the message an isolated frame posts to the embedding page with its content height. */
|
|
2
|
+
export const CONTENT_HEIGHT_MESSAGE = 'pushwooshSandboxedFrameHeight';
|
|
3
|
+
/**
|
|
4
|
+
* Appended to an isolated frame document: posts the content height the way the mobile SDK measures
|
|
5
|
+
* an inline banner, so a preview is as tall as the banner on a device.
|
|
6
|
+
*/
|
|
7
|
+
export const CONTENT_HEIGHT_SCRIPT = `<script>
|
|
8
|
+
(function() {
|
|
9
|
+
var root = document.documentElement, reported = -1;
|
|
10
|
+
function bottomOf(rect, bottom) {
|
|
11
|
+
return rect.width || rect.height ? Math.max(bottom, rect.bottom) : bottom;
|
|
12
|
+
}
|
|
13
|
+
function quirksBottom(body) {
|
|
14
|
+
var range = document.createRange(), bottom = 0;
|
|
15
|
+
for (var i = 0; i < body.childNodes.length; i++) {
|
|
16
|
+
var node = body.childNodes[i];
|
|
17
|
+
if (node.nodeType === 1) {
|
|
18
|
+
bottom = bottomOf(node.getBoundingClientRect(), bottom);
|
|
19
|
+
} else if (node.nodeType === 3) {
|
|
20
|
+
range.selectNode(node);
|
|
21
|
+
bottom = bottomOf(range.getBoundingClientRect(), bottom);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!bottom) return 0;
|
|
25
|
+
var style = getComputedStyle(body);
|
|
26
|
+
return bottom + parseFloat(style.paddingBottom) + parseFloat(style.borderBottomWidth) +
|
|
27
|
+
parseFloat(style.marginBottom);
|
|
28
|
+
}
|
|
29
|
+
function positionedBottom(body) {
|
|
30
|
+
var bottom = 0, nodes = body.getElementsByTagName('*');
|
|
31
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
32
|
+
var position = getComputedStyle(nodes[i]).position;
|
|
33
|
+
if (position === 'absolute' || position === 'fixed') {
|
|
34
|
+
bottom = bottomOf(nodes[i].getBoundingClientRect(), bottom);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return bottom;
|
|
38
|
+
}
|
|
39
|
+
function report() {
|
|
40
|
+
var body = document.body, height = 0;
|
|
41
|
+
if (document.compatMode === 'CSS1Compat') {
|
|
42
|
+
height = root.getBoundingClientRect().height;
|
|
43
|
+
} else if (body) {
|
|
44
|
+
height = quirksBottom(body);
|
|
45
|
+
}
|
|
46
|
+
if (body) height = Math.max(height, positionedBottom(body));
|
|
47
|
+
height = Math.ceil(height + window.scrollY);
|
|
48
|
+
if (height !== reported) {
|
|
49
|
+
reported = height;
|
|
50
|
+
parent.postMessage({ type: '${CONTENT_HEIGHT_MESSAGE}', height: height }, '*');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
var resizes = new ResizeObserver(report);
|
|
54
|
+
function observe() {
|
|
55
|
+
resizes.observe(root);
|
|
56
|
+
var nodes = root.getElementsByTagName('*');
|
|
57
|
+
for (var i = 0; i < nodes.length; i++) resizes.observe(nodes[i]);
|
|
58
|
+
}
|
|
59
|
+
new MutationObserver(function() { observe(); report(); }).observe(root, { childList: true, subtree: true });
|
|
60
|
+
window.addEventListener('load', report);
|
|
61
|
+
observe();
|
|
62
|
+
report();
|
|
63
|
+
})();
|
|
64
|
+
</script>`;
|
|
@@ -14,6 +14,11 @@ type SandboxedHtmlFrameBaseProps = {
|
|
|
14
14
|
export type IsolatedSandboxedHtmlFrameProps = SandboxedHtmlFrameBaseProps & {
|
|
15
15
|
mode: 'isolated';
|
|
16
16
|
onReady?: never;
|
|
17
|
+
/**
|
|
18
|
+
* Called with the height of the frame content in CSS pixels, on load and on every change.
|
|
19
|
+
* The value comes from the untrusted document: clamp it before using it for layout.
|
|
20
|
+
*/
|
|
21
|
+
onContentHeight?: (height: number) => void;
|
|
17
22
|
};
|
|
18
23
|
/**
|
|
19
24
|
* Inspectable rendering: scripts are disabled entirely, but the embedding page keeps
|
|
@@ -22,6 +27,7 @@ export type IsolatedSandboxedHtmlFrameProps = SandboxedHtmlFrameBaseProps & {
|
|
|
22
27
|
*/
|
|
23
28
|
export type InspectableSandboxedHtmlFrameProps = SandboxedHtmlFrameBaseProps & {
|
|
24
29
|
mode: 'inspectable';
|
|
30
|
+
onContentHeight?: never;
|
|
25
31
|
/**
|
|
26
32
|
* Called with the frame document once it has loaded, and again whenever the callback
|
|
27
33
|
* identity changes. May return a cleanup run before the next call and on unmount.
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AccessForbidden } from './AccessForbidden';
|
|
2
|
+
export { AppScreenPlaceholder, type AppScreenPlaceholderProps } from './AppScreenPlaceholder';
|
|
2
3
|
export { Badge, type BadgeColor } from './Badge';
|
|
3
4
|
export { Banner, type BannerType } from './Banner';
|
|
4
5
|
export { Button, GhostButton, RemoveButton, type RequiredButtonProps, } from './Button';
|
|
@@ -58,6 +59,7 @@ export { CodeEditor, json as jsonLanguage, html as htmlLanguage } from './CodeEd
|
|
|
58
59
|
export { EnhancedInput, SearchInput } from './EnhancedInput';
|
|
59
60
|
export { Chip, type ChipProps, type ChipVariant } from './Chip';
|
|
60
61
|
export { PillSelector, Pill, type PillProps, type PillSelectorProps, type PillSelectorRadioProps, type PillSelectorCheckboxProps, type PillSelectorItem, } from './PillSelector';
|
|
62
|
+
export { InlineBannerPreview, type InlineBannerPreviewProps } from './InlineBannerPreview';
|
|
61
63
|
export { RichmediaPreview, useRichmediaHtml } from './RichmediaPreview';
|
|
62
64
|
export { SandboxedHtmlFrame, type SandboxedHtmlFrameProps, type IsolatedSandboxedHtmlFrameProps, type InspectableSandboxedHtmlFrameProps, } from './SandboxedHtmlFrame';
|
|
63
65
|
export { NativeRichMediaPreview, parseNativeRichMediaConfig, parseLocalizationParams, NATIVE_RICH_MEDIA_DISPLAY_TYPES, EDITABLE_NATIVE_RICH_MEDIA_DISPLAY_TYPES, } from './NativeRichMediaPreview';
|
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AccessForbidden } from './AccessForbidden';
|
|
2
|
+
export { AppScreenPlaceholder } from './AppScreenPlaceholder';
|
|
2
3
|
export { Badge } from './Badge';
|
|
3
4
|
export { Banner } from './Banner';
|
|
4
5
|
export { Button, GhostButton, RemoveButton } from './Button';
|
|
@@ -52,6 +53,7 @@ export { CodeEditor, json as jsonLanguage, html as htmlLanguage } from './CodeEd
|
|
|
52
53
|
export { EnhancedInput, SearchInput } from './EnhancedInput';
|
|
53
54
|
export { Chip } from './Chip';
|
|
54
55
|
export { PillSelector, Pill } from './PillSelector';
|
|
56
|
+
export { InlineBannerPreview } from './InlineBannerPreview';
|
|
55
57
|
export { RichmediaPreview, useRichmediaHtml } from './RichmediaPreview';
|
|
56
58
|
export { SandboxedHtmlFrame } from './SandboxedHtmlFrame';
|
|
57
59
|
export { NativeRichMediaPreview, parseNativeRichMediaConfig, parseLocalizationParams, NATIVE_RICH_MEDIA_DISPLAY_TYPES, EDITABLE_NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './NativeRichMediaPreview';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/dumb-components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.20.0",
|
|
4
4
|
"description": "React components to build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"react": "19.3.0",
|
|
36
36
|
"react-dom": "19.3.0",
|
|
37
37
|
"styled-components": "6.6.0",
|
|
38
|
-
"vitest": "^
|
|
38
|
+
"vitest": "^5.1.1"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@codemirror/lang-html": "^6.4.12",
|