@antscorp/antsomi-ui 1.3.5-beta.144 → 1.3.5-beta.146
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/TemplateSaveAs/TemplateSaveAs.js +2 -2
- package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.js +4 -1
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/BigImage.js +9 -2
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/SmallImage.js +12 -2
- package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.d.ts +1 -1
- package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.js +1 -1
- package/es/components/template/TemplateListing/hooks/useTemplateListing.js +9 -1
- package/es/test.js +70 -18
- package/package.json +1 -1
|
@@ -152,7 +152,7 @@ export const TemplateSaveAs = props => {
|
|
|
152
152
|
} }))),
|
|
153
153
|
React.createElement(Flex, { className: "field-container", style: { marginTop: '-20px' } },
|
|
154
154
|
React.createElement(Text, { className: "field-title field-title--middle" }, descriptionLabel || 'Description'),
|
|
155
|
-
React.createElement(Input, { placeholder: descriptionPlaceholder || 'Describe your media template', className: "field-input",
|
|
155
|
+
React.createElement(Input, { placeholder: descriptionPlaceholder || 'Describe your media template', className: "field-input", maxLength: 400, onBlur: e => handleChangeValue({ description: e.target.value }) })),
|
|
156
156
|
React.createElement(Flex, { className: "field-container" },
|
|
157
157
|
React.createElement(Text, { className: "field-title" },
|
|
158
158
|
imageReviewLabel || 'Thumbnail template',
|
|
@@ -178,7 +178,7 @@ export const TemplateSaveAs = props => {
|
|
|
178
178
|
})
|
|
179
179
|
: null),
|
|
180
180
|
isShowShareAccess ? (React.createElement("div", { className: "share-access-container" },
|
|
181
|
-
React.createElement(ShareAccess, Object.assign({ accessInfo: accessInfo, excludeUserAccess: ['to_editor'], generalAccessSettings: {
|
|
181
|
+
React.createElement(ShareAccess, Object.assign({ accessInfo: accessInfo, excludeUserAccess: ['to_editor', 'to_owner'], generalAccessSettings: {
|
|
182
182
|
publicOnlyWith: true,
|
|
183
183
|
}, onChange: value => handleChangeValue({ accessInfo: value }) }, shareAccessProps)))) : null))));
|
|
184
184
|
};
|
|
@@ -34,7 +34,10 @@ export const TemplateSaveAsModal = props => {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
const handleOk = (event) => {
|
|
37
|
-
|
|
37
|
+
var _a;
|
|
38
|
+
// Check form errors
|
|
39
|
+
const isError = ((_a = restTemplateProps.form) === null || _a === void 0 ? void 0 : _a.getFieldsError().some(field => field.errors.length)) || false;
|
|
40
|
+
if (onOk && (!errors || errors.length === 0) && !isError) {
|
|
38
41
|
// NOTE: If there are templateValue and onChange => controlled component => return templateValue
|
|
39
42
|
onOk(event, templateValue && onChange ? templateValue : internalValue);
|
|
40
43
|
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { Image } from 'antd';
|
|
3
3
|
import { Button } from '@antscorp/antsomi-ui/es/components';
|
|
4
4
|
import Icon from '@antscorp/icons';
|
|
5
5
|
export const BigImage = React.memo(props => {
|
|
6
6
|
const { url, isDefaultThumbnail, isHideDefaultButton, index, onClickDefaultButton } = props;
|
|
7
|
+
const currentTime = useMemo(() => new Date(), []);
|
|
8
|
+
const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
|
|
9
|
+
const urlNoCache = url
|
|
10
|
+
? url.includes('nocache')
|
|
11
|
+
? url
|
|
12
|
+
: `${url}?nocache=${timeGenerated}`
|
|
13
|
+
: undefined;
|
|
7
14
|
return (React.createElement("div", { className: "image-container--big" },
|
|
8
|
-
url ? (React.createElement(Image, { preview: false, width: "80%", height: "96%", src:
|
|
15
|
+
url ? (React.createElement(Image, { preview: false, width: "80%", height: "96%", src: urlNoCache })) : null,
|
|
9
16
|
isHideDefaultButton ? null : (React.createElement(Button, { className: "set-default-button", onClick: () => onClickDefaultButton && onClickDefaultButton(index) },
|
|
10
17
|
isDefaultThumbnail ? React.createElement(Icon, { type: "icon-ants-check", style: { fontSize: '12px' } }) : null,
|
|
11
18
|
isDefaultThumbnail ? 'Default thumbnail' : 'Set as default'))));
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { Image } from 'antd';
|
|
3
3
|
export const SmallImage = React.memo(props => {
|
|
4
4
|
const { url, isSelected, index, onClick } = props;
|
|
5
|
-
|
|
5
|
+
const currentTime = useMemo(() => new Date(), []);
|
|
6
|
+
const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
|
|
7
|
+
const urlNoCache = url
|
|
8
|
+
? url.includes('nocache')
|
|
9
|
+
? url
|
|
10
|
+
: `${url}?nocache=${timeGenerated}`
|
|
11
|
+
: undefined;
|
|
12
|
+
return (React.createElement("div", { className: `image-container--small ${isSelected ? 'image-container--selected' : ''}`, onClick: () => onClick && onClick(index) }, url ? (React.createElement(Image, { preview: false, width: "80%", height: "96%",
|
|
13
|
+
// src={imageUrl}
|
|
14
|
+
// src={url}
|
|
15
|
+
src: urlNoCache })) : null));
|
|
6
16
|
});
|
|
@@ -61,7 +61,7 @@ export declare const useTemplateSave: (options: TemplateListingOptions) => {
|
|
|
61
61
|
onSearch: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
62
62
|
onScrollToBottom: () => void;
|
|
63
63
|
isLoading: boolean;
|
|
64
|
-
validateName: (rule: RuleObject, value: any) => Promise<void>;
|
|
64
|
+
validateName: (rule: RuleObject, value: any, callback?: any) => Promise<void>;
|
|
65
65
|
};
|
|
66
66
|
form: import("antd").FormInstance<any>;
|
|
67
67
|
errors: any[] | undefined;
|
|
@@ -96,7 +96,7 @@ export const useTemplateSave = (options) => {
|
|
|
96
96
|
setValue(valueArg || {});
|
|
97
97
|
};
|
|
98
98
|
/* Validate Template Name */
|
|
99
|
-
const validateName = (rule, value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
+
const validateName = (rule, value, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
100
|
if (!value)
|
|
101
101
|
return;
|
|
102
102
|
const response = yield validateTemplateName({
|
|
@@ -140,7 +140,8 @@ export const useTemplateListing = (options) => {
|
|
|
140
140
|
return undefined;
|
|
141
141
|
}, [infiniteObjectTemplate, selectedTemplateId]);
|
|
142
142
|
const categoryItems = useDeepCompareMemo(() => {
|
|
143
|
-
const recursiveCategory = (categories = [], parentCategoryCode = '') => categories
|
|
143
|
+
const recursiveCategory = (categories = [], parentCategoryCode = '') => categories
|
|
144
|
+
.map(category => {
|
|
144
145
|
const { categoryCode, categoryId, categoryName, children, total } = category;
|
|
145
146
|
const key = Array.isArray(children) && children.length
|
|
146
147
|
? categoryCode
|
|
@@ -151,6 +152,13 @@ export const useTemplateListing = (options) => {
|
|
|
151
152
|
total,
|
|
152
153
|
children: recursiveCategory(children || [], categoryCode),
|
|
153
154
|
};
|
|
155
|
+
})
|
|
156
|
+
.filter(category => {
|
|
157
|
+
// Filter category has no children and total template is 0
|
|
158
|
+
if (isEmpty(category.children) && !category.total) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
154
162
|
});
|
|
155
163
|
return recursiveCategory(categoryList || []);
|
|
156
164
|
}, [categoryList]);
|
package/es/test.js
CHANGED
|
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
11
|
-
import React from 'react';
|
|
11
|
+
import React, { useState } from 'react';
|
|
12
12
|
import { createRoot } from 'react-dom/client';
|
|
13
13
|
import '@antscorp/icons/main.css';
|
|
14
|
-
import { ConfigProvider,
|
|
14
|
+
import { Button, ConfigProvider, TemplateSaveAsModal, useTemplateSave, } from './components';
|
|
15
15
|
// Constants
|
|
16
16
|
import { GET_LIST_TYPE, OBJECT_TYPES, PUBLIC_LEVEL } from './constants';
|
|
17
17
|
// import { Slider } from 'antd';
|
|
@@ -48,7 +48,7 @@ const SHARE_ACCESS_DEFAULT_VALUE = {
|
|
|
48
48
|
publicRole: null,
|
|
49
49
|
};
|
|
50
50
|
const thumbnailPortrait = [
|
|
51
|
-
'https://
|
|
51
|
+
'https://upload.wikimedia.org/wikipedia/commons/3/3d/LARGE_elevation.jpg',
|
|
52
52
|
'https://images.unsplash.com/photo-1571423483570-eb27018d1ec0?q=80&w=1887&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
|
|
53
53
|
'https://images.creativefabrica.com/products/previews/2023/11/03/jG9YjMvHg/2XfoTnjLlEvPMgjGeu0VIDk96mr-desktop.jpg',
|
|
54
54
|
];
|
|
@@ -71,7 +71,7 @@ const getUserInfos = (email) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
71
71
|
return data;
|
|
72
72
|
});
|
|
73
73
|
export const App = () => {
|
|
74
|
-
const { categoryItems, templateItems, value: templateValue, onChange:
|
|
74
|
+
const { categoryItems, templateItems, value: templateValue, onChange: onChangeTemplateValue, searchNameProps, form, } = useTemplateSave({
|
|
75
75
|
service: {
|
|
76
76
|
url: 'https://sandbox-media-template.antsomi.com/cdp/api/v1',
|
|
77
77
|
token: '5474r2x214z254a4u2a4y444m4j5p27444c4h4h4n5t5',
|
|
@@ -89,20 +89,72 @@ export const App = () => {
|
|
|
89
89
|
saveOption: 'save-new',
|
|
90
90
|
},
|
|
91
91
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
92
|
+
const [isOpenSaveTemplate, setIsOpenSaveTemplate] = useState(false);
|
|
93
|
+
return (
|
|
94
|
+
// <TemplateSaveAs
|
|
95
|
+
// form={form}
|
|
96
|
+
// imageReview={{
|
|
97
|
+
// thumbnails,
|
|
98
|
+
// skeleton: true,
|
|
99
|
+
// }}
|
|
100
|
+
// categories={categoryItems}
|
|
101
|
+
// templateNames={templateItems}
|
|
102
|
+
// shareAccess={{
|
|
103
|
+
// show: true,
|
|
104
|
+
// userId: 1600085510,
|
|
105
|
+
// userPermission: {
|
|
106
|
+
// edit: MENU_PERMISSION.CREATED_BY_USER,
|
|
107
|
+
// view: MENU_PERMISSION.NONE,
|
|
108
|
+
// },
|
|
109
|
+
// getUserInfo: getUserInfos,
|
|
110
|
+
// }}
|
|
111
|
+
// templateNamesOptions={{
|
|
112
|
+
// ...searchNameProps,
|
|
113
|
+
// }}
|
|
114
|
+
// value={templateValue}
|
|
115
|
+
// onChange={value => {
|
|
116
|
+
// onChangeValue(value);
|
|
117
|
+
// }}
|
|
118
|
+
// />
|
|
119
|
+
React.createElement(React.Fragment, null,
|
|
120
|
+
React.createElement(Button, { onClick: () => setIsOpenSaveTemplate(true) }, "Open Modal"),
|
|
121
|
+
React.createElement(TemplateSaveAsModal, { open: isOpenSaveTemplate, okButtonProps: { loading: false }, cancelButtonProps: { disabled: false },
|
|
122
|
+
// onCancel={() => {
|
|
123
|
+
// !loadingPersistTemplate && handleCancel();
|
|
124
|
+
// }}
|
|
125
|
+
onOk: (e, value) => {
|
|
126
|
+
console.log('e');
|
|
127
|
+
}, templateProps: {
|
|
128
|
+
form,
|
|
129
|
+
value: templateValue,
|
|
130
|
+
onChange: onChangeTemplateValue,
|
|
131
|
+
// onEvent: event => {
|
|
132
|
+
// if (event.templateName && event.templateName.id)
|
|
133
|
+
// setSelectedTemplate(event.templateName.id.toString());
|
|
134
|
+
// },
|
|
135
|
+
imageReview: {
|
|
136
|
+
thumbnails: [],
|
|
137
|
+
skeleton: true,
|
|
138
|
+
},
|
|
139
|
+
templateNames: templateItems,
|
|
140
|
+
categories: categoryItems,
|
|
141
|
+
omitCategories: ['device_type', 'template_type'],
|
|
142
|
+
shareAccess: {
|
|
143
|
+
// getUserInfo: email => permissionServices.getUserInfo(email, userInfo?.user_id!) as any,
|
|
144
|
+
show: true,
|
|
145
|
+
// userId: +userInfo?.user_id!,
|
|
146
|
+
userPermission: {
|
|
147
|
+
edit: MENU_PERMISSION.CREATED_BY_USER,
|
|
148
|
+
view: MENU_PERMISSION.CREATED_BY_USER,
|
|
149
|
+
},
|
|
150
|
+
placeholder: 'Add people',
|
|
151
|
+
generalAccessSettings: {
|
|
152
|
+
publicOnlyWith: true,
|
|
153
|
+
},
|
|
154
|
+
allowAddUser: true,
|
|
155
|
+
},
|
|
156
|
+
templateNamesOptions: Object.assign({}, searchNameProps),
|
|
157
|
+
} })));
|
|
106
158
|
};
|
|
107
159
|
const container = document.getElementById('root');
|
|
108
160
|
const root = createRoot(container);
|