@pushwoosh/smart-components-kit 0.2.0 → 0.3.0
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/{dynamic-content-picker → DynamicContentPicker}/DynamicContentPicker.js +1 -1
- package/{dynamic-content-picker → DynamicContentPicker}/DynamicContentPicker.types.d.ts +1 -1
- package/{dynamic-content-picker → DynamicContentPicker}/hooks.d.ts +1 -1
- package/{dynamic-content-picker → DynamicContentPicker}/hooks.js +2 -3
- package/{dynamic-content-picker → DynamicContentPicker}/styled.js +2 -2
- package/EmailTemplatePreview/EmailTemplatePreview.d.ts +9 -0
- package/EmailTemplatePreview/EmailTemplatePreview.js +47 -0
- package/EmailTemplatePreview/index.d.ts +1 -0
- package/EmailTemplatePreview/index.js +1 -0
- package/_devel/lib/dynamic-content-picker.js +3 -2
- package/_devel/lib/index.d.ts +1 -1
- package/_devel/lib/index.js +1 -1
- package/asyncHelpers.js +0 -1
- package/context/context.d.ts +2 -0
- package/context/context.js +2 -0
- package/context/index.d.ts +4 -14
- package/context/index.js +4 -10
- package/context/types.d.ts +13 -0
- package/context/types.js +1 -0
- package/context/useSPAContext.d.ts +1 -0
- package/context/useSPAContext.js +9 -0
- package/package.json +7 -9
- /package/{dynamic-content-picker → DynamicContentPicker}/DynamicContentPicker.d.ts +0 -0
- /package/{dynamic-content-picker → DynamicContentPicker}/DynamicContentPicker.types.js +0 -0
- /package/{dynamic-content-picker → DynamicContentPicker}/index.d.ts +0 -0
- /package/{dynamic-content-picker → DynamicContentPicker}/index.js +0 -0
- /package/{dynamic-content-picker → DynamicContentPicker}/styled.d.ts +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
3
|
-
import { TextInputField } from '@pushwoosh/kit-text-input';
|
|
4
3
|
import { NativeSelect } from '@pushwoosh/kit-select';
|
|
5
4
|
import { Spinner } from '@pushwoosh/kit-spinner';
|
|
5
|
+
import { TextInputField } from '@pushwoosh/kit-text-input';
|
|
6
6
|
import { useDynamicContentTags } from './hooks';
|
|
7
7
|
import { FieldTitle, TagPickerDiv } from './styled';
|
|
8
8
|
export const Field = ({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SPAContextType } from '../context';
|
|
1
|
+
import { type SPAContextType } from '../context';
|
|
2
2
|
import type { FullTagData } from './DynamicContentPicker.types';
|
|
3
3
|
export declare function fetchDynamicContentTags(context: SPAContextType): Promise<FullTagData[]>;
|
|
4
4
|
export declare function useDynamicContentTags(): {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
1
|
import { useAsync } from '@pushwoosh/kit-helpers';
|
|
3
2
|
import { collectPaginatedData } from '../asyncHelpers';
|
|
4
|
-
import {
|
|
3
|
+
import { useSPAContext } from '../context';
|
|
5
4
|
const ignoreTagTypes = ['boolean', 'list'];
|
|
6
5
|
const numberTypes = ['integer', 'decimal'];
|
|
7
6
|
export async function fetchDynamicContentTags(context) {
|
|
@@ -23,7 +22,7 @@ export async function fetchDynamicContentTags(context) {
|
|
|
23
22
|
}));
|
|
24
23
|
}
|
|
25
24
|
export function useDynamicContentTags() {
|
|
26
|
-
const context =
|
|
25
|
+
const context = useSPAContext();
|
|
27
26
|
return useAsync(async () => {
|
|
28
27
|
return fetchDynamicContentTags(context);
|
|
29
28
|
}, [context]);
|
|
@@ -5,9 +5,9 @@ export const TagPickerDiv = styled(Vertical).attrs({
|
|
|
5
5
|
$padding: 16
|
|
6
6
|
}).withConfig({
|
|
7
7
|
displayName: "TagPickerDiv",
|
|
8
|
-
componentId: "sc-
|
|
8
|
+
componentId: "sc-1blii2o-0"
|
|
9
9
|
})(["width:240px;border-radius:4px;background:#F7F9FA;box-shadow:0 0 4px 0 rgba(0,0,0,0.06),0 4px 6px 0 rgba(0,0,0,0.06);"]);
|
|
10
10
|
export const FieldTitle = styled.div.withConfig({
|
|
11
11
|
displayName: "FieldTitle",
|
|
12
|
-
componentId: "sc-
|
|
12
|
+
componentId: "sc-1blii2o-1"
|
|
13
13
|
})(["font-size:12px;font-style:normal;font-weight:500;line-height:130%;"]);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EmailTemplatePreview as DumpPreview } from '@pushwoosh/kit-dumb-components';
|
|
3
|
+
import { useAsync } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { RectangularSkeleton } from '@pushwoosh/kit-skeleton';
|
|
5
|
+
import { useSPAContext } from '../context';
|
|
6
|
+
export const EmailTemplatePreview = ({
|
|
7
|
+
code,
|
|
8
|
+
width,
|
|
9
|
+
height,
|
|
10
|
+
scale
|
|
11
|
+
}) => {
|
|
12
|
+
const {
|
|
13
|
+
grpcBridge
|
|
14
|
+
} = useSPAContext();
|
|
15
|
+
const res = useAsync(async () => {
|
|
16
|
+
const {
|
|
17
|
+
content: {
|
|
18
|
+
content: {
|
|
19
|
+
html,
|
|
20
|
+
localizationData
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
previewSettings
|
|
24
|
+
} = await grpcBridge.emailTemplates.get({
|
|
25
|
+
code
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
template: html,
|
|
29
|
+
localization: localizationData.default || {},
|
|
30
|
+
values: previewSettings
|
|
31
|
+
};
|
|
32
|
+
}, [code]);
|
|
33
|
+
if (res.loading) {
|
|
34
|
+
return React.createElement(RectangularSkeleton, {
|
|
35
|
+
width: width,
|
|
36
|
+
height: height
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return React.createElement(DumpPreview, {
|
|
40
|
+
template: res.value.template,
|
|
41
|
+
localization: res.value.localization,
|
|
42
|
+
values: res.value.values,
|
|
43
|
+
width: width,
|
|
44
|
+
height: height,
|
|
45
|
+
scale: scale
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EmailTemplatePreview } from './EmailTemplatePreview';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EmailTemplatePreview } from './EmailTemplatePreview';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
1
2
|
import React, { useState } from 'react';
|
|
2
|
-
import { DynamicContentPicker } from '../../dynamic-content-picker';
|
|
3
|
-
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
3
|
import { Button } from '@pushwoosh/kit-button';
|
|
4
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
5
|
+
import { DynamicContentPicker } from '../../DynamicContentPicker';
|
|
5
6
|
export function DynamicContentPickerExample() {
|
|
6
7
|
const [dc, setDc] = useState();
|
|
7
8
|
return React.createElement("div", null, React.createElement(DynamicContentPicker, {
|
package/_devel/lib/index.d.ts
CHANGED
package/_devel/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export const Lib = ({
|
|
|
13
13
|
"$sizes": "200px 780px"
|
|
14
14
|
}, React.createElement("ul", null, React.createElement("li", null, React.createElement(Link, {
|
|
15
15
|
to: `${match.url}/dynamic-content-picker`
|
|
16
|
-
}, "
|
|
16
|
+
}, "Dynamic content picker")), React.createElement("li", null, React.createElement(Link, {
|
|
17
17
|
to: `${match.url}/example`
|
|
18
18
|
}, "Child 2"))), React.createElement("div", null, React.createElement(Switch, null, React.createElement(Route, {
|
|
19
19
|
path: `${match.path}/dynamic-content-picker`,
|
package/asyncHelpers.js
CHANGED
package/context/index.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type SPAContextType = {
|
|
6
|
-
readonly history: History;
|
|
7
|
-
readonly httpClient: HttpClient;
|
|
8
|
-
readonly rpcClient: RpcClient;
|
|
9
|
-
readonly grpcClient: GrpcClient;
|
|
10
|
-
readonly grpcBridge: GrpcBridge;
|
|
11
|
-
readonly sessionStore: SessionStore;
|
|
12
|
-
};
|
|
13
|
-
export declare const SPAContext: import("react").Context<SPAContextType | undefined>;
|
|
1
|
+
import type { SPAContextType } from './types';
|
|
2
|
+
import { useSPAContext } from './useSPAContext';
|
|
3
|
+
export type { SPAContextType };
|
|
4
|
+
export { useSPAContext };
|
|
14
5
|
export declare const SPAContextProvider: import("react").Provider<SPAContextType | undefined>;
|
|
15
|
-
export declare function useSPAContext(): SPAContextType;
|
package/context/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
const contextValue = useContext(SPAContext);
|
|
6
|
-
if (!contextValue) {
|
|
7
|
-
throw new Error('useSPAContext must be used within a SPAContextProvider');
|
|
8
|
-
}
|
|
9
|
-
return contextValue;
|
|
10
|
-
}
|
|
1
|
+
import { SPAContext } from './context';
|
|
2
|
+
import { useSPAContext } from './useSPAContext';
|
|
3
|
+
export { useSPAContext };
|
|
4
|
+
export const SPAContextProvider = SPAContext.Provider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type History } from 'history';
|
|
2
|
+
import type { GrpcBridge } from '@pushwoosh/grpc-bridge';
|
|
3
|
+
import type { GrpcClient, HttpClient, RpcClient } from '@pushwoosh/http-client';
|
|
4
|
+
import type { SessionStore } from '@pushwoosh/session-store';
|
|
5
|
+
export type SPAContextType = {
|
|
6
|
+
readonly history: History;
|
|
7
|
+
readonly httpClient: HttpClient;
|
|
8
|
+
readonly rpcClient: RpcClient;
|
|
9
|
+
readonly grpcClient: GrpcClient;
|
|
10
|
+
readonly grpcBridge: GrpcBridge;
|
|
11
|
+
readonly sessionStore: SessionStore;
|
|
12
|
+
readonly __smartComponentsCache: Record<string, any>;
|
|
13
|
+
};
|
package/context/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSPAContext(): import("./types").SPAContextType;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { SPAContext } from './context';
|
|
3
|
+
export function useSPAContext() {
|
|
4
|
+
const contextValue = useContext(SPAContext);
|
|
5
|
+
if (!contextValue) {
|
|
6
|
+
throw new Error('useSPAContext must be used within a SPAContextProvider');
|
|
7
|
+
}
|
|
8
|
+
return contextValue;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -16,32 +16,30 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@pushwoosh/kit-button": "^2.2.5",
|
|
18
18
|
"@pushwoosh/kit-constants": "^1.6.5",
|
|
19
|
+
"@pushwoosh/kit-dumb-components": "^0.0.6",
|
|
19
20
|
"@pushwoosh/kit-helpers": "^4.6.1",
|
|
20
21
|
"@pushwoosh/kit-select": "^1.1.0",
|
|
22
|
+
"@pushwoosh/kit-skeleton": "^1.1.6",
|
|
21
23
|
"@pushwoosh/kit-spinner": "^1.5.1",
|
|
22
24
|
"@pushwoosh/kit-text-input": "^1.5.1"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@pushwoosh/
|
|
27
|
-
"@pushwoosh/grpc-bridge": "^1.5.10",
|
|
27
|
+
"@pushwoosh/frontend-builder-engine": "^1.0.4",
|
|
28
|
+
"@pushwoosh/grpc-bridge": "^1.5.36",
|
|
28
29
|
"@pushwoosh/http-client": "^2.4.12",
|
|
29
30
|
"@pushwoosh/session-store": "^2.4.1",
|
|
30
|
-
"@types/eslint__js": "^8.42.3",
|
|
31
31
|
"@types/react": "^18.3.5",
|
|
32
32
|
"@types/react-dom": "^18.3.0",
|
|
33
33
|
"@types/react-router-dom": "^5.3.3",
|
|
34
34
|
"@types/styled-components": "^5.1.34",
|
|
35
|
-
"eslint": "^9.10.0",
|
|
36
35
|
"react": "^18.3.1",
|
|
37
36
|
"react-dom": "^18.3.1",
|
|
38
37
|
"react-router-dom": "^5.3.4",
|
|
39
38
|
"styled-components": "^5.3.11",
|
|
40
|
-
"typescript": "^5.6.2"
|
|
41
|
-
"typescript-eslint": "^8.5.0"
|
|
39
|
+
"typescript": "^5.6.2"
|
|
42
40
|
},
|
|
43
41
|
"peerDependencies": {
|
|
44
|
-
"@pushwoosh/grpc-bridge": "^1.5.
|
|
42
|
+
"@pushwoosh/grpc-bridge": "^1.5.36",
|
|
45
43
|
"@pushwoosh/http-client": "^2.4.12",
|
|
46
44
|
"@pushwoosh/session-store": "^2.4.1",
|
|
47
45
|
"react": "^16.14.0 || ^18.0.0",
|
|
@@ -50,5 +48,5 @@
|
|
|
50
48
|
"engines": {
|
|
51
49
|
"node": ">= 18"
|
|
52
50
|
},
|
|
53
|
-
"version": "0.
|
|
51
|
+
"version": "0.3.0"
|
|
54
52
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|