diginet-core-ui 1.3.24

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 (360) hide show
  1. package/assets/avatar/default.svg +3 -0
  2. package/assets/images/menu/dhr/Default.svg +13 -0
  3. package/assets/images/menu/dhr/MHRM00N0001.svg +14 -0
  4. package/assets/images/menu/dhr/MHRM09N0001.svg +1 -0
  5. package/assets/images/menu/dhr/MHRM09N0002.svg +3 -0
  6. package/assets/images/menu/dhr/MHRM09N0003.svg +25 -0
  7. package/assets/images/menu/dhr/MHRM25N0001.svg +26 -0
  8. package/assets/images/menu/dhr/MHRM29N0001.svg +30 -0
  9. package/assets/images/menu/dhr/MHRM29N0015.svg +63 -0
  10. package/assets/images/menu/dhr/MHRM39N0012.svg +43 -0
  11. package/assets/images/menu/dhr/MHRM39N0013.svg +24 -0
  12. package/assets/images/menu/dhr/MHRM39N0014.svg +14 -0
  13. package/assets/images/menu/dhr/MHRM39N0015.svg +36 -0
  14. package/assets/images/menu/dhr/MHRM39N0016.svg +23 -0
  15. package/assets/images/menu/dhr/MHRM77N0001.svg +28 -0
  16. package/assets/images/menu/dhr/MHRM84N0001.svg +27 -0
  17. package/assets/images/menu/dhr/MHRM84N0002.svg +24 -0
  18. package/assets/images/menu/dhr/MHRM89N0001.svg +16 -0
  19. package/assets/images/menu/dhr/MHRP00N0001.svg +10 -0
  20. package/assets/images/menu/dhr/MHRP09N0001.svg +22 -0
  21. package/assets/images/menu/dhr/MHRP09N0002.svg +19 -0
  22. package/assets/images/menu/dhr/MHRP09N0003.svg +12 -0
  23. package/assets/images/menu/dhr/MHRP09N0004.svg +6 -0
  24. package/assets/images/menu/dhr/MHRP09N0005.svg +10 -0
  25. package/assets/images/menu/dhr/MHRP09N0006.svg +17 -0
  26. package/assets/images/menu/dhr/MHRP09N0007.svg +15 -0
  27. package/assets/images/menu/dhr/MHRP09N0008.svg +8 -0
  28. package/assets/images/menu/dhr/MHRP09N0009.svg +10 -0
  29. package/assets/images/menu/dhr/MHRP09N0010.svg +12 -0
  30. package/assets/images/menu/dhr/MHRP09N0011.svg +16 -0
  31. package/assets/images/menu/dhr/MHRP09N0012.svg +6 -0
  32. package/assets/images/menu/dhr/MHRP09N0013.svg +8 -0
  33. package/assets/images/menu/dhr/MHRP09N0014.svg +11 -0
  34. package/assets/images/menu/dhr/MHRP09N0015.svg +12 -0
  35. package/assets/images/menu/dhr/MHRP09N0016.svg +18 -0
  36. package/assets/images/menu/dhr/MHRP09N0017.svg +18 -0
  37. package/assets/images/menu/dhr/MHRP09N0018.svg +12 -0
  38. package/assets/images/menu/dhr/MHRP09N0019.svg +13 -0
  39. package/assets/images/menu/dhr/MHRP09N0020.svg +17 -0
  40. package/assets/images/menu/dhr/MHRP09N0021.svg +10 -0
  41. package/assets/images/menu/dhr/MHRP09N0022.svg +16 -0
  42. package/assets/images/menu/dhr/MHRP09N0023.svg +8 -0
  43. package/assets/images/menu/dhr/MHRP09N0024.svg +15 -0
  44. package/assets/images/menu/dhr/MHRP09N0025.svg +16 -0
  45. package/assets/images/menu/dhr/MHRP09N0026.svg +13 -0
  46. package/assets/images/menu/dhr/MHRP09N0027.svg +10 -0
  47. package/assets/images/menu/dhr/MHRP13N0001.svg +9 -0
  48. package/assets/images/menu/dhr/MHRP21N0001.svg +12 -0
  49. package/assets/images/menu/dhr/MHRP21N0002.svg +13 -0
  50. package/assets/images/menu/dhr/MHRP25N0001.svg +13 -0
  51. package/assets/images/menu/dhr/MHRP25N0002.svg +16 -0
  52. package/assets/images/menu/dhr/MHRP25N0003.svg +38 -0
  53. package/assets/images/menu/dhr/MHRP25N0004.svg +17 -0
  54. package/assets/images/menu/dhr/MHRP25N0005.svg +20 -0
  55. package/assets/images/menu/dhr/MHRP29N0001.svg +18 -0
  56. package/assets/images/menu/dhr/MHRP29N0002.svg +15 -0
  57. package/assets/images/menu/dhr/MHRP29N0003.svg +20 -0
  58. package/assets/images/menu/dhr/MHRP29N0004.svg +21 -0
  59. package/assets/images/menu/dhr/MHRP29N0005.svg +21 -0
  60. package/assets/images/menu/dhr/MHRP29N0006.svg +14 -0
  61. package/assets/images/menu/dhr/MHRP29N0007.svg +19 -0
  62. package/assets/images/menu/dhr/MHRP29N0008.svg +20 -0
  63. package/assets/images/menu/dhr/MHRP29N0009.svg +11 -0
  64. package/assets/images/menu/dhr/MHRP29N0010.svg +11 -0
  65. package/assets/images/menu/dhr/MHRP29N0011.svg +12 -0
  66. package/assets/images/menu/dhr/MHRP29N0013.svg +27 -0
  67. package/assets/images/menu/dhr/MHRP29N0014.svg +32 -0
  68. package/assets/images/menu/dhr/MHRP29N0016.svg +54 -0
  69. package/assets/images/menu/dhr/MHRP29N0017.svg +24 -0
  70. package/assets/images/menu/dhr/MHRP29N0018.svg +44 -0
  71. package/assets/images/menu/dhr/MHRP29N0019.svg +17 -0
  72. package/assets/images/menu/dhr/MHRP29N0020.svg +11 -0
  73. package/assets/images/menu/dhr/MHRP38N0001.svg +13 -0
  74. package/assets/images/menu/dhr/MHRP38N0002.svg +14 -0
  75. package/assets/images/menu/dhr/MHRP39N0001.svg +15 -0
  76. package/assets/images/menu/dhr/MHRP39N0002.svg +13 -0
  77. package/assets/images/menu/dhr/MHRP39N0003.svg +16 -0
  78. package/assets/images/menu/dhr/MHRP39N0004.svg +22 -0
  79. package/assets/images/menu/dhr/MHRP39N0005.svg +16 -0
  80. package/assets/images/menu/dhr/MHRP39N0006.svg +17 -0
  81. package/assets/images/menu/dhr/MHRP39N0007.svg +13 -0
  82. package/assets/images/menu/dhr/MHRP39N0008.svg +3 -0
  83. package/assets/images/menu/dhr/MHRP39N0009.svg +3 -0
  84. package/assets/images/menu/dhr/MHRP39N0010.svg +7 -0
  85. package/assets/images/menu/dhr/MHRP39N0011.svg +14 -0
  86. package/assets/images/menu/dhr/MHRP39N0013.svg +10 -0
  87. package/assets/images/menu/dhr/MHRP39N0014.svg +11 -0
  88. package/assets/images/menu/dhr/MHRP39N1222.svg +12 -0
  89. package/assets/images/menu/dhr/MHRP51N0001.svg +9 -0
  90. package/assets/images/menu/dhr/MHRP51N0002.svg +13 -0
  91. package/assets/images/menu/dhr/MHRP52N0001.svg +21 -0
  92. package/assets/images/menu/dhr/MHRP52N0002.svg +21 -0
  93. package/assets/images/menu/dhr/MHRP52N0003.svg +16 -0
  94. package/assets/images/menu/dhr/MHRP75N0001.svg +19 -0
  95. package/assets/images/menu/dhr/MHRP75N0002.svg +25 -0
  96. package/assets/images/menu/dhr/MHRP75N0003.svg +3 -0
  97. package/assets/images/menu/dhr/MHRP75N0006.svg +14 -0
  98. package/assets/images/menu/dhr/MHRP75N0007.svg +19 -0
  99. package/assets/images/menu/dhr/MHRP75N0008.svg +19 -0
  100. package/assets/images/menu/dhr/MHRP77N0007.svg +28 -0
  101. package/assets/images/menu/dhr/MHRP77N0008.svg +17 -0
  102. package/assets/images/menu/dhr/MHRP77N0009.svg +19 -0
  103. package/assets/images/menu/dhr/MHRP77N0010.svg +20 -0
  104. package/assets/images/menu/dhr/MHRP89N1000.svg +6 -0
  105. package/assets/images/menu/dhr/MHRP89N1001.svg +6 -0
  106. package/assets/images/menu/dhr/W00F0001.svg +3 -0
  107. package/assets/images/menu/dhr/W00F0002.svg +3 -0
  108. package/assets/images/menu/dhr/W00F0003.svg +3 -0
  109. package/assets/images/menu/dhr/W00F0004.svg +3 -0
  110. package/assets/images/menu/dhr/W00F0005.svg +1 -0
  111. package/assets/images/menu/dhr/W09F2000-WEB5.svg +17 -0
  112. package/assets/images/menu/dhr/W09F2000.svg +6 -0
  113. package/assets/images/menu/dhr/W09F2002-WEB5.svg +21 -0
  114. package/assets/images/menu/dhr/W09F2005-WEB5.svg +13 -0
  115. package/assets/images/menu/dhr/W09F2020-WEB5.svg +16 -0
  116. package/assets/images/menu/dhr/W09F2022-WEB5.svg +20 -0
  117. package/assets/images/menu/dhr/W09F2150-WEB5.svg +16 -0
  118. package/assets/images/menu/dhr/W09F2152-WEB5.svg +20 -0
  119. package/assets/images/menu/dhr/W09F2160-WEB5.svg +14 -0
  120. package/assets/images/menu/dhr/W09F2162-WEB5.svg +18 -0
  121. package/assets/images/menu/dhr/W29F4006-WEB5.svg +19 -0
  122. package/assets/images/menu/dhr/W75F2260-WEB5.svg +15 -0
  123. package/assets/images/menu/dhr/W75F2261-WEB5.svg +19 -0
  124. package/assets/images/menu/dhr/W75F3005-WEB5.svg +13 -0
  125. package/assets/images/menu/dhr/W75F4070-WEB5.svg +21 -0
  126. package/assets/images/menu/dhr/W75F4071-WEB5.svg +17 -0
  127. package/assets/images/menu/dhr/W75F4100-WEB5.svg +14 -0
  128. package/assets/images/menu/dhr/W77F1011.svg +19 -0
  129. package/assets/images/menu/dhr/W77F1013.svg +22 -0
  130. package/assets/images/menu/erp/W00F0001.svg +3 -0
  131. package/assets/images/menu/erp/W00F0002.svg +3 -0
  132. package/assets/images/menu/erp/W00F0003.svg +3 -0
  133. package/assets/images/menu/erp/W00F0004.svg +3 -0
  134. package/assets/images/menu/erp/W05F0001.svg +16 -0
  135. package/assets/images/menu/erp/W05F0001N0000.svg +16 -0
  136. package/assets/images/menu/erp/W05F0004N0000.svg +6 -0
  137. package/assets/images/menu/erp/W05F0006.svg +30 -0
  138. package/assets/images/menu/erp/W05F0007N0000.svg +6 -0
  139. package/assets/images/menu/erp/W05F0008.svg +14 -0
  140. package/assets/images/menu/erp/W05F4000.svg +9 -0
  141. package/assets/images/menu/erp/W06F0001.svg +17 -0
  142. package/assets/images/menu/erp/W06F0001N0000.svg +17 -0
  143. package/assets/images/menu/erp/W06F0004N0000.svg +22 -0
  144. package/assets/images/menu/erp/W06F0005.svg +22 -0
  145. package/assets/images/menu/erp/W06F0006.svg +55 -0
  146. package/assets/images/menu/erp/W06F0008.svg +17 -0
  147. package/assets/images/menu/erp/WA3F1025.svg +5 -0
  148. package/assets/images/menu/erp/WA3F2100.svg +10 -0
  149. package/components/accordion/context.js +6 -0
  150. package/components/accordion/css.js +159 -0
  151. package/components/accordion/details.js +60 -0
  152. package/components/accordion/group.js +122 -0
  153. package/components/accordion/index.js +117 -0
  154. package/components/accordion/summary.js +175 -0
  155. package/components/alert/index.js +264 -0
  156. package/components/alert/notify.js +192 -0
  157. package/components/avatar/index.js +556 -0
  158. package/components/badge/index.js +223 -0
  159. package/components/button/icon.js +493 -0
  160. package/components/button/index.js +653 -0
  161. package/components/button/more.js +135 -0
  162. package/components/button/ripple-effect.js +85 -0
  163. package/components/card/body-card.js +67 -0
  164. package/components/card/card.js +127 -0
  165. package/components/card/context.js +6 -0
  166. package/components/card/index.js +50 -0
  167. package/components/chart/Pie/Circle.js +50 -0
  168. package/components/chart/Pie/Sector.js +142 -0
  169. package/components/chart/Pie/Sectors.js +91 -0
  170. package/components/chart/Pie/index.js +311 -0
  171. package/components/chart/Pie-v2/Circle.js +50 -0
  172. package/components/chart/Pie-v2/Sector.js +128 -0
  173. package/components/chart/Pie-v2/Sectors.js +224 -0
  174. package/components/chart/Pie-v2/index.js +397 -0
  175. package/components/chart/bar/Axis.js +79 -0
  176. package/components/chart/bar/Bar.js +365 -0
  177. package/components/chart/bar/Grid.js +115 -0
  178. package/components/chart/bar/Labels.js +175 -0
  179. package/components/chart/bar/Points.js +111 -0
  180. package/components/chart/bar/index.js +172 -0
  181. package/components/chart/bar-v2/Axis.js +79 -0
  182. package/components/chart/bar-v2/Bar.js +374 -0
  183. package/components/chart/bar-v2/Grid.js +115 -0
  184. package/components/chart/bar-v2/Labels.js +175 -0
  185. package/components/chart/bar-v2/Points.js +111 -0
  186. package/components/chart/bar-v2/index.js +172 -0
  187. package/components/chart/line/Axis.js +79 -0
  188. package/components/chart/line/Grid.js +115 -0
  189. package/components/chart/line/Labels.js +172 -0
  190. package/components/chart/line/Path.js +163 -0
  191. package/components/chart/line/Point.js +348 -0
  192. package/components/chart/line/Title.js +56 -0
  193. package/components/chart/line/index.js +174 -0
  194. package/components/chart/line-v2/Axis.js +79 -0
  195. package/components/chart/line-v2/Grid.js +115 -0
  196. package/components/chart/line-v2/Labels.js +172 -0
  197. package/components/chart/line-v2/Path.js +163 -0
  198. package/components/chart/line-v2/Point.js +354 -0
  199. package/components/chart/line-v2/Title.js +56 -0
  200. package/components/chart/line-v2/index.js +174 -0
  201. package/components/check-text/index.js +157 -0
  202. package/components/check-text/interview-confirmation.js +172 -0
  203. package/components/check-text/interview-status.js +138 -0
  204. package/components/chip/attach.js +180 -0
  205. package/components/chip/index.js +340 -0
  206. package/components/collapse/index.js +67 -0
  207. package/components/dialogs/colors.js +11 -0
  208. package/components/divider/index.js +71 -0
  209. package/components/divider/style.js +12 -0
  210. package/components/form-control/attachment/index.js +1890 -0
  211. package/components/form-control/calendar/function.js +673 -0
  212. package/components/form-control/calendar/index.js +248 -0
  213. package/components/form-control/calendar/range.js +293 -0
  214. package/components/form-control/checkbox/index.js +306 -0
  215. package/components/form-control/control/index.js +92 -0
  216. package/components/form-control/date-picker/index-old.js +953 -0
  217. package/components/form-control/date-picker/index.js +676 -0
  218. package/components/form-control/date-range-picker/index.js +1305 -0
  219. package/components/form-control/dropdown/index.js +1865 -0
  220. package/components/form-control/dropdown-box/index.js +292 -0
  221. package/components/form-control/form/context.js +5 -0
  222. package/components/form-control/form/index.js +41 -0
  223. package/components/form-control/form-group/index.js +118 -0
  224. package/components/form-control/helper-text/index.js +71 -0
  225. package/components/form-control/input-base/index.js +733 -0
  226. package/components/form-control/label/index.js +73 -0
  227. package/components/form-control/money-input/index.js +491 -0
  228. package/components/form-control/number-input/index.js +633 -0
  229. package/components/form-control/phone-input/index.js +433 -0
  230. package/components/form-control/radio/index.js +263 -0
  231. package/components/form-control/text-input/index.js +523 -0
  232. package/components/form-control/time-picker/index.js +829 -0
  233. package/components/form-control/time-picker/swiper.js +590 -0
  234. package/components/form-control/toggle/index.js +250 -0
  235. package/components/form-view/helper-text.js +33 -0
  236. package/components/form-view/index.js +107 -0
  237. package/components/form-view/input.js +129 -0
  238. package/components/form-view/label.js +38 -0
  239. package/components/index.js +100 -0
  240. package/components/list/list-item-action.js +82 -0
  241. package/components/list/list-item-icon.js +76 -0
  242. package/components/list/list-item-text.js +57 -0
  243. package/components/list/list-item.js +114 -0
  244. package/components/list/list.js +155 -0
  245. package/components/list/sub-header.js +61 -0
  246. package/components/modal/body.js +71 -0
  247. package/components/modal/context.js +6 -0
  248. package/components/modal/footer.js +63 -0
  249. package/components/modal/header.js +108 -0
  250. package/components/modal/index.js +69 -0
  251. package/components/modal/modal.js +339 -0
  252. package/components/others/extra/index.js +124 -0
  253. package/components/others/scrollbar/index.js +95 -0
  254. package/components/paging/page-info.js +298 -0
  255. package/components/paging/page-selector.js +281 -0
  256. package/components/paper/index.js +119 -0
  257. package/components/popover/index.js +417 -0
  258. package/components/popup/danger_popup.js +215 -0
  259. package/components/popup/index.js +469 -0
  260. package/components/popup/proposals_popup.js +364 -0
  261. package/components/popup/v2/danger-popup.js +17 -0
  262. package/components/popup/v2/index.js +460 -0
  263. package/components/popup/v2/info-popup.js +17 -0
  264. package/components/popup/v2/success-popup.js +17 -0
  265. package/components/popup/v2/warning-popup.js +17 -0
  266. package/components/popup/v2/yes-no-popup.js +20 -0
  267. package/components/progress/circular.js +414 -0
  268. package/components/progress/linear.js +327 -0
  269. package/components/rating/index.js +392 -0
  270. package/components/slider/slider-container.js +356 -0
  271. package/components/slider/slider-item.js +183 -0
  272. package/components/status/index.js +123 -0
  273. package/components/tab/context.js +3 -0
  274. package/components/tab/tab-container.js +83 -0
  275. package/components/tab/tab-header.js +133 -0
  276. package/components/tab/tab-panel.js +51 -0
  277. package/components/tab/tab.js +206 -0
  278. package/components/tooltip/index.js +602 -0
  279. package/components/tooltip/portal.js +13 -0
  280. package/components/transfer/index.js +489 -0
  281. package/components/tree-view/css.js +94 -0
  282. package/components/tree-view/index.js +1009 -0
  283. package/components/typography/index.js +218 -0
  284. package/css/styles.css +1 -0
  285. package/css/styles.css.map +1 -0
  286. package/global/index.js +175 -0
  287. package/icons/basic.js +6326 -0
  288. package/icons/effect.js +171 -0
  289. package/icons/general/clock/clock.js +21 -0
  290. package/icons/general/color-handler/background.js +41 -0
  291. package/icons/general/color-handler/text.js +41 -0
  292. package/icons/general/emoji/emoji.js +35 -0
  293. package/icons/general/font-properties/bold.js +21 -0
  294. package/icons/general/font-properties/font-family.js +35 -0
  295. package/icons/general/font-properties/font-size.js +27 -0
  296. package/icons/general/font-properties/italic.js +21 -0
  297. package/icons/general/font-properties/underline.js +31 -0
  298. package/icons/general/hyperlink/hyperlink.js +38 -0
  299. package/icons/general/indent/decrease.js +55 -0
  300. package/icons/general/indent/increase.js +55 -0
  301. package/icons/general/index.js +21 -0
  302. package/icons/general/list/bullets.js +77 -0
  303. package/icons/general/list/numbering.js +71 -0
  304. package/icons/general/picture/picture.js +21 -0
  305. package/icons/general/steps/redo.js +21 -0
  306. package/icons/general/steps/undo.js +21 -0
  307. package/icons/general/text-align/center.js +21 -0
  308. package/icons/general/text-align/justify.js +21 -0
  309. package/icons/general/text-align/left.js +21 -0
  310. package/icons/general/text-align/right.js +21 -0
  311. package/icons/index.js +3 -0
  312. package/icons/menu/dhr.js +2440 -0
  313. package/icons/menu/erp.js +490 -0
  314. package/icons/menu/index.js +5 -0
  315. package/icons/menu/v2/index.js +52 -0
  316. package/locale/index.js +11 -0
  317. package/package.json +45 -0
  318. package/readme.md +517 -0
  319. package/styles/animation.js +890 -0
  320. package/styles/color-helper.js +504 -0
  321. package/styles/colors.js +306 -0
  322. package/styles/general.js +48 -0
  323. package/styles/media-queries.js +10 -0
  324. package/styles/typography.js +122 -0
  325. package/styles/utils.js +10 -0
  326. package/theme/index.js +5 -0
  327. package/theme/make-styles.js +95 -0
  328. package/theme/set-theme.js +39 -0
  329. package/theme/settings.js +230 -0
  330. package/theme/theme-provider.js +68 -0
  331. package/theme/theme.js +56 -0
  332. package/theme/with-styles.js +17 -0
  333. package/theme/with-theme.js +11 -0
  334. package/utils/array/array.js +186 -0
  335. package/utils/console.js +34 -0
  336. package/utils/date.js +471 -0
  337. package/utils/error/error.js +62 -0
  338. package/utils/error/errors.js +247 -0
  339. package/utils/getFileType.js +32 -0
  340. package/utils/index.js +23 -0
  341. package/utils/iterator.js +45 -0
  342. package/utils/map-parent.js +53 -0
  343. package/utils/number.js +64 -0
  344. package/utils/object/extend.js +57 -0
  345. package/utils/object/object.js +68 -0
  346. package/utils/parseHTML.js +8 -0
  347. package/utils/promisify.js +38 -0
  348. package/utils/randomString.js +33 -0
  349. package/utils/remove-unicode.js +6 -0
  350. package/utils/render-portal.js +90 -0
  351. package/utils/renderHTML.js +21 -0
  352. package/utils/renderIcon.js +57 -0
  353. package/utils/string/capitalize.js +3 -0
  354. package/utils/string/capitalizeSentenceCase.js +10 -0
  355. package/utils/string/string.js +81 -0
  356. package/utils/type.js +90 -0
  357. package/utils/updatePosition.js +36 -0
  358. package/utils/useOnClickOutside.js +23 -0
  359. package/utils/usePortal.js +56 -0
  360. package/utils/validate.js +149 -0
@@ -0,0 +1,556 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ /** @jsxRuntime classic */
4
+
5
+ /** @jsx jsx */
6
+ import { Fragment, memo, useRef, forwardRef, useState, useEffect, useMemo } from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { jsx, css } from '@emotion/core';
9
+ import Icon, { Account } from '../../icons';
10
+ import { ModalSample, Popover, Popup, Typography } from '../';
11
+ import { randomString } from '../../utils';
12
+ import { getGlobal } from '../../global';
13
+ const existed = {},
14
+ urlAvatar = {},
15
+ popupHandler = {};
16
+
17
+ const getDirection = direction => {
18
+ switch (direction) {
19
+ case 'top':
20
+ return {
21
+ anchorOrigin: {
22
+ vertical: 'top',
23
+ horizontal: 'center'
24
+ },
25
+ transformOrigin: {
26
+ vertical: 'bottom',
27
+ horizontal: 'center'
28
+ }
29
+ };
30
+
31
+ case 'left':
32
+ return {
33
+ anchorOrigin: {
34
+ vertical: 'center',
35
+ horizontal: 'left'
36
+ },
37
+ transformOrigin: {
38
+ vertical: 'center',
39
+ horizontal: 'right'
40
+ }
41
+ };
42
+
43
+ case 'right':
44
+ return {
45
+ anchorOrigin: {
46
+ vertical: 'center',
47
+ horizontal: 'right'
48
+ },
49
+ transformOrigin: {
50
+ vertical: 'center',
51
+ horizontal: 'left'
52
+ }
53
+ };
54
+
55
+ default:
56
+ return {
57
+ anchorOrigin: {
58
+ vertical: 'bottom',
59
+ horizontal: 'center'
60
+ },
61
+ transformOrigin: {
62
+ vertical: 'top',
63
+ horizontal: 'center'
64
+ }
65
+ };
66
+ }
67
+ };
68
+
69
+ const isMobile = {
70
+ iOS: function () {
71
+ return navigator.userAgent.match(/iPhone|iPad|iPod/i);
72
+ },
73
+ Android: function () {
74
+ return navigator.userAgent.match(/Android/i);
75
+ },
76
+ BlackBerry: function () {
77
+ return navigator.userAgent.match(/BlackBerry/i);
78
+ },
79
+ Opera: function () {
80
+ return navigator.userAgent.match(/Opera Mini/i);
81
+ },
82
+ Windows: function () {
83
+ return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
84
+ },
85
+ any: function () {
86
+ return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows();
87
+ }
88
+ };
89
+ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
90
+ refs,
91
+ src,
92
+ defaultSrc,
93
+ outlined,
94
+ width,
95
+ height,
96
+ maxSize,
97
+ matchType,
98
+ className,
99
+ maxSizeError,
100
+ wrongTypeError,
101
+ actionIconWidth,
102
+ actionIconHeight,
103
+ direction,
104
+ data,
105
+ onRemove,
106
+ onChange,
107
+ clearAble,
108
+ hoverAble,
109
+ readOnly,
110
+ disabled,
111
+ ...props
112
+ }, ref) => {
113
+ if (!ref) {
114
+ ref = useRef(null);
115
+ }
116
+
117
+ const inputRef = useRef(null);
118
+ const avatarRef = useRef(null);
119
+ const [unique] = useState(randomString(6, {
120
+ allowNumber: false,
121
+ allowSymbol: false
122
+ }));
123
+ const [viewAvatar, setViewAvatar] = useState(false);
124
+ const [viewMoreInfo, setViewMoreInfo] = useState(false);
125
+
126
+ if (width && !height) {
127
+ height = width;
128
+ }
129
+
130
+ if (!width && height) {
131
+ width = height;
132
+ }
133
+
134
+ const iconDefault = `<svg width="${width}" height="${height}" viewBox="0 0 20 20" fill="none">
135
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M10 0C4.47998 0 0 4.48 0 10C0 15.52 4.47998 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34003 9 7 7.66 7 6C7 4.34 8.34003 3 10 3ZM4 13.98C5.28998 15.92 7.5 17.2 10 17.2C12.5 17.2 14.71 15.92 16 13.98C15.97 11.99 11.99 10.9 10 10.9C8 10.9 4.03003 11.99 4 13.98Z" fill="#7F828E"/>
136
+ </svg>`;
137
+ const ActionIcon = css`
138
+ position: absolute;
139
+ right: -36px;
140
+ transition: opacity 0.5s;
141
+ opacity: 0;
142
+ .icon-delete {
143
+ display: none;
144
+ }
145
+ `;
146
+ const AvatarPreview = css`
147
+ display: block;
148
+ position: relative;
149
+ width: 100%;
150
+ height: 100%;
151
+ border-radius: 50%;
152
+ overflow: hidden;
153
+ cursor: ${readOnly ? 'initial' : 'pointer'};
154
+ `;
155
+ const AvatarContainer = css`
156
+ display: inline-flex;
157
+ position: relative;
158
+ align-items: center;
159
+ &.disabled {
160
+ .css-${AvatarPreview.name} {
161
+ pointer-events: none;
162
+ cursor: inherit;
163
+ }
164
+ .css-${ActionIcon.name} {
165
+ display: none !important;
166
+ }
167
+ }
168
+ &:hover {
169
+ .css-${ActionIcon.name} {
170
+ opacity: 1;
171
+ }
172
+ }
173
+ `;
174
+ const AvatarRoot = css`
175
+ display: block;
176
+ position: relative;
177
+ border-radius: 50%;
178
+ width: ${isNaN(width) ? width : width + 'px'};
179
+ height: ${isNaN(height) ? height : height + 'px'};
180
+ overflow: hidden;
181
+ box-sizing: content-box;
182
+ user-select: none;
183
+ border: none;
184
+ input {
185
+ display: none;
186
+ }
187
+ img {
188
+ background-image: url(${require('../../assets/avatar/default.svg')});
189
+ background-size: cover;
190
+ width: 100%;
191
+ height: 100%;
192
+ }
193
+ `;
194
+ const MoreInfo = css`
195
+ display: block;
196
+ position: relative;
197
+ padding: 8px;
198
+ `;
199
+
200
+ const triggerInput = e => {
201
+ if (!e || !existed[unique]) {
202
+ ref.current.querySelector('input').click();
203
+ } else {
204
+ // on View
205
+ setViewAvatar(true);
206
+ }
207
+ };
208
+
209
+ const checkFileType = type => {
210
+ if (typeof matchType === 'object' && matchType instanceof RegExp) {
211
+ return matchType.test(type);
212
+ } else if (typeof matchType === 'object' && Array.isArray(matchType)) {
213
+ const pattern = new RegExp('^image\/(' + matchType.join('|') + ')', 'i');
214
+ return pattern.test(type);
215
+ } else {
216
+ return new RegExp(matchType).test(type);
217
+ }
218
+ };
219
+
220
+ const onChangeAvatar = input => {
221
+ const [file] = input.target.files;
222
+ if (!file) return;
223
+ const reader = new FileReader();
224
+
225
+ if (!checkFileType(file.type)) {
226
+ input.target.value = '';
227
+ popupHandler[unique].show(wrongTypeError);
228
+ return;
229
+ }
230
+
231
+ if (+maxSize && file.size > maxSize * 1024 ** 2) {
232
+ input.target.value = '';
233
+ popupHandler[unique].show(maxSizeError);
234
+ return;
235
+ }
236
+
237
+ reader.onload = e => {
238
+ const img = document.createElement('img');
239
+ urlAvatar[unique] = e.target.result;
240
+ img.src = urlAvatar[unique];
241
+ img.alt = '';
242
+ img.style.cssText = 'object-fit: cover';
243
+ ref.current.querySelector(`.css-${AvatarPreview.name}`).innerHTML = '';
244
+ ref.current.querySelector(`.css-${AvatarPreview.name}`).appendChild(img);
245
+
246
+ if (!readOnly && clearAble) {
247
+ ref.current.querySelector(`.icon-delete`).style.display = 'flex';
248
+ }
249
+
250
+ existed[unique] = true;
251
+ };
252
+
253
+ reader.readAsDataURL(file);
254
+ !!onChange && onChange(input);
255
+ };
256
+
257
+ const onRemoveAvatar = () => {
258
+ if (defaultSrc) {
259
+ ref.current.querySelector('img').src = defaultSrc;
260
+ } else {
261
+ ref.current.querySelector(`.css-${AvatarPreview.name}`).innerHTML = iconDefault;
262
+ }
263
+
264
+ existed[unique] = false;
265
+ inputRef.current.value = '';
266
+
267
+ if (!readOnly && clearAble) {
268
+ ref.current.querySelector(`.icon-delete`).style.display = null;
269
+ }
270
+
271
+ !!onRemove && onRemove();
272
+ };
273
+
274
+ const renderData = () => {
275
+ const info = Object.keys(data);
276
+
277
+ if (info.length) {
278
+ return info.map((key, index) => {
279
+ return jsx(Typography, {
280
+ key: index,
281
+ color: 'white',
282
+ type: 'p1'
283
+ }, key + ': ' + data[key]);
284
+ });
285
+ }
286
+
287
+ return jsx(Typography, {
288
+ color: 'white',
289
+ type: 'p1'
290
+ }, "Kh\xF4ng c\xF3 d\u1EEF li\u1EC7u");
291
+ };
292
+
293
+ const showMoreInfo = () => {
294
+ if (hoverAble) setViewMoreInfo(true);
295
+ };
296
+
297
+ const closeMoreInfo = () => {
298
+ if (hoverAble) setViewMoreInfo(false);
299
+ };
300
+
301
+ useEffect(() => {
302
+ if (refs) refs(ref);
303
+ }, []);
304
+ useEffect(() => {
305
+ if (outlined) {
306
+ ref.current.querySelector(`.css-${AvatarRoot.name}`).style.border = typeof outlined === 'boolean' ? '1px solid #FFF' : outlined;
307
+ return () => {
308
+ if (ref.current) {
309
+ ref.current.querySelector(`.css-${AvatarRoot.name}`).style.border = null;
310
+ }
311
+ };
312
+ }
313
+ }, [outlined]);
314
+ useEffect(() => {
315
+ if (!readOnly && clearAble && src) {
316
+ ref.current.querySelector(`.icon-delete`).style.display = 'flex';
317
+ }
318
+ }, [clearAble]); // useEffect(() => {
319
+ // if (hoverAble) {
320
+ // avatarRef.current.addEventListener('mouseenter', showMoreInfo);
321
+ // avatarRef.current.addEventListener('mouseleave', closeMoreInfo);
322
+ // }
323
+ // return () => {
324
+ // if (hoverAble && avatarRef.current) {
325
+ // avatarRef.current.removeEventListener('mouseenter', showMoreInfo);
326
+ // avatarRef.current.removeEventListener('mouseleave', closeMoreInfo);
327
+ // }
328
+ // };
329
+ // }, [hoverAble])
330
+
331
+ useEffect(() => {
332
+ if (src) {
333
+ existed[unique] = true;
334
+ inputRef.current.value = '';
335
+ const img = document.createElement('img');
336
+ urlAvatar[unique] = src;
337
+ img.src = src;
338
+ img.alt = '';
339
+
340
+ img.onerror = e => {
341
+ if (defaultSrc) {
342
+ e.target.src = defaultSrc;
343
+ } else {
344
+ ref.current.querySelector(`.css-${AvatarPreview.name}`).innerHTML = iconDefault;
345
+ }
346
+ };
347
+
348
+ img.style.cssText = 'object-fit: cover';
349
+ ref.current.querySelector(`.css-${AvatarPreview.name}`).innerHTML = '';
350
+ ref.current.querySelector(`.css-${AvatarPreview.name}`).appendChild(img);
351
+
352
+ if (!readOnly && clearAble) {
353
+ ref.current.querySelector(`.icon-delete`).style.display = 'flex';
354
+ }
355
+
356
+ return () => {
357
+ existed[unique] = false;
358
+
359
+ if (ref.current) {
360
+ if (defaultSrc) {
361
+ ref.current.querySelector('img').src = defaultSrc;
362
+ } else {
363
+ ref.current.querySelector(`.css-${AvatarPreview.name}`).innerHTML = iconDefault;
364
+ }
365
+
366
+ if (!readOnly && clearAble && ref.current.querySelector(`.icon-delete`)) {
367
+ ref.current.querySelector(`.icon-delete`).style.display = null;
368
+ }
369
+ }
370
+ };
371
+ }
372
+ }, [src]);
373
+ useEffect(() => {
374
+ if (disabled) {
375
+ ref.current.classList.add('disabled');
376
+ return () => {
377
+ if (ref.current) {
378
+ ref.current.classList.remove('disabled');
379
+ }
380
+ };
381
+ }
382
+ }, [disabled]);
383
+ const AvatarView = useMemo(() => jsx("div", {
384
+ css: AvatarContainer,
385
+ ref: ref,
386
+ id: unique
387
+ }, jsx("div", _extends({
388
+ css: AvatarRoot,
389
+ className: ['DGN-UI-Avatar', className].join(' ').trim()
390
+ }, props), jsx("input", {
391
+ ref: inputRef,
392
+ type: "file",
393
+ title: '',
394
+ accept: 'image/*',
395
+ onChange: onChangeAvatar
396
+ }), jsx("div", {
397
+ css: AvatarPreview,
398
+ onClick: readOnly ? isMobile.any() ? showMoreInfo : null : triggerInput,
399
+ ref: avatarRef,
400
+ onMouseEnter: isMobile.any() ? null : showMoreInfo,
401
+ onMouseLeave: isMobile.any() ? null : closeMoreInfo,
402
+ tabIndex: "-1",
403
+ onBlur: closeMoreInfo
404
+ }, defaultSrc ? jsx("img", {
405
+ src: defaultSrc,
406
+ alt: defaultSrc,
407
+ style: {
408
+ objectFit: 'cover'
409
+ }
410
+ }) : jsx(Account, {
411
+ width: width,
412
+ height: height,
413
+ viewBox: true
414
+ }))), !readOnly && !disabled && jsx("span", {
415
+ css: ActionIcon
416
+ }, jsx(Icon, {
417
+ name: 'Edit',
418
+ width: actionIconWidth,
419
+ height: actionIconHeight,
420
+ className: 'icon-edit',
421
+ onClick: () => triggerInput()
422
+ }), clearAble && jsx(Icon, {
423
+ name: 'Delete',
424
+ width: actionIconWidth,
425
+ height: actionIconHeight,
426
+ className: 'icon-delete',
427
+ onClick: onRemoveAvatar,
428
+ style: {
429
+ marginTop: '8px'
430
+ }
431
+ }))), [width, height, readOnly, disabled, clearAble, maxSize, matchType, hoverAble]);
432
+ const ModalView = useMemo(() => jsx(ModalSample, {
433
+ open: viewAvatar,
434
+ onClose: () => setViewAvatar(false),
435
+ width: 'max-content'
436
+ }, jsx("img", {
437
+ src: urlAvatar[unique],
438
+ alt: "",
439
+ style: {
440
+ objectFit: 'cover',
441
+ maxHeight: '100%',
442
+ maxWidth: '100%',
443
+ margin: 'auto',
444
+ display: 'block'
445
+ }
446
+ })), [viewAvatar]);
447
+ const MoreInfoView = useMemo(() => jsx(Popover, _extends({
448
+ open: viewMoreInfo,
449
+ pressESCToClose: false,
450
+ bgColor: '#000',
451
+ anchor: avatarRef,
452
+ fullScreen: false,
453
+ width: 'max-content'
454
+ }, getDirection(direction)), jsx("div", {
455
+ css: MoreInfo
456
+ }, typeof data === 'function' ? data() : renderData())), [viewMoreInfo, direction, data]);
457
+ const PopupView = useMemo(() => jsx(Popup, {
458
+ getPopup: func => popupHandler[unique] = func,
459
+ type: 'info',
460
+ title: maxSizeError,
461
+ icon: 'danger',
462
+ fullScreen: true
463
+ }), []);
464
+ return jsx(Fragment, null, AvatarView, ModalView, hoverAble && MoreInfoView, !disabled && !readOnly && PopupView);
465
+ }));
466
+ Avatar.defaultProps = {
467
+ disabled: false,
468
+ readOnly: false,
469
+ clearAble: true,
470
+ hoverAble: false,
471
+ outlined: false,
472
+ width: 48,
473
+ height: 48,
474
+ actionIconWidth: 18,
475
+ actionIconHeight: 18,
476
+ className: '',
477
+ direction: 'down',
478
+ maxSizeError: `File ${getGlobal(['errorDefault', 'maxSize'])}`,
479
+ wrongTypeError: `File ${getGlobal(['errorDefault', 'fileType'])}`,
480
+ matchType: /^image\/(gif|jpe?g|tiff?|png|webp|bmp|svg(\+xml)?)$/i,
481
+ data: {}
482
+ };
483
+ Avatar.propTypes = {
484
+ /** prevent all events, only view */
485
+ disabled: PropTypes.bool,
486
+
487
+ /** only view and allow show more info if hoverAble is true */
488
+ readOnly: PropTypes.bool,
489
+
490
+ /** display remove avatar icon if true */
491
+ clearAble: PropTypes.bool,
492
+
493
+ /** show more info in popover if true */
494
+ hoverAble: PropTypes.bool,
495
+
496
+ /** border of avatar (true or '1px solid #color') */
497
+ outlined: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
498
+
499
+ /** The width of avatar box (48 or '48px' or ...) */
500
+ width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
501
+
502
+ /** The height of avatar box (48 or '48px' or ...) */
503
+ height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
504
+
505
+ /** The width of action icon (18 or '18px') */
506
+ actionIconWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
507
+
508
+ /** The height of action icon (18 or '18px') */
509
+ actionIconHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
510
+
511
+ /** maximum size for avatar file (unit: MB) */
512
+ maxSize: PropTypes.number,
513
+
514
+ /** type of image was allowed */
515
+ matchType: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func, PropTypes.array]),
516
+
517
+ /** class for Avatar component */
518
+ className: PropTypes.string,
519
+
520
+ /** the error to show on exceeded allowed size */
521
+ maxSizeError: PropTypes.string,
522
+
523
+ /** the error to show on wrong type */
524
+ wrongTypeError: PropTypes.string,
525
+
526
+ /** source of file (http:// or https://) */
527
+ src: PropTypes.string,
528
+
529
+ /**
530
+ * it is used to display the default if there is no src<br />
531
+ * if undefined, will display icons available in the icons store
532
+ */
533
+ defaultSrc: PropTypes.string,
534
+
535
+ /** the direction to display more info */
536
+ direction: PropTypes.oneOf(['top', 'down', 'left', 'right']),
537
+
538
+ /**
539
+ * data to display when hoverAble is true<br />
540
+ * data is an object or function return a jsx element
541
+ */
542
+ data: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
543
+
544
+ /** refs is a function to get ref of avatar component */
545
+ refs: PropTypes.func,
546
+
547
+ /** will run after remove avatar */
548
+ onRemove: PropTypes.func,
549
+
550
+ /** will run after change avatar */
551
+ onChange: PropTypes.func,
552
+
553
+ /** any props else */
554
+ props: PropTypes.any
555
+ };
556
+ export default Avatar;