@pushwoosh/smart-components-kit 1.0.16 → 1.0.18
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 +6 -7
- package/DynamicContentPicker/DynamicContentPicker.js +89 -83
- package/DynamicContentPicker/Line.d.ts +10 -0
- package/DynamicContentPicker/Line.js +33 -0
- package/DynamicContentPicker/assets/arrow.svg +1 -0
- package/DynamicContentPicker/helpers.d.ts +5 -0
- package/DynamicContentPicker/helpers.js +24 -0
- package/DynamicContentPicker/index.d.ts +0 -1
- package/DynamicContentPicker/index.js +1 -2
- package/DynamicContentPicker/styled.d.ts +63 -8
- package/DynamicContentPicker/styled.js +25 -12
- package/DynamicContentPicker/types.d.ts +1 -0
- package/DynamicContentPickerForm/DynamicContentCustomPickerForm.d.ts +8 -0
- package/DynamicContentPickerForm/DynamicContentCustomPickerForm.js +22 -0
- package/DynamicContentPickerForm/DynamicContentEventPickerForm.d.ts +10 -0
- package/DynamicContentPickerForm/DynamicContentEventPickerForm.js +63 -0
- package/DynamicContentPickerForm/DynamicContentTagPickerForm.d.ts +10 -0
- package/DynamicContentPickerForm/DynamicContentTagPickerForm.js +63 -0
- package/DynamicContentPickerForm/SimpleDynamicContentPickerFormSmart.d.ts +9 -0
- package/DynamicContentPickerForm/SimpleDynamicContentPickerFormSmart.js +88 -0
- package/DynamicContentPickerForm/VariedDynamicContentPickerFormSmart.d.ts +11 -0
- package/DynamicContentPickerForm/VariedDynamicContentPickerFormSmart.js +111 -0
- package/DynamicContentPickerForm/hooks.d.ts +39 -0
- package/{DynamicContentPicker → DynamicContentPickerForm}/hooks.js +18 -0
- package/DynamicContentPickerForm/index.d.ts +2 -0
- package/DynamicContentPickerForm/index.js +2 -0
- package/DynamicContentPickerForm/styled.d.ts +64 -0
- package/DynamicContentPickerForm/styled.js +14 -0
- package/DynamicContentPickerForm/types.d.ts +27 -0
- package/DynamicContentPickerForm/types.js +1 -0
- package/DynamicContentPickerForm/utils.d.ts +2 -0
- package/DynamicContentPickerForm/utils.js +29 -0
- package/RichMessageEditorSmart/NewDynamicContentForm.js +2 -2
- package/RichMessageEditorSmart/RichMessageEditorSmart.js +2 -2
- package/_devel/lib/dynamic-content-picker.js +2 -2
- package/context/types.d.ts +1 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +4 -3
- package/DynamicContentPicker/DynamicContentPicker.types.d.ts +0 -4
- package/DynamicContentPicker/hooks.d.ts +0 -20
- /package/DynamicContentPicker/{DynamicContentPicker.types.js → types.js} +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { type FC
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
update?: () => void;
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
type DynamicContentPickerProps = {
|
|
3
|
+
applicationCode: string;
|
|
4
|
+
text: string;
|
|
5
|
+
title?: string;
|
|
7
6
|
};
|
|
8
|
-
export declare const DynamicContentPicker: FC<
|
|
7
|
+
export declare const DynamicContentPicker: FC<DynamicContentPickerProps>;
|
|
9
8
|
export {};
|
|
@@ -1,88 +1,94 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { Horizontal
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { arrow, autoPlacement, offset, useFloating } from '@floating-ui/react-dom';
|
|
2
|
+
import React, { useMemo, useReducer, useRef, useState } from 'react';
|
|
3
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
5
|
+
import { Arrow, FieldPlace, TextPlace } from './styled';
|
|
6
|
+
import { VariedDynamicContentPickerFormSmart } from '../DynamicContentPickerForm/VariedDynamicContentPickerFormSmart';
|
|
7
|
+
import ArrowIcon from './assets/arrow.svg';
|
|
8
|
+
import { placementToDirection } from './helpers';
|
|
9
|
+
import { Line } from './Line';
|
|
10
|
+
const initialState = {};
|
|
11
|
+
const reducer = (state, action) => {
|
|
12
|
+
switch (action.type) {
|
|
13
|
+
case 'set':
|
|
14
|
+
return {
|
|
15
|
+
...state,
|
|
16
|
+
[action.key]: action.value
|
|
17
|
+
};
|
|
18
|
+
default:
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
10
21
|
};
|
|
11
22
|
export const DynamicContentPicker = ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
children
|
|
23
|
+
applicationCode,
|
|
24
|
+
text,
|
|
25
|
+
title
|
|
16
26
|
}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
label: dc.tagName
|
|
46
|
-
},
|
|
47
|
-
onChange: option => {
|
|
48
|
-
onChange({
|
|
49
|
-
tagName: option.value,
|
|
50
|
-
modifier: currentTag.modifiers[0],
|
|
51
|
-
defaultValue: ''
|
|
27
|
+
var _middlewareData$arrow, _middlewareData$arrow2;
|
|
28
|
+
const arrowRef = useRef(null);
|
|
29
|
+
const [activeVar, setActiveVar] = useState();
|
|
30
|
+
const {
|
|
31
|
+
refs,
|
|
32
|
+
floatingStyles,
|
|
33
|
+
update,
|
|
34
|
+
middlewareData,
|
|
35
|
+
placement
|
|
36
|
+
} = useFloating({
|
|
37
|
+
strategy: 'fixed',
|
|
38
|
+
middleware: [offset(8), autoPlacement({
|
|
39
|
+
allowedPlacements: ['left', 'left-start', 'left-end', 'right', 'right-start', 'right-end']
|
|
40
|
+
}), arrow({
|
|
41
|
+
element: arrowRef
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
const [state, dispatch] = useReducer(reducer, initialState);
|
|
45
|
+
const parsedLines = useMemo(() => {
|
|
46
|
+
const lines = text.split('\n');
|
|
47
|
+
return lines.map(line => {
|
|
48
|
+
return line.split(/\{\{(\d+)}}/g).map((match, index) => {
|
|
49
|
+
if (index % 2 === 0) {
|
|
50
|
+
return match;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
varname: match
|
|
54
|
+
};
|
|
52
55
|
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
});
|
|
57
|
+
}, [text]);
|
|
58
|
+
return React.createElement(React.Fragment, null, React.createElement(FieldPlace, {
|
|
59
|
+
ref: refs.setReference
|
|
60
|
+
}, React.createElement(Horizontal, {
|
|
61
|
+
"$padding": "8px 16px"
|
|
62
|
+
}, React.createElement(Text, {
|
|
63
|
+
"$variant": "h4"
|
|
64
|
+
}, title)), React.createElement(Horizontal, {
|
|
65
|
+
"$padding": "12px 16px"
|
|
66
|
+
}, React.createElement(TextPlace, null, parsedLines.map((line, index) => React.createElement(Line, {
|
|
67
|
+
key: index /* eslint-disable-line react/no-array-index-key */,
|
|
68
|
+
activeVar: activeVar,
|
|
69
|
+
line: line,
|
|
70
|
+
state: state,
|
|
71
|
+
onClickVar: setActiveVar
|
|
72
|
+
}))))), !!activeVar && React.createElement("div", {
|
|
73
|
+
ref: refs.setFloating,
|
|
74
|
+
style: floatingStyles
|
|
75
|
+
}, React.createElement(VariedDynamicContentPickerFormSmart, {
|
|
76
|
+
key: activeVar,
|
|
77
|
+
applicationCode: applicationCode,
|
|
78
|
+
initialDc: state[activeVar],
|
|
79
|
+
onChange: newDc => dispatch({
|
|
80
|
+
type: 'set',
|
|
81
|
+
key: activeVar,
|
|
82
|
+
value: newDc
|
|
83
|
+
}),
|
|
84
|
+
onClose: () => setActiveVar(undefined),
|
|
85
|
+
update: update
|
|
86
|
+
}), React.createElement(Arrow, {
|
|
87
|
+
"$direction": placementToDirection(placement),
|
|
88
|
+
ref: arrowRef,
|
|
89
|
+
style: {
|
|
90
|
+
left: (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x,
|
|
91
|
+
top: (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y
|
|
92
|
+
}
|
|
93
|
+
}, React.createElement(ArrowIcon, null))));
|
|
88
94
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import type { VariedDynamicContent } from '../DynamicContentPickerForm/types';
|
|
3
|
+
export declare const Line: FC<{
|
|
4
|
+
activeVar?: string;
|
|
5
|
+
line: (string | {
|
|
6
|
+
varname: string;
|
|
7
|
+
})[];
|
|
8
|
+
state: Record<string, VariedDynamicContent>;
|
|
9
|
+
onClickVar: (key: string) => void;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Chip } from '@pushwoosh/dumb-components';
|
|
3
|
+
import { WarningRoundIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
import { dc2text } from './helpers';
|
|
5
|
+
export const Line = ({
|
|
6
|
+
activeVar,
|
|
7
|
+
line,
|
|
8
|
+
state,
|
|
9
|
+
onClickVar
|
|
10
|
+
}) => {
|
|
11
|
+
return React.createElement("p", null, line.map((item, index) => {
|
|
12
|
+
if (typeof item === 'string') {
|
|
13
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
14
|
+
return React.createElement("span", {
|
|
15
|
+
key: index
|
|
16
|
+
}, item);
|
|
17
|
+
}
|
|
18
|
+
return React.createElement(Chip, {
|
|
19
|
+
key: index /* eslint-disable-line react/no-array-index-key */,
|
|
20
|
+
as: "span",
|
|
21
|
+
"$variant": state[item.varname] ? 'primary' : 'warning',
|
|
22
|
+
"$selected": activeVar === item.varname,
|
|
23
|
+
onClick: () => {
|
|
24
|
+
onClickVar(item.varname);
|
|
25
|
+
}
|
|
26
|
+
}, state[item.varname] ? dc2text(state[item.varname]) : React.createElement(WarningRoundIcon, {
|
|
27
|
+
size: "small",
|
|
28
|
+
view: "lined",
|
|
29
|
+
as: "span",
|
|
30
|
+
onClick: () => onClickVar(item.varname)
|
|
31
|
+
}));
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="20" fill="none"><mask id="a" fill="#fff"><path fill-rule="evenodd" d="M0 2a2 2 0 0 1 4 0v1.26a2 2 0 0 0 .598 1.426L8.55 8.574a2 2 0 0 1 0 2.852l-3.953 3.888A2 2 0 0 0 4 16.74V18a2 2 0 1 1-4 0z" clip-rule="evenodd"/></mask><path fill="#F7F9FA" fill-rule="evenodd" d="M0 2a2 2 0 0 1 4 0v1.26a2 2 0 0 0 .598 1.426L8.55 8.574a2 2 0 0 1 0 2.852l-3.953 3.888A2 2 0 0 0 4 16.74V18a2 2 0 1 1-4 0z" clip-rule="evenodd"/><path fill="#DCE1E5" d="m4.598 15.314.7.713zM3 3.26V2h2v1.26zm4.85 6.027L3.896 5.4 5.3 3.973 9.252 7.86zm-3.954 5.314 3.954-3.888 1.402 1.426L5.3 16.027zM3 18v-1.26h2V18zM1 2v16h-2V2zm1 19a3 3 0 0 1-3-3h2a1 1 0 0 0 1 1zm3-3a3 3 0 0 1-3 3v-2a1 1 0 0 0 1-1zm.299-1.973A1 1 0 0 0 5 16.74H3a3 3 0 0 1 .896-2.138L5.3 16.026zm3.953-8.166a3 3 0 0 1 0 4.278L7.85 10.713a1 1 0 0 0 0-1.426zM5 3.26a1 1 0 0 0 .299.713L3.896 5.399A3 3 0 0 1 3 3.259zM2 1a1 1 0 0 0-1 1h-2a3 3 0 0 1 3-3zm0-2a3 3 0 0 1 3 3H3a1 1 0 0 0-1-1z" mask="url(#a)"/><path stroke="#F7F9FA" stroke-width="3" d="M1.5 0v20"/></svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Placement } from '@floating-ui/react-dom';
|
|
2
|
+
import type { ArrowDirection } from './types';
|
|
3
|
+
import type { VariedDynamicContent } from '../DynamicContentPickerForm/types';
|
|
4
|
+
export declare function placementToDirection(placement: Placement): ArrowDirection;
|
|
5
|
+
export declare function dc2text(dc: VariedDynamicContent): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function placementToDirection(placement) {
|
|
2
|
+
if (placement.startsWith('left')) {
|
|
3
|
+
return 'right';
|
|
4
|
+
}
|
|
5
|
+
if (placement.startsWith('right')) {
|
|
6
|
+
return 'left';
|
|
7
|
+
}
|
|
8
|
+
if (placement.startsWith('top')) {
|
|
9
|
+
return 'bottom';
|
|
10
|
+
}
|
|
11
|
+
return 'top';
|
|
12
|
+
}
|
|
13
|
+
export function dc2text(dc) {
|
|
14
|
+
if (dc.kind === 'tag') {
|
|
15
|
+
return dc.dc.tagName;
|
|
16
|
+
}
|
|
17
|
+
if (dc.kind === 'event') {
|
|
18
|
+
return dc.dc.attribute;
|
|
19
|
+
}
|
|
20
|
+
if (dc.kind === 'customText') {
|
|
21
|
+
return dc.dc.text;
|
|
22
|
+
}
|
|
23
|
+
return '🤷';
|
|
24
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { DynamicContentPicker } from './DynamicContentPicker';
|
|
2
|
-
export * from './hooks';
|
|
1
|
+
export { DynamicContentPicker } from './DynamicContentPicker';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
1
|
+
import { type ArrowDirection } from './types';
|
|
2
|
+
export declare const FieldPlace: import("styled-components").StyledComponent<"div", any, {
|
|
3
3
|
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
4
4
|
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
5
5
|
$bgColor?: string | undefined;
|
|
@@ -54,10 +54,65 @@ export declare const TagPickerDiv: import("styled-components").StyledComponent<"
|
|
|
54
54
|
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
55
55
|
} & {
|
|
56
56
|
$gridAutoFlow: string;
|
|
57
|
+
}, "$gridAutoFlow">;
|
|
58
|
+
export declare const TextPlace: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
59
|
+
export declare const Arrow: import("styled-components").StyledComponent<"div", any, {
|
|
60
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
61
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
62
|
+
$bgColor?: string | undefined;
|
|
63
|
+
$border?: string | ({
|
|
64
|
+
top?: string | undefined;
|
|
65
|
+
right?: string | undefined;
|
|
66
|
+
bottom?: string | undefined;
|
|
67
|
+
left?: string | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
horizontal: string;
|
|
70
|
+
top?: string | undefined;
|
|
71
|
+
bottom?: string | undefined;
|
|
72
|
+
} | {
|
|
73
|
+
vertical: string;
|
|
74
|
+
right?: string | undefined;
|
|
75
|
+
left?: string | undefined;
|
|
76
|
+
}) | undefined;
|
|
77
|
+
$borderRadius?: (string | number) | undefined;
|
|
78
|
+
$boxShadow?: string | undefined;
|
|
79
|
+
$gap?: (string | number) | undefined;
|
|
80
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
81
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
82
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
83
|
+
$margin?: (string | number) | ({
|
|
84
|
+
top?: (string | number) | undefined;
|
|
85
|
+
right?: (string | number) | undefined;
|
|
86
|
+
bottom?: (string | number) | undefined;
|
|
87
|
+
left?: (string | number) | undefined;
|
|
88
|
+
} | {
|
|
89
|
+
horizontal: string | number;
|
|
90
|
+
top?: (string | number) | undefined;
|
|
91
|
+
bottom?: (string | number) | undefined;
|
|
92
|
+
} | {
|
|
93
|
+
vertical: string | number;
|
|
94
|
+
right?: (string | number) | undefined;
|
|
95
|
+
left?: (string | number) | undefined;
|
|
96
|
+
}) | undefined;
|
|
97
|
+
$padding?: (string | number) | ({
|
|
98
|
+
top?: (string | number) | undefined;
|
|
99
|
+
right?: (string | number) | undefined;
|
|
100
|
+
bottom?: (string | number) | undefined;
|
|
101
|
+
left?: (string | number) | undefined;
|
|
102
|
+
} | {
|
|
103
|
+
horizontal: string | number;
|
|
104
|
+
top?: (string | number) | undefined;
|
|
105
|
+
bottom?: (string | number) | undefined;
|
|
106
|
+
} | {
|
|
107
|
+
vertical: string | number;
|
|
108
|
+
right?: (string | number) | undefined;
|
|
109
|
+
left?: (string | number) | undefined;
|
|
110
|
+
}) | undefined;
|
|
111
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
112
|
+
} & {
|
|
113
|
+
$gridAutoFlow: string;
|
|
114
|
+
} & {
|
|
115
|
+
$placeItems: string;
|
|
57
116
|
} & {
|
|
58
|
-
$
|
|
59
|
-
|
|
60
|
-
$borderRadius: ShapeRadius;
|
|
61
|
-
$bgColor: Color;
|
|
62
|
-
$boxShadow: Shadow;
|
|
63
|
-
}, "$gridAutoFlow" | "$bgColor" | "$borderRadius" | "$boxShadow" | "$gap" | "$padding">;
|
|
117
|
+
$direction: ArrowDirection;
|
|
118
|
+
}, "$gridAutoFlow" | "$placeItems">;
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
$gap: 16,
|
|
7
|
-
$padding: 16,
|
|
8
|
-
$borderRadius: ShapeRadius.CONTROL,
|
|
9
|
-
$bgColor: Color.FROZEN,
|
|
10
|
-
$boxShadow: Shadow.REGULAR
|
|
11
|
-
}).withConfig({
|
|
12
|
-
displayName: "TagPickerDiv",
|
|
2
|
+
import { Color, FontSize, FontWeight, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
export const FieldPlace = styled(Vertical).withConfig({
|
|
5
|
+
displayName: "FieldPlace",
|
|
13
6
|
componentId: "sc-1blii2o-0"
|
|
14
|
-
})(["
|
|
7
|
+
})(["border:1px solid ", ";border-radius:", ";& > div:first-child{background-color:", ";}"], Color.DIVIDER, ShapeRadius.SECTION, Color.SOFT_LIGHT);
|
|
8
|
+
export const TextPlace = styled.div.withConfig({
|
|
9
|
+
displayName: "TextPlace",
|
|
10
|
+
componentId: "sc-1blii2o-1"
|
|
11
|
+
})(["font-weight:", ";font-size:", ";line-height:140%;& > p{margin:4px 0;vertical-align:center;svg{vertical-align:middle;}&:first-child{margin-top:0;}&:last-child{margin-bottom:0;}}"], FontWeight.REGULAR, FontSize.REGULAR);
|
|
12
|
+
const transforms = {
|
|
13
|
+
left: 'scaleX(-1)',
|
|
14
|
+
right: 'scaleX(1)',
|
|
15
|
+
top: 'rotate(-90deg)',
|
|
16
|
+
bottom: 'rotate(90deg)'
|
|
17
|
+
};
|
|
18
|
+
export const Arrow = styled(Horizontal).attrs({
|
|
19
|
+
$placeItems: 'center'
|
|
20
|
+
}).withConfig({
|
|
21
|
+
displayName: "Arrow",
|
|
22
|
+
componentId: "sc-1blii2o-2"
|
|
23
|
+
})(["position:absolute;width:20px;height:20px;transform:", " translateX(11px);", ":0;"], ({
|
|
24
|
+
$direction
|
|
25
|
+
}) => transforms[$direction], ({
|
|
26
|
+
$direction
|
|
27
|
+
}) => $direction);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ArrowDirection = 'top' | 'bottom' | 'left' | 'right';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type CustomTextDynamicContent } from './types';
|
|
3
|
+
type DynamicContentCustomPickerFormProps = {
|
|
4
|
+
dc: CustomTextDynamicContent['dc'];
|
|
5
|
+
onChange: (dc: CustomTextDynamicContent['dc']) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const DynamicContentCustomPickerForm: FC<DynamicContentCustomPickerFormProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeTextarea } from '@pushwoosh/dumb-components';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
export const DynamicContentCustomPickerForm = ({
|
|
5
|
+
dc,
|
|
6
|
+
onChange
|
|
7
|
+
}) => {
|
|
8
|
+
return React.createElement(Vertical, {
|
|
9
|
+
"$gap": 16
|
|
10
|
+
}, React.createElement(NativeTextarea, {
|
|
11
|
+
value: dc.text,
|
|
12
|
+
onChange: e => {
|
|
13
|
+
onChange({
|
|
14
|
+
text: e.target.value
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
placeholder: "Enter custom text",
|
|
18
|
+
style: {
|
|
19
|
+
minHeight: 200
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type Event } from '@pushwoosh/rpc-v2-http-api-data/events';
|
|
3
|
+
import { type EventDynamicContent } from './types';
|
|
4
|
+
type DynamicContentEventPickerFormProps = {
|
|
5
|
+
dc: EventDynamicContent['dc'];
|
|
6
|
+
events: Event[];
|
|
7
|
+
onChange: (dc: EventDynamicContent['dc']) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const DynamicContentEventPickerForm: FC<DynamicContentEventPickerFormProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldBox, NativeInput, Select } from '@pushwoosh/dumb-components';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
export const DynamicContentEventPickerForm = ({
|
|
5
|
+
dc,
|
|
6
|
+
events,
|
|
7
|
+
onChange
|
|
8
|
+
}) => {
|
|
9
|
+
const currentEvent = events.find(tag => tag.name === dc.eventName) || {
|
|
10
|
+
name: '',
|
|
11
|
+
attributes: []
|
|
12
|
+
};
|
|
13
|
+
return React.createElement(Vertical, {
|
|
14
|
+
"$gap": 16
|
|
15
|
+
}, React.createElement(Select, {
|
|
16
|
+
value: {
|
|
17
|
+
value: dc.eventName,
|
|
18
|
+
label: dc.eventName
|
|
19
|
+
},
|
|
20
|
+
onChange: option => {
|
|
21
|
+
onChange({
|
|
22
|
+
eventName: option.value,
|
|
23
|
+
attribute: '',
|
|
24
|
+
defaultValue: ''
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
options: events.map(event => ({
|
|
28
|
+
value: event.name,
|
|
29
|
+
label: event.name
|
|
30
|
+
})),
|
|
31
|
+
placeholder: "Select an event"
|
|
32
|
+
}), React.createElement(FieldBox, {
|
|
33
|
+
title: "Attribute"
|
|
34
|
+
}, React.createElement(Select, {
|
|
35
|
+
value: {
|
|
36
|
+
value: dc.attribute,
|
|
37
|
+
label: dc.attribute
|
|
38
|
+
},
|
|
39
|
+
onChange: option => {
|
|
40
|
+
onChange({
|
|
41
|
+
...dc,
|
|
42
|
+
attribute: option.value
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
options: currentEvent.attributes.map(attr => ({
|
|
46
|
+
value: attr.name,
|
|
47
|
+
label: attr.name
|
|
48
|
+
})),
|
|
49
|
+
isDisabled: !currentEvent.name
|
|
50
|
+
})), React.createElement(FieldBox, {
|
|
51
|
+
title: "Fallback text",
|
|
52
|
+
isOptional: true
|
|
53
|
+
}, React.createElement(NativeInput, {
|
|
54
|
+
value: dc.defaultValue,
|
|
55
|
+
onChange: e => {
|
|
56
|
+
onChange({
|
|
57
|
+
...dc,
|
|
58
|
+
defaultValue: e.target.value
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
disabled: !currentEvent.name
|
|
62
|
+
})));
|
|
63
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from 'react';
|
|
2
|
+
import { type DynamicContent } from '@pushwoosh/dumb-components/RichMessageEditor/slate/types';
|
|
3
|
+
import { type FullTagData } from './types';
|
|
4
|
+
type DynamicContentTagPickerFormProps = {
|
|
5
|
+
dc: DynamicContent;
|
|
6
|
+
tags: FullTagData[];
|
|
7
|
+
onChange: (dc: DynamicContent) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const DynamicContentTagPickerForm: FC<PropsWithChildren<DynamicContentTagPickerFormProps>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldBox, NativeInput, Select } from '@pushwoosh/dumb-components';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
export const DynamicContentTagPickerForm = ({
|
|
5
|
+
dc,
|
|
6
|
+
tags,
|
|
7
|
+
onChange
|
|
8
|
+
}) => {
|
|
9
|
+
const currentTag = tags.find(tag => tag.name === dc.tagName) || {
|
|
10
|
+
name: '',
|
|
11
|
+
modifiers: ['regular']
|
|
12
|
+
};
|
|
13
|
+
return React.createElement(Vertical, {
|
|
14
|
+
"$gap": 16
|
|
15
|
+
}, React.createElement(Select, {
|
|
16
|
+
value: {
|
|
17
|
+
value: dc.tagName,
|
|
18
|
+
label: dc.tagName
|
|
19
|
+
},
|
|
20
|
+
onChange: option => {
|
|
21
|
+
onChange({
|
|
22
|
+
tagName: option.value,
|
|
23
|
+
modifier: currentTag.modifiers[0],
|
|
24
|
+
defaultValue: ''
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
options: tags.map(tag => ({
|
|
28
|
+
value: tag.name,
|
|
29
|
+
label: tag.name
|
|
30
|
+
})),
|
|
31
|
+
placeholder: "Select a tag"
|
|
32
|
+
}), React.createElement(FieldBox, {
|
|
33
|
+
title: "Modifier"
|
|
34
|
+
}, React.createElement(Select, {
|
|
35
|
+
value: {
|
|
36
|
+
value: dc.modifier,
|
|
37
|
+
label: dc.modifier
|
|
38
|
+
},
|
|
39
|
+
onChange: option => {
|
|
40
|
+
onChange({
|
|
41
|
+
...dc,
|
|
42
|
+
modifier: option.value
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
options: currentTag.modifiers.map(modifier => ({
|
|
46
|
+
value: modifier,
|
|
47
|
+
label: modifier
|
|
48
|
+
})),
|
|
49
|
+
isDisabled: !currentTag.name
|
|
50
|
+
})), React.createElement(FieldBox, {
|
|
51
|
+
title: "Fallback text",
|
|
52
|
+
isOptional: true
|
|
53
|
+
}, React.createElement(NativeInput, {
|
|
54
|
+
value: dc.defaultValue,
|
|
55
|
+
onChange: e => {
|
|
56
|
+
onChange({
|
|
57
|
+
...dc,
|
|
58
|
+
defaultValue: e.target.value
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
disabled: !currentTag.name
|
|
62
|
+
})));
|
|
63
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from 'react';
|
|
2
|
+
import { type DynamicContent } from '@pushwoosh/dumb-components/RichMessageEditor/slate/types';
|
|
3
|
+
type SimpleDynamicContentPickerFormSmartProps = {
|
|
4
|
+
dc?: DynamicContent;
|
|
5
|
+
onChange: (dc: DynamicContent) => void;
|
|
6
|
+
update?: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const SimpleDynamicContentPickerFormSmart: FC<PropsWithChildren<SimpleDynamicContentPickerFormSmartProps>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { FieldBox, NativeInput, Select, Spinner } from '@pushwoosh/dumb-components';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { useDynamicContentTags } from './hooks';
|
|
5
|
+
import { TagPickerDiv } from './styled';
|
|
6
|
+
const defaultDynamicContent = {
|
|
7
|
+
tagName: '',
|
|
8
|
+
modifier: 'regular',
|
|
9
|
+
defaultValue: ''
|
|
10
|
+
};
|
|
11
|
+
export const SimpleDynamicContentPickerFormSmart = ({
|
|
12
|
+
dc = defaultDynamicContent,
|
|
13
|
+
onChange,
|
|
14
|
+
update,
|
|
15
|
+
children
|
|
16
|
+
}) => {
|
|
17
|
+
const asyncResult = useDynamicContentTags();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!asyncResult.loading) {
|
|
20
|
+
update === null || update === void 0 || update();
|
|
21
|
+
}
|
|
22
|
+
}, [asyncResult.loading, update]);
|
|
23
|
+
if (asyncResult.loading) {
|
|
24
|
+
return React.createElement(TagPickerDiv, null, React.createElement(Horizontal, {
|
|
25
|
+
"$placeItems": "center",
|
|
26
|
+
"$padding": 36
|
|
27
|
+
}, React.createElement(Spinner, {
|
|
28
|
+
size: "medium"
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
const tags = asyncResult.value || [];
|
|
32
|
+
const currentTag = tags.find(tag => tag.name === dc.tagName) || {
|
|
33
|
+
name: '',
|
|
34
|
+
modifiers: ['regular']
|
|
35
|
+
};
|
|
36
|
+
return React.createElement(TagPickerDiv, null, React.createElement(FieldBox, {
|
|
37
|
+
title: "Tag"
|
|
38
|
+
}, React.createElement(Vertical, {
|
|
39
|
+
"$gap": 8
|
|
40
|
+
}, React.createElement(Select, {
|
|
41
|
+
width: "auto",
|
|
42
|
+
menuPlacement: "auto",
|
|
43
|
+
value: {
|
|
44
|
+
value: dc.tagName,
|
|
45
|
+
label: dc.tagName
|
|
46
|
+
},
|
|
47
|
+
onChange: option => {
|
|
48
|
+
onChange({
|
|
49
|
+
tagName: option.value,
|
|
50
|
+
modifier: currentTag.modifiers[0],
|
|
51
|
+
defaultValue: ''
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
options: tags.map(tag => ({
|
|
55
|
+
value: tag.name,
|
|
56
|
+
label: tag.name
|
|
57
|
+
}))
|
|
58
|
+
}), React.createElement(Select, {
|
|
59
|
+
width: "auto",
|
|
60
|
+
menuPlacement: "auto",
|
|
61
|
+
value: {
|
|
62
|
+
value: dc.modifier,
|
|
63
|
+
label: dc.modifier
|
|
64
|
+
},
|
|
65
|
+
onChange: option => {
|
|
66
|
+
onChange({
|
|
67
|
+
...dc,
|
|
68
|
+
modifier: option.value
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
options: currentTag.modifiers.map(modifier => ({
|
|
72
|
+
value: modifier,
|
|
73
|
+
label: modifier
|
|
74
|
+
})),
|
|
75
|
+
isDisabled: !currentTag.name
|
|
76
|
+
}))), React.createElement(FieldBox, {
|
|
77
|
+
title: "Default Tag Value"
|
|
78
|
+
}, React.createElement(NativeInput, {
|
|
79
|
+
value: dc.defaultValue,
|
|
80
|
+
onChange: e => {
|
|
81
|
+
onChange({
|
|
82
|
+
...dc,
|
|
83
|
+
defaultValue: e.target.value
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
disabled: !currentTag.name
|
|
87
|
+
})), children);
|
|
88
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type VariedDynamicContent } from './types';
|
|
3
|
+
type VariedDynamicContentFormSmartProps = {
|
|
4
|
+
applicationCode: string;
|
|
5
|
+
initialDc?: VariedDynamicContent;
|
|
6
|
+
onChange: (dc: VariedDynamicContent) => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
update: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const VariedDynamicContentPickerFormSmart: FC<VariedDynamicContentFormSmartProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button, FieldBox, Select, Spinner } from '@pushwoosh/dumb-components';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { DynamicContentCustomPickerForm } from './DynamicContentCustomPickerForm';
|
|
5
|
+
import { DynamicContentEventPickerForm } from './DynamicContentEventPickerForm';
|
|
6
|
+
import { DynamicContentTagPickerForm } from './DynamicContentTagPickerForm';
|
|
7
|
+
import { useVariedDynamicContentTags } from './hooks';
|
|
8
|
+
import { TagPickerDiv } from './styled';
|
|
9
|
+
import { createDefaultDynamicContent } from './utils';
|
|
10
|
+
const defaultVariedDynamicContent = {
|
|
11
|
+
kind: 'tag',
|
|
12
|
+
dc: {
|
|
13
|
+
tagName: '',
|
|
14
|
+
modifier: 'regular',
|
|
15
|
+
defaultValue: ''
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const kindsOptions = [{
|
|
19
|
+
value: 'tag',
|
|
20
|
+
label: 'Tag'
|
|
21
|
+
}, {
|
|
22
|
+
value: 'event',
|
|
23
|
+
label: 'Event'
|
|
24
|
+
}, {
|
|
25
|
+
value: 'customText',
|
|
26
|
+
label: 'Custom Text'
|
|
27
|
+
}];
|
|
28
|
+
export const VariedDynamicContentPickerFormSmart = ({
|
|
29
|
+
applicationCode,
|
|
30
|
+
initialDc = defaultVariedDynamicContent,
|
|
31
|
+
onChange,
|
|
32
|
+
onClose,
|
|
33
|
+
update
|
|
34
|
+
}) => {
|
|
35
|
+
var _kindsOptions$find;
|
|
36
|
+
const [vdc, setVdc] = useState(initialDc);
|
|
37
|
+
const asyncResult = useVariedDynamicContentTags(applicationCode);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
update();
|
|
40
|
+
}, [asyncResult.loading, update]);
|
|
41
|
+
if (asyncResult.loading) {
|
|
42
|
+
return React.createElement(TagPickerDiv, null, React.createElement(Horizontal, {
|
|
43
|
+
"$placeItems": "center",
|
|
44
|
+
"$padding": 36
|
|
45
|
+
}, React.createElement(Spinner, {
|
|
46
|
+
size: "medium"
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
49
|
+
const isValidDc = vdc.kind === 'tag' && vdc.dc.tagName !== '' && vdc.dc.modifier !== '' || vdc.kind === 'event' && vdc.dc.eventName !== '' && vdc.dc.attribute !== '' || vdc.kind === 'customText' && vdc.dc.text !== '';
|
|
50
|
+
return React.createElement(TagPickerDiv, null, React.createElement(Vertical, {
|
|
51
|
+
"$gap": 8
|
|
52
|
+
}, React.createElement(FieldBox, {
|
|
53
|
+
title: "Variable Type"
|
|
54
|
+
}, React.createElement(Vertical, {
|
|
55
|
+
"$gap": 8
|
|
56
|
+
}, React.createElement(Select, {
|
|
57
|
+
width: "auto",
|
|
58
|
+
menuPlacement: "auto",
|
|
59
|
+
value: {
|
|
60
|
+
value: vdc.kind,
|
|
61
|
+
label: (_kindsOptions$find = kindsOptions.find(o => o.value === vdc.kind)) === null || _kindsOptions$find === void 0 ? void 0 : _kindsOptions$find.label
|
|
62
|
+
},
|
|
63
|
+
onChange: option => {
|
|
64
|
+
const newDc = createDefaultDynamicContent(option.value);
|
|
65
|
+
setVdc(newDc);
|
|
66
|
+
update();
|
|
67
|
+
},
|
|
68
|
+
options: kindsOptions
|
|
69
|
+
}))), vdc.kind === 'tag' && React.createElement(DynamicContentTagPickerForm, {
|
|
70
|
+
dc: vdc.dc,
|
|
71
|
+
tags: asyncResult.value[0],
|
|
72
|
+
onChange: newDc => {
|
|
73
|
+
setVdc({
|
|
74
|
+
...vdc,
|
|
75
|
+
dc: newDc
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}), vdc.kind === 'event' && React.createElement(DynamicContentEventPickerForm, {
|
|
79
|
+
dc: vdc.dc,
|
|
80
|
+
events: asyncResult.value[1],
|
|
81
|
+
onChange: newDc => {
|
|
82
|
+
setVdc({
|
|
83
|
+
...vdc,
|
|
84
|
+
dc: newDc
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}), vdc.kind === 'customText' && React.createElement(DynamicContentCustomPickerForm, {
|
|
88
|
+
dc: vdc.dc,
|
|
89
|
+
onChange: newDc => {
|
|
90
|
+
setVdc({
|
|
91
|
+
...vdc,
|
|
92
|
+
dc: newDc
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
})), React.createElement(Horizontal, {
|
|
96
|
+
"$justifyContent": "end",
|
|
97
|
+
"$gap": 8
|
|
98
|
+
}, React.createElement(Button, {
|
|
99
|
+
color: "secondary",
|
|
100
|
+
size: "compact",
|
|
101
|
+
onClick: onClose
|
|
102
|
+
}, "Cancel"), React.createElement(Button, {
|
|
103
|
+
color: "primary",
|
|
104
|
+
size: "compact",
|
|
105
|
+
onClick: () => {
|
|
106
|
+
onChange(vdc);
|
|
107
|
+
onClose();
|
|
108
|
+
},
|
|
109
|
+
isDisabled: !isValidDc
|
|
110
|
+
}, "Apply")));
|
|
111
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Event } from '@pushwoosh/rpc-v2-http-api-data/events';
|
|
2
|
+
import { type SPAContextType } from '../context';
|
|
3
|
+
import { type FullTagData } from './types';
|
|
4
|
+
export declare function fetchDynamicContentTags(context: SPAContextType): Promise<FullTagData[]>;
|
|
5
|
+
export declare function useDynamicContentTags(): {
|
|
6
|
+
loading: boolean;
|
|
7
|
+
error?: undefined;
|
|
8
|
+
value?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
loading: false;
|
|
11
|
+
error: Error;
|
|
12
|
+
value?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
loading: true;
|
|
15
|
+
error?: Error | undefined;
|
|
16
|
+
value?: FullTagData[] | undefined;
|
|
17
|
+
} | {
|
|
18
|
+
loading: false;
|
|
19
|
+
error?: undefined;
|
|
20
|
+
value: FullTagData[];
|
|
21
|
+
};
|
|
22
|
+
export declare function fetchDynamicContentEvents(context: SPAContextType, application: string): Promise<Event[]>;
|
|
23
|
+
export declare function useVariedDynamicContentTags(application: string): {
|
|
24
|
+
loading: boolean;
|
|
25
|
+
error?: undefined;
|
|
26
|
+
value?: undefined;
|
|
27
|
+
} | {
|
|
28
|
+
loading: false;
|
|
29
|
+
error: Error;
|
|
30
|
+
value?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
loading: true;
|
|
33
|
+
error?: Error | undefined;
|
|
34
|
+
value?: [FullTagData[], Event[]] | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
loading: false;
|
|
37
|
+
error?: undefined;
|
|
38
|
+
value: [FullTagData[], Event[]];
|
|
39
|
+
};
|
|
@@ -24,4 +24,22 @@ export function useDynamicContentTags() {
|
|
|
24
24
|
return useAsync(async () => {
|
|
25
25
|
return fetchDynamicContentTags(context);
|
|
26
26
|
}, [context]);
|
|
27
|
+
}
|
|
28
|
+
export async function fetchDynamicContentEvents(context, application) {
|
|
29
|
+
return collectPaginatedData(1000, async (perPage, page) => {
|
|
30
|
+
const res = await context.rpcGateway.events.List({
|
|
31
|
+
application,
|
|
32
|
+
orderBy: 'NAME',
|
|
33
|
+
orderDirection: 'ASC',
|
|
34
|
+
page,
|
|
35
|
+
perPage
|
|
36
|
+
});
|
|
37
|
+
return res.events;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function useVariedDynamicContentTags(application) {
|
|
41
|
+
const context = useSPAContext();
|
|
42
|
+
return useAsync(() => {
|
|
43
|
+
return Promise.all([fetchDynamicContentTags(context), fetchDynamicContentEvents(context, application)]);
|
|
44
|
+
}, [context, application]);
|
|
27
45
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
2
|
+
export declare const TagPickerDiv: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
4
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
5
|
+
$bgColor?: string | undefined;
|
|
6
|
+
$border?: string | ({
|
|
7
|
+
top?: string | undefined;
|
|
8
|
+
right?: string | undefined;
|
|
9
|
+
bottom?: string | undefined;
|
|
10
|
+
left?: string | undefined;
|
|
11
|
+
} | {
|
|
12
|
+
horizontal: string;
|
|
13
|
+
top?: string | undefined;
|
|
14
|
+
bottom?: string | undefined;
|
|
15
|
+
} | {
|
|
16
|
+
vertical: string;
|
|
17
|
+
right?: string | undefined;
|
|
18
|
+
left?: string | undefined;
|
|
19
|
+
}) | undefined;
|
|
20
|
+
$borderRadius?: (string | number) | undefined;
|
|
21
|
+
$boxShadow?: string | undefined;
|
|
22
|
+
$gap?: (string | number) | undefined;
|
|
23
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
24
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
25
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
26
|
+
$margin?: (string | number) | ({
|
|
27
|
+
top?: (string | number) | undefined;
|
|
28
|
+
right?: (string | number) | undefined;
|
|
29
|
+
bottom?: (string | number) | undefined;
|
|
30
|
+
left?: (string | number) | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
horizontal: string | number;
|
|
33
|
+
top?: (string | number) | undefined;
|
|
34
|
+
bottom?: (string | number) | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
vertical: string | number;
|
|
37
|
+
right?: (string | number) | undefined;
|
|
38
|
+
left?: (string | number) | undefined;
|
|
39
|
+
}) | undefined;
|
|
40
|
+
$padding?: (string | number) | ({
|
|
41
|
+
top?: (string | number) | undefined;
|
|
42
|
+
right?: (string | number) | undefined;
|
|
43
|
+
bottom?: (string | number) | undefined;
|
|
44
|
+
left?: (string | number) | undefined;
|
|
45
|
+
} | {
|
|
46
|
+
horizontal: string | number;
|
|
47
|
+
top?: (string | number) | undefined;
|
|
48
|
+
bottom?: (string | number) | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
vertical: string | number;
|
|
51
|
+
right?: (string | number) | undefined;
|
|
52
|
+
left?: (string | number) | undefined;
|
|
53
|
+
}) | undefined;
|
|
54
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
55
|
+
} & {
|
|
56
|
+
$gridAutoFlow: string;
|
|
57
|
+
} & {
|
|
58
|
+
$gap: number;
|
|
59
|
+
$padding: number;
|
|
60
|
+
$borderRadius: ShapeRadius;
|
|
61
|
+
$border: string;
|
|
62
|
+
$bgColor: Color;
|
|
63
|
+
$boxShadow: Shadow;
|
|
64
|
+
}, "$gridAutoFlow" | "$bgColor" | "$border" | "$borderRadius" | "$boxShadow" | "$gap" | "$padding">;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
export const TagPickerDiv = styled(Vertical).attrs({
|
|
5
|
+
$gap: 16,
|
|
6
|
+
$padding: 16,
|
|
7
|
+
$borderRadius: ShapeRadius.CONTROL,
|
|
8
|
+
$border: `1px solid ${Color.FORM}`,
|
|
9
|
+
$bgColor: Color.FROZEN,
|
|
10
|
+
$boxShadow: Shadow.REGULAR
|
|
11
|
+
}).withConfig({
|
|
12
|
+
displayName: "TagPickerDiv",
|
|
13
|
+
componentId: "sc-17kpm8h-0"
|
|
14
|
+
})(["width:240px;"]);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Tag } from '@pushwoosh/rpc-v2-http-api-data/tags';
|
|
2
|
+
export type FullTagData = Tag & {
|
|
3
|
+
modifiers: string[];
|
|
4
|
+
};
|
|
5
|
+
export type TagDynamicContent = {
|
|
6
|
+
kind: 'tag';
|
|
7
|
+
dc: {
|
|
8
|
+
tagName: string;
|
|
9
|
+
modifier: string;
|
|
10
|
+
defaultValue: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type EventDynamicContent = {
|
|
14
|
+
kind: 'event';
|
|
15
|
+
dc: {
|
|
16
|
+
eventName: string;
|
|
17
|
+
attribute: string;
|
|
18
|
+
defaultValue: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type CustomTextDynamicContent = {
|
|
22
|
+
kind: 'customText';
|
|
23
|
+
dc: {
|
|
24
|
+
text: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type VariedDynamicContent = TagDynamicContent | EventDynamicContent | CustomTextDynamicContent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function createDefaultDynamicContent(kind) {
|
|
2
|
+
switch (kind) {
|
|
3
|
+
case 'tag':
|
|
4
|
+
return {
|
|
5
|
+
kind,
|
|
6
|
+
dc: {
|
|
7
|
+
tagName: '',
|
|
8
|
+
modifier: 'regular',
|
|
9
|
+
defaultValue: ''
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
case 'event':
|
|
13
|
+
return {
|
|
14
|
+
kind,
|
|
15
|
+
dc: {
|
|
16
|
+
eventName: '',
|
|
17
|
+
attribute: '',
|
|
18
|
+
defaultValue: ''
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
case 'customText':
|
|
22
|
+
return {
|
|
23
|
+
kind,
|
|
24
|
+
dc: {
|
|
25
|
+
text: ''
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { Button } from '@pushwoosh/dumb-components';
|
|
3
3
|
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
-
import {
|
|
4
|
+
import { SimpleDynamicContentPickerFormSmart } from '../DynamicContentPickerForm';
|
|
5
5
|
export const NewDynamicContentForm = ({
|
|
6
6
|
update,
|
|
7
7
|
onSubmit
|
|
8
8
|
}) => {
|
|
9
9
|
const [dc, setDc] = useState();
|
|
10
|
-
return React.createElement(
|
|
10
|
+
return React.createElement(SimpleDynamicContentPickerFormSmart, {
|
|
11
11
|
dc: dc,
|
|
12
12
|
onChange: setDc,
|
|
13
13
|
update: update
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RichMessageEditor } from '@pushwoosh/dumb-components';
|
|
3
|
-
import {
|
|
3
|
+
import { SimpleDynamicContentPickerFormSmart } from '../DynamicContentPickerForm';
|
|
4
4
|
import { NewDynamicContentForm } from './NewDynamicContentForm';
|
|
5
5
|
export const RichMessageEditorSmart = props => {
|
|
6
6
|
return React.createElement(RichMessageEditor, {
|
|
@@ -9,7 +9,7 @@ export const RichMessageEditorSmart = props => {
|
|
|
9
9
|
dc,
|
|
10
10
|
onChange,
|
|
11
11
|
update
|
|
12
|
-
}) => dc ? React.createElement(
|
|
12
|
+
}) => dc ? React.createElement(SimpleDynamicContentPickerFormSmart, {
|
|
13
13
|
dc: dc,
|
|
14
14
|
onChange: onChange,
|
|
15
15
|
update: update
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { Button } from '@pushwoosh/dumb-components';
|
|
4
4
|
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
5
|
-
import {
|
|
5
|
+
import { SimpleDynamicContentPickerFormSmart } from '../../DynamicContentPickerForm';
|
|
6
6
|
export function DynamicContentPickerExample() {
|
|
7
7
|
const [dc, setDc] = useState();
|
|
8
|
-
return React.createElement("div", null, React.createElement(
|
|
8
|
+
return React.createElement("div", null, React.createElement(SimpleDynamicContentPickerFormSmart, {
|
|
9
9
|
dc: dc,
|
|
10
10
|
onChange: setDc
|
|
11
11
|
}, React.createElement(Horizontal, {
|
package/context/types.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './EmailTemplatePreview';
|
|
2
2
|
export * from './context';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './DynamicContentPickerForm';
|
|
4
4
|
export * from './PlatformsConfigurationDrawer';
|
|
5
5
|
export * from './LanguagesSelector';
|
|
6
6
|
export * from './RichMessageEditorSmart';
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './EmailTemplatePreview';
|
|
2
2
|
export * from './context';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './DynamicContentPickerForm';
|
|
4
4
|
export * from './PlatformsConfigurationDrawer';
|
|
5
5
|
export * from './LanguagesSelector';
|
|
6
6
|
export * from './RichMessageEditorSmart';
|
package/package.json
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"pre-commit": "check",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@emoji-mart/react": "^1.1.1",
|
|
20
|
-
"@
|
|
20
|
+
"@floating-ui/react-dom": "^2.1.2",
|
|
21
|
+
"@pushwoosh/dumb-components": "^1.0.74",
|
|
21
22
|
"@pushwoosh/kit-constants": "^1.6.9",
|
|
22
23
|
"@pushwoosh/kit-helpers": "^4.8.1",
|
|
23
24
|
"@pushwoosh/kit-icons": "^2.1.2",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"@pushwoosh/grpc-bridge": "^1.5.36",
|
|
43
44
|
"@pushwoosh/http-client": "^2.5.0",
|
|
44
|
-
"@pushwoosh/rpc-v2-http-api-data": "^0.1.
|
|
45
|
+
"@pushwoosh/rpc-v2-http-api-data": "^0.1.501",
|
|
45
46
|
"@pushwoosh/session-store": "^2.5.0",
|
|
46
47
|
"react": "^16.14.0 || ^18.0.0",
|
|
47
48
|
"react-dom": "^16.14.0 || ^18.0.0"
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"engines": {
|
|
50
51
|
"node": ">= 18"
|
|
51
52
|
},
|
|
52
|
-
"version": "1.0.
|
|
53
|
+
"version": "1.0.18"
|
|
53
54
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type SPAContextType } from '../context';
|
|
2
|
-
import { type FullTagData } from './DynamicContentPicker.types';
|
|
3
|
-
export declare function fetchDynamicContentTags(context: SPAContextType): Promise<FullTagData[]>;
|
|
4
|
-
export declare function useDynamicContentTags(): {
|
|
5
|
-
loading: boolean;
|
|
6
|
-
error?: undefined;
|
|
7
|
-
value?: undefined;
|
|
8
|
-
} | {
|
|
9
|
-
loading: false;
|
|
10
|
-
error: Error;
|
|
11
|
-
value?: undefined;
|
|
12
|
-
} | {
|
|
13
|
-
loading: true;
|
|
14
|
-
error?: Error | undefined;
|
|
15
|
-
value?: FullTagData[] | undefined;
|
|
16
|
-
} | {
|
|
17
|
-
loading: false;
|
|
18
|
-
error?: undefined;
|
|
19
|
-
value: FullTagData[];
|
|
20
|
-
};
|
|
File without changes
|