@antscorp/antsomi-ui 1.3.5-beta.2 → 1.3.5-beta.21

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.
Files changed (255) hide show
  1. package/es/assets/css/main.scss +0 -2
  2. package/es/assets/images/background/skeleton-background.png +0 -0
  3. package/es/assets/images/skeleton_bg.png +0 -0
  4. package/es/assets/svg/mobile-frame.svg +3 -0
  5. package/es/components/atoms/Spin/Spin.js +2 -2
  6. package/es/components/common/ConfigProvider/ConfigProvider.js +8 -4
  7. package/es/components/common/ConfigProvider/GlobalStyle.js +85 -16
  8. package/es/components/molecules/CalendarSelection/CalendarSelection.d.ts +3 -0
  9. package/es/components/molecules/CalendarSelection/CalendarSelection.js +45 -0
  10. package/es/components/molecules/CalendarSelection/actions.d.ts +55 -0
  11. package/es/components/molecules/CalendarSelection/actions.js +39 -0
  12. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/AutoUpdateTo.d.ts +7 -0
  13. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/AutoUpdateTo.js +24 -0
  14. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/index.d.ts +1 -0
  15. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/index.js +1 -0
  16. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.d.ts +1 -0
  17. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.js +10 -0
  18. package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.d.ts +3 -0
  19. package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.js +96 -0
  20. package/es/components/molecules/CalendarSelection/components/CustomPicker/index.d.ts +1 -0
  21. package/es/components/molecules/CalendarSelection/components/CustomPicker/index.js +1 -0
  22. package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.d.ts +6 -0
  23. package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.js +152 -0
  24. package/es/components/molecules/CalendarSelection/components/CustomPicker/types.d.ts +1 -0
  25. package/es/components/molecules/CalendarSelection/components/Footer/Footer.d.ts +2 -0
  26. package/es/components/molecules/CalendarSelection/components/Footer/Footer.js +11 -0
  27. package/es/components/molecules/CalendarSelection/components/Footer/index.d.ts +1 -0
  28. package/es/components/molecules/CalendarSelection/components/Footer/index.js +1 -0
  29. package/es/components/molecules/CalendarSelection/components/Footer/styled.d.ts +1 -0
  30. package/es/components/molecules/CalendarSelection/components/Footer/styled.js +6 -0
  31. package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.d.ts +5 -0
  32. package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.js +4 -0
  33. package/es/components/molecules/CalendarSelection/components/RangePicker/index.d.ts +1 -0
  34. package/es/components/molecules/CalendarSelection/components/RangePicker/index.js +1 -0
  35. package/es/components/molecules/CalendarSelection/components/RangePicker/styled.d.ts +5 -0
  36. package/es/components/molecules/CalendarSelection/components/RangePicker/styled.js +13 -0
  37. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/RangeSelectOptions.d.ts +3 -0
  38. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/RangeSelectOptions.js +23 -0
  39. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/NumOfDaysRanges.d.ts +2 -0
  40. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/NumOfDaysRanges.js +41 -0
  41. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.d.ts +1 -0
  42. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.js +1 -0
  43. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.d.ts +11 -0
  44. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.js +40 -0
  45. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/index.d.ts +1 -0
  46. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/index.js +1 -0
  47. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.d.ts +1 -0
  48. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.js +29 -0
  49. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.d.ts +2 -0
  50. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.js +2 -0
  51. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/index.d.ts +1 -0
  52. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/index.js +1 -0
  53. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.d.ts +3 -0
  54. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.js +34 -0
  55. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/types.d.ts +1 -0
  56. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/types.js +1 -0
  57. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.d.ts +8 -0
  58. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js +49 -0
  59. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/index.d.ts +2 -0
  60. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/index.js +2 -0
  61. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.d.ts +1 -0
  62. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.js +70 -0
  63. package/es/components/molecules/CalendarSelection/components/index.d.ts +5 -0
  64. package/es/components/molecules/CalendarSelection/components/index.js +5 -0
  65. package/es/components/molecules/CalendarSelection/constants.d.ts +97 -0
  66. package/es/components/molecules/CalendarSelection/constants.js +183 -0
  67. package/es/components/molecules/CalendarSelection/context.d.ts +4 -0
  68. package/es/components/molecules/CalendarSelection/context.js +6 -0
  69. package/es/components/molecules/CalendarSelection/hooks/index.d.ts +2 -0
  70. package/es/components/molecules/CalendarSelection/hooks/index.js +2 -0
  71. package/es/components/molecules/CalendarSelection/hooks/useStateContext.d.ts +4 -0
  72. package/es/components/molecules/CalendarSelection/hooks/useStateContext.js +13 -0
  73. package/es/components/molecules/CalendarSelection/hooks/useTriggerOut.d.ts +9 -0
  74. package/es/components/molecules/CalendarSelection/hooks/useTriggerOut.js +19 -0
  75. package/es/components/molecules/CalendarSelection/index.d.ts +25 -0
  76. package/es/components/molecules/CalendarSelection/index.js +6 -0
  77. package/es/components/molecules/CalendarSelection/reducer.d.ts +3 -0
  78. package/es/components/molecules/CalendarSelection/reducer.js +121 -0
  79. package/es/components/molecules/CalendarSelection/styled.d.ts +6 -0
  80. package/es/components/molecules/CalendarSelection/styled.js +13 -0
  81. package/es/components/molecules/CalendarSelection/types.d.ts +97 -0
  82. package/es/components/molecules/CalendarSelection/types.js +1 -0
  83. package/es/components/molecules/CalendarSelection/utils.d.ts +52 -0
  84. package/es/components/molecules/CalendarSelection/utils.js +304 -0
  85. package/es/components/molecules/ColorPicker/CustomPicker/index.js +3 -3
  86. package/es/components/molecules/ColorPicker/index.d.ts +1 -0
  87. package/es/components/molecules/ColorPicker/index.js +3 -2
  88. package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +24 -16
  89. package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.d.ts +5 -0
  90. package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +31 -1
  91. package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +1 -1
  92. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +3 -1
  93. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +5 -4
  94. package/es/components/molecules/ModalV2/styled.js +4 -0
  95. package/es/components/molecules/ResizeGrid/ResizeGrid.js +10 -2
  96. package/es/components/molecules/ResizeGrid/types.d.ts +1 -0
  97. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.d.ts +1 -0
  98. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.js +2 -2
  99. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +1 -0
  100. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +2 -2
  101. package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +2 -2
  102. package/es/components/molecules/ShareAccess/index.d.ts +2 -3
  103. package/es/components/molecules/ShareAccess/index.js +2 -3
  104. package/es/components/molecules/ShareAccess/types.d.ts +1 -0
  105. package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.d.ts +52 -0
  106. package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.js +144 -0
  107. package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.d.ts +10 -0
  108. package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.js +38 -0
  109. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.d.ts +15 -0
  110. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +68 -0
  111. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/index.d.ts +1 -0
  112. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/index.js +1 -0
  113. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.d.ts +5 -0
  114. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +175 -0
  115. package/es/components/molecules/TemplateSaveAs/components/index.d.ts +1 -0
  116. package/es/components/molecules/TemplateSaveAs/components/index.js +1 -0
  117. package/es/components/molecules/TemplateSaveAs/index.d.ts +3 -0
  118. package/es/components/molecules/TemplateSaveAs/index.js +2 -0
  119. package/es/components/molecules/TemplateSaveAs/styled.d.ts +4 -0
  120. package/es/components/molecules/TemplateSaveAs/styled.js +70 -0
  121. package/es/components/molecules/ThumbnailCard/ThumbnailCard.d.ts +3 -0
  122. package/es/components/molecules/ThumbnailCard/ThumbnailCard.js +72 -0
  123. package/es/components/molecules/ThumbnailCard/constants.d.ts +3 -0
  124. package/es/components/molecules/ThumbnailCard/constants.js +3 -0
  125. package/es/components/molecules/ThumbnailCard/index.d.ts +2 -0
  126. package/es/components/molecules/ThumbnailCard/index.js +2 -0
  127. package/es/components/molecules/ThumbnailCard/styled.d.ts +1 -0
  128. package/es/components/{template/TemplateListing/components/TemplateItem → molecules/ThumbnailCard}/styled.js +14 -7
  129. package/es/components/molecules/ThumbnailCard/types.d.ts +21 -0
  130. package/es/components/molecules/ThumbnailCard/types.js +1 -0
  131. package/es/components/molecules/UploadImage/index.js +1 -1
  132. package/es/components/molecules/index.d.ts +5 -0
  133. package/es/components/molecules/index.js +3 -0
  134. package/es/components/organism/Help/Help.js +23 -1
  135. package/es/components/organism/Menu/Menu.d.ts +2 -0
  136. package/es/components/organism/Menu/Menu.js +3 -0
  137. package/es/components/organism/Menu/index.d.ts +1 -0
  138. package/es/components/organism/Menu/index.js +3 -0
  139. package/es/components/organism/PreviewTemplateModal/components/Banner/index.d.ts +3 -0
  140. package/es/components/organism/PreviewTemplateModal/components/Banner/index.js +12 -0
  141. package/es/components/organism/PreviewTemplateModal/components/Banner/styled.d.ts +4 -0
  142. package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +91 -0
  143. package/es/components/organism/PreviewTemplateModal/components/Information/index.d.ts +3 -0
  144. package/es/components/organism/PreviewTemplateModal/components/Information/index.js +29 -0
  145. package/es/components/organism/PreviewTemplateModal/components/Information/styled.d.ts +2 -0
  146. package/es/components/organism/PreviewTemplateModal/components/Information/styled.js +41 -0
  147. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.d.ts +3 -0
  148. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.js +29 -0
  149. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.d.ts +2 -0
  150. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.js +12 -0
  151. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.d.ts +6 -0
  152. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.js +77 -0
  153. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.d.ts +3 -0
  154. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.js +62 -0
  155. package/es/components/organism/PreviewTemplateModal/components/index.d.ts +4 -0
  156. package/es/components/organism/PreviewTemplateModal/components/index.js +4 -0
  157. package/es/components/organism/PreviewTemplateModal/constants/dataSample.d.ts +2 -0
  158. package/es/components/organism/PreviewTemplateModal/constants/dataSample.js +9 -0
  159. package/es/components/organism/PreviewTemplateModal/constants/defaultProps.d.ts +8 -0
  160. package/es/components/organism/PreviewTemplateModal/constants/defaultProps.js +11 -0
  161. package/es/components/organism/PreviewTemplateModal/constants/index.d.ts +3 -0
  162. package/es/components/organism/PreviewTemplateModal/constants/index.js +3 -0
  163. package/es/components/organism/PreviewTemplateModal/constants/variables.d.ts +12 -0
  164. package/es/components/organism/PreviewTemplateModal/constants/variables.js +12 -0
  165. package/es/components/organism/PreviewTemplateModal/index.d.ts +3 -0
  166. package/es/components/organism/PreviewTemplateModal/index.js +34 -0
  167. package/es/components/organism/PreviewTemplateModal/styled.d.ts +4 -0
  168. package/es/components/organism/PreviewTemplateModal/styled.js +26 -0
  169. package/es/components/organism/PreviewTemplateModal/types.d.ts +39 -0
  170. package/es/components/organism/PreviewTemplateModal/types.js +1 -0
  171. package/es/components/organism/index.d.ts +1 -0
  172. package/es/components/organism/index.js +1 -0
  173. package/es/components/template/TemplateListing/Loadable.d.ts +6 -0
  174. package/es/components/template/TemplateListing/Loadable.js +7 -0
  175. package/es/components/template/TemplateListing/components/BlankTemplate/index.js +9 -7
  176. package/es/components/template/TemplateListing/components/BlankTemplate/styled.js +2 -0
  177. package/es/components/template/TemplateListing/components/CategoryListing/index.js +19 -10
  178. package/es/components/template/TemplateListing/components/CategoryListing/styled.d.ts +2 -0
  179. package/es/components/template/TemplateListing/components/CategoryListing/styled.js +44 -7
  180. package/es/components/template/TemplateListing/components/CategoryListing/types.d.ts +2 -1
  181. package/es/components/template/TemplateListing/components/Empty/index.d.ts +3 -0
  182. package/es/components/template/TemplateListing/components/Empty/index.js +18 -0
  183. package/es/components/template/TemplateListing/components/Empty/styled.d.ts +3 -0
  184. package/es/components/template/TemplateListing/components/Empty/styled.js +35 -0
  185. package/es/components/template/TemplateListing/components/index.d.ts +1 -1
  186. package/es/components/template/TemplateListing/components/index.js +1 -1
  187. package/es/components/template/TemplateListing/constants/defaultProps.d.ts +8 -4
  188. package/es/components/template/TemplateListing/constants/defaultProps.js +9 -6
  189. package/es/components/template/TemplateListing/hooks/index.d.ts +1 -0
  190. package/es/components/template/TemplateListing/hooks/index.js +1 -0
  191. package/es/components/template/TemplateListing/hooks/useTemplateListing.d.ts +62 -0
  192. package/es/components/template/TemplateListing/hooks/useTemplateListing.js +206 -0
  193. package/es/components/template/TemplateListing/index.js +77 -13
  194. package/es/components/template/TemplateListing/styled/index.d.ts +2 -0
  195. package/es/components/template/TemplateListing/styled/index.js +29 -5
  196. package/es/components/template/TemplateListing/types/BlankTemplate.d.ts +3 -2
  197. package/es/components/template/TemplateListing/types/CategoryListing.d.ts +5 -2
  198. package/es/components/template/TemplateListing/types/Empty.d.ts +5 -0
  199. package/es/components/template/TemplateListing/types/Empty.js +1 -0
  200. package/es/components/template/TemplateListing/types/TemplateListing.d.ts +20 -9
  201. package/es/components/template/TemplateListing/types/index.d.ts +0 -1
  202. package/es/components/template/TemplateListing/types/index.js +0 -1
  203. package/es/components/template/index.d.ts +2 -1
  204. package/es/components/template/index.js +5 -1
  205. package/es/constants/datetime.d.ts +8 -0
  206. package/es/constants/datetime.js +1594 -0
  207. package/es/constants/index.d.ts +4 -1
  208. package/es/constants/index.js +4 -1
  209. package/es/constants/queries.d.ts +3 -0
  210. package/es/constants/queries.js +4 -0
  211. package/es/constants/templateListing.d.ts +58 -0
  212. package/es/constants/templateListing.js +58 -0
  213. package/es/hooks/index.d.ts +4 -0
  214. package/es/hooks/index.js +4 -0
  215. package/es/hooks/useEffectOnlyOnce.d.ts +2 -0
  216. package/es/hooks/useEffectOnlyOnce.js +12 -0
  217. package/es/hooks/useForceUpdate.d.ts +1 -0
  218. package/es/hooks/useForceUpdate.js +5 -0
  219. package/es/hooks/useIntersectionObserver.d.ts +57 -0
  220. package/es/hooks/useIntersectionObserver.js +97 -0
  221. package/es/hooks/useListingItemResize.d.ts +12 -0
  222. package/es/hooks/useListingItemResize.js +58 -0
  223. package/es/hooks/useScrollToEnd.d.ts +1 -0
  224. package/es/hooks/useScrollToEnd.js +30 -0
  225. package/es/index.d.ts +2 -0
  226. package/es/index.js +2 -0
  227. package/es/locales/en/translation.json +11 -3
  228. package/es/locales/i18n.d.ts +16 -0
  229. package/es/locales/translations.d.ts +8 -0
  230. package/es/locales/vi/translation.json +9 -1
  231. package/es/models/ObjectTemplate.d.ts +53 -0
  232. package/es/models/ObjectTemplate.js +80 -0
  233. package/es/models/TemplateCategory.d.ts +13 -0
  234. package/es/models/TemplateCategory.js +28 -0
  235. package/es/queries/TemplateListing/index.d.ts +47 -0
  236. package/es/queries/TemplateListing/index.js +93 -0
  237. package/es/queries/index.d.ts +1 -0
  238. package/es/queries/index.js +1 -0
  239. package/es/services/TemplateListing/index.d.ts +64 -0
  240. package/es/services/TemplateListing/index.js +149 -0
  241. package/es/test.js +62 -11
  242. package/es/types/index.d.ts +4 -0
  243. package/es/types/index.js +2 -0
  244. package/es/types/service.d.ts +22 -0
  245. package/es/types/service.js +1 -0
  246. package/es/types/templateListing.d.ts +11 -0
  247. package/es/types/templateListing.js +1 -0
  248. package/es/utils/common.d.ts +2 -0
  249. package/es/utils/common.js +12 -0
  250. package/package.json +6 -1
  251. package/es/components/template/TemplateListing/components/TemplateItem/index.d.ts +0 -3
  252. package/es/components/template/TemplateListing/components/TemplateItem/index.js +0 -53
  253. package/es/components/template/TemplateListing/components/TemplateItem/styled.d.ts +0 -1
  254. package/es/components/template/TemplateListing/types/TemplateItem.d.ts +0 -14
  255. /package/es/components/{template/TemplateListing/types/TemplateItem.js → molecules/CalendarSelection/components/CustomPicker/types.js} +0 -0
@@ -1,5 +1,7 @@
1
+ /// <reference types="react" />
1
2
  export declare const MenuWrapper: import("styled-components").StyledComponent<"div", any, {
2
3
  $width?: number | undefined;
3
4
  }, never>;
4
5
  export declare const CustomLabelStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
5
6
  export declare const CustomRootLabel: import("styled-components").StyledComponent<"div", any, {}, never>;
7
+ export declare const TextWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/typography/Text").TextProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
@@ -1,22 +1,47 @@
1
+ var _a, _b;
1
2
  import styled from 'styled-components';
3
+ import { Typography } from '../../../../atoms';
4
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
5
+ const { Text } = Typography;
2
6
  export const MenuWrapper = styled.div `
3
- width: ${({ $width }) => ($width !== undefined ? `${$width}px` : 'auto')} !important;
7
+ flex-shrink: 0;
8
+ width: ${({ $width }) => ($width !== undefined ? `${$width}px` : 'auto')};
4
9
  overflow: auto;
10
+ overflow-x: hidden;
5
11
 
6
12
  .antsomi-menu {
7
13
  height: 100%;
8
14
 
9
- .antsomi-menu-submenu {
10
- .antsomi-menu-submenu-title,
11
- .antsomi-menu-item {
12
- padding-left: 10px !important;
15
+ [role='menuitem'] {
16
+ width: 100%;
17
+ border-radius: 0;
18
+ height: 30px;
19
+ padding: 0 10px !important;
20
+ margin-left: 0 !important;
21
+ margin-right: 0 !important;
22
+
23
+ .antsomi-menu-title-content {
24
+ height: 100%;
13
25
  }
14
26
  }
15
27
  }
28
+
29
+ .category-loading {
30
+ height: 100%;
31
+ }
32
+
33
+ .empty-wrapper {
34
+ width: 100%;
35
+ height: 100%;
36
+ border-right: 1px solid rgba(5, 5, 5, 0.06);
37
+ box-sizing: border-box;
38
+ }
16
39
  `;
17
40
  export const CustomLabelStyled = styled.div `
18
41
  display: flex;
19
42
  justify-content: space-between;
43
+ height: 100%;
44
+ align-items: center;
20
45
 
21
46
  .label {
22
47
  flex: 1 1 0%;
@@ -44,12 +69,24 @@ export const CustomLabelStyled = styled.div `
44
69
  flex-shrink: 0;
45
70
  font-size: 11px;
46
71
  font-weight: 400;
47
- color: #595959;
72
+ color: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8};
73
+ line-height: 1 !important;
74
+ height: fit-content;
48
75
  }
49
76
  `;
50
77
  // TODO: tách class dùng chung
51
78
  export const CustomRootLabel = styled.div `
52
79
  font-size: 11px;
53
80
  font-weight: 400;
54
- color: #595959;
81
+ color: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.bw8};
82
+ height: 100%;
83
+ display: flex;
84
+ align-items: center;
85
+ padding-right: 20px;
86
+ `;
87
+ export const TextWrapper = styled(Text) `
88
+ max-width: 100%;
89
+ color: inherit;
90
+ height: fit-content;
91
+ font-size: inherit;
55
92
  `;
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { MenuProps } from 'antd';
3
+ import { TCategoryItemId } from '../../types';
3
4
  export type TMenuItem = Required<MenuProps>['items'][number];
4
5
  export type TItem = {
5
- key: string;
6
+ key: TCategoryItemId;
6
7
  label: React.ReactNode | string;
7
8
  total?: number;
8
9
  children?: TItem[];
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { EmptyProps } from '@antscorp/antsomi-ui/es/components/template/TemplateListing/types/Empty';
3
+ export declare const Empty: React.FC<EmptyProps>;
@@ -0,0 +1,18 @@
1
+ // Libraries
2
+ import React from 'react';
3
+ // Components
4
+ import { Icon } from '@antscorp/antsomi-ui/es/components';
5
+ import { Typography } from '@antscorp/antsomi-ui/es/components/atoms';
6
+ // Styled
7
+ import { EmptyIcon, EmptyWrapper } from './styled';
8
+ const { Text } = Typography;
9
+ export const Empty = props => {
10
+ const { icon, description } = props;
11
+ return (React.createElement(EmptyWrapper, null,
12
+ React.createElement(EmptyIcon, { className: "animate__animated animate__tada" }, icon),
13
+ React.createElement(Text, { className: "animate__animated animate__fadeInUp" }, description)));
14
+ };
15
+ Empty.defaultProps = {
16
+ icon: React.createElement(Icon, { type: "icon-ants-media" }),
17
+ description: 'No data',
18
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const EmptyWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
3
+ export declare const EmptyIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,35 @@
1
+ var _a, _b, _c;
2
+ // Libraries
3
+ import styled from 'styled-components';
4
+ // Components
5
+ import { Flex } from '@antscorp/antsomi-ui/es/components/atoms';
6
+ // Constants
7
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
8
+ export const EmptyWrapper = styled(Flex) `
9
+ width: 100%;
10
+ height: 100%;
11
+
12
+ .antsomi-typography {
13
+ color: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.bw8};
14
+ }
15
+ `;
16
+ EmptyWrapper.defaultProps = {
17
+ vertical: true,
18
+ align: 'center',
19
+ justify: 'center',
20
+ gap: 15,
21
+ };
22
+ export const EmptyIcon = styled.div `
23
+ display: flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ width: 60px;
27
+ height: 60px;
28
+ border-radius: 100%;
29
+ background-color: ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw2};
30
+
31
+ i {
32
+ font-size: 24px;
33
+ color: ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.bw6};
34
+ }
35
+ `;
@@ -1,3 +1,3 @@
1
- export { TemplateItem } from './TemplateItem';
2
1
  export { BlankTemplate } from './BlankTemplate';
3
2
  export { CategoryListing } from './CategoryListing';
3
+ export { Empty } from './Empty';
@@ -1,3 +1,3 @@
1
- export { TemplateItem } from './TemplateItem';
2
1
  export { BlankTemplate } from './BlankTemplate';
3
2
  export { CategoryListing } from './CategoryListing';
3
+ export { Empty } from './Empty';
@@ -1,8 +1,12 @@
1
- import { BlankTemplateProps, CategoryListingProps, TemplateItemProps, TemplateListingProps } from '../types';
2
- export declare const TEMPLATE_ITEM_WIDTH = 200;
3
- export declare const TEMPLATE_ITEM_HEIGHT = 200;
1
+ import { ThumbnailCardProps } from '../../../molecules';
2
+ import { BlankTemplateProps, CategoryListingProps, TemplateListingProps, TemplatesProps } from '../types';
3
+ import { EmptyProps } from '../types/Empty';
4
4
  export declare const CATEGORY_LISTING_WITH = 220;
5
- export declare const TEMPLATE_ITEM_DEFAULT: Omit<TemplateItemProps, 'id'>;
5
+ export declare const THUMBNAIL_URL = "https://st-media-template.antsomi.com/base64-img/37563.png";
6
+ export declare const LISTING_GAP_DEFAULT = 30;
7
+ export declare const TEMPLATE_ITEM_DEFAULT: Omit<ThumbnailCardProps, 'id'>;
6
8
  export declare const BLANK_TEMPLATE_DEFAULT: BlankTemplateProps;
7
9
  export declare const CATEGORY_LISTING_DEFAULT: Omit<CategoryListingProps, 'items'>;
8
10
  export declare const TEMPLATE_LISTING_DEFAULT: TemplateListingProps;
11
+ export declare const EMPTY_DEFAULT: EmptyProps;
12
+ export declare const TEMPLATES_DEFAULT: TemplatesProps;
@@ -1,20 +1,23 @@
1
- export const TEMPLATE_ITEM_WIDTH = 200;
2
- export const TEMPLATE_ITEM_HEIGHT = 200;
1
+ /* Variables */
3
2
  export const CATEGORY_LISTING_WITH = 220;
3
+ export const THUMBNAIL_URL = 'https://st-media-template.antsomi.com/base64-img/37563.png';
4
+ export const LISTING_GAP_DEFAULT = 30;
5
+ /* Default props */
4
6
  export const TEMPLATE_ITEM_DEFAULT = {
5
- width: TEMPLATE_ITEM_WIDTH,
6
- height: TEMPLATE_ITEM_HEIGHT,
7
7
  removable: true,
8
8
  };
9
9
  export const BLANK_TEMPLATE_DEFAULT = { show: false };
10
10
  export const CATEGORY_LISTING_DEFAULT = {
11
11
  width: CATEGORY_LISTING_WITH,
12
+ show: true,
12
13
  checkedCategories: {},
13
14
  onMenuChange: () => { },
14
15
  };
15
16
  export const TEMPLATE_LISTING_DEFAULT = {
16
- templateItems: [],
17
- categoryItems: [],
18
17
  templateItemProps: TEMPLATE_ITEM_DEFAULT,
19
18
  blankTemplateProps: BLANK_TEMPLATE_DEFAULT,
20
19
  };
20
+ export const EMPTY_DEFAULT = {
21
+ description: 'No data',
22
+ };
23
+ export const TEMPLATES_DEFAULT = { items: [] };
@@ -0,0 +1 @@
1
+ export * from './useTemplateListing';
@@ -0,0 +1 @@
1
+ export * from './useTemplateListing';
@@ -0,0 +1,62 @@
1
+ /// <reference types="react" />
2
+ import { TServiceAuth } from '@antscorp/antsomi-ui/es/types';
3
+ import { TCategoryItem, TCheckedCategories, TSelectTemplateAction, TTemplateItem } from '../types';
4
+ import { TTemplateListingConfig } from '@antscorp/antsomi-ui/es/types/templateListing';
5
+ import { TThumbnailCardId } from '../../../molecules/ThumbnailCard';
6
+ import { TemplateCategory } from '@antscorp/antsomi-ui/es/models/TemplateCategory';
7
+ interface TemplateListingOptions {
8
+ serviceAuth: TServiceAuth;
9
+ config: TTemplateListingConfig;
10
+ checkedCategoriesDefault?: TCheckedCategories;
11
+ }
12
+ type TState = {
13
+ checkedCategories: TCheckedCategories;
14
+ openCategoryKeys: string[];
15
+ selectedTemplateId?: TThumbnailCardId;
16
+ selectTemplateAction?: TSelectTemplateAction;
17
+ };
18
+ /**
19
+ * Custom React Hook for managing state and data fetching logic related to a template listing.
20
+ *
21
+ * @param {Object} options - The options object for configuring the hook.
22
+ * @param {PayloadInfo} options.service - Payload information for making API requests.
23
+ * @param {TTemplateListingConfig} options.config - Configuration options for the template listing.
24
+ *
25
+ * @returns {Object} - An object containing various properties and functions for template listing management.
26
+ *
27
+ * @property {TCategoryItem[]} categoryItems - An array of category items for rendering the template listing's category structure.
28
+ * @property {TTemplateItem[]} templateItems - An array of template items representing the templates available for the specified configuration.
29
+ * @property {string[]} openCategoryKeys - An array of keys representing the currently open category items in the template listing.
30
+ * @property {TCheckedCategories} checkedCategories - An object containing information about the checked categories in the template listing.
31
+ * @property {boolean} isLoading - A boolean indicating whether data is currently being loaded.
32
+ *
33
+ * @property {Function} onChangeCheckedCategories - A function to update the checked categories in the template listing.
34
+ * @param {TCheckedCategories} checkedCategories - An object containing information about the checked categories.
35
+ *
36
+ * @property {Function} onChangeOpenCategoryKeys - A function to update the open category keys in the template listing.
37
+ * @param {string[]} openKeys - An array of keys representing the currently open category items.
38
+ *
39
+ * @property {Function} onLoadMore - A function to load more template data when scrolling in the template listing.
40
+ */
41
+ export declare const useTemplateListing: (options: TemplateListingOptions) => {
42
+ categoryItems: TCategoryItem[];
43
+ templateItems: TTemplateItem[];
44
+ openCategoryKeys: string[];
45
+ similarTemplates: TTemplateItem[];
46
+ templateDetail: import("../../../../models/ObjectTemplate").ObjectTemplate | undefined;
47
+ checkedCategories: TCheckedCategories;
48
+ selectTemplateAction: TSelectTemplateAction | undefined;
49
+ isLoadingCategoryList: boolean;
50
+ isLoadingTemplateList: boolean;
51
+ isLoadingTemplateDetail: boolean;
52
+ refetchCategoryList: <TPageData>(options?: (import("@tanstack/query-core").RefetchOptions & import("@tanstack/query-core").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/query-core").QueryObserverResult<TemplateCategory[], any>>;
53
+ refetchTemplateList: <TPageData_1>(options?: (import("@tanstack/query-core").RefetchOptions & import("@tanstack/query-core").RefetchQueryFilters<TPageData_1>) | undefined) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@tanstack/query-core").InfiniteData<import("@antscorp/antsomi-ui/es/types").ResponseListing<import("../../../../models/ObjectTemplate").ObjectTemplate>>, any>>;
54
+ onChangeCheckedCategories: (checkedCategories: TCheckedCategories) => void;
55
+ onChangeOpenCategoryKeys: (openKeys: string[]) => void;
56
+ onRemoveObjectTemplate: (id: TThumbnailCardId) => void;
57
+ onLoadMore: () => void;
58
+ onSelectTemplate: (id: TThumbnailCardId, action: TSelectTemplateAction) => void;
59
+ onClosePreviewModal: () => void;
60
+ setState: import("react").Dispatch<import("react").SetStateAction<TState>>;
61
+ };
62
+ export {};
@@ -0,0 +1,206 @@
1
+ // Libraries
2
+ import { useCallback, useMemo, useState } from 'react';
3
+ import { App } from 'antd';
4
+ import { isEmpty } from 'lodash';
5
+ import { useGetTemplateCategoryList, useGetObjectTemplateList, useBulkUpdateTemplate, useGetObjectTemplateDetail, } from '@antscorp/antsomi-ui/es/queries/TemplateListing';
6
+ // Locales
7
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
8
+ // Hooks
9
+ import { useDeepCompareEffect, useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
10
+ // Constants
11
+ import { CATEGORY_SPLIT_KEY, TEMPLATE_STATUS, } from '@antscorp/antsomi-ui/es/constants/templateListing';
12
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
13
+ import { getShuffleArray } from '@antscorp/antsomi-ui/es/utils';
14
+ /**
15
+ * Custom React Hook for managing state and data fetching logic related to a template listing.
16
+ *
17
+ * @param {Object} options - The options object for configuring the hook.
18
+ * @param {PayloadInfo} options.service - Payload information for making API requests.
19
+ * @param {TTemplateListingConfig} options.config - Configuration options for the template listing.
20
+ *
21
+ * @returns {Object} - An object containing various properties and functions for template listing management.
22
+ *
23
+ * @property {TCategoryItem[]} categoryItems - An array of category items for rendering the template listing's category structure.
24
+ * @property {TTemplateItem[]} templateItems - An array of template items representing the templates available for the specified configuration.
25
+ * @property {string[]} openCategoryKeys - An array of keys representing the currently open category items in the template listing.
26
+ * @property {TCheckedCategories} checkedCategories - An object containing information about the checked categories in the template listing.
27
+ * @property {boolean} isLoading - A boolean indicating whether data is currently being loaded.
28
+ *
29
+ * @property {Function} onChangeCheckedCategories - A function to update the checked categories in the template listing.
30
+ * @param {TCheckedCategories} checkedCategories - An object containing information about the checked categories.
31
+ *
32
+ * @property {Function} onChangeOpenCategoryKeys - A function to update the open category keys in the template listing.
33
+ * @param {string[]} openKeys - An array of keys representing the currently open category items.
34
+ *
35
+ * @property {Function} onLoadMore - A function to load more template data when scrolling in the template listing.
36
+ */
37
+ export const useTemplateListing = (options) => {
38
+ const { serviceAuth, config, checkedCategoriesDefault } = options;
39
+ const { objectType, categoryCodes, publicLevel, limitListPerPage = 10 } = config;
40
+ const { message } = App.useApp();
41
+ // Locales
42
+ const { t } = i18nInstance;
43
+ // State
44
+ const [state, setState] = useState({
45
+ checkedCategories: {},
46
+ openCategoryKeys: [],
47
+ });
48
+ const { checkedCategories, openCategoryKeys, selectedTemplateId, selectTemplateAction } = state;
49
+ const { data: categoryList, isLoading: isLoadingCategoryList, refetch: refetchCategoryList, } = useGetTemplateCategoryList({
50
+ args: {
51
+ auth: serviceAuth,
52
+ params: {
53
+ objectTypes: [objectType],
54
+ categoryCodes,
55
+ publicLevel,
56
+ },
57
+ },
58
+ });
59
+ const filter = useDeepCompareMemo(() => {
60
+ const draftFilter = Object.entries(checkedCategories)
61
+ .map(([key, value]) => {
62
+ const category = categoryList === null || categoryList === void 0 ? void 0 : categoryList.find(category => category.categoryCode === key);
63
+ if (category && !isEmpty(value)) {
64
+ return {
65
+ [key.toUpperCase()]: {
66
+ [category.filterOperator || 'matches_any']: value.map(item => +(item.toString().split(CATEGORY_SPLIT_KEY) || [])[1]),
67
+ },
68
+ };
69
+ }
70
+ return {};
71
+ })
72
+ .filter(filter => !isEmpty(filter));
73
+ return draftFilter;
74
+ }, [checkedCategories]);
75
+ // Queries
76
+ const { data: infiniteObjectTemplate, isFetchingNextPage, isFetching, hasNextPage, fetchNextPage, refetch: refetchTemplateList, } = useGetObjectTemplateList({
77
+ args: {
78
+ auth: serviceAuth,
79
+ params: {
80
+ object_type: objectType,
81
+ public_level: publicLevel,
82
+ limit: limitListPerPage,
83
+ filter: JSON.stringify(filter),
84
+ },
85
+ },
86
+ });
87
+ const { mutateAsync: bulkUpdateTemplate } = useBulkUpdateTemplate({
88
+ options: {
89
+ onSuccess: () => {
90
+ message.success(t(translations.templateListing.removeSuccess));
91
+ },
92
+ onError: () => {
93
+ message.error(t(translations.templateListing.removeFailed));
94
+ },
95
+ },
96
+ });
97
+ const { data: templateDetail, isLoading: isLoadingTemplateDetail } = useGetObjectTemplateDetail({
98
+ args: {
99
+ params: {
100
+ template_id: selectedTemplateId || '',
101
+ object_type: objectType,
102
+ public_level: publicLevel,
103
+ },
104
+ auth: serviceAuth,
105
+ },
106
+ });
107
+ // Variables
108
+ const isLoadingTemplateList = isFetching || isFetchingNextPage;
109
+ // Memo
110
+ const categoryItems = useDeepCompareMemo(() => {
111
+ const recursiveCategory = (categories = [], parentCategoryCode = '') => categories.map(category => {
112
+ const { categoryCode, categoryId, categoryName, children, total } = category;
113
+ const key = Array.isArray(children) && children.length
114
+ ? categoryCode
115
+ : [parentCategoryCode, categoryId].join(CATEGORY_SPLIT_KEY);
116
+ return {
117
+ key,
118
+ label: categoryName,
119
+ total,
120
+ children: recursiveCategory(children || [], categoryCode),
121
+ };
122
+ });
123
+ return recursiveCategory(categoryList || []);
124
+ }, [categoryList]);
125
+ const templateItems = useMemo(() => {
126
+ if (infiniteObjectTemplate) {
127
+ const { pages } = infiniteObjectTemplate;
128
+ return pages.flatMap(({ entities }) => entities.flatMap(({ id, name, thumbnail }) => ({
129
+ id,
130
+ name,
131
+ thumbnail,
132
+ })));
133
+ }
134
+ return [];
135
+ }, [infiniteObjectTemplate]);
136
+ const similarTemplates = useMemo(() => {
137
+ const maxSimilarTemplateLength = 4;
138
+ return (getShuffleArray(templateItems.filter(item => item.id !== selectedTemplateId)).slice(0, maxSimilarTemplateLength) || []);
139
+ }, [templateItems, selectedTemplateId]);
140
+ // Effects
141
+ useDeepCompareEffect(() => {
142
+ setState(prev => (Object.assign(Object.assign({}, prev), { openCategoryKeys: (categoryList === null || categoryList === void 0 ? void 0 : categoryList.map(({ categoryCode }) => categoryCode)) || [] })));
143
+ }, [categoryList]);
144
+ useDeepCompareEffect(() => {
145
+ if (!isEmpty(checkedCategoriesDefault)) {
146
+ setState(prev => (Object.assign(Object.assign({}, prev), { checkedCategories: Object.entries(checkedCategoriesDefault).reduce((acc, curr) => {
147
+ const [key, value] = curr;
148
+ acc[key] = value.map(item => [key, item].join(CATEGORY_SPLIT_KEY));
149
+ return acc;
150
+ }, {}) || {} })));
151
+ }
152
+ }, [checkedCategoriesDefault]);
153
+ // Handles
154
+ const onChangeCheckedCategories = (checkedCategories) => {
155
+ setState(prev => (Object.assign(Object.assign({}, prev), { checkedCategories })));
156
+ };
157
+ const onChangeOpenCategoryKeys = useCallback((openKeys) => {
158
+ setState(prev => (Object.assign(Object.assign({}, prev), { openCategoryKeys: openKeys })));
159
+ }, []);
160
+ const onRemoveObjectTemplate = useCallback((id) => {
161
+ bulkUpdateTemplate({
162
+ auth: serviceAuth,
163
+ params: {
164
+ template_ids: [+id],
165
+ data: {
166
+ status: TEMPLATE_STATUS.REMOVED,
167
+ },
168
+ },
169
+ });
170
+ }, [bulkUpdateTemplate, serviceAuth]);
171
+ const onLoadMore = useCallback(() => {
172
+ if (!isFetchingNextPage && hasNextPage) {
173
+ fetchNextPage();
174
+ }
175
+ }, [fetchNextPage, hasNextPage, isFetchingNextPage]);
176
+ const onSelectTemplate = useCallback((id, action) => {
177
+ setState(prev => (Object.assign(Object.assign({}, prev), { selectedTemplateId: id, selectTemplateAction: action })));
178
+ }, []);
179
+ const onClosePreviewModal = useCallback(() => {
180
+ setState(prev => (Object.assign(Object.assign({}, prev), { selectedTemplateId: undefined })));
181
+ }, []);
182
+ return {
183
+ // MapKeys
184
+ categoryItems,
185
+ templateItems,
186
+ openCategoryKeys,
187
+ similarTemplates,
188
+ // Values
189
+ templateDetail,
190
+ checkedCategories,
191
+ selectTemplateAction,
192
+ isLoadingCategoryList,
193
+ isLoadingTemplateList,
194
+ isLoadingTemplateDetail,
195
+ // Functions
196
+ refetchCategoryList,
197
+ refetchTemplateList,
198
+ onChangeCheckedCategories,
199
+ onChangeOpenCategoryKeys,
200
+ onRemoveObjectTemplate,
201
+ onLoadMore,
202
+ onSelectTemplate,
203
+ onClosePreviewModal,
204
+ setState,
205
+ };
206
+ };
@@ -1,22 +1,86 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ /* eslint-disable react/function-component-definition */
1
13
  // Libraries
2
- import React, { memo } from 'react';
14
+ import React, { memo, useState } from 'react';
3
15
  // Components
4
- import { CategoryListing, TemplateItem, BlankTemplate } from './components';
5
- import { Flex, Typography } from '../../atoms';
16
+ import { CategoryListing, BlankTemplate, Empty } from './components';
17
+ import { Spin } from '@antscorp/antsomi-ui/es/components/atoms';
18
+ import { ThumbnailCard } from '@antscorp/antsomi-ui/es/components/molecules';
19
+ import { PreviewTemplateModal } from '../../organism/PreviewTemplateModal';
6
20
  // Constants
7
- import { BLANK_TEMPLATE_DEFAULT, TEMPLATE_ITEM_DEFAULT, TEMPLATE_LISTING_DEFAULT, TEMPLATE_ITEM_HEIGHT, TEMPLATE_ITEM_WIDTH, CATEGORY_LISTING_DEFAULT, } from './constants';
21
+ import { BLANK_TEMPLATE_DEFAULT, TEMPLATE_ITEM_DEFAULT, TEMPLATE_LISTING_DEFAULT, CATEGORY_LISTING_DEFAULT, EMPTY_DEFAULT, TEMPLATES_DEFAULT, LISTING_GAP_DEFAULT, } from './constants';
22
+ import { THUMBNAIL_CARD_DEFAULT_HEIGHT, THUMBNAIL_CARD_DEFAULT_WIDTH, } from '../../molecules/ThumbnailCard/constants';
8
23
  // Styled
9
- import { TemplateListingWrapper } from './styled';
24
+ import { LoadMoreBlock, TemplateListingWrapper } from './styled';
25
+ // Hooks
26
+ import { useIntersectionObserver, useListingItemResize } from '@antscorp/antsomi-ui/es/hooks';
10
27
  export const TemplateListing = memo(props => {
11
- const { templateItems, categoryItems, templateItemProps = TEMPLATE_ITEM_DEFAULT, blankTemplateProps = BLANK_TEMPLATE_DEFAULT, categoryListingProps = CATEGORY_LISTING_DEFAULT, } = props;
12
- const { width = TEMPLATE_ITEM_WIDTH, height = TEMPLATE_ITEM_HEIGHT } = templateItemProps;
28
+ // Props
29
+ const { templatesProps = TEMPLATES_DEFAULT, templateItemProps = TEMPLATE_ITEM_DEFAULT, blankTemplateProps = BLANK_TEMPLATE_DEFAULT, categoryListingProps = CATEGORY_LISTING_DEFAULT, emptyProps = EMPTY_DEFAULT, previewModalProps, } = props;
30
+ // States
31
+ const [openPreviewModal, setOpenPreviewModal] = useState(false);
32
+ // Variables
33
+ const { items = [], gap = LISTING_GAP_DEFAULT, loading = false, onLoadMoreTemplates = () => { }, } = templatesProps || {};
34
+ const _a = previewModalProps || {}, { informationProps, onOk, onCancel } = _a, restOfPreviewModalProps = __rest(_a, ["informationProps", "onOk", "onCancel"]);
35
+ const _b = informationProps || {}, { onButtonClick } = _b, restOfPreviewModalInfoProps = __rest(_b, ["onButtonClick"]);
36
+ const _c = templateItemProps || {}, { width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, onClickPreview } = _c, restOfTemplateItemProps = __rest(_c, ["width", "height", "onClickPreview"]);
37
+ const isHasData = items.length > 0;
38
+ // Hooks
39
+ const { ref: containerRef, itemPerRow, ratio, gap: listingGap, } = useListingItemResize({
40
+ gap,
41
+ initialWidth: width || THUMBNAIL_CARD_DEFAULT_WIDTH,
42
+ });
43
+ const { ref: loadMoreRef } = useIntersectionObserver({
44
+ threshold: 0,
45
+ initialIsIntersecting: false,
46
+ onChange(isIntersecting) {
47
+ if (isIntersecting) {
48
+ onLoadMoreTemplates();
49
+ }
50
+ },
51
+ });
52
+ // Handlers
53
+ const handleClickThumbnailPreview = (id) => {
54
+ onClickPreview === null || onClickPreview === void 0 ? void 0 : onClickPreview(id);
55
+ setOpenPreviewModal(true);
56
+ };
57
+ const handleOkPreviewModal = (e) => {
58
+ onOk === null || onOk === void 0 ? void 0 : onOk(e);
59
+ setOpenPreviewModal(false);
60
+ };
61
+ const handleCancelPreviewModal = (e) => {
62
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
63
+ setOpenPreviewModal(false);
64
+ };
65
+ const handleClickPreviewModalInfoBtn = e => {
66
+ onButtonClick === null || onButtonClick === void 0 ? void 0 : onButtonClick(e);
67
+ onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
68
+ };
13
69
  return (React.createElement(TemplateListingWrapper, null,
14
- React.createElement(CategoryListing, Object.assign({ items: categoryItems }, categoryListingProps, { className: `category-listing ${(categoryListingProps === null || categoryListingProps === void 0 ? void 0 : categoryListingProps.className) || ''}` })),
15
- React.createElement(Flex, { gap: 30, wrap: "wrap", style: { padding: '15px' }, className: "template-listing" },
16
- React.createElement(BlankTemplate, Object.assign({ width: width, height: height }, blankTemplateProps)), templateItems === null || templateItems === void 0 ? void 0 :
17
- templateItems.map(({ key, name, thumbnail }) => (React.createElement(Flex, { key: key, vertical: true, gap: 10 },
18
- React.createElement(TemplateItem, Object.assign({ id: key, thumbnail: thumbnail }, templateItemProps)),
19
- React.createElement(Typography.Text, { ellipsis: { tooltip: name }, style: { maxWidth: '100%' } }, name)))))));
70
+ React.createElement(CategoryListing, Object.assign({}, categoryListingProps)),
71
+ React.createElement(Spin, { spinning: loading, wrapperClassName: "template-listing__loading template-listing__loading--full" },
72
+ React.createElement("div", { className: "template-listing" },
73
+ React.createElement("div", { ref: containerRef, style: {
74
+ display: 'grid',
75
+ gap: listingGap,
76
+ gridTemplateColumns: `repeat(${itemPerRow}, minmax(0, 1fr))`,
77
+ } },
78
+ React.createElement(BlankTemplate, Object.assign({ width: width * ratio, height: height * ratio }, blankTemplateProps)), items === null || items === void 0 ? void 0 :
79
+ items.map(({ id, name, thumbnail }, index) => (React.createElement("div", { key: id },
80
+ React.createElement(ThumbnailCard, Object.assign({ id: id, name: name, width: width * ratio, height: height * ratio, thumbnail: thumbnail, className: `animate__animated animate__fadeIn ${templateItemProps.className}`, onClickPreview: handleClickThumbnailPreview }, restOfTemplateItemProps)),
81
+ index === items.length - 1 && React.createElement(LoadMoreBlock, { ref: loadMoreRef }))))),
82
+ !loading && !blankTemplateProps.show && !isHasData && React.createElement(Empty, Object.assign({}, emptyProps)))),
83
+ React.createElement(PreviewTemplateModal, Object.assign({ informationProps: Object.assign({ onButtonClick: handleClickPreviewModalInfoBtn }, restOfPreviewModalInfoProps), open: openPreviewModal, onOk: handleOkPreviewModal, onCancel: handleCancelPreviewModal }, restOfPreviewModalProps))));
20
84
  });
21
85
  TemplateListing.displayName = 'TemplateListing';
22
86
  TemplateListing.defaultProps = TEMPLATE_LISTING_DEFAULT;
@@ -1,2 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  export declare const TemplateListingWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
3
+ export declare const LoadMoreBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export declare const ImageWrapper: import("styled-components").StyledComponent<"img", any, {}, never>;
@@ -3,14 +3,38 @@ import styled from 'styled-components';
3
3
  // Components
4
4
  import { Flex } from '../../../atoms';
5
5
  export const TemplateListingWrapper = styled(Flex) `
6
+ position: relative;
6
7
  height: 100%;
7
8
 
8
- .category-listing {
9
- flex-shrink: 0;
10
- }
11
-
12
9
  .template-listing {
13
10
  flex: 1 1 0%;
14
- height: fit-content;
11
+ height: 100%;
12
+ max-height: 100%;
13
+ overflow-y: auto;
14
+ box-sizing: border-box;
15
+ padding: 15px;
16
+
17
+ &__loading {
18
+ height: 100%;
19
+
20
+ .antsomi-spin-container {
21
+ height: 100%;
22
+ width: 100%;
23
+
24
+ > div {
25
+ max-height: 100%;
26
+ }
27
+ }
28
+
29
+ &--full {
30
+ width: 100%;
31
+ }
32
+ }
15
33
  }
16
34
  `;
35
+ export const LoadMoreBlock = styled.div ``;
36
+ export const ImageWrapper = styled.img `
37
+ width: 100%;
38
+ height: 100%;
39
+ object-fit: contain;
40
+ `;