@antscorp/antsomi-ui 1.3.5-beta.246 → 1.3.5-beta.247
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/ThumbnailCard/ThumbnailCard.js +2 -3
- package/es/components/molecules/ThumbnailCard/types.d.ts +1 -0
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.js +4 -2
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.js +2 -1
- package/es/components/template/TemplateListing/index.js +4 -2
- package/es/utils/common.js +1 -1
- package/package.json +1 -1
|
@@ -29,10 +29,9 @@ import { Button, Flex, Spin, Typography } from '../../atoms';
|
|
|
29
29
|
// Constants
|
|
30
30
|
import { THUMBNAIL_CARD_DEFAULT_HEIGHT, THUMBNAIL_CARD_DEFAULT_WIDTH } from './constants';
|
|
31
31
|
import { getUrlNoCache, checkShowSkeletonBaseUrl } from '@antscorp/antsomi-ui/es/utils';
|
|
32
|
-
const cacheValue = new Date().getTime();
|
|
33
32
|
export const ThumbnailCard = memo(props => {
|
|
34
33
|
const [modal, contextHolder] = Modal.useModal();
|
|
35
|
-
const { id, name, width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, thumbnail, thumbnailFit, removable = true, actionAvailable = true, showSkeleton, loading = false, removeModalProps, editBtnProps, previewBtnProps, onClickWrapper } = props, restOfProps = __rest(props, ["id", "name", "width", "height", "thumbnail", "thumbnailFit", "removable", "actionAvailable", "showSkeleton", "loading", "removeModalProps", "editBtnProps", "previewBtnProps", "onClickWrapper"]);
|
|
34
|
+
const { id, name, width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, thumbnail, thumbnailFit, removable = true, actionAvailable = true, showSkeleton, loading = false, removeModalProps, editBtnProps, previewBtnProps, thumbnailCacheValue, onClickWrapper } = props, restOfProps = __rest(props, ["id", "name", "width", "height", "thumbnail", "thumbnailFit", "removable", "actionAvailable", "showSkeleton", "loading", "removeModalProps", "editBtnProps", "previewBtnProps", "thumbnailCacheValue", "onClickWrapper"]);
|
|
36
35
|
const _a = removeModalProps || {}, { onOk } = _a, restOfRemoveTemplateModalProps = __rest(_a, ["onOk"]);
|
|
37
36
|
const _b = editBtnProps || {}, { text: editText = 'Use template', onClick: onClickEdit } = _b, restOfEditBtnProps = __rest(_b, ["text", "onClick"]);
|
|
38
37
|
const _c = previewBtnProps || {}, { text: previewText = 'Preview', onClick: onClickPreview } = _c, restOfPreviewBtnProps = __rest(_c, ["text", "onClick"]);
|
|
@@ -60,7 +59,7 @@ export const ThumbnailCard = memo(props => {
|
|
|
60
59
|
};
|
|
61
60
|
return (React.createElement(Flex, Object.assign({ gap: 10, vertical: true }, restOfProps, { style: Object.assign({ width }, restOfProps.style) }),
|
|
62
61
|
React.createElement(ThumbnailCardWrapper, { "$showSkeleton": showSkeletonMemo, style: { height, cursor: actionAvailable ? 'default' : 'pointer' }, onClick: handleWrapperClick },
|
|
63
|
-
React.createElement("div", { className: "screen" }, thumbnail && (React.createElement("img", { src: getUrlNoCache(thumbnail,
|
|
62
|
+
React.createElement("div", { className: "screen" }, thumbnail && (React.createElement("img", { src: getUrlNoCache(thumbnail, thumbnailCacheValue), alt: "", style: { objectFit: thumbnailFit }, onError: e => {
|
|
64
63
|
e.currentTarget.style.display = 'none';
|
|
65
64
|
} }))),
|
|
66
65
|
actionAvailable && !loading && (React.createElement(React.Fragment, null,
|
|
@@ -22,5 +22,6 @@ export interface ThumbnailCardProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
22
22
|
actionAvailable?: boolean;
|
|
23
23
|
removeModalProps?: TRemoveModalProps;
|
|
24
24
|
thumbnailFit?: React.CSSProperties['objectFit'];
|
|
25
|
+
thumbnailCacheValue?: string | number;
|
|
25
26
|
onClickWrapper?: (id: TThumbnailCardId) => void;
|
|
26
27
|
}
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
// Libraries
|
|
13
|
-
import React, { memo } from 'react';
|
|
13
|
+
import React, { memo, useMemo } from 'react';
|
|
14
14
|
import { isEmpty } from 'lodash';
|
|
15
15
|
// Components
|
|
16
16
|
import { ThumbnailCard } from '../../../../molecules';
|
|
@@ -23,10 +23,12 @@ export const SimilarTemplate = memo(props => {
|
|
|
23
23
|
var _a;
|
|
24
24
|
const { show = true, similarTemplates = [], similarCardProps } = props;
|
|
25
25
|
const _b = similarCardProps || {}, { width = SIMILAR_CARD_WIDTH_DEFAULT, height = SIMILAR_CARD_HEIGHT_DEFAULT } = _b, restOfSimilarCardProps = __rest(_b, ["width", "height"]);
|
|
26
|
+
// Memo
|
|
27
|
+
const thumbnailCacheValue = useMemo(() => new Date().getTime(), []);
|
|
26
28
|
return show && !isEmpty(similarTemplates) ? (React.createElement(SimilarTemplateWrapper, { gap: 15, vertical: true },
|
|
27
29
|
React.createElement("div", { className: "title" }, "Similar templates"),
|
|
28
30
|
React.createElement(TemplateListWrapper, { templateQuantity: MAX_QUANTITY_TEMPLATES }, (_a = similarTemplates.slice(0, MAX_QUANTITY_TEMPLATES)) === null || _a === void 0 ? void 0 : _a.map((item, idx) => {
|
|
29
31
|
const { id, name, thumbnail } = item || {};
|
|
30
|
-
return (React.createElement(ThumbnailCard, Object.assign({ key: id, id: id || idx, name: name, width: width, height: height, thumbnail: thumbnail, actionAvailable: false, className: "thumbnail-card" }, restOfSimilarCardProps)));
|
|
32
|
+
return (React.createElement(ThumbnailCard, Object.assign({ key: id, id: id || idx, name: name, width: width, height: height, thumbnail: thumbnail, actionAvailable: false, className: "thumbnail-card", thumbnailCacheValue: thumbnailCacheValue }, restOfSimilarCardProps)));
|
|
31
33
|
})))) : null;
|
|
32
34
|
});
|
|
@@ -44,6 +44,7 @@ export const ThumbnailSlider = memo(props => {
|
|
|
44
44
|
const calculate = ((thumbnails === null || thumbnails === void 0 ? void 0 : thumbnails.length) || 0) * thumbnailWrapperWidth;
|
|
45
45
|
return calculate > WRAPPER_WIDTH;
|
|
46
46
|
}, [thumbnails === null || thumbnails === void 0 ? void 0 : thumbnails.length, thumbnailWrapperWidth]);
|
|
47
|
+
const thumbnailCacheValue = useMemo(() => new Date().getTime(), []);
|
|
47
48
|
// Renders
|
|
48
49
|
const renderThumbnail = (args) => {
|
|
49
50
|
const { thumbnail, index } = args;
|
|
@@ -51,7 +52,7 @@ export const ThumbnailSlider = memo(props => {
|
|
|
51
52
|
return (React.createElement(Flex, { gap: GAP_X },
|
|
52
53
|
!!index && (React.createElement(Flex, { align: "center" },
|
|
53
54
|
React.createElement(Icon, { type: "icon-ants-expand-more", style: { fontSize: ICON_SIZE, transform: 'rotate(270deg)' } }))),
|
|
54
|
-
React.createElement(ThumbnailCard, Object.assign({ key: id, id: id, width: width, height: height, thumbnail: url, style: { flexShrink: 0 }, className: "thumbnail-animation", actionAvailable: false, onClickWrapper: () => onClickThumbnail === null || onClickThumbnail === void 0 ? void 0 : onClickThumbnail(thumbnail) }, restOfThumbnailProps))));
|
|
55
|
+
React.createElement(ThumbnailCard, Object.assign({ key: id, id: id, width: width, height: height, thumbnail: url, thumbnailCacheValue: thumbnailCacheValue, style: { flexShrink: 0 }, className: "thumbnail-animation", actionAvailable: false, onClickWrapper: () => onClickThumbnail === null || onClickThumbnail === void 0 ? void 0 : onClickThumbnail(thumbnail) }, restOfThumbnailProps))));
|
|
55
56
|
};
|
|
56
57
|
return thumbnails && !isEmpty(thumbnails) ? (React.createElement(ThumbnailSliderWrapper, null, isShowSwiper ? (React.createElement(React.Fragment, null,
|
|
57
58
|
React.createElement(Swiper, { slidesPerView: Math.floor(WRAPPER_WIDTH / thumbnailWrapperWidth), spaceBetween: GAP_X, modules: [Navigation, A11y, Thumbs], navigation: {
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
/* eslint-disable react/function-component-definition */
|
|
13
13
|
// Libraries
|
|
14
|
-
import React, { memo, useState } from 'react';
|
|
14
|
+
import React, { memo, useMemo, useState } from 'react';
|
|
15
15
|
// Components
|
|
16
16
|
import { CategoryListing, BlankTemplate, Empty } from './components';
|
|
17
17
|
import { Spin } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
@@ -35,6 +35,8 @@ export const TemplateListing = memo(props => {
|
|
|
35
35
|
const _b = templateItemProps || {}, { width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, previewBtnProps } = _b, restOfTemplateItemProps = __rest(_b, ["width", "height", "previewBtnProps"]);
|
|
36
36
|
const { onClick: onClickPreview } = previewBtnProps || {};
|
|
37
37
|
const isHasData = items.length > 0;
|
|
38
|
+
// Memo
|
|
39
|
+
const thumbnailCacheValue = useMemo(() => new Date().getTime(), []);
|
|
38
40
|
// Hooks
|
|
39
41
|
const { ref: containerRef, itemPerRow, ratio, gap: listingGap, } = useListingItemResize({
|
|
40
42
|
gap,
|
|
@@ -82,7 +84,7 @@ export const TemplateListing = memo(props => {
|
|
|
82
84
|
const loading = typeof (item === null || item === void 0 ? void 0 : item.name) === 'undefined';
|
|
83
85
|
return (React.createElement("div", { key: id },
|
|
84
86
|
index === items.length - 2 && React.createElement(LoadMoreBlock, { ref: loadMoreRef }),
|
|
85
|
-
React.createElement(ThumbnailCard, Object.assign({ id: id || 0, name: name || 'Untitled', loading: loading, width: width * ratio, height: height * ratio, thumbnail: thumbnail, className: `${templateItemProps.className}`, previewBtnProps: {
|
|
87
|
+
React.createElement(ThumbnailCard, Object.assign({ id: id || 0, name: name || 'Untitled', loading: loading, width: width * ratio, height: height * ratio, thumbnail: thumbnail, className: `${templateItemProps.className}`, thumbnailCacheValue: thumbnailCacheValue, previewBtnProps: {
|
|
86
88
|
onClick: handleClickThumbnailPreview,
|
|
87
89
|
} }, restOfTemplateItemProps))));
|
|
88
90
|
}))),
|
package/es/utils/common.js
CHANGED
|
@@ -477,7 +477,7 @@ export const isExistedImage = (imageUrl) => {
|
|
|
477
477
|
};
|
|
478
478
|
export const getUrlNoCache = (url = '', cacheValue = 0) => {
|
|
479
479
|
let urlNoCache = url;
|
|
480
|
-
if (urlNoCache.includes('nocache') || url.startsWith('data:image')) {
|
|
480
|
+
if (urlNoCache.includes('nocache') || url.startsWith('data:image') || !cacheValue) {
|
|
481
481
|
urlNoCache = url;
|
|
482
482
|
}
|
|
483
483
|
else {
|