@antscorp/antsomi-ui 1.3.5-beta.192 → 1.3.5-beta.194

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.
@@ -28,6 +28,7 @@ import { ThumbnailCardWrapper } from './styled';
28
28
  import { Button, Flex, Typography, Spin } from '../../atoms';
29
29
  // Constants
30
30
  import { THUMBNAIL_CARD_DEFAULT_HEIGHT, THUMBNAIL_CARD_DEFAULT_WIDTH } from './constants';
31
+ import { getUrlNoCache } from '@antscorp/antsomi-ui/es/utils';
31
32
  export const ThumbnailCard = memo(props => {
32
33
  const [modal, contextHolder] = Modal.useModal();
33
34
  const { id, name, width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, thumbnail, removable = true, actionAvailable = true, showSkeleton = true, loading = false, removeModalProps, editBtnProps, previewBtnProps, onClickWrapper } = props, restOfProps = __rest(props, ["id", "name", "width", "height", "thumbnail", "removable", "actionAvailable", "showSkeleton", "loading", "removeModalProps", "editBtnProps", "previewBtnProps", "onClickWrapper"]);
@@ -52,7 +53,7 @@ export const ThumbnailCard = memo(props => {
52
53
  };
53
54
  return (React.createElement(Flex, Object.assign({ gap: 10, vertical: true }, restOfProps, { style: Object.assign({ width }, restOfProps.style) }),
54
55
  React.createElement(ThumbnailCardWrapper, { "$showSkeleton": showSkeletonMemo, style: { height, cursor: actionAvailable ? 'default' : 'pointer' }, onClick: handleWrapperClick },
55
- React.createElement("div", { className: "screen" }, thumbnail && React.createElement("img", { src: thumbnail, alt: "" })),
56
+ React.createElement("div", { className: "screen" }, thumbnail && React.createElement("img", { src: getUrlNoCache(thumbnail), alt: "" })),
56
57
  actionAvailable && !loading && (React.createElement(React.Fragment, null,
57
58
  React.createElement(Flex, { className: "center-action", align: "center", gap: 10, vertical: true },
58
59
  React.createElement(Button, Object.assign({ type: "primary", className: "animate__animated animate__fadeIn" }, restOfEditBtnProps, { onClick: e => {
@@ -10,7 +10,7 @@ import { useDeepCompareEffect, useDeepCompareMemo } from '@antscorp/antsomi-ui/e
10
10
  // Constants
11
11
  import { CATEGORY_SPLIT_KEY, TEMPLATE_STATUS } from '@antscorp/antsomi-ui/es/constants';
12
12
  import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
13
- import { getShuffleArray } from '@antscorp/antsomi-ui/es/utils';
13
+ import { getShuffleArray, random } from '@antscorp/antsomi-ui/es/utils';
14
14
  /**
15
15
  * Custom React Hook for managing state and data fetching logic related to a template listing.
16
16
  *
@@ -162,7 +162,8 @@ export const useTemplateListing = (options) => {
162
162
  });
163
163
  return recursiveCategory(categoryList || []);
164
164
  }, [categoryList]);
165
- const templateItems = useMemo(() => mockTemplateItems.map((_, index) => flatTemplateItems === null || flatTemplateItems === void 0 ? void 0 : flatTemplateItems[index]) || [], [flatTemplateItems, mockTemplateItems]);
165
+ const templateItems = useMemo(() => mockTemplateItems.map((_, index) => (flatTemplateItems === null || flatTemplateItems === void 0 ? void 0 : flatTemplateItems[index]) || { id: random(10) }) || [], [flatTemplateItems, mockTemplateItems]);
166
+ console.log({ templateItems });
166
167
  const similarTemplates = useMemo(() => {
167
168
  const maxSimilarTemplateLength = 4;
168
169
  return (getShuffleArray(templateItems.filter(item => (item === null || item === void 0 ? void 0 : item.id) !== selectedTemplateId)).slice(0, maxSimilarTemplateLength) || []);
@@ -76,7 +76,7 @@ export const TemplateListing = memo(props => {
76
76
  React.createElement(BlankTemplate, Object.assign({ width: width * ratio, height: height * ratio }, blankTemplateProps)), items === null || items === void 0 ? void 0 :
77
77
  items.map((item, index) => {
78
78
  const { id, name, thumbnail } = item || {};
79
- const loading = typeof item === 'undefined';
79
+ const loading = typeof (item === null || item === void 0 ? void 0 : item.name) === 'undefined';
80
80
  return (React.createElement("div", { key: id || index },
81
81
  index === items.length - 2 && React.createElement(LoadMoreBlock, { ref: loadMoreRef }),
82
82
  React.createElement(ThumbnailCard, Object.assign({ id: id || index, name: name || 'Untitled', loading: loading, width: width * ratio, height: height * ratio, thumbnail: thumbnail, className: `${templateItemProps.className}`, previewBtnProps: {
@@ -17,7 +17,7 @@ import { THEME } from '@antscorp/antsomi-ui/es/constants';
17
17
  const { getDesignToken } = theme;
18
18
  const themeV2 = {
19
19
  token: Object.assign(Object.assign({}, THEME.token), { colorText: '#000000', borderRadius: 10, borderRadiusLG: 10 }),
20
- components: Object.assign(Object.assign({}, THEME.components), { Button: Object.assign(Object.assign({}, (_a = THEME.components) === null || _a === void 0 ? void 0 : _a.Button), { textHoverBg: '#F2F9FF' }) }),
20
+ components: Object.assign(Object.assign({}, THEME.components), { Button: Object.assign(Object.assign({}, (_a = THEME.components) === null || _a === void 0 ? void 0 : _a.Button), { borderRadius: 10, borderRadiusLG: 10, textHoverBg: '#F2F9FF' }) }),
21
21
  };
22
22
  export const AntdConfigProviderV2 = props => {
23
23
  const { children } = props, restProps = __rest(props, ["children"]);
@@ -84,3 +84,4 @@ export declare const simplifyString: (str: string) => string;
84
84
  */
85
85
  export declare const searchStringQuery: (str: string, queryStr: string) => boolean;
86
86
  export declare const isExistedImage: (imageUrl: string) => boolean;
87
+ export declare const getUrlNoCache: (url?: string) => string | undefined;
@@ -475,3 +475,13 @@ export const isExistedImage = (imageUrl) => {
475
475
  return false;
476
476
  }
477
477
  };
478
+ export const getUrlNoCache = (url = '') => {
479
+ const currentTime = new Date();
480
+ const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
481
+ const urlNoCache = url
482
+ ? url.includes('nocache') || url.startsWith('data:image')
483
+ ? url
484
+ : `${url}?nocache=${timeGenerated}`
485
+ : undefined;
486
+ return urlNoCache;
487
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.192",
3
+ "version": "1.3.5-beta.194",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",