funda-ui 4.5.711 → 4.5.713

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