@antscorp/antsomi-ui 1.3.5-beta.37 → 1.3.5-beta.39

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.
@@ -22,6 +22,7 @@ export interface TemplateValueOptions {
22
22
  }
23
23
  export interface ImagePreviewOptions {
24
24
  thumbnails: (string | undefined)[];
25
+ isLoading?: boolean;
25
26
  skeleton?: boolean;
26
27
  previewNavigation?: boolean;
27
28
  slidesPerView?: number;
@@ -24,7 +24,7 @@ export const TemplateSaveAs = props => {
24
24
  // onNamePopupScroll,
25
25
  } = props;
26
26
  const { show: isShowShareAccess } = shareAccess, shareAccessProps = __rest(shareAccess, ["show"]);
27
- const { thumbnails, skeleton, previewNavigation, slidesPerView, hideThumbnailsList, hideDefaultButton, label: imageReviewLabel, } = imageReview;
27
+ const { thumbnails, isLoading: isLoadingThumbnail, skeleton, previewNavigation, slidesPerView, hideThumbnailsList, hideDefaultButton, label: imageReviewLabel, } = imageReview;
28
28
  const { isLoading, searchValue, label: templateLabel, defaultNewTemplateName, onSearch, onNamePopupScroll, } = templateNamesOptions || {};
29
29
  const { label: descriptionLabel, placeholder: descriptionPlaceholder } = descriptionOptions || {};
30
30
  const { saveNewText = 'Save as a new media Template', saveExistText = 'Save as an existing media Template', saveNewValue = 'save-new', saveExistValue = 'save-exist', } = saveOptions || {};
@@ -118,7 +118,7 @@ export const TemplateSaveAs = props => {
118
118
  imageReviewLabel || 'Thumbnail template',
119
119
  " ",
120
120
  React.createElement("span", null, "*")),
121
- React.createElement(ImageSlider, { thumbnails: thumbnails, skeleton: skeleton, previewNavigation: previewNavigation, slidesPerView: slidesPerView, defaultThumbnail: defaultThumbnail, onSelectDefault: value => handleChangeValue({ defaultThumbnail: value }), hideThumbnailsList: hideThumbnailsList, hideDefaultButton: hideDefaultButton })), categories === null || categories === void 0 ? void 0 :
121
+ React.createElement(ImageSlider, { thumbnails: thumbnails, isLoading: isLoadingThumbnail, skeleton: skeleton, previewNavigation: previewNavigation, slidesPerView: slidesPerView, defaultThumbnail: defaultThumbnail, onSelectDefault: value => handleChangeValue({ defaultThumbnail: value }), hideThumbnailsList: hideThumbnailsList, hideDefaultButton: hideDefaultButton })), categories === null || categories === void 0 ? void 0 :
122
122
  categories.map(parentCategory => {
123
123
  var _a, _b, _c;
124
124
  const selectedChildren = (_a = categoriesValue
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  interface ImageSliderProps {
3
3
  thumbnails: (string | undefined)[];
4
+ isLoading?: boolean;
4
5
  className?: string;
5
6
  skeleton?: boolean;
6
7
  previewNavigation?: boolean;
@@ -3,13 +3,13 @@ import React, { useState, useRef } from 'react';
3
3
  import { Image } from 'antd';
4
4
  import Icon from '@antscorp/icons';
5
5
  // Components
6
- import { Button, Flex } from '@antscorp/antsomi-ui/es/components';
6
+ import { Button, Flex, Spin } from '@antscorp/antsomi-ui/es/components';
7
7
  // Styles
8
8
  import { ImageSliderStyled } from './styled';
9
9
  import clsx from 'clsx';
10
10
  export const ImageSlider = props => {
11
11
  var _a, _b;
12
- const { thumbnails, className, skeleton, previewNavigation, slidesPerView = 3, hideThumbnailsList, hideDefaultButton, defaultThumbnail, onSelectDefault, } = props;
12
+ const { thumbnails, isLoading, className, skeleton, previewNavigation, slidesPerView = 3, hideThumbnailsList, hideDefaultButton, defaultThumbnail, onSelectDefault, } = props;
13
13
  const sliderContainerRef = useRef(null);
14
14
  const thumbnailSelectedRef = useRef(null);
15
15
  const [selectedThumbnail, setSelectedThumbnail] = useState(0);
@@ -28,14 +28,9 @@ export const ImageSlider = props => {
28
28
  const handlePrevThumbnail = () => {
29
29
  setSelectedThumbnail(prev => (prev === 0 ? thumbnails.length - 1 : prev - 1));
30
30
  };
31
- // useEffect(() => {
32
- // handleScrollToImage();
33
- // // eslint-disable-next-line react-hooks/exhaustive-deps
34
- // }, [selectedThumbnail]);
35
31
  return (React.createElement(ImageSliderStyled, { className: className || '', "$skeleton": skeleton, "$slidesPerView": slidesPerView, vertical: true, gap: 10 },
36
- React.createElement(Flex, { className: "thumbnail-preview-container", ref: thumbnailSelectedRef }, thumbnails.map((url, index) => (React.createElement("div", { key: `image-big_${url}_${index * 2}`, className: clsx('image-container--big', {
32
+ React.createElement(Flex, { className: "thumbnail-preview-container", ref: thumbnailSelectedRef }, isLoading ? (React.createElement(Spin, { spinning: true })) : (thumbnails.map((url, index) => (React.createElement("div", { key: `image-big_${url}_${index * 2}`, className: clsx('image-container--big', {
37
33
  'image-container--default': defaultThumbnailInternal === index,
38
- // 'image-container--default': isSelectedDefault,
39
34
  }) },
40
35
  url ? (React.createElement(Image, { preview: false, width: "80%", height: "96%", src: thumbnails[index] })) : null,
41
36
  hideDefaultButton ? null : (React.createElement(Button, { className: "set-default-button", onClick: () => {
@@ -45,16 +40,16 @@ export const ImageSlider = props => {
45
40
  }
46
41
  } },
47
42
  defaultThumbnailInternal === index ? (React.createElement(Icon, { type: "icon-ants-check", style: { fontSize: '12px' } })) : null,
48
- defaultThumbnailInternal === index ? 'Default thumbnail' : 'Set as default')))))),
49
- hideThumbnailsList ? null : (React.createElement(Flex, { gap: 10, className: "thumbnail-slider-container", ref: sliderContainerRef }, thumbnails.map((url, index) => (React.createElement("div", { key: `${url}_${index * 2}`, className: clsx('image-container--small', {
43
+ defaultThumbnailInternal === index ? 'Default thumbnail' : 'Set as default'))))))),
44
+ hideThumbnailsList ? null : (React.createElement(Flex, { gap: 10, className: "thumbnail-slider-container", ref: sliderContainerRef }, isLoading ? (React.createElement(Spin, { spinning: true })) : (thumbnails.map((url, index) => (React.createElement("div", { key: `${url}_${index * 2}`, className: clsx('image-container--small', {
50
45
  'image-container--selected': index === selectedThumbnail,
51
- }), onClick: () => setSelectedThumbnail(index) }, url ? React.createElement(Image, { key: url, preview: false, width: "80%", height: "96%", src: url }) : null))))),
52
- previewNavigation ? (React.createElement(React.Fragment, null,
46
+ }), onClick: () => setSelectedThumbnail(index) }, url ? (React.createElement(Image, { key: url, preview: false, width: "80%", height: "96%", src: url })) : null)))))),
47
+ previewNavigation && !isLoading ? (React.createElement(React.Fragment, null,
53
48
  React.createElement("div", { className: "change-preview-button change-preview-button--left", onClick: handlePrevThumbnail },
54
49
  React.createElement(Icon, { type: "icon-ants-angle-left" })),
55
50
  React.createElement("div", { className: "change-preview-button change-preview-button--right", onClick: handleNextThumbnail },
56
51
  React.createElement(Icon, { type: "icon-ants-angle-right" })))) : null,
57
- hideThumbnailsList ? null : (React.createElement(React.Fragment, null,
52
+ hideThumbnailsList || isLoading ? null : (React.createElement(React.Fragment, null,
58
53
  React.createElement("div", { className: "slider-button slider-button--left", onClick: handlePrevThumbnail },
59
54
  React.createElement(Icon, { type: "icon-ants-angle-left" })),
60
55
  React.createElement("div", { className: "slider-button slider-button--right", onClick: handleNextThumbnail },
@@ -68,6 +68,20 @@ export const ImageSliderStyled = styled(Flex) `
68
68
  }
69
69
  }
70
70
 
71
+ .thumbnail-preview-container:has(.antsomi-spin),
72
+ .thumbnail-slider-container:has(.antsomi-spin) {
73
+ box-shadow: rgba(159, 180, 180, 0.2) 0px 2px 8px;
74
+ }
75
+
76
+ .thumbnail-preview-container .antsomi-spin,
77
+ .thumbnail-slider-container .antsomi-spin {
78
+ width: 100%;
79
+ display: flex;
80
+ justify-content: center;
81
+ align-items: center;
82
+ background-color: #fcfcfc;
83
+ }
84
+
71
85
  .thumbnail-preview-container {
72
86
  width: 330px;
73
87
  overflow-x: scroll;
@@ -79,6 +93,10 @@ export const ImageSliderStyled = styled(Flex) `
79
93
  & > div {
80
94
  overflow: hidden;
81
95
  }
96
+
97
+ .antsomi-spin {
98
+ height: 230px;
99
+ }
82
100
  }
83
101
 
84
102
  .thumbnail-slider-container {
@@ -86,6 +104,10 @@ export const ImageSliderStyled = styled(Flex) `
86
104
  width: 330px;
87
105
  overflow-x: scroll;
88
106
  scrollbar-width: none;
107
+
108
+ .antsomi-spin {
109
+ height: 72px;
110
+ }
89
111
  }
90
112
 
91
113
  .image-container {
@@ -1,5 +1,6 @@
1
1
  import { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
2
2
  import { TCategoryItem, TCheckedCategories, TTemplateItem } from '../../../template';
3
+ import { TGetTemplateCategoryList, TGetObjectTEmplateList } from '@antscorp/antsomi-ui/es/queries/TemplateListing';
3
4
  import { TTemplateListingConfig } from '@antscorp/antsomi-ui/es/types/templateListing';
4
5
  import { TemplateCategory } from '@antscorp/antsomi-ui/es/models/TemplateCategory';
5
6
  interface TemplateListingOptions {
@@ -8,6 +9,10 @@ interface TemplateListingOptions {
8
9
  filter?: any;
9
10
  };
10
11
  checkedCategoriesDefault?: TCheckedCategories;
12
+ queriesOptions?: {
13
+ categoryList?: TGetTemplateCategoryList['options'];
14
+ templateList?: TGetObjectTEmplateList['options'];
15
+ };
11
16
  }
12
17
  /**
13
18
  * Custom React Hook for managing state and data fetching logic related to a template listing.
@@ -29,8 +29,9 @@ import { CATEGORY_SPLIT_KEY } from '@antscorp/antsomi-ui/es/constants';
29
29
  * @property {Function} onLoadMore - A function to load more template data when scrolling in the template listing.
30
30
  */
31
31
  export const useTemplateSave = (options) => {
32
- const { service, config } = options;
32
+ const { service, config, queriesOptions } = options;
33
33
  const { objectType, categoryCodes, publicLevel, limitListPerPage = 10, getListType, filter, } = config;
34
+ const { categoryList: categoryListOptions, templateList: templateListOptions } = queriesOptions || {};
34
35
  // const { message } = App.useApp();
35
36
  // State
36
37
  const [state, setState] = useState({
@@ -47,6 +48,7 @@ export const useTemplateSave = (options) => {
47
48
  publicLevel,
48
49
  },
49
50
  },
51
+ options: categoryListOptions,
50
52
  });
51
53
  // Queries
52
54
  const { data: infiniteObjectTemplate, isFetchingNextPage, isFetching, hasNextPage, fetchNextPage, refetch: refetchTemplateList, } = useGetObjectTemplateList({
@@ -54,6 +56,7 @@ export const useTemplateSave = (options) => {
54
56
  auth: service,
55
57
  params: Object.assign({ get_list_type: getListType, object_type: objectType, public_level: publicLevel, limit: limitListPerPage }, (filter ? { filter } : {})),
56
58
  },
59
+ options: templateListOptions,
57
60
  });
58
61
  // Variables
59
62
  const isLoadingTemplateList = isFetching || isFetchingNextPage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.37",
3
+ "version": "1.3.5-beta.39",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",