@pushwoosh/dumb-components 1.1.162 → 1.1.164

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.
Files changed (94) hide show
  1. package/Modal/components/Modal/styles.js +3 -3
  2. package/NativeRichMediaPreview/NativeRichMediaPreview.d.ts +23 -4
  3. package/NativeRichMediaPreview/NativeRichMediaPreview.js +125 -63
  4. package/NativeRichMediaPreview/components/NativeRichMediaButtonList/NativeRichMediaButtonList.d.ts +3 -0
  5. package/NativeRichMediaPreview/components/NativeRichMediaButtonList/NativeRichMediaButtonList.js +24 -0
  6. package/NativeRichMediaPreview/components/NativeRichMediaButtonList/index.d.ts +1 -0
  7. package/NativeRichMediaPreview/components/NativeRichMediaButtonList/index.js +1 -0
  8. package/NativeRichMediaPreview/components/NativeRichMediaButtonList/types.d.ts +6 -0
  9. package/NativeRichMediaPreview/components/NativeRichMediaCloseChip/styles.js +4 -5
  10. package/NativeRichMediaPreview/components/NativeRichMediaRewardPanel/NativeRichMediaRewardPanel.js +26 -26
  11. package/NativeRichMediaPreview/components/NativeRichMediaRewardPanel/styles.d.ts +29 -2
  12. package/NativeRichMediaPreview/components/NativeRichMediaRewardPanel/styles.js +19 -4
  13. package/NativeRichMediaPreview/components/NativeRichMediaText/index.d.ts +1 -0
  14. package/NativeRichMediaPreview/components/NativeRichMediaText/index.js +1 -0
  15. package/NativeRichMediaPreview/components/NativeRichMediaText/styles.d.ts +7 -0
  16. package/NativeRichMediaPreview/components/NativeRichMediaText/styles.js +19 -0
  17. package/NativeRichMediaPreview/components/NativeRichMediaTitle/index.d.ts +1 -0
  18. package/NativeRichMediaPreview/components/NativeRichMediaTitle/index.js +1 -0
  19. package/NativeRichMediaPreview/components/NativeRichMediaTitle/styles.d.ts +12 -0
  20. package/NativeRichMediaPreview/components/NativeRichMediaTitle/styles.js +22 -0
  21. package/NativeRichMediaPreview/helpers.d.ts +22 -6
  22. package/NativeRichMediaPreview/helpers.js +45 -6
  23. package/NativeRichMediaPreview/icons/MutedIcon.svg +1 -1
  24. package/NativeRichMediaPreview/icons/SoundIcon.svg +1 -1
  25. package/NativeRichMediaPreview/index.d.ts +1 -1
  26. package/NativeRichMediaPreview/parseNativeRichMediaConfig.d.ts +3 -1
  27. package/NativeRichMediaPreview/parseNativeRichMediaConfig.js +74 -18
  28. package/NativeRichMediaPreview/styles.d.ts +7 -7
  29. package/NativeRichMediaPreview/styles.js +25 -23
  30. package/NativeRichMediaPreview/types.d.ts +180 -176
  31. package/NativeRichMediaPreview/views/NativeRichMediaBannerView/NativeRichMediaBannerView.js +31 -36
  32. package/NativeRichMediaPreview/views/NativeRichMediaBannerView/styles.d.ts +3 -4
  33. package/NativeRichMediaPreview/views/NativeRichMediaBannerView/styles.js +8 -11
  34. package/NativeRichMediaPreview/views/NativeRichMediaCarouselView/NativeRichMediaCarouselView.js +31 -30
  35. package/NativeRichMediaPreview/views/NativeRichMediaCarouselView/styles.d.ts +0 -2
  36. package/NativeRichMediaPreview/views/NativeRichMediaCarouselView/styles.js +4 -12
  37. package/NativeRichMediaPreview/views/NativeRichMediaCarouselView/types.d.ts +0 -1
  38. package/NativeRichMediaPreview/views/NativeRichMediaFullscreenView/NativeRichMediaFullscreenView.js +26 -35
  39. package/NativeRichMediaPreview/views/NativeRichMediaInvalidView/NativeRichMediaInvalidView.js +5 -3
  40. package/NativeRichMediaPreview/views/NativeRichMediaInvalidView/styles.d.ts +9 -0
  41. package/NativeRichMediaPreview/views/NativeRichMediaInvalidView/styles.js +10 -1
  42. package/NativeRichMediaPreview/views/NativeRichMediaModalView/NativeRichMediaModalView.js +33 -38
  43. package/NativeRichMediaPreview/views/NativeRichMediaPipView/NativeRichMediaPipView.js +30 -35
  44. package/NativeRichMediaPreview/views/NativeRichMediaPipView/styles.d.ts +7 -6
  45. package/NativeRichMediaPreview/views/NativeRichMediaPipView/styles.js +15 -13
  46. package/NativeRichMediaPreview/views/NativeRichMediaScratchcardView/NativeRichMediaScratchcardView.js +50 -52
  47. package/NativeRichMediaPreview/views/NativeRichMediaScratchcardView/styles.d.ts +18 -5
  48. package/NativeRichMediaPreview/views/NativeRichMediaScratchcardView/styles.js +15 -8
  49. package/NativeRichMediaPreview/views/NativeRichMediaSheetView/NativeRichMediaSheetView.js +31 -37
  50. package/NativeRichMediaPreview/views/NativeRichMediaSheetView/styles.js +1 -1
  51. package/NativeRichMediaPreview/views/NativeRichMediaSpinwheelView/NativeRichMediaSpinwheelView.js +45 -47
  52. package/NativeRichMediaPreview/views/NativeRichMediaSpinwheelView/styles.d.ts +11 -3
  53. package/NativeRichMediaPreview/views/NativeRichMediaSpinwheelView/styles.js +16 -10
  54. package/NativeRichMediaPreview/views/NativeRichMediaStoriesView/NativeRichMediaStoriesView.js +24 -33
  55. package/NativeRichMediaPreview/views/NativeRichMediaStoriesView/styles.d.ts +1 -7
  56. package/NativeRichMediaPreview/views/NativeRichMediaStoriesView/styles.js +7 -21
  57. package/NativeRichMediaPreview/views/NativeRichMediaStoriesView/types.d.ts +0 -1
  58. package/NativeRichMediaPreview/views/NativeRichMediaVideoView/NativeRichMediaVideoView.js +22 -42
  59. package/NativeRichMediaPreview/views/shared/styles.d.ts +3 -3
  60. package/NativeRichMediaPreview/views/shared/styles.js +6 -5
  61. package/index.d.ts +1 -1
  62. package/package.json +1 -1
  63. package/NativeRichMediaPreview/components/NativeRichMediaCardButtons/NativeRichMediaCardButtons.d.ts +0 -3
  64. package/NativeRichMediaPreview/components/NativeRichMediaCardButtons/NativeRichMediaCardButtons.js +0 -29
  65. package/NativeRichMediaPreview/components/NativeRichMediaCardButtons/index.d.ts +0 -1
  66. package/NativeRichMediaPreview/components/NativeRichMediaCardButtons/index.js +0 -1
  67. package/NativeRichMediaPreview/components/NativeRichMediaCardButtons/types.d.ts +0 -5
  68. package/NativeRichMediaPreview/components/NativeRichMediaOverlayButtons/NativeRichMediaOverlayButtons.d.ts +0 -3
  69. package/NativeRichMediaPreview/components/NativeRichMediaOverlayButtons/NativeRichMediaOverlayButtons.js +0 -40
  70. package/NativeRichMediaPreview/components/NativeRichMediaOverlayButtons/index.d.ts +0 -1
  71. package/NativeRichMediaPreview/components/NativeRichMediaOverlayButtons/index.js +0 -1
  72. package/NativeRichMediaPreview/components/NativeRichMediaOverlayButtons/types.d.ts +0 -4
  73. package/NativeRichMediaPreview/components/NativeRichMediaOverlayButtons/types.js +0 -1
  74. package/NativeRichMediaPreview/components/NativeRichMediaPreviewCanvas/NativeRichMediaPreviewCanvas.d.ts +0 -3
  75. package/NativeRichMediaPreview/components/NativeRichMediaPreviewCanvas/NativeRichMediaPreviewCanvas.js +0 -10
  76. package/NativeRichMediaPreview/components/NativeRichMediaPreviewCanvas/index.d.ts +0 -1
  77. package/NativeRichMediaPreview/components/NativeRichMediaPreviewCanvas/index.js +0 -1
  78. package/NativeRichMediaPreview/components/NativeRichMediaPreviewCanvas/styles.d.ts +0 -1
  79. package/NativeRichMediaPreview/components/NativeRichMediaPreviewCanvas/styles.js +0 -6
  80. package/NativeRichMediaPreview/components/NativeRichMediaPreviewCanvas/types.d.ts +0 -4
  81. package/NativeRichMediaPreview/components/NativeRichMediaPreviewCanvas/types.js +0 -1
  82. package/NativeRichMediaPreview/components/NativeRichMediaPtLabel/NativeRichMediaPtLabel.d.ts +0 -3
  83. package/NativeRichMediaPreview/components/NativeRichMediaPtLabel/NativeRichMediaPtLabel.js +0 -27
  84. package/NativeRichMediaPreview/components/NativeRichMediaPtLabel/index.d.ts +0 -1
  85. package/NativeRichMediaPreview/components/NativeRichMediaPtLabel/index.js +0 -1
  86. package/NativeRichMediaPreview/components/NativeRichMediaPtLabel/styles.d.ts +0 -10
  87. package/NativeRichMediaPreview/components/NativeRichMediaPtLabel/styles.js +0 -30
  88. package/NativeRichMediaPreview/components/NativeRichMediaPtLabel/types.d.ts +0 -12
  89. package/NativeRichMediaPreview/components/NativeRichMediaPtLabel/types.js +0 -1
  90. package/NativeRichMediaPreview/views/NativeRichMediaFullscreenView/styles.d.ts +0 -1
  91. package/NativeRichMediaPreview/views/NativeRichMediaFullscreenView/styles.js +0 -1
  92. package/NativeRichMediaPreview/views/NativeRichMediaVideoView/styles.d.ts +0 -1
  93. package/NativeRichMediaPreview/views/NativeRichMediaVideoView/styles.js +0 -1
  94. /package/NativeRichMediaPreview/components/{NativeRichMediaCardButtons → NativeRichMediaButtonList}/types.js +0 -0
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { CSSTransition } from 'react-transition-group';
3
3
  import styled, { createGlobalStyle } from 'styled-components';
4
- import { ShapeRadius } from '@pushwoosh/kit-constants';
4
+ import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
5
5
  const animationTimeout = 300;
6
6
  export const LockBody = createGlobalStyle(["body{overflow:hidden;position:relative;height:100%;}"]);
7
7
  export const ModalBox = styled.div.attrs(({
@@ -44,9 +44,9 @@ export const ModalBoxTrans = styled(ModalBoxBase).withConfig({
44
44
  export const ModalContainer = styled.div.withConfig({
45
45
  displayName: "ModalContainer",
46
46
  componentId: "sc-lejcgu-3"
47
- })(["display:inline-flex;flex-direction:column;align-items:stretch;justify-content:flex-start;position:relative;width:", ";height:calc(100vh - 2 * 56px);vertical-align:middle;z-index:10;& > *{&:first-child{border-top-left-radius:", ";border-top-right-radius:", ";}&:last-child{border-bottom-left-radius:", ";border-bottom-right-radius:", ";}}"], ({
47
+ })(["display:inline-flex;flex-direction:column;align-items:stretch;justify-content:flex-start;position:relative;width:", ";height:calc(100vh - 2 * 56px);vertical-align:middle;z-index:10;background:", ";& > *{&:first-child{border-top-left-radius:", ";border-top-right-radius:", ";}&:last-child{border-bottom-left-radius:", ";border-bottom-right-radius:", ";}}"], ({
48
48
  $width
49
- }) => $width, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG);
49
+ }) => $width, Color.CLEAR, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG);
50
50
  ModalBox.displayName = 'ModalBox';
51
51
  ModalInner.displayName = 'ModalInner';
52
52
  ModalContainer.displayName = 'ModalContainer';
@@ -1,11 +1,30 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import type { NativeRichMediaPreviewProps } from './types';
3
3
  /**
4
- * Phone-frame preview of a native rich media (modal, banner, stories,
5
- * spinwheel, …) rendered from its JSON config; shows an invalid-config
6
- * placeholder when the config cannot be parsed.
4
+ * Preview of a native rich media (modal, banner, stories, spinwheel, …)
5
+ * rendered from its JSON config; lays out with plain CSS in the real pixels
6
+ * of the given width/height box — there is no scaling and no fidelity to any
7
+ * phone's pt-metrics, since this is a preview and devices vary. Content flows
8
+ * inside a scrollable layer above a static backdrop (the dim overlay or, for
9
+ * `fullscreen`/`video`/`stories`, the full-bleed background image or poster):
10
+ * content taller than the box scrolls, shorter content aligns per display
11
+ * type while the backdrop stays put. Shows an invalid-config placeholder
12
+ * when the config cannot be parsed or misses required contract fields.
7
13
  *
8
14
  * @example
9
- * <NativeRichMediaPreview content={'{"displayType":"modal","modal":{"title":{"text":"Hi"}}}'} />
15
+ * <NativeRichMediaPreview
16
+ * width={304}
17
+ * height={659}
18
+ * content={{
19
+ * displayType: 'modal',
20
+ * modal: {
21
+ * showClose: true,
22
+ * dimBackground: true,
23
+ * background: '#FFFFFFFF',
24
+ * title: { text: 'Hi', color: '#4B5057FF' },
25
+ * buttons: [],
26
+ * },
27
+ * }}
28
+ * />
10
29
  */
11
30
  export declare function NativeRichMediaPreview(props: NativeRichMediaPreviewProps): ReactElement;
@@ -1,15 +1,16 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useRef, useState } from 'react';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
3
  import { Color } from '@pushwoosh/kit-constants';
4
4
  import { Spinner } from '../Spinner';
5
+ import { NativeRichMediaCloseChip } from './components/NativeRichMediaCloseChip';
6
+ import { NativeRichMediaCoverImg } from './components/NativeRichMediaCoverImg';
5
7
  import { NativeRichMediaDim } from './components/NativeRichMediaDim';
6
- import { NativeRichMediaPreviewCanvas } from './components/NativeRichMediaPreviewCanvas';
7
- import { PT } from './helpers';
8
+ import { NativeRichMediaMuteChip } from './components/NativeRichMediaMuteChip';
9
+ import { EDGE_INSET, clampIndex } from './helpers';
8
10
  import { parseNativeRichMediaConfig } from './parseNativeRichMediaConfig';
9
- import { CanvasWrapper, ScaledCanvasHost } from './styles';
11
+ import { BackdropLayer, ContentFlow, PreviewHost, ScrollLayer, SpinnerLayer } from './styles';
10
12
  import { NativeRichMediaBannerView, NativeRichMediaCarouselView, NativeRichMediaFullscreenView, NativeRichMediaInvalidView, NativeRichMediaModalView, NativeRichMediaPipView, NativeRichMediaScratchcardView, NativeRichMediaSheetView, NativeRichMediaSpinwheelView, NativeRichMediaStoriesView, NativeRichMediaVideoView } from './views';
11
- const DEFAULT_WIDTH = 304;
12
- const DEFAULT_HEIGHT = 659;
13
+ import { GradientOverlay } from './views/shared/styles';
13
14
  function dimsScreen(config) {
14
15
  if (!config) {
15
16
  return false;
@@ -27,7 +28,85 @@ function dimsScreen(config) {
27
28
  return false;
28
29
  }
29
30
  }
30
- function renderConfig(config, activeIndex, onNavigate) {
31
+ function justifyFor(config) {
32
+ switch (config.displayType) {
33
+ case 'modal':
34
+ case 'carousel':
35
+ case 'scratchcard':
36
+ case 'spinwheel':
37
+ return 'center';
38
+ case 'stories':
39
+ return 'space-between';
40
+ case 'fullscreen':
41
+ case 'video':
42
+ case 'sheet':
43
+ return 'flex-end';
44
+ case 'banner':
45
+ return config.banner.position === 'top' ? 'flex-start' : 'flex-end';
46
+ case 'pip':
47
+ return config.pip.position.includes('top') ? 'flex-start' : 'flex-end';
48
+ default:
49
+ return 'center';
50
+ }
51
+ }
52
+ function renderCoverBackdrop(url, backgroundColor, overlayTopOffset) {
53
+ return _jsxs(_Fragment, {
54
+ children: [_jsx(NativeRichMediaCoverImg, {
55
+ url: url,
56
+ position: "absolute",
57
+ inset: true,
58
+ backgroundColor: backgroundColor
59
+ }), _jsx(GradientOverlay, {
60
+ "$topOffset": overlayTopOffset
61
+ })]
62
+ });
63
+ }
64
+ function renderBackdrop(config, activeIndex) {
65
+ switch (config.displayType) {
66
+ case 'fullscreen':
67
+ return renderCoverBackdrop(config.fullscreen.cover.image, config.fullscreen.cover.background);
68
+ case 'video':
69
+ return renderCoverBackdrop(config.video.poster, '#000');
70
+ case 'stories':
71
+ {
72
+ var _items$clampIndex;
73
+ const items = config.stories.items;
74
+ return renderCoverBackdrop((_items$clampIndex = items[clampIndex(activeIndex, items.length)]) === null || _items$clampIndex === void 0 ? void 0 : _items$clampIndex.image, '#000', '55%');
75
+ }
76
+ default:
77
+ return null;
78
+ }
79
+ }
80
+ const STORIES_PROGRESS_BAR_HEIGHT = 3;
81
+ const STORIES_CLOSE_CHIP_GAP = 10;
82
+ function renderChrome(config) {
83
+ switch (config.displayType) {
84
+ case 'fullscreen':
85
+ return config.fullscreen.showClose ? _jsx(NativeRichMediaCloseChip, {
86
+ top: EDGE_INSET,
87
+ right: 16
88
+ }) : null;
89
+ case 'video':
90
+ return _jsxs(_Fragment, {
91
+ children: [_jsx(NativeRichMediaMuteChip, {
92
+ muted: config.video.muted,
93
+ top: EDGE_INSET,
94
+ left: 16
95
+ }), config.video.showClose && _jsx(NativeRichMediaCloseChip, {
96
+ top: EDGE_INSET,
97
+ right: 16
98
+ })]
99
+ });
100
+ case 'stories':
101
+ return config.stories.showClose ? _jsx(NativeRichMediaCloseChip, {
102
+ top: EDGE_INSET + STORIES_PROGRESS_BAR_HEIGHT + STORIES_CLOSE_CHIP_GAP,
103
+ right: 16
104
+ }) : null;
105
+ default:
106
+ return null;
107
+ }
108
+ }
109
+ function renderConfig(config, activeIndex) {
31
110
  switch (config.displayType) {
32
111
  case 'modal':
33
112
  return _jsx(NativeRichMediaModalView, {
@@ -40,14 +119,12 @@ function renderConfig(config, activeIndex, onNavigate) {
40
119
  case 'carousel':
41
120
  return _jsx(NativeRichMediaCarouselView, {
42
121
  block: config.carousel,
43
- activeIndex: activeIndex,
44
- onNavigate: onNavigate
122
+ activeIndex: activeIndex
45
123
  });
46
124
  case 'stories':
47
125
  return _jsx(NativeRichMediaStoriesView, {
48
126
  block: config.stories,
49
- activeIndex: activeIndex,
50
- onNavigate: onNavigate
127
+ activeIndex: activeIndex
51
128
  });
52
129
  case 'banner':
53
130
  return _jsx(NativeRichMediaBannerView, {
@@ -78,74 +155,59 @@ function renderConfig(config, activeIndex, onNavigate) {
78
155
  }
79
156
  }
80
157
  /**
81
- * Phone-frame preview of a native rich media (modal, banner, stories,
82
- * spinwheel, …) rendered from its JSON config; shows an invalid-config
83
- * placeholder when the config cannot be parsed.
158
+ * Preview of a native rich media (modal, banner, stories, spinwheel, …)
159
+ * rendered from its JSON config; lays out with plain CSS in the real pixels
160
+ * of the given width/height box — there is no scaling and no fidelity to any
161
+ * phone's pt-metrics, since this is a preview and devices vary. Content flows
162
+ * inside a scrollable layer above a static backdrop (the dim overlay or, for
163
+ * `fullscreen`/`video`/`stories`, the full-bleed background image or poster):
164
+ * content taller than the box scrolls, shorter content aligns per display
165
+ * type while the backdrop stays put. Shows an invalid-config placeholder
166
+ * when the config cannot be parsed or misses required contract fields.
84
167
  *
85
168
  * @example
86
- * <NativeRichMediaPreview content={'{"displayType":"modal","modal":{"title":{"text":"Hi"}}}'} />
169
+ * <NativeRichMediaPreview
170
+ * width={304}
171
+ * height={659}
172
+ * content={{
173
+ * displayType: 'modal',
174
+ * modal: {
175
+ * showClose: true,
176
+ * dimBackground: true,
177
+ * background: '#FFFFFFFF',
178
+ * title: { text: 'Hi', color: '#4B5057FF' },
179
+ * buttons: [],
180
+ * },
181
+ * }}
182
+ * />
87
183
  */
88
184
  export function NativeRichMediaPreview(props) {
89
185
  const {
90
186
  content,
91
- name,
92
- width = DEFAULT_WIDTH,
93
- height = DEFAULT_HEIGHT,
187
+ width,
188
+ height,
189
+ activeIndex = 0,
94
190
  isLoading = false,
95
191
  withBackground = true
96
192
  } = props;
97
- const [activeIndex, setActiveIndex] = useState(0);
98
193
  const config = useMemo(() => parseNativeRichMediaConfig(content), [content]);
99
- const hostRef = useRef(null);
100
- const isSizeString = typeof width !== 'number' || typeof height !== 'number';
101
- const [measuredSize, setMeasuredSize] = useState(null);
102
- useEffect(() => {
103
- const host = hostRef.current;
104
- if (!isSizeString || !host) {
105
- return undefined;
106
- }
107
- const observer = new ResizeObserver(([entry]) => {
108
- if (entry) {
109
- const {
110
- width: measuredWidth,
111
- height: measuredHeight
112
- } = entry.contentRect;
113
- setMeasuredSize({
114
- width: measuredWidth,
115
- height: measuredHeight
116
- });
117
- }
118
- });
119
- observer.observe(host);
120
- return () => observer.disconnect();
121
- }, [isSizeString]);
122
- const scale = useMemo(() => {
123
- const effectiveWidth = typeof width === 'number' ? width : (measuredSize === null || measuredSize === void 0 ? void 0 : measuredSize.width) ?? DEFAULT_WIDTH;
124
- const effectiveHeight = typeof height === 'number' ? height : (measuredSize === null || measuredSize === void 0 ? void 0 : measuredSize.height) ?? DEFAULT_HEIGHT;
125
- return Math.min(effectiveWidth / PT.W, effectiveHeight / PT.H);
126
- }, [width, height, measuredSize]);
127
194
  const shouldDim = !isLoading && dimsScreen(config);
128
- return _jsxs(ScaledCanvasHost, {
129
- ref: hostRef,
195
+ return _jsxs(PreviewHost, {
130
196
  width: width,
131
197
  height: height,
132
198
  "$withBackground": withBackground,
133
- title: name,
134
- children: [shouldDim && _jsx(NativeRichMediaDim, {}), isLoading && _jsx(CanvasWrapper, {
135
- "$canvasWidth": PT.W,
136
- "$canvasHeight": PT.H,
137
- "$scale": scale,
199
+ children: [_jsxs(BackdropLayer, {
200
+ children: [shouldDim && _jsx(NativeRichMediaDim, {}), !isLoading && config && renderBackdrop(config, activeIndex)]
201
+ }), isLoading && _jsx(SpinnerLayer, {
138
202
  children: _jsx(Spinner, {
139
203
  size: "medium",
140
204
  color: Color.LOCKED
141
205
  })
142
- }), !isLoading && !config && _jsx(NativeRichMediaInvalidView, {}), !isLoading && config && _jsx(CanvasWrapper, {
143
- "$canvasWidth": PT.W,
144
- "$canvasHeight": PT.H,
145
- "$scale": scale,
146
- children: _jsx(NativeRichMediaPreviewCanvas, {
147
- children: renderConfig(config, activeIndex, setActiveIndex)
148
- }, config.displayType)
149
- })]
206
+ }), !isLoading && !config && _jsx(NativeRichMediaInvalidView, {}), !isLoading && config && _jsx(ScrollLayer, {
207
+ children: _jsx(ContentFlow, {
208
+ "$justify": justifyFor(config),
209
+ children: renderConfig(config, activeIndex)
210
+ })
211
+ }, config.displayType), !isLoading && config && renderChrome(config)]
150
212
  });
151
213
  }
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { NativeRichMediaButtonListProps } from './types';
3
+ export declare function NativeRichMediaButtonList(props: NativeRichMediaButtonListProps): ReactElement;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Vertical } from '@pushwoosh/kit-helpers';
3
+ import { ButtonRow } from '../../styles';
4
+ export function NativeRichMediaButtonList(props) {
5
+ const {
6
+ buttons,
7
+ $padding,
8
+ $margin
9
+ } = props;
10
+ return _jsx(Vertical, {
11
+ "$padding": $padding,
12
+ "$margin": $margin,
13
+ "$gap": 10,
14
+ children: (buttons || []).map((b, i) => _jsx(ButtonRow
15
+ // eslint-disable-next-line react/no-array-index-key
16
+ , {
17
+ "$borderRadius": b.border.radius,
18
+ "$background": b.background,
19
+ "$color": b.text.color,
20
+ "$border": `1px solid ${b.border.color}`,
21
+ children: b.text.text
22
+ }, `btn-${i}`))
23
+ });
24
+ }
@@ -0,0 +1 @@
1
+ export { NativeRichMediaButtonList } from './NativeRichMediaButtonList';
@@ -0,0 +1 @@
1
+ export { NativeRichMediaButtonList } from './NativeRichMediaButtonList';
@@ -0,0 +1,6 @@
1
+ import type { NativeRichMediaButtonValue } from '../../helpers';
2
+ export type NativeRichMediaButtonListProps = {
3
+ buttons?: NativeRichMediaButtonValue[];
4
+ $padding?: string;
5
+ $margin?: string;
6
+ };
@@ -1,14 +1,13 @@
1
1
  import styled from 'styled-components';
2
+ import { FontSize, FontWeight } from '@pushwoosh/kit-constants';
2
3
  export const Chip = styled.div.withConfig({
3
4
  displayName: "Chip",
4
5
  componentId: "sc-17mcpnr-0"
5
- })(["position:absolute;width:", ";height:", ";border-radius:50%;background:rgba(70,70,76,0.62);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);color:#FFF;display:flex;align-items:center;justify-content:center;font-size:", ";font-weight:700;z-index:6;line-height:1;", " ", " ", " ", " svg{display:block;}"], ({
6
+ })(["position:absolute;width:", ";height:", ";border-radius:50%;background:rgba(70,70,76,0.62);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);color:#FFF;display:flex;align-items:center;justify-content:center;font-size:", ";font-weight:", ";z-index:6;line-height:1;user-select:none;cursor:pointer;", " ", " ", " ", " svg{display:block;}"], ({
6
7
  $small
7
- }) => $small ? '26px' : '34px', ({
8
+ }) => $small ? '26px' : '30px', ({
8
9
  $small
9
- }) => $small ? '26px' : '34px', ({
10
- $small
11
- }) => $small ? '11px' : '14px', ({
10
+ }) => $small ? '26px' : '30px', FontSize.SMALL, FontWeight.BOLD, ({
12
11
  $top
13
12
  }) => $top !== undefined ? `top: ${$top}px;` : '', ({
14
13
  $right
@@ -1,10 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Color } from '@pushwoosh/kit-constants';
3
- import { SECONDARY_LABEL, asText, contrastOn, isLightHex, withAlpha } from '../../helpers';
2
+ import { CodeBox, CodeText, RewardMessage, RewardTitle } from './styles';
3
+ import { SECONDARY_LABEL, asButtonValue, asText, asTextValue, contrastOn, isLightHex, withAlpha } from '../../helpers';
4
4
  import { CopyIcon } from '../../icons';
5
5
  import { ButtonRow } from '../../styles';
6
- import { NativeRichMediaPtLabel } from '../NativeRichMediaPtLabel';
7
- import { CodeBox, CodeText } from './styles';
8
6
  export function NativeRichMediaRewardPanel(props) {
9
7
  const {
10
8
  reward,
@@ -14,27 +12,28 @@ export function NativeRichMediaRewardPanel(props) {
14
12
  return null;
15
13
  }
16
14
  const primary = contrastOn(onBackgroundHex);
17
- const codeColor = reward.title && reward.title.color || primary;
15
+ const title = asTextValue(reward.title);
16
+ const message = asTextValue(reward.message);
17
+ const button = asButtonValue(reward.button);
18
+ const codeColor = title.color || primary;
18
19
  const messageColor = isLightHex(onBackgroundHex) ? SECONDARY_LABEL : 'rgba(255,255,255,0.72)';
19
20
  const codeBackground = isLightHex(onBackgroundHex) ? 'rgba(0,0,0,0.06)' : 'rgba(255,255,255,0.16)';
20
- const visibleOrder = [reward.title && 'title', reward.message && 'message', reward.code && 'code', reward.button && 'button'].filter(Boolean);
21
+ const visibleOrder = [title.text && 'title', message.text && 'message', reward.code && 'code', button && 'button'].filter(Boolean);
21
22
  const firstVisible = visibleOrder[0];
22
- const marginFor = key => key === firstVisible ? undefined : 12;
23
+ const marginFor = key => {
24
+ if (key === firstVisible) return undefined;
25
+ if (key === 'message' && title.text) return 4;
26
+ return 12;
27
+ };
23
28
  return _jsxs("div", {
24
- children: [reward.title && _jsx(NativeRichMediaPtLabel, {
25
- value: reward.title,
26
- size: 22,
27
- weight: 800,
28
- fallbackColor: primary,
29
- align: "center",
30
- marginTop: marginFor('title')
31
- }), reward.message && _jsx(NativeRichMediaPtLabel, {
32
- value: reward.message,
33
- size: 15,
34
- weight: 400,
35
- fallbackColor: messageColor,
36
- align: "center",
37
- marginTop: marginFor('message')
29
+ children: [title.text && _jsx(RewardTitle, {
30
+ "$color": title.color || primary,
31
+ "$marginTop": marginFor('title'),
32
+ children: title.text
33
+ }), message.text && _jsx(RewardMessage, {
34
+ "$color": message.color || messageColor,
35
+ "$marginTop": marginFor('message'),
36
+ children: message.text
38
37
  }), reward.code && _jsxs(CodeBox, {
39
38
  "$marginTop": marginFor('code'),
40
39
  "$background": codeBackground,
@@ -45,12 +44,13 @@ export function NativeRichMediaRewardPanel(props) {
45
44
  }), _jsx(CopyIcon, {
46
45
  color: withAlpha(codeColor, 0.7)
47
46
  })]
48
- }), reward.button && _jsx(ButtonRow, {
47
+ }), button && _jsx(ButtonRow, {
49
48
  "$marginTop": marginFor('button'),
50
- "$borderRadius": 14,
51
- "$background": Color.PRIMARY,
52
- "$color": "#FFF",
53
- children: asText(reward.button)
49
+ "$borderRadius": button.border.radius,
50
+ "$background": button.background,
51
+ "$color": button.text.color,
52
+ "$border": `1px solid ${button.border.color}`,
53
+ children: button.text.text
54
54
  })]
55
55
  });
56
56
  }
@@ -4,5 +4,32 @@ export declare const CodeBox: import("styled-components").StyledComponent<"div",
4
4
  $marginTop?: number;
5
5
  }, never>;
6
6
  export declare const CodeText: import("styled-components").StyledComponent<"span", any, {
7
- $color: string;
8
- }, never>;
7
+ $color?: string | undefined;
8
+ $uppercase?: boolean | undefined;
9
+ $ellipsis?: boolean | undefined;
10
+ $variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
11
+ } & {
12
+ $variant: string;
13
+ }, "$variant">;
14
+ export declare const RewardTitle: import("styled-components").StyledComponent<"span", any, {
15
+ $color?: string | undefined;
16
+ $uppercase?: boolean | undefined;
17
+ $ellipsis?: boolean | undefined;
18
+ $variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
19
+ } & {
20
+ $color?: string;
21
+ $align?: "center";
22
+ $marginTop?: number;
23
+ $size?: "h3" | "h4";
24
+ $truncate?: boolean;
25
+ } & {
26
+ $align: string;
27
+ }, "$align">;
28
+ export declare const RewardMessage: import("styled-components").StyledComponent<typeof import("@pushwoosh/kit-typography").Footnote, any, {
29
+ $color?: string;
30
+ $align?: "center";
31
+ $clamp?: number;
32
+ $marginTop?: number;
33
+ } & {
34
+ $align: string;
35
+ }, "$align">;
@@ -1,4 +1,7 @@
1
1
  import styled from 'styled-components';
2
+ import { Text } from '@pushwoosh/kit-typography';
3
+ import { NativeRichMediaText } from '../NativeRichMediaText';
4
+ import { NativeRichMediaTitle } from '../NativeRichMediaTitle';
2
5
  export const CodeBox = styled.div.withConfig({
3
6
  displayName: "CodeBox",
4
7
  componentId: "sc-z83bc4-0"
@@ -9,9 +12,21 @@ export const CodeBox = styled.div.withConfig({
9
12
  }) => $border, ({
10
13
  $marginTop
11
14
  }) => $marginTop !== undefined ? `margin-top: ${$marginTop}px;` : '');
12
- export const CodeText = styled.span.withConfig({
15
+ export const CodeText = styled(Text).attrs({
16
+ $variant: 'h3'
17
+ }).withConfig({
13
18
  displayName: "CodeText",
14
19
  componentId: "sc-z83bc4-1"
15
- })(["font-size:17px;font-weight:700;color:", ";"], ({
16
- $color
17
- }) => $color);
20
+ })([""]);
21
+ export const RewardTitle = styled(NativeRichMediaTitle).attrs({
22
+ $align: 'center'
23
+ }).withConfig({
24
+ displayName: "RewardTitle",
25
+ componentId: "sc-z83bc4-2"
26
+ })([""]);
27
+ export const RewardMessage = styled(NativeRichMediaText).attrs({
28
+ $align: 'center'
29
+ }).withConfig({
30
+ displayName: "RewardMessage",
31
+ componentId: "sc-z83bc4-3"
32
+ })([""]);
@@ -0,0 +1 @@
1
+ export { NativeRichMediaText } from './styles';
@@ -0,0 +1 @@
1
+ export { NativeRichMediaText } from './styles';
@@ -0,0 +1,7 @@
1
+ import { Footnote } from '@pushwoosh/kit-typography';
2
+ export declare const NativeRichMediaText: import("styled-components").StyledComponent<typeof Footnote, any, {
3
+ $color?: string;
4
+ $align?: "center";
5
+ $clamp?: number;
6
+ $marginTop?: number;
7
+ }, never>;
@@ -0,0 +1,19 @@
1
+ import styled from 'styled-components';
2
+ import { Footnote } from '@pushwoosh/kit-typography';
3
+ export const NativeRichMediaText = styled(Footnote).withConfig({
4
+ displayName: "NativeRichMediaText",
5
+ componentId: "sc-1e1cjl8-0"
6
+ })(["display:block;color:", ";", " ", " ", ""], ({
7
+ $color
8
+ }) => $color, ({
9
+ $align
10
+ }) => $align ? `text-align: ${$align};` : '', ({
11
+ $marginTop
12
+ }) => $marginTop !== undefined ? `margin-top: ${$marginTop}px;` : '', ({
13
+ $clamp
14
+ }) => $clamp ? `
15
+ display: -webkit-box;
16
+ -webkit-line-clamp: ${$clamp};
17
+ -webkit-box-orient: vertical;
18
+ overflow: hidden;
19
+ ` : '');
@@ -0,0 +1 @@
1
+ export { NativeRichMediaTitle } from './styles';
@@ -0,0 +1 @@
1
+ export { NativeRichMediaTitle } from './styles';
@@ -0,0 +1,12 @@
1
+ export declare const NativeRichMediaTitle: import("styled-components").StyledComponent<"span", any, {
2
+ $color?: string | undefined;
3
+ $uppercase?: boolean | undefined;
4
+ $ellipsis?: boolean | undefined;
5
+ $variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
6
+ } & {
7
+ $color?: string;
8
+ $align?: "center";
9
+ $marginTop?: number;
10
+ $size?: "h3" | "h4";
11
+ $truncate?: boolean;
12
+ }, never>;
@@ -0,0 +1,22 @@
1
+ import styled from 'styled-components';
2
+ import { Text } from '@pushwoosh/kit-typography';
3
+ export const NativeRichMediaTitle = styled(Text).attrs(({
4
+ $size
5
+ }) => ({
6
+ $variant: $size === 'h4' ? 'h4' : 'h3'
7
+ })).withConfig({
8
+ displayName: "NativeRichMediaTitle",
9
+ componentId: "sc-1oklc22-0"
10
+ })(["display:block;color:", ";", " ", " ", ""], ({
11
+ $color
12
+ }) => $color, ({
13
+ $align
14
+ }) => $align ? `text-align: ${$align};` : '', ({
15
+ $marginTop
16
+ }) => $marginTop !== undefined ? `margin-top: ${$marginTop}px;` : '', ({
17
+ $truncate
18
+ }) => $truncate ? `
19
+ white-space: nowrap;
20
+ overflow: hidden;
21
+ text-overflow: ellipsis;
22
+ ` : '');
@@ -1,9 +1,5 @@
1
- export declare const PT: {
2
- W: number;
3
- H: number;
4
- SAFE_TOP: number;
5
- SAFE_BOTTOM: number;
6
- };
1
+ import type { NativeRichMediaAction } from './types';
2
+ export declare const EDGE_INSET = 24;
7
3
  export declare const SEG_FALLBACK: string[];
8
4
  export declare const SECONDARY_LABEL = "rgba(60,60,67,0.6)";
9
5
  export declare const TERTIARY_LABEL = "rgba(60,60,67,0.3)";
@@ -14,4 +10,24 @@ export declare function withAlpha(hex: string, a: number): string;
14
10
  export declare function mixHex(hex: string, target: string, t: number): string;
15
11
  export declare function surfaceBackground(background: string | string[] | undefined, fallbackHex: string): string;
16
12
  export declare function asText(value: unknown): string;
13
+ export type NativeRichMediaTextValue = {
14
+ text: string;
15
+ color?: string;
16
+ };
17
+ export declare function asTextValue(value: unknown): NativeRichMediaTextValue;
18
+ export type NativeRichMediaButtonValue = {
19
+ text: {
20
+ text: string;
21
+ color: string;
22
+ };
23
+ background: string;
24
+ border: {
25
+ color: string;
26
+ radius: number;
27
+ };
28
+ action?: NativeRichMediaAction;
29
+ };
30
+ export declare function asButtonValue(value: unknown): NativeRichMediaButtonValue | null;
31
+ export declare function asButtonList(value: unknown): NativeRichMediaButtonValue[];
17
32
  export declare function surfaceBaseHex(background: string | string[] | undefined): string | null;
33
+ export declare function clampIndex(index: number, length: number): number;