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,602 @@
1
+ /** @jsxRuntime classic */
2
+
3
+ /** @jsx jsx */
4
+ import PropTypes from 'prop-types';
5
+ import { forwardRef, memo, useEffect, useRef, useState } from 'react';
6
+ import Portal from './portal';
7
+ import { randomString } from '../../utils';
8
+ import theme from '../../theme/settings';
9
+ import { jsx, css } from '@emotion/core';
10
+ const defaultColor = 'rgba(255, 255, 255, 0.9)';
11
+ const defaultBg = 'rgba(21, 26, 48, 0.9)';
12
+ const defaultViewPadding = 4;
13
+
14
+ const getScrollTop = () => {
15
+ return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
16
+ };
17
+
18
+ const getScrollLeft = () => {
19
+ return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
20
+ };
21
+
22
+ const getArrowSpacing = (arrow, arrowSize, distance) => {
23
+ const defaultArrowSpacing = arrow ? arrowSize : 0;
24
+ return typeof distance === 'number' ? distance : defaultArrowSpacing;
25
+ };
26
+
27
+ const parseAlignMode = alignMode => {
28
+ if (alignMode.split('-').length > 1) {
29
+ return alignMode.split('-')[1];
30
+ }
31
+
32
+ return 'middle';
33
+ }; // const getScrollParent = (element) => {
34
+ // const style = getComputedStyle(element);
35
+ // let scrollParent = window;
36
+ // if (style.position !== 'fixed') {
37
+ // let parent = element.parentElement;
38
+ // while (parent) {
39
+ // const parentStyle = getComputedStyle(parent);
40
+ // if (/(auto|scroll)/.test(parentStyle.overflow + parentStyle.overflowY + parentStyle.overflowX)) {
41
+ // scrollParent = parent;
42
+ // parent = undefined;
43
+ // } else {
44
+ // parent = parent.parentElement;
45
+ // }
46
+ // }
47
+ // }
48
+ // return scrollParent;
49
+ // };
50
+
51
+
52
+ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((props, ref) => {
53
+ const {
54
+ alignMode,
55
+ arrow,
56
+ arrowSize,
57
+ backgroundColor,
58
+ children,
59
+ color,
60
+ direction,
61
+ distance,
62
+ size,
63
+ forceDirection,
64
+ hoverDelay,
65
+ onToggle,
66
+ padding,
67
+ style,
68
+ tagCreatedName: TagCreatedName,
69
+ textAlign,
70
+ title,
71
+ tooltipMaxWidth,
72
+ viewportPadding,
73
+ ...other
74
+ } = props;
75
+ const Id = randomString(length = 6, {
76
+ allowSymbol: false
77
+ }),
78
+ IDs = {
79
+ arrow: 'DCUI-tooltip-arrow-' + Id,
80
+ container: 'DCUI-tooltip-container-' + Id,
81
+ main: 'DCUI-tooltip-main-' + Id
82
+ },
83
+ arrowRef = useRef(null),
84
+ containerRef = useRef(null),
85
+ tooltipRef = useRef(null),
86
+ containerProps = { ...other,
87
+ ref: ref || containerRef,
88
+ className: IDs.container,
89
+ style: {
90
+ boxSizing: 'border-box',
91
+ height: 'max-content',
92
+ position: 'relative',
93
+ width: 'max-content',
94
+ ...style
95
+ }
96
+ },
97
+ hiddenPositions = {
98
+ tooltip: {
99
+ left: '-10000000px',
100
+ opacity: 0
101
+ },
102
+ arrow: {
103
+ border: 'none',
104
+ left: '-10000000px',
105
+ opacity: 0,
106
+ top: '-10000000px'
107
+ }
108
+ },
109
+ [existed, setExisted] = useState(false);
110
+ let calculateTimeout, hoverTimeout, tooltip;
111
+ const styles = {
112
+ arrow: css`
113
+ height : 0;
114
+ opacity : 0;
115
+ position : absolute;
116
+ transition : opacity 0.1s ease-in-out;
117
+ user-select: none;
118
+ width : 0;
119
+ z-index : 9005;
120
+ `,
121
+ main: css`
122
+ background-color: ${backgroundColor};
123
+ border-radius : 3px;
124
+ box-sizing : border-box;
125
+ color : ${color};
126
+ display : inline-block;
127
+ font-family : ${theme.typography.fontFamily};
128
+ font-size : ${size === 'small' ? 12 : 14}px;
129
+ opacity : 0;
130
+ padding : ${padding};
131
+ position : absolute;
132
+ text-align : ${textAlign};
133
+ transition : opacity 0.1s ease-in-out;
134
+ user-select : none;
135
+ word-wrap : break-word;
136
+ z-index : 9004;
137
+ `
138
+ };
139
+
140
+ const checkHorizontal = (distance, el, parent) => {
141
+ const {
142
+ left,
143
+ right
144
+ } = parent.getBoundingClientRect();
145
+ const clientW = document.documentElement.clientWidth;
146
+ const deadSpace = Math.min(left, clientW - right);
147
+ return el.offsetWidth + parent.offsetWidth + distance + viewportPadding + deadSpace < clientW;
148
+ };
149
+
150
+ const checkParent = (el, parent) => {
151
+ const {
152
+ bottom,
153
+ top
154
+ } = parent.getBoundingClientRect();
155
+ const bottomOverhang = bottom > window.innerHeight;
156
+ const topOverhang = top < 0;
157
+
158
+ if (topOverhang && bottomOverhang) {
159
+ return true;
160
+ }
161
+
162
+ if (parent.offsetHeight > el.offsetHeight) {
163
+ const halfTargetHeight = parent.offsetHeight / 2;
164
+ const arrowFree = arrowSize + 6;
165
+ const bOAmount = bottom - window.innerHeight;
166
+ const tOAmount = -top;
167
+ const centerToBottom = halfTargetHeight - bOAmount;
168
+ const centerToTop = halfTargetHeight - tOAmount;
169
+ return centerToBottom >= arrowFree && centerToTop >= arrowFree;
170
+ }
171
+
172
+ return !bottomOverhang && !topOverhang;
173
+ };
174
+
175
+ const checkArrowOverhang = arrowStyles => {
176
+ const scrollLeft = getScrollLeft();
177
+ const enoughLeft = arrowStyles.position.left - scrollLeft > viewportPadding;
178
+ const enoughRight = arrowStyles.position.left + arrowSize * 2 < scrollLeft + document.documentElement.clientWidth - viewportPadding;
179
+ return !enoughLeft || !enoughRight;
180
+ };
181
+
182
+ const getTooltipMaxWidth = () => {
183
+ return tooltipMaxWidth ? tooltipMaxWidth : typeof document !== 'undefined' ? document.documentElement.clientWidth - viewportPadding * 2 : 300;
184
+ };
185
+
186
+ const getArrowStyles = (direction, el, parent) => {
187
+ if (!parent || !arrow) {
188
+ return {
189
+ position: {
190
+ top: 0,
191
+ left: -10000000
192
+ }
193
+ };
194
+ }
195
+
196
+ const parentRect = parent.getBoundingClientRect();
197
+ const halfParentH = parent.offsetHeight / 2;
198
+ const halfParentW = parent.offsetWidth / 2;
199
+ const scrollTop = getScrollTop();
200
+ const scrollLeft = getScrollLeft();
201
+ const arrowSpacing = getArrowSpacing(arrow, arrowSize, distance);
202
+ const border = {};
203
+ const position = {};
204
+
205
+ switch (direction) {
206
+ case 'right':
207
+ border.borderLeft = `${arrowSize}px solid transparent`;
208
+ border.borderTop = `${arrowSize}px solid transparent`;
209
+ border.borderBottom = `${arrowSize}px solid transparent`;
210
+ border.borderRight = `${arrowSize}px solid ${backgroundColor}`;
211
+ position.top = el ? parentRect.top + scrollTop + halfParentH - arrowSize - 1 : '-10000000px';
212
+ position.left = parentRect.right + scrollLeft - arrowSize + 1;
213
+ break;
214
+
215
+ case 'left':
216
+ border.borderRight = `${arrowSize}px solid transparent`;
217
+ border.borderTop = `${arrowSize}px solid transparent`;
218
+ border.borderBottom = `${arrowSize}px solid transparent`;
219
+ border.borderLeft = `${arrowSize}px solid ${backgroundColor}`;
220
+ position.top = el ? parentRect.top + scrollTop + halfParentH - arrowSize - 1 : '-10000000px';
221
+ position.left = parentRect.left + scrollLeft - arrowSpacing - 1;
222
+ break;
223
+
224
+ case 'up':
225
+ border.borderBottom = `${arrowSize}px solid transparent`;
226
+ border.borderLeft = `${arrowSize}px solid transparent`;
227
+ border.borderRight = `${arrowSize}px solid transparent`;
228
+ border.borderTop = `${arrowSize}px solid ${backgroundColor}`;
229
+ position.left = el ? parentRect.left + scrollLeft + halfParentW - arrowSize : '-10000000px';
230
+ position.top = parentRect.top + scrollTop - arrowSpacing;
231
+ break;
232
+
233
+ case 'down':
234
+ default:
235
+ border.borderUp = `${arrowSize}px solid transparent`;
236
+ border.borderLeft = `${arrowSize}px solid transparent`;
237
+ border.borderRight = `${arrowSize}px solid transparent`;
238
+ border.borderBottom = `${arrowSize}px solid ${backgroundColor}`;
239
+ position.left = el ? parentRect.left + scrollLeft + halfParentW - arrowSize : '-10000000px';
240
+ position.top = parentRect.bottom + scrollTop + arrowSpacing + 1 - arrowSize;
241
+ break;
242
+ }
243
+
244
+ return {
245
+ border,
246
+ position
247
+ };
248
+ };
249
+
250
+ const getDirection = (arrowStyles, currentDirection, el, parent, recursive) => {
251
+ if (!parent) {
252
+ return currentDirection;
253
+ }
254
+
255
+ const clientW = document.documentElement.clientWidth;
256
+ const parentRect = parent.getBoundingClientRect();
257
+ const arrowSpacing = getArrowSpacing(arrow, arrowSize, distance);
258
+ const wrapperHight = el.offsetHeight + arrowSpacing + viewportPadding;
259
+ const spaceBelow = window.innerHeight - parentRect.bottom;
260
+ const spaceAbove = parentRect.top;
261
+ const enoughBelow = spaceBelow >= wrapperHight;
262
+ const enoughAbove = spaceAbove >= wrapperHight;
263
+
264
+ switch (currentDirection) {
265
+ case 'right':
266
+ if (!checkHorizontal(arrowSpacing, el, parent) || !checkParent(el, parent)) {
267
+ return getDirection(arrowStyles, 'down', el, parent, true);
268
+ }
269
+
270
+ if (clientW - parentRect.right < el.offsetWidth + arrowSpacing + viewportPadding) {
271
+ return 'left';
272
+ }
273
+
274
+ return 'right';
275
+
276
+ case 'left':
277
+ if (!checkHorizontal(arrowSpacing, el, parent) || !checkParent(el, parent)) {
278
+ return getDirection(arrowStyles, 'down', el, parent, true);
279
+ }
280
+
281
+ if (parentRect.left < el.offsetWidth + arrowSpacing + viewportPadding) {
282
+ return 'right';
283
+ }
284
+
285
+ return 'left';
286
+
287
+ case 'up':
288
+ if (!recursive && arrowStyles && checkArrowOverhang(arrowStyles)) {
289
+ return getDirection(arrowStyles, 'left', el, parent, true);
290
+ }
291
+
292
+ if (!enoughAbove) {
293
+ if (enoughBelow) {
294
+ return 'down';
295
+ }
296
+
297
+ if (!recursive && arrowStyles && checkHorizontal(arrowSpacing, el, parent)) {
298
+ return getDirection(arrowStyles, 'right', el, parent, true);
299
+ }
300
+ }
301
+
302
+ return 'up';
303
+
304
+ case 'down':
305
+ default:
306
+ if (!recursive && arrowStyles && checkArrowOverhang(arrowStyles)) {
307
+ return getDirection(arrowStyles, 'right', el, parent, true);
308
+ }
309
+
310
+ if (!enoughBelow) {
311
+ if (enoughAbove) {
312
+ return 'up';
313
+ }
314
+
315
+ if (!recursive && arrowStyles && checkHorizontal(arrowSpacing, el, parent)) {
316
+ return getDirection(arrowStyles, 'right', el, parent, true);
317
+ }
318
+ }
319
+
320
+ return 'down';
321
+ }
322
+ };
323
+
324
+ const getVertical = (alignMode, direction, el, parent) => {
325
+ let left = -10000000,
326
+ top;
327
+ const arrowSpacing = getArrowSpacing(arrow, arrowSize, distance);
328
+
329
+ if (el) {
330
+ const scrollLeft = getScrollLeft();
331
+ const parentRect = parent.getBoundingClientRect();
332
+ const parentLeft = parentRect.left + scrollLeft;
333
+ const halfParentW = parent.offsetWidth / 2;
334
+ const tooltipW = Math.min(getTooltipMaxWidth(), el && el.offsetWidth);
335
+ const arrowCenter = parentLeft + halfParentW;
336
+ const arrowLeft = arrowCenter - arrowSize;
337
+ const arrowRight = arrowCenter + arrowSize;
338
+
339
+ if (alignMode === 'start') {
340
+ left = arrow ? Math.min(arrowLeft, parentLeft) : parentLeft;
341
+ } else if (alignMode === 'end') {
342
+ const rightWithArrow = Math.max(arrowRight, parentLeft + parent.offsetWidth);
343
+ const rightEdge = arrow ? rightWithArrow : parentLeft + parent.offsetWidth;
344
+ left = Math.max(rightEdge - tooltipW, scrollLeft + viewportPadding);
345
+ } else {
346
+ const centeredLeft = parentLeft + halfParentW - tooltipW / 2;
347
+ const availableLeft = scrollLeft + viewportPadding;
348
+ left = Math.max(centeredLeft, availableLeft);
349
+ }
350
+
351
+ const rightTooltip = left + tooltipW;
352
+ const rightScreen = document.documentElement.clientWidth + scrollLeft - viewportPadding;
353
+ const rightOverhang = rightTooltip - rightScreen;
354
+
355
+ if (rightOverhang > 0) {
356
+ left -= rightOverhang;
357
+ }
358
+
359
+ if (direction === 'up') {
360
+ top = parentRect.top + getScrollTop() - (el.offsetHeight + arrowSpacing);
361
+ } else {
362
+ top = parentRect.bottom + getScrollTop() + arrowSpacing;
363
+ }
364
+ }
365
+
366
+ return {
367
+ left: left + 'px',
368
+ top: top + 'px'
369
+ };
370
+ };
371
+
372
+ const getHorizontal = (alignMode, direction, el, parent) => {
373
+ let left = -10000000,
374
+ top = 0;
375
+ const arrowSpacing = getArrowSpacing(arrow, arrowSize, distance);
376
+ const arrowPadding = arrow ? 6 : 0;
377
+
378
+ if (el) {
379
+ const scrollLeft = getScrollLeft();
380
+ const scrollTop = getScrollTop();
381
+ const parentRect = parent.getBoundingClientRect();
382
+ const parentTop = parentRect.top + scrollTop;
383
+ const halfParentH = parent.offsetHeight / 2;
384
+ const arrowTop = parentTop + halfParentH - arrowSize;
385
+ const arrowBottom = parentRect.top + scrollTop + halfParentH + arrowSize;
386
+
387
+ if (alignMode === 'start') {
388
+ top = arrow ? Math.min(parentTop, arrowTop) : parentTop;
389
+ } else if (alignMode === 'end') {
390
+ const topForBottomAlign = parentRect.bottom + scrollTop - el.offsetHeight;
391
+ top = arrow ? Math.max(topForBottomAlign, arrowBottom - el.offsetHeight) : topForBottomAlign;
392
+ } else {
393
+ const centeredTop = Math.max(parentTop + halfParentH - el.offsetHeight / 2, scrollTop + viewportPadding);
394
+ top = Math.min(centeredTop, arrowTop - arrowPadding);
395
+ }
396
+
397
+ const bottomOverhang = top - scrollTop + el.offsetHeight + viewportPadding - window.innerHeight;
398
+
399
+ if (bottomOverhang > 0) {
400
+ top = Math.max(top - bottomOverhang, arrowBottom + arrowPadding - el.offsetHeight);
401
+ }
402
+
403
+ if (direction === 'right') {
404
+ left = parentRect.right + arrowSpacing + scrollLeft;
405
+ } else {
406
+ left = parentRect.left - arrowSpacing - el.offsetWidth + scrollLeft;
407
+ }
408
+ }
409
+
410
+ return {
411
+ left: left + 'px',
412
+ top: top + 'px'
413
+ };
414
+ };
415
+
416
+ const getPosition = (el, parent) => {
417
+ const align = parseAlignMode(alignMode);
418
+ let trueDirection = direction;
419
+ const maxWidth = getTooltipMaxWidth() + 'px';
420
+ let tooltipPosition, width;
421
+
422
+ if (!forceDirection && el) {
423
+ const arrowStylesForGetDirection = arrow && getArrowStyles(direction, el, parent);
424
+ trueDirection = getDirection(arrowStylesForGetDirection, trueDirection, el, parent, false);
425
+ }
426
+
427
+ if (el) {
428
+ const space = el.style.width ? 0 : 5;
429
+ width = Math.min(el.offsetWidth, maxWidth) + space + 'px';
430
+ tooltipPosition = trueDirection === 'up' || trueDirection === 'down' ? getVertical(align, trueDirection, el, parent) : getHorizontal(align, trueDirection, el, parent);
431
+ }
432
+
433
+ return {
434
+ tooltip: { ...tooltipPosition,
435
+ maxWidth,
436
+ width
437
+ },
438
+ arrow: getArrowStyles(trueDirection, el, parent)
439
+ };
440
+ };
441
+
442
+ const onSettingTooltip = (arrow, parent) => {
443
+ if (!existed) {
444
+ setExisted(true);
445
+ onShowTooltip(arrow, parent);
446
+ } else {
447
+ onShowTooltip(arrow, parent);
448
+ }
449
+
450
+ ;
451
+ };
452
+
453
+ const onShowTooltip = (arrow, parent) => {
454
+ if (!tooltipRef.current || !arrowRef.current) return;
455
+ const arrowEl = arrowRef.current,
456
+ el = tooltipRef.current;
457
+ let positions;
458
+ clearTimeout(calculateTimeout);
459
+ calculateTimeout = setTimeout(() => {
460
+ positions = getPosition(el, parent);
461
+ }, 10);
462
+ clearTimeout(hoverTimeout);
463
+ hoverTimeout = setTimeout(() => {
464
+ Object.assign(el.style, positions.tooltip, {
465
+ opacity: 1
466
+ });
467
+
468
+ if (arrow) {
469
+ Object.assign(arrowEl.style, positions.arrow.border, {
470
+ opacity: 1
471
+ });
472
+ arrowEl.style.left = positions.arrow.position.left + 'px';
473
+ arrowEl.style.top = positions.arrow.position.top + 'px';
474
+ } else {
475
+ Object.assign(arrowEl.style, hiddenPositions.arrow);
476
+ }
477
+ }, hoverDelay);
478
+ };
479
+
480
+ const onHideTooltip = () => {
481
+ if (!tooltipRef.current || !arrowRef.current) return;
482
+ const arrowEl = arrowRef.current,
483
+ el = tooltipRef.current;
484
+ clearTimeout(hoverTimeout);
485
+ hoverTimeout = setTimeout(() => {
486
+ Object.assign(el.style, hiddenPositions.tooltip);
487
+ Object.assign(arrowEl.style, hiddenPositions.arrow);
488
+ }, hoverDelay);
489
+ }; // const handleEvent = (arrow, parent) => {
490
+ // onHideTooltip();
491
+ // onShowTooltip(arrow, parent);
492
+ // };
493
+
494
+
495
+ tooltip = existed && title ? jsx(Portal, {
496
+ id: 'DGN-UI-Portal'
497
+ }, jsx("span", {
498
+ className: IDs.arrow,
499
+ css: styles.arrow,
500
+ ref: arrowRef,
501
+ style: { ...hiddenPositions.arrow
502
+ }
503
+ }), jsx("span", {
504
+ className: IDs.main,
505
+ css: styles.main,
506
+ ref: tooltipRef,
507
+ style: { ...hiddenPositions.tooltip
508
+ }
509
+ }, title)) : null;
510
+ useEffect(() => {
511
+ const parent = containerProps.ref.current; // const scrollableParent = getScrollParent(parent);
512
+
513
+ parent.addEventListener('mouseenter', () => onSettingTooltip(arrow, parent)); // parent.addEventListener('touchstart', () => onSettingTooltip(arrow, parent), { passive: true });
514
+
515
+ parent.addEventListener('mouseleave', () => onHideTooltip()); // parent.addEventListener('touchend', () => onHideTooltip(), { passive: true });
516
+ // window.addEventListener('resize', handleEvent(arrow, parent));
517
+ // scrollableParent.addEventListener('scroll', handleEvent(arrow, parent));
518
+
519
+ return () => {
520
+ parent.removeEventListener('mouseenter', () => onSettingTooltip(arrow, parent)); // parent.removeEventListener('touchstart', () => onSettingTooltip(arrow, parent), { passive: true });
521
+
522
+ parent.removeEventListener('mouseleave', () => onHideTooltip()); // parent.removeEventListener('touchend', () => onHideTooltip(), { passive: true });
523
+ // window.removeEventListener('resize', handleEvent(arrow, parent));
524
+ // scrollableParent.removeEventListener('scroll', handleEvent(arrow, parent));
525
+
526
+ clearTimeout(calculateTimeout);
527
+ clearTimeout(hoverTimeout);
528
+ };
529
+ }, []);
530
+ return jsx(TagCreatedName, containerProps, children, tooltip);
531
+ }));
532
+ Tooltip.defaultProps = {
533
+ alignMode: 'middle',
534
+ arrow: false,
535
+ arrowSize: 6,
536
+ backgroundColor: defaultBg,
537
+ color: defaultColor,
538
+ direction: 'down',
539
+ size: 'medium',
540
+ forceDirection: false,
541
+ hoverDelay: 50,
542
+ padding: '4px 6px',
543
+ tagCreatedName: 'div',
544
+ textAlign: 'center',
545
+ viewportPadding: defaultViewPadding
546
+ };
547
+ Tooltip.propTypes = {
548
+ /** alignMode use to set align-items of the tooltip*/
549
+ alignMode: PropTypes.oneOf(['flex-end', 'flex-start', 'middle']),
550
+
551
+ /** arrow use to turn on or off the arrow */
552
+ arrow: PropTypes.bool,
553
+
554
+ /** arrowSize use to set size for the arrow*/
555
+ arrowSize: PropTypes.number,
556
+
557
+ /** backgroundColor is a string, it's background color of the tooltip */
558
+ backgroundColor: PropTypes.string,
559
+
560
+ /** children is a node, you want to contain */
561
+ children: PropTypes.node.isRequired,
562
+
563
+ /** color is a string, it's color of the title */
564
+ color: PropTypes.string,
565
+
566
+ /** initialize direction of the tooltip */
567
+ direction: PropTypes.oneOf(['down', 'left', 'right', 'up']),
568
+
569
+ /** distance between the tooltip and the children */
570
+ distance: PropTypes.number,
571
+
572
+ /** size of the title */
573
+ size: PropTypes.oneOf(['small', 'medium']),
574
+
575
+ /** forceDirection use to set the static direction of the tooltip */
576
+ forceDirection: PropTypes.bool,
577
+
578
+ /** hoverDelay (ms) use to set the delay of the tooltip is should be more than 50ms, because the tooltip need a small time to calculate the position */
579
+ hoverDelay: PropTypes.number,
580
+
581
+ /** padding is string like CSS, use to set the padding of the title */
582
+ padding: PropTypes.string,
583
+
584
+ /** style is a object like style-inline, use to set the style for the element will be created to contain the children */
585
+ style: PropTypes.object,
586
+
587
+ /** tagName of the element will be created to contain the children */
588
+ tagCreatedName: PropTypes.oneOf(['div', 'span']),
589
+
590
+ /** textAlign use to set text-align of the title*/
591
+ textAlign: PropTypes.oneOf(['center', 'justify', 'left', 'right']),
592
+
593
+ /** The title to show in tooltip when hover */
594
+ title: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).isRequired,
595
+
596
+ /** tooltipMaxWidth is a number to set the max-width of the tooltip */
597
+ tooltipMaxWidth: PropTypes.number,
598
+
599
+ /** viewportPadding is a number to set the padding of the viewport with the tooltip */
600
+ viewportPadding: PropTypes.number
601
+ };
602
+ export default Tooltip;