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,676 @@
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 { css, jsx } from '@emotion/core';
7
+ import PropTypes from 'prop-types';
8
+ import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
9
+ import { render } from 'react-dom';
10
+ import { getGlobal } from '../../../global';
11
+ import { date as moment, capitalizeSentenceCase, randomString, updatePosition } from '../../../utils';
12
+ import CalendarComp from '../calendar';
13
+ import ControlComp from '../control';
14
+ import theme from '../../../theme/settings';
15
+ import Icon from '../../../icons/';
16
+ import { HelperText, InputBase, Label } from '../../index';
17
+ import Button from '../../button';
18
+ import Tooltip from '../../tooltip';
19
+ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
20
+ actionIconAt,
21
+ clearAble,
22
+ controls,
23
+ defaultValue,
24
+ disabled,
25
+ displayAnotherMonth,
26
+ displayFormat,
27
+ error,
28
+ errorProps,
29
+ inputProps,
30
+ inputStyle,
31
+ label,
32
+ labelProps,
33
+ max,
34
+ min,
35
+ onChange,
36
+ placeholder,
37
+ pressESCToClose,
38
+ readOnly,
39
+ required,
40
+ returnFormat,
41
+ style,
42
+ textAlign,
43
+ value,
44
+ viewType,
45
+ ...props
46
+ }, reference) => {
47
+ var _ipRef$current, _ipRef$current2;
48
+
49
+ const [id] = useState(randomString(6, {
50
+ allowSymbol: false
51
+ }));
52
+ const unique = {
53
+ disabled: 'DGN-UI-DatePicker-disabled',
54
+ error: 'DGN-UI-DatePicker-error',
55
+ focus: 'DGN-UI-DatePicker-focus',
56
+ footer: 'DGN-UI-DatePicker-Footer',
57
+ cancel: 'DGN-UI-DatePicker-cancel',
58
+ confirm: 'DGN-UI-DatePicker-confirm',
59
+ backGr: 'DGN-UI-DatePicker-Background',
60
+ icon: 'DGN-UI-DatePicker-Icon',
61
+ picker: `DGN-UI-DatePicker-Picker-${id}`,
62
+ portal: 'DGN-UI-Portal'
63
+ };
64
+ const calRef = useRef(null);
65
+ const footerRef = useRef(null);
66
+ const iconRef = useRef(null);
67
+ const ipConRef = useRef(null);
68
+ const ipRef = useRef(null);
69
+ const ref = useRef(null);
70
+ const displayValue = useRef();
71
+ const focusedValue = useRef(null);
72
+ const [, setDisplayValue] = useState(Date.now());
73
+ const [, setFocusedValue] = useState(Date.now()); // const [actionsState, setActionsState] = useState(true);
74
+
75
+ useImperativeHandle(reference, () => ({
76
+ get: () => {
77
+ return ref.current;
78
+ },
79
+ getInputContainer: () => {
80
+ return ipConRef.current;
81
+ },
82
+ getInput: () => {
83
+ return ipRef.current;
84
+ },
85
+ getCalendar: () => {
86
+ return calRef.current;
87
+ },
88
+ getIcon: () => {
89
+ return iconRef.current;
90
+ }
91
+ }));
92
+ const confirmText = getGlobal(['confirm']);
93
+ const cancelText = getGlobal(['cancel']);
94
+ const iconAreaCSS = css`
95
+ align-items : center;
96
+ color : inherit;
97
+ display : flex;
98
+ width : 24px;
99
+ & span {
100
+ padding: 0;
101
+ }
102
+ .${unique.icon} {
103
+ cursor : pointer;
104
+ opacity : 0;
105
+ transition : visibility 50ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 50ms;
106
+ visibility : hidden;
107
+ will-change: visibility, opacity;
108
+ }
109
+ .${unique.icon}-cancel {
110
+ transform : translateX(-100%);
111
+ }
112
+ .${unique.icon}-accept {
113
+ opacity : 1;
114
+ visibility: visible;
115
+ }
116
+ `;
117
+ const hiddenStyle = {
118
+ opacity: 0,
119
+ visibility: 'hidden'
120
+ };
121
+ const activeStyle = {
122
+ opacity: 1,
123
+ pointerEvents: 'none',
124
+ visibility: 'visible'
125
+ };
126
+ const pickerCSS = {
127
+ backGr: 'background-color: transparent; inset: 0px; pointer-events: auto; position: fixed; z-index: 9001;',
128
+ picker: (position, left, width) => css`
129
+ background-color: ${theme.colors.white};
130
+ border-radius : ${theme.border.radius};
131
+ height : max-content;
132
+ left : ${left}px;
133
+ max-width : 400px;
134
+ min-width : ${window.innerWidth <= 599 ? 280 : 314}px;
135
+ opacity : 0;
136
+ position : fixed;
137
+ top : ${position.top}px;
138
+ transform : scale(0);
139
+ transform-origin: ${position.transformOrigin};
140
+ transition : opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
141
+ width : ${width}px;
142
+ z-index : 9002;
143
+ `,
144
+ active: {
145
+ opacity: 1,
146
+ transform: 'scale(1)'
147
+ },
148
+ remove: {
149
+ opacity: 0,
150
+ pointerEvents: 'none',
151
+ transform: 'scale(0)'
152
+ }
153
+ };
154
+ const controlContainerCSS = css`
155
+ display : flex;
156
+ justify-content: flex-end;
157
+ margin : 0 16px 16px;
158
+ `;
159
+ const buttonProps = {
160
+ style: {
161
+ margin: '0 2px',
162
+ padding: '7px 8px'
163
+ }
164
+ };
165
+
166
+ const isValid = time => {
167
+ return !isNaN(Date.parse(typeof time !== 'date' ? new Date(time) : time));
168
+ };
169
+
170
+ const handleDisplayValue = useCallback(value => {
171
+ displayValue.current = new Date(value);
172
+ setDisplayValue();
173
+ }, [displayValue]);
174
+ const handleFocusedValue = useCallback(value => {
175
+ focusedValue.current = new Date(value);
176
+ setFocusedValue();
177
+ }, [focusedValue]);
178
+
179
+ const setButtonState = () => {
180
+ if (!footerRef.current || focusedValue.current === undefined || !isValid(focusedValue.current)) return;
181
+ const isEqual = focusedValue.current === null || Date.parse(new Date(focusedValue.current)) === Date.parse(new Date(displayValue.current));
182
+ footerRef.current.querySelector(`.${unique.cancel}`).disabled = isEqual;
183
+ footerRef.current.querySelector(`.${unique.confirm}`).disabled = isEqual;
184
+ };
185
+
186
+ const onConfirm = () => {
187
+ displayValue.current = focusedValue.current;
188
+ setButtonState();
189
+ onChangeValue({
190
+ value: focusedValue.current
191
+ });
192
+ closePicker();
193
+ };
194
+
195
+ const onCancel = () => {
196
+ focusedValue.current = null;
197
+ setButtonState();
198
+ closePicker();
199
+ };
200
+
201
+ const formatValue = (value, format, utc = false) => {
202
+ return moment(value).format(format, utc);
203
+ };
204
+
205
+ const setInputValue = e => {
206
+ ipRef.current.value = capitalizeSentenceCase(formatValue(e.value, displayFormat));
207
+ if (clearAble) onSwap(false);
208
+ };
209
+
210
+ const onChangeValue = e => {
211
+ setInputValue(e);
212
+ !!onChange && onChange({
213
+ value: formatValue(e.value, returnFormat)
214
+ });
215
+ };
216
+
217
+ const onCalendarClick = e => {
218
+ handleFocusedValue(e.value);
219
+ controls ? setButtonState() : onChangeValue(e);
220
+ };
221
+
222
+ const getPickerStyle = () => {
223
+ const {
224
+ innerHeight
225
+ } = window;
226
+ const {
227
+ left,
228
+ height,
229
+ top,
230
+ width
231
+ } = ipConRef.current.getBoundingClientRect();
232
+ const pickerHeight = controls ? 310 : 256;
233
+ let style = {};
234
+ style.top = top + height + 4;
235
+ style.transformOrigin = '50% 20%';
236
+
237
+ if (style.top + pickerHeight > innerHeight) {
238
+ if (top - pickerHeight > 0) {
239
+ style.top = top - pickerHeight - 4;
240
+ style.transformOrigin = '50% 80%';
241
+ }
242
+ }
243
+
244
+ return pickerCSS.picker(style, left, width).styles;
245
+ }; // const createPortal = () => {
246
+ // let portal = document.getElementById(unique.portal);
247
+ // if (!portal) {
248
+ // portal = document.createElement('div');
249
+ // portal.id = unique.portal;
250
+ // document.body.appendChild(portal);
251
+ // }
252
+ // portal.style.cssText = pickerCSS.portal;
253
+ // return portal;
254
+ // };
255
+
256
+
257
+ const createBackground = () => {
258
+ let background = document.getElementById(unique.backGr);
259
+
260
+ if (!background) {
261
+ background = document.createElement('div');
262
+ background.id = unique.backGr;
263
+ background.classList.add(unique.portal, unique.backGr);
264
+ document.body.appendChild(background);
265
+ }
266
+
267
+ background.style.cssText = pickerCSS.backGr;
268
+ return background;
269
+ };
270
+
271
+ const createPicker = () => {
272
+ const picker = document.createElement('div');
273
+ picker.id = unique.picker;
274
+ picker.style.cssText = getPickerStyle();
275
+ return picker;
276
+ };
277
+
278
+ const pressESCHandler = event => {
279
+ if (event.key === 'Escape') {
280
+ onClickOutside({
281
+ target: null
282
+ });
283
+ }
284
+
285
+ ;
286
+ };
287
+
288
+ const onScroll = () => {
289
+ const node = document.getElementById(unique.picker);
290
+
291
+ if (!ipConRef.current || !node) {
292
+ window.removeEventListener('scroll', onScroll);
293
+ return;
294
+ }
295
+
296
+ updatePosition(ipConRef.current, node, closePicker);
297
+ };
298
+
299
+ const onResize = () => {
300
+ if (!ref.current) return;
301
+ const {
302
+ width
303
+ } = ref.current.getBoundingClientRect();
304
+ const node = document.getElementById(unique.picker);
305
+
306
+ if (node) {
307
+ node.style.width = width + 'px';
308
+ }
309
+
310
+ onScroll();
311
+ };
312
+
313
+ const openPicker = () => {
314
+ const backGr = createBackground();
315
+ const picker = createPicker();
316
+ render(jsx(CalendarComp, {
317
+ ref: calRef,
318
+ actions: controls && footerMemo,
319
+ defaultValue: displayValue.current,
320
+ value: focusedValue.current,
321
+ max: max,
322
+ min: min,
323
+ displayAnotherMonth: displayAnotherMonth,
324
+ onClick: onCalendarClick
325
+ }), backGr.appendChild(picker));
326
+ setTimeout(() => {
327
+ Object.assign(picker.style, { ...pickerCSS.active
328
+ });
329
+ window.addEventListener('resize', onResize);
330
+ window.addEventListener('scroll', onScroll);
331
+ document.addEventListener('mousedown', onClickOutside);
332
+
333
+ if (pressESCToClose) {
334
+ document.addEventListener('keydown', pressESCHandler);
335
+ }
336
+
337
+ setButtonState();
338
+ });
339
+ };
340
+
341
+ const closePicker = () => {
342
+ const backGr = document.getElementById(unique.backGr);
343
+ if (!backGr) return;
344
+ const picker = backGr.querySelector(`#${unique.picker}`);
345
+ if (!picker) return;
346
+ Object.assign(picker.style, { ...pickerCSS.remove
347
+ });
348
+
349
+ if (pressESCToClose) {
350
+ document.removeEventListener('keydown', pressESCHandler);
351
+ }
352
+
353
+ document.removeEventListener('mousedown', onClickOutside);
354
+ window.removeEventListener('scroll', onScroll);
355
+ window.removeEventListener('resize', onResize);
356
+ setTimeout(() => {
357
+ backGr.remove();
358
+ }, 200);
359
+
360
+ if (ipConRef.current) {
361
+ ipConRef.current.classList.remove(unique.focus);
362
+ ipConRef.current.style.zIndex = null;
363
+ } // iconRef.current && onSwap(true);
364
+
365
+
366
+ ipRef.current && ipRef.current.blur();
367
+ }; // const updatePicker = () => {
368
+ // const portal = document.body.querySelector(`#${unique.portal}`);
369
+ // if (!portal) return;
370
+ // const backGr = portal.querySelector(`#${unique.backGr}`);
371
+ // if (!backGr) return;
372
+ // const node = portal.querySelector(`#${unique.picker}`);
373
+ // if (!node || !node.firstChild) return;
374
+ // unmountComponentAtNode(node);
375
+ // render(
376
+ // <CalendarComp
377
+ // ref={calRef}
378
+ // actions={footerMemo}
379
+ // defaultValue={displayValue.current}
380
+ // value={focusedValue.current}
381
+ // max={max}
382
+ // min={min}
383
+ // displayAnotherMonth={displayAnotherMonth}
384
+ // onClick={onCalendarClick}
385
+ // />, node);
386
+ // };
387
+
388
+
389
+ const onSwap = open => {
390
+ const t = iconRef.current.childNodes[+open];
391
+
392
+ if (open) {
393
+ Object.assign(t.style, { ...hiddenStyle
394
+ });
395
+ Object.assign(t.previousSibling.style, { ...activeStyle
396
+ });
397
+ setTimeout(() => {
398
+ t.previousSibling.style.pointerEvents = null;
399
+ }, 200);
400
+ } else {
401
+ Object.assign(t.style, { ...hiddenStyle
402
+ });
403
+ Object.assign(t.nextSibling.style, { ...activeStyle
404
+ });
405
+ setTimeout(() => {
406
+ t.nextSibling.style.pointerEvents = null;
407
+ }, 200);
408
+ }
409
+ };
410
+
411
+ const onInputFocus = () => {
412
+ const el = ipConRef.current;
413
+
414
+ if (!el.classList.contains(unique.focus)) {
415
+ el.classList.add(unique.focus);
416
+ el.style.zIndex = 9001;
417
+ openPicker();
418
+ }
419
+ };
420
+
421
+ const onClickOutside = e => {
422
+ if (ipConRef.current && !ipConRef.current.contains(e.target) && ipRef.current && !ipRef.current.contains(e.target) && calRef.current && !calRef.current.contains(e.target)) {
423
+ controls ? onCancel() : closePicker();
424
+ }
425
+ };
426
+
427
+ const triggerFocus = () => {
428
+ if (!ipConRef.current.classList.contains(unique.focus)) {
429
+ ipRef.current.focus();
430
+ } else {
431
+ onClickOutside({
432
+ target: null
433
+ });
434
+ }
435
+ };
436
+
437
+ const onClear = () => {
438
+ if (!clearAble && !ipRef.current) return;
439
+ ipRef.current.value = '';
440
+ focusedValue.current = null;
441
+ setButtonState();
442
+ const e = {
443
+ value: null
444
+ };
445
+ !!onChange && onChange(e);
446
+ onSwap(true);
447
+ };
448
+
449
+ const iconComp = jsx("div", {
450
+ css: iconAreaCSS,
451
+ ref: iconRef
452
+ }, jsx(Icon, {
453
+ onClick: triggerFocus,
454
+ className: `${unique.icon} ${unique.icon}-accept`,
455
+ viewBox: true,
456
+ name: 'CalendarNew'
457
+ }), jsx(Icon, {
458
+ onClick: onClear,
459
+ className: `${unique.icon} ${unique.icon}-cancel`,
460
+ viewBox: true,
461
+ name: 'Close'
462
+ }));
463
+ const endIcon = actionIconAt === 'end' && iconComp;
464
+ const startIcon = actionIconAt === 'start' && iconComp;
465
+ const footerMemo = jsx("div", {
466
+ css: controlContainerCSS,
467
+ className: unique.footer,
468
+ ref: footerRef
469
+ }, jsx(Button, _extends({}, buttonProps, {
470
+ className: unique.cancel,
471
+ onClick: onCancel
472
+ }), cancelText), jsx(Button, _extends({}, buttonProps, {
473
+ color: 'info',
474
+ className: unique.confirm,
475
+ onClick: onConfirm
476
+ }), confirmText));
477
+ const isError = !!error && (!value || !isValid(value));
478
+ useEffect(() => {
479
+ if (defaultValue && isValid(defaultValue)) {
480
+ handleDisplayValue(defaultValue);
481
+ setInputValue({
482
+ value: displayValue.current
483
+ });
484
+ }
485
+
486
+ return () => {
487
+ closePicker();
488
+ };
489
+ }, []);
490
+ useEffect(() => {
491
+ if (value && isValid(value)) {
492
+ handleFocusedValue(value);
493
+ handleDisplayValue(value);
494
+ setInputValue({
495
+ value: displayValue.current
496
+ });
497
+ setButtonState();
498
+ closePicker();
499
+ } else {
500
+ if (ipRef.current) ipRef.current.value = '';
501
+
502
+ if (clearAble) {
503
+ onSwap(true);
504
+ }
505
+
506
+ setButtonState();
507
+ closePicker();
508
+ }
509
+ }, [value]);
510
+ useEffect(() => {
511
+ if (!readOnly) {
512
+ ipRef.current.addEventListener('focus', onInputFocus);
513
+ }
514
+
515
+ return () => {
516
+ if (!ipRef.current) return;
517
+
518
+ if (!readOnly) {
519
+ ipRef.current.removeEventListener('focus', onInputFocus);
520
+ }
521
+ };
522
+ }, [onChange]);
523
+ useEffect(() => {
524
+ if (ipRef.current.value !== '') {
525
+ const e = {
526
+ value: focusedValue.current || displayValue.current
527
+ };
528
+ setInputValue(e, displayFormat);
529
+ }
530
+
531
+ if (disabled) {
532
+ iconRef.current.childNodes[0].style.pointerEvents = 'none';
533
+ closePicker();
534
+ } else if (!readOnly) {
535
+ ipRef.current.addEventListener('focus', onInputFocus);
536
+ } else {
537
+ iconRef.current.childNodes[0].style.pointerEvents = 'none';
538
+ closePicker();
539
+ }
540
+
541
+ return () => {
542
+ if (!iconRef.current || !ipRef.current) return;
543
+
544
+ if (disabled) {
545
+ iconRef.current.childNodes[0].style.pointerEvents = null;
546
+ } else if (!readOnly) {
547
+ ipRef.current.removeEventListener('focus', onInputFocus);
548
+ } else {
549
+ iconRef.current.childNodes[0].style.pointerEvents = null;
550
+ }
551
+
552
+ closePicker();
553
+ };
554
+ }, [actionIconAt, clearAble, controls, disabled, displayFormat, displayAnotherMonth, max, min, readOnly, returnFormat, viewType]);
555
+ return jsx(ControlComp, _extends({}, props, {
556
+ disabled: disabled,
557
+ error: isError,
558
+ ref: ref,
559
+ style: style
560
+ }), !!label && jsx(Label, _extends({}, labelProps, {
561
+ disabled: disabled,
562
+ required: required
563
+ }), label), jsx(Tooltip, {
564
+ title: (ipRef === null || ipRef === void 0 ? void 0 : (_ipRef$current = ipRef.current) === null || _ipRef$current === void 0 ? void 0 : _ipRef$current.clientWidth) < 200 ? ipRef === null || ipRef === void 0 ? void 0 : (_ipRef$current2 = ipRef.current) === null || _ipRef$current2 === void 0 ? void 0 : _ipRef$current2.value : '',
565
+ style: {
566
+ width: 'none'
567
+ }
568
+ }, jsx(InputBase, _extends({
569
+ placeholder: placeholder
570
+ }, inputProps, {
571
+ readOnly: true,
572
+ ref: ipConRef,
573
+ inputRef: ipRef,
574
+ disabled: disabled,
575
+ viewType: viewType,
576
+ inputStyle: {
577
+ textAlign: textAlign,
578
+ ...inputStyle
579
+ },
580
+ startIcon: startIcon,
581
+ startIconProps: {
582
+ className: 'non-effect allow-disabled'
583
+ },
584
+ endIcon: endIcon
585
+ }))), isError && jsx(HelperText, _extends({}, errorProps, {
586
+ disabled: disabled
587
+ }), error));
588
+ }));
589
+ DatePicker.defaultProps = {
590
+ actionIconAt: 'end',
591
+ clearAble: false,
592
+ controls: false,
593
+ disabled: false,
594
+ displayAnotherMonth: true,
595
+ displayFormat: 'dddd, DD MMMM YYYY',
596
+ pressESCToClose: true,
597
+ readOnly: false,
598
+ required: false,
599
+ textAlign: 'start',
600
+ returnFormat: 'YYYY-MM-DD',
601
+ viewType: 'underlined'
602
+ };
603
+ DatePicker.propTypes = {
604
+ /** action icons position */
605
+ actionIconAt: PropTypes.oneOf(['end', 'start']),
606
+
607
+ /** display the clear icon if true */
608
+ clearAble: PropTypes.bool,
609
+
610
+ /** if 'true' the calendar will have a footer controls */
611
+ controls: PropTypes.bool,
612
+
613
+ /** the default value of the component */
614
+ defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
615
+
616
+ /** if 'true' the form control will be disabled */
617
+ disabled: PropTypes.bool,
618
+
619
+ /** format to display value */
620
+ displayFormat: PropTypes.oneOfType([PropTypes.oneOf(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']), PropTypes.string]),
621
+
622
+ /** view days of previous or next month */
623
+ displayAnotherMonth: PropTypes.bool,
624
+
625
+ /** error of the form control */
626
+ error: PropTypes.string,
627
+
628
+ /** inputProps are properties of the input element */
629
+ inputProps: PropTypes.object,
630
+
631
+ /** inputStyle is style of input element */
632
+ inputStyle: PropTypes.object,
633
+
634
+ /** content of the label element */
635
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
636
+
637
+ /** labelProps are properties if the label element */
638
+ labelProps: PropTypes.object,
639
+
640
+ /** min value of date picker */
641
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
642
+
643
+ /** max value of date picker */
644
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
645
+
646
+ /** a callback function when value input change */
647
+ onChange: PropTypes.func,
648
+
649
+ /** hints for input */
650
+ placeholder: PropTypes.string,
651
+
652
+ /** allow close Popup when press ESC */
653
+ pressESCToClose: PropTypes.bool,
654
+
655
+ /** status read only of input */
656
+ readOnly: PropTypes.bool,
657
+
658
+ /** required state of the form control */
659
+ required: PropTypes.bool,
660
+
661
+ /** format of the returned value */
662
+ returnFormat: PropTypes.oneOfType([PropTypes.oneOf(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']), PropTypes.string]),
663
+
664
+ /** style of the component */
665
+ style: PropTypes.object,
666
+
667
+ /** text align of the input */
668
+ textAlign: PropTypes.oneOf(['center', 'end', 'start']),
669
+
670
+ /** value of the component */
671
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array]),
672
+
673
+ /** view type of the form control */
674
+ viewType: PropTypes.oneOf(['outlined', 'underlined'])
675
+ };
676
+ export default DatePicker;