@antscorp/antsomi-ui 1.3.5-beta.270 → 1.3.5-beta.272
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/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +0 -1
- package/es/components/molecules/ImageResizeTuiEditor/ImageResizeTuiEditor.js +17 -14
- package/es/components/organism/ContentSources/Settings.d.ts +3 -0
- package/es/components/organism/ContentSources/Settings.js +9 -4
- package/es/components/organism/ContentSources/index.d.ts +3 -0
- package/es/components/organism/ContentSources/index.js +4 -3
- package/es/components/organism/ContentSources/reducer.d.ts +1 -1
- package/es/components/template/TemplateListing/Loadable.d.ts +0 -1
- package/package.json +1 -1
|
@@ -28,6 +28,8 @@ const ImageResizeTuiEditor = React.forwardRef(({ className, imageUrl, width, hei
|
|
|
28
28
|
};
|
|
29
29
|
const changeImage = url => {
|
|
30
30
|
var _a;
|
|
31
|
+
if (!url)
|
|
32
|
+
return;
|
|
31
33
|
(_a = fabricCanvasRef.current) === null || _a === void 0 ? void 0 : _a.forEachObject(obj => {
|
|
32
34
|
var _a;
|
|
33
35
|
(_a = fabricCanvasRef.current) === null || _a === void 0 ? void 0 : _a.remove(obj);
|
|
@@ -37,36 +39,37 @@ const ImageResizeTuiEditor = React.forwardRef(({ className, imageUrl, width, hei
|
|
|
37
39
|
useImperativeHandle(ref, () => ({
|
|
38
40
|
getBase64(options) {
|
|
39
41
|
var _a;
|
|
40
|
-
const dataURL = (_a = fabricCanvasRef.current) === null || _a === void 0 ? void 0 : _a.toDataURL(Object.assign({ format: 'png', quality: 1 }, options));
|
|
42
|
+
const dataURL = (_a = fabricCanvasRef.current) === null || _a === void 0 ? void 0 : _a.toDataURL(Object.assign({ format: 'png', quality: 1, multiplier: 3 }, options));
|
|
41
43
|
return dataURL;
|
|
42
44
|
},
|
|
43
45
|
replaceImageWithUrl(imageUrl) {
|
|
44
46
|
changeImage(imageUrl);
|
|
45
47
|
},
|
|
46
48
|
getCurrentState() {
|
|
47
|
-
return fabricCanvasRef.current;
|
|
49
|
+
return fabricCanvasRef.current._objects[0];
|
|
48
50
|
},
|
|
49
51
|
}), []);
|
|
50
52
|
useEffect(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
var _a, _b;
|
|
54
|
+
if (!loadRef.current) {
|
|
55
|
+
loadRef.current = true;
|
|
56
|
+
fabricCanvasRef.current = new fabric.Canvas('tui-image-editor', {
|
|
57
|
+
width,
|
|
58
|
+
height,
|
|
59
|
+
});
|
|
60
|
+
fabric.Object.prototype.transparentCorners = false;
|
|
53
61
|
}
|
|
54
|
-
loadRef.current = true;
|
|
55
|
-
fabricCanvasRef.current = new fabric.Canvas('tui-image-editor', {
|
|
56
|
-
width,
|
|
57
|
-
height,
|
|
58
|
-
});
|
|
59
|
-
fabric.Object.prototype.transparentCorners = false;
|
|
60
62
|
if (imageUrl) {
|
|
61
|
-
|
|
63
|
+
changeImage(imageUrl);
|
|
62
64
|
}
|
|
63
65
|
else if (defaultValue) {
|
|
64
|
-
|
|
66
|
+
(_a = fabricCanvasRef.current) === null || _a === void 0 ? void 0 : _a.forEachObject(obj => {
|
|
65
67
|
var _a;
|
|
66
|
-
(_a = fabricCanvasRef.current) === null || _a === void 0 ? void 0 : _a.
|
|
68
|
+
(_a = fabricCanvasRef.current) === null || _a === void 0 ? void 0 : _a.remove(obj);
|
|
67
69
|
});
|
|
70
|
+
(_b = fabricCanvasRef.current) === null || _b === void 0 ? void 0 : _b.add(defaultValue);
|
|
68
71
|
}
|
|
69
|
-
}, [imageUrl]);
|
|
72
|
+
}, [imageUrl, defaultValue]);
|
|
70
73
|
return (React.createElement("div", { className: className },
|
|
71
74
|
React.createElement("canvas", { ref: canvasRef, id: "tui-image-editor", style: { width, height } })));
|
|
72
75
|
});
|
|
@@ -6,6 +6,9 @@ interface SettingsProps {
|
|
|
6
6
|
mode: ContentSourceModeView;
|
|
7
7
|
hideOptionTypes?: HideOptionTypes;
|
|
8
8
|
onChange: (contentSource: TContentSourceSettings) => void;
|
|
9
|
+
onBOChange?: (item: {
|
|
10
|
+
itemTypeId: number;
|
|
11
|
+
}) => void;
|
|
9
12
|
initValue?: TContentSourceSettings;
|
|
10
13
|
isShowErrorAlert: boolean;
|
|
11
14
|
journeySettings: JourneySettings;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
// Libraries
|
|
11
11
|
import React, { memo, useEffect, useLayoutEffect, useState } from 'react';
|
|
12
|
-
import { get, isArray, isEmpty, set } from 'lodash';
|
|
12
|
+
import { get, isArray, isEmpty, isNull, set } from 'lodash';
|
|
13
13
|
// Locale
|
|
14
14
|
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
15
15
|
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
@@ -36,7 +36,7 @@ import { deleteContentSourceGroup, setContentSourceGroup, setContentSourceGroupB
|
|
|
36
36
|
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
37
37
|
const PATH = 'src/components/organism/ContentSources/Settings.tsx';
|
|
38
38
|
const Settings = (props) => {
|
|
39
|
-
const { serviceAuth, mode, isShowErrorAlert, initValue, journeySettings, hideOptionTypes, onChange, } = props;
|
|
39
|
+
const { serviceAuth, mode, isShowErrorAlert, initValue, journeySettings, hideOptionTypes, onChange, onBOChange, } = props;
|
|
40
40
|
const { url = '', userId, token, accountId } = serviceAuth;
|
|
41
41
|
const { t } = i18nInstance;
|
|
42
42
|
const boIdByGroupCS = useSelectBoIdByGroupFromCS();
|
|
@@ -148,8 +148,11 @@ const Settings = (props) => {
|
|
|
148
148
|
switch (action.type) {
|
|
149
149
|
case 'BO_TYPE': {
|
|
150
150
|
const { itemTypeId } = action.payload;
|
|
151
|
-
if (itemTypeId)
|
|
151
|
+
if (itemTypeId) {
|
|
152
152
|
handleChangeItemTypeId({ groupId, id: itemTypeId });
|
|
153
|
+
if (onBOChange)
|
|
154
|
+
onBOChange({ itemTypeId });
|
|
155
|
+
}
|
|
153
156
|
break;
|
|
154
157
|
}
|
|
155
158
|
case 'ALGORITHMS': {
|
|
@@ -275,7 +278,9 @@ const Settings = (props) => {
|
|
|
275
278
|
}, [boIdByGroupCS, serviceAuth, contentSourceDispatch]);
|
|
276
279
|
// callback data out
|
|
277
280
|
useDeepCompareEffect(() => {
|
|
278
|
-
|
|
281
|
+
const groups = get(contentSourcesDebounce, 'groups', []);
|
|
282
|
+
const isValidCallbackOut = groups.every(group => !isNull(group.itemTypeId));
|
|
283
|
+
if (typeof onChange === 'function' && isValidCallbackOut) {
|
|
279
284
|
onChange(contentSourcesDebounce);
|
|
280
285
|
}
|
|
281
286
|
}, [contentSourcesDebounce]);
|
|
@@ -9,6 +9,9 @@ export interface ContentSourceProps {
|
|
|
9
9
|
mode: ContentSourceModeView;
|
|
10
10
|
initValue?: TContentSourceSettings;
|
|
11
11
|
onChange: (contentSource: TContentSourceSettings) => void;
|
|
12
|
+
onBOChange?: (item: {
|
|
13
|
+
itemTypeId: number;
|
|
14
|
+
}) => void;
|
|
12
15
|
journeySettings: JourneySettings;
|
|
13
16
|
}
|
|
14
17
|
declare const _default: React.MemoExoticComponent<{
|
|
@@ -19,6 +19,7 @@ const defaultProps = {
|
|
|
19
19
|
journeySettings: JOURNEY_SETTINGS_DEFAULT,
|
|
20
20
|
mode: 'CDP',
|
|
21
21
|
onChange: () => { },
|
|
22
|
+
onBOChange: () => { },
|
|
22
23
|
serviceAuth: {
|
|
23
24
|
url: '',
|
|
24
25
|
token: '',
|
|
@@ -27,12 +28,12 @@ const defaultProps = {
|
|
|
27
28
|
},
|
|
28
29
|
};
|
|
29
30
|
const ContentSource = (props) => {
|
|
30
|
-
const { useQueryClient, serviceAuth, mode, isShowErrorAlert, initValue, hideOptionTypes, journeySettings, onChange, } = props;
|
|
31
|
+
const { useQueryClient, serviceAuth, mode, isShowErrorAlert, initValue, hideOptionTypes, journeySettings, onChange, onBOChange, } = props;
|
|
31
32
|
if (!useQueryClient)
|
|
32
|
-
return (React.createElement(Settings, { mode: mode, initValue: initValue, hideOptionTypes: hideOptionTypes, serviceAuth: serviceAuth, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, onChange: onChange }));
|
|
33
|
+
return (React.createElement(Settings, { mode: mode, initValue: initValue, hideOptionTypes: hideOptionTypes, serviceAuth: serviceAuth, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, onChange: onChange, onBOChange: onBOChange }));
|
|
33
34
|
return (React.createElement(QueryClientProviderAntsomiUI, { client: queryClientAntsomiUI },
|
|
34
35
|
React.createElement(ContentSourceProvider, null,
|
|
35
|
-
React.createElement(Settings, { mode: mode, initValue: initValue, hideOptionTypes: hideOptionTypes, serviceAuth: serviceAuth, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, onChange: onChange }))));
|
|
36
|
+
React.createElement(Settings, { mode: mode, initValue: initValue, hideOptionTypes: hideOptionTypes, serviceAuth: serviceAuth, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, onChange: onChange, onBOChange: onBOChange }))));
|
|
36
37
|
};
|
|
37
38
|
ContentSource.defaultProps = defaultProps;
|
|
38
39
|
export default memo(ContentSource);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TServiceAuth } from '@antscorp/antsomi-ui/es/types';
|
|
2
1
|
import { UpdateGroupAction, TContentSourceSettings, TContentSourceGroup, ActionSetContentSourceGroup, ActionDeleteContentSourceGroup, ContentSourceModeView, ActionUpdateModeView, ActionUpdateContentSourceSettings, ActionSetContentSourceGroupBOData } from './types';
|
|
2
|
+
import { TServiceAuth } from '@antscorp/antsomi-ui/es/types';
|
|
3
3
|
export interface ContentSourceState {
|
|
4
4
|
serviceAuth: TServiceAuth;
|
|
5
5
|
mode: ContentSourceModeView;
|