@antscorp/antsomi-ui 1.3.5-beta.87 → 1.3.5-beta.89
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.
|
@@ -41,8 +41,8 @@ export interface TemplateSaveAsProps {
|
|
|
41
41
|
saveOptions?: {
|
|
42
42
|
saveNewText?: string;
|
|
43
43
|
saveExistText?: string;
|
|
44
|
-
saveNewValue?: string;
|
|
45
|
-
saveExistValue?: string;
|
|
44
|
+
readonly saveNewValue?: string;
|
|
45
|
+
readonly saveExistValue?: string;
|
|
46
46
|
};
|
|
47
47
|
categories?: Array<{
|
|
48
48
|
label: string | React.ReactNode;
|
|
@@ -27,7 +27,7 @@ export const TemplateSaveAs = props => {
|
|
|
27
27
|
} = props;
|
|
28
28
|
const { show: isShowShareAccess } = shareAccess, shareAccessProps = __rest(shareAccess, ["show"]);
|
|
29
29
|
const { thumbnails, isLoading: isLoadingThumbnail, skeleton, previewNavigation, slidesPerView, hideThumbnailsList, hideDefaultButton, imageHeight, imageWidth, label: imageReviewLabel, } = imageReview;
|
|
30
|
-
const { isLoading, label: templateLabel, defaultNewTemplateName
|
|
30
|
+
const { isLoading, label: templateLabel, defaultNewTemplateName = `Untitled Media Template#${dayjs().format('YYYY-MM-DD HH:mm:ss')}`, onSearch, onNamePopupScroll, } = templateNamesOptions || {};
|
|
31
31
|
const { label: descriptionLabel, placeholder: descriptionPlaceholder } = descriptionOptions || {};
|
|
32
32
|
const { saveNewText = 'Save as a new media Template', saveExistText = 'Save as an existing media Template', saveNewValue = 'save-new', saveExistValue = 'save-exist', } = saveOptions || {};
|
|
33
33
|
const { saveOption = saveNewValue, templateName, description: defaultTemplateDesc, defaultThumbnail = 0, categories: categoriesValue = {}, accessInfo, } = value || {};
|
|
@@ -37,7 +37,7 @@ export const TemplateSaveAs = props => {
|
|
|
37
37
|
if (searchValueDebounce && onSearch)
|
|
38
38
|
onSearch(searchValueDebounce);
|
|
39
39
|
}, [searchValueDebounce, onSearch]);
|
|
40
|
-
const [templateNameNew, setTemplateNameNew] = useState(defaultNewTemplateName
|
|
40
|
+
const [templateNameNew, setTemplateNameNew] = useState(defaultNewTemplateName);
|
|
41
41
|
const [templateNameExist, setTemplateNameExist] = useState((templateName === null || templateName === void 0 ? void 0 : templateName.id) ? templateName : templateNameList === null || templateNameList === void 0 ? void 0 : templateNameList[0]);
|
|
42
42
|
// NOTE: HOTFIX templateNameExist not update when value outside changed
|
|
43
43
|
useEffect(() => {
|
|
@@ -51,13 +51,7 @@ export const TemplateSaveAs = props => {
|
|
|
51
51
|
onEvent(newValue);
|
|
52
52
|
}
|
|
53
53
|
if (onChange) {
|
|
54
|
-
onChange(Object.assign(Object.assign(Object.assign({}, value),
|
|
55
|
-
// TODO: return saveOption and templateName generate default value if not pass as value props
|
|
56
|
-
defaultThumbnail: newValue.defaultThumbnail || defaultThumbnail,
|
|
57
|
-
// NOTE: if have no saveOption set saveOption value follow this priority => newValue >> value
|
|
58
|
-
saveOption: !(value === null || value === void 0 ? void 0 : value.saveOption) && !newValue.saveOption
|
|
59
|
-
? saveOption
|
|
60
|
-
: newValue.saveOption || (value === null || value === void 0 ? void 0 : value.saveOption) }), (_b = (_a = form === null || form === void 0 ? void 0 : form.getFieldsError()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.errors);
|
|
54
|
+
onChange(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, value), (!(value === null || value === void 0 ? void 0 : value.saveOption) && { saveOption: saveNewValue })), (!(value === null || value === void 0 ? void 0 : value.templateName) && { templateName: { id: undefined, label: templateNameNew } })), (!(value === null || value === void 0 ? void 0 : value.defaultThumbnail) && { defaultThumbnail })), newValue), (_b = (_a = form === null || form === void 0 ? void 0 : form.getFieldsError()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.errors);
|
|
61
55
|
}
|
|
62
56
|
};
|
|
63
57
|
const handleAddCategory = ({ parentKey, item, }) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useCallback, useMemo, useState } from 'react';
|
|
3
3
|
import { useGetTemplateCategoryList, useGetObjectTemplateList, } from '@antscorp/antsomi-ui/es/queries/TemplateListing';
|
|
4
4
|
// Hooks
|
|
5
|
-
import {
|
|
5
|
+
import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
|
|
6
6
|
import { Form } from 'antd';
|
|
7
7
|
import { camelCaseToSnakeCase, snakeCaseToCamelCase } from '@antscorp/antsomi-ui/es/utils';
|
|
8
8
|
/**
|
|
@@ -31,9 +31,6 @@ export const useTemplateSave = (options) => {
|
|
|
31
31
|
return { camelCase, snakeCase };
|
|
32
32
|
};
|
|
33
33
|
const formattedCategoriesValue = useMemo(() => handleFormatCategories(value.categories), [value]);
|
|
34
|
-
useDeepCompareEffect(() => {
|
|
35
|
-
setValue(valueArg || {});
|
|
36
|
-
}, [valueArg]);
|
|
37
34
|
const [form] = Form.useForm();
|
|
38
35
|
const { data: categoryList, isLoading: isLoadingCategoryList, refetch: refetchCategoryList, } = useGetTemplateCategoryList({
|
|
39
36
|
args: {
|