@pushwoosh/smart-components-kit 1.0.37 → 1.0.39
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/DynamicContentPicker/DynamicContentPicker.d.ts +2 -0
- package/DynamicContentPicker/DynamicContentPicker.js +34 -9
- package/DynamicContentPickerForm/index.d.ts +1 -0
- package/OpenActions/components/OpenActionsSummary/OpenActionsSummary.js +1 -1
- package/OpenActions/usePresetOpenActions.js +2 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -5,7 +5,9 @@ type State = Record<string, VariedDynamicContent>;
|
|
|
5
5
|
type DynamicContentPickerProps = {
|
|
6
6
|
applicationCode: string;
|
|
7
7
|
text: string;
|
|
8
|
+
icon?: ReactNode;
|
|
8
9
|
title?: string;
|
|
10
|
+
hintText?: string;
|
|
9
11
|
initState?: State;
|
|
10
12
|
error?: ReactNode;
|
|
11
13
|
renderDynamicContent?: (props: RenderDynamicContentProps) => ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { arrow, autoPlacement, offset, useFloating } from '@floating-ui/react-dom';
|
|
2
|
-
import React, { useMemo, useReducer, useRef, useState } from 'react';
|
|
2
|
+
import React, { useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
|
3
3
|
import { Color } from '@pushwoosh/kit-constants';
|
|
4
|
-
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { elementAddListener, Horizontal, usePersistentFunction } from '@pushwoosh/kit-helpers';
|
|
5
5
|
import { WarningRoundIcon } from '@pushwoosh/kit-icons';
|
|
6
6
|
import { Text } from '@pushwoosh/kit-typography';
|
|
7
7
|
import { Arrow, FieldPlace, TextPlace } from './styled';
|
|
@@ -24,7 +24,9 @@ const reducer = (state, action) => {
|
|
|
24
24
|
export const DynamicContentPicker = ({
|
|
25
25
|
applicationCode,
|
|
26
26
|
text,
|
|
27
|
+
icon,
|
|
27
28
|
title,
|
|
29
|
+
hintText,
|
|
28
30
|
initState,
|
|
29
31
|
error,
|
|
30
32
|
renderDynamicContent
|
|
@@ -50,24 +52,44 @@ export const DynamicContentPicker = ({
|
|
|
50
52
|
const parsedLines = useMemo(() => {
|
|
51
53
|
const lines = text.split('\n');
|
|
52
54
|
return lines.map(line => {
|
|
53
|
-
return line.split(
|
|
54
|
-
if (
|
|
55
|
+
return line.split(/(\{\{[^}]+\}\}|\{[^}]+\})/g).filter(match => match !== '').map(match => {
|
|
56
|
+
if (!match.includes('{')) {
|
|
55
57
|
return match;
|
|
56
58
|
}
|
|
59
|
+
const varname = match.replace(/^\{\{?/, '').replace(/\}?\}$/, '').split('|')[0].trim();
|
|
57
60
|
return {
|
|
58
|
-
varname
|
|
61
|
+
varname
|
|
59
62
|
};
|
|
60
63
|
});
|
|
61
64
|
});
|
|
62
65
|
}, [text]);
|
|
66
|
+
const onClose = () => {
|
|
67
|
+
setActiveVar(undefined);
|
|
68
|
+
};
|
|
69
|
+
const clickAwayHandler = usePersistentFunction(() => {
|
|
70
|
+
onClose();
|
|
71
|
+
});
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!activeVar) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
return elementAddListener(document, ['mousedown', 'touchstart', 'focusin'], event => {
|
|
77
|
+
if (refs.floating.current instanceof HTMLElement && !refs.floating.current.contains(event.target)) {
|
|
78
|
+
clickAwayHandler();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}, [clickAwayHandler, activeVar, refs.reference, refs.floating]);
|
|
63
82
|
return React.createElement(React.Fragment, null, React.createElement(FieldPlace, {
|
|
64
83
|
ref: refs.setReference
|
|
65
84
|
}, React.createElement(Horizontal, {
|
|
66
85
|
"$padding": "8px 16px",
|
|
67
86
|
"$justifyContent": "space-between"
|
|
68
|
-
}, React.createElement(
|
|
87
|
+
}, React.createElement(Horizontal, {
|
|
88
|
+
"$alignItems": "center",
|
|
89
|
+
"$gap": 8
|
|
90
|
+
}, icon && icon, React.createElement(Text, {
|
|
69
91
|
"$variant": "h4"
|
|
70
|
-
}, title), error && React.createElement(Horizontal, {
|
|
92
|
+
}, title)), error && React.createElement(Horizontal, {
|
|
71
93
|
"$alignItems": "center",
|
|
72
94
|
"$gap": 8
|
|
73
95
|
}, React.createElement(WarningRoundIcon, {
|
|
@@ -77,7 +99,10 @@ export const DynamicContentPicker = ({
|
|
|
77
99
|
}), React.createElement(Text, {
|
|
78
100
|
"$variant": "footnote",
|
|
79
101
|
"$color": Color.WARNING
|
|
80
|
-
}, error))
|
|
102
|
+
}, error)), !error && hintText && React.createElement(Text, {
|
|
103
|
+
"$variant": "footnote",
|
|
104
|
+
"$color": Color.LOCKED
|
|
105
|
+
}, hintText)), React.createElement(Horizontal, {
|
|
81
106
|
"$padding": "12px 16px"
|
|
82
107
|
}, React.createElement(TextPlace, null, parsedLines.map((line, index) => React.createElement(Line, {
|
|
83
108
|
key: index /* eslint-disable-line react/no-array-index-key */,
|
|
@@ -95,7 +120,7 @@ export const DynamicContentPicker = ({
|
|
|
95
120
|
key: activeVar,
|
|
96
121
|
value: newDC
|
|
97
122
|
}),
|
|
98
|
-
onClose
|
|
123
|
+
onClose,
|
|
99
124
|
update
|
|
100
125
|
}) : React.createElement(VariedDynamicContentPickerFormSmart, {
|
|
101
126
|
key: activeVar,
|
|
@@ -29,7 +29,7 @@ export const OpenActionsSummary = ({
|
|
|
29
29
|
code: applicationCode
|
|
30
30
|
}), [applicationCode]);
|
|
31
31
|
const hasCustomPlatformsDeeplink = Object.keys(platformsDeeplinkUrls).length > 0;
|
|
32
|
-
const safariUrl =
|
|
32
|
+
const safariUrl = getSafariUrl(((_applicationData$valu = applicationData.value) === null || _applicationData$valu === void 0 ? void 0 : _applicationData$valu.application) || null, safariUrlArgs ?? '');
|
|
33
33
|
const renderInfoBlock = (device, action, url = null) => React.createElement(Vertical, null, React.createElement("span", null, "For", ' ', React.createElement("strong", null, device), ' ', "subscribers:", ' ', React.createElement("strong", null, action)), url && React.createElement(LinkRow, null, React.createElement(Link, {
|
|
34
34
|
as: Tag.A,
|
|
35
35
|
rel: "noopener noreferrer",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { useToast } from '@pushwoosh/dumb-components';
|
|
3
3
|
import { useSPAContext } from '../context';
|
|
4
|
-
import { formatDeeplink } from './helpers';
|
|
4
|
+
import { formatDeeplink, isWebLink } from './helpers';
|
|
5
5
|
const WEB_PLATFORM_KEY = 0;
|
|
6
6
|
export const usePresetOpenActions = pushPreset => {
|
|
7
7
|
const [openActions, setOpenActions] = useState(undefined);
|
|
@@ -31,7 +31,7 @@ export const usePresetOpenActions = pushPreset => {
|
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
const safariUrlArgs = ((_pushPreset$localized = pushPreset.localizedProperties.default) === null || _pushPreset$localized === void 0 || (_pushPreset$localized = _pushPreset$localized.safari) === null || _pushPreset$localized === void 0 || (_pushPreset$localized = _pushPreset$localized.urlArguments) === null || _pushPreset$localized === void 0 ? void 0 : _pushPreset$localized[0]) ?? null;
|
|
34
|
-
const webPageUrl = pushPreset.url;
|
|
34
|
+
const webPageUrl = isWebLink(pushPreset.url) ? pushPreset.url : null;
|
|
35
35
|
const {
|
|
36
36
|
platformsDeeplinkUrls,
|
|
37
37
|
showRichmedia
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED