@antscorp/antsomi-ui 1.3.5-beta.232 → 1.3.5-beta.233

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.
@@ -2,16 +2,12 @@ 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
- import { checkShowSkeletonBaseUrl } from '@antscorp/antsomi-ui/es/utils';
5
+ import { checkShowSkeletonBaseUrl, getUrlNoCache } from '@antscorp/antsomi-ui/es/utils';
6
6
  export const BigImage = React.memo(props => {
7
7
  const { url, isDefaultThumbnail, isHideDefaultButton, index, showSkeleton, onClickDefaultButton, } = props;
8
8
  const currentTime = useMemo(() => new Date(), []);
9
9
  const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
10
- const urlNoCache = url
11
- ? url.includes('nocache') || url.startsWith('data:image')
12
- ? url
13
- : `${url}?nocache=${timeGenerated}`
14
- : undefined;
10
+ const urlNoCache = getUrlNoCache(url, timeGenerated);
15
11
  const showSkeletonMemo = showSkeleton !== undefined ? showSkeleton : checkShowSkeletonBaseUrl(urlNoCache);
16
12
  return (React.createElement("div", { className: `image-container--big ${!showSkeletonMemo ? 'hide-skeleton' : ''}` },
17
13
  url ? (React.createElement(Image, { preview: false, width: "100%", height: "100%", src: urlNoCache })) : null,
@@ -1,15 +1,11 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { Image } from 'antd';
3
- import { checkShowSkeletonBaseUrl } from '@antscorp/antsomi-ui/es/utils';
3
+ import { checkShowSkeletonBaseUrl, getUrlNoCache } from '@antscorp/antsomi-ui/es/utils';
4
4
  export const SmallImage = React.memo(props => {
5
5
  const { url, isSelected, index, onClick, showSkeleton } = props;
6
6
  const currentTime = useMemo(() => new Date(), []);
7
7
  const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
8
- const urlNoCache = url
9
- ? url.includes('nocache') || url.startsWith('data:image')
10
- ? url
11
- : `${url}?nocache=${timeGenerated}`
12
- : undefined;
8
+ const urlNoCache = getUrlNoCache(url, timeGenerated);
13
9
  const showSkeletonMemo = showSkeleton !== undefined ? showSkeleton : checkShowSkeletonBaseUrl(urlNoCache);
14
10
  return (React.createElement("div", { className: `image-container--small ${isSelected ? 'image-container--selected' : ''} ${!showSkeletonMemo ? 'hide-skeleton' : ''}`, onClick: () => onClick && onClick(index) }, url ? (React.createElement(Image, { preview: false, width: "100%", height: "100%",
15
11
  // src={imageUrl}
@@ -84,4 +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, cacheValue?: number | string) => string | undefined;
87
+ export declare const getUrlNoCache: (url?: string, cacheValue?: number | string) => string;
@@ -476,10 +476,13 @@ export const isExistedImage = (imageUrl) => {
476
476
  }
477
477
  };
478
478
  export const getUrlNoCache = (url = '', cacheValue = 0) => {
479
- const urlNoCache = url
480
- ? url.includes('nocache') || url.startsWith('data:image')
481
- ? url
482
- : `${url}?nocache=${cacheValue}`
483
- : undefined;
479
+ let urlNoCache = url;
480
+ if (urlNoCache.includes('nocache') || url.startsWith('data:image')) {
481
+ urlNoCache = url;
482
+ }
483
+ else {
484
+ const newUrl = new URL(url);
485
+ newUrl.searchParams.append('nocache', `${cacheValue}`);
486
+ }
484
487
  return urlNoCache;
485
488
  };
@@ -10,5 +10,20 @@ export const getCategoriesFromObjectTemplate = (objectTemplate) => {
10
10
  });
11
11
  return categories;
12
12
  };
13
- export const checkShowSkeletonBaseUrl = (url = '') => `${url || ''}`.includes('base64-img') &&
14
- ['jn_thumb_', 'v_thumb_'].every(prefix => !`${url || ''}`.includes(prefix));
13
+ export const checkShowSkeletonBaseUrl = (url = '') => {
14
+ if (url.includes('type')) {
15
+ switch (true) {
16
+ case url.includes('media'):
17
+ return true;
18
+ case url.includes('email'): {
19
+ return false;
20
+ }
21
+ default:
22
+ return false;
23
+ }
24
+ }
25
+ else {
26
+ return (`${url || ''}`.includes('base64-img') &&
27
+ ['jn_thumb_', 'v_thumb_'].every(prefix => !`${url || ''}`.includes(prefix)));
28
+ }
29
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.232",
3
+ "version": "1.3.5-beta.233",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",