funda-ui 4.7.615 → 4.7.624

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 (564) hide show
  1. package/.gitattributes +2 -0
  2. package/README.md +116 -2
  3. package/README_PUBLISH.md +328 -0
  4. package/lib/cjs/Date/index.js +39 -2
  5. package/lib/cjs/DynamicFields/index.js +11 -3
  6. package/lib/esm/Date/index.tsx +47 -2
  7. package/lib/esm/DynamicFields/index.tsx +9 -4
  8. package/logo.png +0 -0
  9. package/package.json +589 -43
  10. package/preview.png +0 -0
  11. package/{Date → publish/Date}/index.js +39 -2
  12. package/{DynamicFields → publish/DynamicFields}/index.js +11 -3
  13. package/publish/LICENSE +21 -0
  14. package/publish/README.md +328 -0
  15. package/publish/lib/cjs/Accordion/index.d.ts +2 -0
  16. package/publish/lib/cjs/Accordion/index.js +667 -0
  17. package/publish/lib/cjs/BackToTop/index.d.ts +17 -0
  18. package/publish/lib/cjs/BackToTop/index.js +904 -0
  19. package/publish/lib/cjs/CascadingSelect/index.d.ts +80 -0
  20. package/publish/lib/cjs/CascadingSelect/index.js +3383 -0
  21. package/publish/lib/cjs/CascadingSelectE2E/index.d.ts +91 -0
  22. package/publish/lib/cjs/CascadingSelectE2E/index.js +3988 -0
  23. package/publish/lib/cjs/Chatbox/index.d.ts +101 -0
  24. package/publish/lib/cjs/Chatbox/index.js +7037 -0
  25. package/publish/lib/cjs/Checkbox/index.d.ts +28 -0
  26. package/publish/lib/cjs/Checkbox/index.js +673 -0
  27. package/publish/lib/cjs/ColorPicker/index.d.ts +27 -0
  28. package/publish/lib/cjs/ColorPicker/index.js +662 -0
  29. package/publish/lib/cjs/Date/index.d.ts +70 -0
  30. package/publish/lib/cjs/Date/index.js +6368 -0
  31. package/publish/lib/cjs/DigitalClock/index.d.ts +7 -0
  32. package/publish/lib/cjs/DigitalClock/index.js +402 -0
  33. package/publish/lib/cjs/DragDropList/index.d.ts +45 -0
  34. package/publish/lib/cjs/DragDropList/index.js +1586 -0
  35. package/publish/lib/cjs/DropdownMenu/index.d.ts +38 -0
  36. package/publish/lib/cjs/DropdownMenu/index.js +1507 -0
  37. package/publish/lib/cjs/DynamicFields/index.d.ts +40 -0
  38. package/publish/lib/cjs/DynamicFields/index.js +818 -0
  39. package/publish/lib/cjs/EventCalendar/index.d.ts +61 -0
  40. package/publish/lib/cjs/EventCalendar/index.js +3789 -0
  41. package/publish/lib/cjs/EventCalendarTimeline/index.d.ts +100 -0
  42. package/publish/lib/cjs/EventCalendarTimeline/index.js +6141 -0
  43. package/publish/lib/cjs/File/index.d.ts +40 -0
  44. package/publish/lib/cjs/File/index.js +1751 -0
  45. package/publish/lib/cjs/HorizontalScrollContent/index.d.ts +14 -0
  46. package/publish/lib/cjs/HorizontalScrollContent/index.js +426 -0
  47. package/publish/lib/cjs/Input/index.d.ts +59 -0
  48. package/publish/lib/cjs/Input/index.js +1486 -0
  49. package/publish/lib/cjs/LiveSearch/index.d.ts +70 -0
  50. package/publish/lib/cjs/LiveSearch/index.js +4180 -0
  51. package/publish/lib/cjs/MasonryLayout/index.d.ts +14 -0
  52. package/publish/lib/cjs/MasonryLayout/index.js +689 -0
  53. package/publish/lib/cjs/ModalDialog/index.d.ts +83 -0
  54. package/publish/lib/cjs/ModalDialog/index.js +1719 -0
  55. package/publish/lib/cjs/ModeSwitch/index.d.ts +17 -0
  56. package/publish/lib/cjs/ModeSwitch/index.js +202 -0
  57. package/publish/lib/cjs/MultilevelDropdownMenu/index.d.ts +20 -0
  58. package/publish/lib/cjs/MultilevelDropdownMenu/index.js +930 -0
  59. package/publish/lib/cjs/MultipleCheckboxes/index.d.ts +66 -0
  60. package/publish/lib/cjs/MultipleCheckboxes/index.js +2337 -0
  61. package/publish/lib/cjs/MultipleSelect/index.d.ts +65 -0
  62. package/publish/lib/cjs/MultipleSelect/index.js +4197 -0
  63. package/publish/lib/cjs/NativeSelect/index.d.ts +37 -0
  64. package/publish/lib/cjs/NativeSelect/index.js +2052 -0
  65. package/publish/lib/cjs/NumberInput/index.d.ts +40 -0
  66. package/publish/lib/cjs/NumberInput/index.js +1191 -0
  67. package/publish/lib/cjs/Pagination/index.d.ts +51 -0
  68. package/publish/lib/cjs/Pagination/index.js +612 -0
  69. package/publish/lib/cjs/Radio/index.d.ts +45 -0
  70. package/publish/lib/cjs/Radio/index.js +1838 -0
  71. package/publish/lib/cjs/RangeSlider/index.d.ts +22 -0
  72. package/publish/lib/cjs/RangeSlider/index.js +2696 -0
  73. package/publish/lib/cjs/Refresher/index.d.ts +22 -0
  74. package/publish/lib/cjs/Refresher/index.js +564 -0
  75. package/publish/lib/cjs/RootPortal/index.d.ts +9 -0
  76. package/publish/lib/cjs/RootPortal/index.js +148 -0
  77. package/publish/lib/cjs/ScrollReveal/index.d.ts +21 -0
  78. package/publish/lib/cjs/ScrollReveal/index.js +401 -0
  79. package/publish/lib/cjs/Scrollbar/index.d.ts +17 -0
  80. package/publish/lib/cjs/Scrollbar/index.js +1107 -0
  81. package/publish/lib/cjs/SearchBar/index.d.ts +41 -0
  82. package/publish/lib/cjs/SearchBar/index.js +701 -0
  83. package/publish/lib/cjs/Select/index.d.ts +107 -0
  84. package/publish/lib/cjs/Select/index.js +6540 -0
  85. package/publish/lib/cjs/ShowMoreLess/index.d.ts +36 -0
  86. package/publish/lib/cjs/ShowMoreLess/index.js +387 -0
  87. package/publish/lib/cjs/SplitterPanel/index.d.ts +20 -0
  88. package/publish/lib/cjs/SplitterPanel/index.js +800 -0
  89. package/publish/lib/cjs/Stepper/index.d.ts +26 -0
  90. package/publish/lib/cjs/Stepper/index.js +568 -0
  91. package/publish/lib/cjs/Switch/index.d.ts +25 -0
  92. package/publish/lib/cjs/Switch/index.js +630 -0
  93. package/publish/lib/cjs/Table/index.d.ts +12 -0
  94. package/publish/lib/cjs/Table/index.js +2311 -0
  95. package/publish/lib/cjs/Tabs/index.d.ts +3 -0
  96. package/publish/lib/cjs/Tabs/index.js +771 -0
  97. package/publish/lib/cjs/TagInput/index.d.ts +37 -0
  98. package/publish/lib/cjs/TagInput/index.js +1227 -0
  99. package/publish/lib/cjs/Textarea/index.d.ts +50 -0
  100. package/publish/lib/cjs/Textarea/index.js +1795 -0
  101. package/publish/lib/cjs/Toast/index.d.ts +3 -0
  102. package/publish/lib/cjs/Toast/index.js +1345 -0
  103. package/publish/lib/cjs/Tooltip/index.d.ts +38 -0
  104. package/publish/lib/cjs/Tooltip/index.js +1778 -0
  105. package/publish/lib/cjs/Tree/index.d.ts +78 -0
  106. package/publish/lib/cjs/Tree/index.js +2330 -0
  107. package/publish/lib/cjs/Utils/anim.d.ts +11 -0
  108. package/publish/lib/cjs/Utils/anim.js +846 -0
  109. package/publish/lib/cjs/Utils/bodyScrollLock.d.ts +8 -0
  110. package/publish/lib/cjs/Utils/bodyScrollLock.js +311 -0
  111. package/publish/lib/cjs/Utils/buffer.d.ts +67 -0
  112. package/publish/lib/cjs/Utils/buffer.js +343 -0
  113. package/publish/lib/cjs/Utils/cls.d.ts +15 -0
  114. package/publish/lib/cjs/Utils/cls.js +124 -0
  115. package/publish/lib/cjs/Utils/convert.d.ts +25 -0
  116. package/publish/lib/cjs/Utils/convert.js +109 -0
  117. package/publish/lib/cjs/Utils/date.d.ts +227 -0
  118. package/publish/lib/cjs/Utils/date.js +587 -0
  119. package/publish/lib/cjs/Utils/dom.d.ts +13 -0
  120. package/publish/lib/cjs/Utils/dom.js +215 -0
  121. package/publish/lib/cjs/Utils/easing.d.ts +29 -0
  122. package/publish/lib/cjs/Utils/easing.js +221 -0
  123. package/publish/lib/cjs/Utils/extract.d.ts +66 -0
  124. package/publish/lib/cjs/Utils/extract.js +195 -0
  125. package/publish/lib/cjs/Utils/format-string.d.ts +65 -0
  126. package/publish/lib/cjs/Utils/format-string.js +167 -0
  127. package/publish/lib/cjs/Utils/formdata.d.ts +13 -0
  128. package/publish/lib/cjs/Utils/formdata.js +131 -0
  129. package/publish/lib/cjs/Utils/getElementProperty.d.ts +52 -0
  130. package/publish/lib/cjs/Utils/getElementProperty.js +189 -0
  131. package/publish/lib/cjs/Utils/guid.d.ts +7 -0
  132. package/publish/lib/cjs/Utils/guid.js +67 -0
  133. package/publish/lib/cjs/Utils/initDefaultOptions.d.ts +10 -0
  134. package/publish/lib/cjs/Utils/initDefaultOptions.js +607 -0
  135. package/publish/lib/cjs/Utils/inputsCalculation.d.ts +28 -0
  136. package/publish/lib/cjs/Utils/inputsCalculation.js +188 -0
  137. package/publish/lib/cjs/Utils/math.d.ts +77 -0
  138. package/publish/lib/cjs/Utils/math.js +305 -0
  139. package/publish/lib/cjs/Utils/object.d.ts +18 -0
  140. package/publish/lib/cjs/Utils/object.js +120 -0
  141. package/publish/lib/cjs/Utils/os.d.ts +2 -0
  142. package/publish/lib/cjs/Utils/os.js +104 -0
  143. package/publish/lib/cjs/Utils/performance.d.ts +3 -0
  144. package/publish/lib/cjs/Utils/performance.js +94 -0
  145. package/publish/lib/cjs/Utils/sanitize.d.ts +14 -0
  146. package/publish/lib/cjs/Utils/sanitize.js +87 -0
  147. package/publish/lib/cjs/Utils/time.d.ts +40 -0
  148. package/publish/lib/cjs/Utils/time.js +177 -0
  149. package/publish/lib/cjs/Utils/tree.d.ts +40 -0
  150. package/publish/lib/cjs/Utils/tree.js +195 -0
  151. package/publish/lib/cjs/Utils/useAutosizeTextArea.d.ts +10 -0
  152. package/publish/lib/cjs/Utils/useAutosizeTextArea.js +231 -0
  153. package/publish/lib/cjs/Utils/useBoundedDrag.d.ts +125 -0
  154. package/publish/lib/cjs/Utils/useBoundedDrag.js +380 -0
  155. package/publish/lib/cjs/Utils/useClickOutside.d.ts +33 -0
  156. package/publish/lib/cjs/Utils/useClickOutside.js +166 -0
  157. package/publish/lib/cjs/Utils/useComId.d.ts +6 -0
  158. package/publish/lib/cjs/Utils/useComId.js +114 -0
  159. package/publish/lib/cjs/Utils/useDebounce.d.ts +20 -0
  160. package/publish/lib/cjs/Utils/useDebounce.js +138 -0
  161. package/publish/lib/cjs/Utils/useDragDropPosition.d.ts +166 -0
  162. package/publish/lib/cjs/Utils/useDragDropPosition.js +453 -0
  163. package/publish/lib/cjs/Utils/useDraggable.d.ts +62 -0
  164. package/publish/lib/cjs/Utils/useDraggable.js +348 -0
  165. package/publish/lib/cjs/Utils/useHistoryTracker.d.ts +166 -0
  166. package/publish/lib/cjs/Utils/useHistoryTracker.js +649 -0
  167. package/publish/lib/cjs/Utils/useInterval.d.ts +5 -0
  168. package/publish/lib/cjs/Utils/useInterval.js +168 -0
  169. package/publish/lib/cjs/Utils/useIsMobile.d.ts +2 -0
  170. package/publish/lib/cjs/Utils/useIsMobile.js +232 -0
  171. package/publish/lib/cjs/Utils/useKeyPress.d.ts +44 -0
  172. package/publish/lib/cjs/Utils/useKeyPress.js +200 -0
  173. package/publish/lib/cjs/Utils/useSessionStorageListener.d.ts +2 -0
  174. package/publish/lib/cjs/Utils/useSessionStorageListener.js +157 -0
  175. package/publish/lib/cjs/Utils/useStreamController.d.ts +71 -0
  176. package/publish/lib/cjs/Utils/useStreamController.js +494 -0
  177. package/publish/lib/cjs/Utils/useThrottle.d.ts +2 -0
  178. package/publish/lib/cjs/Utils/useThrottle.js +136 -0
  179. package/publish/lib/cjs/Utils/useWindowScroll.d.ts +12 -0
  180. package/publish/lib/cjs/Utils/useWindowScroll.js +217 -0
  181. package/publish/lib/cjs/Utils/validate.d.ts +53 -0
  182. package/publish/lib/cjs/Utils/validate.js +536 -0
  183. package/publish/lib/cjs/Utils/viewport.d.ts +7 -0
  184. package/publish/lib/cjs/Utils/viewport.js +64 -0
  185. package/publish/lib/cjs/index.d.ts +49 -0
  186. package/publish/lib/cjs/index.js +50 -0
  187. package/publish/lib/css/BackToTop/index.css +34 -0
  188. package/publish/lib/css/CascadingSelect/index.css +245 -0
  189. package/publish/lib/css/CascadingSelectE2E/index.css +245 -0
  190. package/publish/lib/css/Chatbox/index.css +774 -0
  191. package/publish/lib/css/ColorPicker/index.css +58 -0
  192. package/publish/lib/css/Date/index.css +434 -0
  193. package/publish/lib/css/DragDropList/index.css +188 -0
  194. package/publish/lib/css/DropdownMenu/index.css +151 -0
  195. package/publish/lib/css/EventCalendar/index.css +300 -0
  196. package/publish/lib/css/EventCalendarTimeline/index.css +694 -0
  197. package/publish/lib/css/HorizontalScrollContent/index.css +70 -0
  198. package/publish/lib/css/LiveSearch/index.css +88 -0
  199. package/publish/lib/css/MultilevelDropdownMenu/index.css +38 -0
  200. package/publish/lib/css/MultipleSelect/index.css +313 -0
  201. package/publish/lib/css/RangeSlider/index.css +150 -0
  202. package/publish/lib/css/Scrollbar/index.css +176 -0
  203. package/publish/lib/css/Select/index.css +434 -0
  204. package/publish/lib/css/ShowMoreLess/index.css +23 -0
  205. package/publish/lib/css/SplitterPanel/index.css +63 -0
  206. package/publish/lib/css/Stepper/index.css +250 -0
  207. package/publish/lib/css/Table/index.css +584 -0
  208. package/publish/lib/css/TagInput/index.css +91 -0
  209. package/publish/lib/css/Toast/index.css +149 -0
  210. package/publish/lib/css/Tooltip/index.css +198 -0
  211. package/publish/lib/css/Tree/index.css +237 -0
  212. package/publish/lib/esm/Accordion/Accordion.tsx +185 -0
  213. package/publish/lib/esm/Accordion/AccordionItem.tsx +248 -0
  214. package/publish/lib/esm/Accordion/index.tsx +2 -0
  215. package/publish/lib/esm/BackToTop/index.scss +47 -0
  216. package/publish/lib/esm/BackToTop/index.tsx +177 -0
  217. package/publish/lib/esm/CascadingSelect/Group.tsx +83 -0
  218. package/publish/lib/esm/CascadingSelect/index.scss +330 -0
  219. package/publish/lib/esm/CascadingSelect/index.tsx +1397 -0
  220. package/publish/lib/esm/CascadingSelectE2E/Group.tsx +87 -0
  221. package/publish/lib/esm/CascadingSelectE2E/index.scss +333 -0
  222. package/publish/lib/esm/CascadingSelectE2E/index.tsx +1684 -0
  223. package/publish/lib/esm/Chatbox/PureLoader.tsx +47 -0
  224. package/publish/lib/esm/Chatbox/TypingEffect.tsx +56 -0
  225. package/publish/lib/esm/Chatbox/index.scss +966 -0
  226. package/publish/lib/esm/Chatbox/index.tsx +1742 -0
  227. package/publish/lib/esm/Chatbox/utils/func.ts +180 -0
  228. package/publish/lib/esm/Checkbox/index.tsx +206 -0
  229. package/publish/lib/esm/ColorPicker/index.scss +91 -0
  230. package/publish/lib/esm/ColorPicker/index.tsx +204 -0
  231. package/publish/lib/esm/Date/Calendar.tsx +723 -0
  232. package/publish/lib/esm/Date/index.scss +567 -0
  233. package/publish/lib/esm/Date/index.tsx +1797 -0
  234. package/publish/lib/esm/Date/localization/en_US.js +13 -0
  235. package/publish/lib/esm/Date/localization/zh_CN.js +12 -0
  236. package/publish/lib/esm/DigitalClock/index.tsx +74 -0
  237. package/publish/lib/esm/DragDropList/index.scss +245 -0
  238. package/publish/lib/esm/DragDropList/index.tsx +504 -0
  239. package/publish/lib/esm/DropdownMenu/Option.tsx +55 -0
  240. package/publish/lib/esm/DropdownMenu/index.scss +205 -0
  241. package/publish/lib/esm/DropdownMenu/index.tsx +378 -0
  242. package/publish/lib/esm/DynamicFields/index.tsx +409 -0
  243. package/publish/lib/esm/EventCalendar/index.scss +407 -0
  244. package/publish/lib/esm/EventCalendar/index.tsx +1005 -0
  245. package/publish/lib/esm/EventCalendarTimeline/index.scss +926 -0
  246. package/publish/lib/esm/EventCalendarTimeline/index.tsx +2686 -0
  247. package/publish/lib/esm/File/index.tsx +477 -0
  248. package/publish/lib/esm/HorizontalScrollContent/index.scss +87 -0
  249. package/publish/lib/esm/HorizontalScrollContent/index.tsx +171 -0
  250. package/publish/lib/esm/Input/index.tsx +641 -0
  251. package/publish/lib/esm/LiveSearch/index.scss +129 -0
  252. package/publish/lib/esm/LiveSearch/index.tsx +1058 -0
  253. package/publish/lib/esm/MasonryLayout/index.tsx +326 -0
  254. package/publish/lib/esm/ModalDialog/index.tsx +572 -0
  255. package/publish/lib/esm/ModeSwitch/index.tsx +82 -0
  256. package/publish/lib/esm/MultilevelDropdownMenu/ItemList.tsx +265 -0
  257. package/publish/lib/esm/MultilevelDropdownMenu/index.scss +79 -0
  258. package/publish/lib/esm/MultilevelDropdownMenu/index.tsx +77 -0
  259. package/publish/lib/esm/MultipleCheckboxes/index.tsx +849 -0
  260. package/publish/lib/esm/MultipleSelect/index.scss +398 -0
  261. package/publish/lib/esm/MultipleSelect/index.tsx +769 -0
  262. package/publish/lib/esm/MultipleSelect/utils/func.ts +63 -0
  263. package/publish/lib/esm/NativeSelect/index.tsx +396 -0
  264. package/publish/lib/esm/NativeSelect/utils/func.ts +51 -0
  265. package/publish/lib/esm/NumberInput/index.tsx +425 -0
  266. package/publish/lib/esm/Pagination/index.tsx +286 -0
  267. package/publish/lib/esm/Pagination/pagination-navigators.tsx +60 -0
  268. package/publish/lib/esm/Radio/index.tsx +694 -0
  269. package/publish/lib/esm/RangeSlider/index.scss +186 -0
  270. package/publish/lib/esm/RangeSlider/index.tsx +241 -0
  271. package/publish/lib/esm/Refresher/index.tsx +121 -0
  272. package/publish/lib/esm/RootPortal/index.tsx +59 -0
  273. package/publish/lib/esm/ScrollReveal/index.tsx +148 -0
  274. package/publish/lib/esm/Scrollbar/index.scss +221 -0
  275. package/publish/lib/esm/Scrollbar/index.tsx +561 -0
  276. package/publish/lib/esm/SearchBar/index.tsx +252 -0
  277. package/publish/lib/esm/Select/index.scss +639 -0
  278. package/publish/lib/esm/Select/index.tsx +3104 -0
  279. package/publish/lib/esm/Select/utils/func.ts +98 -0
  280. package/publish/lib/esm/ShowMoreLess/index.scss +27 -0
  281. package/publish/lib/esm/ShowMoreLess/index.tsx +145 -0
  282. package/publish/lib/esm/SplitterPanel/index.scss +82 -0
  283. package/publish/lib/esm/SplitterPanel/index.tsx +174 -0
  284. package/publish/lib/esm/Stepper/index.scss +315 -0
  285. package/publish/lib/esm/Stepper/index.tsx +325 -0
  286. package/publish/lib/esm/Switch/index.tsx +149 -0
  287. package/publish/lib/esm/Table/Table.tsx +351 -0
  288. package/publish/lib/esm/Table/TableBody.tsx +41 -0
  289. package/publish/lib/esm/Table/TableCaption.tsx +34 -0
  290. package/publish/lib/esm/Table/TableCell.tsx +126 -0
  291. package/publish/lib/esm/Table/TableColgroup.tsx +38 -0
  292. package/publish/lib/esm/Table/TableContext.tsx +26 -0
  293. package/publish/lib/esm/Table/TableFoot.tsx +28 -0
  294. package/publish/lib/esm/Table/TableHead.tsx +28 -0
  295. package/publish/lib/esm/Table/TableRow.tsx +76 -0
  296. package/publish/lib/esm/Table/index.scss +418 -0
  297. package/publish/lib/esm/Table/index.tsx +14 -0
  298. package/publish/lib/esm/Table/utils/DragHandleSprite.tsx +46 -0
  299. package/publish/lib/esm/Table/utils/SortSprite.tsx +63 -0
  300. package/publish/lib/esm/Table/utils/TableFilter.tsx +56 -0
  301. package/publish/lib/esm/Table/utils/ToggleSelection.tsx +255 -0
  302. package/publish/lib/esm/Table/utils/func.ts +182 -0
  303. package/publish/lib/esm/Table/utils/hooks/useTableDraggable.tsx +342 -0
  304. package/publish/lib/esm/Table/utils/hooks/useTableKeyPress.tsx +255 -0
  305. package/publish/lib/esm/Table/utils/hooks/useTableResponsive.tsx +92 -0
  306. package/publish/lib/esm/Table/utils/hooks/useTableSort.tsx +187 -0
  307. package/publish/lib/esm/Tabs/TabList.tsx +50 -0
  308. package/publish/lib/esm/Tabs/TabPanel.tsx +44 -0
  309. package/publish/lib/esm/Tabs/Tabs.tsx +282 -0
  310. package/publish/lib/esm/Tabs/index.tsx +3 -0
  311. package/publish/lib/esm/TagInput/index.scss +126 -0
  312. package/publish/lib/esm/TagInput/index.tsx +379 -0
  313. package/publish/lib/esm/Textarea/index.tsx +621 -0
  314. package/publish/lib/esm/Toast/Item.tsx +165 -0
  315. package/publish/lib/esm/Toast/Toast.tsx +391 -0
  316. package/publish/lib/esm/Toast/ToastContext.tsx +104 -0
  317. package/publish/lib/esm/Toast/__toast.vanilla.js +422 -0
  318. package/publish/lib/esm/Toast/index.scss +197 -0
  319. package/publish/lib/esm/Toast/index.tsx +3 -0
  320. package/publish/lib/esm/Toast/types.ts +60 -0
  321. package/publish/lib/esm/Toast/useToast.tsx +72 -0
  322. package/publish/lib/esm/Tooltip/index.scss +272 -0
  323. package/publish/lib/esm/Tooltip/index.tsx +416 -0
  324. package/publish/lib/esm/Tree/TreeList.tsx +600 -0
  325. package/publish/lib/esm/Tree/index.scss +384 -0
  326. package/publish/lib/esm/Tree/index.tsx +661 -0
  327. package/publish/lib/esm/Tree/init-height.tsx +40 -0
  328. package/publish/lib/esm/Tree/utils/func.ts +15 -0
  329. package/publish/lib/esm/Utils/hooks/useAutosizeTextArea.tsx +131 -0
  330. package/publish/lib/esm/Utils/hooks/useBoundedDrag.tsx +301 -0
  331. package/publish/lib/esm/Utils/hooks/useClickOutside.tsx +69 -0
  332. package/publish/lib/esm/Utils/hooks/useComId.tsx +13 -0
  333. package/publish/lib/esm/Utils/hooks/useDebounce.tsx +40 -0
  334. package/publish/lib/esm/Utils/hooks/useDragDropPosition.tsx +417 -0
  335. package/publish/lib/esm/Utils/hooks/useDraggable.tsx +265 -0
  336. package/publish/lib/esm/Utils/hooks/useHistoryTracker.tsx +554 -0
  337. package/publish/lib/esm/Utils/hooks/useInterval.tsx +74 -0
  338. package/publish/lib/esm/Utils/hooks/useIsMobile.tsx +139 -0
  339. package/publish/lib/esm/Utils/hooks/useKeyPress.tsx +104 -0
  340. package/publish/lib/esm/Utils/hooks/useSessionStorageListener.tsx +45 -0
  341. package/publish/lib/esm/Utils/hooks/useStreamController.tsx +277 -0
  342. package/publish/lib/esm/Utils/hooks/useThrottle.tsx +39 -0
  343. package/publish/lib/esm/Utils/hooks/useWindowScroll.tsx +83 -0
  344. package/publish/lib/esm/Utils/libs/anim.ts +96 -0
  345. package/publish/lib/esm/Utils/libs/buffer.ts +262 -0
  346. package/publish/lib/esm/Utils/libs/cls.ts +64 -0
  347. package/publish/lib/esm/Utils/libs/convert.ts +59 -0
  348. package/publish/lib/esm/Utils/libs/date.ts +598 -0
  349. package/publish/lib/esm/Utils/libs/dom.ts +150 -0
  350. package/publish/lib/esm/Utils/libs/easing.ts +201 -0
  351. package/publish/lib/esm/Utils/libs/extract.ts +160 -0
  352. package/publish/lib/esm/Utils/libs/format-string.ts +116 -0
  353. package/publish/lib/esm/Utils/libs/formdata.ts +93 -0
  354. package/publish/lib/esm/Utils/libs/getElementProperty.ts +150 -0
  355. package/publish/lib/esm/Utils/libs/guid.ts +16 -0
  356. package/publish/lib/esm/Utils/libs/initDefaultOptions.ts +43 -0
  357. package/publish/lib/esm/Utils/libs/inputsCalculation.ts +160 -0
  358. package/publish/lib/esm/Utils/libs/math.ts +276 -0
  359. package/publish/lib/esm/Utils/libs/object.ts +68 -0
  360. package/publish/lib/esm/Utils/libs/os.ts +63 -0
  361. package/publish/lib/esm/Utils/libs/performance.ts +47 -0
  362. package/publish/lib/esm/Utils/libs/sanitize.ts +55 -0
  363. package/publish/lib/esm/Utils/libs/time.ts +139 -0
  364. package/publish/lib/esm/Utils/libs/tree.ts +119 -0
  365. package/publish/lib/esm/Utils/libs/validate.ts +434 -0
  366. package/publish/lib/esm/Utils/libs/viewport.ts +20 -0
  367. package/publish/lib/esm/Utils/plugins/bodyScrollLock.ts +286 -0
  368. package/publish/lib/esm/index.js +47 -0
  369. package/publish/package.json +1 -0
  370. /package/{Accordion → publish/Accordion}/index.d.ts +0 -0
  371. /package/{Accordion → publish/Accordion}/index.js +0 -0
  372. /package/{BackToTop → publish/BackToTop}/index.css +0 -0
  373. /package/{BackToTop → publish/BackToTop}/index.d.ts +0 -0
  374. /package/{BackToTop → publish/BackToTop}/index.js +0 -0
  375. /package/{CascadingSelect → publish/CascadingSelect}/index.css +0 -0
  376. /package/{CascadingSelect → publish/CascadingSelect}/index.d.ts +0 -0
  377. /package/{CascadingSelect → publish/CascadingSelect}/index.js +0 -0
  378. /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.css +0 -0
  379. /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.d.ts +0 -0
  380. /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.js +0 -0
  381. /package/{Chatbox → publish/Chatbox}/index.css +0 -0
  382. /package/{Chatbox → publish/Chatbox}/index.d.ts +0 -0
  383. /package/{Chatbox → publish/Chatbox}/index.js +0 -0
  384. /package/{Checkbox → publish/Checkbox}/index.d.ts +0 -0
  385. /package/{Checkbox → publish/Checkbox}/index.js +0 -0
  386. /package/{ColorPicker → publish/ColorPicker}/index.css +0 -0
  387. /package/{ColorPicker → publish/ColorPicker}/index.d.ts +0 -0
  388. /package/{ColorPicker → publish/ColorPicker}/index.js +0 -0
  389. /package/{Date → publish/Date}/index.css +0 -0
  390. /package/{Date → publish/Date}/index.d.ts +0 -0
  391. /package/{DigitalClock → publish/DigitalClock}/index.d.ts +0 -0
  392. /package/{DigitalClock → publish/DigitalClock}/index.js +0 -0
  393. /package/{DragDropList → publish/DragDropList}/index.css +0 -0
  394. /package/{DragDropList → publish/DragDropList}/index.d.ts +0 -0
  395. /package/{DragDropList → publish/DragDropList}/index.js +0 -0
  396. /package/{DropdownMenu → publish/DropdownMenu}/index.css +0 -0
  397. /package/{DropdownMenu → publish/DropdownMenu}/index.d.ts +0 -0
  398. /package/{DropdownMenu → publish/DropdownMenu}/index.js +0 -0
  399. /package/{DynamicFields → publish/DynamicFields}/index.d.ts +0 -0
  400. /package/{EventCalendar → publish/EventCalendar}/index.css +0 -0
  401. /package/{EventCalendar → publish/EventCalendar}/index.d.ts +0 -0
  402. /package/{EventCalendar → publish/EventCalendar}/index.js +0 -0
  403. /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.css +0 -0
  404. /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.d.ts +0 -0
  405. /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.js +0 -0
  406. /package/{File → publish/File}/index.d.ts +0 -0
  407. /package/{File → publish/File}/index.js +0 -0
  408. /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.css +0 -0
  409. /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.d.ts +0 -0
  410. /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.js +0 -0
  411. /package/{Input → publish/Input}/index.d.ts +0 -0
  412. /package/{Input → publish/Input}/index.js +0 -0
  413. /package/{LiveSearch → publish/LiveSearch}/index.css +0 -0
  414. /package/{LiveSearch → publish/LiveSearch}/index.d.ts +0 -0
  415. /package/{LiveSearch → publish/LiveSearch}/index.js +0 -0
  416. /package/{MasonryLayout → publish/MasonryLayout}/index.d.ts +0 -0
  417. /package/{MasonryLayout → publish/MasonryLayout}/index.js +0 -0
  418. /package/{ModalDialog → publish/ModalDialog}/index.d.ts +0 -0
  419. /package/{ModalDialog → publish/ModalDialog}/index.js +0 -0
  420. /package/{ModeSwitch → publish/ModeSwitch}/index.d.ts +0 -0
  421. /package/{ModeSwitch → publish/ModeSwitch}/index.js +0 -0
  422. /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.css +0 -0
  423. /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.d.ts +0 -0
  424. /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.js +0 -0
  425. /package/{MultipleCheckboxes → publish/MultipleCheckboxes}/index.d.ts +0 -0
  426. /package/{MultipleCheckboxes → publish/MultipleCheckboxes}/index.js +0 -0
  427. /package/{MultipleSelect → publish/MultipleSelect}/index.css +0 -0
  428. /package/{MultipleSelect → publish/MultipleSelect}/index.d.ts +0 -0
  429. /package/{MultipleSelect → publish/MultipleSelect}/index.js +0 -0
  430. /package/{NativeSelect → publish/NativeSelect}/index.d.ts +0 -0
  431. /package/{NativeSelect → publish/NativeSelect}/index.js +0 -0
  432. /package/{NumberInput → publish/NumberInput}/index.d.ts +0 -0
  433. /package/{NumberInput → publish/NumberInput}/index.js +0 -0
  434. /package/{Pagination → publish/Pagination}/index.d.ts +0 -0
  435. /package/{Pagination → publish/Pagination}/index.js +0 -0
  436. /package/{Radio → publish/Radio}/index.d.ts +0 -0
  437. /package/{Radio → publish/Radio}/index.js +0 -0
  438. /package/{RangeSlider → publish/RangeSlider}/index.css +0 -0
  439. /package/{RangeSlider → publish/RangeSlider}/index.d.ts +0 -0
  440. /package/{RangeSlider → publish/RangeSlider}/index.js +0 -0
  441. /package/{Refresher → publish/Refresher}/index.d.ts +0 -0
  442. /package/{Refresher → publish/Refresher}/index.js +0 -0
  443. /package/{RootPortal → publish/RootPortal}/index.d.ts +0 -0
  444. /package/{RootPortal → publish/RootPortal}/index.js +0 -0
  445. /package/{ScrollReveal → publish/ScrollReveal}/index.d.ts +0 -0
  446. /package/{ScrollReveal → publish/ScrollReveal}/index.js +0 -0
  447. /package/{Scrollbar → publish/Scrollbar}/index.css +0 -0
  448. /package/{Scrollbar → publish/Scrollbar}/index.d.ts +0 -0
  449. /package/{Scrollbar → publish/Scrollbar}/index.js +0 -0
  450. /package/{SearchBar → publish/SearchBar}/index.d.ts +0 -0
  451. /package/{SearchBar → publish/SearchBar}/index.js +0 -0
  452. /package/{Select → publish/Select}/index.css +0 -0
  453. /package/{Select → publish/Select}/index.d.ts +0 -0
  454. /package/{Select → publish/Select}/index.js +0 -0
  455. /package/{ShowMoreLess → publish/ShowMoreLess}/index.css +0 -0
  456. /package/{ShowMoreLess → publish/ShowMoreLess}/index.d.ts +0 -0
  457. /package/{ShowMoreLess → publish/ShowMoreLess}/index.js +0 -0
  458. /package/{SplitterPanel → publish/SplitterPanel}/index.css +0 -0
  459. /package/{SplitterPanel → publish/SplitterPanel}/index.d.ts +0 -0
  460. /package/{SplitterPanel → publish/SplitterPanel}/index.js +0 -0
  461. /package/{Stepper → publish/Stepper}/index.css +0 -0
  462. /package/{Stepper → publish/Stepper}/index.d.ts +0 -0
  463. /package/{Stepper → publish/Stepper}/index.js +0 -0
  464. /package/{Switch → publish/Switch}/index.d.ts +0 -0
  465. /package/{Switch → publish/Switch}/index.js +0 -0
  466. /package/{Table → publish/Table}/index.css +0 -0
  467. /package/{Table → publish/Table}/index.d.ts +0 -0
  468. /package/{Table → publish/Table}/index.js +0 -0
  469. /package/{Tabs → publish/Tabs}/index.d.ts +0 -0
  470. /package/{Tabs → publish/Tabs}/index.js +0 -0
  471. /package/{TagInput → publish/TagInput}/index.css +0 -0
  472. /package/{TagInput → publish/TagInput}/index.d.ts +0 -0
  473. /package/{TagInput → publish/TagInput}/index.js +0 -0
  474. /package/{Textarea → publish/Textarea}/index.d.ts +0 -0
  475. /package/{Textarea → publish/Textarea}/index.js +0 -0
  476. /package/{Toast → publish/Toast}/index.css +0 -0
  477. /package/{Toast → publish/Toast}/index.d.ts +0 -0
  478. /package/{Toast → publish/Toast}/index.js +0 -0
  479. /package/{Tooltip → publish/Tooltip}/index.css +0 -0
  480. /package/{Tooltip → publish/Tooltip}/index.d.ts +0 -0
  481. /package/{Tooltip → publish/Tooltip}/index.js +0 -0
  482. /package/{Tree → publish/Tree}/index.css +0 -0
  483. /package/{Tree → publish/Tree}/index.d.ts +0 -0
  484. /package/{Tree → publish/Tree}/index.js +0 -0
  485. /package/{Utils → publish/Utils}/anim.d.ts +0 -0
  486. /package/{Utils → publish/Utils}/anim.js +0 -0
  487. /package/{Utils → publish/Utils}/bodyScrollLock.d.ts +0 -0
  488. /package/{Utils → publish/Utils}/bodyScrollLock.js +0 -0
  489. /package/{Utils → publish/Utils}/buffer.d.ts +0 -0
  490. /package/{Utils → publish/Utils}/buffer.js +0 -0
  491. /package/{Utils → publish/Utils}/cls.d.ts +0 -0
  492. /package/{Utils → publish/Utils}/cls.js +0 -0
  493. /package/{Utils → publish/Utils}/convert.d.ts +0 -0
  494. /package/{Utils → publish/Utils}/convert.js +0 -0
  495. /package/{Utils → publish/Utils}/date.d.ts +0 -0
  496. /package/{Utils → publish/Utils}/date.js +0 -0
  497. /package/{Utils → publish/Utils}/dom.d.ts +0 -0
  498. /package/{Utils → publish/Utils}/dom.js +0 -0
  499. /package/{Utils → publish/Utils}/easing.d.ts +0 -0
  500. /package/{Utils → publish/Utils}/easing.js +0 -0
  501. /package/{Utils → publish/Utils}/extract.d.ts +0 -0
  502. /package/{Utils → publish/Utils}/extract.js +0 -0
  503. /package/{Utils → publish/Utils}/format-string.d.ts +0 -0
  504. /package/{Utils → publish/Utils}/format-string.js +0 -0
  505. /package/{Utils → publish/Utils}/formdata.d.ts +0 -0
  506. /package/{Utils → publish/Utils}/formdata.js +0 -0
  507. /package/{Utils → publish/Utils}/getElementProperty.d.ts +0 -0
  508. /package/{Utils → publish/Utils}/getElementProperty.js +0 -0
  509. /package/{Utils → publish/Utils}/guid.d.ts +0 -0
  510. /package/{Utils → publish/Utils}/guid.js +0 -0
  511. /package/{Utils → publish/Utils}/initDefaultOptions.d.ts +0 -0
  512. /package/{Utils → publish/Utils}/initDefaultOptions.js +0 -0
  513. /package/{Utils → publish/Utils}/inputsCalculation.d.ts +0 -0
  514. /package/{Utils → publish/Utils}/inputsCalculation.js +0 -0
  515. /package/{Utils → publish/Utils}/math.d.ts +0 -0
  516. /package/{Utils → publish/Utils}/math.js +0 -0
  517. /package/{Utils → publish/Utils}/object.d.ts +0 -0
  518. /package/{Utils → publish/Utils}/object.js +0 -0
  519. /package/{Utils → publish/Utils}/os.d.ts +0 -0
  520. /package/{Utils → publish/Utils}/os.js +0 -0
  521. /package/{Utils → publish/Utils}/performance.d.ts +0 -0
  522. /package/{Utils → publish/Utils}/performance.js +0 -0
  523. /package/{Utils → publish/Utils}/sanitize.d.ts +0 -0
  524. /package/{Utils → publish/Utils}/sanitize.js +0 -0
  525. /package/{Utils → publish/Utils}/time.d.ts +0 -0
  526. /package/{Utils → publish/Utils}/time.js +0 -0
  527. /package/{Utils → publish/Utils}/tree.d.ts +0 -0
  528. /package/{Utils → publish/Utils}/tree.js +0 -0
  529. /package/{Utils → publish/Utils}/useAutosizeTextArea.d.ts +0 -0
  530. /package/{Utils → publish/Utils}/useAutosizeTextArea.js +0 -0
  531. /package/{Utils → publish/Utils}/useBoundedDrag.d.ts +0 -0
  532. /package/{Utils → publish/Utils}/useBoundedDrag.js +0 -0
  533. /package/{Utils → publish/Utils}/useClickOutside.d.ts +0 -0
  534. /package/{Utils → publish/Utils}/useClickOutside.js +0 -0
  535. /package/{Utils → publish/Utils}/useComId.d.ts +0 -0
  536. /package/{Utils → publish/Utils}/useComId.js +0 -0
  537. /package/{Utils → publish/Utils}/useDebounce.d.ts +0 -0
  538. /package/{Utils → publish/Utils}/useDebounce.js +0 -0
  539. /package/{Utils → publish/Utils}/useDragDropPosition.d.ts +0 -0
  540. /package/{Utils → publish/Utils}/useDragDropPosition.js +0 -0
  541. /package/{Utils → publish/Utils}/useDraggable.d.ts +0 -0
  542. /package/{Utils → publish/Utils}/useDraggable.js +0 -0
  543. /package/{Utils → publish/Utils}/useHistoryTracker.d.ts +0 -0
  544. /package/{Utils → publish/Utils}/useHistoryTracker.js +0 -0
  545. /package/{Utils → publish/Utils}/useInterval.d.ts +0 -0
  546. /package/{Utils → publish/Utils}/useInterval.js +0 -0
  547. /package/{Utils → publish/Utils}/useIsMobile.d.ts +0 -0
  548. /package/{Utils → publish/Utils}/useIsMobile.js +0 -0
  549. /package/{Utils → publish/Utils}/useKeyPress.d.ts +0 -0
  550. /package/{Utils → publish/Utils}/useKeyPress.js +0 -0
  551. /package/{Utils → publish/Utils}/useSessionStorageListener.d.ts +0 -0
  552. /package/{Utils → publish/Utils}/useSessionStorageListener.js +0 -0
  553. /package/{Utils → publish/Utils}/useStreamController.d.ts +0 -0
  554. /package/{Utils → publish/Utils}/useStreamController.js +0 -0
  555. /package/{Utils → publish/Utils}/useThrottle.d.ts +0 -0
  556. /package/{Utils → publish/Utils}/useThrottle.js +0 -0
  557. /package/{Utils → publish/Utils}/useWindowScroll.d.ts +0 -0
  558. /package/{Utils → publish/Utils}/useWindowScroll.js +0 -0
  559. /package/{Utils → publish/Utils}/validate.d.ts +0 -0
  560. /package/{Utils → publish/Utils}/validate.js +0 -0
  561. /package/{Utils → publish/Utils}/viewport.d.ts +0 -0
  562. /package/{Utils → publish/Utils}/viewport.js +0 -0
  563. /package/{all.d.ts → publish/all.d.ts} +0 -0
  564. /package/{all.js → publish/all.js} +0 -0
@@ -0,0 +1,1684 @@
1
+ import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from 'react';
2
+
3
+ import RootPortal from 'funda-root-portal';
4
+
5
+ import useComId from 'funda-utils/dist/cjs/useComId';
6
+ import useWindowScroll from 'funda-utils/dist/cjs/useWindowScroll';
7
+ import useClickOutside from 'funda-utils/dist/cjs/useClickOutside';
8
+ import {
9
+ extractorExist,
10
+ extractContentsOfBraces,
11
+ extractContentsOfBrackets,
12
+ extractContentsOfMixedCharactersWithBraces,
13
+ extractContentsOfMixedCharactersWithComma
14
+ } from 'funda-utils/dist/cjs/extract';
15
+ import {
16
+ convertArrToValByBraces
17
+ } from 'funda-utils/dist/cjs/convert';
18
+ import {
19
+ getAbsolutePositionOfStage
20
+ } from 'funda-utils/dist/cjs/getElementProperty';
21
+ import {
22
+ addTreeDepth,
23
+ addTreeIndent
24
+ } from 'funda-utils/dist/cjs/tree';
25
+ import {
26
+ htmlToPlain
27
+ } from 'funda-utils/dist/cjs/format-string';
28
+ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
29
+
30
+
31
+
32
+ import Group from './Group';
33
+
34
+
35
+
36
+ export type CascadingSelectE2EOptionChangeFnType = (input: any, currentData: any, index: any, depth: any, value: string, closeFunc: any) => void;
37
+
38
+
39
+ export interface fetchArrayConfig {
40
+ fetchFuncAsync?: any | undefined;
41
+ fetchFuncMethod?: string | undefined;
42
+ fetchFuncMethodParams?: any[] | undefined;
43
+ fetchCallback?: (data: any) => void;
44
+ hierarchical?: boolean;
45
+ indentation?: string;
46
+ doubleIndent?: boolean;
47
+ }
48
+
49
+ export type CascadingSelectE2EProps = {
50
+ popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
51
+ wrapperClassName?: string;
52
+ controlClassName?: string;
53
+ controlExClassName?: string;
54
+ controlGroupWrapperClassName?: string;
55
+ controlGroupTextClassName?: string;
56
+ searchable?: boolean;
57
+ searchPlaceholder?: string;
58
+ perColumnHeadersShow?: boolean;
59
+ exceededSidePosOffset?: number;
60
+ value?: string;
61
+ label?: React.ReactNode | string;
62
+ name?: string;
63
+ placeholder?: string;
64
+ readOnly?: any;
65
+ disabled?: any;
66
+ required?: any;
67
+ requiredLabel?: React.ReactNode | string;
68
+ units?: React.ReactNode | string;
69
+ iconLeft?: React.ReactNode | string;
70
+ iconRight?: React.ReactNode | string;
71
+ minLength?: any;
72
+ maxLength?: any;
73
+ /** Whether to use curly braces to save result and initialize default value */
74
+ extractValueByBraces?: boolean;
75
+ /** Instead of using `queryId` of response to match child and parent data
76
+ * (very useful for multiple fetch requests with no directly related fields),
77
+ * this operation will directly use the click event to modify the result. */
78
+ destroyParentIdMatch?: boolean;
79
+ /** Set headers for each column group */
80
+ columnTitle?: any[];
81
+ /** Set whether to use "label" or "value" for the value of this form
82
+ * Optional values: `label`, `value`
83
+ */
84
+ valueType?: string;
85
+ /** Whether to display the close button. */
86
+ showCloseBtn?: boolean;
87
+ /** Set the depth value of the control to control the display of the pop-up layer appear above.
88
+ * Please set it when multiple controls are used at the same time. */
89
+ depth?: number;
90
+ /** Set a loader component to show while the component waits for the next load of data.
91
+ * e.g. `<span>Loading...</span>` or any fancy loader element */
92
+ loader?: React.ReactNode;
93
+ /** Whether it can be modified in the input box */
94
+ inputable?: boolean;
95
+ /** Set an arrow of breadcrumb result */
96
+ displayResultArrow?: React.ReactNode;
97
+ /** Set an arrow of control */
98
+ controlArrow?: React.ReactNode;
99
+ /** Specify a class for trigger. */
100
+ triggerClassName?: string;
101
+ /** Set a piece of text or HTML code for the trigger */
102
+ triggerContent?: React.ReactNode;
103
+ /** Specify a class for clean node button. */
104
+ cleanNodeBtnClassName?: string;
105
+ /** Set a piece of text or HTML code for the clean node button */
106
+ cleanNodeBtnContent?: React.ReactNode;
107
+ /** Configuration for multiple requests */
108
+ fetchArray?: fetchArrayConfig[];
109
+ /** -- */
110
+ id?: string;
111
+ style?: React.CSSProperties;
112
+ tabIndex?: number;
113
+ [key: `data-${string}`]: string | undefined;
114
+ onFetch?: (data: any, childrenData: any) => void;
115
+ onChange?: CascadingSelectE2EOptionChangeFnType | null;
116
+ onBlur?: (e: any) => void;
117
+ onFocus?: (e: any) => void;
118
+ /**
119
+ * Customize the function of formatting the value of the input input box, and the parameters are labels, values, and queryIds
120
+ * Returns a string as the value of the input
121
+ */
122
+ formatInputResult?: (param: Array<{label: string, value: string | number}>) => string;
123
+ };
124
+
125
+
126
+ const CascadingSelectE2E = forwardRef((props: CascadingSelectE2EProps, externalRef: any) => {
127
+ const {
128
+ popupRef,
129
+ wrapperClassName,
130
+ controlClassName,
131
+ controlExClassName,
132
+ controlGroupWrapperClassName,
133
+ controlGroupTextClassName,
134
+ searchable = false,
135
+ searchPlaceholder = '',
136
+ perColumnHeadersShow = true,
137
+ exceededSidePosOffset,
138
+ readOnly,
139
+ disabled,
140
+ required,
141
+ requiredLabel,
142
+ units,
143
+ iconLeft,
144
+ iconRight,
145
+ minLength,
146
+ maxLength,
147
+ value,
148
+ label,
149
+ placeholder,
150
+ name,
151
+ id,
152
+ extractValueByBraces,
153
+ destroyParentIdMatch,
154
+ columnTitle,
155
+ depth,
156
+ loader,
157
+ inputable = false,
158
+ displayResultArrow,
159
+ controlArrow,
160
+ valueType,
161
+ showCloseBtn,
162
+ style,
163
+ tabIndex,
164
+ triggerClassName,
165
+ triggerContent,
166
+ cleanNodeBtnClassName,
167
+ cleanNodeBtnContent,
168
+ fetchArray,
169
+ onFetch,
170
+ onChange,
171
+ onBlur,
172
+ onFocus,
173
+ formatInputResult,
174
+ ...attributes
175
+ } = props;
176
+
177
+
178
+ const DEPTH = depth || 1055; // the default value same as bootstrap
179
+ const POS_OFFSET = 0;
180
+ const EXCEEDED_SIDE_POS_OFFSET = Number(exceededSidePosOffset) || 15;
181
+ const VALUE_BY_BRACES = typeof extractValueByBraces === 'undefined' ? true : extractValueByBraces;
182
+ const uniqueID = useComId();
183
+ const idRes = id || uniqueID;
184
+ const rootRef = useRef<any>(null);
185
+ const inputRef = useRef<any>(null);
186
+ const listRef = useRef<any>(null);
187
+ const MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
188
+
189
+ // searchable
190
+ const [columnSearchKeywords, setColumnSearchKeywords] = useState<string[]>([]);
191
+
192
+ const propExist = (p: any) => {
193
+ return typeof p !== 'undefined' && p !== null && p !== '';
194
+ };
195
+
196
+ const resultInput = (curData: string[] | number[], curQueryIdsData: string[] | number[]) => {
197
+ return VALUE_BY_BRACES ? convertArrToValByBraces(curData.map((item: any, i: number) => `${item}[${curQueryIdsData[i]}]`)) : curData.map((item: any, i: number) => `${item}[${curQueryIdsData[i]}]`)!.join(',');
198
+ };
199
+
200
+ const resultInputPureText = (inputStr: string) => {
201
+ return VALUE_BY_BRACES ? `{${inputStr}[]}` : `${inputStr}[]`;
202
+
203
+ // value1: {{curLabel[curValue]}[]}
204
+ // value2: curLabel[curValue][]
205
+ };
206
+
207
+
208
+ // exposes the following methods
209
+ useImperativeHandle(
210
+ popupRef,
211
+ () => ({
212
+ close: () => {
213
+ cancel();
214
+ },
215
+ }),
216
+ [popupRef],
217
+ );
218
+
219
+
220
+
221
+
222
+ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
223
+ // DO NOT USE `useState()` for `allData`,, `optData`, `dictionaryData`, `listData`, `selectedData`, `selectedDataByClick`,
224
+ // because the list uses vanilla JS DOM events which will cause the results of useState not to be displayed in real time.
225
+ // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
226
+
227
+
228
+ // current data depth (GLOBAL)
229
+ const [currentDataDepth, setCurrentDataDepth] = useState<number>(0);
230
+
231
+ // all data from fetched data (GLOBAL)
232
+ const allData = useRef<any[]>([]);
233
+
234
+ // options data (GLOBAL)
235
+ const optData = useRef<any[]>([]);
236
+
237
+
238
+ // dictionary data
239
+ const dictionaryData = useRef<any[]>([]);
240
+
241
+ const [loading, setLoading] = useState<boolean>(false);
242
+ const [columnTitleData, setColumnTitleData] = useState<any[]>([]);
243
+ const [hasErr, setHasErr] = useState<boolean>(false);
244
+ const [firstDataFeched, setFirstDataFeched] = useState<boolean>(false);
245
+ const [changedVal, setChangedVal] = useState<string>(value || '');
246
+
247
+ //for variable
248
+ const listData = useRef<any[]>([]);
249
+ const selectedData = useRef<any>({
250
+ labels: [],
251
+ values: [],
252
+ queryIds: []
253
+ });
254
+
255
+ // destroy `queryId` match
256
+ const selectedDataByClick = useRef<any>({
257
+ labels: [],
258
+ values: [],
259
+ queryIds: []
260
+ });
261
+
262
+ const [isShow, setIsShow] = useState<boolean>(false);
263
+
264
+
265
+
266
+ // click outside
267
+ useClickOutside({
268
+ enabled: isShow && rootRef.current && listRef.current,
269
+ isOutside: (event: any) => {
270
+
271
+ // close dropdown when other dropdown is opened
272
+ return (
273
+ (rootRef.current !== event.target && !rootRef.current.contains(event.target as HTMLElement)) &&
274
+ listRef.current !== event.target && !listRef.current.contains(event.target as HTMLElement)
275
+ )
276
+
277
+ },
278
+ handle: (event: any) => {
279
+ cancel();
280
+ }
281
+ }, [isShow, rootRef, listRef]);
282
+
283
+
284
+
285
+ // Add function to the element that should be used as the scrollable area.
286
+ const [scrollData, windowScrollUpdate] = useWindowScroll({
287
+ performance: ['debounce', 500], // "['debounce', 500]" or "['throttle', 500]"
288
+ handle: (scrollData: any) => {
289
+ popwinPosInit(false);
290
+ }
291
+ });
292
+
293
+
294
+
295
+ function popwinPosInit(showAct: boolean = true) {
296
+ if (rootRef.current === null || inputRef.current === null) return;
297
+
298
+
299
+ // update modal position
300
+ const _modalRef: any = document.querySelector(`#casc-menu-e2e__items-wrapper-${idRes}`);
301
+ const _triggerRef: any = inputRef.current;
302
+
303
+
304
+ // console.log(getAbsolutePositionOfStage(_triggerRef));
305
+
306
+ if (_modalRef === null) return;
307
+
308
+ const { x } = getAbsolutePositionOfStage(_triggerRef);
309
+ const { y, width, height } = getAbsolutePositionOfStage(_triggerRef);
310
+ const _triggerBox = _triggerRef.getBoundingClientRect();
311
+ let targetPos = '';
312
+
313
+ // STEP 1:
314
+ //-----------
315
+ // display wrapper
316
+ if (showAct) _modalRef.classList.add('active');
317
+
318
+
319
+ // STEP 2:
320
+ //-----------
321
+ // Detect position
322
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
323
+ targetPos = 'bottom';
324
+ } else {
325
+ targetPos = 'top';
326
+ }
327
+
328
+
329
+ // STEP 3:
330
+ //-----------
331
+ // Adjust position
332
+ if (targetPos === 'top') {
333
+ _modalRef.style.left = x + 'px';
334
+ //_modalRef.style.top = y - POS_OFFSET - (listRef.current.clientHeight) - 2 + 'px';
335
+ _modalRef.style.top = 'auto';
336
+ _modalRef.style.bottom = (window.innerHeight - _triggerBox.top) + POS_OFFSET + 2 + 'px';
337
+ _modalRef.style.setProperty('position', 'fixed', 'important');
338
+ _modalRef.classList.add('pos-top');
339
+ }
340
+
341
+ if (targetPos === 'bottom') {
342
+ _modalRef.style.left = x + 'px';
343
+ _modalRef.style.bottom = 'auto';
344
+ _modalRef.style.top = y + height + POS_OFFSET + 'px';
345
+ _modalRef.style.setProperty('position', 'absolute', 'important');
346
+ _modalRef.classList.remove('pos-top');
347
+ }
348
+
349
+
350
+
351
+ // STEP 4:
352
+ //-----------
353
+ // Determine whether it exceeds the far right or left side of the screen
354
+ const _modalContent = _modalRef;
355
+ const _modalBox = _modalContent.getBoundingClientRect();
356
+ if (typeof _modalContent.dataset.offset === 'undefined' && _modalBox.left > 0) {
357
+
358
+ // 10 pixels is used to account for some bias in mobile devices
359
+ if ((_modalBox.right + 10) > window.innerWidth) {
360
+ const _modalOffsetPosition = _modalBox.right - window.innerWidth + EXCEEDED_SIDE_POS_OFFSET;
361
+ _modalContent.dataset.offset = _modalOffsetPosition;
362
+ _modalContent.style.marginLeft = `-${_modalOffsetPosition}px`;
363
+ // console.log('_modalPosition: ', _modalOffsetPosition)
364
+ }
365
+
366
+
367
+ if ((_modalBox.left - 10) < 0) {
368
+ const _modalOffsetPosition = Math.abs(_modalBox.left) + EXCEEDED_SIDE_POS_OFFSET;
369
+ _modalContent.dataset.offset = _modalOffsetPosition;
370
+ _modalContent.style.marginLeft = `${_modalOffsetPosition}px`;
371
+ // console.log('_modalPosition: ', _modalOffsetPosition)
372
+ }
373
+
374
+
375
+ }
376
+
377
+
378
+
379
+ }
380
+
381
+
382
+
383
+ function popwinPosHide() {
384
+
385
+ const _modalRef: any = document.querySelector(`#casc-menu-e2e__items-wrapper-${idRes}`);
386
+
387
+ if (_modalRef !== null) {
388
+ // remove classnames and styles
389
+ _modalRef.classList.remove('active');
390
+
391
+ }
392
+
393
+ }
394
+
395
+
396
+
397
+ function updateColDisplay(useFetch: boolean, emptyAction: boolean = false, level: number | undefined) {
398
+ if (listRef.current === null) return;
399
+
400
+ let latestDisplayColIndex: number = 0;
401
+ const currentItemsInner: any = listRef.current.querySelector('.casc-menu-e2e__items-inner');
402
+ if (currentItemsInner !== null) {
403
+ const colItemsWrapper = [].slice.call(currentItemsInner.querySelectorAll('.casc-menu-e2e__items-col'));
404
+ colItemsWrapper.forEach((perCol: any) => {
405
+ perCol.classList.remove('hide-col');
406
+ });
407
+
408
+ colItemsWrapper.some((perCol: any, i: number) => {
409
+ const hasActive = [].slice.call(perCol.querySelectorAll('[data-opt]')).some((el: HTMLElement) => el.classList.contains('active'));
410
+ if (!hasActive) {
411
+ latestDisplayColIndex = i;
412
+ return true;
413
+ }
414
+ return false;
415
+ });
416
+
417
+ // remove columns behind the current empty trigger
418
+ colItemsWrapper.forEach((perCol: any, i: number) => {
419
+ if (!emptyAction) {
420
+ if (useFetch) {
421
+ if (i > latestDisplayColIndex && latestDisplayColIndex > 0) perCol.classList.add('hide-col');
422
+ } else {
423
+ if (i === latestDisplayColIndex && latestDisplayColIndex > 0) perCol.classList.add('hide-col');
424
+ }
425
+ } else {
426
+ if (typeof level !== 'undefined' && Number.isInteger(level)) {
427
+ if (i > level) perCol.classList.add('hide-col');
428
+ }
429
+
430
+ }
431
+
432
+
433
+
434
+ });
435
+ }
436
+
437
+
438
+ }
439
+
440
+
441
+ function cancel() {
442
+ // hide list
443
+ setIsShow(false);
444
+ popwinPosHide();
445
+ }
446
+
447
+ function activate() {
448
+ // show list
449
+ setIsShow(true);
450
+
451
+ // update data depth
452
+ setCurrentDataDepth(0);
453
+
454
+ // Execute the fetch task
455
+ if (!firstDataFeched) {
456
+ setLoading(true);
457
+ setFirstDataFeched(true);
458
+ doFetch(false, currentDataDepth, 0, false);
459
+ }
460
+
461
+ // window position
462
+ setTimeout(() => {
463
+ popwinPosInit();
464
+ }, 0);
465
+
466
+
467
+ }
468
+
469
+ async function fetchData(_fetchArray: any, params: string, dataDepth: number, parentId: number = 0) {
470
+
471
+
472
+ const fetchFuncAsync = _fetchArray.fetchFuncAsync;
473
+ const fetchFuncMethod = _fetchArray.fetchFuncMethod;
474
+ const fetchCallback = _fetchArray.fetchCallback;
475
+
476
+ //
477
+ const hierarchical = _fetchArray.hierarchical;
478
+ const indentation = _fetchArray.indentation;
479
+ const doubleIndent = _fetchArray.doubleIndent;
480
+ const INDENT_PLACEHOLDER = doubleIndent ? `&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;` : `&nbsp;&nbsp;&nbsp;&nbsp;`;
481
+ const INDENT_LAST_PLACEHOLDER = `${typeof indentation !== 'undefined' && indentation !== '' ? `${indentation}&nbsp;&nbsp;` : ''}`;
482
+
483
+
484
+
485
+ if (typeof fetchFuncAsync === 'object') {
486
+
487
+ //
488
+ setLoading(true);
489
+
490
+ const response: any = await fetchFuncAsync[`${fetchFuncMethod}`](...params.split(','));
491
+ let _ORGIN_DATA: any[] = response.data;
492
+ let _TEMP_ALL_DATA: any[] = [];
493
+
494
+ // loading
495
+ setLoading(false);
496
+
497
+ if (typeof _ORGIN_DATA[0] === 'undefined') return;
498
+
499
+ // reset data structure
500
+ if (typeof (fetchCallback) === 'function') {
501
+ _ORGIN_DATA = fetchCallback(_ORGIN_DATA);
502
+ }
503
+
504
+
505
+ // Determine whether the data structure matches
506
+ if (_ORGIN_DATA.length > 0 && typeof _ORGIN_DATA[0].id === 'undefined') {
507
+ console.warn('The data structure does not match, please refer to the example in the component documentation.');
508
+ setHasErr(true);
509
+ _ORGIN_DATA = [];
510
+ }
511
+
512
+
513
+ // STEP 0-1: ===========
514
+ // Set hierarchical categories ( with sub-categories )
515
+ if (hierarchical) {
516
+ _ORGIN_DATA = addTreeDepth(_ORGIN_DATA);
517
+ addTreeIndent(_ORGIN_DATA, INDENT_PLACEHOLDER, INDENT_LAST_PLACEHOLDER, 'label');
518
+ }
519
+
520
+
521
+ // STEP 0-2: ===========
522
+ // add data depth
523
+ _ORGIN_DATA.forEach((item: any) => {
524
+ item.itemDepth = dataDepth;
525
+ });
526
+
527
+
528
+
529
+ if (dataDepth === 0) {
530
+
531
+ // STEP 1: ===========
532
+ // all data from fetched data
533
+ _TEMP_ALL_DATA = JSON.parse(JSON.stringify(_ORGIN_DATA));
534
+ allData.current = _TEMP_ALL_DATA;
535
+
536
+ // STEP 2: ===========
537
+ // dictionary data (orginal)
538
+ dictionaryData.current = _TEMP_ALL_DATA;
539
+
540
+
541
+ }
542
+ if (dataDepth > 0) {
543
+
544
+ // STEP 1: ===========
545
+ // all data from fetched data
546
+ _TEMP_ALL_DATA = allData.current;
547
+ addChildrenOpt(_TEMP_ALL_DATA, parentId, _ORGIN_DATA);
548
+
549
+ // STEP 2: ===========
550
+ // dictionary data (orginal)
551
+ dictionaryData.current = _TEMP_ALL_DATA;
552
+
553
+
554
+ }
555
+
556
+
557
+ // STEP 3: ===========
558
+ // Add an empty item to each list to support empty item selection
559
+ const _EMPTY_SUPPORTED_DATA = JSON.parse(JSON.stringify(_TEMP_ALL_DATA));
560
+ addEmptyOpt(_EMPTY_SUPPORTED_DATA, 0);
561
+
562
+
563
+
564
+ // STEP 4: ===========
565
+ // Turn the data of each group into an array
566
+ let _temp_optData;
567
+ if (dataDepth === 0) {
568
+
569
+ _temp_optData = [_EMPTY_SUPPORTED_DATA];
570
+ optData.current = _temp_optData;
571
+ listData.current = _temp_optData;
572
+ }
573
+
574
+ if (dataDepth > 0) {
575
+ _temp_optData = listData.current;
576
+
577
+ // Add an empty item to each list to support empty item selection
578
+ addEmptyOpt(_ORGIN_DATA, 0);
579
+
580
+ const childList = _ORGIN_DATA;
581
+ _temp_optData[dataDepth] = childList;
582
+
583
+
584
+ optData.current = _temp_optData;
585
+ listData.current = optData.current;
586
+ }
587
+
588
+ // STEP 5: ===========
589
+ //
590
+ onFetch?.(_EMPTY_SUPPORTED_DATA, _ORGIN_DATA);
591
+
592
+
593
+
594
+ // STEP 6: ===========
595
+ // update column display with DOM
596
+ updateColDisplay(true, false, undefined);
597
+
598
+
599
+
600
+ return [_ORGIN_DATA, _EMPTY_SUPPORTED_DATA];
601
+
602
+
603
+ } else {
604
+ return [];
605
+ }
606
+
607
+
608
+ }
609
+
610
+
611
+ //
612
+ function doFetch(dataDepthMax: boolean, dataDepth: number = 0, parentId: number = 0, emptyAction: boolean = false) {
613
+
614
+ // if empty selection is selected
615
+ if (emptyAction) return;
616
+
617
+ // If the depth is max, no more requests
618
+ if (dataDepthMax) return;
619
+
620
+
621
+ // other
622
+ if (typeof fetchArray![dataDepth] === 'undefined') return new Promise((resolve, reject) => resolve([[], []]));
623
+
624
+ // data fetch action
625
+ const _oparams: any[] = fetchArray![dataDepth].fetchFuncMethodParams || [];
626
+ const _params: any[] = _oparams.map((item: any) => item !== '$QUERY_ID' ? item : parentId);
627
+ return fetchData(fetchArray![dataDepth], (_params).join(','), dataDepth, parentId);
628
+ }
629
+
630
+
631
+
632
+ function handleFocus(event: any) {
633
+ rootRef.current?.classList.add('focus');
634
+
635
+ //
636
+ handleDisplayOptions(null);
637
+
638
+ //
639
+ onFocus?.(event);
640
+ }
641
+
642
+
643
+ function handleBlur(event: any) {
644
+
645
+ //----
646
+ //remove focus style
647
+ rootRef.current?.classList.remove('focus');
648
+
649
+
650
+ //
651
+ onBlur?.(event);
652
+ }
653
+
654
+
655
+
656
+ function handleDisplayOptions(event: any) {
657
+ if (event) event.preventDefault();
658
+ if (isShow) return;
659
+ activate();
660
+ }
661
+
662
+
663
+ function handleClickItem(e: any, resValue: any, index: number, level: number, curData: any[]) {
664
+ e.preventDefault();
665
+
666
+ const maxDepth: number = fetchArray!.length - 1;
667
+ const dataDepthMax: boolean = resValue.itemDepth === maxDepth;
668
+ const parentId: number = e.currentTarget.dataset.query;
669
+ const emptyAction: boolean = resValue.id.toString().indexOf('$EMPTY_ID_') < 0 ? false : true;
670
+
671
+
672
+ // update data depth
673
+ //////////////////////////////////////////
674
+ setCurrentDataDepth((prevState) => {
675
+ const _currentDataDepth = resValue.itemDepth + 1;
676
+
677
+
678
+ // update column display with DOM
679
+ //////////////////////////////////////////
680
+ updateColDisplay(false, emptyAction, level);
681
+
682
+ // Execute the fetch task
683
+ //////////////////////////////////////////
684
+ doFetch(dataDepthMax, _currentDataDepth, parentId, emptyAction)?.then((res: any) => {
685
+
686
+ // if no data is available with request, close the modal
687
+ if (typeof res === 'undefined') {
688
+ updateColDisplay(false, true, level); // clean rest colums hardhanded
689
+ cancel();
690
+ }
691
+
692
+ });
693
+
694
+ return _currentDataDepth > maxDepth ? maxDepth : _currentDataDepth;
695
+
696
+ });
697
+
698
+
699
+ //update selected data by clicked item
700
+ //////////////////////////////////////////
701
+ updateValueByClickedItem(resValue, level);
702
+
703
+
704
+ // update value
705
+ //////////////////////////////////////////
706
+ const inputVal = updateValue(dictionaryData.current, resValue.id, level);
707
+
708
+ // callback
709
+ //////////////////////////////////////////
710
+ if (typeof onChange === 'function') {
711
+ const curValString = valueType === 'value' ? inputVal[0] : inputVal[1];
712
+ const curValCallback = typeof formatInputResult === 'function' ? formatInputResult(
713
+ VALUE_BY_BRACES
714
+ ? extractContentsOfMixedCharactersWithBraces(curValString)
715
+ : extractContentsOfMixedCharactersWithComma(curValString)
716
+ ) : curValString;
717
+
718
+ onChange(inputRef.current, resValue, index, level, curValCallback, cancel);
719
+ }
720
+
721
+
722
+ // update data
723
+ //////////////////////////////////////////
724
+ let newData: any = curData; // such as: [Array(6), Array(3)]
725
+
726
+ // remove Duplicate objects from JSON Array
727
+ newData = newData.filter((item: any, index: number, self: any) => index === self.findIndex((t: any) => (JSON.stringify(t) === JSON.stringify(item))));
728
+
729
+
730
+ // All the elements from start(array.length - start) to the end of the array will be deleted.
731
+ newData.splice(level + 1);
732
+
733
+ // When requesting a return asynchronously, a new column is added only under the currently clicked column,
734
+ // and the previous column cannot be affected.
735
+ // Make sure that subsequent asynchronous requests will only insert new columns towards the level+1 position.
736
+ listData.current = [...newData];
737
+
738
+
739
+ // active status
740
+ if (resValue.children) {
741
+ const childList = resValue.children;
742
+ markAllItems(childList);
743
+ newData[level + 1] = childList;
744
+ }
745
+
746
+ markCurrent(newData[level], index);
747
+
748
+
749
+
750
+ // close modal
751
+ //////////////////////////////////////////
752
+ if (dataDepthMax && resValue.id.toString().indexOf('$EMPTY_ID_') < 0) {
753
+
754
+ //
755
+ cancel();
756
+
757
+ }
758
+
759
+ // active current option with DOM
760
+ //////////////////////////////////////////
761
+ const currentItemsInner: any = e.currentTarget.closest('.casc-menu-e2e__items-inner');
762
+ if (currentItemsInner !== null) {
763
+ curData.forEach((v: any, col: number) => {
764
+ const colItemsWrapper = currentItemsInner.querySelectorAll('.casc-menu-e2e__items-col');
765
+ colItemsWrapper.forEach((perCol: HTMLUListElement) => {
766
+ const _col = Number(perCol.dataset.col);
767
+
768
+ if (_col >= level) {
769
+ [].slice.call(perCol.querySelectorAll('[data-opt]')).forEach((node: HTMLElement) => {
770
+ node.classList.remove('active');
771
+ });
772
+ }
773
+ });
774
+ });
775
+
776
+
777
+ // not header option
778
+ if (typeof e.currentTarget.dataset.optHeader === 'undefined') e.currentTarget.classList.add('active');
779
+
780
+
781
+ }
782
+
783
+
784
+
785
+
786
+ }
787
+
788
+
789
+
790
+ /**
791
+ * Active the selected item
792
+ * @param arr
793
+ * @param index
794
+ * @returns
795
+ */
796
+ function markCurrent(arr: any[], index: number) {
797
+ if (!Array.isArray(arr)) return;
798
+
799
+ // click an item
800
+ //////////////////////////////////////////
801
+ for (let i = 0; i < arr.length; i++) {
802
+ if (i === index) {
803
+ arr[i].current = true;
804
+ } else {
805
+ arr[i].current = false;
806
+ }
807
+ }
808
+
809
+ // return result
810
+ //////////////////////////////////////////
811
+ return arr;
812
+ }
813
+
814
+ /**
815
+ * Deactivate all items
816
+ * @param arr
817
+ * @returns
818
+ */
819
+ function markAllItems(arr: any[]) {
820
+ for (let i = 0; i < arr.length; i++) {
821
+ arr[i].current = false;
822
+ if (arr[i].children) markAllItems(arr[i].children);
823
+ }
824
+ }
825
+
826
+
827
+
828
+ function updateValue(arr: any[], targetVal: any, level: number | boolean = false) {
829
+
830
+ const inputEl: any = inputRef.current;
831
+ let _valueData: any, _labelData: any, _queryIdsData: any;
832
+
833
+
834
+ if (targetVal.toString().indexOf('$EMPTY_ID_') >= 0) {
835
+
836
+ // If clearing the current column
837
+ //////////////////////////////////////////
838
+ _valueData = selectedData.current.values;
839
+ _labelData = selectedData.current.labels;
840
+ _queryIdsData = selectedData.current.queryIds;
841
+
842
+ // update result to input
843
+ _valueData.splice(level);
844
+ _labelData.splice(level);
845
+ _queryIdsData.splice(level);
846
+
847
+ //
848
+ selectedData.current = {
849
+ labels: _labelData,
850
+ values: _valueData,
851
+ queryIds: _queryIdsData,
852
+ };
853
+
854
+
855
+
856
+ } else {
857
+
858
+
859
+ // click an item
860
+ //////////////////////////////////////////
861
+ //search JSON key that contains specific string
862
+ const _labels = queryResultOfJSON(arr, targetVal, 'value');
863
+ const _values = queryResultOfJSON(arr, targetVal, 'key');
864
+ const _queryIds = queryResultOfJSON(arr, targetVal, 'query');
865
+
866
+
867
+
868
+ // update result to input
869
+ _valueData = _values ? _values.map((item: any) => item) : [];
870
+ _labelData = _labels ? _labels.map((item: any) => item) : [];
871
+ _queryIdsData = _queryIds ? _queryIds.map((item: any) => item) : [];
872
+
873
+ //
874
+ selectedData.current = {
875
+ labels: _labelData,
876
+ values: _valueData,
877
+ queryIds: _queryIdsData,
878
+ };
879
+
880
+
881
+
882
+ }
883
+
884
+
885
+ // update selected data
886
+ //////////////////////////////////////////
887
+ if (destroyParentIdMatch) {
888
+ _valueData = selectedDataByClick.current.values;
889
+ _labelData = selectedDataByClick.current.labels;
890
+ _queryIdsData = selectedDataByClick.current.queryIds;
891
+ }
892
+
893
+ const inputVal_0 = resultInput(_valueData, _queryIdsData);
894
+ const inputVal_1 = resultInput(_labelData, _queryIdsData);
895
+
896
+ if (valueType === 'value') {
897
+ if (inputEl !== null) setChangedVal(inputVal_0);
898
+ } else {
899
+ if (inputEl !== null) setChangedVal(inputVal_1);
900
+ }
901
+
902
+ return {
903
+ 0: inputVal_0,
904
+ 1: inputVal_1
905
+ }
906
+
907
+ }
908
+
909
+ function updateValueByClickedItem(targetData: any, level: number) {
910
+
911
+ //update selected data by clicked item
912
+ //////////////////////////////////////////
913
+ const _valueData = selectedDataByClick.current.values.slice(0, level + 1);
914
+ const _labelData = selectedDataByClick.current.labels.slice(0, level + 1);
915
+ const _queryIdsData = selectedDataByClick.current.queryIds.slice(0, level + 1);
916
+
917
+ _valueData.splice(level, 1, targetData.id);
918
+ _labelData.splice(level, 1, targetData.name);
919
+ if (Array.isArray(_queryIdsData)) _queryIdsData.splice(level, 1, targetData.queryId);
920
+
921
+
922
+ selectedDataByClick.current = {
923
+ labels: _labelData.filter((v: any) => v != ''),
924
+ values: _valueData.filter((v: any) => v.toString().indexOf('$EMPTY_ID_') < 0),
925
+ queryIds: Array.isArray(_queryIdsData) ? _queryIdsData.filter((v: any) => v != undefined) : _labelData.filter((v: any) => v != ''),
926
+ };
927
+
928
+ }
929
+
930
+
931
+ function cleanValue() {
932
+ selectedData.current = {
933
+ labels: [],
934
+ values: [],
935
+ queryIds: []
936
+ };
937
+
938
+ selectedDataByClick.current = {
939
+ labels: [],
940
+ values: [],
941
+ queryIds: []
942
+ };
943
+
944
+ listData.current = [];
945
+ allData.current = [];
946
+ optData.current = [];
947
+ dictionaryData.current = [];
948
+
949
+ setChangedVal('');
950
+ setFirstDataFeched(false);
951
+
952
+ }
953
+
954
+ function chkValueExist(v: any) {
955
+ return typeof v !== 'undefined' && v !== '';
956
+ }
957
+
958
+
959
+ function initDefaultValue(defaultValue: any) {
960
+
961
+
962
+ // STEP 1:
963
+ // Determine whether the splicing value of the default value is empty
964
+ //--------------------------------
965
+ if (chkValueExist(defaultValue)) {
966
+
967
+ // if the default value uses the pure string
968
+ if (!extractorExist(defaultValue)) {
969
+
970
+ //Set a default value
971
+ selectedData.current = {
972
+ labels: [defaultValue],
973
+ values: [''],
974
+ queryIds: ['']
975
+ };
976
+
977
+ selectedDataByClick.current = {
978
+ labels: [defaultValue],
979
+ values: [''],
980
+ queryIds: ['']
981
+ };
982
+ setChangedVal(defaultValue);
983
+
984
+ return; // required RETURN
985
+
986
+ }
987
+
988
+
989
+ //
990
+ const formattedDefaultValue = VALUE_BY_BRACES ? extractContentsOfBraces(defaultValue) : defaultValue.split(',');
991
+ const emptyDefaultValueCheck = Array.isArray(formattedDefaultValue) ? formattedDefaultValue.every((item: any, index: number) => {
992
+ if (item !== '[]') {
993
+ return false;
994
+ }
995
+
996
+ return true;
997
+ }) : true;
998
+
999
+ if (emptyDefaultValueCheck) {
1000
+ cleanValue();
1001
+ return; // required RETURN
1002
+ }
1003
+ }
1004
+
1005
+ // STEP 2:
1006
+ // change the value to trigger component rendering
1007
+ //--------------------------------
1008
+ if (!chkValueExist(defaultValue)) {
1009
+ cleanValue();
1010
+ return; // required RETURN
1011
+ } else {
1012
+ setChangedVal(defaultValue);
1013
+ }
1014
+
1015
+
1016
+ // STEP 3:
1017
+ // update the status of the first fetch
1018
+ //--------------------------------
1019
+ setFirstDataFeched(true);
1020
+
1021
+
1022
+ // STEP 4:
1023
+ // do fetch
1024
+ //--------------------------------
1025
+ doFetch(false, 0, 0, false)?.then((firstColResponse: any) => {
1026
+
1027
+
1028
+ const _ORGIN_DATA: any[] = firstColResponse[0];
1029
+ const _CHILDREN_DATA: any[] = firstColResponse[1];
1030
+ let activedIndex: any;
1031
+ const allFetch: any[] = [];
1032
+
1033
+ const rowQueryAttr: string = valueType === 'value' ? 'id' : 'name';
1034
+ const targetVal: any = defaultValue.match(/(\[.*?\])/gi)!.map((item: any, i: number) => VALUE_BY_BRACES ? extractContentsOfBraces(defaultValue)[i].replace(item, '') : defaultValue.split(',')[i].replace(item, ''));
1035
+ const queryIds: any = extractContentsOfBrackets(defaultValue);
1036
+
1037
+ //
1038
+ let _TEMP_ALL_DATA: any[] = [];
1039
+
1040
+ //
1041
+ const _allColumnsData: any[] = [];
1042
+ const _allLables: any[] = [];
1043
+ const _allValues: any[] = [];
1044
+
1045
+
1046
+ // loop over each column
1047
+ //////////////////////////////////////////
1048
+ for (let col = 0; col <= targetVal.length; col++) {
1049
+
1050
+ if (col === 0) {
1051
+
1052
+ // STEP 1: ===========
1053
+ //active item from current column
1054
+ const newData: any[] = JSON.parse(JSON.stringify(_CHILDREN_DATA));
1055
+ activedIndex = _CHILDREN_DATA.findIndex((item: any) => {
1056
+ return item[rowQueryAttr].toString() === targetVal[col].toString();
1057
+ });
1058
+
1059
+ markAllItems(newData);
1060
+ markCurrent(newData, activedIndex);
1061
+
1062
+
1063
+ // STEP 2: ===========
1064
+ // all data from fetched data
1065
+ _TEMP_ALL_DATA = _ORGIN_DATA;
1066
+
1067
+ // STEP 3: ===========
1068
+ // dictionary data (orginal)
1069
+ // Same as the `STEP 2`
1070
+
1071
+
1072
+ // STEP 4: ===========
1073
+ // update result data
1074
+ if (activedIndex !== -1) {
1075
+ _allLables.push(newData[activedIndex].name);
1076
+ _allValues.push(newData[activedIndex].id);
1077
+ }
1078
+
1079
+ _allColumnsData.push(newData);
1080
+
1081
+
1082
+
1083
+ }
1084
+
1085
+ if (col > 0) {
1086
+ allFetch.push(doFetch(false, col, queryIds[col - 1], false));
1087
+ }
1088
+
1089
+
1090
+ }
1091
+
1092
+ // fetch all columns except the first
1093
+ //////////////////////////////////////////
1094
+ Promise.all(allFetch).then((values) => {
1095
+
1096
+
1097
+ values.filter((v: any) => typeof v !== 'undefined').forEach((colResponse: any, i: number) => {
1098
+
1099
+ const _CURRENT_COL_DATA: any[] = colResponse[0];
1100
+ const curDepth: number = i + 1;
1101
+
1102
+ // STEP 1: ===========
1103
+ //active item from current column
1104
+ const newData: any[] = JSON.parse(JSON.stringify(_CURRENT_COL_DATA));
1105
+ activedIndex = newData.findIndex((item: any) => {
1106
+ if (typeof targetVal[curDepth] !== 'undefined') {
1107
+ return item[rowQueryAttr].toString() === targetVal[curDepth].toString();
1108
+ }
1109
+ });
1110
+
1111
+ markAllItems(newData);
1112
+ markCurrent(newData, activedIndex);
1113
+
1114
+ // STEP 2: ===========
1115
+ // all data from fetched data
1116
+ if (typeof values[curDepth] !== 'undefined') {
1117
+ const childList = values[curDepth][0];
1118
+
1119
+ // if the value of some column is not fetched
1120
+ if (typeof newData[activedIndex] !== 'undefined') newData[activedIndex].children = childList;
1121
+
1122
+ }
1123
+
1124
+
1125
+
1126
+ _TEMP_ALL_DATA.forEach((item: any) => {
1127
+ if (item.id === queryIds[i]) item.children = newData;
1128
+ });
1129
+
1130
+
1131
+ // STEP 3: ===========
1132
+ // dictionary data (orginal)
1133
+ dictionaryData.current = newData;
1134
+
1135
+
1136
+ // STEP 4: ===========
1137
+ // update result data
1138
+ if (activedIndex !== -1) {
1139
+ _allLables.push(newData[activedIndex].name);
1140
+ _allValues.push(newData[activedIndex].id);
1141
+ }
1142
+
1143
+ _allColumnsData.push(newData);
1144
+
1145
+
1146
+ return true;
1147
+
1148
+ });
1149
+
1150
+
1151
+ // STEP 5: ===========
1152
+ // all data from fetched data
1153
+ allData.current = _TEMP_ALL_DATA;
1154
+
1155
+ // STEP 6: ===========
1156
+ // dictionary data (orginal)
1157
+ dictionaryData.current = _TEMP_ALL_DATA;
1158
+
1159
+
1160
+ // STEP 7: ===========
1161
+ //update data
1162
+ optData.current = _allColumnsData;
1163
+ listData.current = _allColumnsData;
1164
+
1165
+
1166
+ // STEP 8: ===========
1167
+ //Set a default value
1168
+ selectedData.current = {
1169
+ labels: _allLables,
1170
+ values: _allValues,
1171
+ queryIds: queryIds,
1172
+ };
1173
+
1174
+ selectedDataByClick.current = {
1175
+ labels: _allLables,
1176
+ values: _allValues,
1177
+ queryIds: queryIds,
1178
+ };
1179
+
1180
+
1181
+
1182
+
1183
+ });
1184
+
1185
+
1186
+
1187
+ });
1188
+
1189
+
1190
+ }
1191
+
1192
+
1193
+
1194
+ function fillColumnTitle() {
1195
+
1196
+ const dataDepth = fetchArray!.length;
1197
+ const oldColumnTitleData = columnTitle ? columnTitle : [];
1198
+ const newColumnTitleData = new Array(dataDepth)?.fill('');
1199
+ oldColumnTitleData!.forEach((item: any, index: number) => {
1200
+ newColumnTitleData[index] = item;
1201
+ });
1202
+
1203
+ //
1204
+ if (oldColumnTitleData.length > dataDepth) {
1205
+ newColumnTitleData.splice(dataDepth, oldColumnTitleData.length - dataDepth);
1206
+ }
1207
+
1208
+ setColumnTitleData(newColumnTitleData);
1209
+ }
1210
+
1211
+
1212
+ function addChildrenOpt(obj: any[], parentId: number, childrenData: any[]) {
1213
+
1214
+
1215
+ // Traverse the results obtained by all fetch
1216
+ obj.forEach((item: any) => {
1217
+
1218
+ // !!!IMPORTANT:
1219
+ // You need to put the contents of other columns after fetch into the "children" attribute
1220
+ if (item.id === parentId) item.children = childrenData;
1221
+
1222
+ if (item.children) {
1223
+ addChildrenOpt(item.children, parentId, childrenData);
1224
+ }
1225
+ });
1226
+ }
1227
+
1228
+
1229
+ function addEmptyOpt(obj: any[], index: number) {
1230
+
1231
+ index++;
1232
+
1233
+ obj.unshift({
1234
+ id: "$EMPTY_ID_" + index,
1235
+ name: "",
1236
+ itemDepth: obj.length === 0 ? 0 : obj[0].itemDepth
1237
+ });
1238
+
1239
+ obj.forEach((item: any, depth: number) => {
1240
+ if (item.children) {
1241
+ addEmptyOpt(item.children, index * (depth + 1));
1242
+ }
1243
+ });
1244
+ }
1245
+
1246
+ function queryResultOfJSON(data: any[], targetVal: any, returnType: string) {
1247
+
1248
+ let callbackValueNested: any[] = [];
1249
+ let lastFirstLevelName = '';
1250
+ let loop = true;
1251
+ let resDepth = 0;
1252
+ const rowQueryAttr = 'id';
1253
+
1254
+ const getIndexOf = function (arr: any[], val: any) {
1255
+ for (let i = 0; i < arr.length; i++) {
1256
+ if (arr[i][rowQueryAttr].toString() === val.toString()) return i;
1257
+ }
1258
+ return -1;
1259
+ };
1260
+
1261
+
1262
+ const searchJsonStr = function (list: any[], depth?: any) {
1263
+
1264
+ // `depth` is very important, it is used to accurately judge the final result
1265
+ if (typeof (depth) === 'undefined') {
1266
+ depth = 0;
1267
+ } else {
1268
+ depth++;
1269
+ }
1270
+
1271
+ for (let i = 0; i < list.length; i++) {
1272
+
1273
+ const row = list[i];
1274
+ let callbackValue: any;
1275
+
1276
+ if (returnType === 'key') callbackValue = row[rowQueryAttr].toString();
1277
+ if (returnType === 'value') callbackValue = row.name.toString();
1278
+ if (returnType === 'query') callbackValue = typeof row.queryId !== 'undefined' ? row.queryId.toString() : '';
1279
+
1280
+
1281
+ if (loop) {
1282
+ // get first-level item
1283
+ if (getIndexOf(data, row[rowQueryAttr]) !== -1) {
1284
+ callbackValueNested.push(callbackValue as never);
1285
+ lastFirstLevelName = callbackValue;
1286
+ }
1287
+
1288
+ // get child-level item
1289
+ if (row.children) {
1290
+ callbackValueNested.push(callbackValue as never);
1291
+ }
1292
+
1293
+ }
1294
+
1295
+
1296
+ //check the value
1297
+ if (row[rowQueryAttr].toString() === targetVal.toString()) {
1298
+ callbackValueNested.push(callbackValue as never);
1299
+ loop = false;
1300
+ resDepth = depth;
1301
+ break;
1302
+ }
1303
+
1304
+ // Note: Recursion must be placed here
1305
+ if (loop) {
1306
+ if (row.children) {
1307
+ searchJsonStr(row.children, depth);
1308
+ }
1309
+ }
1310
+
1311
+
1312
+ }
1313
+
1314
+
1315
+ }
1316
+ searchJsonStr(data);
1317
+
1318
+
1319
+ // (1) Remove duplicate values
1320
+ //------------------------------------------
1321
+ callbackValueNested = callbackValueNested.filter(function (item, index, arr) {
1322
+ return arr.indexOf(item, 0) === index;
1323
+ });
1324
+
1325
+
1326
+ // (2) Delete needless first-level
1327
+ //------------------------------------------
1328
+ let resAll = callbackValueNested.slice(callbackValueNested.indexOf(lastFirstLevelName as never), callbackValueNested.length)
1329
+
1330
+
1331
+ // (3) Returns result
1332
+ //------------------------------------------
1333
+ if (resAll.length > 1) {
1334
+ // Get first-level item
1335
+ resAll.splice(1);
1336
+
1337
+ // Get child-level item
1338
+ let resChild = callbackValueNested.slice(-resDepth); // Get the last elements in reverse
1339
+
1340
+ // Combine
1341
+ resAll = resAll.concat(resChild);
1342
+
1343
+ }
1344
+
1345
+ return resAll;
1346
+
1347
+ }
1348
+
1349
+ function displayInfo(destroyParentId: boolean) {
1350
+
1351
+ const _data = destroyParentId ? selectedDataByClick.current : selectedData.current;
1352
+ let formattedDefaultValue: any = changedVal !== '' ? VALUE_BY_BRACES ? extractContentsOfBraces(changedVal) : changedVal.split(',') : [];
1353
+ let _labels = Array.isArray(_data.labels) && _data.labels.length > 0 ? _data.labels : [];
1354
+
1355
+ // Prevent value from being a pure string that does not include "[]"
1356
+ if (formattedDefaultValue === '') formattedDefaultValue = [];
1357
+
1358
+ // Sometimes the array may be empty due to rendering speed
1359
+ if (_labels.length === 0) {
1360
+ _labels = formattedDefaultValue.map((s: string | number) => s.toString().replace(/[\w\s]/gi, '').replace(/\[\]/g, ''));
1361
+ }
1362
+
1363
+ return _labels.length > 0 ? _labels.map((item: any, i: number, arr: any[]) => {
1364
+ if (arr.length - 1 === i) {
1365
+ return (
1366
+ <div key={i}>
1367
+ <span dangerouslySetInnerHTML={{
1368
+ __html: item
1369
+ }}></span>
1370
+ </div>
1371
+ )
1372
+ } else {
1373
+ return (
1374
+ <div key={i}>
1375
+ <span dangerouslySetInnerHTML={{
1376
+ __html: item
1377
+ }}></span>
1378
+ {arrowGenerator()}
1379
+ </div>
1380
+ )
1381
+ }
1382
+ }) : '';
1383
+
1384
+ }
1385
+
1386
+ function arrowGenerator() {
1387
+ return displayResultArrow ? displayResultArrow : <svg viewBox="0 0 22 22" width="8px"><path d="m345.44 248.29l-194.29 194.28c-12.359 12.365-32.397 12.365-44.75 0-12.354-12.354-12.354-32.391 0-44.744l171.91-171.91-171.91-171.9c-12.354-12.359-12.354-32.394 0-44.748 12.354-12.359 32.391-12.359 44.75 0l194.29 194.28c6.177 6.18 9.262 14.271 9.262 22.366 0 8.099-3.091 16.196-9.267 22.373" transform="matrix(.03541-.00013.00013.03541 2.98 3.02)" fill="#a5a5a5" /></svg>;
1388
+ }
1389
+
1390
+
1391
+ useEffect(() => {
1392
+
1393
+
1394
+ // column titles
1395
+ //--------------
1396
+ fillColumnTitle();
1397
+
1398
+ // Initialize default value (request parameters for each level)
1399
+ //--------------
1400
+ initDefaultValue(value);
1401
+
1402
+
1403
+ }, [value]);
1404
+
1405
+
1406
+ // Automatically complete and truncate column Search Keywords each time the number of columns changes
1407
+ useEffect(() => {
1408
+ if (listData.current.length !== columnSearchKeywords.length) {
1409
+ setColumnSearchKeywords(
1410
+ Array(listData.current.length).fill('').map((v, i) => columnSearchKeywords[i] || '')
1411
+ );
1412
+ }
1413
+ }, [listData.current.length]);
1414
+
1415
+ useEffect(() => {
1416
+ return () => {
1417
+ // update data depth
1418
+ setCurrentDataDepth(0);
1419
+ }
1420
+ }, []);
1421
+
1422
+
1423
+
1424
+ return (
1425
+ <>
1426
+
1427
+ <div
1428
+ className={clsWrite(wrapperClassName, 'casc-menu-e2e__wrapper mb-3 position-relative', `casc-menu-e2e__wrapper ${wrapperClassName}`)}
1429
+ ref={rootRef}
1430
+ data-overlay-id={`casc-menu-e2e__items-wrapper-${idRes}`}
1431
+ >
1432
+ {label ? <>{typeof label === 'string' ? <label htmlFor={idRes} className="form-label" dangerouslySetInnerHTML={{ __html: `${label}` }}></label> : <label htmlFor={idRes} className="form-label" >{label}</label>}</> : null}
1433
+
1434
+ {triggerContent ? <>
1435
+ <div className={clsWrite(triggerClassName, 'casc-menu-e2e__trigger d-inline w-auto', `casc-menu-e2e__trigger ${triggerClassName}`)} onClick={handleDisplayOptions}>{triggerContent}</div>
1436
+ </> : null}
1437
+
1438
+
1439
+ {!hasErr ? (
1440
+ <RootPortal show={true} containerClassName="CascadingSelectE2E">
1441
+ <div
1442
+ ref={listRef}
1443
+ id={`casc-menu-e2e__items-wrapper-${idRes}`}
1444
+ className="casc-menu-e2e__items-wrapper position-absolute border shadow small"
1445
+ style={{ zIndex: DEPTH, display: 'none' }}
1446
+ >
1447
+ <ul className="casc-menu-e2e__items-inner">
1448
+ {loading ? <><div className="casc-menu-e2e__items-loader">{loader || <svg height="12px" width="12px" viewBox="0 0 512 512"><g><path fill="inherit" d="M256,0c-23.357,0-42.297,18.932-42.297,42.288c0,23.358,18.94,42.288,42.297,42.288c23.357,0,42.279-18.93,42.279-42.288C298.279,18.932,279.357,0,256,0z" /><path fill="inherit" d="M256,427.424c-23.357,0-42.297,18.931-42.297,42.288C213.703,493.07,232.643,512,256,512c23.357,0,42.279-18.93,42.279-42.288C298.279,446.355,279.357,427.424,256,427.424z" /><path fill="inherit" d="M74.974,74.983c-16.52,16.511-16.52,43.286,0,59.806c16.52,16.52,43.287,16.52,59.806,0c16.52-16.511,16.52-43.286,0-59.806C118.261,58.463,91.494,58.463,74.974,74.983z" /><path fill="inherit" d="M377.203,377.211c-16.503,16.52-16.503,43.296,0,59.815c16.519,16.52,43.304,16.52,59.806,0c16.52-16.51,16.52-43.295,0-59.815C420.489,360.692,393.722,360.7,377.203,377.211z" /><path fill="inherit" d="M84.567,256c0.018-23.348-18.922-42.279-42.279-42.279c-23.357-0.009-42.297,18.932-42.279,42.288c-0.018,23.348,18.904,42.279,42.279,42.279C65.645,298.288,84.567,279.358,84.567,256z" /><path fill="inherit" d="M469.712,213.712c-23.357,0-42.279,18.941-42.297,42.288c0,23.358,18.94,42.288,42.297,42.297c23.357,0,42.297-18.94,42.279-42.297C512.009,232.652,493.069,213.712,469.712,213.712z" /><path fill="inherit" d="M74.991,377.22c-16.519,16.511-16.519,43.296,0,59.806c16.503,16.52,43.27,16.52,59.789,0c16.52-16.519,16.52-43.295,0-59.815C118.278,360.692,91.511,360.692,74.991,377.22z" /><path fill="inherit" d="M437.026,134.798c16.52-16.52,16.52-43.304,0-59.824c-16.519-16.511-43.304-16.52-59.823,0c-16.52,16.52-16.503,43.295,0,59.815C393.722,151.309,420.507,151.309,437.026,134.798z" /></g></svg>}</div></> : null}
1449
+ {showCloseBtn ? <a href="#" tabIndex={-1} onClick={(e) => {
1450
+ e.preventDefault();
1451
+ cancel();
1452
+ }} className="casc-menu-e2e__close position-absolute top-0 end-0 mt-0 mx-1"><svg width="10px" height="10px" viewBox="0 0 1024 1024"><path fill="#000" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z" /></svg></a> : null}
1453
+
1454
+
1455
+
1456
+ {listData.current.map((item: any, level: number) => {
1457
+
1458
+ if (item.length > 0) {
1459
+
1460
+ // filter data
1461
+ let filteredItem = item;
1462
+ if (searchable && columnSearchKeywords[level]) {
1463
+ const keyword = columnSearchKeywords[level].toLowerCase();
1464
+ filteredItem = item.filter((opt: any) =>
1465
+ (htmlToPlain(opt.name) || '').toLowerCase().includes(keyword)
1466
+ );
1467
+ }
1468
+
1469
+
1470
+ return (
1471
+ <li key={level} data-col={level} className="casc-menu-e2e__items-col">
1472
+
1473
+
1474
+ {/* SEARCH BOX */}
1475
+ {searchable && (
1476
+ <div className="casc-menu-e2e__items-col-searchbox">
1477
+ <input
1478
+ type="text"
1479
+ placeholder={searchPlaceholder}
1480
+ value={columnSearchKeywords[level] || ''}
1481
+ onChange={e => {
1482
+ const newKeywords = [...columnSearchKeywords];
1483
+ newKeywords[level] = e.target.value;
1484
+ setColumnSearchKeywords(newKeywords);
1485
+ }}
1486
+ />
1487
+ </div>
1488
+ )}
1489
+ {/* /SEARCH BOX */}
1490
+
1491
+ <Group
1492
+ perColumnHeadersShow={perColumnHeadersShow}
1493
+ level={level}
1494
+ columnTitle={columnTitleData}
1495
+ data={filteredItem} // filter result
1496
+ cleanNodeBtnClassName={cleanNodeBtnClassName}
1497
+ cleanNodeBtnContent={cleanNodeBtnContent}
1498
+ selectEv={(e, value, index) => handleClickItem(e, value, index, level, listData.current)}
1499
+ />
1500
+ </li>
1501
+ )
1502
+ } else {
1503
+ return null;
1504
+ }
1505
+
1506
+ })}
1507
+ </ul>
1508
+
1509
+ </div>
1510
+
1511
+ </RootPortal>
1512
+
1513
+ ) : null}
1514
+
1515
+
1516
+
1517
+ <div className={combinedCls(
1518
+ 'casc-menu-e2e__val',
1519
+ {
1520
+ 'inputable': inputable,
1521
+ }
1522
+
1523
+ )}
1524
+ onClick={handleDisplayOptions}
1525
+ >
1526
+
1527
+
1528
+ {/* INPIT */}
1529
+ <div className={combinedCls(
1530
+ 'position-relative',
1531
+ clsWrite(controlGroupWrapperClassName, 'input-group'),
1532
+ {
1533
+ 'has-left-content': propExist(iconLeft),
1534
+ 'has-right-content': propExist(iconRight) || propExist(units)
1535
+ }
1536
+
1537
+ )}>
1538
+
1539
+ {propExist(iconLeft) ? <><span className={clsWrite(controlGroupTextClassName, 'input-group-text')}>{iconLeft}</span></> : null}
1540
+
1541
+ <div className="input-group-control-container flex-fill position-relative">
1542
+ <input
1543
+ ref={(node) => {
1544
+ inputRef.current = node;
1545
+ if (typeof externalRef === 'function') {
1546
+ externalRef(node);
1547
+ } else if (externalRef) {
1548
+ externalRef.current = node;
1549
+ }
1550
+ }}
1551
+ id={idRes}
1552
+ data-overlay-id={`casc-menu-e2e__items-wrapper-${idRes}`}
1553
+ name={name}
1554
+ className={combinedCls(
1555
+ clsWrite(controlClassName, 'form-control'),
1556
+ controlExClassName,
1557
+ {
1558
+ 'rounded': !propExist(iconLeft) && !propExist(iconRight) && !propExist(units),
1559
+ 'rounded-start-0': propExist(iconLeft),
1560
+ 'rounded-end-0': propExist(iconRight) || propExist(units)
1561
+ }
1562
+ )}
1563
+
1564
+ placeholder={placeholder}
1565
+ value={(() => {
1566
+ const curValForamt: string = resultInputPureText(changedVal);
1567
+ let curValCallback: string = '';
1568
+
1569
+ // STEP 1
1570
+ //============
1571
+
1572
+ if (inputable) {
1573
+ curValCallback = curValForamt;
1574
+ } else {
1575
+ curValCallback = destroyParentIdMatch ? (valueType === 'value'
1576
+ ? resultInput(selectedDataByClick.current.values, selectedDataByClick.current.queryIds)
1577
+ : resultInput(selectedDataByClick.current.labels, selectedDataByClick.current.queryIds)
1578
+ ) : curValForamt;
1579
+ }
1580
+
1581
+
1582
+ // STEP 2
1583
+ //============
1584
+ if (typeof formatInputResult === 'function') {
1585
+
1586
+ return formatInputResult(
1587
+ VALUE_BY_BRACES
1588
+ ? extractContentsOfMixedCharactersWithBraces(curValCallback)
1589
+ : extractContentsOfMixedCharactersWithComma(curValCallback)
1590
+ );
1591
+
1592
+ } else {
1593
+ return changedVal;
1594
+ }
1595
+
1596
+
1597
+ })()
1598
+ }
1599
+ // placeholder will not change if defaultValue is used
1600
+ onFocus={handleFocus}
1601
+ onBlur={handleBlur}
1602
+ autoComplete="off"
1603
+ disabled={disabled || null}
1604
+ readOnly={readOnly || null}
1605
+ required={required || null}
1606
+ minLength={minLength || null}
1607
+ maxLength={maxLength || null}
1608
+ style={style}
1609
+ tabIndex={tabIndex || 0}
1610
+ onChange={inputable ? (e) => {
1611
+ setChangedVal(e.target.value);
1612
+ if (typeof onChange === 'function') {
1613
+ onChange(
1614
+ e, // input dom event
1615
+ null, // currentData
1616
+ null, // index
1617
+ null, // depth
1618
+ e.target.value, // value
1619
+ cancel
1620
+ );
1621
+ }
1622
+ } : undefined}
1623
+ {...attributes}
1624
+
1625
+ />
1626
+
1627
+
1628
+
1629
+ {/** REVIEW RESULT */}
1630
+ {destroyParentIdMatch ? <>
1631
+ {!inputable ? <div className="casc-menu-e2e__result">{displayInfo(true)}</div> : null}
1632
+ </> : <>
1633
+ {!inputable ? <div className="casc-menu-e2e__result">{displayInfo(false)}</div> : null}
1634
+ </>}
1635
+
1636
+
1637
+ {/* Required marking */}
1638
+ {required ? <>{requiredLabel || requiredLabel === '' ? requiredLabel : <span className="position-absolute end-0 top-0 my-2 mx-2 pe-3"><span className="text-danger">*</span></span>}</> : ''}
1639
+
1640
+ </div>
1641
+
1642
+
1643
+ {propExist(units) ? <><span className={clsWrite(controlGroupTextClassName, 'input-group-text')}>{units}</span></> : null}
1644
+ {propExist(iconRight) ? <><span className={clsWrite(controlGroupTextClassName, 'input-group-text')}>{iconRight}</span></> : null}
1645
+
1646
+ </div>
1647
+ {/* /INPIT */}
1648
+
1649
+
1650
+ {isShow ? <div
1651
+ className="casc-menu-e2e__closemask"
1652
+ onClick={(e) => {
1653
+ e.preventDefault();
1654
+ cancel();
1655
+ }}></div> : null}
1656
+
1657
+
1658
+ <span className="arrow" style={{ pointerEvents: 'none' }}>
1659
+ {controlArrow ? controlArrow : <svg width="10px" height="10px" viewBox="0 -4.5 20 20">
1660
+ <g stroke="none" strokeWidth="1" fill="none">
1661
+ <g transform="translate(-180.000000, -6684.000000)" className="arrow-fill-g" fill="#a5a5a5">
1662
+ <g transform="translate(56.000000, 160.000000)">
1663
+ <path d="M144,6525.39 L142.594,6524 L133.987,6532.261 L133.069,6531.38 L133.074,6531.385 L125.427,6524.045 L124,6525.414 C126.113,6527.443 132.014,6533.107 133.987,6535 C135.453,6533.594 134.024,6534.965 144,6525.39">
1664
+ </path>
1665
+ </g>
1666
+ </g>
1667
+ </g>
1668
+ </svg>}
1669
+ </span>
1670
+
1671
+ </div>
1672
+
1673
+
1674
+
1675
+
1676
+
1677
+ </div>
1678
+
1679
+
1680
+ </>
1681
+ )
1682
+ });
1683
+
1684
+ export default CascadingSelectE2E;