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

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.
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  interface BigImageProps {
3
3
  url?: string;
4
+ showSkeleton?: boolean;
4
5
  isDefaultThumbnail?: boolean;
5
6
  isHideDefaultButton?: boolean;
6
7
  index: number;
@@ -2,8 +2,9 @@ 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
6
  export const BigImage = React.memo(props => {
6
- const { url, isDefaultThumbnail, isHideDefaultButton, index, onClickDefaultButton } = props;
7
+ const { url, isDefaultThumbnail, isHideDefaultButton, index, showSkeleton, onClickDefaultButton, } = props;
7
8
  const currentTime = useMemo(() => new Date(), []);
8
9
  const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
9
10
  const urlNoCache = url
@@ -11,8 +12,9 @@ export const BigImage = React.memo(props => {
11
12
  ? url
12
13
  : `${url}?nocache=${timeGenerated}`
13
14
  : undefined;
14
- return (React.createElement("div", { className: "image-container--big" },
15
- url ? (React.createElement(Image, { preview: false, width: "80%", height: "96%", src: urlNoCache })) : null,
15
+ const showSkeletonMemo = showSkeleton !== undefined ? showSkeleton : checkShowSkeletonBaseUrl(urlNoCache);
16
+ return (React.createElement("div", { className: `image-container--big ${!showSkeletonMemo ? 'hide-skeleton' : ''}` },
17
+ url ? (React.createElement(Image, { preview: false, width: "100%", height: "100%", src: urlNoCache })) : null,
16
18
  isHideDefaultButton ? null : (React.createElement(Button, { className: "set-default-button", onClick: () => onClickDefaultButton && onClickDefaultButton(index) },
17
19
  isDefaultThumbnail ? React.createElement(Icon, { type: "icon-ants-check", style: { fontSize: '12px' } }) : null,
18
20
  isDefaultThumbnail ? 'Default thumbnail' : 'Set as default'))));
@@ -55,8 +55,8 @@ export const ImageSlider = props => {
55
55
  }
56
56
  }, [onSelectDefault]);
57
57
  return (React.createElement(ImageSliderStyled, { className: className || '', "$skeleton": skeleton, "$imageWidth": imageWidth, "$smallImageWidth": smallImageWidth, "$imageHeight": imageHeight, vertical: true, gap: 10 },
58
- React.createElement(Flex, { className: "thumbnail-preview-container", ref: thumbnailSelectedRef }, isLoading ? (React.createElement(Spin, { spinning: true })) : (thumbnails.map((url, index) => (React.createElement(BigImage, { key: `image-big_${url}_${index * 2}`, url: url, index: index, isDefaultThumbnail: defaultThumbnailInternal === index, isHideDefaultButton: hideDefaultButton || hideThumbnailsList || thumbnails.length <= 1, onClickDefaultButton: handleClickDefault }))))),
59
- hideThumbnailsList || thumbnails.length <= 1 ? null : (React.createElement(Flex, { gap: 10, className: "thumbnail-slider-container", ref: sliderContainerRef, style: { justifyContent: thumbnails.length < slidesPerView ? 'center' : 'flex-start' } }, isLoading ? (React.createElement(Spin, { spinning: true })) : (thumbnails.map((url, index) => (React.createElement(SmallImage, { key: `${url}_${index * 2}`, isSelected: index === selectedThumbnail, url: url, index: index, onClick: handleSelectThumbnail })))))),
58
+ React.createElement(Flex, { className: "thumbnail-preview-container", ref: thumbnailSelectedRef }, isLoading ? (React.createElement(Spin, { spinning: true })) : (thumbnails.map((url, index) => (React.createElement(BigImage, { key: `image-big_${url}_${index * 2}`, url: url, index: index, showSkeleton: skeleton, isDefaultThumbnail: defaultThumbnailInternal === index, isHideDefaultButton: hideDefaultButton || hideThumbnailsList || thumbnails.length <= 1, onClickDefaultButton: handleClickDefault }))))),
59
+ hideThumbnailsList || thumbnails.length <= 1 ? null : (React.createElement(Flex, { gap: 10, className: "thumbnail-slider-container", ref: sliderContainerRef, style: { justifyContent: thumbnails.length < slidesPerView ? 'center' : 'flex-start' } }, isLoading ? (React.createElement(Spin, { spinning: true })) : (thumbnails.map((url, index) => (React.createElement(SmallImage, { key: `${url}_${index * 2}`, showSkeleton: skeleton, isSelected: index === selectedThumbnail, url: url, index: index, onClick: handleSelectThumbnail })))))),
60
60
  previewNavigation && !isLoading ? (React.createElement(React.Fragment, null,
61
61
  React.createElement(ButtonSlider, { direction: "left", type: "preview", onClick: handlePrevThumbnail }),
62
62
  React.createElement(ButtonSlider, { direction: "right", type: "preview", onClick: handleNextThumbnail }))) : null,
@@ -3,6 +3,7 @@ interface SmallImageProps {
3
3
  url?: string;
4
4
  isSelected?: boolean;
5
5
  index: number;
6
+ showSkeleton?: boolean;
6
7
  onClick?: (index: number) => void;
7
8
  }
8
9
  export declare const SmallImage: React.FC<SmallImageProps>;
@@ -1,7 +1,8 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { Image } from 'antd';
3
+ import { checkShowSkeletonBaseUrl } from '@antscorp/antsomi-ui/es/utils';
3
4
  export const SmallImage = React.memo(props => {
4
- const { url, isSelected, index, onClick } = props;
5
+ const { url, isSelected, index, onClick, showSkeleton } = props;
5
6
  const currentTime = useMemo(() => new Date(), []);
6
7
  const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
7
8
  const urlNoCache = url
@@ -9,7 +10,8 @@ export const SmallImage = React.memo(props => {
9
10
  ? url
10
11
  : `${url}?nocache=${timeGenerated}`
11
12
  : undefined;
12
- return (React.createElement("div", { className: `image-container--small ${isSelected ? 'image-container--selected' : ''}`, onClick: () => onClick && onClick(index) }, url ? (React.createElement(Image, { preview: false, width: "80%", height: "96%",
13
+ const showSkeletonMemo = showSkeleton !== undefined ? showSkeleton : checkShowSkeletonBaseUrl(urlNoCache);
14
+ 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%",
13
15
  // src={imageUrl}
14
16
  // src={url}
15
17
  src: urlNoCache })) : null));
@@ -4,14 +4,10 @@ import { Flex } from '@antscorp/antsomi-ui/es/components';
4
4
  // Assets
5
5
  import SkeletonBg from '@antscorp/antsomi-ui/es/assets/images/skeleton_bg.png';
6
6
  const backgroundImage = css `
7
- ${props => props.$skeleton
8
- ? css `
9
- background: url(${SkeletonBg}) no-repeat center center, #e5e5e5;
10
- background-size: contain;
11
- `
12
- : css `
13
- background: #e5e5e5;
14
- `}
7
+ ${() => css `
8
+ background: url(${SkeletonBg}) no-repeat center center, #e5e5e5;
9
+ background-size: contain;
10
+ `}
15
11
  `;
16
12
  const setWidthHeight = ({ w, h }) => `
17
13
  width: ${w};
@@ -141,8 +137,12 @@ export const ImageSliderStyled = styled(Flex) `
141
137
  .image-container {
142
138
  &--big,
143
139
  &--small {
140
+ background: #e5e5e5;
144
141
  ${centerBlock}
145
- ${backgroundImage}
142
+ &:not(.hide-skeleton) {
143
+ ${backgroundImage}
144
+ }
145
+
146
146
  img {
147
147
  object-fit: contain;
148
148
  }
@@ -28,16 +28,22 @@ import { ThumbnailCardWrapper } from './styled';
28
28
  import { Button, Flex, Spin, Typography } 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
+ import { getUrlNoCache, checkShowSkeletonBaseUrl } from '@antscorp/antsomi-ui/es/utils';
32
32
  const cacheValue = new Date().getTime();
33
33
  export const ThumbnailCard = memo(props => {
34
34
  const [modal, contextHolder] = Modal.useModal();
35
- 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"]);
35
+ const { id, name, width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, thumbnail, removable = true, actionAvailable = true, showSkeleton, loading = false, removeModalProps, editBtnProps, previewBtnProps, onClickWrapper } = props, restOfProps = __rest(props, ["id", "name", "width", "height", "thumbnail", "removable", "actionAvailable", "showSkeleton", "loading", "removeModalProps", "editBtnProps", "previewBtnProps", "onClickWrapper"]);
36
36
  const _a = removeModalProps || {}, { onOk } = _a, restOfRemoveTemplateModalProps = __rest(_a, ["onOk"]);
37
37
  const _b = editBtnProps || {}, { text: editText = 'Use template', onClick: onClickEdit } = _b, restOfEditBtnProps = __rest(_b, ["text", "onClick"]);
38
38
  const _c = previewBtnProps || {}, { text: previewText = 'Preview', onClick: onClickPreview } = _c, restOfPreviewBtnProps = __rest(_c, ["text", "onClick"]);
39
39
  // Memo
40
- const showSkeletonMemo = typeof showSkeleton === 'function' ? showSkeleton(props) : showSkeleton;
40
+ const showSkeletonMemo =
41
+ // NOTES: Hot fix for showSkeleton base url if showSkeleton is not defined
42
+ typeof showSkeleton === 'undefined'
43
+ ? checkShowSkeletonBaseUrl(thumbnail)
44
+ : typeof showSkeleton === 'function'
45
+ ? showSkeleton(props)
46
+ : showSkeleton;
41
47
  // Handlers
42
48
  const handleRemoveThumbnail = e => {
43
49
  e.stopPropagation();
@@ -1,2 +1,3 @@
1
1
  import { ObjectTemplate } from '../models/ObjectTemplate';
2
2
  export declare const getCategoriesFromObjectTemplate: (objectTemplate: ObjectTemplate) => {};
3
+ export declare const checkShowSkeletonBaseUrl: (url?: string) => boolean;
@@ -10,3 +10,5 @@ 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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.230",
3
+ "version": "1.3.5-beta.232",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",