@pushwoosh/dumb-components 1.1.173 → 1.1.175
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/Calendar/CalendarMonthSlider/CalendarMonthSlider.js +1 -3
- package/NativeRichMediaPreview/helpers.d.ts +1 -0
- package/NativeRichMediaPreview/helpers.js +3 -0
- package/NativeRichMediaPreview/index.d.ts +1 -0
- package/NativeRichMediaPreview/index.js +1 -0
- package/NativeRichMediaPreview/parseLocalizationParams.d.ts +9 -0
- package/NativeRichMediaPreview/parseLocalizationParams.js +37 -0
- package/NativeRichMediaPreview/parseNativeRichMediaConfig.js +1 -3
- package/NativeRichMediaPreview/views/NativeRichMediaSpinwheelView/NativeRichMediaSpinwheelView.js +9 -12
- package/RichMessageEditor/RichMessageViewer.js +17 -26
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
|
@@ -93,9 +93,7 @@ export const CalendarMonthSlider = ({
|
|
|
93
93
|
onTransitionEnd: () => {
|
|
94
94
|
toBaseline(anchor);
|
|
95
95
|
},
|
|
96
|
-
children: panels.map((p, i) =>
|
|
97
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
98
|
-
_jsx(Panel, {
|
|
96
|
+
children: panels.map((p, i) => _jsx(Panel, {
|
|
99
97
|
children: _jsxs(Vertical, {
|
|
100
98
|
"$gap": 4,
|
|
101
99
|
children: [_jsxs(Horizontal, {
|
|
@@ -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
|
}
|
package/NativeRichMediaPreview/views/NativeRichMediaSpinwheelView/NativeRichMediaSpinwheelView.js
CHANGED
|
@@ -34,18 +34,15 @@ export function NativeRichMediaSpinwheelView(props) {
|
|
|
34
34
|
children: segs.map((s, i) => {
|
|
35
35
|
const theta = -90 + (i + 0.5) * per;
|
|
36
36
|
const label = asTextValue(s.message);
|
|
37
|
-
return (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})]
|
|
47
|
-
}, `spin-segment-${i}`)
|
|
48
|
-
);
|
|
37
|
+
return _jsxs(Fragment, {
|
|
38
|
+
children: [_jsx(Tick, {
|
|
39
|
+
"$rotate": i * per - 180
|
|
40
|
+
}), _jsx(SegmentLabel, {
|
|
41
|
+
"$color": label.color,
|
|
42
|
+
"$rotate": theta,
|
|
43
|
+
children: label.text
|
|
44
|
+
})]
|
|
45
|
+
}, `spin-segment-${i}`);
|
|
49
46
|
})
|
|
50
47
|
}), _jsx(Pointer, {}), _jsx(Hub, {
|
|
51
48
|
"$background": spinButton === null || spinButton === void 0 ? void 0 : spinButton.background,
|
|
@@ -19,36 +19,27 @@ export const RichMessageViewer = ({
|
|
|
19
19
|
return content.map((node, index) => {
|
|
20
20
|
const children = node.children.map((child, idx) => {
|
|
21
21
|
if (isElement(child) && child.type === 'dc') {
|
|
22
|
-
return (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})]
|
|
30
|
-
}, idx)
|
|
31
|
-
);
|
|
22
|
+
return _jsxs(DynamicContentRoot, {
|
|
23
|
+
children: [_jsx(DynamicContentBracket, {
|
|
24
|
+
children: '{'
|
|
25
|
+
}), "\u00A0", child.dc.tagName, "\u00A0", _jsx(DynamicContentBracket, {
|
|
26
|
+
children: '}'
|
|
27
|
+
})]
|
|
28
|
+
}, idx);
|
|
32
29
|
}
|
|
33
30
|
return child.text;
|
|
34
31
|
});
|
|
35
32
|
if (flat) {
|
|
36
|
-
return (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
children:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})]
|
|
43
|
-
}, index)
|
|
44
|
-
);
|
|
33
|
+
return _jsxs(Fragment, {
|
|
34
|
+
children: [index > 0 && ' ', _jsx("span", {
|
|
35
|
+
dir: "auto",
|
|
36
|
+
children: children
|
|
37
|
+
})]
|
|
38
|
+
}, index);
|
|
45
39
|
}
|
|
46
|
-
return (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
children: children
|
|
51
|
-
}, index)
|
|
52
|
-
);
|
|
40
|
+
return _jsx(Paragraph, {
|
|
41
|
+
dir: "auto",
|
|
42
|
+
children: children
|
|
43
|
+
}, index);
|
|
53
44
|
});
|
|
54
45
|
};
|
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.
|
|
3
|
+
"version": "1.1.175",
|
|
4
4
|
"description": "React components to build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"npm": ">= 7"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@pushwoosh/frontend-builder-engine": "^
|
|
27
|
+
"@pushwoosh/frontend-builder-engine": "^3.0.0",
|
|
28
28
|
"@svgr/webpack": "^8.1.0",
|
|
29
29
|
"@testing-library/jest-dom": "^6.9.1",
|
|
30
30
|
"@testing-library/react": "^16.3.0",
|