diginet-core-ui 1.4.39 → 1.4.40

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 (906) hide show
  1. package/.browserslistrc +6 -0
  2. package/.eslintrc.js +91 -0
  3. package/.husky/pre-commit +4 -0
  4. package/.prettierrc +32 -0
  5. package/.storybook/main.js +4 -0
  6. package/.storybook/manager.js +10 -0
  7. package/.storybook/preview-head.html +17 -0
  8. package/.storybook/preview.js +36 -0
  9. package/.storybook/themeDecorator.js +19 -0
  10. package/babel.config.json +17 -0
  11. package/bitbucket-pipelines.yml +18 -0
  12. package/jsconfig.json +8 -0
  13. package/package.json +78 -44
  14. package/package.json.tmp +44 -0
  15. package/postcss.config.js +9 -0
  16. package/readme.md +5 -0
  17. package/src/assets/images/menu/dhr/MHRP15N0002.svg +17 -0
  18. package/src/assets/images/menu/dhr/MHRP15N0003.svg +26 -0
  19. package/src/components/accordion/context.js +5 -0
  20. package/src/components/accordion/details.js +80 -0
  21. package/src/components/accordion/group.js +140 -0
  22. package/src/components/accordion/index.js +207 -0
  23. package/src/components/accordion/index.stories.js +278 -0
  24. package/src/components/accordion/summary.js +380 -0
  25. package/src/components/alert/index.js +312 -0
  26. package/src/components/alert/index.stories.js +109 -0
  27. package/src/components/alert/notify.js +179 -0
  28. package/src/components/avatar/index.js +472 -0
  29. package/src/components/avatar/index.stories.js +80 -0
  30. package/src/components/badge/index.js +307 -0
  31. package/src/components/badge/index.stories.js +187 -0
  32. package/src/components/breadcrumb/index.js +280 -0
  33. package/src/components/breadcrumb/index.stories.js +69 -0
  34. package/src/components/button/button.stories.js +34 -0
  35. package/src/components/button/buttonIcon.stories.js +36 -0
  36. package/src/components/button/buttonMore.stories.js +58 -0
  37. package/src/components/button/icon.js +468 -0
  38. package/src/components/button/index.js +582 -0
  39. package/src/components/button/more.js +249 -0
  40. package/src/components/button/ripple-effect.js +95 -0
  41. package/src/components/button/sample.stories.js +194 -0
  42. package/src/components/card/body.js +73 -0
  43. package/src/components/card/extra.js +73 -0
  44. package/src/components/card/footer.js +73 -0
  45. package/src/components/card/header.js +74 -0
  46. package/src/components/card/index.js +256 -0
  47. package/src/components/card/index.stories.js +242 -0
  48. package/src/components/chart/Pie/Circle.js +68 -0
  49. package/src/components/chart/Pie/Sector.js +134 -0
  50. package/src/components/chart/Pie/Sectors.js +96 -0
  51. package/src/components/chart/Pie/index.js +312 -0
  52. package/src/components/chart/Pie/index.stories.js +77 -0
  53. package/src/components/chart/Pie-v2/Circle.js +62 -0
  54. package/src/components/chart/Pie-v2/Sector.js +128 -0
  55. package/src/components/chart/Pie-v2/Sectors.js +353 -0
  56. package/src/components/chart/Pie-v2/index.js +499 -0
  57. package/src/components/chart/Pie-v2/index.stories.js +77 -0
  58. package/src/components/chart/bar/Axis.js +67 -0
  59. package/src/components/chart/bar/Bar.js +365 -0
  60. package/src/components/chart/bar/Grid.js +111 -0
  61. package/src/components/chart/bar/Labels.js +193 -0
  62. package/src/components/chart/bar/Points.js +112 -0
  63. package/src/components/chart/bar/index.js +170 -0
  64. package/src/components/chart/bar/index.stories.js +174 -0
  65. package/src/components/chart/bar-v2/Axis.js +67 -0
  66. package/src/components/chart/bar-v2/Bar.js +372 -0
  67. package/src/components/chart/bar-v2/Grid.js +111 -0
  68. package/src/components/chart/bar-v2/Labels.js +193 -0
  69. package/src/components/chart/bar-v2/Points.js +112 -0
  70. package/src/components/chart/bar-v2/index.js +170 -0
  71. package/src/components/chart/bar-v2/index.stories.js +174 -0
  72. package/src/components/chart/line/Axis.js +68 -0
  73. package/src/components/chart/line/Grid.js +98 -0
  74. package/src/components/chart/line/Labels.js +191 -0
  75. package/src/components/chart/line/Path.js +155 -0
  76. package/src/components/chart/line/Point.js +358 -0
  77. package/src/components/chart/line/Title.js +50 -0
  78. package/src/components/chart/line/index.js +202 -0
  79. package/src/components/chart/line/index.stories.js +148 -0
  80. package/src/components/chart/line-v2/Axis.js +66 -0
  81. package/src/components/chart/line-v2/Grid.js +111 -0
  82. package/src/components/chart/line-v2/Labels.js +190 -0
  83. package/src/components/chart/line-v2/Path.js +154 -0
  84. package/src/components/chart/line-v2/Point.js +336 -0
  85. package/src/components/chart/line-v2/Title.js +50 -0
  86. package/src/components/chart/line-v2/index.js +172 -0
  87. package/src/components/chart/line-v2/index.stories.js +148 -0
  88. package/src/components/check-text/index.js +168 -0
  89. package/src/components/check-text/index.stories.js +50 -0
  90. package/src/components/check-text/interview-confirmation.js +169 -0
  91. package/src/components/check-text/interview-status.js +142 -0
  92. package/src/components/chip/attach.js +156 -0
  93. package/src/components/chip/index.js +366 -0
  94. package/src/components/chip/index.stories.js +190 -0
  95. package/src/components/collapse/index.js +104 -0
  96. package/src/components/collapse/index.stories.js +35 -0
  97. package/src/components/dialogs/colors.js +13 -0
  98. package/src/components/divider/index.js +87 -0
  99. package/src/components/divider/index.stories.js +52 -0
  100. package/src/components/form-control/attachment/index.js +1770 -0
  101. package/src/components/form-control/attachment/index.stories.js +106 -0
  102. package/src/components/form-control/calendar/function.js +959 -0
  103. package/src/components/form-control/calendar/index.js +413 -0
  104. package/src/components/form-control/calendar/index.stories.js +40 -0
  105. package/src/components/form-control/calendar/range.js +329 -0
  106. package/src/components/form-control/checkbox/index.js +382 -0
  107. package/src/components/form-control/checkbox/index.stories.js +110 -0
  108. package/src/components/form-control/control/index.js +99 -0
  109. package/src/components/form-control/date-input/DateField.js +191 -0
  110. package/src/components/form-control/date-input/index.js +315 -0
  111. package/src/components/form-control/date-input/index.stories.js +96 -0
  112. package/src/components/form-control/date-input/useDateInputState.js +138 -0
  113. package/src/components/form-control/date-input/useIsFocused.js +25 -0
  114. package/src/components/form-control/date-input/useKeyboardInputEvent.js +45 -0
  115. package/src/components/form-control/date-input/utils.js +293 -0
  116. package/src/components/form-control/date-picker/index.js +429 -0
  117. package/src/components/form-control/date-picker/index.stories.js +141 -0
  118. package/src/components/form-control/date-range-picker/index.js +1349 -0
  119. package/src/components/form-control/date-range-picker/index.stories.js +43 -0
  120. package/src/components/form-control/dropdown/index.js +1858 -0
  121. package/src/components/form-control/dropdown/index.stories.js +222 -0
  122. package/src/components/form-control/dropdown-box/index.js +271 -0
  123. package/src/components/form-control/dropdown-box/index.stories.js +103 -0
  124. package/src/components/form-control/form/context.js +5 -0
  125. package/src/components/form-control/form/index.js +39 -0
  126. package/src/components/form-control/form-group/index.js +131 -0
  127. package/src/components/form-control/form-group/index.stories.js +57 -0
  128. package/src/components/form-control/helper-text/index.js +92 -0
  129. package/src/components/form-control/helper-text/index.stories.js +29 -0
  130. package/src/components/form-control/input-base/UncontrolledInputBase.js +499 -0
  131. package/src/components/form-control/input-base/index.js +706 -0
  132. package/src/components/form-control/input-base/index.stories.js +69 -0
  133. package/src/components/form-control/label/index.js +127 -0
  134. package/src/components/form-control/label/index.stories.js +69 -0
  135. package/src/components/form-control/money-input/index.js +622 -0
  136. package/src/components/form-control/money-input/index.stories.js +42 -0
  137. package/src/components/form-control/number-input/index.js +582 -0
  138. package/src/components/form-control/number-input/index.stories.js +53 -0
  139. package/src/components/form-control/number-input/index2.js +531 -0
  140. package/src/components/form-control/password-input/index.js +259 -0
  141. package/src/components/form-control/password-input/index.stories.js +32 -0
  142. package/src/components/form-control/phone-input/index.js +382 -0
  143. package/src/components/form-control/phone-input/index.stories.js +39 -0
  144. package/src/components/form-control/radio/index.js +241 -0
  145. package/src/components/form-control/radio/index.stories.js +51 -0
  146. package/src/components/form-control/text-input/index.js +254 -0
  147. package/src/components/form-control/text-input/index.stories.js +60 -0
  148. package/src/components/form-control/time-picker/index.js +782 -0
  149. package/src/components/form-control/time-picker/index.mdx +49 -0
  150. package/src/components/form-control/time-picker/index.stories.js +69 -0
  151. package/src/components/form-control/time-picker/swiper.js +568 -0
  152. package/src/components/form-control/time-picker/v2/index.js +785 -0
  153. package/src/components/form-control/time-picker/v2/index.stories.js +43 -0
  154. package/src/components/form-control/toggle/index.js +247 -0
  155. package/src/components/form-control/toggle/index.stories.js +51 -0
  156. package/src/components/form-view/helper-text.js +30 -0
  157. package/src/components/form-view/index.js +100 -0
  158. package/src/components/form-view/index.stories.js +25 -0
  159. package/src/components/form-view/input.js +134 -0
  160. package/src/components/form-view/label.js +39 -0
  161. package/src/components/grid/Col.js +89 -0
  162. package/src/components/grid/Container.js +99 -0
  163. package/src/components/grid/Row.js +97 -0
  164. package/src/components/grid/context.js +5 -0
  165. package/src/components/grid/index.js +323 -0
  166. package/src/components/grid/index.stories.js +523 -0
  167. package/src/components/image/index.js +191 -0
  168. package/src/components/image/index.stories.js +53 -0
  169. package/src/components/index.js +157 -0
  170. package/src/components/list/index.stories.js +261 -0
  171. package/src/components/list/list-item-action.js +94 -0
  172. package/src/components/list/list-item-icon.js +89 -0
  173. package/src/components/list/list-item-text.js +69 -0
  174. package/src/components/list/list-item.js +131 -0
  175. package/src/components/list/list.js +164 -0
  176. package/src/components/list/sub-header.js +79 -0
  177. package/src/components/modal/body.js +84 -0
  178. package/src/components/modal/context.js +5 -0
  179. package/src/components/modal/footer.js +90 -0
  180. package/src/components/modal/header.js +145 -0
  181. package/src/components/modal/index.js +59 -0
  182. package/src/components/modal/index.stories.js +95 -0
  183. package/src/components/modal/modal.js +330 -0
  184. package/src/components/others/date/index.stories.js +217 -0
  185. package/src/components/others/extra/index.js +129 -0
  186. package/src/components/others/extra/index.mdx +39 -0
  187. package/src/components/others/extra/index.stories.js +17 -0
  188. package/src/components/others/import/index.js +66 -0
  189. package/src/components/others/import/index.stories.js +70 -0
  190. package/src/components/others/locale/index.stories.js +42 -0
  191. package/src/components/others/option-wrapper/index.js +34 -0
  192. package/src/components/others/scrollbar/index.js +106 -0
  193. package/src/components/others/scrollbar/index.stories.js +68 -0
  194. package/src/components/others/validate/index.stories.js +113 -0
  195. package/src/components/paging/index.stories.js +76 -0
  196. package/src/components/paging/page-info.js +637 -0
  197. package/src/components/paging/page-selector.js +437 -0
  198. package/src/components/paper/index.js +128 -0
  199. package/src/components/paper/index.stories.js +37 -0
  200. package/src/components/popover/body.js +98 -0
  201. package/src/components/popover/footer.js +96 -0
  202. package/src/components/popover/header.js +99 -0
  203. package/src/components/popover/index.js +718 -0
  204. package/src/components/popover/index.stories.js +189 -0
  205. package/src/components/popup/danger_popup.js +196 -0
  206. package/src/components/popup/index.js +464 -0
  207. package/src/components/popup/v2/index.js +556 -0
  208. package/src/components/popup/v2/index.stories.js +113 -0
  209. package/src/components/progress/circular.js +326 -0
  210. package/src/components/progress/index.stories.js +51 -0
  211. package/src/components/progress/linear.js +361 -0
  212. package/src/components/rating/index.js +309 -0
  213. package/src/components/rating/index.stories.js +78 -0
  214. package/src/components/skeleton/index.js +79 -0
  215. package/src/components/skeleton/index.stories.js +29 -0
  216. package/src/components/slider/index.stories.js +50 -0
  217. package/src/components/slider/slider-container.js +415 -0
  218. package/src/components/slider/slider-item.js +222 -0
  219. package/src/components/status/index.js +145 -0
  220. package/src/components/status/index.stories.js +71 -0
  221. package/src/components/tab/context.js +5 -0
  222. package/src/components/tab/index.stories.js +123 -0
  223. package/src/components/tab/tab-container.js +109 -0
  224. package/src/components/tab/tab-header.js +177 -0
  225. package/src/components/tab/tab-panel.js +101 -0
  226. package/src/components/tab/tab.js +249 -0
  227. package/src/components/tooltip/index.js +580 -0
  228. package/src/components/tooltip/index.stories.js +282 -0
  229. package/src/components/tooltip/portal.js +10 -0
  230. package/src/components/transfer/index.js +555 -0
  231. package/src/components/transfer/index.stories.js +53 -0
  232. package/src/components/tree-view/index.js +1085 -0
  233. package/src/components/tree-view/index.stories.js +347 -0
  234. package/src/components/typography/index.js +331 -0
  235. package/src/components/typography/index.stories.js +166 -0
  236. package/src/docs/changelog/changelog.md +1354 -0
  237. package/src/docs/changelog/index.stories.js +20 -0
  238. package/src/global/index.js +247 -0
  239. package/src/icons/basic.js +5930 -0
  240. package/src/icons/basic.stories.js +178 -0
  241. package/src/icons/effect.js +167 -0
  242. package/src/icons/general/clock/clock.js +16 -0
  243. package/src/icons/general/color-handler/background.js +34 -0
  244. package/src/icons/general/color-handler/text.js +34 -0
  245. package/src/icons/general/emoji/emoji.js +27 -0
  246. package/src/icons/general/font-properties/bold.js +17 -0
  247. package/src/icons/general/font-properties/font-family.js +27 -0
  248. package/src/icons/general/font-properties/font-size.js +24 -0
  249. package/src/icons/general/font-properties/italic.js +17 -0
  250. package/src/icons/general/font-properties/underline.js +26 -0
  251. package/src/icons/general/hyperlink/hyperlink.js +33 -0
  252. package/src/icons/general/indent/decrease.js +54 -0
  253. package/src/icons/general/indent/increase.js +54 -0
  254. package/src/icons/general/index.js +21 -0
  255. package/src/icons/general/index.mdx +68 -0
  256. package/src/icons/general/list/bullets.js +76 -0
  257. package/src/icons/general/list/numbering.js +69 -0
  258. package/src/icons/general/picture/picture.js +17 -0
  259. package/src/icons/general/steps/redo.js +17 -0
  260. package/src/icons/general/steps/undo.js +17 -0
  261. package/src/icons/general/text-align/center.js +17 -0
  262. package/src/icons/general/text-align/justify.js +17 -0
  263. package/src/icons/general/text-align/left.js +17 -0
  264. package/src/icons/general/text-align/right.js +17 -0
  265. package/src/icons/index.js +3 -0
  266. package/src/icons/index.stories.js +22 -0
  267. package/src/icons/menu/dhr.js +2625 -0
  268. package/src/icons/menu/erp.js +513 -0
  269. package/src/icons/menu/index.js +6 -0
  270. package/src/icons/menu/index.stories.js +107 -0
  271. package/src/icons/menu/v2/index.js +77 -0
  272. package/src/icons/menu/v2/index.stories.js +426 -0
  273. package/src/locale/index.js +13 -0
  274. package/src/scss/styles.scss +10 -0
  275. package/src/styles/animation.js +930 -0
  276. package/src/styles/animations.js +13 -0
  277. package/src/styles/color-helper.js +364 -0
  278. package/src/styles/colors.js +504 -0
  279. package/src/styles/colors.stories.js +105 -0
  280. package/src/styles/font.js +26 -0
  281. package/src/styles/general.js +824 -0
  282. package/src/styles/sx/index.js +35 -0
  283. package/src/styles/typography.js +181 -0
  284. package/src/styles/utils.js +35 -0
  285. package/src/theme/createBreakpoints.js +95 -0
  286. package/src/theme/createSpacing.js +12 -0
  287. package/src/theme/createTheme.js +29 -0
  288. package/src/theme/createZIndex.js +10 -0
  289. package/src/theme/docs/breakpoints.md +242 -0
  290. package/src/theme/docs/colors.md +64 -0
  291. package/src/theme/docs/components.md +32 -0
  292. package/src/theme/docs/darkMode.md +20 -0
  293. package/src/theme/docs/spacing.md +52 -0
  294. package/src/theme/docs/theming.md +69 -0
  295. package/src/theme/docs/zIndex.md +27 -0
  296. package/src/theme/index.js +15 -0
  297. package/src/theme/make-styles.js +32 -0
  298. package/src/theme/settings.js +816 -0
  299. package/src/theme/stories/breakpoints.stories.js +20 -0
  300. package/src/theme/stories/colors.stories.js +20 -0
  301. package/src/theme/stories/components.stories.js +20 -0
  302. package/src/theme/stories/darkMode.stories.js +20 -0
  303. package/src/theme/stories/spacing.stories.js +20 -0
  304. package/src/theme/stories/theming.stories.js +20 -0
  305. package/src/theme/stories/zIndex.stories.js +20 -0
  306. package/src/theme/theme-provider.js +101 -0
  307. package/src/theme/theme.js +57 -0
  308. package/src/theme/use-classes.js +19 -0
  309. package/src/theme/utils/getThemeProps.js +11 -0
  310. package/src/theme/utils/resolveProps.js +16 -0
  311. package/src/theme/utils/useThemeProps.js +8 -0
  312. package/src/utils/array/array.js +197 -0
  313. package/src/utils/classNames/index.js +28 -0
  314. package/src/utils/classNames/index.stories.js +61 -0
  315. package/src/utils/console.js +30 -0
  316. package/src/utils/date.js +391 -0
  317. package/src/utils/error/error.js +65 -0
  318. package/src/utils/error/errors.js +250 -0
  319. package/src/utils/getFileType.js +24 -0
  320. package/src/utils/handleBreakpoints.js +27 -0
  321. package/src/utils/hexToRGBA/index.js +25 -0
  322. package/src/utils/hexToRGBA/index.stories.js +43 -0
  323. package/src/utils/index.js +40 -0
  324. package/src/utils/intersectionObserver.js +45 -0
  325. package/src/utils/isMobile/index.js +22 -0
  326. package/src/utils/isMobile/index.stories.js +49 -0
  327. package/src/utils/isUndefined.js +3 -0
  328. package/src/utils/iterator.js +45 -0
  329. package/src/utils/map-parent.js +49 -0
  330. package/src/utils/object/deepmerge.js +129 -0
  331. package/src/utils/object/extend.js +55 -0
  332. package/src/utils/object/object.js +61 -0
  333. package/src/utils/parseHTML.js +20 -0
  334. package/src/utils/promisify.js +37 -0
  335. package/src/utils/randomString.js +22 -0
  336. package/src/utils/refMethodType.js +9 -0
  337. package/src/utils/refType.js +5 -0
  338. package/src/utils/remove-unicode.js +13 -0
  339. package/src/utils/render-portal.js +87 -0
  340. package/src/utils/renderHTML.js +17 -0
  341. package/src/utils/renderIcon.js +41 -0
  342. package/src/utils/sb-template.js +115 -0
  343. package/src/utils/storybook/index.js +1 -0
  344. package/src/utils/storybook/refArgTypes.js +46 -0
  345. package/src/utils/string/capitalize.js +6 -0
  346. package/src/utils/string/capitalizeSentenceCase.js +9 -0
  347. package/src/utils/string/string.js +83 -0
  348. package/src/utils/type.js +121 -0
  349. package/src/utils/updatePosition.js +27 -0
  350. package/src/utils/useControlled/index.js +23 -0
  351. package/src/utils/useDelayUnmount.js +17 -0
  352. package/src/utils/useElementSize.js +59 -0
  353. package/src/utils/useEventListener.js +54 -0
  354. package/src/utils/useInput.js +39 -0
  355. package/src/utils/useMediaQuery/index.js +50 -0
  356. package/src/utils/useMediaQuery/index.stories.js +55 -0
  357. package/src/utils/useOnClickOutside.js +28 -0
  358. package/src/utils/usePortal.js +54 -0
  359. package/src/utils/validate.js +135 -0
  360. package/components/accordion/context.js +0 -6
  361. package/components/accordion/details.js +0 -76
  362. package/components/accordion/group.js +0 -135
  363. package/components/accordion/index.js +0 -178
  364. package/components/accordion/summary.js +0 -324
  365. package/components/alert/index.js +0 -257
  366. package/components/alert/notify.js +0 -140
  367. package/components/avatar/index.js +0 -388
  368. package/components/badge/index.js +0 -231
  369. package/components/breadcrumb/index.js +0 -220
  370. package/components/button/icon.js +0 -357
  371. package/components/button/index.js +0 -444
  372. package/components/button/more.js +0 -210
  373. package/components/button/ripple-effect.js +0 -81
  374. package/components/card/body.js +0 -76
  375. package/components/card/extra.js +0 -76
  376. package/components/card/footer.js +0 -76
  377. package/components/card/header.js +0 -80
  378. package/components/card/index.js +0 -203
  379. package/components/chart/Pie/Circle.js +0 -50
  380. package/components/chart/Pie/Sector.js +0 -124
  381. package/components/chart/Pie/Sectors.js +0 -81
  382. package/components/chart/Pie/index.js +0 -277
  383. package/components/chart/Pie-v2/Circle.js +0 -48
  384. package/components/chart/Pie-v2/Sector.js +0 -108
  385. package/components/chart/Pie-v2/Sectors.js +0 -204
  386. package/components/chart/Pie-v2/index.js +0 -488
  387. package/components/chart/bar/Axis.js +0 -67
  388. package/components/chart/bar/Bar.js +0 -344
  389. package/components/chart/bar/Grid.js +0 -97
  390. package/components/chart/bar/Labels.js +0 -162
  391. package/components/chart/bar/Points.js +0 -94
  392. package/components/chart/bar/index.js +0 -161
  393. package/components/chart/bar-v2/Axis.js +0 -67
  394. package/components/chart/bar-v2/Bar.js +0 -354
  395. package/components/chart/bar-v2/Grid.js +0 -97
  396. package/components/chart/bar-v2/Labels.js +0 -162
  397. package/components/chart/bar-v2/Points.js +0 -94
  398. package/components/chart/bar-v2/index.js +0 -161
  399. package/components/chart/line/Axis.js +0 -68
  400. package/components/chart/line/Grid.js +0 -99
  401. package/components/chart/line/Labels.js +0 -160
  402. package/components/chart/line/Path.js +0 -154
  403. package/components/chart/line/Point.js +0 -343
  404. package/components/chart/line/Title.js +0 -52
  405. package/components/chart/line/index.js +0 -199
  406. package/components/chart/line-v2/Axis.js +0 -66
  407. package/components/chart/line-v2/Grid.js +0 -97
  408. package/components/chart/line-v2/Labels.js +0 -160
  409. package/components/chart/line-v2/Path.js +0 -153
  410. package/components/chart/line-v2/Point.js +0 -326
  411. package/components/chart/line-v2/Title.js +0 -52
  412. package/components/chart/line-v2/index.js +0 -165
  413. package/components/check-text/index.js +0 -155
  414. package/components/check-text/interview-confirmation.js +0 -171
  415. package/components/check-text/interview-status.js +0 -137
  416. package/components/chip/attach.js +0 -167
  417. package/components/chip/index.js +0 -275
  418. package/components/collapse/index.js +0 -93
  419. package/components/dialogs/colors.js +0 -13
  420. package/components/divider/index.js +0 -89
  421. package/components/form-control/attachment/index.js +0 -1537
  422. package/components/form-control/calendar/function.js +0 -752
  423. package/components/form-control/calendar/index.js +0 -317
  424. package/components/form-control/calendar/range.js +0 -291
  425. package/components/form-control/checkbox/index.js +0 -329
  426. package/components/form-control/control/index.js +0 -91
  427. package/components/form-control/date-input/DateField.js +0 -187
  428. package/components/form-control/date-input/index.js +0 -292
  429. package/components/form-control/date-input/useDateInputState.js +0 -129
  430. package/components/form-control/date-input/useIsFocused.js +0 -20
  431. package/components/form-control/date-input/useKeyboardInputEvent.js +0 -45
  432. package/components/form-control/date-input/utils.js +0 -290
  433. package/components/form-control/date-picker/index.js +0 -357
  434. package/components/form-control/date-range-picker/index.js +0 -1183
  435. package/components/form-control/dropdown/index.js +0 -1624
  436. package/components/form-control/dropdown-box/index.js +0 -238
  437. package/components/form-control/form/context.js +0 -5
  438. package/components/form-control/form/index.js +0 -40
  439. package/components/form-control/form-group/index.js +0 -117
  440. package/components/form-control/helper-text/index.js +0 -88
  441. package/components/form-control/input-base/UncontrolledInputBase.js +0 -450
  442. package/components/form-control/input-base/index.js +0 -646
  443. package/components/form-control/label/index.js +0 -117
  444. package/components/form-control/money-input/index.js +0 -513
  445. package/components/form-control/number-input/index.js +0 -582
  446. package/components/form-control/number-input/index2.js +0 -481
  447. package/components/form-control/password-input/index.js +0 -242
  448. package/components/form-control/phone-input/index.js +0 -364
  449. package/components/form-control/radio/index.js +0 -224
  450. package/components/form-control/text-input/index.js +0 -239
  451. package/components/form-control/time-picker/index.js +0 -781
  452. package/components/form-control/time-picker/swiper.js +0 -540
  453. package/components/form-control/time-picker/v2/index.js +0 -809
  454. package/components/form-control/toggle/index.js +0 -222
  455. package/components/form-view/helper-text.js +0 -33
  456. package/components/form-view/index.js +0 -95
  457. package/components/form-view/input.js +0 -117
  458. package/components/form-view/label.js +0 -37
  459. package/components/grid/Col.js +0 -91
  460. package/components/grid/Container.js +0 -85
  461. package/components/grid/Row.js +0 -81
  462. package/components/grid/context.js +0 -3
  463. package/components/grid/index.js +0 -251
  464. package/components/image/index.js +0 -170
  465. package/components/index.js +0 -156
  466. package/components/list/list-item-action.js +0 -82
  467. package/components/list/list-item-icon.js +0 -71
  468. package/components/list/list-item-text.js +0 -56
  469. package/components/list/list-item.js +0 -108
  470. package/components/list/list.js +0 -149
  471. package/components/list/sub-header.js +0 -63
  472. package/components/modal/body.js +0 -74
  473. package/components/modal/context.js +0 -6
  474. package/components/modal/footer.js +0 -78
  475. package/components/modal/header.js +0 -128
  476. package/components/modal/index.js +0 -63
  477. package/components/modal/modal.js +0 -292
  478. package/components/others/extra/index.js +0 -116
  479. package/components/others/import/index.js +0 -71
  480. package/components/others/option-wrapper/index.js +0 -39
  481. package/components/others/scrollbar/index.js +0 -94
  482. package/components/paging/page-info.js +0 -582
  483. package/components/paging/page-selector.js +0 -381
  484. package/components/paper/index.js +0 -112
  485. package/components/popover/body.js +0 -86
  486. package/components/popover/footer.js +0 -84
  487. package/components/popover/header.js +0 -88
  488. package/components/popover/index.js +0 -663
  489. package/components/popup/danger_popup.js +0 -189
  490. package/components/popup/index.js +0 -414
  491. package/components/popup/v2/index.js +0 -398
  492. package/components/progress/circular.js +0 -296
  493. package/components/progress/linear.js +0 -324
  494. package/components/rating/index.js +0 -243
  495. package/components/skeleton/index.js +0 -79
  496. package/components/slider/slider-container.js +0 -340
  497. package/components/slider/slider-item.js +0 -205
  498. package/components/status/index.js +0 -111
  499. package/components/tab/context.js +0 -3
  500. package/components/tab/tab-container.js +0 -100
  501. package/components/tab/tab-header.js +0 -160
  502. package/components/tab/tab-panel.js +0 -91
  503. package/components/tab/tab.js +0 -210
  504. package/components/tooltip/index.js +0 -522
  505. package/components/tooltip/portal.js +0 -11
  506. package/components/transfer/index.js +0 -434
  507. package/components/tree-view/index.js +0 -1017
  508. package/components/typography/index.js +0 -193
  509. package/css/styles.css +0 -1
  510. package/css/styles.css.map +0 -1
  511. package/global/index.js +0 -194
  512. package/icons/basic.js +0 -7864
  513. package/icons/effect.js +0 -131
  514. package/icons/general/clock/clock.js +0 -20
  515. package/icons/general/color-handler/background.js +0 -40
  516. package/icons/general/color-handler/text.js +0 -40
  517. package/icons/general/emoji/emoji.js +0 -34
  518. package/icons/general/font-properties/bold.js +0 -20
  519. package/icons/general/font-properties/font-family.js +0 -34
  520. package/icons/general/font-properties/font-size.js +0 -26
  521. package/icons/general/font-properties/italic.js +0 -20
  522. package/icons/general/font-properties/underline.js +0 -30
  523. package/icons/general/hyperlink/hyperlink.js +0 -37
  524. package/icons/general/indent/decrease.js +0 -54
  525. package/icons/general/indent/increase.js +0 -54
  526. package/icons/general/index.js +0 -21
  527. package/icons/general/list/bullets.js +0 -76
  528. package/icons/general/list/numbering.js +0 -70
  529. package/icons/general/picture/picture.js +0 -20
  530. package/icons/general/steps/redo.js +0 -20
  531. package/icons/general/steps/undo.js +0 -20
  532. package/icons/general/text-align/center.js +0 -20
  533. package/icons/general/text-align/justify.js +0 -20
  534. package/icons/general/text-align/left.js +0 -20
  535. package/icons/general/text-align/right.js +0 -20
  536. package/icons/index.js +0 -3
  537. package/icons/menu/dhr.js +0 -2442
  538. package/icons/menu/erp.js +0 -491
  539. package/icons/menu/index.js +0 -5
  540. package/icons/menu/v2/index.js +0 -71
  541. package/locale/index.js +0 -11
  542. package/styles/animation.js +0 -848
  543. package/styles/animations.js +0 -13
  544. package/styles/color-helper.js +0 -343
  545. package/styles/colors.js +0 -476
  546. package/styles/font.js +0 -24
  547. package/styles/general.js +0 -568
  548. package/styles/sx/index.js +0 -28
  549. package/styles/typography.js +0 -156
  550. package/styles/utils.js +0 -35
  551. package/theme/createBreakpoints.js +0 -82
  552. package/theme/createSpacing.js +0 -10
  553. package/theme/createTheme.js +0 -26
  554. package/theme/createZIndex.js +0 -9
  555. package/theme/index.js +0 -14
  556. package/theme/make-styles.js +0 -30
  557. package/theme/settings.js +0 -861
  558. package/theme/theme-provider.js +0 -102
  559. package/theme/theme.js +0 -57
  560. package/theme/use-classes.js +0 -15
  561. package/theme/utils/getThemeProps.js +0 -12
  562. package/theme/utils/resolveProps.js +0 -17
  563. package/theme/utils/useThemeProps.js +0 -14
  564. package/utils/array/array.js +0 -169
  565. package/utils/classNames/index.js +0 -25
  566. package/utils/console.js +0 -27
  567. package/utils/date.js +0 -401
  568. package/utils/error/error.js +0 -53
  569. package/utils/error/errors.js +0 -200
  570. package/utils/getFileType.js +0 -23
  571. package/utils/handleBreakpoints.js +0 -25
  572. package/utils/hexToRGBA/index.js +0 -23
  573. package/utils/index.js +0 -38
  574. package/utils/intersectionObserver.js +0 -37
  575. package/utils/isMobile/index.js +0 -21
  576. package/utils/isUndefined.js +0 -2
  577. package/utils/iterator.js +0 -36
  578. package/utils/map-parent.js +0 -46
  579. package/utils/object/deepmerge.js +0 -103
  580. package/utils/object/extend.js +0 -47
  581. package/utils/object/object.js +0 -54
  582. package/utils/parseHTML.js +0 -18
  583. package/utils/promisify.js +0 -34
  584. package/utils/randomString.js +0 -26
  585. package/utils/refMethodType.js +0 -6
  586. package/utils/refType.js +0 -5
  587. package/utils/remove-unicode.js +0 -5
  588. package/utils/render-portal.js +0 -87
  589. package/utils/renderHTML.js +0 -18
  590. package/utils/renderIcon.js +0 -53
  591. package/utils/sb-template.js +0 -113
  592. package/utils/storybook/index.js +0 -1
  593. package/utils/storybook/refArgTypes.js +0 -41
  594. package/utils/string/capitalize.js +0 -3
  595. package/utils/string/capitalizeSentenceCase.js +0 -8
  596. package/utils/string/string.js +0 -60
  597. package/utils/type.js +0 -69
  598. package/utils/updatePosition.js +0 -35
  599. package/utils/useControlled/index.js +0 -14
  600. package/utils/useDelayUnmount.js +0 -15
  601. package/utils/useElementSize.js +0 -55
  602. package/utils/useEventListener.js +0 -51
  603. package/utils/useInput.js +0 -33
  604. package/utils/useMediaQuery/index.js +0 -44
  605. package/utils/useOnClickOutside.js +0 -21
  606. package/utils/usePortal.js +0 -49
  607. package/utils/validate.js +0 -135
  608. /package/{assets → src/assets}/avatar/default.svg +0 -0
  609. /package/{assets → src/assets}/fonts/SF-Pro-Display-Bold.otf +0 -0
  610. /package/{assets → src/assets}/fonts/SF-Pro-Display-Medium.otf +0 -0
  611. /package/{assets → src/assets}/fonts/SF-Pro-Display-Regular.otf +0 -0
  612. /package/{assets → src/assets}/fonts/text-security-disc-compat.eot +0 -0
  613. /package/{assets → src/assets}/fonts/text-security-disc-compat.ttf +0 -0
  614. /package/{assets → src/assets}/fonts/text-security-disc-compat.woff2 +0 -0
  615. /package/{assets → src/assets}/fonts/text-security-disc.woff2 +0 -0
  616. /package/{assets → src/assets}/image/default.png +0 -0
  617. /package/{assets → src/assets}/images/icons/wifi.svg +0 -0
  618. /package/{assets → src/assets}/images/menu/bem/WA3F0100.svg +0 -0
  619. /package/{assets → src/assets}/images/menu/bem/WA3F1025.svg +0 -0
  620. /package/{assets → src/assets}/images/menu/bem/WA3F2000.svg +0 -0
  621. /package/{assets → src/assets}/images/menu/bem/WA3F2020.svg +0 -0
  622. /package/{assets → src/assets}/images/menu/bem/WA3F2030.svg +0 -0
  623. /package/{assets → src/assets}/images/menu/bem/WA3F2040.svg +0 -0
  624. /package/{assets → src/assets}/images/menu/bem/WA3F2100.svg +0 -0
  625. /package/{assets → src/assets}/images/menu/dhr/ALL.svg +0 -0
  626. /package/{assets → src/assets}/images/menu/dhr/D00.svg +0 -0
  627. /package/{assets → src/assets}/images/menu/dhr/D09.svg +0 -0
  628. /package/{assets → src/assets}/images/menu/dhr/D13.svg +0 -0
  629. /package/{assets → src/assets}/images/menu/dhr/D15.svg +0 -0
  630. /package/{assets → src/assets}/images/menu/dhr/D21.svg +0 -0
  631. /package/{assets → src/assets}/images/menu/dhr/D25.svg +0 -0
  632. /package/{assets → src/assets}/images/menu/dhr/D29.svg +0 -0
  633. /package/{assets → src/assets}/images/menu/dhr/D38.svg +0 -0
  634. /package/{assets → src/assets}/images/menu/dhr/D39.svg +0 -0
  635. /package/{assets → src/assets}/images/menu/dhr/D51.svg +0 -0
  636. /package/{assets → src/assets}/images/menu/dhr/D52.svg +0 -0
  637. /package/{assets → src/assets}/images/menu/dhr/D77.svg +0 -0
  638. /package/{assets → src/assets}/images/menu/dhr/D84.svg +0 -0
  639. /package/{assets → src/assets}/images/menu/dhr/D89.svg +0 -0
  640. /package/{assets → src/assets}/images/menu/dhr/Default.svg +0 -0
  641. /package/{assets → src/assets}/images/menu/dhr/MAHR21N0000.svg +0 -0
  642. /package/{assets → src/assets}/images/menu/dhr/MAHR29N0001.svg +0 -0
  643. /package/{assets → src/assets}/images/menu/dhr/MAHR29N0002.svg +0 -0
  644. /package/{assets → src/assets}/images/menu/dhr/MAHR29N0003.svg +0 -0
  645. /package/{assets → src/assets}/images/menu/dhr/MAHR29N0004.svg +0 -0
  646. /package/{assets → src/assets}/images/menu/dhr/MAHR29N0011.svg +0 -0
  647. /package/{assets → src/assets}/images/menu/dhr/MAHR29N0012.svg +0 -0
  648. /package/{assets → src/assets}/images/menu/dhr/MAHR29N0013.svg +0 -0
  649. /package/{assets → src/assets}/images/menu/dhr/MAHR75N0005.svg +0 -0
  650. /package/{assets → src/assets}/images/menu/dhr/MAHR75N0006.svg +0 -0
  651. /package/{assets → src/assets}/images/menu/dhr/MAHR75N0007.svg +0 -0
  652. /package/{assets → src/assets}/images/menu/dhr/MAHR75N0008.svg +0 -0
  653. /package/{assets → src/assets}/images/menu/dhr/MAHR75N0009.svg +0 -0
  654. /package/{assets → src/assets}/images/menu/dhr/MAHR75N0010.svg +0 -0
  655. /package/{assets → src/assets}/images/menu/dhr/MAHR89N0014.svg +0 -0
  656. /package/{assets → src/assets}/images/menu/dhr/MAHR89N0015.svg +0 -0
  657. /package/{assets → src/assets}/images/menu/dhr/MHRM00N0001.svg +0 -0
  658. /package/{assets → src/assets}/images/menu/dhr/MHRM00N0002.svg +0 -0
  659. /package/{assets → src/assets}/images/menu/dhr/MHRM00N0003.svg +0 -0
  660. /package/{assets → src/assets}/images/menu/dhr/MHRM00N0004.svg +0 -0
  661. /package/{assets → src/assets}/images/menu/dhr/MHRM00N0005.svg +0 -0
  662. /package/{assets → src/assets}/images/menu/dhr/MHRM00N0006.svg +0 -0
  663. /package/{assets → src/assets}/images/menu/dhr/MHRM00N0007.svg +0 -0
  664. /package/{assets → src/assets}/images/menu/dhr/MHRM09N0001.svg +0 -0
  665. /package/{assets → src/assets}/images/menu/dhr/MHRM09N0002.svg +0 -0
  666. /package/{assets → src/assets}/images/menu/dhr/MHRM09N0003.svg +0 -0
  667. /package/{assets → src/assets}/images/menu/dhr/MHRM09N0004.svg +0 -0
  668. /package/{assets → src/assets}/images/menu/dhr/MHRM09N0005.svg +0 -0
  669. /package/{assets → src/assets}/images/menu/dhr/MHRM09N1010.svg +0 -0
  670. /package/{assets → src/assets}/images/menu/dhr/MHRM09N1015.svg +0 -0
  671. /package/{assets → src/assets}/images/menu/dhr/MHRM09N1020.svg +0 -0
  672. /package/{assets → src/assets}/images/menu/dhr/MHRM09N1025.svg +0 -0
  673. /package/{assets → src/assets}/images/menu/dhr/MHRM09N1030.svg +0 -0
  674. /package/{assets → src/assets}/images/menu/dhr/MHRM09N1035.svg +0 -0
  675. /package/{assets → src/assets}/images/menu/dhr/MHRM09N1040.svg +0 -0
  676. /package/{assets → src/assets}/images/menu/dhr/MHRM09N1400.svg +0 -0
  677. /package/{assets → src/assets}/images/menu/dhr/MHRM13N0001.svg +0 -0
  678. /package/{assets → src/assets}/images/menu/dhr/MHRM13N0002.svg +0 -0
  679. /package/{assets → src/assets}/images/menu/dhr/MHRM13N0003.svg +0 -0
  680. /package/{assets → src/assets}/images/menu/dhr/MHRM13N0004.svg +0 -0
  681. /package/{assets → src/assets}/images/menu/dhr/MHRM15N0001.svg +0 -0
  682. /package/{assets → src/assets}/images/menu/dhr/MHRM25N0001.svg +0 -0
  683. /package/{assets → src/assets}/images/menu/dhr/MHRM29N0001.svg +0 -0
  684. /package/{assets → src/assets}/images/menu/dhr/MHRM29N0002.svg +0 -0
  685. /package/{assets → src/assets}/images/menu/dhr/MHRM29N0003.svg +0 -0
  686. /package/{assets → src/assets}/images/menu/dhr/MHRM29N0004.svg +0 -0
  687. /package/{assets → src/assets}/images/menu/dhr/MHRM29N0005.svg +0 -0
  688. /package/{assets → src/assets}/images/menu/dhr/MHRM29N0015.svg +0 -0
  689. /package/{assets → src/assets}/images/menu/dhr/MHRM38N0001.svg +0 -0
  690. /package/{assets → src/assets}/images/menu/dhr/MHRM38N0002.svg +0 -0
  691. /package/{assets → src/assets}/images/menu/dhr/MHRM38N0003.svg +0 -0
  692. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0012.svg +0 -0
  693. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0013.svg +0 -0
  694. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0014.svg +0 -0
  695. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0015.svg +0 -0
  696. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0016.svg +0 -0
  697. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0017.svg +0 -0
  698. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0018.svg +0 -0
  699. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0019.svg +0 -0
  700. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0020.svg +0 -0
  701. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0021.svg +0 -0
  702. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0022.svg +0 -0
  703. /package/{assets → src/assets}/images/menu/dhr/MHRM39N0023.svg +0 -0
  704. /package/{assets → src/assets}/images/menu/dhr/MHRM51N0005.svg +0 -0
  705. /package/{assets → src/assets}/images/menu/dhr/MHRM51N0006.svg +0 -0
  706. /package/{assets → src/assets}/images/menu/dhr/MHRM51N0007.svg +0 -0
  707. /package/{assets → src/assets}/images/menu/dhr/MHRM77N0001.svg +0 -0
  708. /package/{assets → src/assets}/images/menu/dhr/MHRM77N0003.svg +0 -0
  709. /package/{assets → src/assets}/images/menu/dhr/MHRM82N0001.svg +0 -0
  710. /package/{assets → src/assets}/images/menu/dhr/MHRM82N0002.svg +0 -0
  711. /package/{assets → src/assets}/images/menu/dhr/MHRM84N0001.svg +0 -0
  712. /package/{assets → src/assets}/images/menu/dhr/MHRM84N0002.svg +0 -0
  713. /package/{assets → src/assets}/images/menu/dhr/MHRM89N0001.svg +0 -0
  714. /package/{assets → src/assets}/images/menu/dhr/MHRM89N0002.svg +0 -0
  715. /package/{assets → src/assets}/images/menu/dhr/MHRP00N0001.svg +0 -0
  716. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0001.svg +0 -0
  717. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0002.svg +0 -0
  718. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0003.svg +0 -0
  719. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0004.svg +0 -0
  720. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0005.svg +0 -0
  721. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0006.svg +0 -0
  722. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0007.svg +0 -0
  723. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0008.svg +0 -0
  724. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0009.svg +0 -0
  725. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0010.svg +0 -0
  726. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0011.svg +0 -0
  727. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0012.svg +0 -0
  728. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0013.svg +0 -0
  729. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0014.svg +0 -0
  730. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0015.svg +0 -0
  731. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0016.svg +0 -0
  732. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0017.svg +0 -0
  733. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0018.svg +0 -0
  734. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0019.svg +0 -0
  735. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0020.svg +0 -0
  736. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0021.svg +0 -0
  737. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0022.svg +0 -0
  738. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0023.svg +0 -0
  739. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0024.svg +0 -0
  740. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0025.svg +0 -0
  741. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0026.svg +0 -0
  742. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0027.svg +0 -0
  743. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0028.svg +0 -0
  744. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0029.svg +0 -0
  745. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0030.svg +0 -0
  746. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0031.svg +0 -0
  747. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0032.svg +0 -0
  748. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0033.svg +0 -0
  749. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0034.svg +0 -0
  750. /package/{assets → src/assets}/images/menu/dhr/MHRP09N0035.svg +0 -0
  751. /package/{assets → src/assets}/images/menu/dhr/MHRP13N0001.svg +0 -0
  752. /package/{assets → src/assets}/images/menu/dhr/MHRP13N0005.svg +0 -0
  753. /package/{assets → src/assets}/images/menu/dhr/MHRP13N0006.svg +0 -0
  754. /package/{assets → src/assets}/images/menu/dhr/MHRP21N0001.svg +0 -0
  755. /package/{assets → src/assets}/images/menu/dhr/MHRP21N0002.svg +0 -0
  756. /package/{assets → src/assets}/images/menu/dhr/MHRP25L0101.svg +0 -0
  757. /package/{assets → src/assets}/images/menu/dhr/MHRP25L0501.svg +0 -0
  758. /package/{assets → src/assets}/images/menu/dhr/MHRP25N0001.svg +0 -0
  759. /package/{assets → src/assets}/images/menu/dhr/MHRP25N0002.svg +0 -0
  760. /package/{assets → src/assets}/images/menu/dhr/MHRP25N0003.svg +0 -0
  761. /package/{assets → src/assets}/images/menu/dhr/MHRP25N0004.svg +0 -0
  762. /package/{assets → src/assets}/images/menu/dhr/MHRP25N0005.svg +0 -0
  763. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0001.svg +0 -0
  764. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0002.svg +0 -0
  765. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0003.svg +0 -0
  766. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0004.svg +0 -0
  767. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0005.svg +0 -0
  768. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0006.svg +0 -0
  769. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0007.svg +0 -0
  770. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0008.svg +0 -0
  771. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0009.svg +0 -0
  772. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0010.svg +0 -0
  773. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0011.svg +0 -0
  774. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0012.svg +0 -0
  775. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0013.svg +0 -0
  776. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0014.svg +0 -0
  777. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0016.svg +0 -0
  778. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0017.svg +0 -0
  779. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0018.svg +0 -0
  780. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0019.svg +0 -0
  781. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0020.svg +0 -0
  782. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0021.svg +0 -0
  783. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0022.svg +0 -0
  784. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0023.svg +0 -0
  785. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0026.svg +0 -0
  786. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0027.svg +0 -0
  787. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0028.svg +0 -0
  788. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0029.svg +0 -0
  789. /package/{assets → src/assets}/images/menu/dhr/MHRP29N0030.svg +0 -0
  790. /package/{assets → src/assets}/images/menu/dhr/MHRP38N0001.svg +0 -0
  791. /package/{assets → src/assets}/images/menu/dhr/MHRP38N0002.svg +0 -0
  792. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0001.svg +0 -0
  793. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0002.svg +0 -0
  794. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0003.svg +0 -0
  795. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0004.svg +0 -0
  796. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0005.svg +0 -0
  797. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0006.svg +0 -0
  798. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0007.svg +0 -0
  799. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0008.svg +0 -0
  800. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0009.svg +0 -0
  801. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0010.svg +0 -0
  802. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0011.svg +0 -0
  803. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0013.svg +0 -0
  804. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0014.svg +0 -0
  805. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0015.svg +0 -0
  806. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0017.svg +0 -0
  807. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0018.svg +0 -0
  808. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0019.svg +0 -0
  809. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0020.svg +0 -0
  810. /package/{assets → src/assets}/images/menu/dhr/MHRP39N0021.svg +0 -0
  811. /package/{assets → src/assets}/images/menu/dhr/MHRP39N1222.svg +0 -0
  812. /package/{assets → src/assets}/images/menu/dhr/MHRP51N0001.svg +0 -0
  813. /package/{assets → src/assets}/images/menu/dhr/MHRP51N0002.svg +0 -0
  814. /package/{assets → src/assets}/images/menu/dhr/MHRP51N0003.svg +0 -0
  815. /package/{assets → src/assets}/images/menu/dhr/MHRP51N0004.svg +0 -0
  816. /package/{assets → src/assets}/images/menu/dhr/MHRP52N0001.svg +0 -0
  817. /package/{assets → src/assets}/images/menu/dhr/MHRP52N0002.svg +0 -0
  818. /package/{assets → src/assets}/images/menu/dhr/MHRP52N0003.svg +0 -0
  819. /package/{assets → src/assets}/images/menu/dhr/MHRP75N0001.svg +0 -0
  820. /package/{assets → src/assets}/images/menu/dhr/MHRP75N0002.svg +0 -0
  821. /package/{assets → src/assets}/images/menu/dhr/MHRP75N0003.svg +0 -0
  822. /package/{assets → src/assets}/images/menu/dhr/MHRP75N0006.svg +0 -0
  823. /package/{assets → src/assets}/images/menu/dhr/MHRP75N0007.svg +0 -0
  824. /package/{assets → src/assets}/images/menu/dhr/MHRP75N0008.svg +0 -0
  825. /package/{assets → src/assets}/images/menu/dhr/MHRP77N0007.svg +0 -0
  826. /package/{assets → src/assets}/images/menu/dhr/MHRP77N0008.svg +0 -0
  827. /package/{assets → src/assets}/images/menu/dhr/MHRP77N0009.svg +0 -0
  828. /package/{assets → src/assets}/images/menu/dhr/MHRP77N0010.svg +0 -0
  829. /package/{assets → src/assets}/images/menu/dhr/MHRP77N0011.svg +0 -0
  830. /package/{assets → src/assets}/images/menu/dhr/MHRP89N1000.svg +0 -0
  831. /package/{assets → src/assets}/images/menu/dhr/MHRP89N1001.svg +0 -0
  832. /package/{assets → src/assets}/images/menu/dhr/TASK.svg +0 -0
  833. /package/{assets → src/assets}/images/menu/dhr/W00F0001.svg +0 -0
  834. /package/{assets → src/assets}/images/menu/dhr/W00F0002.svg +0 -0
  835. /package/{assets → src/assets}/images/menu/dhr/W00F0003.svg +0 -0
  836. /package/{assets → src/assets}/images/menu/dhr/W00F0004.svg +0 -0
  837. /package/{assets → src/assets}/images/menu/dhr/W00F0005.svg +0 -0
  838. /package/{assets → src/assets}/images/menu/dhr/W09F2000-WEB5.svg +0 -0
  839. /package/{assets → src/assets}/images/menu/dhr/W09F2000.svg +0 -0
  840. /package/{assets → src/assets}/images/menu/dhr/W09F2002-WEB5.svg +0 -0
  841. /package/{assets → src/assets}/images/menu/dhr/W09F2005-WEB5.svg +0 -0
  842. /package/{assets → src/assets}/images/menu/dhr/W09F2020-WEB5.svg +0 -0
  843. /package/{assets → src/assets}/images/menu/dhr/W09F2022-WEB5.svg +0 -0
  844. /package/{assets → src/assets}/images/menu/dhr/W09F2150-WEB5.svg +0 -0
  845. /package/{assets → src/assets}/images/menu/dhr/W09F2152-WEB5.svg +0 -0
  846. /package/{assets → src/assets}/images/menu/dhr/W09F2160-WEB5.svg +0 -0
  847. /package/{assets → src/assets}/images/menu/dhr/W09F2162-WEB5.svg +0 -0
  848. /package/{assets → src/assets}/images/menu/dhr/W29F4006-WEB5.svg +0 -0
  849. /package/{assets → src/assets}/images/menu/dhr/W75F2260-WEB5.svg +0 -0
  850. /package/{assets → src/assets}/images/menu/dhr/W75F2261-WEB5.svg +0 -0
  851. /package/{assets → src/assets}/images/menu/dhr/W75F3005-WEB5.svg +0 -0
  852. /package/{assets → src/assets}/images/menu/dhr/W75F4070-WEB5.svg +0 -0
  853. /package/{assets → src/assets}/images/menu/dhr/W75F4071-WEB5.svg +0 -0
  854. /package/{assets → src/assets}/images/menu/dhr/W75F4100-WEB5.svg +0 -0
  855. /package/{assets → src/assets}/images/menu/dhr/W77F1011.svg +0 -0
  856. /package/{assets → src/assets}/images/menu/dhr/W77F1013.svg +0 -0
  857. /package/{assets → src/assets}/images/menu/eo/W00F0001.svg +0 -0
  858. /package/{assets → src/assets}/images/menu/eo/W00F0002.svg +0 -0
  859. /package/{assets → src/assets}/images/menu/eo/W00F0003.svg +0 -0
  860. /package/{assets → src/assets}/images/menu/eo/W00F0004.svg +0 -0
  861. /package/{assets → src/assets}/images/menu/eo/WEO76APP0001.svg +0 -0
  862. /package/{assets → src/assets}/images/menu/eo/WEO76APP0002.svg +0 -0
  863. /package/{assets → src/assets}/images/menu/eo/WEO76LIS0001.svg +0 -0
  864. /package/{assets → src/assets}/images/menu/eo/WEO76LIS0002.svg +0 -0
  865. /package/{assets → src/assets}/images/menu/eo/WEO76LIS0003.svg +0 -0
  866. /package/{assets → src/assets}/images/menu/eo/WEO76LIS0004.svg +0 -0
  867. /package/{assets → src/assets}/images/menu/eo/WEO76LIS0005.svg +0 -0
  868. /package/{assets → src/assets}/images/menu/eo/WEO76LIS0006.svg +0 -0
  869. /package/{assets → src/assets}/images/menu/eo/WEO76LIS0007.svg +0 -0
  870. /package/{assets → src/assets}/images/menu/eo/WEO76REQ0001.svg +0 -0
  871. /package/{assets → src/assets}/images/menu/eo/WEO76REQ0002.svg +0 -0
  872. /package/{assets → src/assets}/images/menu/eo/WEO76REQ0003.svg +0 -0
  873. /package/{assets → src/assets}/images/menu/eo/WEO76TRA0001.svg +0 -0
  874. /package/{assets → src/assets}/images/menu/eo/WTM76ACC0001.svg +0 -0
  875. /package/{assets → src/assets}/images/menu/eo/WTM76INF0001.svg +0 -0
  876. /package/{assets → src/assets}/images/menu/eo/WTM76PRO0001.svg +0 -0
  877. /package/{assets → src/assets}/images/menu/eo/WTM76SYS0001.svg +0 -0
  878. /package/{assets → src/assets}/images/menu/erp/D05.svg +0 -0
  879. /package/{assets → src/assets}/images/menu/erp/D06.svg +0 -0
  880. /package/{assets → src/assets}/images/menu/erp/D90R.svg +0 -0
  881. /package/{assets → src/assets}/images/menu/erp/DBC.svg +0 -0
  882. /package/{assets → src/assets}/images/menu/erp/W00F0001.svg +0 -0
  883. /package/{assets → src/assets}/images/menu/erp/W00F0002.svg +0 -0
  884. /package/{assets → src/assets}/images/menu/erp/W00F0003.svg +0 -0
  885. /package/{assets → src/assets}/images/menu/erp/W00F0004.svg +0 -0
  886. /package/{assets → src/assets}/images/menu/erp/W05F0001.svg +0 -0
  887. /package/{assets → src/assets}/images/menu/erp/W05F0001N0000.svg +0 -0
  888. /package/{assets → src/assets}/images/menu/erp/W05F0004N0000.svg +0 -0
  889. /package/{assets → src/assets}/images/menu/erp/W05F0006N0000.svg +0 -0
  890. /package/{assets → src/assets}/images/menu/erp/W05F0007N0000.svg +0 -0
  891. /package/{assets → src/assets}/images/menu/erp/W05F0008N0000.svg +0 -0
  892. /package/{assets → src/assets}/images/menu/erp/W05F0011N0000.svg +0 -0
  893. /package/{assets → src/assets}/images/menu/erp/W05F0013N0000.svg +0 -0
  894. /package/{assets → src/assets}/images/menu/erp/W05F4000N0000.svg +0 -0
  895. /package/{assets → src/assets}/images/menu/erp/W06F0001.svg +0 -0
  896. /package/{assets → src/assets}/images/menu/erp/W06F0001N0000.svg +0 -0
  897. /package/{assets → src/assets}/images/menu/erp/W06F0004N0000.svg +0 -0
  898. /package/{assets → src/assets}/images/menu/erp/W06F0005N0000.svg +0 -0
  899. /package/{assets → src/assets}/images/menu/erp/W06F0006N0000.svg +0 -0
  900. /package/{assets → src/assets}/images/menu/erp/W06F0008N0000.svg +0 -0
  901. /package/{assets → src/assets}/images/menu/erp/W94F1000N0000.svg +0 -0
  902. /package/{assets → src/assets}/images/menu/erp/W94F1000N0001.svg +0 -0
  903. /package/{assets → src/assets}/images/menu/erp/WA3F1025.svg +0 -0
  904. /package/{assets → src/assets}/images/menu/erp/WA3F2100.svg +0 -0
  905. /package/{assets → src/assets}/storybook/avatar01.svg +0 -0
  906. /package/{assets → src/assets}/storybook/cover01.svg +0 -0
@@ -0,0 +1,1858 @@
1
+ /** @jsxRuntime classic */
2
+ /** @jsx jsx */
3
+ import { css, jsx } from '@emotion/core';
4
+ import {
5
+ Avatar,
6
+ ButtonIcon,
7
+ Checkbox,
8
+ Chip,
9
+ CircularProgress,
10
+ HelperText,
11
+ InputBase,
12
+ Label,
13
+ Popup,
14
+ TreeView,
15
+ Typography,
16
+ } from 'components';
17
+ import Popover from 'components/popover';
18
+ import { getGlobal } from 'global';
19
+ import PropTypes from 'prop-types';
20
+ import {
21
+ Fragment,
22
+ forwardRef,
23
+ memo,
24
+ useEffect,
25
+ useImperativeHandle,
26
+ useLayoutEffect,
27
+ useMemo,
28
+ useRef,
29
+ useState,
30
+ } from 'react';
31
+ import ReactDOM from 'react-dom';
32
+ import {
33
+ animation,
34
+ bgColor,
35
+ border,
36
+ borderBottom,
37
+ borderBottomColor,
38
+ borderColor,
39
+ borderNone,
40
+ borderRadius,
41
+ bottom,
42
+ boxBorder,
43
+ breakWord,
44
+ cursorDefault,
45
+ cursorNotAllowed,
46
+ cursorPointer,
47
+ displayBlock,
48
+ displayFlex,
49
+ fill,
50
+ flexRow,
51
+ flexWrap,
52
+ inset,
53
+ insetX,
54
+ invisible,
55
+ italic,
56
+ itemsCenter,
57
+ justifyCenter,
58
+ justifyStart,
59
+ outlineNone,
60
+ overflowAuto,
61
+ overflowHidden,
62
+ parseHeight,
63
+ parseMaxHeight,
64
+ parseMaxWidth,
65
+ parseMinHeight,
66
+ parseWidth,
67
+ parseWidthHeight,
68
+ pointerEventsNone,
69
+ positionAbsolute,
70
+ positionRelative,
71
+ textColor,
72
+ top,
73
+ userSelectNone,
74
+ z,
75
+ } from 'styles/general';
76
+ import { useTheme } from 'theme';
77
+ import useThemeProps from 'theme/utils/useThemeProps';
78
+ import { classNames, getProp, isMobile, randomString } from 'utils';
79
+
80
+ const currentValue = {},
81
+ isSearch = {},
82
+ allValue = {};
83
+ const separatorPattern = /\{\w+\}/g;
84
+ const regexBetween = /[^{}]+(?=})/g;
85
+ const regexInclude = /{|}/g;
86
+
87
+ const checkHasValue = value => {
88
+ return Array.isArray(value) ? value.length > 0 : value === 0 || !!value;
89
+ };
90
+
91
+ const convertData = (dt, valueExpr) => {
92
+ let data = dt || [];
93
+ let valueTemp = Array.isArray(data) ? data : [data];
94
+ valueTemp = valueTemp.map(i => i[valueExpr] || i);
95
+ return valueTemp;
96
+ };
97
+
98
+ const convertSearchDelayTime = searchDelayTime => {
99
+ if (searchDelayTime === true) return getGlobal('delayOnInput');
100
+
101
+ const units = {
102
+ m: 60000,
103
+ s: 1000,
104
+ ms: 1,
105
+ };
106
+ return typeof searchDelayTime === 'number'
107
+ ? searchDelayTime
108
+ : (searchDelayTime.match(/[^a-z]+/i)?.[0] || 1) * units[searchDelayTime.match(/ms|s|m/i)?.[0] || 's'];
109
+ };
110
+
111
+ const uniqBy = (arr, iteratee) => {
112
+ const seen = new Set();
113
+ return arr.filter(item => {
114
+ const val = iteratee(item);
115
+ if (seen.has(val)) {
116
+ return false;
117
+ }
118
+ seen.add(val);
119
+ return true;
120
+ });
121
+ };
122
+
123
+ const Dropdown = memo(
124
+ forwardRef((inProps, reference) => {
125
+ if (!reference) reference = useRef(null);
126
+
127
+ const theme = useTheme();
128
+ const { spacing } = theme;
129
+
130
+ // props priority: `inProps` > `themeDefaultProps`
131
+ const props = useThemeProps({ props: inProps, name: 'Dropdown' });
132
+ const {
133
+ action = {},
134
+ allowSearch,
135
+ children,
136
+ className,
137
+ clearAble,
138
+ closeAfterSelect,
139
+ dataSource,
140
+ displayExpr: displayExprProp,
141
+ dropdownItemStyle,
142
+ error,
143
+ helperTextProps,
144
+ iconExpr,
145
+ inputProps,
146
+ inputStyle,
147
+ itemMode,
148
+ label,
149
+ labelProps,
150
+ limit,
151
+ loading,
152
+ maximumSelectionLength,
153
+ multilineSelectedItem,
154
+ multiple,
155
+ noDataText: noDataTextProp,
156
+ onChange,
157
+ onClosed,
158
+ onInput,
159
+ onKeyDown,
160
+ onLoadMore,
161
+ placeholder: placeholderProp,
162
+ readOnly,
163
+ renderItem,
164
+ renderSelectedItem,
165
+ required,
166
+ searchDelayTime: searchDelayTimeProp,
167
+ searchExpr: searchExprProp,
168
+ searchMode,
169
+ selectBox: selectBoxProp,
170
+ skip,
171
+ style,
172
+ subText,
173
+ total,
174
+ treeViewID,
175
+ treeViewParentID,
176
+ value: valueProp,
177
+ valueExpr,
178
+ valueObjectDefault,
179
+ viewType,
180
+ defaultValue,
181
+ disabled,
182
+ } = props;
183
+
184
+ const selectBox = multiple && selectBoxProp === undefined ? true : selectBoxProp;
185
+ const searchExpr = typeof searchExprProp === 'string' ? [searchExprProp] : searchExprProp;
186
+ const searchDelayTime = convertSearchDelayTime(
187
+ searchDelayTimeProp === undefined ? getGlobal('delayOnInput') : searchDelayTimeProp
188
+ );
189
+ let displayExpr = displayExprProp;
190
+
191
+ const noDataText = noDataTextProp || getGlobal('noDataText');
192
+ const placeholder = placeholderProp || getGlobal('dropdownPlaceholder');
193
+
194
+ const ref = useRef(null);
195
+ const dropdownRef = useRef(null);
196
+ const timer = useRef(null);
197
+ const timerRef = useRef(null);
198
+ const formRef = useRef(null);
199
+ const inputRef = useRef(null);
200
+ const iconRef = useRef(null);
201
+ const dropdownListRef = useRef(null);
202
+ const searchRef = useRef(null);
203
+ const loadMoreTimer = useRef(null);
204
+ const dataChosen = useRef([]);
205
+ const popupRef = useRef(null);
206
+ const filter = useRef({
207
+ skip: skip || 0,
208
+ limit: limit || 50,
209
+ });
210
+
211
+ const [unique] = useState(randomString(6, { allowNumber: false, allowSymbol: false }));
212
+ const [openState, setOpenState] = useState(false);
213
+ const [showClear, setShowClear] = useState(false);
214
+ const [valueSingle, setValueSingle] = useState('');
215
+ const [txtSearch, setTxtSearch] = useState('');
216
+ const [popoverWidth, setPopoverWidth] = useState(0);
217
+ const [loadingState, setLoadingState] = useState(loading);
218
+ const [totalState, setTotalState] = useState(total);
219
+ const [dataSourceState, setDataSourceState] = useState(dataSource || []);
220
+ const [popupDataState, setPopupDataState] = useState({
221
+ title: '',
222
+ substitle: '',
223
+ description: '',
224
+ });
225
+ const [vlObjDefaultState, setVlObjDefaultState] = useState([]);
226
+
227
+ let valueTemp = valueProp || defaultValue || [];
228
+
229
+ // only mode multi
230
+ if (multiple) {
231
+ valueTemp = convertData(valueTemp, valueExpr);
232
+ }
233
+ const [valueMulti, setValueMulti] = useState(valueTemp);
234
+
235
+ const _isMobile = isMobile.any();
236
+
237
+ const _InputCSS = InputCSS(multiple, typeof renderSelectedItem === 'function');
238
+ const _DropdownInputCSS = DropdownInputCSS(
239
+ viewType,
240
+ multiple,
241
+ placeholder,
242
+ disabled,
243
+ readOnly,
244
+ multilineSelectedItem,
245
+ theme
246
+ );
247
+ const _IconCSS = IconCSS(viewType, theme);
248
+ const _DropdownFormCSS =
249
+ viewType === 'outlined'
250
+ ? DropdownFormOutlinedCSS(disabled, readOnly, placeholder, theme)
251
+ : DropdownFormCSS(viewType, multiple, disabled, readOnly, placeholder, _DropdownInputCSS.name, theme);
252
+ const _DropdownListCSS = DropdownListCSS(loadingState, theme);
253
+ const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox, theme);
254
+ const _DropdownRootCSS = DropdownRootCSS(_DropdownFormCSS.name, _DropdownInputCSS.name, theme);
255
+ const _CheckBoxCSS = CheckBoxCSS(theme);
256
+
257
+ /* Start handler */
258
+ const setShowDropdown = () => {
259
+ setOpenState(!openState);
260
+ };
261
+
262
+ const triggerBlur = (blur = true) => {
263
+ if ((currentValue[unique] || currentValue[unique] === 0) && !multiple) {
264
+ setValueIntoInput(currentValue[unique]);
265
+ } else if (!multiple) {
266
+ setValueIntoInput('');
267
+ }
268
+ !!blur && inputRef.current.blur();
269
+ };
270
+
271
+ const onClickInput = e => {
272
+ if (disabled || readOnly || loadingState) return;
273
+ if (!dropdownListRef.current) {
274
+ if (
275
+ !multiple ||
276
+ !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item =>
277
+ item.contains(e?.target)
278
+ )
279
+ ) {
280
+ setOpenState(true);
281
+ }
282
+ }
283
+ };
284
+
285
+ const showDropdown = () => {
286
+ const dropdown = children ? (
287
+ <div
288
+ css={_DropdownListCSS}
289
+ ref={dropdownListRef}
290
+ className={'DGN-Dropdown-List'}
291
+ onKeyDown={moveOnItem}
292
+ onScroll={onLoadMoreHandler}
293
+ tabIndex={-1}
294
+ >
295
+ {dataSourceState?.length ? children : EmptyDataText}
296
+ </div>
297
+ ) : itemMode === 'normal' ? (
298
+ mapDropdown()
299
+ ) : (
300
+ mapTreeView()
301
+ );
302
+
303
+ return (
304
+ <Fragment>
305
+ {(multiple || allowSearch) && itemMode === 'normal' && !children ? (
306
+ <div className={'DGN-Dropdown-Search'}>
307
+ <InputBase
308
+ inputRef={searchRef}
309
+ delayOnChange={searchDelayTime}
310
+ viewType={'outlined'}
311
+ defaultValue={txtSearch}
312
+ onChange={onChangeInput}
313
+ style={{ marginBottom: 1 }}
314
+ onKeyDown={pressESCHandler}
315
+ readOnly={loadingState}
316
+ autoFocus
317
+ />
318
+ </div>
319
+ ) : null}
320
+ {multiple && maximumSelectionLength ? (
321
+ <Typography
322
+ css={css`
323
+ padding: ${spacing([2, 4])};
324
+ `}
325
+ >
326
+ {getGlobal('selected')} {valueMulti?.length || 0}/{maximumSelectionLength}
327
+ </Typography>
328
+ ) : null}
329
+ <div className={'DGN-Dropdown-Box'}>{dropdown}</div>
330
+ {loadingState ? (
331
+ <div css={LoadingProgressCSS} className={'DGN-Dropdown-Loading-Progress'}>
332
+ <CircularProgress size={24} />
333
+ </div>
334
+ ) : null}
335
+ </Fragment>
336
+ );
337
+ };
338
+
339
+ const moveOnItem = e => {
340
+ if (e.key === 'Tab') {
341
+ closeDropdown(e, `key${e.key}`);
342
+ triggerBlur();
343
+ }
344
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
345
+ let activeEl = document.activeElement;
346
+ activeEl = e.key === 'ArrowDown' ? activeEl.nextElementSibling : activeEl.previousElementSibling;
347
+ if (activeEl) {
348
+ activeEl.focus();
349
+ activeEl.scrollIntoView({
350
+ block: 'center',
351
+ behavior: 'smooth',
352
+ });
353
+ }
354
+ }
355
+ };
356
+
357
+ const pressESCHandler = e => {
358
+ if (e.key === 'Tab') {
359
+ closeDropdown(e, `key${e.key}`);
360
+ triggerBlur();
361
+ } else if (e.key === 'ArrowDown' && dropdownListRef.current) {
362
+ e.preventDefault();
363
+ dropdownListRef.current.firstChild.focus();
364
+ }
365
+ };
366
+
367
+ const closeDropdown = (event, reason, value) => {
368
+ if (dropdownRef.current) {
369
+ setOpenState(false);
370
+ }
371
+ onClosed?.({
372
+ event,
373
+ reason,
374
+ recentSearch: searchRef.current?.value,
375
+ value,
376
+ });
377
+ };
378
+
379
+ /**
380
+ * So sánh text đầu vào cáo map với txtSearch
381
+ * @param text
382
+ * @return {boolean}
383
+ */
384
+ const handleRenderBySearch = (text = '') => {
385
+ if (typeof text !== 'string') text = text.toString();
386
+ if (!txtSearch) return true;
387
+ if (searchMode === 'startswith') {
388
+ return text.toLowerCase().startsWith(txtSearch.toLowerCase());
389
+ } else if (searchMode === 'equals') {
390
+ return text.toLowerCase() === txtSearch.toLowerCase();
391
+ } else return text.toLowerCase().includes(txtSearch.toLowerCase());
392
+ };
393
+
394
+ /**
395
+ * Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
396
+ * @param data {object} rowData of dataSource
397
+ * @return {string}
398
+ */
399
+ const displayValue = data => {
400
+ let text = '';
401
+ if (data || data === 0) {
402
+ displayExpr = displayExpr || valueExpr;
403
+
404
+ let mask = data?.[displayExpr];
405
+ // convert {id} - {name} to {<data[id]>} - {<data[name]>}
406
+ if (!mask && regexBetween.test(displayExpr)) {
407
+ mask = displayExpr?.replace(regexBetween, _ => data?.[_] || '');
408
+ } else if (!mask) {
409
+ mask = typeof data !== 'object' ? data : '';
410
+ }
411
+ text = mask.toString().replace(regexInclude, '');
412
+ }
413
+ return text;
414
+ };
415
+
416
+ const mapDropdown = () => {
417
+ const items = [];
418
+ let dataSourceUsable = [...dataSourceState];
419
+
420
+ // search dataSource dựa trên txtSearch
421
+ if (!onInput || action?.loadData) {
422
+ dataSourceUsable = dataSourceUsable?.filter(i => {
423
+ if (searchExpr) {
424
+ // nếu map đc vs 1 trong những <key>(data[key]) của searchExpr
425
+ return !!searchExpr.find(j => handleRenderBySearch(i[j]));
426
+ } else {
427
+ // nếu map đc vs displayValue
428
+ return handleRenderBySearch(displayValue(i)) || handleRenderBySearch(i?.[valueExpr]);
429
+ }
430
+ });
431
+ }
432
+
433
+ if (vlObjDefaultState && vlObjDefaultState?.length) {
434
+ const length = vlObjDefaultState?.length;
435
+ let existItemQuantity = 0;
436
+ for (let index = length - 1; index >= 0; index--) {
437
+ if (
438
+ (vlObjDefaultState[index][valueExpr] || vlObjDefaultState[index][valueExpr] === 0) &&
439
+ !dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])
440
+ ) {
441
+ dataSourceUsable.unshift(vlObjDefaultState[index]);
442
+ } else {
443
+ // Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
444
+ if (++existItemQuantity > limit) {
445
+ continue;
446
+ }
447
+ }
448
+ }
449
+ }
450
+ const length = dataSourceUsable?.length;
451
+ for (let index = 0; index < length; index++) {
452
+ const data = dataSourceUsable[index];
453
+ if (!data) continue;
454
+ const itemHidden = typeof data === 'object' ? data['hidden'] : false;
455
+ if (itemHidden) continue;
456
+ let displayText = displayValue(data);
457
+
458
+ if (subText) {
459
+ displayText = (
460
+ <Fragment>
461
+ <Typography className={'DGN-UI-Dropdown-PrimaryText'} type={'p1'}>
462
+ {displayText}
463
+ </Typography>
464
+ <Typography className={'DGN-UI-Dropdown-SubText'} type={'p3'} color={'text/sub'}>
465
+ {typeof subText === 'function' ? subText({ data, index }) : data[subText] || subText}
466
+ </Typography>
467
+ </Fragment>
468
+ );
469
+ }
470
+ const value = typeof data === 'object' ? data[valueExpr] : data;
471
+ let itemDisabled = typeof data === 'object' ? data['disabled'] : false;
472
+ const icon = getIconFromData(data);
473
+ const text =
474
+ renderItem && typeof renderItem === 'function' ? (
475
+ renderItem({ data, index })
476
+ ) : (
477
+ <Typography type={'p1'}>{displayText}</Typography>
478
+ );
479
+ if (multiple && selectBox) {
480
+ const checked = Array.isArray(valueMulti) ? valueMulti.includes(value) : valueMulti.includes(value);
481
+ const isMaximumSelection = maximumSelectionLength === valueMulti?.length;
482
+ itemDisabled = itemDisabled || (isMaximumSelection && !checked);
483
+ items.push(
484
+ <div
485
+ key={index}
486
+ css={!itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS]}
487
+ className={'DGN-UI-Dropdown-Item'}
488
+ onKeyDown={e => {
489
+ if (itemDisabled) return;
490
+ if (e.key === 'Enter') e.currentTarget.firstChild.click();
491
+ }}
492
+ tabIndex={-1}
493
+ >
494
+ <Checkbox
495
+ css={_CheckBoxCSS}
496
+ forTreeView
497
+ checked={checked}
498
+ value={value}
499
+ disabled={itemDisabled}
500
+ onChange={e => onChangeValue(e, displayText, value, icon, data, index)}
501
+ >
502
+ {icon}
503
+ {text}
504
+ </Checkbox>
505
+ </div>
506
+ );
507
+ } else {
508
+ items.push(
509
+ <div
510
+ key={index}
511
+ css={!itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS]}
512
+ className={'DGN-UI-Dropdown-Item'}
513
+ onClick={e => {
514
+ if (itemDisabled) return;
515
+ onChangeValue(e, displayText, value, icon, data, index);
516
+ }}
517
+ onKeyDown={e => {
518
+ if (itemDisabled) return;
519
+ if (e.key === 'Enter') onChangeValue(e, displayText, value, icon, data, index);
520
+ }}
521
+ tabIndex={-1}
522
+ style={dropdownItemStyle}
523
+ >
524
+ {icon}
525
+ {text}
526
+ </div>
527
+ );
528
+ }
529
+ }
530
+ return (
531
+ <div
532
+ css={_DropdownListCSS}
533
+ ref={dropdownListRef}
534
+ className={'DGN-Dropdown-List'}
535
+ onKeyDown={moveOnItem}
536
+ onScroll={onLoadMoreHandler}
537
+ tabIndex={-1}
538
+ >
539
+ {items?.length ? items : EmptyDataText}
540
+ </div>
541
+ );
542
+ };
543
+
544
+ const mapTreeView = () => {
545
+ return (
546
+ <div
547
+ css={_DropdownListCSS}
548
+ ref={dropdownListRef}
549
+ className={'DGN-Dropdown-List'}
550
+ onKeyDown={moveOnItem}
551
+ onScroll={onLoadMoreHandler}
552
+ tabIndex={-1}
553
+ >
554
+ {dataSourceState?.length ? (
555
+ <TreeView
556
+ dataSource={dataSourceState}
557
+ displayExpr={displayExpr}
558
+ valueExpr={valueExpr}
559
+ multiple={multiple}
560
+ selectBox={selectBox}
561
+ allowSearch={allowSearch}
562
+ searchProps={{ autoFocus: true, inputRef: searchRef }}
563
+ searchDelayTime={searchDelayTime}
564
+ id={treeViewID}
565
+ parentID={treeViewParentID}
566
+ value={
567
+ typeof currentValue[unique] === 'string' ? [currentValue[unique]] : currentValue[unique]
568
+ }
569
+ onChange={(e, value) => onChangeValue(e, '', multiple ? value : e.value)}
570
+ renderItem={renderItem}
571
+ />
572
+ ) : (
573
+ EmptyDataText
574
+ )}
575
+ </div>
576
+ );
577
+ };
578
+
579
+ // remove item cũ và append child item mới khi load more
580
+ const loadMoreItemsDropdown = (i = 0, pattern) => {
581
+ const dataSourceUsable = [...dataSourceState];
582
+ // Nếu có load more thì đẩy đội tượng mặc định lên đầu
583
+ let notExistItem = 0;
584
+ if (onLoadMore && vlObjDefaultState?.length) {
585
+ const length = vlObjDefaultState.length;
586
+ for (let index = length - 1; index >= 0; index--) {
587
+ if (!dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
588
+ notExistItem++;
589
+ dataSourceUsable.unshift(vlObjDefaultState[index]);
590
+ }
591
+ }
592
+ }
593
+ const length = dataSourceUsable?.length;
594
+ let num = 0;
595
+ if (displayExpr && Array.isArray(displayExpr)) {
596
+ displayExpr = displayExpr.join(' - ');
597
+ }
598
+ const keyArr = displayExpr?.match(separatorPattern);
599
+ for (i; i < length; i++) {
600
+ const data = { ...dataSourceUsable[i] };
601
+ // Nếu đối tượng đã được hiển thị ở trên rồi thì không hiển thị ra nữa
602
+ if (
603
+ onLoadMore &&
604
+ i > notExistItem &&
605
+ vlObjDefaultState.some(valueObject => valueObject[valueExpr] === data[valueExpr])
606
+ )
607
+ continue;
608
+ let displayText =
609
+ typeof data === 'object'
610
+ ? keyArr
611
+ ? displayValue(data)
612
+ : data[displayExpr] || data[valueExpr]
613
+ : data;
614
+ if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
615
+ const value = typeof data === 'object' ? data[valueExpr] : data;
616
+ const icon = getIconFromData(data);
617
+ const text = <Typography type={'p1'}>{displayText}</Typography>;
618
+ if (renderItem && typeof renderItem === 'function') {
619
+ displayText = renderItem({ data, index: i });
620
+ } else if (subText) {
621
+ displayText = (
622
+ <Fragment>
623
+ <Typography className={'DGN-UI-Dropdown-PrimaryText'} type={'p1'}>
624
+ {displayText}
625
+ </Typography>
626
+ <Typography className={'DGN-UI-Dropdown-SubText'} type={'p3'} color={'text/sub'}>
627
+ {typeof subText === 'function' ? subText({ data, index: i }) : data[subText] || subText}
628
+ </Typography>
629
+ </Fragment>
630
+ );
631
+ }
632
+ const dropdownItem = document.createElement('div');
633
+ dropdownItem.className = `DGN-UI-Dropdown-Item css-${_DropdownItemCSS.name}`;
634
+ dropdownItem.tabIndex = -1;
635
+ dropdownItem.addEventListener('click', e => onChangeValue(e, displayText, value, icon, data, i));
636
+ dropdownItem.addEventListener('keypress', e => {
637
+ if (e.key === 'Enter') dropdownItem.firstChild.click();
638
+ });
639
+ let item = null;
640
+ if (multiple && selectBox) {
641
+ const checked = Array.isArray(currentValue[unique])
642
+ ? currentValue[unique].includes(value)
643
+ : [currentValue[unique]].includes(value);
644
+ item = (
645
+ <Checkbox css={_CheckBoxCSS} forTreeView checked={checked}>
646
+ {icon}
647
+ {text}
648
+ </Checkbox>
649
+ );
650
+ } else {
651
+ item = (
652
+ <Fragment>
653
+ {icon}
654
+ {text}
655
+ </Fragment>
656
+ );
657
+ }
658
+ if (!dropdownListRef.current) {
659
+ return;
660
+ }
661
+ ReactDOM.render(item, dropdownListRef.current.appendChild(dropdownItem));
662
+ if (++num === 100) {
663
+ timerRef.current = setTimeout(() => {
664
+ loadMoreItemsDropdown(i + 1, pattern);
665
+ }, 1000);
666
+ break;
667
+ }
668
+ }
669
+ };
670
+
671
+ const getIconFromData = (data, insideChip = false) => {
672
+ if (!data || !iconExpr || iconExpr === 'none') return null;
673
+ let _src;
674
+ if (typeof iconExpr === 'string') _src = data[iconExpr];
675
+ else {
676
+ let prefix = iconExpr.prefix || '';
677
+ const suffix = iconExpr.suffix || '';
678
+ const url = data[iconExpr.key];
679
+ if (prefix && /^http/i.test(prefix) && /^http/i.test(url)) {
680
+ prefix = '';
681
+ }
682
+ _src = prefix + url + suffix;
683
+ }
684
+ return (
685
+ <Avatar
686
+ css={css`
687
+ margin-right: ${spacing([insideChip ? 0 : 2])};
688
+ `}
689
+ disabled
690
+ src={_src}
691
+ width={insideChip ? 20 : 24}
692
+ height={insideChip ? 20 : 24}
693
+ style={{ ...iconExpr.style }}
694
+ />
695
+ );
696
+ };
697
+
698
+ const customizeWidthDropdown = () => {
699
+ if (timer.current) {
700
+ clearTimeout(timer.current);
701
+ }
702
+ timer.current = setTimeout(() => {
703
+ if (ref.current) {
704
+ const { width } = ref.current.getBoundingClientRect();
705
+ setPopoverWidth(width);
706
+ }
707
+ }, 300);
708
+ };
709
+
710
+ const handleActionLoadData = isReset => {
711
+ const { skip, limit, strSearch: search } = filter.current;
712
+
713
+ const params = onLoadMore
714
+ ? {
715
+ skip,
716
+ limit,
717
+ search,
718
+ }
719
+ : { search };
720
+
721
+ const callbackSave = (error, data) => {
722
+ setLoadingState(false);
723
+ if (error) {
724
+ let _data = {};
725
+ if (error.originalError) {
726
+ const { message, originalError, customMessage, code: codeError } = error;
727
+ const _customMessage =
728
+ customMessage && typeof customMessage === 'object'
729
+ ? customMessage[codeError]
730
+ : customMessage;
731
+ let messageError = '';
732
+ Object.keys(originalError).forEach(key => {
733
+ messageError += `${key}: ${JSON.stringify(originalError[key], null, 8)}\n`;
734
+ });
735
+ _data = {
736
+ title: getGlobal('error') + (codeError ? `: ${codeError}` : ''),
737
+ subtitle: _customMessage || message || getGlobal('unknownError'),
738
+ description: messageError,
739
+ };
740
+ } else {
741
+ const message = data?.message || data?.data?.Message || data;
742
+ _data = {
743
+ description: message || getGlobal('unknownError'),
744
+ };
745
+ }
746
+ setPopupDataState(_data);
747
+ popupRef.current.instance.show();
748
+ return false;
749
+ } else if (data) {
750
+ let rows = [];
751
+ if (Array.isArray(data)) {
752
+ rows = data;
753
+ } else {
754
+ rows = data && data.rows ? data.rows : dataSourceState;
755
+ const total = data && data.total ? data.total : data?.length;
756
+ setTotalState(total);
757
+ }
758
+ setDataSourceState(isReset ? rows : dataSourceState.concat(rows));
759
+ }
760
+ };
761
+
762
+ setLoadingState(true);
763
+ action.loadData(params, callbackSave);
764
+ };
765
+
766
+ const onLoadMoreHandler = e => {
767
+ e.persist();
768
+ if (loadMoreTimer.current) {
769
+ clearTimeout(loadMoreTimer.current);
770
+ }
771
+ loadMoreTimer.current = setTimeout(() => {
772
+ if (onLoadMore && dataSourceState?.length < totalState && !loadingState) {
773
+ const { scrollTop, scrollHeight, offsetHeight } = e.target;
774
+ if (scrollHeight === Math.ceil(scrollTop) + offsetHeight && dropdownListRef.current) {
775
+ const length = dropdownListRef.current.children?.length - (vlObjDefaultState?.length || 0);
776
+ // dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
777
+ if (!!onLoadMore && typeof onLoadMore === 'boolean' && action?.loadData) {
778
+ filter.current.skip = length;
779
+ filter.current.limit = limit;
780
+ handleActionLoadData();
781
+ } else !!onLoadMore && onLoadMore({ skip: length, limit: limit });
782
+ }
783
+ }
784
+ }, 300);
785
+ };
786
+
787
+ const onPreventKeyDownHandler = e => {
788
+ e.preventDefault();
789
+ return false;
790
+ };
791
+
792
+ const onChangeInput = e => {
793
+ if (!dropdownRef.current) return; // Kiểm tra nếu dropdown đóng trước searchDelayTime thì không chạy
794
+ setTxtSearch(e.target.value ?? '');
795
+ if (onInput) {
796
+ onInput(e);
797
+ }
798
+ if (action?.loadData && !!onLoadMore) {
799
+ filter.current.strSearch = e.target.value;
800
+ handleActionLoadData(true);
801
+ }
802
+ };
803
+
804
+ const onChangeValue = (e, displayText, value, icon, data) => {
805
+ if (itemMode === 'treeview') {
806
+ if (valueProp === undefined) {
807
+ setValueMulti(value);
808
+ setValueIntoInput(value);
809
+ setShowClear(clearAble && checkHasValue(value) && !disabled && !readOnly && !loadingState);
810
+ }
811
+ !!onChange && onChange({ value });
812
+ } else if (multiple) {
813
+ if (!Array.isArray(currentValue[unique])) currentValue[unique] = [];
814
+ // const newValueArr = [...currentValue[unique]];
815
+ const newValueArrState = [...valueMulti];
816
+ if (!newValueArrState.some(v => JSON.stringify(v) === JSON.stringify(value))) {
817
+ // newValueArr.push(value);
818
+ newValueArrState.push(value);
819
+ } else {
820
+ const index = newValueArrState.indexOf(value);
821
+ newValueArrState.splice(index, 1);
822
+ }
823
+ setValueMulti(newValueArrState);
824
+ !!onChange && onChange({ value: newValueArrState, data });
825
+ } else {
826
+ const isChanged = currentValue[unique] !== value;
827
+ if (isChanged) {
828
+ if (valueProp === undefined) {
829
+ allValue[unique].push(value);
830
+ setValueIntoInput(value);
831
+ setShowClear(clearAble && checkHasValue(value) && !disabled && !readOnly && !loading);
832
+ }
833
+ !!onChange && onChange({ value, data });
834
+ } else {
835
+ // Fix lost icon when select same value
836
+ triggerBlur(false);
837
+ }
838
+ }
839
+ if (closeAfterSelect === true || (closeAfterSelect === undefined && !multiple)) {
840
+ closeDropdown(e, 'changeValue', value);
841
+ }
842
+ };
843
+
844
+ const onRemove = (e, value) => {
845
+ if (readOnly || disabled) return;
846
+ const index = currentValue[unique].findIndex(v => JSON.stringify(v) === JSON.stringify(value));
847
+ if (index !== -1) {
848
+ currentValue[unique].splice(index, 1);
849
+ }
850
+
851
+ // logic mới
852
+ const newValueArrState = [...valueMulti]?.filter(i => i !== value) || [];
853
+ setValueMulti(newValueArrState);
854
+ !!onChange && onChange({ value: newValueArrState, removed: value });
855
+ };
856
+
857
+ const onClear = e => {
858
+ if (disabled || readOnly || loadingState || !clearAble) return;
859
+ currentValue[unique] = multiple ? [] : '';
860
+ if (multiple) {
861
+ setValueMulti([]);
862
+ } else {
863
+ setValueSingle('');
864
+ }
865
+ setValueMulti([]);
866
+ setShowClear(false);
867
+ e && e.target && e.target.blur();
868
+ onInput?.({ ...inputRef?.current, target: { value: '' } });
869
+ !!onChange && onChange({ value: currentValue[unique] });
870
+ };
871
+
872
+ const setPreviousValue = () => {
873
+ allValue[unique].pop();
874
+ setValueIntoInput(allValue[unique][allValue[unique]?.length - 1]);
875
+ };
876
+
877
+ const setValueIntoInput = source => {
878
+ if (!source && source !== 0) {
879
+ if (multiple) {
880
+ currentValue[unique] = [];
881
+ } else {
882
+ currentValue[unique] = '';
883
+ setValueSingle('');
884
+ }
885
+ return;
886
+ }
887
+ const length = dataSourceState?.length;
888
+ const displayKey = typeof renderSelectedItem === 'string' ? renderSelectedItem : displayExpr;
889
+ if (displayKey && Array.isArray(displayKey)) {
890
+ displayExpr = displayExpr.join(' - ');
891
+ }
892
+ const keyArr = displayKey?.match(separatorPattern);
893
+ if (multiple) {
894
+ let valueArr = source;
895
+ if (!Array.isArray(valueArr)) {
896
+ valueArr = [valueArr];
897
+ }
898
+ valueArr = [...new Set(valueArr)];
899
+ currentValue[unique] = [];
900
+ valueArr.forEach(v => {
901
+ for (let i = 0; i < length; i++) {
902
+ if (!dataSourceState[i]) continue;
903
+ if (
904
+ (typeof dataSourceState[i] === 'object' && dataSourceState[i][valueExpr] === v) ||
905
+ dataSourceState[i] === v
906
+ ) {
907
+ setMultipleValueHandler(dataSourceState[i], v, keyArr, i);
908
+ return;
909
+ }
910
+ }
911
+ if (vlObjDefaultState?.length) {
912
+ const itemOfValue = vlObjDefaultState.find(
913
+ valueObject => valueObject[valueExpr] === v || valueObject === v
914
+ );
915
+ if (itemOfValue) {
916
+ setMultipleValueHandler(itemOfValue, v, keyArr);
917
+ }
918
+ }
919
+ });
920
+ } else {
921
+ currentValue[unique] = source;
922
+ for (let i = 0; i < length; i++) {
923
+ if (!dataSourceState[i]) continue;
924
+ if (dataSourceState[i][valueExpr] === source || dataSourceState[i] === source) {
925
+ setSingleValueHandler(dataSourceState[i], keyArr);
926
+ return;
927
+ }
928
+ }
929
+ if (vlObjDefaultState?.length) {
930
+ const itemOfValue = vlObjDefaultState.find(
931
+ valueObject => valueObject[valueExpr] === source || valueObject === source
932
+ );
933
+ if (itemOfValue) {
934
+ setSingleValueHandler(itemOfValue, keyArr);
935
+ return;
936
+ }
937
+ }
938
+ }
939
+ };
940
+
941
+ const setMultipleValueHandler = (data, value) => {
942
+ currentValue[unique].push(value);
943
+ };
944
+
945
+ const setSingleValueHandler = (data, keyArr) => {
946
+ const text = keyArr
947
+ ? displayValue(data)
948
+ : typeof renderSelectedItem === 'string'
949
+ ? data[renderSelectedItem]
950
+ : data[displayExpr] || data[valueExpr] || data;
951
+
952
+ const renderContent = content => (
953
+ <Typography type={'p1'} lineClamp={multilineSelectedItem ? undefined : 1} hoverTooltip={!_isMobile}>
954
+ {content}
955
+ </Typography>
956
+ );
957
+ if (typeof renderSelectedItem === 'function') {
958
+ const item = renderSelectedItem({ data });
959
+ const el = (
960
+ <div
961
+ css={[
962
+ displayFlex,
963
+ parseWidth('100%'),
964
+ parseMinHeight(24),
965
+ !multilineSelectedItem && parseMaxHeight(24),
966
+ ]}
967
+ >
968
+ {item}
969
+ </div>
970
+ );
971
+ setValueSingle(el);
972
+ } else if (iconExpr && iconExpr !== 'none') {
973
+ const icon = getIconFromData(data);
974
+ const valueWithIcon = (
975
+ <Fragment>
976
+ {icon ? icon : null}
977
+ {renderContent(text)}
978
+ </Fragment>
979
+ );
980
+ const el = <div css={[displayFlex, itemsCenter, parseMinHeight(24)]}>{valueWithIcon}</div>;
981
+ setValueSingle(el);
982
+ } else {
983
+ setValueSingle(text);
984
+ }
985
+ };
986
+
987
+ useImperativeHandle(reference, () => {
988
+ const currentRef = ref.current || {};
989
+ const _instance = {
990
+ ...action,
991
+ closeDropdown: () => {
992
+ closeDropdown(null, 'ref');
993
+ },
994
+ showDropdown: () => {
995
+ setOpenState(true);
996
+ },
997
+ onClear,
998
+ setPreviousValue,
999
+ setValue: value => {
1000
+ if (allValue[unique][allValue[unique]?.length - 1] !== value) {
1001
+ allValue[unique].push(value);
1002
+ }
1003
+ setValueIntoInput(value);
1004
+ },
1005
+ }; // methods
1006
+ _instance.__proto__ = {}; // hidden methods
1007
+ currentRef.instance = _instance;
1008
+ // keep old method
1009
+ currentRef.closeDropdown = () => closeDropdown(null, 'ref');
1010
+ currentRef.showDropdown = () => setOpenState(true);
1011
+ currentRef.onClear = onClear;
1012
+ currentRef.setPreviousValue = setPreviousValue;
1013
+ currentRef.setValue = value => {
1014
+ if (allValue[unique][allValue[unique]?.length - 1] !== value) {
1015
+ allValue[unique].push(value);
1016
+ }
1017
+ setValueIntoInput(value);
1018
+ };
1019
+ currentRef.DOM = ref.current;
1020
+ return currentRef;
1021
+ });
1022
+
1023
+ useLayoutEffect(() => {
1024
+ window.addEventListener('resize', customizeWidthDropdown);
1025
+ return () => {
1026
+ window.removeEventListener('resize', customizeWidthDropdown);
1027
+ };
1028
+ }, []);
1029
+
1030
+ useEffect(() => {
1031
+ setLoadingState(loading);
1032
+ }, [loading]);
1033
+
1034
+ useEffect(() => {
1035
+ setTotalState(total);
1036
+ }, [total]);
1037
+
1038
+ useEffect(() => {
1039
+ setDataSourceState(dataSource || []);
1040
+ }, [dataSource]);
1041
+
1042
+ useEffect(() => {
1043
+ setShowClear(
1044
+ clearAble && checkHasValue(valueProp ?? defaultValue) && !disabled && !readOnly && !loadingState
1045
+ );
1046
+ }, [clearAble, valueProp, defaultValue, disabled, readOnly, loadingState]);
1047
+
1048
+ useEffect(() => {
1049
+ if (multiple) {
1050
+ if (valueMulti?.length) {
1051
+ const dataFilter = getData();
1052
+ dataChosen.current = [...dataFilter].filter(i => [...valueMulti].includes(i?.[valueExpr]));
1053
+ } else dataChosen.current = [];
1054
+ }
1055
+ if (valueObjectDefault) {
1056
+ if (Array.isArray(valueObjectDefault)) {
1057
+ setVlObjDefaultState([...dataChosen.current, ...valueObjectDefault]);
1058
+ } else if (typeof valueObjectDefault === 'object') {
1059
+ setVlObjDefaultState(
1060
+ Object.keys(valueObjectDefault)?.length !== 0
1061
+ ? [...dataChosen.current, valueObjectDefault]
1062
+ : [...dataChosen.current]
1063
+ );
1064
+ }
1065
+ } else {
1066
+ setVlObjDefaultState([...dataChosen.current]);
1067
+ }
1068
+ }, [valueObjectDefault, valueMulti]);
1069
+
1070
+ useEffect(() => {
1071
+ allValue[unique] = [];
1072
+
1073
+ if (action?.loadData) handleActionLoadData(true);
1074
+ else if (defaultValue !== undefined && JSON.stringify(defaultValue) !== '[]') {
1075
+ setValueIntoInput(defaultValue);
1076
+ setShowClear(clearAble && checkHasValue(defaultValue) && !disabled && !readOnly && !loadingState);
1077
+ }
1078
+
1079
+ return () => {
1080
+ allValue[unique] = null;
1081
+ closeDropdown(null, 'cleanup');
1082
+ };
1083
+ }, []);
1084
+
1085
+ useEffect(() => {
1086
+ if (allValue[unique][allValue[unique]?.length - 1] !== valueProp) {
1087
+ allValue[unique].push(valueProp);
1088
+ }
1089
+ if (multiple && valueProp) {
1090
+ setValueMulti(convertData(valueProp, valueExpr));
1091
+ }
1092
+ // Close dropdown treeview by children when select item
1093
+ if (children && (closeAfterSelect === true || (closeAfterSelect === undefined && !multiple))) {
1094
+ closeDropdown(null, 'treeView');
1095
+ }
1096
+ }, [valueProp]);
1097
+
1098
+ useEffect(() => {
1099
+ if (
1100
+ valueProp !== undefined &&
1101
+ (!dropdownListRef.current ||
1102
+ children ||
1103
+ JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))
1104
+ ) {
1105
+ setValueIntoInput(valueProp);
1106
+ }
1107
+ }, [valueProp, dataSourceState, vlObjDefaultState]);
1108
+
1109
+ useEffect(() => {
1110
+ inputRef.current.readOnly = readOnly || inputProps.readOnly;
1111
+ if (disabled || readOnly || children) {
1112
+ inputRef.current.addEventListener('keydown', onPreventKeyDownHandler);
1113
+ } else {
1114
+ inputRef.current.addEventListener('keydown', onKeyDown);
1115
+ }
1116
+ return () => {
1117
+ if (!ref.current || !inputRef.current || !iconRef.current) return;
1118
+ if (disabled || readOnly || children) {
1119
+ inputRef.current.removeEventListener('keydown', onPreventKeyDownHandler);
1120
+ } else {
1121
+ inputRef.current.removeEventListener('keydown', onKeyDown);
1122
+ }
1123
+ closeDropdown(null, 'cleanup');
1124
+ };
1125
+ }, [disabled, readOnly, displayExpr, multiple, allowSearch, viewType, closeAfterSelect, selectBox]);
1126
+
1127
+ useEffect(() => {
1128
+ if (!disabled && !readOnly) {
1129
+ inputRef.current.addEventListener('click', onClickInput);
1130
+ inputRef.current.addEventListener('input', onChangeInput);
1131
+ }
1132
+ return () => {
1133
+ if (!disabled && !readOnly && inputRef.current) {
1134
+ inputRef.current.removeEventListener('click', onClickInput);
1135
+ inputRef.current.removeEventListener('input', onChangeInput);
1136
+ }
1137
+ };
1138
+ }, [onChange, children]);
1139
+
1140
+ useEffect(() => {
1141
+ if (!disabled && !readOnly) {
1142
+ inputRef.current.addEventListener('click', onClickInput);
1143
+ }
1144
+ if (dropdownListRef.current) {
1145
+ if (!disabled && !readOnly) {
1146
+ inputRef.current.addEventListener('input', onChangeInput);
1147
+ }
1148
+ const length = dropdownListRef.current?.children?.length;
1149
+ if (length < dataSourceState?.length + vlObjDefaultState?.length && !isSearch[unique]) {
1150
+ loadMoreItemsDropdown(length);
1151
+ } else {
1152
+ isSearch[unique] = false;
1153
+ }
1154
+ } else {
1155
+ if (!multiple && !disabled && !readOnly) {
1156
+ inputRef.current.addEventListener('input', onChangeInput);
1157
+ }
1158
+ }
1159
+ // Fix set defaultValue before action loadData
1160
+ if (
1161
+ action?.loadData &&
1162
+ (!valueSingle || valueMulti?.length === 0) &&
1163
+ defaultValue !== undefined &&
1164
+ JSON.stringify(defaultValue) !== '[]'
1165
+ ) {
1166
+ setValueIntoInput(defaultValue);
1167
+ setShowClear(clearAble && checkHasValue(defaultValue) && !disabled && !readOnly && !loadingState);
1168
+ }
1169
+ return () => {
1170
+ if (inputRef.current) {
1171
+ inputRef.current.removeEventListener('input', onChangeInput);
1172
+ inputRef.current.removeEventListener('click', onClickInput);
1173
+ }
1174
+ };
1175
+ }, [dataSourceState]);
1176
+
1177
+ useEffect(() => {
1178
+ if (!openState && txtSearch) {
1179
+ setTxtSearch('');
1180
+ if (action?.loadData && !!onLoadMore) {
1181
+ filter.current.strSearch = '';
1182
+ handleActionLoadData(true);
1183
+ }
1184
+ }
1185
+ }, [openState]);
1186
+
1187
+ useLayoutEffect(() => {
1188
+ if (ref.current) {
1189
+ const { width } = ref.current.getBoundingClientRect();
1190
+ setPopoverWidth(width);
1191
+ }
1192
+ });
1193
+ /* End handler */
1194
+
1195
+ /* Start component */
1196
+ const EmptyDataText = (
1197
+ <div css={_DropdownItemCSS} className={'no-data'}>
1198
+ {noDataText}
1199
+ </div>
1200
+ );
1201
+
1202
+ const LabelView = useMemo(
1203
+ () =>
1204
+ label ? (
1205
+ <Label required={required} disabled={disabled} {...labelProps}>
1206
+ {label}
1207
+ </Label>
1208
+ ) : null,
1209
+ [label, required, disabled, labelProps]
1210
+ );
1211
+
1212
+ const getData = () => {
1213
+ let dataFilter = JSON.parse(JSON.stringify(dataSourceState));
1214
+ dataFilter = uniqBy([...vlObjDefaultState, ...dataFilter], data => data?.[valueExpr]);
1215
+ return dataFilter;
1216
+ };
1217
+
1218
+ const InputView = (
1219
+ <div
1220
+ css={_DropdownFormCSS}
1221
+ ref={formRef}
1222
+ className={classNames('DGN-UI-Dropdown-Form', openState && 'dropdown-showing')}
1223
+ >
1224
+ <div css={_InputCSS} className={'DGN-UI-Dropdown-Form-Input'}>
1225
+ {multiple && valueMulti?.length ? (
1226
+ <div
1227
+ {...inputProps}
1228
+ style={inputStyle}
1229
+ ref={inputRef}
1230
+ css={[_DropdownInputCSS]}
1231
+ className={classNames('dgn-dropdown-multiple', inputProps.className)}
1232
+ onChange={e => {
1233
+ e.preventDefault();
1234
+ return false;
1235
+ }}
1236
+ >
1237
+ {valueMulti.map((vl, index) => {
1238
+ const dataFilter = getData();
1239
+ const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1240
+ if (data) {
1241
+ const displayText = displayValue(data);
1242
+ let item;
1243
+ if (typeof renderSelectedItem === 'function') {
1244
+ item = renderSelectedItem({ data, index });
1245
+ } else {
1246
+ item = (
1247
+ <Chip
1248
+ css={[parseWidth('100%'), parseMaxWidth('max-content')]}
1249
+ key={index}
1250
+ startIcon={getIconFromData(data, true)}
1251
+ label={displayText}
1252
+ size={'medium'}
1253
+ disabled={disabled}
1254
+ clearAble={!readOnly && !disabled}
1255
+ onRemove={e => onRemove(e, vl)}
1256
+ />
1257
+ );
1258
+ }
1259
+ return item;
1260
+ }
1261
+ })}
1262
+ </div>
1263
+ ) : typeof renderSelectedItem === 'function' || (iconExpr && iconExpr !== 'none') ? (
1264
+ <div
1265
+ {...inputProps}
1266
+ style={inputStyle}
1267
+ ref={inputRef}
1268
+ css={_DropdownInputCSS}
1269
+ className={classNames('dgn-dropdown-multiple', inputProps.className)}
1270
+ onKeyDown={e => {
1271
+ if (e.key === 'Enter') {
1272
+ e.preventDefault();
1273
+ return false;
1274
+ }
1275
+ }}
1276
+ >
1277
+ {valueSingle}
1278
+ </div>
1279
+ ) : (
1280
+ <div css={_DropdownInputCSS} onClick={onClickInput}>
1281
+ <Typography
1282
+ {...inputProps}
1283
+ ref={inputRef}
1284
+ hoverTooltip
1285
+ lineClamp={multilineSelectedItem ? undefined : 1}
1286
+ type={'p1'}
1287
+ style={{
1288
+ lineHeight: multiple ? '30px' : '24px',
1289
+ ...inputStyle,
1290
+ }}
1291
+ tabIndex={-1}
1292
+ >
1293
+ {valueSingle}
1294
+ </Typography>
1295
+ </div>
1296
+ )}
1297
+ </div>
1298
+ <div ref={iconRef} css={_IconCSS} className={'DGN-UI-Dropdown-Icon'}>
1299
+ {loadingState ? <CircularProgress size={24} /> : null}
1300
+ {showClear ? (
1301
+ <ButtonIcon
1302
+ css={css`
1303
+ margin-right: ${spacing([1])};
1304
+ `}
1305
+ viewType={'ghost'}
1306
+ name={'Close'}
1307
+ onClick={onClear}
1308
+ />
1309
+ ) : null}
1310
+ {!loadingState ? (
1311
+ <ButtonIcon
1312
+ key={openState}
1313
+ css={animation}
1314
+ viewType={'ghost'}
1315
+ name={openState ? 'ArrowUp' : 'ArrowDown'}
1316
+ onClick={setShowDropdown}
1317
+ disabled={disabled || readOnly}
1318
+ />
1319
+ ) : null}
1320
+ </div>
1321
+ </div>
1322
+ );
1323
+
1324
+ const ErrorView = useMemo(() => {
1325
+ return error ? (
1326
+ <HelperText {...helperTextProps} disabled={disabled}>
1327
+ {error}
1328
+ </HelperText>
1329
+ ) : null;
1330
+ }, [disabled, error, helperTextProps]);
1331
+
1332
+ const DropdownView = (
1333
+ <Popover
1334
+ css={PopoverCSS(theme)}
1335
+ ref={dropdownRef}
1336
+ open={openState}
1337
+ anchor={ref.current}
1338
+ width={popoverWidth}
1339
+ onClose={closeDropdown}
1340
+ >
1341
+ {showDropdown()}
1342
+ </Popover>
1343
+ );
1344
+
1345
+ /* End component */
1346
+
1347
+ return (
1348
+ <Fragment>
1349
+ <div
1350
+ ref={ref}
1351
+ css={_DropdownRootCSS}
1352
+ style={style}
1353
+ className={classNames(
1354
+ 'DGN-UI-Dropdown',
1355
+ className,
1356
+ error && 'error',
1357
+ loadingState && 'dgn-dropdown-loading',
1358
+ disabled ? 'disabled' : readOnly && 'readOnly'
1359
+ )}
1360
+ >
1361
+ {LabelView}
1362
+ {InputView}
1363
+ {ErrorView}
1364
+ </div>
1365
+ {DropdownView}
1366
+ <Popup ref={popupRef} type={'danger'} {...popupDataState} />
1367
+ </Fragment>
1368
+ );
1369
+ })
1370
+ );
1371
+
1372
+ /* Start styled */
1373
+ const InputCSS = (multiple, renderSelectedItem) => css`
1374
+ ${displayFlex};
1375
+ ${positionRelative};
1376
+ ${parseWidth(!multiple && renderSelectedItem ? 'calc(100% - 34px)' : '100%')};
1377
+ `;
1378
+
1379
+ const PopoverCSS = ({ spacing }) => css`
1380
+ margin-top: ${spacing([1])};
1381
+ ${overflowHidden};
1382
+ `;
1383
+
1384
+ const DropdownInputCSS = (
1385
+ viewType,
1386
+ multiple,
1387
+ placeholder,
1388
+ disabled,
1389
+ readOnly,
1390
+ multilineSelectedItem,
1391
+ { colors, spacing, typography }
1392
+ ) => css`
1393
+ ${displayFlex};
1394
+ ${itemsCenter};
1395
+ ${outlineNone};
1396
+ ${bgColor('transparent')};
1397
+ ${borderNone};
1398
+ ${typography.paragraph1};
1399
+ ${disabled ? cursorNotAllowed : readOnly ? cursorDefault : cursorPointer};
1400
+ ${parseWidth('100%')};
1401
+ ${textColor(getProp(colors, 'text/main'))};
1402
+ padding-top: ${spacing([0])};
1403
+ padding-bottom: ${spacing([viewType !== 'outlined' ? 0 : 'inherit'])};
1404
+ padding-left: ${spacing([viewType !== 'outlined' ? 0 : 4])};
1405
+ gap: ${spacing([0.5])};
1406
+ ${parseMinHeight(multiple ? 30 : 24)};
1407
+ &.dgn-dropdown-multiple {
1408
+ ${displayFlex};
1409
+ ${flexWrap};
1410
+ ${overflowHidden};
1411
+ ${breakWord};
1412
+ ${!multiple &&
1413
+ css`
1414
+ ${parseMinHeight(24)};
1415
+ ${parseMaxWidth('100%')};
1416
+ ${!multilineSelectedItem && parseMaxHeight(24)};
1417
+ `};
1418
+ &::after {
1419
+ ${displayFlex};
1420
+ ${flexRow};
1421
+ ${positionAbsolute};
1422
+ ${itemsCenter};
1423
+ ${justifyCenter};
1424
+ content: '${placeholder}';
1425
+ ${textColor(getProp(colors, 'text/sub'))};
1426
+ }
1427
+ &:not(:empty)::after {
1428
+ ${invisible};
1429
+ }
1430
+ }
1431
+ &:focus {
1432
+ ${bgColor('transparent')};
1433
+ }
1434
+ .dropdown-item {
1435
+ &:not(:last-child) {
1436
+ margin-right: ${spacing([1.25])};
1437
+ }
1438
+ svg {
1439
+ ${boxBorder};
1440
+ padding: ${spacing([0.5])};
1441
+ }
1442
+ }
1443
+ .DGN-UI-Typography {
1444
+ ${disabled && textColor(getProp(colors, 'system/disabled'))};
1445
+ }
1446
+ `;
1447
+
1448
+ const IconCSS = (viewType, { spacing }) => css`
1449
+ ${displayFlex};
1450
+ ${itemsCenter};
1451
+ margin-left: ${spacing([2])};
1452
+ margin-right: ${spacing([viewType !== 'outlined' ? 0 : 4])};
1453
+ `;
1454
+
1455
+ const DropdownFormOutlinedCSS = (disabled, readOnly, placeholder, { colors, spacing }) => css`
1456
+ ${displayFlex};
1457
+ ${flexRow};
1458
+ ${itemsCenter};
1459
+ ${positionRelative};
1460
+ ${borderRadius(4)};
1461
+ ${boxBorder};
1462
+ ${border(1, disabled ? getProp(colors, 'system/disabled') : getProp(colors, 'system/rest'))};
1463
+ ${parseWidth('100%')};
1464
+ ${parseMinHeight(40)};
1465
+ margin-top: ${spacing([0.5])};
1466
+ ${!disabled &&
1467
+ !readOnly &&
1468
+ css`
1469
+ &:not(:focus-within):hover {
1470
+ ${bgColor(getProp(colors, 'fill/hover'))};
1471
+ ${borderColor(getProp(colors, 'system/active'))};
1472
+ input {
1473
+ ${bgColor(getProp(colors, 'fill/hover'))};
1474
+ }
1475
+ }
1476
+ `}
1477
+ &:focus-within {
1478
+ ${borderColor(getProp(colors, 'line/focus'))};
1479
+ }
1480
+ span:empty:before {
1481
+ content: '${placeholder}';
1482
+ ${parseHeight('100%')};
1483
+ ${overflowHidden};
1484
+ ${textColor(getProp(colors, 'text/sub'))};
1485
+ display: -webkit-box;
1486
+ -webkit-line-clamp: 1;
1487
+ -webkit-box-orient: vertical;
1488
+ }
1489
+ &::placeholder {
1490
+ ${textColor(getProp(colors, 'text/sub'))};
1491
+ }
1492
+ &::after {
1493
+ ${positionAbsolute};
1494
+ ${pointerEventsNone};
1495
+ ${borderRadius(4)};
1496
+ ${border(2, 'transparent')};
1497
+ ${inset(-2)};
1498
+ content: '';
1499
+ }
1500
+ `;
1501
+
1502
+ const DropdownFormCSS = (
1503
+ viewType,
1504
+ multiple,
1505
+ disabled,
1506
+ readOnly,
1507
+ placeholder,
1508
+ DropdownInputCSSName,
1509
+ { colors, spacing }
1510
+ ) => css`
1511
+ ${displayFlex};
1512
+ ${flexRow};
1513
+ ${itemsCenter};
1514
+ ${positionRelative};
1515
+ ${boxBorder};
1516
+ ${parseWidth('100%')};
1517
+ padding-top: ${spacing([multiple ? 0.25 : 1])};
1518
+ padding-bottom: ${spacing([multiple ? 0.25 : 1])};
1519
+ ${!disabled &&
1520
+ !readOnly &&
1521
+ css`
1522
+ &:not(:focus-within):hover {
1523
+ &::before {
1524
+ ${borderBottomColor(getProp(colors, 'system/active'))};
1525
+ }
1526
+ .css-${DropdownInputCSSName} {
1527
+ ${textColor(getProp(colors, 'system/active'))};
1528
+ }
1529
+ }
1530
+ `}
1531
+ &:focus-within {
1532
+ ${borderBottomColor(getProp(colors, 'line/focus'))};
1533
+ &::after {
1534
+ ${borderBottomColor('inherit')};
1535
+ transform: scaleX(1);
1536
+ }
1537
+ .css-${DropdownInputCSSName} {
1538
+ ${textColor(getProp(colors, 'system/active'))};
1539
+ }
1540
+ }
1541
+ span:empty:before {
1542
+ content: '${placeholder}';
1543
+ ${parseHeight('100%')};
1544
+ ${overflowHidden};
1545
+ ${textColor(getProp(colors, 'text/sub'))};
1546
+ display: -webkit-box;
1547
+ -webkit-line-clamp: 1;
1548
+ -webkit-box-orient: vertical;
1549
+ }
1550
+ &::placeholder {
1551
+ ${textColor(getProp(colors, 'text/sub'))};
1552
+ }
1553
+ &::before {
1554
+ ${positionAbsolute};
1555
+ content: '';
1556
+ ${insetX(0)};
1557
+ ${bottom(0)};
1558
+ ${viewType === 'underlined' &&
1559
+ borderBottom(1, disabled ? getProp(colors, 'system/disabled') : getProp(colors, 'system/rest'))}
1560
+ }
1561
+ &::after {
1562
+ ${positionAbsolute};
1563
+ content: '';
1564
+ ${insetX(0)};
1565
+ ${bottom(-1)};
1566
+ ${borderBottom(2, 'transparent')};
1567
+ transform: scaleX(0);
1568
+ transform-origin: center;
1569
+ transition: all 0.2s ease;
1570
+ }
1571
+ `;
1572
+
1573
+ const DropdownListCSS = (loading, { colors, spacing }) => css`
1574
+ ${displayBlock};
1575
+ ${positionRelative};
1576
+ ${boxBorder};
1577
+ ${borderRadius(4)};
1578
+ ${parseWidth('100%')};
1579
+ ${parseMaxHeight(280)};
1580
+ ${loading ? overflowHidden : overflowAuto};
1581
+ ${bgColor(getProp(colors, 'system/standard'))};
1582
+ box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
1583
+ ${z(1)};
1584
+ &::-webkit-scrollbar {
1585
+ ${borderRadius(4)};
1586
+ ${parseWidth(24)};
1587
+ ${bgColor(getProp(colors, 'system/standard'))};
1588
+ }
1589
+ &::-webkit-scrollbar-thumb {
1590
+ ${parseMinHeight(40)};
1591
+ ${borderRadius(24)};
1592
+ ${border(8, 'transparent')};
1593
+ ${bgColor(getProp(colors, 'fill/scrollbar_rest'))};
1594
+ mix-blend-mode: normal;
1595
+ background-clip: content-box;
1596
+ }
1597
+ .DGN-UI-TreeView {
1598
+ padding: ${spacing([0.25])};
1599
+ }
1600
+ `;
1601
+
1602
+ const DropdownItemCSS = (multiple, selectBox, { colors, spacing }) => css`
1603
+ ${displayFlex};
1604
+ ${flexRow};
1605
+ ${positionRelative};
1606
+ ${itemsCenter};
1607
+ ${justifyStart};
1608
+ ${boxBorder};
1609
+ ${cursorPointer};
1610
+ ${userSelectNone};
1611
+ ${parseMinHeight(40)};
1612
+ ${parseWidth('100%')};
1613
+ ${bgColor(getProp(colors, 'system/standard'))};
1614
+ padding: ${spacing([2, multiple && selectBox ? 0 : 4])};
1615
+ ${textColor(getProp(colors, 'text/main'))};
1616
+ &.no-data {
1617
+ ${justifyCenter};
1618
+ ${cursorDefault};
1619
+ ${italic};
1620
+ }
1621
+ &:not(.no-data):hover,
1622
+ &:not(.no-data):focus {
1623
+ ${outlineNone};
1624
+ ${bgColor(getProp(colors, 'fill/hover'))};
1625
+ ${textColor(getProp(colors, 'system/active'))};
1626
+ }
1627
+ `;
1628
+
1629
+ const DropdownRootCSS = (DropdownFormCSSName, DropdownInputCSSName, { colors, spacing }) => css`
1630
+ ${displayBlock};
1631
+ ${positionRelative};
1632
+ margin-bottom: ${spacing([5])};
1633
+ ${parseHeight('max-content')};
1634
+ &.error {
1635
+ .css-${DropdownFormCSSName} {
1636
+ ${borderColor(getProp(colors, 'semantic/danger'))};
1637
+ path {
1638
+ ${fill(getProp(colors, 'semantic/danger'))};
1639
+ }
1640
+ &::before {
1641
+ ${borderColor(getProp(colors, 'semantic/danger'))};
1642
+ }
1643
+ }
1644
+ }
1645
+ &.dgn-dropdown-loading,
1646
+ &.disabled {
1647
+ .css-${DropdownFormCSSName} {
1648
+ ${borderColor(getProp(colors, 'system/disabled'))};
1649
+ &::before {
1650
+ ${borderColor(getProp(colors, 'system/disabled'))};
1651
+ }
1652
+ }
1653
+ }
1654
+ &.readOnly {
1655
+ .css-${DropdownInputCSSName} {
1656
+ .dropdown-item {
1657
+ ${pointerEventsNone};
1658
+ }
1659
+ }
1660
+ }
1661
+ `;
1662
+
1663
+ const LoadingProgressCSS = css`
1664
+ ${displayFlex};
1665
+ ${flexRow};
1666
+ ${justifyCenter};
1667
+ ${itemsCenter};
1668
+ ${positionAbsolute};
1669
+ ${borderRadius(4)};
1670
+ ${parseWidthHeight('100%')}
1671
+ ${bgColor('rgba(255, 255, 255, 0.6)')};
1672
+ ${z(2)};
1673
+ ${top(0)};
1674
+ `;
1675
+
1676
+ const DisabledCSS = css`
1677
+ pointer-events: none !important;
1678
+ opacity: 0.4 !important;
1679
+ `;
1680
+
1681
+ const CheckBoxCSS = ({ spacing }) => css`
1682
+ ${parseWidthHeight('100%')};
1683
+ padding: ${spacing([0, 4])};
1684
+ `;
1685
+ /* End styled */
1686
+
1687
+ // Dropdown.defaultProps = {
1688
+ // allowSearch: true,
1689
+ // className: '',
1690
+ // clearAble: false,
1691
+ // dataSource: [],
1692
+ // disabled: false,
1693
+ // displayExpr: 'name',
1694
+ // error: '',
1695
+ // iconExpr: 'none',
1696
+ // inputProps: {},
1697
+ // itemMode: 'normal',
1698
+ // label: '',
1699
+ // limit: 50,
1700
+ // loading: false,
1701
+ // multilineSelectedItem: false,
1702
+ // multiple: false,
1703
+ // noDataText: getGlobal('noDataText'),
1704
+ // placeholder: getGlobal('dropdownPlaceholder'),
1705
+ // readOnly: false,
1706
+ // required: false,
1707
+ // searchDelayTime: getGlobal('delayOnInput'),
1708
+ // searchMode: 'contains',
1709
+ // total: Number.MAX_SAFE_INTEGER,
1710
+ // valueExpr: 'id',
1711
+ // viewType: 'underlined',
1712
+ // };
1713
+
1714
+ Dropdown.propTypes = {
1715
+ action: PropTypes.shape({
1716
+ loadData: PropTypes.func,
1717
+ }),
1718
+ /** If `true`, the input box for searching will be displayed. */
1719
+ allowSearch: PropTypes.bool,
1720
+ /** The content to be displayed inside the Dropdown box, such as TreeView. */
1721
+ children: PropTypes.node,
1722
+ /** The CSS class for the component. */
1723
+ className: PropTypes.string,
1724
+ /** If `true`, the clear button will be displayed. */
1725
+ clearAble: PropTypes.bool,
1726
+ /** If `true`, the dropdown will automatically close after selecting an item. */
1727
+ closeAfterSelect: PropTypes.bool,
1728
+ /** The array of elements that appear in the dropdown list. */
1729
+ dataSource: PropTypes.array,
1730
+ /** The default value to be displayed when the Dropdown first renders. */
1731
+ defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1732
+ /** If `true`, the component is disabled. */
1733
+ disabled: PropTypes.bool,
1734
+ /** The field name used for displaying text in the dropdown list.<br/>
1735
+ * Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
1736
+ * Note: Do not use 'id - name', as it will return undefined.
1737
+ */
1738
+ displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1739
+ /** Inline style for dropdown items. */
1740
+ dropdownItemStyle: PropTypes.object,
1741
+ /** Error message displayed below the input. */
1742
+ error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1743
+ /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1744
+ helperTextProps: PropTypes.object,
1745
+ /** The field name used for displaying icons.<br/>
1746
+ * Example:<br/>
1747
+ * &nbsp;&nbsp;string: 'icon'<br/>
1748
+ * &nbsp;&nbsp;object: {<br/>
1749
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1750
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1751
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1752
+ * &nbsp;&nbsp;}
1753
+ */
1754
+ iconExpr: PropTypes.oneOfType([
1755
+ PropTypes.string,
1756
+ PropTypes.shape({
1757
+ key: PropTypes.string,
1758
+ prefix: PropTypes.string,
1759
+ suffix: PropTypes.string,
1760
+ style: PropTypes.object,
1761
+ }),
1762
+ ]),
1763
+ /** Attributes applied to the input element. */
1764
+ inputProps: PropTypes.object,
1765
+ /** Inline style for the input element. */
1766
+ inputStyle: PropTypes.object,
1767
+ /** The mode of rendering for items. */
1768
+ itemMode: PropTypes.oneOf(['normal', 'table', 'treeview']),
1769
+ /** The label for the input. */
1770
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
1771
+ /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label--simple) applied to the label element. */
1772
+ labelProps: PropTypes.object,
1773
+ /** Number of items to render at a time. */
1774
+ limit: PropTypes.number,
1775
+ /** If `true`, a loading indicator is shown. */
1776
+ loading: PropTypes.bool,
1777
+ /** Maximum number of options that can be selected (used with `multiple` prop).*/
1778
+ maximumSelectionLength: PropTypes.number,
1779
+ /** If `true`, multi-line selected item(s) will be shown. */
1780
+ multilineSelectedItem: PropTypes.bool,
1781
+ /** If `true`, the Dropdown supports multiple selections (value must be an array). */
1782
+ multiple: PropTypes.bool,
1783
+ /** Text shown when there is no data. */
1784
+ noDataText: PropTypes.string,
1785
+ /** Callback function fired when the value changes. */
1786
+ onChange: PropTypes.func,
1787
+ /** Callback function fired when the dropdown is closed. */
1788
+ onClosed: PropTypes.func,
1789
+ /** Callback function fired when the input value changes.<br/>
1790
+ * If undefined, the filter function will run (default behavior).
1791
+ */
1792
+ onInput: PropTypes.func,
1793
+ /** Callback function fired when a key is pressed down in the input. */
1794
+ onKeyDown: PropTypes.func,
1795
+ /** Callback function fired when scrolling near the end of the dropdown. */
1796
+ onLoadMore: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
1797
+ /** The short hint displayed in the input before the user selects a value. */
1798
+ placeholder: PropTypes.string,
1799
+ /** If `true`, the component is read-only. */
1800
+ readOnly: PropTypes.bool,
1801
+ /** Function used for custom rendering of items.<br/>
1802
+ * Example: `(data, index) => data.name + ' - ' + data.role`<br/>
1803
+ * This can be used as an alternative to `displayExpr`
1804
+ */
1805
+ renderItem: PropTypes.func,
1806
+ /** Function or field name used to display selected items.<br/>
1807
+ * Example: `(data, index) => index + ' - ' + data.name`<br/>
1808
+ */
1809
+ renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1810
+ /** If `true`, the label will indicate that the input is required. */
1811
+ required: PropTypes.bool,
1812
+ /**
1813
+ * Duration to wait after entering search content before triggering a search.<br/>
1814
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1815
+ * If `true`, the default delayOnInput will be used.
1816
+ */
1817
+ searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1818
+ /** Specifies the field name or expression used to compare values with the search string. */
1819
+ searchExpr: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
1820
+ /** Specifies the comparison operation used to search items. */
1821
+ searchMode: PropTypes.oneOf(['contains', 'startswith', 'equals']),
1822
+ /** If `true`, checkboxes will be shown next to each dropdown item. */
1823
+ selectBox: PropTypes.bool,
1824
+ /** Inline style for the component. */
1825
+ style: PropTypes.object,
1826
+ /** Sub content to display. */
1827
+ subText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
1828
+ /** The total number of items in the dropdown list. */
1829
+ total: PropTypes.number,
1830
+ /** Used to identify the parent key (only used when `itemMode` is 'treeview'). */
1831
+ treeViewID: PropTypes.string,
1832
+ /** Used for mapping into a nested list (only used when `itemMode` is 'treeview'). */
1833
+ treeViewParentID: PropTypes.string,
1834
+ /** The displayed value of the component. */
1835
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1836
+ /** The field name used for the returned result. */
1837
+ valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1838
+ /** An object default for value (used for load more). */
1839
+ valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1840
+ /** The variant to use. */
1841
+ viewType: PropTypes.oneOf(['underlined', 'outlined', 'none']),
1842
+ /**
1843
+ * ref methods
1844
+ *
1845
+ * how to get component element? ref.current
1846
+ *
1847
+ * how to call method? ref.current.instance.{method}
1848
+ *
1849
+ * * showDropdown(): Show dropdown
1850
+ * * closeDropdown(): Close dropdown
1851
+ * * onClear(): Clear selected value
1852
+ * * setPreviousValue(): Set value to previous value
1853
+ * * setValue(value): Set value of dropdown
1854
+ * * @param {value} - string || number || array
1855
+ */
1856
+ };
1857
+
1858
+ export default Dropdown;