@antscorp/antsomi-ui 1.4.8 → 1.4.9
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/assets/images/background/skeleton-background.png +0 -0
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +23 -6
- package/es/components/molecules/TemplateSaveAs/styled.js +20 -5
- package/es/components/molecules/ThumbnailCard/ThumbnailCard.js +2 -3
- package/es/components/molecules/ThumbnailCard/styled.js +5 -1
- package/es/components/molecules/ThumbnailCard/types.d.ts +1 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +2 -1
- 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/constants/theme.js +2 -0
- package/es/utils/common.js +1 -1
- package/package.json +1 -1
|
Binary file
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
var _a, _b;
|
|
1
2
|
// Libraries
|
|
2
3
|
import styled, { css } from 'styled-components';
|
|
3
4
|
import { Flex } from '@antscorp/antsomi-ui/es/components';
|
|
4
5
|
// Assets
|
|
5
|
-
import SkeletonBg from '@antscorp/antsomi-ui/es/assets/images/
|
|
6
|
+
import SkeletonBg from '@antscorp/antsomi-ui/es/assets/images/background/skeleton-background.png';
|
|
7
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
6
8
|
const backgroundImage = css `
|
|
7
9
|
${() => css `
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
&::after {
|
|
11
|
+
content: '';
|
|
12
|
+
position: absolute;
|
|
13
|
+
width: 90%;
|
|
14
|
+
height: 90%;
|
|
15
|
+
background: url(${SkeletonBg}) no-repeat center center;
|
|
16
|
+
background-size: contain;
|
|
17
|
+
z-index: 0;
|
|
18
|
+
}
|
|
10
19
|
`}
|
|
11
20
|
`;
|
|
12
21
|
const setWidthHeight = ({ w, h }) => `
|
|
@@ -125,7 +134,7 @@ export const ImageSliderStyled = styled(Flex) `
|
|
|
125
134
|
width: 100%;
|
|
126
135
|
height: 100%;
|
|
127
136
|
background-color: transparent;
|
|
128
|
-
z-index:
|
|
137
|
+
z-index: 2;
|
|
129
138
|
transition: background-color 150ms ease-in-out;
|
|
130
139
|
}
|
|
131
140
|
|
|
@@ -137,14 +146,21 @@ export const ImageSliderStyled = styled(Flex) `
|
|
|
137
146
|
.image-container {
|
|
138
147
|
&--big,
|
|
139
148
|
&--small {
|
|
140
|
-
|
|
149
|
+
position: relative;
|
|
150
|
+
box-sizing: border-box;
|
|
151
|
+
background: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorBgSkeleton};
|
|
152
|
+
border: 1px solid ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.blue1_1};
|
|
153
|
+
border-radius: 5px;
|
|
154
|
+
|
|
141
155
|
${centerBlock}
|
|
142
156
|
&:not(.hide-skeleton) {
|
|
143
157
|
${backgroundImage}
|
|
144
158
|
}
|
|
145
159
|
|
|
146
160
|
img {
|
|
161
|
+
position: relative;
|
|
147
162
|
object-fit: contain;
|
|
163
|
+
z-index: 1;
|
|
148
164
|
}
|
|
149
165
|
|
|
150
166
|
div:has(> img) {
|
|
@@ -169,7 +185,8 @@ export const ImageSliderStyled = styled(Flex) `
|
|
|
169
185
|
height: 72px;
|
|
170
186
|
flex-shrink: 0;
|
|
171
187
|
|
|
172
|
-
border: 2px solid #e5e5e5;
|
|
188
|
+
/* border: 2px solid #e5e5e5; */
|
|
189
|
+
border-width: 2px;
|
|
173
190
|
border-radius: 2px;
|
|
174
191
|
user-select: none;
|
|
175
192
|
cursor: pointer;
|
|
@@ -19,13 +19,17 @@ export const TemplateSaveAsStyled = styled(Flex) `
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.template-container {
|
|
22
|
-
flex:
|
|
22
|
+
flex: 1 0 680px;
|
|
23
23
|
/* flex: 1 1 60%; */
|
|
24
24
|
max-height: 60vh;
|
|
25
25
|
padding-right: 28px;
|
|
26
26
|
overflow-y: auto;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
.template-container:has(+ .share-access-container) {
|
|
30
|
+
flex-grow: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
.categories-container {
|
|
30
34
|
margin-bottom: 20px;
|
|
31
35
|
}
|
|
@@ -92,16 +96,27 @@ export const TemplateSaveAsStyled = styled(Flex) `
|
|
|
92
96
|
|
|
93
97
|
.category-container {
|
|
94
98
|
flex: 1;
|
|
95
|
-
display:
|
|
96
|
-
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-wrap: wrap;
|
|
101
|
+
min-width: 510px;
|
|
102
|
+
max-width: 510px;
|
|
103
|
+
& > button {
|
|
104
|
+
height: 36px;
|
|
105
|
+
box-sizing: border-box;
|
|
106
|
+
padding: 0 10px;
|
|
107
|
+
}
|
|
108
|
+
/* display: grid;
|
|
109
|
+
grid-template-columns: repeat(2, minmax(100px, 250px)); */
|
|
97
110
|
}
|
|
98
111
|
|
|
99
112
|
.selected-category {
|
|
100
113
|
/* width: 240px; */
|
|
101
114
|
overflow: hidden;
|
|
102
|
-
|
|
115
|
+
box-sizing: border-box;
|
|
116
|
+
width: 250px;
|
|
117
|
+
height: 36px;
|
|
103
118
|
border: 1px solid #b8cfe6;
|
|
104
|
-
padding: 0
|
|
119
|
+
padding: 0 10px;
|
|
105
120
|
border-radius: 3px;
|
|
106
121
|
|
|
107
122
|
& > .remove-btn {
|
|
@@ -29,10 +29,9 @@ import { Button, Flex, Typography, Spin } 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 = 'Edit thumbnail', 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,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
var _a, _b;
|
|
1
2
|
// Libraries
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
// Images
|
|
4
5
|
import skeletonBackground from '../../../assets/images/background/skeleton-background.png';
|
|
6
|
+
// Constants
|
|
7
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
5
8
|
const THUMBNAIL_CARD_RADIUS = 5;
|
|
6
9
|
export const ThumbnailCardWrapper = styled.div `
|
|
7
|
-
background-color:
|
|
10
|
+
background-color: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorBgSkeleton};
|
|
8
11
|
padding: 10px;
|
|
9
12
|
border-radius: ${THUMBNAIL_CARD_RADIUS}px;
|
|
10
13
|
position: relative;
|
|
@@ -13,6 +16,7 @@ export const ThumbnailCardWrapper = styled.div `
|
|
|
13
16
|
display: flex;
|
|
14
17
|
align-items: center;
|
|
15
18
|
justify-content: center;
|
|
19
|
+
border: 1px solid ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.blue1_1};
|
|
16
20
|
|
|
17
21
|
:hover {
|
|
18
22
|
.center-action {
|
|
@@ -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,8 +10,9 @@ export const BannerWrapper = styled.div `
|
|
|
10
10
|
display: flex;
|
|
11
11
|
justify-content: center;
|
|
12
12
|
align-items: center;
|
|
13
|
-
background-color:
|
|
13
|
+
background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorBgSkeleton};
|
|
14
14
|
border-radius: ${globalToken.borderRadius}px;
|
|
15
|
+
border: 1px solid ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue1_1};
|
|
15
16
|
|
|
16
17
|
${props => props.$height
|
|
17
18
|
? css `
|
|
@@ -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,
|
|
@@ -80,7 +82,7 @@ export const TemplateListing = memo(props => {
|
|
|
80
82
|
const loading = typeof (item === null || item === void 0 ? void 0 : item.name) === 'undefined';
|
|
81
83
|
return (React.createElement("div", { key: id },
|
|
82
84
|
index === items.length - 2 && React.createElement(LoadMoreBlock, { ref: loadMoreRef }),
|
|
83
|
-
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: {
|
|
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}`, thumbnailCacheValue: thumbnailCacheValue, previewBtnProps: {
|
|
84
86
|
onClick: handleClickThumbnailPreview,
|
|
85
87
|
} }, restOfTemplateItemProps))));
|
|
86
88
|
}))),
|
package/es/constants/theme.js
CHANGED
package/es/utils/common.js
CHANGED
|
@@ -411,7 +411,7 @@ export const camelCaseToSnakeCase = (object, recursive = false) => {
|
|
|
411
411
|
};
|
|
412
412
|
export const getUrlNoCache = (url = '', cacheValue = 0) => {
|
|
413
413
|
let urlNoCache = url;
|
|
414
|
-
if (urlNoCache.includes('nocache') || url.startsWith('data:image')) {
|
|
414
|
+
if (urlNoCache.includes('nocache') || url.startsWith('data:image') || !cacheValue) {
|
|
415
415
|
urlNoCache = url;
|
|
416
416
|
}
|
|
417
417
|
else {
|