@pushwoosh/dumb-components 1.1.164 → 1.1.166

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.
@@ -17,7 +17,7 @@ export const ModalBox = styled.div.attrs(({
17
17
  export const ModalInner = styled.div.withConfig({
18
18
  displayName: "ModalInner",
19
19
  componentId: "sc-lejcgu-1"
20
- })(["display:flex;justify-content:center;width:100vw;height:100vh;padding:56px 0;"]);
20
+ })(["display:flex;align-items:flex-start;justify-content:center;width:100vw;height:100vh;padding:56px 0;"]);
21
21
  function ModalBoxBase(props) {
22
22
  const {
23
23
  isOpen,
@@ -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;background:", ";& > *{&: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:", ";max-height:calc(100vh - 2 * 56px);vertical-align:middle;z-index:10;background:", ";border-radius:", ";& > *{&: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, Color.CLEAR, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG);
49
+ }) => $width, Color.CLEAR, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG);
50
50
  ModalBox.displayName = 'ModalBox';
51
51
  ModalInner.displayName = 'ModalInner';
52
52
  ModalContainer.displayName = 'ModalContainer';
@@ -3,6 +3,9 @@ import { type NativeRichMediaConfig } from './types';
3
3
  * Parses and validates a native rich media config from an object or a JSON
4
4
  * string; returns `null` when the input is not a well-formed config — unknown
5
5
  * `displayType`, missing block, empty `items`/`segments`, or any required
6
- * field of the block contract absent or malformed.
6
+ * field of the block contract absent or malformed. Content that may be
7
+ * legitimately unfinished in a draft — empty text values, an empty or absent
8
+ * video `url`, an absent `reward` — is accepted and rendered bare, so live
9
+ * editor drafts preview without a placeholder.
7
10
  */
8
11
  export declare function parseNativeRichMediaConfig(content: string | NativeRichMediaConfig): NativeRichMediaConfig | null;
@@ -9,7 +9,13 @@ function isFiniteNumber(value) {
9
9
  return typeof value === 'number' && Number.isFinite(value);
10
10
  }
11
11
  function isText(value) {
12
- return isObject(value) && isNonEmptyString(value.text) && isNonEmptyString(value.color);
12
+ return isObject(value) && typeof value.text === 'string' && isNonEmptyString(value.color);
13
+ }
14
+ function isFilledText(value) {
15
+ return isText(value) && isNonEmptyString(value.text);
16
+ }
17
+ function isOptionalString(value) {
18
+ return value === undefined || typeof value === 'string';
13
19
  }
14
20
  function isOptionalText(value) {
15
21
  return value === undefined || isText(value);
@@ -21,7 +27,7 @@ function isAction(value) {
21
27
  if (value.type === 'close') {
22
28
  return true;
23
29
  }
24
- return value.type === 'url' && isNonEmptyString(value.url);
30
+ return value.type === 'url' && isOptionalString(value.url);
25
31
  }
26
32
  function isOptionalAction(value) {
27
33
  return value === undefined || isAction(value);
@@ -45,7 +51,7 @@ function isReward(value) {
45
51
  if (!isObject(value)) {
46
52
  return false;
47
53
  }
48
- const hasIdentity = isText(value.title) || isNonEmptyString(value.code);
54
+ const hasIdentity = isFilledText(value.title) || isNonEmptyString(value.code);
49
55
  return hasIdentity && isOptionalText(value.title) && isOptionalText(value.message) && (value.button === undefined || isButton(value.button));
50
56
  }
51
57
  function isOptionalReward(value) {
@@ -59,18 +65,21 @@ const BLOCK_VALIDATORS = {
59
65
  carousel: block => typeof block.showClose === 'boolean' && Array.isArray(block.items) && block.items.length > 0 && block.items.every(item => isObject(item) && isOptionalText(item.title) && isOptionalText(item.message) && isOptionalAction(item.action)),
60
66
  fullscreen: block => typeof block.showClose === 'boolean' && isCover(block.cover) && isOptionalText(block.title) && isOptionalText(block.message) && isButtonArray(block.buttons),
61
67
  modal: block => typeof block.showClose === 'boolean' && typeof block.dimBackground === 'boolean' && isNonEmptyString(block.background) && isOptionalText(block.title) && isOptionalText(block.message) && isButtonArray(block.buttons),
62
- pip: block => typeof block.showClose === 'boolean' && ['bottom-right', 'bottom-left', 'top-right', 'top-left'].includes(block.position) && typeof block.loop === 'boolean' && typeof block.muted === 'boolean' && isNonEmptyString(block.url) && isFiniteNumber(block.width) && isFiniteNumber(block.aspectRatio) && isOptionalAction(block.action),
63
- scratchcard: block => typeof block.showClose === 'boolean' && isBackground(block.background) && isFiniteNumber(block.revealThreshold) && isCover(block.cover) && (block.revealButton === undefined || isActionlessButton(block.revealButton)) && isOptionalText(block.title) && isOptionalText(block.message) && isReward(block.reward),
68
+ pip: block => typeof block.showClose === 'boolean' && ['bottom-right', 'bottom-left', 'top-right', 'top-left'].includes(block.position) && typeof block.loop === 'boolean' && typeof block.muted === 'boolean' && isOptionalString(block.url) && isFiniteNumber(block.width) && isFiniteNumber(block.aspectRatio) && isOptionalAction(block.action),
69
+ scratchcard: block => typeof block.showClose === 'boolean' && isBackground(block.background) && isFiniteNumber(block.revealThreshold) && isCover(block.cover) && (block.revealButton === undefined || isActionlessButton(block.revealButton)) && isOptionalText(block.title) && isOptionalText(block.message) && isOptionalReward(block.reward),
64
70
  sheet: block => typeof block.showClose === 'boolean' && typeof block.dimBackground === 'boolean' && isNonEmptyString(block.background) && isOptionalText(block.title) && isOptionalText(block.message) && isButtonArray(block.buttons),
65
- spinwheel: block => typeof block.showClose === 'boolean' && isBackground(block.background) && isFiniteNumber(block.winIndex) && isActionlessButton(block.spinButton) && isOptionalText(block.title) && isOptionalText(block.message) && isReward(block.reward) && isOptionalText(block.loseTitle) && Array.isArray(block.segments) && block.segments.length > 0 && block.segments.every(segment => isObject(segment) && isText(segment.message) && isFiniteNumber(segment.weight) && isOptionalReward(segment.reward)),
71
+ spinwheel: block => typeof block.showClose === 'boolean' && isBackground(block.background) && isFiniteNumber(block.winIndex) && isActionlessButton(block.spinButton) && isOptionalText(block.title) && isOptionalText(block.message) && isOptionalReward(block.reward) && isOptionalText(block.loseTitle) && Array.isArray(block.segments) && block.segments.length > 0 && block.segments.every(segment => isObject(segment) && isText(segment.message) && isFiniteNumber(segment.weight) && isOptionalReward(segment.reward)),
66
72
  stories: block => typeof block.showClose === 'boolean' && typeof block.loop === 'boolean' && Array.isArray(block.items) && block.items.length > 0 && block.items.every(item => isObject(item) && isOptionalText(item.title) && isOptionalText(item.message) && isButtonArray(item.buttons) && isFiniteNumber(item.duration)),
67
- video: block => typeof block.showClose === 'boolean' && typeof block.loop === 'boolean' && typeof block.muted === 'boolean' && isNonEmptyString(block.url) && isOptionalText(block.title) && isOptionalText(block.message) && isButtonArray(block.buttons)
73
+ video: block => typeof block.showClose === 'boolean' && typeof block.loop === 'boolean' && typeof block.muted === 'boolean' && isOptionalString(block.url) && isOptionalText(block.title) && isOptionalText(block.message) && isButtonArray(block.buttons)
68
74
  };
69
75
  /**
70
76
  * Parses and validates a native rich media config from an object or a JSON
71
77
  * string; returns `null` when the input is not a well-formed config — unknown
72
78
  * `displayType`, missing block, empty `items`/`segments`, or any required
73
- * field of the block contract absent or malformed.
79
+ * field of the block contract absent or malformed. Content that may be
80
+ * legitimately unfinished in a draft — empty text values, an empty or absent
81
+ * video `url`, an absent `reward` — is accepted and rendered bare, so live
82
+ * editor drafts preview without a placeholder.
74
83
  */
75
84
  export function parseNativeRichMediaConfig(content) {
76
85
  let raw = content;
@@ -22,9 +22,11 @@ export type NativeRichMediaCover = {
22
22
  /** Available actions. */
23
23
  export type NativeRichMediaAction = {
24
24
  type: 'close';
25
- } | {
25
+ }
26
+ /** `url` is required by the SDK, but may be empty or absent in a draft. */
27
+ | {
26
28
  type: 'url';
27
- url: string;
29
+ url?: string;
28
30
  };
29
31
  /** Button block. */
30
32
  export type NativeRichMediaButton = {
@@ -162,8 +164,8 @@ export type NativeRichMediaVideoBlock = {
162
164
  loop: boolean;
163
165
  /** Start playback muted. */
164
166
  muted: boolean;
165
- /** Video URL. */
166
- url: string;
167
+ /** Video URL; required by the SDK, may be empty or absent in a draft. */
168
+ url?: string;
167
169
  /** Poster image URL shown before playback. */
168
170
  poster?: string;
169
171
  /** Image URL shown when the video cannot be played. */
@@ -181,8 +183,8 @@ export type NativeRichMediaPipBlock = {
181
183
  loop: boolean;
182
184
  /** Start playback muted. */
183
185
  muted: boolean;
184
- /** Video URL. */
185
- url: string;
186
+ /** Video URL; required by the SDK, may be empty or absent in a draft. */
187
+ url?: string;
186
188
  /** Poster image URL shown before playback. */
187
189
  poster?: string;
188
190
  /** Image URL shown when the video cannot be played. */
@@ -212,8 +214,8 @@ export type NativeRichMediaScratchcardBlock = {
212
214
  title?: NativeRichMediaText;
213
215
  /** Message. */
214
216
  message?: NativeRichMediaText;
215
- /** Reward revealed under the cover. */
216
- reward: NativeRichMediaReward;
217
+ /** Reward revealed under the cover; required by the SDK, may be absent in a draft. */
218
+ reward?: NativeRichMediaReward;
217
219
  };
218
220
  /** Content of a `spinwheel` rich media. */
219
221
  export type NativeRichMediaSpinwheelBlock = {
@@ -229,8 +231,8 @@ export type NativeRichMediaSpinwheelBlock = {
229
231
  winIndex: number;
230
232
  /** Spin button, including its own tap action. */
231
233
  spinButton: Omit<NativeRichMediaButton, 'action'>;
232
- /** Reward shown after a winning spin. */
233
- reward: NativeRichMediaReward;
234
+ /** Reward shown after a winning spin; required by the SDK, may be absent in a draft. */
235
+ reward?: NativeRichMediaReward;
234
236
  /** Heading shown after a losing spin. */
235
237
  loseTitle?: NativeRichMediaText;
236
238
  /** Wheel sectors. */
@@ -13,4 +13,4 @@ export const Card = styled.div.withConfig({
13
13
  export const CloseGlyph = styled.div.withConfig({
14
14
  displayName: "CloseGlyph",
15
15
  componentId: "sc-1fs78cm-1"
16
- })(["flex:none;width:24px;height:24px;display:flex;align-items:center;justify-content:center;color:rgba(255,255,255,0.6);font-size:", ";font-weight:", ";user-select:none;cursor:pointer;"], FontSize.SMALL, FontWeight.BOLD);
16
+ })(["flex:none;margin-left:auto;width:24px;height:24px;border-radius:50%;background:rgba(0,0,0,0.4);display:flex;align-items:center;justify-content:center;color:rgba(255,255,255,0.6);font-size:", ";font-weight:", ";user-select:none;cursor:pointer;"], FontSize.SMALL, FontWeight.BOLD);
@@ -5,4 +5,4 @@ export const Card = styled(SharedCard).attrs({
5
5
  }).withConfig({
6
6
  displayName: "Card",
7
7
  componentId: "sc-1std439-0"
8
- })([""]);
8
+ })(["min-height:70px;"]);
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Card, HintOverlay, HintText, RevealArea, RevealButtonText, RewardSlot } from './styles';
2
+ import { Card, HintOverlay, HintText, RevealArea, RevealButtonText, RewardSlot, TextBlock } from './styles';
3
3
  import { NativeRichMediaCloseChip } from '../../components/NativeRichMediaCloseChip';
4
4
  import { NativeRichMediaCoverImg } from '../../components/NativeRichMediaCoverImg';
5
5
  import { NativeRichMediaRewardPanel } from '../../components/NativeRichMediaRewardPanel';
@@ -21,15 +21,17 @@ export function NativeRichMediaScratchcardView(props) {
21
21
  const revealButton = asButtonValue(block.revealButton);
22
22
  return _jsxs(Card, {
23
23
  "$background": surfaceBackground(block.background, '#FFFFFF'),
24
- children: [title.text && _jsx(NativeRichMediaTitle, {
25
- "$color": title.color,
26
- "$align": "center",
27
- children: title.text
28
- }), message.text && _jsx(NativeRichMediaText, {
29
- "$color": message.color,
30
- "$marginTop": 4,
31
- "$align": "center",
32
- children: message.text
24
+ children: [(title.text || message.text) && _jsxs(TextBlock, {
25
+ children: [title.text && _jsx(NativeRichMediaTitle, {
26
+ "$color": title.color,
27
+ "$align": "center",
28
+ children: title.text
29
+ }), message.text && _jsx(NativeRichMediaText, {
30
+ "$color": message.color,
31
+ "$marginTop": 4,
32
+ "$align": "center",
33
+ children: message.text
34
+ })]
33
35
  }), _jsxs(RevealArea, {
34
36
  children: [_jsx(RewardSlot, {
35
37
  children: _jsx(NativeRichMediaRewardPanel, {
@@ -4,6 +4,7 @@ export declare const Card: import("styled-components").StyledComponent<"div", an
4
4
  } & {
5
5
  $padding: string;
6
6
  }, "$padding">;
7
+ export declare const TextBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
7
8
  export declare const RevealArea: import("styled-components").StyledComponent<"div", any, {}, never>;
8
9
  export declare const RewardSlot: import("styled-components").StyledComponent<"div", any, {}, never>;
9
10
  export declare const HintOverlay: import("styled-components").StyledComponent<"div", any, {
@@ -4,35 +4,39 @@ import { NativeRichMediaText } from '../../components/NativeRichMediaText';
4
4
  import { mixHex } from '../../helpers';
5
5
  import { Card as SharedCard } from '../shared/styles';
6
6
  export const Card = styled(SharedCard).attrs({
7
- $padding: '28px 24px 16px'
7
+ $padding: '24px'
8
8
  }).withConfig({
9
9
  displayName: "Card",
10
10
  componentId: "sc-nguevq-0"
11
11
  })([""]);
12
+ export const TextBlock = styled.div.withConfig({
13
+ displayName: "TextBlock",
14
+ componentId: "sc-nguevq-1"
15
+ })(["margin-bottom:14px;"]);
12
16
  export const RevealArea = styled.div.withConfig({
13
17
  displayName: "RevealArea",
14
- componentId: "sc-nguevq-1"
15
- })(["position:relative;margin-top:14px;height:179px;border-radius:18px;background:#F7F7F7;overflow:hidden;"]);
18
+ componentId: "sc-nguevq-2"
19
+ })(["position:relative;height:179px;border-radius:18px;background:#F7F7F7;overflow:hidden;"]);
16
20
  export const RewardSlot = styled.div.withConfig({
17
21
  displayName: "RewardSlot",
18
- componentId: "sc-nguevq-2"
22
+ componentId: "sc-nguevq-3"
19
23
  })(["position:absolute;left:16px;right:16px;top:50%;transform:translateY(-50%);"]);
20
24
  export const HintOverlay = styled.div.withConfig({
21
25
  displayName: "HintOverlay",
22
- componentId: "sc-nguevq-3"
26
+ componentId: "sc-nguevq-4"
23
27
  })(["position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;background:", ";"], ({
24
28
  $coverBase
25
29
  }) => `linear-gradient(135deg, ${mixHex($coverBase, '#FFFFFF', 0.4)}, ${$coverBase} 45%, ${mixHex($coverBase, '#000000', 0.12)})`);
26
30
  export const HintText = styled(NativeRichMediaText).withConfig({
27
31
  displayName: "HintText",
28
- componentId: "sc-nguevq-4"
32
+ componentId: "sc-nguevq-5"
29
33
  })(["font-weight:", ";"], FontWeight.MEDIUM);
30
34
  export const RevealButtonText = styled(NativeRichMediaText).attrs({
31
35
  $align: 'center',
32
36
  $marginTop: 14
33
37
  }).withConfig({
34
38
  displayName: "RevealButtonText",
35
- componentId: "sc-nguevq-5"
39
+ componentId: "sc-nguevq-6"
36
40
  })(["font-weight:", ";width:fit-content;margin-left:auto;margin-right:auto;background:", ";border-radius:", "px;padding:10px 16px;border:1px solid ", ";user-select:none;cursor:pointer;"], FontWeight.MEDIUM, ({
37
41
  $background
38
42
  }) => $background, ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.164",
3
+ "version": "1.1.166",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",