@antscorp/antsomi-ui 1.3.5-beta.53 → 1.3.5-beta.55

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.
@@ -26,6 +26,8 @@ export interface ImagePreviewOptions {
26
26
  hideThumbnailsList?: boolean;
27
27
  hideDefaultButton?: boolean;
28
28
  label?: string;
29
+ imageWidth?: number;
30
+ imageHeight?: number;
29
31
  }
30
32
  export interface TemplateSaveAsProps {
31
33
  className?: string;
@@ -26,7 +26,7 @@ export const TemplateSaveAs = props => {
26
26
  // onNamePopupScroll,
27
27
  } = props;
28
28
  const { show: isShowShareAccess } = shareAccess, shareAccessProps = __rest(shareAccess, ["show"]);
29
- const { thumbnails, isLoading: isLoadingThumbnail, skeleton, previewNavigation, slidesPerView, hideThumbnailsList, hideDefaultButton, label: imageReviewLabel, } = imageReview;
29
+ const { thumbnails, isLoading: isLoadingThumbnail, skeleton, previewNavigation, slidesPerView, hideThumbnailsList, hideDefaultButton, imageHeight, imageWidth, label: imageReviewLabel, } = imageReview;
30
30
  const { isLoading, label: templateLabel, defaultNewTemplateName, onSearch, onNamePopupScroll, } = templateNamesOptions || {};
31
31
  const { label: descriptionLabel, placeholder: descriptionPlaceholder } = descriptionOptions || {};
32
32
  const { saveNewText = 'Save as a new media Template', saveExistText = 'Save as an existing media Template', saveNewValue = 'save-new', saveExistValue = 'save-exist', } = saveOptions || {};
@@ -57,11 +57,8 @@ export const TemplateSaveAs = props => {
57
57
  }
58
58
  };
59
59
  const handleAddCategory = ({ parentKey, item, }) => {
60
- // console.log('🚀 ~ handleAddCategory:', { parent, parentKey, item }, categories);
61
60
  const currCategory = categoriesValue === null || categoriesValue === void 0 ? void 0 : categoriesValue[parentKey];
62
61
  if (currCategory) {
63
- // currCategory.children.push(+item);
64
- // const newCategoryList = categoriesValue.filter(item => item.label !== currCategory.label);
65
62
  const newCategory = Object.assign(Object.assign({}, categoriesValue), { [parentKey]: [...currCategory, +item] });
66
63
  handleChangeValue({ categories: newCategory });
67
64
  }
@@ -69,24 +66,12 @@ export const TemplateSaveAs = props => {
69
66
  const newCategory = Object.assign(Object.assign({}, categoriesValue), { [parentKey]: [+item] });
70
67
  handleChangeValue({ categories: newCategory });
71
68
  }
72
- // const currCategory = categoriesValue.find(category => category.label === parent);
73
- // if (currCategory) {
74
- // currCategory.children.push(item);
75
- // const newCategoryList = categoriesValue.filter(item => item.label !== currCategory.label);
76
- // const newCategory = [...newCategoryList, currCategory];
77
- // handleChangeValue({ categories: newCategory });
78
- // } else {
79
- // const newCategory = [...categoriesValue, { label: parent, key: parentKey, children: [item] }];
80
- // handleChangeValue({ categories: newCategory });
81
- // }
82
69
  };
83
70
  const handleRemoveCategory = ({ parent, item, }) => {
84
71
  const currCategory = categoriesValue === null || categoriesValue === void 0 ? void 0 : categoriesValue[parent];
85
72
  if (!currCategory)
86
73
  return;
87
74
  const newChildren = currCategory.filter(child => child !== item);
88
- // const newChildren = currCategory.children.filter(child => child.label !== item.label);
89
- // const newCategoryList = categoriesValue.filter(child => child.label !== currCategory.label);
90
75
  handleChangeValue({
91
76
  categories: Object.assign(Object.assign({}, categoriesValue), { [parent]: newChildren }),
92
77
  });
@@ -147,7 +132,7 @@ export const TemplateSaveAs = props => {
147
132
  imageReviewLabel || 'Thumbnail template',
148
133
  " ",
149
134
  React.createElement("span", null, "*")),
150
- 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 :
135
+ React.createElement(ImageSlider, { thumbnails: thumbnails, isLoading: isLoadingThumbnail, skeleton: skeleton, previewNavigation: previewNavigation, slidesPerView: slidesPerView, defaultThumbnail: defaultThumbnail, onSelectDefault: value => handleChangeValue({ defaultThumbnail: value }), hideThumbnailsList: hideThumbnailsList, hideDefaultButton: hideDefaultButton, imageHeight: imageHeight, imageWidth: imageWidth })), categories === null || categories === void 0 ? void 0 :
151
136
  categories.map(parentCategory => {
152
137
  var _a, _b;
153
138
  // const selectedChildren = categoriesValue
@@ -8,6 +8,8 @@ interface ImageSliderProps {
8
8
  slidesPerView?: number;
9
9
  hideThumbnailsList?: boolean;
10
10
  hideDefaultButton?: boolean;
11
+ imageWidth?: number;
12
+ imageHeight?: number;
11
13
  /**
12
14
  * Default thumbnail - order of default thumbnail in thumbnails array
13
15
  */
@@ -9,17 +9,17 @@ import { ImageSliderStyled } from './styled';
9
9
  import clsx from 'clsx';
10
10
  export const ImageSlider = props => {
11
11
  var _a, _b;
12
- const { thumbnails, isLoading, className, skeleton, previewNavigation, slidesPerView = 3, hideThumbnailsList, hideDefaultButton, defaultThumbnail, onSelectDefault, } = props;
12
+ const { thumbnails, isLoading, className, skeleton, previewNavigation, slidesPerView = 3, hideThumbnailsList, hideDefaultButton, imageWidth = 330, imageHeight = 230, defaultThumbnail, onSelectDefault, } = props;
13
13
  const sliderContainerRef = useRef(null);
14
14
  const thumbnailSelectedRef = useRef(null);
15
15
  const [selectedThumbnail, setSelectedThumbnail] = useState(0);
16
16
  const [defaultThumbnailInternal, setDefaultThumbnailInternal] = useState(defaultThumbnail || 0);
17
17
  (_a = thumbnailSelectedRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
18
- left: selectedThumbnail * 330,
18
+ left: selectedThumbnail * imageWidth,
19
19
  behavior: 'smooth',
20
20
  });
21
21
  (_b = sliderContainerRef.current) === null || _b === void 0 ? void 0 : _b.scrollTo({
22
- left: selectedThumbnail * (330 / slidesPerView),
22
+ left: selectedThumbnail * (imageWidth / slidesPerView),
23
23
  behavior: 'smooth',
24
24
  });
25
25
  const handleNextThumbnail = () => {
@@ -28,12 +28,12 @@ export const ImageSlider = props => {
28
28
  const handlePrevThumbnail = () => {
29
29
  setSelectedThumbnail(prev => (prev === 0 ? thumbnails.length - 1 : prev - 1));
30
30
  };
31
- return (React.createElement(ImageSliderStyled, { className: className || '', "$skeleton": skeleton, "$slidesPerView": slidesPerView, vertical: true, gap: 10 },
31
+ return (React.createElement(ImageSliderStyled, { className: className || '', "$skeleton": skeleton, "$slidesPerView": slidesPerView, "$imageWidth": imageWidth, "$imageHeight": imageHeight, vertical: true, gap: 10 },
32
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', {
33
33
  'image-container--default': defaultThumbnailInternal === index,
34
34
  }) },
35
35
  url ? (React.createElement(Image, { preview: false, width: "80%", height: "96%", src: thumbnails[index] })) : null,
36
- hideDefaultButton ? null : (React.createElement(Button, { className: "set-default-button", onClick: () => {
36
+ hideDefaultButton || hideThumbnailsList || thumbnails.length <= 1 ? null : (React.createElement(Button, { className: "set-default-button", onClick: () => {
37
37
  setDefaultThumbnailInternal(selectedThumbnail);
38
38
  if (onSelectDefault) {
39
39
  onSelectDefault(selectedThumbnail);
@@ -41,7 +41,7 @@ export const ImageSlider = props => {
41
41
  } },
42
42
  defaultThumbnailInternal === index ? (React.createElement(Icon, { type: "icon-ants-check", style: { fontSize: '12px' } })) : null,
43
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', {
44
+ hideThumbnailsList || thumbnails.length <= 1 ? 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', {
45
45
  'image-container--selected': index === selectedThumbnail,
46
46
  }), onClick: () => setSelectedThumbnail(index) }, url ? (React.createElement(Image, { key: url, preview: false, width: "80%", height: "96%", src: url })) : null)))))),
47
47
  previewNavigation && !isLoading ? (React.createElement(React.Fragment, null,
@@ -49,7 +49,7 @@ export const ImageSlider = props => {
49
49
  React.createElement(Icon, { type: "icon-ants-angle-left" })),
50
50
  React.createElement("div", { className: "change-preview-button change-preview-button--right", onClick: handleNextThumbnail },
51
51
  React.createElement(Icon, { type: "icon-ants-angle-right" })))) : null,
52
- hideThumbnailsList || isLoading ? null : (React.createElement(React.Fragment, null,
52
+ hideThumbnailsList || isLoading || thumbnails.length <= 1 ? null : (React.createElement(React.Fragment, null,
53
53
  React.createElement("div", { className: "slider-button slider-button--left", onClick: handlePrevThumbnail },
54
54
  React.createElement(Icon, { type: "icon-ants-angle-left" })),
55
55
  React.createElement("div", { className: "slider-button slider-button--right", onClick: handleNextThumbnail },
@@ -1,5 +1,9 @@
1
1
  /// <reference types="react" />
2
- export declare const ImageSliderStyled: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {
3
- $skeleton?: boolean | undefined;
4
- $slidesPerView?: number | undefined;
5
- }, never>;
2
+ interface ImageSliderStyledProps {
3
+ $skeleton?: boolean;
4
+ $slidesPerView?: number;
5
+ $imageWidth?: number;
6
+ $imageHeight?: number;
7
+ }
8
+ export declare const ImageSliderStyled: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, ImageSliderStyledProps, never>;
9
+ export {};
@@ -76,14 +76,12 @@ export const ImageSliderStyled = styled(Flex) `
76
76
  .thumbnail-preview-container .antsomi-spin,
77
77
  .thumbnail-slider-container .antsomi-spin {
78
78
  width: 100%;
79
- display: flex;
80
- justify-content: center;
81
- align-items: center;
79
+ ${centerBlock}
82
80
  background-color: #fcfcfc;
83
81
  }
84
82
 
85
83
  .thumbnail-preview-container {
86
- width: 330px;
84
+ width: ${({ $imageWidth }) => `${$imageWidth}px`};
87
85
  overflow-x: scroll;
88
86
  scrollbar-width: none;
89
87
 
@@ -95,13 +93,13 @@ export const ImageSliderStyled = styled(Flex) `
95
93
  }
96
94
 
97
95
  .antsomi-spin {
98
- height: 230px;
96
+ height: ${({ $imageHeight }) => `${$imageHeight}px`};
99
97
  }
100
98
  }
101
99
 
102
100
  .thumbnail-slider-container {
103
101
  position: relative;
104
- width: 330px;
102
+ width: ${({ $imageWidth }) => `${$imageWidth}px`};
105
103
  overflow-x: scroll;
106
104
  scrollbar-width: none;
107
105
 
@@ -110,6 +108,24 @@ export const ImageSliderStyled = styled(Flex) `
110
108
  }
111
109
  }
112
110
 
111
+ &:has(> .thumbnail-preview-container + .thumbnail-slider-container) {
112
+ .image-container--big::before {
113
+ content: '';
114
+ position: absolute;
115
+ top: 0;
116
+ left: 0;
117
+ width: 100%;
118
+ height: 100%;
119
+ background-color: transparent;
120
+ z-index: 1;
121
+ transition: background-color 150ms ease-in-out;
122
+ }
123
+
124
+ .image-container--big:hover::before {
125
+ background-color: rgba(0, 0, 0, 0.5);
126
+ }
127
+ }
128
+
113
129
  .image-container {
114
130
  &--big,
115
131
  &--small {
@@ -126,24 +142,12 @@ export const ImageSliderStyled = styled(Flex) `
126
142
  }
127
143
 
128
144
  &--big {
129
- ${setWidthHeight({ w: '100%', h: '230px' })}
130
- /* ${setWidthHeight({ w: '330px', h: '230px' })} */
145
+ width: 100%;
146
+ height: ${({ $imageHeight }) => `${$imageHeight}px`};
131
147
  flex-shrink: 0;
132
148
 
133
149
  position: relative;
134
- /* border-radius: 5px; */
135
150
  overflow: hidden;
136
-
137
- &::before {
138
- content: '';
139
- position: absolute;
140
- top: 0;
141
- left: 0;
142
- width: 100%;
143
- height: 100%;
144
- background-color: rgba(0, 0, 0, 0.5);
145
- z-index: 1;
146
- }
147
151
  }
148
152
 
149
153
  &--small {
@@ -167,31 +171,12 @@ export const ImageSliderStyled = styled(Flex) `
167
171
  left: 50%;
168
172
  transform: translate(-50%, -50%);
169
173
  z-index: 2;
174
+ opacity: 0;
175
+ transition: opacity 150ms ease-in-out;
170
176
  }
171
-
172
- /* .swiper-button-prev,
173
- .swiper-button-next {
174
- background: #fff;
175
- width: 24px;
176
- height: 24px;
177
- border-radius: 999px;
178
- &:after {
179
- font-size: 14px;
180
- font-weight: bold;
181
- color: #000;
182
- }
183
- &.swiper-button-disabled {
177
+ .image-container--big:hover {
178
+ .set-default-button {
184
179
  opacity: 1;
185
- cursor: pointer;
186
180
  }
187
- } */
188
-
189
- /* .swiper-button-prev.swiper-button-disabled {
190
- opacity: 1;
191
- cursor: pointer;
192
- } */
193
-
194
- /* .swiper-button-lock {
195
- display: flex;
196
- } */
181
+ }
197
182
  `;
@@ -41,6 +41,8 @@ export declare const useTemplateSave: (options: TemplateListingOptions) => {
41
41
  thumbnail?: string | undefined;
42
42
  }[];
43
43
  value: Partial<TemplateValueOptions>;
44
+ setValue: import("react").Dispatch<import("react").SetStateAction<Partial<TemplateValueOptions>>>;
45
+ reset: () => void;
44
46
  formattedCategoriesValue: {
45
47
  camelCase: Record<string, any>;
46
48
  snakeCase: Record<string, any>;
@@ -5,7 +5,6 @@ import { useGetTemplateCategoryList, useGetObjectTemplateList, } from '@antscorp
5
5
  import { useDeepCompareEffect, useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
6
6
  import { Form } from 'antd';
7
7
  import { camelCaseToSnakeCase, snakeCaseToCamelCase } from '@antscorp/antsomi-ui/es/utils';
8
- import { omit } from 'lodash';
9
8
  /**
10
9
  * Custom React Hook for managing state and data fetching logic related to a template listing.
11
10
  *
@@ -24,21 +23,16 @@ export const useTemplateSave = (options) => {
24
23
  const { objectType, categoryCodes, publicLevel, limitListPerPage = 10, getListType } = config;
25
24
  const { categoryList: categoryListOptions, templateList: templateListOptions } = queriesOptions || {};
26
25
  const [searchName, setSearchName] = useState('');
27
- const [value, setValue] = useState(omit(valueArg, ['categoriesWithId']) || {});
26
+ const [value, setValue] = useState(valueArg || {});
28
27
  const [errors, setErrors] = useState();
29
28
  const handleFormatCategories = (categories) => {
30
- // const snakeCase = {};
31
- // categories?.forEach(category => {
32
- // snakeCase[category.key] = category.children.map(item => item.key);
33
- // });
34
29
  const snakeCase = camelCaseToSnakeCase(categories || {});
35
30
  const camelCase = snakeCaseToCamelCase(categories || {});
36
- // const camelCase = snakeCaseToCamelCase(snakeCase);
37
31
  return { camelCase, snakeCase };
38
32
  };
39
33
  const formattedCategoriesValue = useMemo(() => handleFormatCategories(value.categories), [value]);
40
34
  useDeepCompareEffect(() => {
41
- setValue(omit(valueArg, ['categoriesWithId']));
35
+ setValue(valueArg || {});
42
36
  }, [valueArg]);
43
37
  const [form] = Form.useForm();
44
38
  const { data: categoryList, isLoading: isLoadingCategoryList, refetch: refetchCategoryList, } = useGetTemplateCategoryList({
@@ -94,11 +88,17 @@ export const useTemplateSave = (options) => {
94
88
  setErrors((_b = (_a = form === null || form === void 0 ? void 0 : form.getFieldsError()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.errors);
95
89
  setValue(newValue);
96
90
  };
91
+ const reset = () => {
92
+ setValue(valueArg || {});
93
+ };
97
94
  return {
98
95
  // MapKeys
99
96
  categoryItems,
100
97
  templateItems,
98
+ // State value
101
99
  value,
100
+ setValue,
101
+ reset,
102
102
  // formattedValue
103
103
  formattedCategoriesValue,
104
104
  handleFormatCategories,
@@ -406,7 +406,7 @@ export const camelCaseToSnakeCase = (object, recursive = false) => {
406
406
  newObject[newKey] =
407
407
  recursive && !!object[key] && typeof object[key] === 'object'
408
408
  ? Array.isArray(object[key])
409
- ? object[key].map(value => snakeCaseToCamelCase(value, recursive))
409
+ ? object[key].map(value => camelCaseToSnakeCase(value, recursive))
410
410
  : camelCaseToSnakeCase(object[key], recursive)
411
411
  : object[key];
412
412
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.53",
3
+ "version": "1.3.5-beta.55",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -59,6 +59,7 @@
59
59
  "not op_mini all"
60
60
  ],
61
61
  "dependencies": {
62
+ "@antscorp/antsomi-ui": "file:.yalc/@antscorp/antsomi-ui",
62
63
  "@antscorp/icons": "0.27.6",
63
64
  "@antscorp/image-editor": "1.0.2",
64
65
  "@emotion/react": "^11.11.1",
@@ -78,8 +79,8 @@
78
79
  "axios": "^1.4.0",
79
80
  "babel-plugin-file-loader": "^2.0.0",
80
81
  "currency-formatter": "1.5.9",
81
- "dayjs": "^1.11.10",
82
82
  "d3-interpolate": "^3.0.1",
83
+ "dayjs": "^1.11.10",
83
84
  "font-awesome": "4.7.0",
84
85
  "highlight.js": "^11.8.0",
85
86
  "html-entities": "^2.0.2",