@antscorp/antsomi-ui 1.3.5-beta.4 → 1.3.5-beta.41

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 (284) hide show
  1. package/es/assets/images/background/skeleton-background.png +0 -0
  2. package/es/assets/images/profile.png +0 -0
  3. package/es/assets/images/skeleton_bg.png +0 -0
  4. package/es/assets/images/tail.png +0 -0
  5. package/es/assets/svg/mobile-frame.svg +3 -0
  6. package/es/components/atoms/MobileFrame/MobileFrame.d.ts +2 -0
  7. package/es/components/atoms/MobileFrame/MobileFrame.js +1 -1
  8. package/es/components/atoms/MobileFrame/styled.d.ts +2 -1
  9. package/es/components/atoms/MobileFrame/styled.js +11 -6
  10. package/es/components/atoms/SlideBar/SlideBar.js +3 -1
  11. package/es/components/atoms/Spin/Spin.js +2 -2
  12. package/es/components/common/ConfigProvider/ConfigProvider.d.ts +1 -1
  13. package/es/components/common/ConfigProvider/ConfigProvider.js +9 -4
  14. package/es/components/common/ConfigProvider/GlobalStyle.js +85 -16
  15. package/es/components/molecules/CalendarSelection/CalendarSelection.d.ts +3 -0
  16. package/es/components/molecules/CalendarSelection/CalendarSelection.js +45 -0
  17. package/es/components/molecules/CalendarSelection/actions.d.ts +55 -0
  18. package/es/components/molecules/CalendarSelection/actions.js +39 -0
  19. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/AutoUpdateTo.d.ts +7 -0
  20. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/AutoUpdateTo.js +24 -0
  21. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/index.d.ts +1 -0
  22. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/index.js +1 -0
  23. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.d.ts +1 -0
  24. package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.js +10 -0
  25. package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.d.ts +3 -0
  26. package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.js +108 -0
  27. package/es/components/molecules/CalendarSelection/components/CustomPicker/index.d.ts +1 -0
  28. package/es/components/molecules/CalendarSelection/components/CustomPicker/index.js +1 -0
  29. package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.d.ts +6 -0
  30. package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.js +152 -0
  31. package/es/components/molecules/CalendarSelection/components/CustomPicker/types.d.ts +1 -0
  32. package/es/components/molecules/CalendarSelection/components/Footer/Footer.d.ts +2 -0
  33. package/es/components/molecules/CalendarSelection/components/Footer/Footer.js +11 -0
  34. package/es/components/molecules/CalendarSelection/components/Footer/index.d.ts +1 -0
  35. package/es/components/molecules/CalendarSelection/components/Footer/index.js +1 -0
  36. package/es/components/molecules/CalendarSelection/components/Footer/styled.d.ts +1 -0
  37. package/es/components/molecules/CalendarSelection/components/Footer/styled.js +6 -0
  38. package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.d.ts +5 -0
  39. package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.js +4 -0
  40. package/es/components/molecules/CalendarSelection/components/RangePicker/index.d.ts +1 -0
  41. package/es/components/molecules/CalendarSelection/components/RangePicker/index.js +1 -0
  42. package/es/components/molecules/CalendarSelection/components/RangePicker/styled.d.ts +5 -0
  43. package/es/components/molecules/CalendarSelection/components/RangePicker/styled.js +13 -0
  44. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/RangeSelectOptions.d.ts +3 -0
  45. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/RangeSelectOptions.js +23 -0
  46. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/NumOfDaysRanges.d.ts +2 -0
  47. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/NumOfDaysRanges.js +41 -0
  48. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.d.ts +1 -0
  49. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.js +1 -0
  50. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.d.ts +11 -0
  51. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.js +40 -0
  52. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/index.d.ts +1 -0
  53. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/index.js +1 -0
  54. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.d.ts +1 -0
  55. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.js +29 -0
  56. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.d.ts +2 -0
  57. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.js +2 -0
  58. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/index.d.ts +1 -0
  59. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/index.js +1 -0
  60. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.d.ts +3 -0
  61. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.js +34 -0
  62. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/types.d.ts +1 -0
  63. package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/types.js +1 -0
  64. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.d.ts +8 -0
  65. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js +49 -0
  66. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/index.d.ts +2 -0
  67. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/index.js +2 -0
  68. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.d.ts +1 -0
  69. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.js +70 -0
  70. package/es/components/molecules/CalendarSelection/components/index.d.ts +5 -0
  71. package/es/components/molecules/CalendarSelection/components/index.js +5 -0
  72. package/es/components/molecules/CalendarSelection/constants.d.ts +97 -0
  73. package/es/components/molecules/CalendarSelection/constants.js +183 -0
  74. package/es/components/molecules/CalendarSelection/context.d.ts +4 -0
  75. package/es/components/molecules/CalendarSelection/context.js +6 -0
  76. package/es/components/molecules/CalendarSelection/hooks/index.d.ts +2 -0
  77. package/es/components/molecules/CalendarSelection/hooks/index.js +2 -0
  78. package/es/components/molecules/CalendarSelection/hooks/useStateContext.d.ts +4 -0
  79. package/es/components/molecules/CalendarSelection/hooks/useStateContext.js +13 -0
  80. package/es/components/molecules/CalendarSelection/hooks/useTriggerOut.d.ts +9 -0
  81. package/es/components/molecules/CalendarSelection/hooks/useTriggerOut.js +19 -0
  82. package/es/components/molecules/CalendarSelection/index.d.ts +25 -0
  83. package/es/components/molecules/CalendarSelection/index.js +6 -0
  84. package/es/components/molecules/CalendarSelection/reducer.d.ts +3 -0
  85. package/es/components/molecules/CalendarSelection/reducer.js +121 -0
  86. package/es/components/molecules/CalendarSelection/styled.d.ts +6 -0
  87. package/es/components/molecules/CalendarSelection/styled.js +13 -0
  88. package/es/components/molecules/CalendarSelection/types.d.ts +98 -0
  89. package/es/components/molecules/CalendarSelection/types.js +1 -0
  90. package/es/components/molecules/CalendarSelection/utils.d.ts +52 -0
  91. package/es/components/molecules/CalendarSelection/utils.js +304 -0
  92. package/es/components/molecules/ColorPicker/CustomPicker/index.js +3 -3
  93. package/es/components/molecules/ColorPicker/index.d.ts +1 -0
  94. package/es/components/molecules/ColorPicker/index.js +3 -2
  95. package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +24 -16
  96. package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.d.ts +5 -0
  97. package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +31 -1
  98. package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +1 -1
  99. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +3 -1
  100. package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +5 -4
  101. package/es/components/molecules/ModalV2/styled.js +4 -0
  102. package/es/components/molecules/ResizeGrid/ResizeGrid.js +10 -2
  103. package/es/components/molecules/ResizeGrid/types.d.ts +1 -0
  104. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.d.ts +1 -0
  105. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.js +2 -2
  106. package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.d.ts +1 -0
  107. package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.js +3 -2
  108. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.d.ts +1 -0
  109. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.js +1 -1
  110. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +7 -0
  111. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +25 -6
  112. package/es/components/molecules/RichMenu/RichMenuMobileView/styled.d.ts +5 -0
  113. package/es/components/molecules/RichMenu/RichMenuMobileView/styled.js +31 -0
  114. package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +2 -2
  115. package/es/components/molecules/ShareAccess/index.d.ts +2 -3
  116. package/es/components/molecules/ShareAccess/index.js +2 -3
  117. package/es/components/molecules/ShareAccess/types.d.ts +2 -0
  118. package/es/components/molecules/ShareAccess/utils.d.ts +2 -1
  119. package/es/components/molecules/ShareAccess/utils.js +9 -0
  120. package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.d.ts +71 -0
  121. package/es/components/molecules/TemplateSaveAs/TemplateSaveAs.js +172 -0
  122. package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.d.ts +10 -0
  123. package/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.js +50 -0
  124. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.d.ts +18 -0
  125. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/ImageSlider.js +57 -0
  126. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/index.d.ts +1 -0
  127. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/index.js +1 -0
  128. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.d.ts +5 -0
  129. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +197 -0
  130. package/es/components/molecules/TemplateSaveAs/components/index.d.ts +1 -0
  131. package/es/components/molecules/TemplateSaveAs/components/index.js +1 -0
  132. package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.d.ts +52 -0
  133. package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.js +107 -0
  134. package/es/components/molecules/TemplateSaveAs/index.d.ts +4 -0
  135. package/es/components/molecules/TemplateSaveAs/index.js +3 -0
  136. package/es/components/molecules/TemplateSaveAs/styled.d.ts +4 -0
  137. package/es/components/molecules/TemplateSaveAs/styled.js +73 -0
  138. package/es/components/molecules/ThumbnailCard/ThumbnailCard.d.ts +3 -0
  139. package/es/components/molecules/ThumbnailCard/ThumbnailCard.js +72 -0
  140. package/es/components/molecules/ThumbnailCard/constants.d.ts +3 -0
  141. package/es/components/molecules/ThumbnailCard/constants.js +3 -0
  142. package/es/components/molecules/ThumbnailCard/index.d.ts +2 -0
  143. package/es/components/molecules/ThumbnailCard/index.js +2 -0
  144. package/es/components/molecules/ThumbnailCard/styled.d.ts +1 -0
  145. package/es/components/{template/TemplateListing/components/TemplateItem → molecules/ThumbnailCard}/styled.js +14 -7
  146. package/es/components/molecules/ThumbnailCard/types.d.ts +23 -0
  147. package/es/components/molecules/ThumbnailCard/types.js +1 -0
  148. package/es/components/molecules/UploadImage/index.js +1 -1
  149. package/es/components/molecules/index.d.ts +5 -0
  150. package/es/components/molecules/index.js +3 -0
  151. package/es/components/organism/Help/Help.js +30 -1
  152. package/es/components/organism/Menu/Menu.d.ts +2 -0
  153. package/es/components/organism/Menu/Menu.js +3 -0
  154. package/es/components/organism/Menu/index.d.ts +1 -0
  155. package/es/components/organism/Menu/index.js +3 -0
  156. package/es/components/organism/PreviewTemplateModal/components/Banner/index.d.ts +3 -0
  157. package/es/components/organism/PreviewTemplateModal/components/Banner/index.js +13 -0
  158. package/es/components/organism/PreviewTemplateModal/components/Banner/styled.d.ts +4 -0
  159. package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +98 -0
  160. package/es/components/organism/PreviewTemplateModal/components/Information/index.d.ts +3 -0
  161. package/es/components/organism/PreviewTemplateModal/components/Information/index.js +29 -0
  162. package/es/components/organism/PreviewTemplateModal/components/Information/styled.d.ts +2 -0
  163. package/es/components/organism/PreviewTemplateModal/components/Information/styled.js +41 -0
  164. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.d.ts +3 -0
  165. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.js +29 -0
  166. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.d.ts +2 -0
  167. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.js +12 -0
  168. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.d.ts +6 -0
  169. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.js +77 -0
  170. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.d.ts +3 -0
  171. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.js +62 -0
  172. package/es/components/organism/PreviewTemplateModal/components/index.d.ts +4 -0
  173. package/es/components/organism/PreviewTemplateModal/components/index.js +4 -0
  174. package/es/components/organism/PreviewTemplateModal/constants/dataSample.d.ts +2 -0
  175. package/es/components/organism/PreviewTemplateModal/constants/dataSample.js +9 -0
  176. package/es/components/organism/PreviewTemplateModal/constants/defaultProps.d.ts +8 -0
  177. package/es/components/organism/PreviewTemplateModal/constants/defaultProps.js +11 -0
  178. package/es/components/organism/PreviewTemplateModal/constants/html.d.ts +1 -0
  179. package/es/components/organism/PreviewTemplateModal/constants/html.js +1 -0
  180. package/es/components/organism/PreviewTemplateModal/constants/index.d.ts +4 -0
  181. package/es/components/organism/PreviewTemplateModal/constants/index.js +4 -0
  182. package/es/components/organism/PreviewTemplateModal/constants/variables.d.ts +12 -0
  183. package/es/components/organism/PreviewTemplateModal/constants/variables.js +12 -0
  184. package/es/components/organism/PreviewTemplateModal/index.d.ts +3 -0
  185. package/es/components/organism/PreviewTemplateModal/index.js +34 -0
  186. package/es/components/organism/PreviewTemplateModal/styled.d.ts +4 -0
  187. package/es/components/organism/PreviewTemplateModal/styled.js +26 -0
  188. package/es/components/organism/PreviewTemplateModal/types.d.ts +39 -0
  189. package/es/components/organism/PreviewTemplateModal/types.js +1 -0
  190. package/es/components/organism/index.d.ts +1 -0
  191. package/es/components/organism/index.js +1 -0
  192. package/es/components/template/TemplateListing/Loadable.d.ts +6 -0
  193. package/es/components/template/TemplateListing/Loadable.js +7 -0
  194. package/es/components/template/TemplateListing/components/BlankTemplate/index.js +9 -7
  195. package/es/components/template/TemplateListing/components/BlankTemplate/styled.js +2 -0
  196. package/es/components/template/TemplateListing/components/CategoryListing/index.js +19 -10
  197. package/es/components/template/TemplateListing/components/CategoryListing/styled.d.ts +2 -0
  198. package/es/components/template/TemplateListing/components/CategoryListing/styled.js +44 -7
  199. package/es/components/template/TemplateListing/components/CategoryListing/types.d.ts +2 -1
  200. package/es/components/template/TemplateListing/components/Empty/index.d.ts +3 -0
  201. package/es/components/template/TemplateListing/components/Empty/index.js +18 -0
  202. package/es/components/template/TemplateListing/components/Empty/styled.d.ts +3 -0
  203. package/es/components/template/TemplateListing/components/Empty/styled.js +35 -0
  204. package/es/components/template/TemplateListing/components/index.d.ts +1 -1
  205. package/es/components/template/TemplateListing/components/index.js +1 -1
  206. package/es/components/template/TemplateListing/constants/defaultProps.d.ts +8 -4
  207. package/es/components/template/TemplateListing/constants/defaultProps.js +9 -6
  208. package/es/components/template/TemplateListing/hooks/index.d.ts +1 -0
  209. package/es/components/template/TemplateListing/hooks/index.js +1 -0
  210. package/es/components/template/TemplateListing/hooks/useTemplateListing.d.ts +62 -0
  211. package/es/components/template/TemplateListing/hooks/useTemplateListing.js +226 -0
  212. package/es/components/template/TemplateListing/index.js +75 -13
  213. package/es/components/template/TemplateListing/styled/index.d.ts +2 -0
  214. package/es/components/template/TemplateListing/styled/index.js +29 -5
  215. package/es/components/template/TemplateListing/types/BlankTemplate.d.ts +3 -2
  216. package/es/components/template/TemplateListing/types/CategoryListing.d.ts +5 -2
  217. package/es/components/template/TemplateListing/types/Empty.d.ts +5 -0
  218. package/es/components/template/TemplateListing/types/Empty.js +1 -0
  219. package/es/components/template/TemplateListing/types/TemplateListing.d.ts +20 -9
  220. package/es/components/template/TemplateListing/types/index.d.ts +0 -1
  221. package/es/components/template/TemplateListing/types/index.js +0 -1
  222. package/es/components/template/index.d.ts +2 -1
  223. package/es/components/template/index.js +5 -1
  224. package/es/constants/datetime.d.ts +8 -0
  225. package/es/constants/datetime.js +1594 -0
  226. package/es/constants/index.d.ts +5 -1
  227. package/es/constants/index.js +5 -1
  228. package/es/constants/queries.d.ts +3 -0
  229. package/es/constants/queries.js +4 -0
  230. package/es/constants/templateListing.d.ts +50 -0
  231. package/es/constants/templateListing.js +52 -0
  232. package/es/constants/theme.js +1 -1
  233. package/es/constants/variables.d.ts +19 -0
  234. package/es/constants/variables.js +19 -0
  235. package/es/hooks/index.d.ts +4 -0
  236. package/es/hooks/index.js +4 -0
  237. package/es/hooks/useEffectOnlyOnce.d.ts +2 -0
  238. package/es/hooks/useEffectOnlyOnce.js +12 -0
  239. package/es/hooks/useForceUpdate.d.ts +1 -0
  240. package/es/hooks/useForceUpdate.js +5 -0
  241. package/es/hooks/useIntersectionObserver.d.ts +57 -0
  242. package/es/hooks/useIntersectionObserver.js +97 -0
  243. package/es/hooks/useListingItemResize.d.ts +12 -0
  244. package/es/hooks/useListingItemResize.js +58 -0
  245. package/es/hooks/useScrollToEnd.d.ts +1 -0
  246. package/es/hooks/useScrollToEnd.js +30 -0
  247. package/es/index.d.ts +3 -0
  248. package/es/index.js +3 -0
  249. package/es/locales/en/translation.json +11 -3
  250. package/es/locales/i18n.d.ts +16 -0
  251. package/es/locales/translations.d.ts +8 -0
  252. package/es/locales/vi/translation.json +9 -1
  253. package/es/models/ObjectTemplate.d.ts +56 -0
  254. package/es/models/ObjectTemplate.js +82 -0
  255. package/es/models/TemplateCategory.d.ts +13 -0
  256. package/es/models/TemplateCategory.js +28 -0
  257. package/es/queries/TemplateListing/index.d.ts +47 -0
  258. package/es/queries/TemplateListing/index.js +98 -0
  259. package/es/queries/index.d.ts +1 -0
  260. package/es/queries/index.js +1 -0
  261. package/es/services/TemplateListing/index.d.ts +65 -0
  262. package/es/services/TemplateListing/index.js +149 -0
  263. package/es/test.js +65 -11
  264. package/es/types/index.d.ts +5 -0
  265. package/es/types/index.js +3 -0
  266. package/es/types/service.d.ts +22 -0
  267. package/es/types/service.js +1 -0
  268. package/es/types/share-access.d.ts +17 -0
  269. package/es/types/share-access.js +1 -0
  270. package/es/types/templateListing.d.ts +13 -0
  271. package/es/types/templateListing.js +1 -0
  272. package/es/types/variables.d.ts +3 -0
  273. package/es/utils/common.d.ts +4 -0
  274. package/es/utils/common.js +34 -0
  275. package/es/utils/index.d.ts +1 -0
  276. package/es/utils/index.js +1 -0
  277. package/es/utils/templateListing.d.ts +2 -0
  278. package/es/utils/templateListing.js +12 -0
  279. package/package.json +6 -1
  280. package/es/components/template/TemplateListing/components/TemplateItem/index.d.ts +0 -3
  281. package/es/components/template/TemplateListing/components/TemplateItem/index.js +0 -53
  282. package/es/components/template/TemplateListing/components/TemplateItem/styled.d.ts +0 -1
  283. package/es/components/template/TemplateListing/types/TemplateItem.d.ts +0 -14
  284. /package/es/components/{template/TemplateListing/types/TemplateItem.js → molecules/CalendarSelection/components/CustomPicker/types.js} +0 -0
@@ -2,16 +2,18 @@
2
2
  import React, { memo } from 'react';
3
3
  import Icon from '@antscorp/icons';
4
4
  // Components
5
- import { Button, Flex } from '../../../../atoms';
5
+ import { Button, Flex, Typography } from '../../../../atoms';
6
6
  // Styled
7
7
  import { BlankTemplateWrapper } from './styled';
8
+ // Constants
9
+ import { THUMBNAIL_CARD_DEFAULT_HEIGHT, THUMBNAIL_CARD_DEFAULT_WIDTH, } from '@antscorp/antsomi-ui/es/components/molecules/ThumbnailCard/constants';
8
10
  export const BlankTemplate = memo(props => {
9
- const { width, height, show, description, onButtonClick } = props;
10
- return show ? (React.createElement(BlankTemplateWrapper, { style: { width, height }, align: "center", justify: "center" },
11
- React.createElement(Flex, { align: "center", justify: "center", gap: 10, vertical: true },
12
- React.createElement(Button, { type: "text", className: "add-blank-btn", icon: React.createElement(Icon, { type: "icon-ants-plus-slim", style: { fontSize: 24 } }), onClick: onButtonClick }),
11
+ const { width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, show, description = 'Blank Template', blankTemplateRender, onClick, } = props;
12
+ const BlankTemplateNode = (React.createElement(BlankTemplateWrapper, { style: { width, height }, align: "center", justify: "center", onClick: onClick },
13
+ React.createElement(Flex, { align: "center", justify: "center", gap: 10, vertical: true, style: { width: '100%' } },
14
+ React.createElement(Button, { type: "text", className: "add-blank-btn", icon: React.createElement(Icon, { type: "icon-ants-plus-slim", style: { fontSize: 24 } }) }),
13
15
  React.createElement("div", { className: "description" },
14
- " ",
15
- description || 'Blank Template')))) : null;
16
+ React.createElement(Typography.Text, { ellipsis: { tooltip: description }, style: { maxWidth: '100%', color: 'inherit' } }, description)))));
17
+ return show ? (blankTemplateRender ? (React.createElement(React.Fragment, null, blankTemplateRender(BlankTemplateNode))) : (BlankTemplateNode)) : null;
16
18
  });
17
19
  BlankTemplate.displayName = 'BlankTemplate';
@@ -6,6 +6,7 @@ export const BlankTemplateWrapper = styled(Flex) `
6
6
  box-sizing: border-box;
7
7
  border: 1px solid #b8cfe6;
8
8
  border-radius: 5px;
9
+ cursor: pointer;
9
10
 
10
11
  .add-blank-btn {
11
12
  width: 50px !important;
@@ -20,5 +21,6 @@ export const BlankTemplateWrapper = styled(Flex) `
20
21
 
21
22
  .description {
22
23
  font-weight: 700;
24
+ max-width: 90%;
23
25
  }
24
26
  `;
@@ -13,18 +13,21 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  import React, { memo, useCallback, useMemo } from 'react';
14
14
  import { isEmpty, isNumber } from 'lodash';
15
15
  import Icon from '@antscorp/icons';
16
- import { Menu } from 'antd';
16
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
17
17
  // Styled
18
- import { CustomLabelStyled, CustomRootLabel, MenuWrapper } from './styled';
18
+ import { CustomLabelStyled, CustomRootLabel, MenuWrapper, TextWrapper } from './styled';
19
19
  // Components
20
- import { Checkbox, Typography } from '../../../../atoms';
20
+ import { Checkbox, Spin } from '../../../../atoms';
21
+ import { Menu } from '../../../../organism';
22
+ import { Empty } from '../Empty';
21
23
  // Utils
22
24
  import { handleError } from '@antscorp/antsomi-ui/es/utils';
23
25
  // Constants
24
26
  import { CATEGORY_LISTING_WITH } from '../../constants';
25
27
  const PATH = 'src/components/template/TemplateListing/components/CategoryListing/index.tsx';
26
28
  export const CategoryListing = memo(props => {
27
- const { width = CATEGORY_LISTING_WITH, items, checkedCategories = {}, onMenuChange } = props, restOfProps = __rest(props, ["width", "items", "checkedCategories", "onMenuChange"]);
29
+ var _a;
30
+ const { width = CATEGORY_LISTING_WITH, items = [], loading = false, show = true, checkedCategories = {}, onMenuChange } = props, restOfProps = __rest(props, ["width", "items", "loading", "show", "checkedCategories", "onMenuChange"]);
28
31
  // Handlers
29
32
  const handleClickMenu = e => {
30
33
  var _a;
@@ -51,11 +54,11 @@ export const CategoryListing = memo(props => {
51
54
  try {
52
55
  const { key, parentId, label, total } = args;
53
56
  const isChecked = !!(!!parentId && ((_a = checkedCategories === null || checkedCategories === void 0 ? void 0 : checkedCategories[parentId]) === null || _a === void 0 ? void 0 : _a.includes(key)));
54
- return (React.createElement(CustomLabelStyled, null,
57
+ return (React.createElement(CustomLabelStyled, { onClick: e => e.preventDefault() },
55
58
  React.createElement("div", { className: "label" },
56
59
  React.createElement(Checkbox, { checked: isChecked },
57
- React.createElement(Typography.Text, { style: { maxWidth: '100%' }, ellipsis: { tooltip: label } }, label))),
58
- React.createElement("div", { className: "total" }, isNumber(total) ? total : '')));
60
+ React.createElement(TextWrapper, { ellipsis: { tooltip: label } }, label))),
61
+ React.createElement("span", { className: "total" }, isNumber(total) ? total : '')));
59
62
  }
60
63
  catch (error) {
61
64
  handleError(error, {
@@ -69,7 +72,12 @@ export const CategoryListing = memo(props => {
69
72
  const getItem = useCallback((item, isRoot) => {
70
73
  try {
71
74
  const { key, label, children } = item;
72
- return Object.assign(Object.assign(Object.assign({}, item), (isRoot ? { label: React.createElement(CustomRootLabel, null, label) } : {})), { children: !!children && !isEmpty(children)
75
+ return Object.assign(Object.assign(Object.assign({}, item), (isRoot
76
+ ? {
77
+ label: (React.createElement(CustomRootLabel, null,
78
+ React.createElement(TextWrapper, { ellipsis: { tooltip: label } }, label))),
79
+ }
80
+ : {})), { children: !!children && !isEmpty(children)
73
81
  ? children === null || children === void 0 ? void 0 : children.map(child => {
74
82
  const childItem = Object.assign(Object.assign({}, child), { parentId: key });
75
83
  return getItem(Object.assign(Object.assign({}, childItem), { label: renderCustomLabel(childItem) }));
@@ -97,7 +105,8 @@ export const CategoryListing = memo(props => {
97
105
  });
98
106
  return menuItems;
99
107
  }, [getItem, items]);
100
- return (React.createElement(MenuWrapper, { "$width": width },
101
- React.createElement(Menu, Object.assign({ items: menuItems, inlineIndent: 0, mode: "inline", expandIcon: React.createElement(Icon, { type: "icon-ants-expand-more", style: { fontSize: 20, color: '#595959' } }), onClick: handleClickMenu }, restOfProps))));
108
+ return show ? (React.createElement(MenuWrapper, { "$width": width },
109
+ React.createElement(Spin, { spinning: loading, wrapperClassName: "template-listing__loading" }, isEmpty(menuItems) && !loading ? (React.createElement("div", { className: "empty-wrapper" },
110
+ React.createElement(Empty, null))) : (React.createElement(Menu, Object.assign({ items: menuItems, inlineIndent: 0, mode: "inline", defaultOpenKeys: items === null || items === void 0 ? void 0 : items.map(item => String(item.key)), expandIcon: React.createElement(Icon, { type: "icon-ants-expand-more", style: { fontSize: 20, color: (_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8 } }), onClick: handleClickMenu }, restOfProps)))))) : null;
102
111
  });
103
112
  CategoryListing.displayName = 'CategoryListing';
@@ -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;
11
+ border-right: 1px solid rgba(5, 5, 5, 0.06);
5
12
 
6
13
  .antsomi-menu {
7
14
  height: 100%;
8
15
 
9
- .antsomi-menu-submenu {
10
- .antsomi-menu-submenu-title,
11
- .antsomi-menu-item {
12
- padding-left: 10px !important;
16
+ [role='menuitem'] {
17
+ width: 100%;
18
+ border-radius: 0;
19
+ height: 30px;
20
+ padding: 0 10px !important;
21
+ margin-left: 0 !important;
22
+ margin-right: 0 !important;
23
+
24
+ .antsomi-menu-title-content {
25
+ height: 100%;
13
26
  }
14
27
  }
15
28
  }
29
+
30
+ .category-loading {
31
+ height: 100%;
32
+ }
33
+
34
+ .empty-wrapper {
35
+ width: 100%;
36
+ height: 100%;
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<T> = {
13
+ checkedCategories: TCheckedCategories;
14
+ openCategoryKeys: string[];
15
+ selectedTemplateId?: TThumbnailCardId;
16
+ selectTemplateAction?: TSelectTemplateAction | T;
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: <T = undefined>(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 | T | undefined;
49
+ previewTemplateCategories: TCategoryItem[];
50
+ isLoadingCategoryList: boolean;
51
+ isLoadingTemplateList: boolean;
52
+ isLoadingTemplateDetail: boolean;
53
+ refetchCategoryList: <TPageData>(options?: (import("@tanstack/query-core").RefetchOptions & import("@tanstack/query-core").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/query-core").QueryObserverResult<TemplateCategory[], any>>;
54
+ 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>>;
55
+ onChangeCheckedCategories: (checkedCategories: TCheckedCategories) => void;
56
+ onChangeOpenCategoryKeys: (openKeys: string[]) => void;
57
+ onRemoveObjectTemplate: (id: TThumbnailCardId) => void;
58
+ onLoadMore: () => void;
59
+ onSelectTemplate: (id: TThumbnailCardId, action: TSelectTemplateAction) => void;
60
+ setState: import("react").Dispatch<import("react").SetStateAction<TState<T>>>;
61
+ };
62
+ export {};
@@ -0,0 +1,226 @@
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';
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, getListType, 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
+ get_list_type: getListType,
83
+ limit: limitListPerPage,
84
+ filter: JSON.stringify(filter),
85
+ },
86
+ },
87
+ });
88
+ const { mutateAsync: bulkUpdateTemplate } = useBulkUpdateTemplate({
89
+ options: {
90
+ onSuccess: () => {
91
+ message.success(t(translations.templateListing.removeSuccess));
92
+ },
93
+ onError: () => {
94
+ message.error(t(translations.templateListing.removeFailed));
95
+ },
96
+ },
97
+ });
98
+ const { data: templateDetail, isLoading: isLoadingTemplateDetail } = useGetObjectTemplateDetail({
99
+ args: {
100
+ params: {
101
+ template_id: selectedTemplateId || '',
102
+ object_type: objectType,
103
+ public_level: publicLevel,
104
+ },
105
+ auth: serviceAuth,
106
+ },
107
+ });
108
+ // Variables
109
+ const isLoadingTemplateList = isFetching || isFetchingNextPage;
110
+ // Memo
111
+ const categoryItems = useDeepCompareMemo(() => {
112
+ const recursiveCategory = (categories = [], parentCategoryCode = '') => categories.map(category => {
113
+ const { categoryCode, categoryId, categoryName, children, total } = category;
114
+ const key = Array.isArray(children) && children.length
115
+ ? categoryCode
116
+ : [parentCategoryCode, categoryId].join(CATEGORY_SPLIT_KEY);
117
+ return {
118
+ key,
119
+ label: categoryName,
120
+ total,
121
+ children: recursiveCategory(children || [], categoryCode),
122
+ };
123
+ });
124
+ return recursiveCategory(categoryList || []);
125
+ }, [categoryList]);
126
+ const templateItems = useMemo(() => {
127
+ if (infiniteObjectTemplate) {
128
+ const { pages } = infiniteObjectTemplate;
129
+ return pages.flatMap(({ entities }) => entities.flatMap(({ id, name, thumbnail }) => ({
130
+ id,
131
+ name,
132
+ thumbnail,
133
+ })));
134
+ }
135
+ return [];
136
+ }, [infiniteObjectTemplate]);
137
+ const similarTemplates = useMemo(() => {
138
+ const maxSimilarTemplateLength = 4;
139
+ return (getShuffleArray(templateItems.filter(item => item.id !== selectedTemplateId)).slice(0, maxSimilarTemplateLength) || []);
140
+ }, [templateItems, selectedTemplateId]);
141
+ const previewTemplateCategories = useDeepCompareMemo(() => {
142
+ if ((categoryItems === null || categoryItems === void 0 ? void 0 : categoryItems.length) && !!templateDetail) {
143
+ /**
144
+ * Filter category items has value of object template
145
+ * and filter child items has value of object template
146
+ */
147
+ return categoryItems
148
+ .filter(item => {
149
+ const values = templateDetail.model[item.key];
150
+ return typeof values === 'object' ? !isEmpty(values) : !!values;
151
+ })
152
+ .map(item => {
153
+ var _a;
154
+ return (Object.assign(Object.assign({}, item), { children: (_a = item.children) === null || _a === void 0 ? void 0 : _a.filter(childItem => {
155
+ let values = templateDetail.model[item.key];
156
+ values = Array.isArray(values) ? values : [values];
157
+ return values.includes(+`${childItem.key}`.split(CATEGORY_SPLIT_KEY)[1]);
158
+ }) }));
159
+ });
160
+ }
161
+ return [];
162
+ }, [categoryItems, templateDetail]);
163
+ // Effects
164
+ useDeepCompareEffect(() => {
165
+ setState(prev => (Object.assign(Object.assign({}, prev), { openCategoryKeys: (categoryList === null || categoryList === void 0 ? void 0 : categoryList.map(({ categoryCode }) => categoryCode)) || [] })));
166
+ }, [categoryList]);
167
+ useDeepCompareEffect(() => {
168
+ if (!isEmpty(checkedCategoriesDefault)) {
169
+ setState(prev => (Object.assign(Object.assign({}, prev), { checkedCategories: Object.entries(checkedCategoriesDefault).reduce((acc, curr) => {
170
+ const [key, value] = curr;
171
+ acc[key] = value.map(item => [key, item].join(CATEGORY_SPLIT_KEY));
172
+ return acc;
173
+ }, {}) || {} })));
174
+ }
175
+ }, [checkedCategoriesDefault]);
176
+ // Handles
177
+ const onChangeCheckedCategories = (checkedCategories) => {
178
+ setState(prev => (Object.assign(Object.assign({}, prev), { checkedCategories })));
179
+ };
180
+ const onChangeOpenCategoryKeys = useCallback((openKeys) => {
181
+ setState(prev => (Object.assign(Object.assign({}, prev), { openCategoryKeys: openKeys })));
182
+ }, []);
183
+ const onRemoveObjectTemplate = useCallback((id) => {
184
+ bulkUpdateTemplate({
185
+ auth: serviceAuth,
186
+ params: {
187
+ template_ids: [+id],
188
+ data: {
189
+ status: TEMPLATE_STATUS.REMOVED,
190
+ },
191
+ },
192
+ });
193
+ }, [bulkUpdateTemplate, serviceAuth]);
194
+ const onLoadMore = useCallback(() => {
195
+ if (!isFetchingNextPage && hasNextPage) {
196
+ fetchNextPage();
197
+ }
198
+ }, [fetchNextPage, hasNextPage, isFetchingNextPage]);
199
+ const onSelectTemplate = useCallback((id, action) => {
200
+ setState(prev => (Object.assign(Object.assign({}, prev), { selectedTemplateId: id, selectTemplateAction: action })));
201
+ }, []);
202
+ return {
203
+ // MapKeys
204
+ categoryItems,
205
+ templateItems,
206
+ openCategoryKeys,
207
+ similarTemplates,
208
+ // Values
209
+ templateDetail,
210
+ checkedCategories,
211
+ selectTemplateAction,
212
+ previewTemplateCategories,
213
+ isLoadingCategoryList,
214
+ isLoadingTemplateList,
215
+ isLoadingTemplateDetail,
216
+ // Functions
217
+ refetchCategoryList,
218
+ refetchTemplateList,
219
+ onChangeCheckedCategories,
220
+ onChangeOpenCategoryKeys,
221
+ onRemoveObjectTemplate,
222
+ onLoadMore,
223
+ onSelectTemplate,
224
+ setState,
225
+ };
226
+ };