@pushwoosh/dumb-components 1.1.172 → 1.1.174

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 (26) hide show
  1. package/NativeRichMediaPreview/NativeRichMediaPreview.js +7 -12
  2. package/NativeRichMediaPreview/components/NativeRichMediaContentImg/NativeRichMediaContentImg.d.ts +3 -0
  3. package/NativeRichMediaPreview/components/NativeRichMediaContentImg/NativeRichMediaContentImg.js +21 -0
  4. package/NativeRichMediaPreview/components/NativeRichMediaContentImg/index.d.ts +1 -0
  5. package/NativeRichMediaPreview/components/NativeRichMediaContentImg/index.js +1 -0
  6. package/NativeRichMediaPreview/components/NativeRichMediaContentImg/styles.d.ts +1 -0
  7. package/NativeRichMediaPreview/components/NativeRichMediaContentImg/styles.js +5 -0
  8. package/NativeRichMediaPreview/components/NativeRichMediaContentImg/types.d.ts +5 -0
  9. package/NativeRichMediaPreview/components/NativeRichMediaContentImg/types.js +1 -0
  10. package/NativeRichMediaPreview/helpers.d.ts +1 -0
  11. package/NativeRichMediaPreview/helpers.js +3 -0
  12. package/NativeRichMediaPreview/index.d.ts +1 -0
  13. package/NativeRichMediaPreview/index.js +1 -0
  14. package/NativeRichMediaPreview/parseLocalizationParams.d.ts +9 -0
  15. package/NativeRichMediaPreview/parseLocalizationParams.js +37 -0
  16. package/NativeRichMediaPreview/parseNativeRichMediaConfig.js +1 -3
  17. package/NativeRichMediaPreview/views/NativeRichMediaCarouselView/NativeRichMediaCarouselView.js +9 -11
  18. package/NativeRichMediaPreview/views/NativeRichMediaCarouselView/styles.d.ts +0 -1
  19. package/NativeRichMediaPreview/views/NativeRichMediaCarouselView/styles.js +3 -7
  20. package/NativeRichMediaPreview/views/NativeRichMediaModalView/NativeRichMediaModalView.js +2 -3
  21. package/NativeRichMediaPreview/views/NativeRichMediaSheetView/NativeRichMediaSheetView.js +2 -3
  22. package/NativeRichMediaPreview/views/shared/styles.d.ts +0 -3
  23. package/NativeRichMediaPreview/views/shared/styles.js +2 -8
  24. package/index.d.ts +1 -1
  25. package/index.js +1 -1
  26. package/package.json +1 -1
@@ -11,7 +11,6 @@ import { parseNativeRichMediaConfig } from './parseNativeRichMediaConfig';
11
11
  import { resolveLocalization } from './resolveLocalization';
12
12
  import { BackdropLayer, ContentFlow, PreviewHost, ScrollLayer, SpinnerLayer } from './styles';
13
13
  import { NativeRichMediaBannerView, NativeRichMediaCarouselView, NativeRichMediaFullscreenView, NativeRichMediaInvalidView, NativeRichMediaModalView, NativeRichMediaPipView, NativeRichMediaScratchcardView, NativeRichMediaSheetView, NativeRichMediaSpinwheelView, NativeRichMediaStoriesView, NativeRichMediaVideoView } from './views';
14
- import { GradientOverlay } from './views/shared/styles';
15
14
  function dimsScreen(config) {
16
15
  if (!config) {
17
16
  return false;
@@ -50,16 +49,12 @@ function justifyFor(config) {
50
49
  return 'center';
51
50
  }
52
51
  }
53
- function renderCoverBackdrop(url, backgroundColor, overlayTopOffset) {
54
- return _jsxs(_Fragment, {
55
- children: [_jsx(NativeRichMediaCoverImg, {
56
- url: url,
57
- position: "absolute",
58
- inset: true,
59
- backgroundColor: backgroundColor
60
- }), _jsx(GradientOverlay, {
61
- "$topOffset": overlayTopOffset
62
- })]
52
+ function renderCoverBackdrop(url, backgroundColor) {
53
+ return _jsx(NativeRichMediaCoverImg, {
54
+ url: url,
55
+ position: "absolute",
56
+ inset: true,
57
+ backgroundColor: backgroundColor
63
58
  });
64
59
  }
65
60
  function renderBackdrop(config, activeIndex) {
@@ -72,7 +67,7 @@ function renderBackdrop(config, activeIndex) {
72
67
  {
73
68
  var _items$clampIndex;
74
69
  const items = config.stories.items;
75
- return renderCoverBackdrop((_items$clampIndex = items[clampIndex(activeIndex, items.length)]) === null || _items$clampIndex === void 0 ? void 0 : _items$clampIndex.image, '#000', '55%');
70
+ return renderCoverBackdrop((_items$clampIndex = items[clampIndex(activeIndex, items.length)]) === null || _items$clampIndex === void 0 ? void 0 : _items$clampIndex.image, '#000');
76
71
  }
77
72
  default:
78
73
  return null;
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { NativeRichMediaContentImgProps } from './types';
3
+ export declare function NativeRichMediaContentImg(props: NativeRichMediaContentImgProps): ReactElement;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Color } from '@pushwoosh/kit-constants';
3
+ import { Horizontal } from '@pushwoosh/kit-helpers';
4
+ import { Img } from './styles';
5
+ export function NativeRichMediaContentImg(props) {
6
+ const {
7
+ url,
8
+ margin,
9
+ borderRadius = 18
10
+ } = props;
11
+ return _jsx(Horizontal, {
12
+ "$margin": margin,
13
+ "$borderRadius": borderRadius,
14
+ "$bgColor": Color.FROZEN,
15
+ "$overflow": "hidden",
16
+ children: _jsx(Img, {
17
+ src: url,
18
+ alt: ""
19
+ })
20
+ });
21
+ }
@@ -0,0 +1 @@
1
+ export { NativeRichMediaContentImg } from './NativeRichMediaContentImg';
@@ -0,0 +1 @@
1
+ export { NativeRichMediaContentImg } from './NativeRichMediaContentImg';
@@ -0,0 +1 @@
1
+ export declare const Img: import("styled-components").StyledComponent<"img", any, {}, never>;
@@ -0,0 +1,5 @@
1
+ import styled from 'styled-components';
2
+ export const Img = styled.img.withConfig({
3
+ displayName: "Img",
4
+ componentId: "sc-1q27duj-0"
5
+ })(["display:block;width:100%;height:auto;"]);
@@ -0,0 +1,5 @@
1
+ export type NativeRichMediaContentImgProps = {
2
+ url?: string;
3
+ margin?: string;
4
+ borderRadius?: number;
5
+ };
@@ -9,6 +9,7 @@ export declare function contrastOn(hex: string): string;
9
9
  export declare function withAlpha(hex: string, a: number): string;
10
10
  export declare function mixHex(hex: string, target: string, t: number): string;
11
11
  export declare function surfaceBackground(background: string | string[] | undefined, fallbackHex: string): string;
12
+ export declare function isObject(value: unknown): value is Record<string, unknown>;
12
13
  export declare function asText(value: unknown): string;
13
14
  export type NativeRichMediaTextValue = {
14
15
  text: string;
@@ -65,6 +65,9 @@ export function surfaceBackground(background, fallbackHex) {
65
65
  }
66
66
  return background || fallbackHex;
67
67
  }
68
+ export function isObject(value) {
69
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
70
+ }
68
71
  export function asText(value) {
69
72
  return typeof value === 'string' ? value : '';
70
73
  }
@@ -1,4 +1,5 @@
1
1
  export type { NativeRichMediaConfig, NativeRichMediaDisplayType, NativeRichMediaText, NativeRichMediaBorder, NativeRichMediaCover, NativeRichMediaAction, NativeRichMediaButton, NativeRichMediaReward, NativeRichMediaModalBlock, NativeRichMediaSheetBlock, NativeRichMediaCarouselBlock, NativeRichMediaStoriesBlock, NativeRichMediaBannerBlock, NativeRichMediaFullscreenBlock, NativeRichMediaVideoBlock, NativeRichMediaPipBlock, NativeRichMediaScratchcardBlock, NativeRichMediaSpinwheelBlock, NativeRichMediaPreviewProps, NativeRichMediaLocalization, } from './types';
2
2
  export { NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './types';
3
3
  export { parseNativeRichMediaConfig } from './parseNativeRichMediaConfig';
4
+ export { parseLocalizationParams } from './parseLocalizationParams';
4
5
  export { NativeRichMediaPreview } from './NativeRichMediaPreview';
@@ -1,3 +1,4 @@
1
1
  export { NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './types';
2
2
  export { parseNativeRichMediaConfig } from './parseNativeRichMediaConfig';
3
+ export { parseLocalizationParams } from './parseLocalizationParams';
3
4
  export { NativeRichMediaPreview } from './NativeRichMediaPreview';
@@ -0,0 +1,9 @@
1
+ import type { NativeRichMediaLocalization } from './types';
2
+ /**
3
+ * Parses a rich media `params` JSON string into a {@link NativeRichMediaLocalization}
4
+ * ready for the `localization` prop of {@link NativeRichMediaPreview}. Accepts both the
5
+ * wrapped shape (`{ localization: { … } }`) and a bare localization object, and tolerates
6
+ * malformed input: a missing, non-JSON, or non-object `params` yields `{}`, and non-string
7
+ * leaves are dropped so the result is always `Record<string, Record<string, string>>`.
8
+ */
9
+ export declare function parseLocalizationParams(params?: string): NativeRichMediaLocalization;
@@ -0,0 +1,37 @@
1
+ import { isObject } from './helpers';
2
+ /**
3
+ * Parses a rich media `params` JSON string into a {@link NativeRichMediaLocalization}
4
+ * ready for the `localization` prop of {@link NativeRichMediaPreview}. Accepts both the
5
+ * wrapped shape (`{ localization: { … } }`) and a bare localization object, and tolerates
6
+ * malformed input: a missing, non-JSON, or non-object `params` yields `{}`, and non-string
7
+ * leaves are dropped so the result is always `Record<string, Record<string, string>>`.
8
+ */
9
+ export function parseLocalizationParams(params) {
10
+ if (!params) {
11
+ return {};
12
+ }
13
+ let parsed;
14
+ try {
15
+ parsed = JSON.parse(params);
16
+ } catch {
17
+ return {};
18
+ }
19
+ if (!isObject(parsed)) {
20
+ return {};
21
+ }
22
+ const source = isObject(parsed.localization) ? parsed.localization : parsed;
23
+ const result = {};
24
+ Object.entries(source).forEach(([code, dict]) => {
25
+ if (!isObject(dict)) {
26
+ return;
27
+ }
28
+ const clean = {};
29
+ Object.entries(dict).forEach(([key, value]) => {
30
+ if (typeof value === 'string') {
31
+ clean[key] = value;
32
+ }
33
+ });
34
+ result[code] = clean;
35
+ });
36
+ return result;
37
+ }
@@ -1,7 +1,5 @@
1
+ import { isObject } from './helpers';
1
2
  import { NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './types';
2
- function isObject(value) {
3
- return typeof value === 'object' && value !== null && !Array.isArray(value);
4
- }
5
3
  function isNonEmptyString(value) {
6
4
  return typeof value === 'string' && value.length > 0;
7
5
  }
@@ -1,5 +1,5 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Card, Dot, Dots, GradientOverlay, TextBlock } from './styles';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Card, Dot, Dots, TextBlock } from './styles';
3
3
  import { NativeRichMediaCloseChip } from '../../components/NativeRichMediaCloseChip';
4
4
  import { NativeRichMediaCoverImg } from '../../components/NativeRichMediaCoverImg';
5
5
  import { NativeRichMediaText } from '../../components/NativeRichMediaText';
@@ -20,15 +20,13 @@ export function NativeRichMediaCarouselView(props) {
20
20
  url: item.image,
21
21
  position: "absolute",
22
22
  inset: true
23
- }), (title.text || message.text) && _jsxs(_Fragment, {
24
- children: [_jsx(GradientOverlay, {}), _jsxs(TextBlock, {
25
- children: [title.text && _jsx(NativeRichMediaTitle, {
26
- "$color": title.color,
27
- children: title.text
28
- }), message.text && _jsx(NativeRichMediaText, {
29
- "$color": message.color,
30
- children: message.text
31
- })]
23
+ }), (title.text || message.text) && _jsxs(TextBlock, {
24
+ children: [title.text && _jsx(NativeRichMediaTitle, {
25
+ "$color": title.color,
26
+ children: title.text
27
+ }), message.text && _jsx(NativeRichMediaText, {
28
+ "$color": message.color,
29
+ children: message.text
32
30
  })]
33
31
  }), items.length > 1 && _jsx(Dots, {
34
32
  children: items.map((_, i) => _jsx(Dot
@@ -1,5 +1,4 @@
1
1
  export declare const Card: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export declare const GradientOverlay: import("styled-components").StyledComponent<"div", any, {}, never>;
3
2
  export declare const TextBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
4
3
  export declare const Dots: import("styled-components").StyledComponent<"div", any, {}, never>;
5
4
  export declare const Dot: import("styled-components").StyledComponent<"div", any, {
@@ -3,21 +3,17 @@ export const Card = styled.div.withConfig({
3
3
  displayName: "Card",
4
4
  componentId: "sc-15b2cux-0"
5
5
  })(["position:relative;margin:0 12px;height:461px;border-radius:24px;background:#000;overflow:hidden;box-shadow:0 16px 28px rgba(0,0,0,0.28);"]);
6
- export const GradientOverlay = styled.div.withConfig({
7
- displayName: "GradientOverlay",
8
- componentId: "sc-15b2cux-1"
9
- })(["position:absolute;left:0;right:0;bottom:0;height:140px;background:linear-gradient(180deg,rgba(0,0,0,0),rgba(0,0,0,0.75));"]);
10
6
  export const TextBlock = styled.div.withConfig({
11
7
  displayName: "TextBlock",
12
- componentId: "sc-15b2cux-2"
8
+ componentId: "sc-15b2cux-1"
13
9
  })(["position:absolute;left:18px;right:18px;bottom:36px;"]);
14
10
  export const Dots = styled.div.withConfig({
15
11
  displayName: "Dots",
16
- componentId: "sc-15b2cux-3"
12
+ componentId: "sc-15b2cux-2"
17
13
  })(["position:absolute;left:0;right:0;bottom:12px;text-align:center;font-size:0;"]);
18
14
  export const Dot = styled.div.withConfig({
19
15
  displayName: "Dot",
20
- componentId: "sc-15b2cux-4"
16
+ componentId: "sc-15b2cux-3"
21
17
  })(["display:inline-block;width:7px;height:7px;border-radius:50%;margin:0 4.5px;background:", ";"], ({
22
18
  $active
23
19
  }) => $active ? '#FFF' : 'rgba(255,255,255,0.4)');
@@ -3,7 +3,7 @@ import { Vertical } from '@pushwoosh/kit-helpers';
3
3
  import { Card } from './styles';
4
4
  import { NativeRichMediaButtonList } from '../../components/NativeRichMediaButtonList';
5
5
  import { NativeRichMediaCloseChip } from '../../components/NativeRichMediaCloseChip';
6
- import { NativeRichMediaCoverImg } from '../../components/NativeRichMediaCoverImg';
6
+ import { NativeRichMediaContentImg } from '../../components/NativeRichMediaContentImg';
7
7
  import { NativeRichMediaText } from '../../components/NativeRichMediaText';
8
8
  import { NativeRichMediaTitle } from '../../components/NativeRichMediaTitle';
9
9
  import { asButtonList, asTextValue } from '../../helpers';
@@ -17,10 +17,9 @@ export function NativeRichMediaModalView(props) {
17
17
  const message = asTextValue(block.message);
18
18
  return _jsxs(Card, {
19
19
  "$background": block.background,
20
- children: [block.image && _jsx(NativeRichMediaCoverImg, {
20
+ children: [block.image && _jsx(NativeRichMediaContentImg, {
21
21
  url: block.image,
22
22
  margin: "14px 14px 0",
23
- height: 179,
24
23
  borderRadius: 18
25
24
  }), (title.text || message.text) && _jsxs(Vertical, {
26
25
  "$padding": (block.image ? '20px' : '30px') + ' 24px 0',
@@ -3,7 +3,7 @@ import { Vertical } from '@pushwoosh/kit-helpers';
3
3
  import { Handle, Sheet } from './styles';
4
4
  import { NativeRichMediaButtonList } from '../../components/NativeRichMediaButtonList';
5
5
  import { NativeRichMediaCloseChip } from '../../components/NativeRichMediaCloseChip';
6
- import { NativeRichMediaCoverImg } from '../../components/NativeRichMediaCoverImg';
6
+ import { NativeRichMediaContentImg } from '../../components/NativeRichMediaContentImg';
7
7
  import { NativeRichMediaText } from '../../components/NativeRichMediaText';
8
8
  import { NativeRichMediaTitle } from '../../components/NativeRichMediaTitle';
9
9
  import { asButtonList, asTextValue } from '../../helpers';
@@ -17,10 +17,9 @@ export function NativeRichMediaSheetView(props) {
17
17
  const message = asTextValue(block.message);
18
18
  return _jsxs(Sheet, {
19
19
  "$background": block.background,
20
- children: [_jsx(Handle, {}), block.image && _jsx(NativeRichMediaCoverImg, {
20
+ children: [_jsx(Handle, {}), block.image && _jsx(NativeRichMediaContentImg, {
21
21
  url: block.image,
22
22
  margin: "26px 14px 0",
23
- height: 190,
24
23
  borderRadius: 18
25
24
  }), (title.text || message.text) && _jsxs(Vertical, {
26
25
  "$padding": (block.image ? '16px' : '20px') + ' 24px 0',
@@ -1,6 +1,3 @@
1
- export declare const GradientOverlay: import("styled-components").StyledComponent<"div", any, {
2
- $topOffset?: string;
3
- }, never>;
4
1
  export declare const TextBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
5
2
  export declare const Card: import("styled-components").StyledComponent<"div", any, {
6
3
  $background: string;
@@ -1,18 +1,12 @@
1
1
  import styled from 'styled-components';
2
2
  import { EDGE_INSET } from '../../helpers';
3
- export const GradientOverlay = styled.div.withConfig({
4
- displayName: "GradientOverlay",
5
- componentId: "sc-x5bn03-0"
6
- })(["position:absolute;left:0;right:0;bottom:0;top:", ";background:linear-gradient(180deg,rgba(0,0,0,0),rgba(0,0,0,0.75));"], ({
7
- $topOffset
8
- }) => $topOffset ?? '45%');
9
3
  export const TextBlock = styled.div.withConfig({
10
4
  displayName: "TextBlock",
11
- componentId: "sc-x5bn03-1"
5
+ componentId: "sc-x5bn03-0"
12
6
  })(["margin:0 ", "px ", "px;"], EDGE_INSET, EDGE_INSET);
13
7
  export const Card = styled.div.withConfig({
14
8
  displayName: "Card",
15
- componentId: "sc-x5bn03-2"
9
+ componentId: "sc-x5bn03-1"
16
10
  })(["position:relative;margin:0 12px;border-radius:24px;box-shadow:0 16px 28px rgba(0,0,0,0.28);padding:", ";background:", ";"], ({
17
11
  $padding
18
12
  }) => $padding, ({
package/index.d.ts CHANGED
@@ -44,7 +44,7 @@ export { EnhancedInput, SearchInput } from './EnhancedInput';
44
44
  export { Chip, type ChipProps, type ChipVariant } from './Chip';
45
45
  export { RichmediaPreview, useRichmediaHtml } from './RichmediaPreview';
46
46
  export { SandboxedHtmlFrame, type SandboxedHtmlFrameProps, type IsolatedSandboxedHtmlFrameProps, type InspectableSandboxedHtmlFrameProps, } from './SandboxedHtmlFrame';
47
- export { NativeRichMediaPreview, parseNativeRichMediaConfig, NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './NativeRichMediaPreview';
47
+ export { NativeRichMediaPreview, parseNativeRichMediaConfig, parseLocalizationParams, NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './NativeRichMediaPreview';
48
48
  export type { NativeRichMediaConfig, NativeRichMediaDisplayType, NativeRichMediaText, NativeRichMediaBorder, NativeRichMediaCover, NativeRichMediaAction, NativeRichMediaButton, NativeRichMediaReward, NativeRichMediaModalBlock, NativeRichMediaSheetBlock, NativeRichMediaCarouselBlock, NativeRichMediaStoriesBlock, NativeRichMediaBannerBlock, NativeRichMediaFullscreenBlock, NativeRichMediaVideoBlock, NativeRichMediaPipBlock, NativeRichMediaScratchcardBlock, NativeRichMediaSpinwheelBlock, NativeRichMediaPreviewProps, NativeRichMediaLocalization, } from './NativeRichMediaPreview';
49
49
  export { RichMessageEditor, RichMessageViewer, type DynamicContent, } from './RichMessageEditor';
50
50
  export { FrequencyCappingEdit, FrequencyCappingReadonly, FrequencyCappingInApps, type LocalCapping, type CappingInAppBase, } from './FrequencyCapping';
package/index.js CHANGED
@@ -44,7 +44,7 @@ export { EnhancedInput, SearchInput } from './EnhancedInput';
44
44
  export { Chip } from './Chip';
45
45
  export { RichmediaPreview, useRichmediaHtml } from './RichmediaPreview';
46
46
  export { SandboxedHtmlFrame } from './SandboxedHtmlFrame';
47
- export { NativeRichMediaPreview, parseNativeRichMediaConfig, NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './NativeRichMediaPreview';
47
+ export { NativeRichMediaPreview, parseNativeRichMediaConfig, parseLocalizationParams, NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './NativeRichMediaPreview';
48
48
  export { RichMessageEditor, RichMessageViewer } from './RichMessageEditor';
49
49
  export { FrequencyCappingEdit, FrequencyCappingReadonly, FrequencyCappingInApps } from './FrequencyCapping';
50
50
  export { SendRateEdit, SendRateReadonly } from './SendRate';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.172",
3
+ "version": "1.1.174",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",