@antscorp/antsomi-ui 1.3.5-beta.246 → 1.3.5-beta.248

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.
@@ -19,13 +19,17 @@ export const TemplateSaveAsStyled = styled(Flex) `
19
19
  }
20
20
 
21
21
  .template-container {
22
- flex: 0 0 670px;
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,17 +96,28 @@ export const TemplateSaveAsStyled = styled(Flex) `
92
96
 
93
97
  .category-container {
94
98
  flex: 1;
95
- display: grid;
96
- grid-template-columns: repeat(2, minmax(100px, 250px));
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
- height: 30px;
115
+ box-sizing: border-box;
116
+ width: 250px;
117
+ height: 36px;
103
118
  border: 1px solid #b8cfe6;
104
- padding: 0 5px;
105
119
  border-radius: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.borderRadiusXL}px;
120
+ padding: 0 10px;
106
121
 
107
122
  & > .remove-btn {
108
123
  cursor: pointer;
@@ -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, cacheValue), alt: "", style: { objectFit: thumbnailFit }, onError: e => {
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
  }))),
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.246",
3
+ "version": "1.3.5-beta.248",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",