@pushwoosh/smart-components-kit 1.0.1 → 1.0.2
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 +1 -4
- package/DynamicContentPicker/DynamicContentPicker.js +4 -12
- package/DynamicContentPicker/hooks.js +4 -6
- package/DynamicContentPicker/styled.d.ts +0 -1
- package/DynamicContentPicker/styled.js +2 -5
- package/EmailTemplatePreview/EmailTemplatePreview.js +10 -9
- package/hooks/useSession.js +1 -3
- package/package.json +3 -3
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { type FC, type PropsWithChildren
|
|
1
|
+
import { type FC, type PropsWithChildren } from 'react';
|
|
2
2
|
import type { DynamicContent } from './DynamicContentPicker.types';
|
|
3
|
-
export declare const Field: FC<PropsWithChildren<{
|
|
4
|
-
title: ReactNode;
|
|
5
|
-
}>>;
|
|
6
3
|
type DynamicContentFormProps = {
|
|
7
4
|
dc?: DynamicContent;
|
|
8
5
|
onChange: (dc: DynamicContent) => void;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { NativeInput, NativeSelect, Spinner } from '@pushwoosh/dumb-components';
|
|
2
|
+
import { FieldBox, NativeInput, NativeSelect, Spinner } from '@pushwoosh/dumb-components';
|
|
3
3
|
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
4
|
import { useDynamicContentTags } from './hooks';
|
|
5
|
-
import {
|
|
6
|
-
export const Field = ({
|
|
7
|
-
title,
|
|
8
|
-
children
|
|
9
|
-
}) => {
|
|
10
|
-
return React.createElement(Vertical, {
|
|
11
|
-
"$gap": 4
|
|
12
|
-
}, React.createElement(FieldTitle, null, title), children);
|
|
13
|
-
};
|
|
5
|
+
import { TagPickerDiv } from './styled';
|
|
14
6
|
const defaultDynamicContent = {
|
|
15
7
|
tagName: '',
|
|
16
8
|
modifier: 'regular',
|
|
@@ -35,7 +27,7 @@ export const DynamicContentPicker = ({
|
|
|
35
27
|
name: '',
|
|
36
28
|
modifiers: ['regular']
|
|
37
29
|
};
|
|
38
|
-
return React.createElement(TagPickerDiv, null, React.createElement(
|
|
30
|
+
return React.createElement(TagPickerDiv, null, React.createElement(FieldBox, {
|
|
39
31
|
title: "Tag"
|
|
40
32
|
}, React.createElement(Vertical, {
|
|
41
33
|
"$gap": 8
|
|
@@ -65,7 +57,7 @@ export const DynamicContentPicker = ({
|
|
|
65
57
|
}, currentTag.modifiers.map(modifier => React.createElement("option", {
|
|
66
58
|
value: modifier,
|
|
67
59
|
key: modifier
|
|
68
|
-
}, modifier))))), React.createElement(
|
|
60
|
+
}, modifier))))), React.createElement(FieldBox, {
|
|
69
61
|
title: "Default Tag Value"
|
|
70
62
|
}, React.createElement(NativeInput, {
|
|
71
63
|
value: dc.defaultValue,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { DynamicContentModifiers } from '@pushwoosh/kit-constants';
|
|
1
2
|
import { useAsync } from '@pushwoosh/kit-helpers';
|
|
2
3
|
import { collectPaginatedData } from '../asyncHelpers';
|
|
3
4
|
import { useSPAContext } from '../context';
|
|
4
5
|
const ignoreTagTypes = ['BOOLEAN', 'LIST'];
|
|
5
6
|
const numberTypes = ['INTEGER', 'PRICE'];
|
|
6
7
|
export async function fetchDynamicContentTags(context) {
|
|
7
|
-
const
|
|
8
|
+
const originalTags = await collectPaginatedData(1000, async (perPage, page) => {
|
|
8
9
|
const res = await context.rpcGateway.tags.List({
|
|
9
10
|
orderBy: 'NAME',
|
|
10
11
|
orderDirection: 'ASC',
|
|
@@ -12,13 +13,10 @@ export async function fetchDynamicContentTags(context) {
|
|
|
12
13
|
perPage
|
|
13
14
|
});
|
|
14
15
|
return res.tags;
|
|
15
|
-
})
|
|
16
|
-
const {
|
|
17
|
-
result
|
|
18
|
-
} = modifiers.response;
|
|
16
|
+
});
|
|
19
17
|
return originalTags.filter(tag => !ignoreTagTypes.includes(tag.type)).map(tag => ({
|
|
20
18
|
...tag,
|
|
21
|
-
modifiers: numberTypes.includes(tag.type) ?
|
|
19
|
+
modifiers: numberTypes.includes(tag.type) ? DynamicContentModifiers.integer : DynamicContentModifiers.string
|
|
22
20
|
}));
|
|
23
21
|
}
|
|
24
22
|
export function useDynamicContentTags() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
+
import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
2
3
|
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
3
4
|
export const TagPickerDiv = styled(Vertical).attrs({
|
|
4
5
|
$gap: 16,
|
|
@@ -6,8 +7,4 @@ export const TagPickerDiv = styled(Vertical).attrs({
|
|
|
6
7
|
}).withConfig({
|
|
7
8
|
displayName: "TagPickerDiv",
|
|
8
9
|
componentId: "sc-1blii2o-0"
|
|
9
|
-
})(["width:240px;border-radius:
|
|
10
|
-
export const FieldTitle = styled.div.withConfig({
|
|
11
|
-
displayName: "FieldTitle",
|
|
12
|
-
componentId: "sc-1blii2o-1"
|
|
13
|
-
})(["font-size:12px;font-style:normal;font-weight:500;line-height:130%;"]);
|
|
10
|
+
})(["width:240px;border-radius:", ";background:", ";box-shadow:", ";"], ShapeRadius.CONTROL, Color.FROZEN, Shadow.REGULAR);
|
|
@@ -9,20 +9,21 @@ export const EmailTemplatePreview = ({
|
|
|
9
9
|
scale
|
|
10
10
|
}) => {
|
|
11
11
|
const {
|
|
12
|
-
|
|
12
|
+
rpcGateway
|
|
13
13
|
} = useSPAContext();
|
|
14
14
|
const res = useAsync(async () => {
|
|
15
15
|
const {
|
|
16
|
-
|
|
17
|
-
content
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
previewSettings
|
|
23
|
-
} = await grpcBridge.emailTemplates.get({
|
|
16
|
+
emailTemplate: {
|
|
17
|
+
content,
|
|
18
|
+
previewSettings
|
|
19
|
+
}
|
|
20
|
+
} = await rpcGateway.emailTemplates.Get({
|
|
24
21
|
code
|
|
25
22
|
});
|
|
23
|
+
const {
|
|
24
|
+
html,
|
|
25
|
+
localizationData
|
|
26
|
+
} = content.kind.data;
|
|
26
27
|
return {
|
|
27
28
|
template: html,
|
|
28
29
|
localization: localizationData.default || {},
|
package/hooks/useSession.js
CHANGED
|
@@ -6,9 +6,7 @@ export function useSession() {
|
|
|
6
6
|
} = useSPAContext();
|
|
7
7
|
const [session, setSession] = useState(sessionStore.getLastSession());
|
|
8
8
|
useEffect(() => {
|
|
9
|
-
const subscriber = sessionStore.subscribe(
|
|
10
|
-
setSession(s);
|
|
11
|
-
});
|
|
9
|
+
const subscriber = sessionStore.subscribe(setSession);
|
|
12
10
|
return () => {
|
|
13
11
|
subscriber.unsubscribe();
|
|
14
12
|
};
|
package/package.json
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"pre-commit": "check",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@pushwoosh/dumb-components": "^1.0.
|
|
19
|
-
"@pushwoosh/kit-constants": "^1.6.
|
|
18
|
+
"@pushwoosh/dumb-components": "^1.0.27",
|
|
19
|
+
"@pushwoosh/kit-constants": "^1.6.8",
|
|
20
20
|
"@pushwoosh/kit-helpers": "^4.6.1",
|
|
21
21
|
"@pushwoosh/kit-icons": "^2.1.1",
|
|
22
22
|
"@pushwoosh/kit-typography": "^1.7.2"
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">= 18"
|
|
49
49
|
},
|
|
50
|
-
"version": "1.0.
|
|
50
|
+
"version": "1.0.2"
|
|
51
51
|
}
|