@antscorp/antsomi-ui 1.4.2 → 1.4.4

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.
@@ -123,7 +123,7 @@ export const TemplateSaveAs = props => {
123
123
  form.setFieldValue('categories', newCategory);
124
124
  handleChangeValue({ categories: newCategory });
125
125
  };
126
- return (React.createElement(Form, { form: form, initialValues: initFormValue, colon: false, labelAlign: "left" },
126
+ return (React.createElement(Form, { form: form, initialValues: initFormValue, colon: false, labelAlign: "left", style: { height: '100%' } },
127
127
  React.createElement(TemplateSaveAsStyled, { className: className || '', vertical: true },
128
128
  React.createElement(Flex, { className: "save-options-container" },
129
129
  React.createElement(Form.Item, { name: "saveOption", noStyle: true },
@@ -132,7 +132,7 @@ export const useTemplateSave = (options) => {
132
132
  },
133
133
  });
134
134
  if (response.existed) {
135
- return Promise.reject(new Error('Template name already exists'));
135
+ return Promise.reject(new Error('This name has already existed'));
136
136
  }
137
137
  return Promise.resolve();
138
138
  }), [objectType, publicLevel, service, validateTemplateName]);
@@ -6,6 +6,7 @@ import { Flex } from '@antscorp/antsomi-ui/es/components';
6
6
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
7
7
  export const TemplateSaveAsStyled = styled(Flex) `
8
8
  /* max-width: 1177px; */
9
+ height: 100%;
9
10
 
10
11
  .save-options-container {
11
12
  padding: 15px 0;
@@ -13,6 +14,10 @@ export const TemplateSaveAsStyled = styled(Flex) `
13
14
  border-bottom: 1px dashed #e5e5e5;
14
15
  }
15
16
 
17
+ div:has(> .template-container) {
18
+ height: 100%;
19
+ }
20
+
16
21
  .template-container {
17
22
  flex: 1 1 60%;
18
23
  max-height: 60vh;
@@ -32,7 +37,7 @@ export const TemplateSaveAsStyled = styled(Flex) `
32
37
  flex: 1 1 40%;
33
38
  padding-left: 20px;
34
39
  margin-left: 5px;
35
- max-height: 60vh;
40
+ /* max-height: 60vh; */
36
41
  overflow-y: auto;
37
42
  border-left: 1px solid #e5e5e5;
38
43
 
@@ -28,6 +28,8 @@ 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';
32
+ const cacheValue = new Date().getTime();
31
33
  export const ThumbnailCard = memo(props => {
32
34
  const [modal, contextHolder] = Modal.useModal();
33
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"]);
@@ -52,7 +54,7 @@ export const ThumbnailCard = memo(props => {
52
54
  };
53
55
  return (React.createElement(Flex, Object.assign({ gap: 10, vertical: true }, restOfProps, { style: Object.assign({ width }, restOfProps.style) }),
54
56
  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: "" })),
57
+ React.createElement("div", { className: "screen" }, thumbnail && React.createElement("img", { src: getUrlNoCache(thumbnail, cacheValue), alt: "" })),
56
58
  actionAvailable && !loading && (React.createElement(React.Fragment, null,
57
59
  React.createElement(Flex, { className: "center-action", align: "center", gap: 10, vertical: true },
58
60
  React.createElement(Button, Object.assign({ type: "primary", className: "animate__animated animate__fadeIn" }, restOfEditBtnProps, { onClick: e => {
@@ -163,7 +163,6 @@ export const useTemplateListing = (options) => {
163
163
  return recursiveCategory(categoryList || []);
164
164
  }, [categoryList]);
165
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 });
167
166
  const similarTemplates = useMemo(() => {
168
167
  const maxSimilarTemplateLength = 4;
169
168
  return (getShuffleArray(templateItems.filter(item => (item === null || item === void 0 ? void 0 : item.id) !== selectedTemplateId)).slice(0, maxSimilarTemplateLength) || []);
@@ -66,23 +66,24 @@ export const TemplateListing = memo(props => {
66
66
  React.createElement(CategoryListing, Object.assign({}, categoryListingProps, { emptyProps: emptyProps })),
67
67
  React.createElement(TemplateWrapper, { className: wrapperClassName, style: wrapperStyle },
68
68
  header,
69
- React.createElement(Spin, { spinning: loading, wrapperClassName: "template-listing__loading template-listing__loading--full" },
69
+ React.createElement(Spin, { spinning: loading || !itemPerRow, wrapperClassName: "template-listing__loading template-listing__loading--full" },
70
70
  React.createElement("div", { className: "template-listing" },
71
71
  React.createElement("div", { ref: containerRef, style: {
72
72
  display: 'grid',
73
73
  gap: listingGap,
74
74
  gridTemplateColumns: `repeat(${itemPerRow}, minmax(0, 1fr))`,
75
75
  } },
76
- React.createElement(BlankTemplate, Object.assign({ width: width * ratio, height: height * ratio }, blankTemplateProps)), items === null || items === void 0 ? void 0 :
77
- items.map((item, index) => {
78
- const { id, name, thumbnail } = item || {};
79
- const loading = typeof (item === null || item === void 0 ? void 0 : item.name) === 'undefined';
80
- return (React.createElement("div", { key: id || index },
81
- index === items.length - 2 && React.createElement(LoadMoreBlock, { ref: loadMoreRef }),
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: {
83
- onClick: handleClickThumbnailPreview,
84
- } }, restOfTemplateItemProps))));
85
- })),
76
+ React.createElement(BlankTemplate, Object.assign({ width: width * ratio, height: height * ratio }, blankTemplateProps)),
77
+ !!itemPerRow &&
78
+ (items === null || items === void 0 ? void 0 : items.map((item, index) => {
79
+ const { id, name, thumbnail } = item || {};
80
+ const loading = typeof (item === null || item === void 0 ? void 0 : item.name) === 'undefined';
81
+ return (React.createElement("div", { key: id },
82
+ 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: {
84
+ onClick: handleClickThumbnailPreview,
85
+ } }, restOfTemplateItemProps))));
86
+ }))),
86
87
  !loading && !blankTemplateProps.show && !isHasData && React.createElement(Empty, Object.assign({}, emptyProps)))),
87
88
  footer),
88
89
  React.createElement(PreviewTemplateModal, Object.assign({ open: openPreviewModal, onOk: handleOkPreviewModal, onCancel: handleCancelPreviewModal }, restOfPreviewModalProps))));
@@ -52,7 +52,7 @@ export const useListingItemResize = (props) => {
52
52
  }
53
53
  timeoutAfterChange.current = setTimeout(() => {
54
54
  forceUpdate();
55
- }, 500);
55
+ }, 200);
56
56
  });
57
57
  return { ref, itemPerRow, ratio, gap };
58
58
  };
@@ -58,3 +58,4 @@ export declare const searchParamsToObject: (searchParams?: string) => Record<str
58
58
  export declare const getShuffleArray: <T>(array: T[]) => T[];
59
59
  export declare const snakeCaseToCamelCase: <T = Record<string, any>>(object: Record<string, any> | Record<string, any>[], recursive?: boolean) => T;
60
60
  export declare const camelCaseToSnakeCase: <T = Record<string, any>>(object: Record<string, any>, recursive?: boolean) => T;
61
+ export declare const getUrlNoCache: (url?: string, cacheValue?: number | string) => string | undefined;
@@ -409,3 +409,11 @@ export const camelCaseToSnakeCase = (object, recursive = false) => {
409
409
  });
410
410
  return newObject;
411
411
  };
412
+ export const getUrlNoCache = (url = '', cacheValue = 0) => {
413
+ const urlNoCache = url
414
+ ? url.includes('nocache') || url.startsWith('data:image')
415
+ ? url
416
+ : `${url}?nocache=${cacheValue}`
417
+ : undefined;
418
+ return urlNoCache;
419
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",