funda-ui 4.5.712 → 4.5.766

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 (501) hide show
  1. package/Chatbox/index.d.ts +54 -0
  2. package/{publish/lib/cjs/Date → Chatbox}/index.js +2465 -3802
  3. package/README.md +4 -105
  4. package/Utils/useStreamController.d.ts +71 -0
  5. package/Utils/useStreamController.js +494 -0
  6. package/{publish/all.d.ts → all.d.ts} +1 -0
  7. package/{publish/all.js → all.js} +1 -0
  8. package/lib/cjs/Chatbox/index.d.ts +54 -0
  9. package/lib/cjs/Chatbox/index.js +4863 -0
  10. package/lib/cjs/Utils/useStreamController.d.ts +71 -0
  11. package/lib/cjs/Utils/useStreamController.js +494 -0
  12. package/lib/cjs/index.d.ts +1 -0
  13. package/lib/cjs/index.js +1 -0
  14. package/lib/esm/Chatbox/PureLoader.tsx +45 -0
  15. package/lib/esm/Chatbox/TypingEffect.tsx +32 -0
  16. package/lib/esm/Chatbox/index.scss +502 -0
  17. package/lib/esm/Chatbox/index.tsx +1171 -0
  18. package/lib/esm/Chatbox/useStreamController.tsx +277 -0
  19. package/lib/esm/Chatbox/utils/func.ts +107 -0
  20. package/lib/esm/Textarea/index.tsx +1 -0
  21. package/lib/esm/Utils/hooks/useStreamController.tsx +277 -0
  22. package/lib/esm/index.js +1 -0
  23. package/package.json +44 -41
  24. package/.gitattributes +0 -2
  25. package/README_PUBLISH.md +0 -126
  26. package/logo.png +0 -0
  27. package/preview.png +0 -0
  28. package/publish/LICENSE +0 -21
  29. package/publish/README.md +0 -126
  30. package/publish/lib/cjs/Accordion/index.d.ts +0 -2
  31. package/publish/lib/cjs/Accordion/index.js +0 -1035
  32. package/publish/lib/cjs/BackToTop/index.d.ts +0 -17
  33. package/publish/lib/cjs/BackToTop/index.js +0 -904
  34. package/publish/lib/cjs/CascadingSelect/index.d.ts +0 -60
  35. package/publish/lib/cjs/CascadingSelect/index.js +0 -2943
  36. package/publish/lib/cjs/CascadingSelectE2E/index.d.ts +0 -71
  37. package/publish/lib/cjs/CascadingSelectE2E/index.js +0 -3540
  38. package/publish/lib/cjs/Checkbox/index.d.ts +0 -28
  39. package/publish/lib/cjs/Checkbox/index.js +0 -662
  40. package/publish/lib/cjs/ColorPicker/index.d.ts +0 -27
  41. package/publish/lib/cjs/ColorPicker/index.js +0 -662
  42. package/publish/lib/cjs/Date/index.d.ts +0 -70
  43. package/publish/lib/cjs/DigitalClock/index.d.ts +0 -7
  44. package/publish/lib/cjs/DigitalClock/index.js +0 -402
  45. package/publish/lib/cjs/DragDropList/index.d.ts +0 -44
  46. package/publish/lib/cjs/DragDropList/index.js +0 -1587
  47. package/publish/lib/cjs/DropdownMenu/index.d.ts +0 -38
  48. package/publish/lib/cjs/DropdownMenu/index.js +0 -1498
  49. package/publish/lib/cjs/DynamicFields/index.d.ts +0 -40
  50. package/publish/lib/cjs/DynamicFields/index.js +0 -810
  51. package/publish/lib/cjs/EventCalendar/index.d.ts +0 -61
  52. package/publish/lib/cjs/EventCalendar/index.js +0 -3740
  53. package/publish/lib/cjs/EventCalendarTimeline/index.d.ts +0 -100
  54. package/publish/lib/cjs/EventCalendarTimeline/index.js +0 -6084
  55. package/publish/lib/cjs/File/index.d.ts +0 -40
  56. package/publish/lib/cjs/File/index.js +0 -1751
  57. package/publish/lib/cjs/HorizontalScrollContent/index.d.ts +0 -14
  58. package/publish/lib/cjs/HorizontalScrollContent/index.js +0 -426
  59. package/publish/lib/cjs/Input/index.d.ts +0 -59
  60. package/publish/lib/cjs/Input/index.js +0 -1455
  61. package/publish/lib/cjs/LiveSearch/index.d.ts +0 -69
  62. package/publish/lib/cjs/LiveSearch/index.js +0 -3626
  63. package/publish/lib/cjs/MasonryLayout/index.d.ts +0 -14
  64. package/publish/lib/cjs/MasonryLayout/index.js +0 -689
  65. package/publish/lib/cjs/ModalDialog/index.d.ts +0 -79
  66. package/publish/lib/cjs/ModalDialog/index.js +0 -1695
  67. package/publish/lib/cjs/ModeSwitch/index.d.ts +0 -17
  68. package/publish/lib/cjs/ModeSwitch/index.js +0 -202
  69. package/publish/lib/cjs/MultilevelDropdownMenu/index.d.ts +0 -20
  70. package/publish/lib/cjs/MultilevelDropdownMenu/index.js +0 -930
  71. package/publish/lib/cjs/MultipleCheckboxes/index.d.ts +0 -41
  72. package/publish/lib/cjs/MultipleCheckboxes/index.js +0 -1717
  73. package/publish/lib/cjs/MultipleSelect/index.d.ts +0 -65
  74. package/publish/lib/cjs/MultipleSelect/index.js +0 -3704
  75. package/publish/lib/cjs/NativeSelect/index.d.ts +0 -37
  76. package/publish/lib/cjs/NativeSelect/index.js +0 -1631
  77. package/publish/lib/cjs/NumberInput/index.d.ts +0 -40
  78. package/publish/lib/cjs/NumberInput/index.js +0 -1188
  79. package/publish/lib/cjs/Pagination/index.d.ts +0 -51
  80. package/publish/lib/cjs/Pagination/index.js +0 -612
  81. package/publish/lib/cjs/Radio/index.d.ts +0 -45
  82. package/publish/lib/cjs/Radio/index.js +0 -1391
  83. package/publish/lib/cjs/RangeSlider/index.d.ts +0 -22
  84. package/publish/lib/cjs/RangeSlider/index.js +0 -2665
  85. package/publish/lib/cjs/RootPortal/index.d.ts +0 -8
  86. package/publish/lib/cjs/RootPortal/index.js +0 -141
  87. package/publish/lib/cjs/ScrollReveal/index.d.ts +0 -21
  88. package/publish/lib/cjs/ScrollReveal/index.js +0 -401
  89. package/publish/lib/cjs/Scrollbar/index.d.ts +0 -17
  90. package/publish/lib/cjs/Scrollbar/index.js +0 -1107
  91. package/publish/lib/cjs/SearchBar/index.d.ts +0 -41
  92. package/publish/lib/cjs/SearchBar/index.js +0 -701
  93. package/publish/lib/cjs/Select/index.d.ts +0 -99
  94. package/publish/lib/cjs/Select/index.js +0 -5697
  95. package/publish/lib/cjs/ShowMoreLess/index.d.ts +0 -36
  96. package/publish/lib/cjs/ShowMoreLess/index.js +0 -387
  97. package/publish/lib/cjs/Switch/index.d.ts +0 -25
  98. package/publish/lib/cjs/Switch/index.js +0 -628
  99. package/publish/lib/cjs/Table/index.d.ts +0 -12
  100. package/publish/lib/cjs/Table/index.js +0 -2062
  101. package/publish/lib/cjs/Tabs/index.d.ts +0 -3
  102. package/publish/lib/cjs/Tabs/index.js +0 -771
  103. package/publish/lib/cjs/TagInput/index.d.ts +0 -31
  104. package/publish/lib/cjs/TagInput/index.js +0 -1144
  105. package/publish/lib/cjs/Textarea/index.d.ts +0 -50
  106. package/publish/lib/cjs/Textarea/index.js +0 -1784
  107. package/publish/lib/cjs/Toast/index.d.ts +0 -34
  108. package/publish/lib/cjs/Toast/index.js +0 -861
  109. package/publish/lib/cjs/Tooltip/index.d.ts +0 -23
  110. package/publish/lib/cjs/Tooltip/index.js +0 -1674
  111. package/publish/lib/cjs/Tree/index.d.ts +0 -62
  112. package/publish/lib/cjs/Tree/index.js +0 -1960
  113. package/publish/lib/cjs/Utils/anim.d.ts +0 -11
  114. package/publish/lib/cjs/Utils/anim.js +0 -400
  115. package/publish/lib/cjs/Utils/bodyScrollLock.d.ts +0 -8
  116. package/publish/lib/cjs/Utils/bodyScrollLock.js +0 -311
  117. package/publish/lib/cjs/Utils/buffer.d.ts +0 -67
  118. package/publish/lib/cjs/Utils/buffer.js +0 -343
  119. package/publish/lib/cjs/Utils/cls.d.ts +0 -15
  120. package/publish/lib/cjs/Utils/cls.js +0 -124
  121. package/publish/lib/cjs/Utils/convert.d.ts +0 -25
  122. package/publish/lib/cjs/Utils/convert.js +0 -109
  123. package/publish/lib/cjs/Utils/date.d.ts +0 -217
  124. package/publish/lib/cjs/Utils/date.js +0 -567
  125. package/publish/lib/cjs/Utils/dom.d.ts +0 -13
  126. package/publish/lib/cjs/Utils/dom.js +0 -215
  127. package/publish/lib/cjs/Utils/easing.d.ts +0 -29
  128. package/publish/lib/cjs/Utils/easing.js +0 -221
  129. package/publish/lib/cjs/Utils/extract.d.ts +0 -28
  130. package/publish/lib/cjs/Utils/extract.js +0 -130
  131. package/publish/lib/cjs/Utils/getElementProperty.d.ts +0 -52
  132. package/publish/lib/cjs/Utils/getElementProperty.js +0 -189
  133. package/publish/lib/cjs/Utils/guid.d.ts +0 -7
  134. package/publish/lib/cjs/Utils/guid.js +0 -67
  135. package/publish/lib/cjs/Utils/initDefaultOptions.d.ts +0 -21
  136. package/publish/lib/cjs/Utils/initDefaultOptions.js +0 -131
  137. package/publish/lib/cjs/Utils/inputsCalculation.d.ts +0 -28
  138. package/publish/lib/cjs/Utils/inputsCalculation.js +0 -188
  139. package/publish/lib/cjs/Utils/math.d.ts +0 -77
  140. package/publish/lib/cjs/Utils/math.js +0 -305
  141. package/publish/lib/cjs/Utils/object.d.ts +0 -18
  142. package/publish/lib/cjs/Utils/object.js +0 -120
  143. package/publish/lib/cjs/Utils/os.d.ts +0 -2
  144. package/publish/lib/cjs/Utils/os.js +0 -104
  145. package/publish/lib/cjs/Utils/performance.d.ts +0 -3
  146. package/publish/lib/cjs/Utils/performance.js +0 -94
  147. package/publish/lib/cjs/Utils/tree.d.ts +0 -40
  148. package/publish/lib/cjs/Utils/tree.js +0 -195
  149. package/publish/lib/cjs/Utils/useAutosizeTextArea.d.ts +0 -10
  150. package/publish/lib/cjs/Utils/useAutosizeTextArea.js +0 -227
  151. package/publish/lib/cjs/Utils/useBoundedDrag.d.ts +0 -125
  152. package/publish/lib/cjs/Utils/useBoundedDrag.js +0 -380
  153. package/publish/lib/cjs/Utils/useClickOutside.d.ts +0 -33
  154. package/publish/lib/cjs/Utils/useClickOutside.js +0 -166
  155. package/publish/lib/cjs/Utils/useComId.d.ts +0 -6
  156. package/publish/lib/cjs/Utils/useComId.js +0 -114
  157. package/publish/lib/cjs/Utils/useDebounce.d.ts +0 -20
  158. package/publish/lib/cjs/Utils/useDebounce.js +0 -138
  159. package/publish/lib/cjs/Utils/useDragDropPosition.d.ts +0 -169
  160. package/publish/lib/cjs/Utils/useDragDropPosition.js +0 -456
  161. package/publish/lib/cjs/Utils/useDraggable.d.ts +0 -62
  162. package/publish/lib/cjs/Utils/useDraggable.js +0 -348
  163. package/publish/lib/cjs/Utils/useInterval.d.ts +0 -5
  164. package/publish/lib/cjs/Utils/useInterval.js +0 -168
  165. package/publish/lib/cjs/Utils/useIsMobile.d.ts +0 -2
  166. package/publish/lib/cjs/Utils/useIsMobile.js +0 -168
  167. package/publish/lib/cjs/Utils/useKeyPress.d.ts +0 -44
  168. package/publish/lib/cjs/Utils/useKeyPress.js +0 -200
  169. package/publish/lib/cjs/Utils/useThrottle.d.ts +0 -2
  170. package/publish/lib/cjs/Utils/useThrottle.js +0 -136
  171. package/publish/lib/cjs/Utils/useWindowScroll.d.ts +0 -12
  172. package/publish/lib/cjs/Utils/useWindowScroll.js +0 -217
  173. package/publish/lib/cjs/Utils/viewport.d.ts +0 -7
  174. package/publish/lib/cjs/Utils/viewport.js +0 -64
  175. package/publish/lib/cjs/index.d.ts +0 -45
  176. package/publish/lib/cjs/index.js +0 -46
  177. package/publish/lib/css/BackToTop/index.css +0 -34
  178. package/publish/lib/css/CascadingSelect/index.css +0 -216
  179. package/publish/lib/css/CascadingSelectE2E/index.css +0 -216
  180. package/publish/lib/css/ColorPicker/index.css +0 -58
  181. package/publish/lib/css/Date/index.css +0 -434
  182. package/publish/lib/css/DragDropList/index.css +0 -188
  183. package/publish/lib/css/DropdownMenu/index.css +0 -151
  184. package/publish/lib/css/EventCalendar/index.css +0 -300
  185. package/publish/lib/css/EventCalendarTimeline/index.css +0 -694
  186. package/publish/lib/css/HorizontalScrollContent/index.css +0 -70
  187. package/publish/lib/css/LiveSearch/index.css +0 -55
  188. package/publish/lib/css/MultilevelDropdownMenu/index.css +0 -38
  189. package/publish/lib/css/MultipleSelect/index.css +0 -313
  190. package/publish/lib/css/RangeSlider/index.css +0 -150
  191. package/publish/lib/css/Scrollbar/index.css +0 -176
  192. package/publish/lib/css/Select/index.css +0 -368
  193. package/publish/lib/css/ShowMoreLess/index.css +0 -23
  194. package/publish/lib/css/Table/index.css +0 -584
  195. package/publish/lib/css/TagInput/index.css +0 -91
  196. package/publish/lib/css/Toast/index.css +0 -201
  197. package/publish/lib/css/Tooltip/index.css +0 -197
  198. package/publish/lib/css/Tree/index.css +0 -232
  199. package/publish/lib/esm/Accordion/Accordion.tsx +0 -184
  200. package/publish/lib/esm/Accordion/AccordionItem.tsx +0 -143
  201. package/publish/lib/esm/Accordion/index.tsx +0 -2
  202. package/publish/lib/esm/BackToTop/index.scss +0 -47
  203. package/publish/lib/esm/BackToTop/index.tsx +0 -177
  204. package/publish/lib/esm/CascadingSelect/Group.tsx +0 -82
  205. package/publish/lib/esm/CascadingSelect/index.scss +0 -291
  206. package/publish/lib/esm/CascadingSelect/index.tsx +0 -1203
  207. package/publish/lib/esm/CascadingSelectE2E/Group.tsx +0 -83
  208. package/publish/lib/esm/CascadingSelectE2E/index.scss +0 -293
  209. package/publish/lib/esm/CascadingSelectE2E/index.tsx +0 -1471
  210. package/publish/lib/esm/Checkbox/index.tsx +0 -193
  211. package/publish/lib/esm/ColorPicker/index.scss +0 -91
  212. package/publish/lib/esm/ColorPicker/index.tsx +0 -204
  213. package/publish/lib/esm/Date/Calendar.tsx +0 -723
  214. package/publish/lib/esm/Date/index.scss +0 -567
  215. package/publish/lib/esm/Date/index.tsx +0 -1683
  216. package/publish/lib/esm/Date/localization/en_US.js +0 -13
  217. package/publish/lib/esm/Date/localization/zh_CN.js +0 -12
  218. package/publish/lib/esm/DigitalClock/index.tsx +0 -74
  219. package/publish/lib/esm/DragDropList/index.scss +0 -245
  220. package/publish/lib/esm/DragDropList/index.tsx +0 -494
  221. package/publish/lib/esm/DropdownMenu/Option.tsx +0 -55
  222. package/publish/lib/esm/DropdownMenu/index.scss +0 -205
  223. package/publish/lib/esm/DropdownMenu/index.tsx +0 -377
  224. package/publish/lib/esm/DynamicFields/index.tsx +0 -404
  225. package/publish/lib/esm/EventCalendar/index.scss +0 -407
  226. package/publish/lib/esm/EventCalendar/index.tsx +0 -1004
  227. package/publish/lib/esm/EventCalendarTimeline/index.scss +0 -926
  228. package/publish/lib/esm/EventCalendarTimeline/index.tsx +0 -2683
  229. package/publish/lib/esm/File/index.tsx +0 -477
  230. package/publish/lib/esm/HorizontalScrollContent/index.scss +0 -87
  231. package/publish/lib/esm/HorizontalScrollContent/index.tsx +0 -171
  232. package/publish/lib/esm/Input/index.tsx +0 -614
  233. package/publish/lib/esm/LiveSearch/index.scss +0 -82
  234. package/publish/lib/esm/LiveSearch/index.tsx +0 -960
  235. package/publish/lib/esm/MasonryLayout/index.tsx +0 -326
  236. package/publish/lib/esm/ModalDialog/index.tsx +0 -552
  237. package/publish/lib/esm/ModeSwitch/index.tsx +0 -82
  238. package/publish/lib/esm/MultilevelDropdownMenu/ItemList.tsx +0 -265
  239. package/publish/lib/esm/MultilevelDropdownMenu/index.scss +0 -79
  240. package/publish/lib/esm/MultilevelDropdownMenu/index.tsx +0 -77
  241. package/publish/lib/esm/MultipleCheckboxes/index.tsx +0 -669
  242. package/publish/lib/esm/MultipleSelect/index.scss +0 -398
  243. package/publish/lib/esm/MultipleSelect/index.tsx +0 -766
  244. package/publish/lib/esm/MultipleSelect/utils/func.ts +0 -61
  245. package/publish/lib/esm/NativeSelect/index.tsx +0 -396
  246. package/publish/lib/esm/NativeSelect/utils/func.ts +0 -49
  247. package/publish/lib/esm/NumberInput/index.tsx +0 -385
  248. package/publish/lib/esm/Pagination/index.tsx +0 -286
  249. package/publish/lib/esm/Pagination/pagination-navigators.tsx +0 -60
  250. package/publish/lib/esm/Radio/index.tsx +0 -670
  251. package/publish/lib/esm/RangeSlider/index.scss +0 -186
  252. package/publish/lib/esm/RangeSlider/index.tsx +0 -241
  253. package/publish/lib/esm/RootPortal/index.tsx +0 -53
  254. package/publish/lib/esm/ScrollReveal/index.tsx +0 -148
  255. package/publish/lib/esm/Scrollbar/index.scss +0 -221
  256. package/publish/lib/esm/Scrollbar/index.tsx +0 -561
  257. package/publish/lib/esm/SearchBar/index.tsx +0 -253
  258. package/publish/lib/esm/Select/index.scss +0 -553
  259. package/publish/lib/esm/Select/index.tsx +0 -2816
  260. package/publish/lib/esm/Select/utils/func.ts +0 -106
  261. package/publish/lib/esm/ShowMoreLess/index.scss +0 -27
  262. package/publish/lib/esm/ShowMoreLess/index.tsx +0 -145
  263. package/publish/lib/esm/Switch/index.tsx +0 -147
  264. package/publish/lib/esm/Table/Table.tsx +0 -257
  265. package/publish/lib/esm/Table/TableBody.tsx +0 -41
  266. package/publish/lib/esm/Table/TableCaption.tsx +0 -34
  267. package/publish/lib/esm/Table/TableCell.tsx +0 -123
  268. package/publish/lib/esm/Table/TableColgroup.tsx +0 -38
  269. package/publish/lib/esm/Table/TableContext.tsx +0 -26
  270. package/publish/lib/esm/Table/TableFoot.tsx +0 -28
  271. package/publish/lib/esm/Table/TableHead.tsx +0 -28
  272. package/publish/lib/esm/Table/TableRow.tsx +0 -76
  273. package/publish/lib/esm/Table/index.scss +0 -418
  274. package/publish/lib/esm/Table/index.tsx +0 -14
  275. package/publish/lib/esm/Table/utils/DragHandleSprite.tsx +0 -46
  276. package/publish/lib/esm/Table/utils/SortSprite.tsx +0 -57
  277. package/publish/lib/esm/Table/utils/TableFilter.tsx +0 -56
  278. package/publish/lib/esm/Table/utils/ToggleSelection.tsx +0 -225
  279. package/publish/lib/esm/Table/utils/func.ts +0 -171
  280. package/publish/lib/esm/Table/utils/hooks/useTableDraggable.tsx +0 -342
  281. package/publish/lib/esm/Table/utils/hooks/useTableKeyPress.tsx +0 -154
  282. package/publish/lib/esm/Table/utils/hooks/useTableResponsive.tsx +0 -92
  283. package/publish/lib/esm/Table/utils/hooks/useTableSort.tsx +0 -143
  284. package/publish/lib/esm/Tabs/TabList.tsx +0 -50
  285. package/publish/lib/esm/Tabs/TabPanel.tsx +0 -44
  286. package/publish/lib/esm/Tabs/Tabs.tsx +0 -282
  287. package/publish/lib/esm/Tabs/index.tsx +0 -3
  288. package/publish/lib/esm/TagInput/index.scss +0 -126
  289. package/publish/lib/esm/TagInput/index.tsx +0 -352
  290. package/publish/lib/esm/Textarea/index.tsx +0 -608
  291. package/publish/lib/esm/Toast/Item.tsx +0 -124
  292. package/publish/lib/esm/Toast/index.scss +0 -269
  293. package/publish/lib/esm/Toast/index.tsx +0 -374
  294. package/publish/lib/esm/Tooltip/index.scss +0 -269
  295. package/publish/lib/esm/Tooltip/index.tsx +0 -312
  296. package/publish/lib/esm/Tree/TreeList.tsx +0 -616
  297. package/publish/lib/esm/Tree/index.scss +0 -386
  298. package/publish/lib/esm/Tree/index.tsx +0 -396
  299. package/publish/lib/esm/Tree/init-height.tsx +0 -27
  300. package/publish/lib/esm/Tree/utils/func.ts +0 -15
  301. package/publish/lib/esm/Utils/hooks/useAutosizeTextArea.tsx +0 -125
  302. package/publish/lib/esm/Utils/hooks/useBoundedDrag.tsx +0 -301
  303. package/publish/lib/esm/Utils/hooks/useClickOutside.tsx +0 -69
  304. package/publish/lib/esm/Utils/hooks/useComId.tsx +0 -13
  305. package/publish/lib/esm/Utils/hooks/useDebounce.tsx +0 -40
  306. package/publish/lib/esm/Utils/hooks/useDragDropPosition.tsx +0 -420
  307. package/publish/lib/esm/Utils/hooks/useDraggable.tsx +0 -265
  308. package/publish/lib/esm/Utils/hooks/useInterval.tsx +0 -74
  309. package/publish/lib/esm/Utils/hooks/useIsMobile.tsx +0 -56
  310. package/publish/lib/esm/Utils/hooks/useKeyPress.tsx +0 -104
  311. package/publish/lib/esm/Utils/hooks/useThrottle.tsx +0 -39
  312. package/publish/lib/esm/Utils/hooks/useWindowScroll.tsx +0 -83
  313. package/publish/lib/esm/Utils/libs/anim.ts +0 -96
  314. package/publish/lib/esm/Utils/libs/buffer.ts +0 -262
  315. package/publish/lib/esm/Utils/libs/cls.ts +0 -64
  316. package/publish/lib/esm/Utils/libs/convert.ts +0 -59
  317. package/publish/lib/esm/Utils/libs/date.ts +0 -578
  318. package/publish/lib/esm/Utils/libs/dom.ts +0 -150
  319. package/publish/lib/esm/Utils/libs/easing.ts +0 -201
  320. package/publish/lib/esm/Utils/libs/extract.ts +0 -86
  321. package/publish/lib/esm/Utils/libs/getElementProperty.ts +0 -150
  322. package/publish/lib/esm/Utils/libs/guid.ts +0 -16
  323. package/publish/lib/esm/Utils/libs/initDefaultOptions.ts +0 -104
  324. package/publish/lib/esm/Utils/libs/inputsCalculation.ts +0 -160
  325. package/publish/lib/esm/Utils/libs/math.ts +0 -276
  326. package/publish/lib/esm/Utils/libs/object.ts +0 -68
  327. package/publish/lib/esm/Utils/libs/os.ts +0 -63
  328. package/publish/lib/esm/Utils/libs/performance.ts +0 -47
  329. package/publish/lib/esm/Utils/libs/tree.ts +0 -119
  330. package/publish/lib/esm/Utils/libs/viewport.ts +0 -20
  331. package/publish/lib/esm/Utils/plugins/bodyScrollLock.ts +0 -286
  332. package/publish/lib/esm/index.js +0 -43
  333. package/publish/package.json +0 -1
  334. /package/{publish/Accordion → Accordion}/index.d.ts +0 -0
  335. /package/{publish/Accordion → Accordion}/index.js +0 -0
  336. /package/{publish/BackToTop → BackToTop}/index.css +0 -0
  337. /package/{publish/BackToTop → BackToTop}/index.d.ts +0 -0
  338. /package/{publish/BackToTop → BackToTop}/index.js +0 -0
  339. /package/{publish/CascadingSelect → CascadingSelect}/index.css +0 -0
  340. /package/{publish/CascadingSelect → CascadingSelect}/index.d.ts +0 -0
  341. /package/{publish/CascadingSelect → CascadingSelect}/index.js +0 -0
  342. /package/{publish/CascadingSelectE2E → CascadingSelectE2E}/index.css +0 -0
  343. /package/{publish/CascadingSelectE2E → CascadingSelectE2E}/index.d.ts +0 -0
  344. /package/{publish/CascadingSelectE2E → CascadingSelectE2E}/index.js +0 -0
  345. /package/{publish/Checkbox → Checkbox}/index.d.ts +0 -0
  346. /package/{publish/Checkbox → Checkbox}/index.js +0 -0
  347. /package/{publish/ColorPicker → ColorPicker}/index.css +0 -0
  348. /package/{publish/ColorPicker → ColorPicker}/index.d.ts +0 -0
  349. /package/{publish/ColorPicker → ColorPicker}/index.js +0 -0
  350. /package/{publish/Date → Date}/index.css +0 -0
  351. /package/{publish/Date → Date}/index.d.ts +0 -0
  352. /package/{publish/Date → Date}/index.js +0 -0
  353. /package/{publish/DigitalClock → DigitalClock}/index.d.ts +0 -0
  354. /package/{publish/DigitalClock → DigitalClock}/index.js +0 -0
  355. /package/{publish/DragDropList → DragDropList}/index.css +0 -0
  356. /package/{publish/DragDropList → DragDropList}/index.d.ts +0 -0
  357. /package/{publish/DragDropList → DragDropList}/index.js +0 -0
  358. /package/{publish/DropdownMenu → DropdownMenu}/index.css +0 -0
  359. /package/{publish/DropdownMenu → DropdownMenu}/index.d.ts +0 -0
  360. /package/{publish/DropdownMenu → DropdownMenu}/index.js +0 -0
  361. /package/{publish/DynamicFields → DynamicFields}/index.d.ts +0 -0
  362. /package/{publish/DynamicFields → DynamicFields}/index.js +0 -0
  363. /package/{publish/EventCalendar → EventCalendar}/index.css +0 -0
  364. /package/{publish/EventCalendar → EventCalendar}/index.d.ts +0 -0
  365. /package/{publish/EventCalendar → EventCalendar}/index.js +0 -0
  366. /package/{publish/EventCalendarTimeline → EventCalendarTimeline}/index.css +0 -0
  367. /package/{publish/EventCalendarTimeline → EventCalendarTimeline}/index.d.ts +0 -0
  368. /package/{publish/EventCalendarTimeline → EventCalendarTimeline}/index.js +0 -0
  369. /package/{publish/File → File}/index.d.ts +0 -0
  370. /package/{publish/File → File}/index.js +0 -0
  371. /package/{publish/HorizontalScrollContent → HorizontalScrollContent}/index.css +0 -0
  372. /package/{publish/HorizontalScrollContent → HorizontalScrollContent}/index.d.ts +0 -0
  373. /package/{publish/HorizontalScrollContent → HorizontalScrollContent}/index.js +0 -0
  374. /package/{publish/Input → Input}/index.d.ts +0 -0
  375. /package/{publish/Input → Input}/index.js +0 -0
  376. /package/{publish/LiveSearch → LiveSearch}/index.css +0 -0
  377. /package/{publish/LiveSearch → LiveSearch}/index.d.ts +0 -0
  378. /package/{publish/LiveSearch → LiveSearch}/index.js +0 -0
  379. /package/{publish/MasonryLayout → MasonryLayout}/index.d.ts +0 -0
  380. /package/{publish/MasonryLayout → MasonryLayout}/index.js +0 -0
  381. /package/{publish/ModalDialog → ModalDialog}/index.d.ts +0 -0
  382. /package/{publish/ModalDialog → ModalDialog}/index.js +0 -0
  383. /package/{publish/ModeSwitch → ModeSwitch}/index.d.ts +0 -0
  384. /package/{publish/ModeSwitch → ModeSwitch}/index.js +0 -0
  385. /package/{publish/MultilevelDropdownMenu → MultilevelDropdownMenu}/index.css +0 -0
  386. /package/{publish/MultilevelDropdownMenu → MultilevelDropdownMenu}/index.d.ts +0 -0
  387. /package/{publish/MultilevelDropdownMenu → MultilevelDropdownMenu}/index.js +0 -0
  388. /package/{publish/MultipleCheckboxes → MultipleCheckboxes}/index.d.ts +0 -0
  389. /package/{publish/MultipleCheckboxes → MultipleCheckboxes}/index.js +0 -0
  390. /package/{publish/MultipleSelect → MultipleSelect}/index.css +0 -0
  391. /package/{publish/MultipleSelect → MultipleSelect}/index.d.ts +0 -0
  392. /package/{publish/MultipleSelect → MultipleSelect}/index.js +0 -0
  393. /package/{publish/NativeSelect → NativeSelect}/index.d.ts +0 -0
  394. /package/{publish/NativeSelect → NativeSelect}/index.js +0 -0
  395. /package/{publish/NumberInput → NumberInput}/index.d.ts +0 -0
  396. /package/{publish/NumberInput → NumberInput}/index.js +0 -0
  397. /package/{publish/Pagination → Pagination}/index.d.ts +0 -0
  398. /package/{publish/Pagination → Pagination}/index.js +0 -0
  399. /package/{publish/Radio → Radio}/index.d.ts +0 -0
  400. /package/{publish/Radio → Radio}/index.js +0 -0
  401. /package/{publish/RangeSlider → RangeSlider}/index.css +0 -0
  402. /package/{publish/RangeSlider → RangeSlider}/index.d.ts +0 -0
  403. /package/{publish/RangeSlider → RangeSlider}/index.js +0 -0
  404. /package/{publish/RootPortal → RootPortal}/index.d.ts +0 -0
  405. /package/{publish/RootPortal → RootPortal}/index.js +0 -0
  406. /package/{publish/ScrollReveal → ScrollReveal}/index.d.ts +0 -0
  407. /package/{publish/ScrollReveal → ScrollReveal}/index.js +0 -0
  408. /package/{publish/Scrollbar → Scrollbar}/index.css +0 -0
  409. /package/{publish/Scrollbar → Scrollbar}/index.d.ts +0 -0
  410. /package/{publish/Scrollbar → Scrollbar}/index.js +0 -0
  411. /package/{publish/SearchBar → SearchBar}/index.d.ts +0 -0
  412. /package/{publish/SearchBar → SearchBar}/index.js +0 -0
  413. /package/{publish/Select → Select}/index.css +0 -0
  414. /package/{publish/Select → Select}/index.d.ts +0 -0
  415. /package/{publish/Select → Select}/index.js +0 -0
  416. /package/{publish/ShowMoreLess → ShowMoreLess}/index.css +0 -0
  417. /package/{publish/ShowMoreLess → ShowMoreLess}/index.d.ts +0 -0
  418. /package/{publish/ShowMoreLess → ShowMoreLess}/index.js +0 -0
  419. /package/{publish/Switch → Switch}/index.d.ts +0 -0
  420. /package/{publish/Switch → Switch}/index.js +0 -0
  421. /package/{publish/Table → Table}/index.css +0 -0
  422. /package/{publish/Table → Table}/index.d.ts +0 -0
  423. /package/{publish/Table → Table}/index.js +0 -0
  424. /package/{publish/Tabs → Tabs}/index.d.ts +0 -0
  425. /package/{publish/Tabs → Tabs}/index.js +0 -0
  426. /package/{publish/TagInput → TagInput}/index.css +0 -0
  427. /package/{publish/TagInput → TagInput}/index.d.ts +0 -0
  428. /package/{publish/TagInput → TagInput}/index.js +0 -0
  429. /package/{publish/Textarea → Textarea}/index.d.ts +0 -0
  430. /package/{publish/Textarea → Textarea}/index.js +0 -0
  431. /package/{publish/Toast → Toast}/index.css +0 -0
  432. /package/{publish/Toast → Toast}/index.d.ts +0 -0
  433. /package/{publish/Toast → Toast}/index.js +0 -0
  434. /package/{publish/Tooltip → Tooltip}/index.css +0 -0
  435. /package/{publish/Tooltip → Tooltip}/index.d.ts +0 -0
  436. /package/{publish/Tooltip → Tooltip}/index.js +0 -0
  437. /package/{publish/Tree → Tree}/index.css +0 -0
  438. /package/{publish/Tree → Tree}/index.d.ts +0 -0
  439. /package/{publish/Tree → Tree}/index.js +0 -0
  440. /package/{publish/Utils → Utils}/anim.d.ts +0 -0
  441. /package/{publish/Utils → Utils}/anim.js +0 -0
  442. /package/{publish/Utils → Utils}/bodyScrollLock.d.ts +0 -0
  443. /package/{publish/Utils → Utils}/bodyScrollLock.js +0 -0
  444. /package/{publish/Utils → Utils}/buffer.d.ts +0 -0
  445. /package/{publish/Utils → Utils}/buffer.js +0 -0
  446. /package/{publish/Utils → Utils}/cls.d.ts +0 -0
  447. /package/{publish/Utils → Utils}/cls.js +0 -0
  448. /package/{publish/Utils → Utils}/convert.d.ts +0 -0
  449. /package/{publish/Utils → Utils}/convert.js +0 -0
  450. /package/{publish/Utils → Utils}/date.d.ts +0 -0
  451. /package/{publish/Utils → Utils}/date.js +0 -0
  452. /package/{publish/Utils → Utils}/dom.d.ts +0 -0
  453. /package/{publish/Utils → Utils}/dom.js +0 -0
  454. /package/{publish/Utils → Utils}/easing.d.ts +0 -0
  455. /package/{publish/Utils → Utils}/easing.js +0 -0
  456. /package/{publish/Utils → Utils}/extract.d.ts +0 -0
  457. /package/{publish/Utils → Utils}/extract.js +0 -0
  458. /package/{publish/Utils → Utils}/getElementProperty.d.ts +0 -0
  459. /package/{publish/Utils → Utils}/getElementProperty.js +0 -0
  460. /package/{publish/Utils → Utils}/guid.d.ts +0 -0
  461. /package/{publish/Utils → Utils}/guid.js +0 -0
  462. /package/{publish/Utils → Utils}/initDefaultOptions.d.ts +0 -0
  463. /package/{publish/Utils → Utils}/initDefaultOptions.js +0 -0
  464. /package/{publish/Utils → Utils}/inputsCalculation.d.ts +0 -0
  465. /package/{publish/Utils → Utils}/inputsCalculation.js +0 -0
  466. /package/{publish/Utils → Utils}/math.d.ts +0 -0
  467. /package/{publish/Utils → Utils}/math.js +0 -0
  468. /package/{publish/Utils → Utils}/object.d.ts +0 -0
  469. /package/{publish/Utils → Utils}/object.js +0 -0
  470. /package/{publish/Utils → Utils}/os.d.ts +0 -0
  471. /package/{publish/Utils → Utils}/os.js +0 -0
  472. /package/{publish/Utils → Utils}/performance.d.ts +0 -0
  473. /package/{publish/Utils → Utils}/performance.js +0 -0
  474. /package/{publish/Utils → Utils}/tree.d.ts +0 -0
  475. /package/{publish/Utils → Utils}/tree.js +0 -0
  476. /package/{publish/Utils → Utils}/useAutosizeTextArea.d.ts +0 -0
  477. /package/{publish/Utils → Utils}/useAutosizeTextArea.js +0 -0
  478. /package/{publish/Utils → Utils}/useBoundedDrag.d.ts +0 -0
  479. /package/{publish/Utils → Utils}/useBoundedDrag.js +0 -0
  480. /package/{publish/Utils → Utils}/useClickOutside.d.ts +0 -0
  481. /package/{publish/Utils → Utils}/useClickOutside.js +0 -0
  482. /package/{publish/Utils → Utils}/useComId.d.ts +0 -0
  483. /package/{publish/Utils → Utils}/useComId.js +0 -0
  484. /package/{publish/Utils → Utils}/useDebounce.d.ts +0 -0
  485. /package/{publish/Utils → Utils}/useDebounce.js +0 -0
  486. /package/{publish/Utils → Utils}/useDragDropPosition.d.ts +0 -0
  487. /package/{publish/Utils → Utils}/useDragDropPosition.js +0 -0
  488. /package/{publish/Utils → Utils}/useDraggable.d.ts +0 -0
  489. /package/{publish/Utils → Utils}/useDraggable.js +0 -0
  490. /package/{publish/Utils → Utils}/useInterval.d.ts +0 -0
  491. /package/{publish/Utils → Utils}/useInterval.js +0 -0
  492. /package/{publish/Utils → Utils}/useIsMobile.d.ts +0 -0
  493. /package/{publish/Utils → Utils}/useIsMobile.js +0 -0
  494. /package/{publish/Utils → Utils}/useKeyPress.d.ts +0 -0
  495. /package/{publish/Utils → Utils}/useKeyPress.js +0 -0
  496. /package/{publish/Utils → Utils}/useThrottle.d.ts +0 -0
  497. /package/{publish/Utils → Utils}/useThrottle.js +0 -0
  498. /package/{publish/Utils → Utils}/useWindowScroll.d.ts +0 -0
  499. /package/{publish/Utils → Utils}/useWindowScroll.js +0 -0
  500. /package/{publish/Utils → Utils}/viewport.d.ts +0 -0
  501. /package/{publish/Utils → Utils}/viewport.js +0 -0
@@ -1,960 +0,0 @@
1
- import React, { forwardRef, useEffect, useState, useRef, KeyboardEvent, useImperativeHandle } from 'react';
2
-
3
-
4
- import RootPortal from 'funda-root-portal';
5
- import SearchBar from 'funda-searchbar';
6
-
7
- import useComId from 'funda-utils/dist/cjs/useComId';
8
- import {
9
- isJSON
10
- } from 'funda-utils/dist/cjs/initDefaultOptions';
11
- import useWindowScroll from 'funda-utils/dist/cjs/useWindowScroll';
12
- import useClickOutside from 'funda-utils/dist/cjs/useClickOutside';
13
- import useDebounce from 'funda-utils/dist/cjs/useDebounce';
14
- import {
15
- getAbsolutePositionOfStage
16
- } from 'funda-utils/dist/cjs/getElementProperty';
17
- import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
18
-
19
-
20
- export interface OptionConfig {
21
- disabled?: boolean;
22
- label: any;
23
- listItemLabel?: any;
24
- value: any;
25
- queryString: string | number;
26
- }
27
-
28
-
29
- export type LiveSearchProps = {
30
- contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
31
- popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
32
- wrapperClassName?: string;
33
- controlClassName?: string;
34
- controlExClassName?: string;
35
- optionsExClassName?: string;
36
- controlGroupWrapperClassName?: string;
37
- controlGroupTextClassName?: string;
38
- exceededSidePosOffset?: number;
39
- appearance?: string;
40
- isSearchInput?: boolean;
41
- allowSpacingRetrive?: boolean;
42
- value?: string;
43
- label?: React.ReactNode | string;
44
- name?: string;
45
- units?: React.ReactNode | string;
46
- iconLeft?: React.ReactNode | string;
47
- iconRight?: React.ReactNode | string;
48
- minLength?: any;
49
- maxLength?: any;
50
- readOnly?: any;
51
- disabled?: any;
52
- required?: any;
53
- placeholder?: string;
54
- noMatchPopup?: boolean;
55
- options?: OptionConfig[] | string;
56
- winWidth?: string | Function;
57
- icon?: React.ReactNode | string;
58
- btnId?: string;
59
- fetchTrigger?: boolean;
60
- hideIcon?: boolean;
61
- /** Set the depth value of the control to control the display of the pop-up layer appear above.
62
- * Please set it when multiple controls are used at the same time. */
63
- depth?: number;
64
- /** Incoming data, you can set the third parameter of `onFetch` */
65
- data?: any;
66
- /** -- */
67
- id?: string;
68
- autoComplete?: string;
69
- autoCapitalize?: string;
70
- spellCheck?: boolean;
71
- style?: React.CSSProperties;
72
- tabIndex?: number;
73
- [key: `data-${string}`]: string | undefined;
74
- autoShowOptions?: boolean;
75
- fetchNoneInfo?: string;
76
- fetchUpdate?: boolean;
77
- fetchFuncAsync?: any;
78
- fetchFuncMethod?: string;
79
- fetchFuncMethodParams?: any[];
80
- fetchCallback?: (data: any) => void;
81
- onFetch?: (data: any) => void;
82
- onClick?: (inputEl: any, popupEl: any) => void;
83
- onChange?: (inputEl: any, data: any, selectedData: any, popupEl: any) => void;
84
- onKeyboardInput?: (e: any, inputEl: any, popupEl: any) => void;
85
- onBlur?: (inputEl: any, popupEl: any) => void;
86
- onPressEnter?: (inputEl: any, popupEl: any) => void;
87
- };
88
-
89
- const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
90
- const {
91
- contentRef,
92
- popupRef,
93
- wrapperClassName,
94
- controlClassName,
95
- controlExClassName,
96
- optionsExClassName,
97
- controlGroupWrapperClassName,
98
- controlGroupTextClassName,
99
- exceededSidePosOffset,
100
- appearance,
101
- isSearchInput,
102
- allowSpacingRetrive,
103
- readOnly,
104
- disabled,
105
- required,
106
- placeholder,
107
- noMatchPopup,
108
- options,
109
- value,
110
- label,
111
- name,
112
- units,
113
- iconLeft,
114
- iconRight,
115
- minLength,
116
- maxLength,
117
- id,
118
- autoComplete,
119
- autoCapitalize,
120
- spellCheck,
121
- icon,
122
- btnId,
123
- fetchTrigger,
124
- hideIcon,
125
- depth,
126
- style,
127
- winWidth,
128
- tabIndex,
129
- data,
130
- autoShowOptions,
131
- fetchNoneInfo,
132
- fetchUpdate,
133
- fetchFuncAsync,
134
- fetchFuncMethod,
135
- fetchFuncMethodParams,
136
- fetchCallback,
137
- onClick,
138
- onFetch,
139
- onChange,
140
- onKeyboardInput,
141
- onBlur,
142
- onPressEnter,
143
- ...attributes
144
- } = props;
145
-
146
-
147
- const DEPTH = depth || 1055; // the default value same as bootstrap
148
- const POS_OFFSET = 0;
149
- const EXCEEDED_SIDE_POS_OFFSET = Number(exceededSidePosOffset) || 15;
150
- const EMPTY_FOR_FETCH = typeof autoShowOptions === 'undefined' || autoShowOptions === false ? false : true;
151
- const NO_MATCH_POPUP = typeof noMatchPopup === 'undefined' ? true : noMatchPopup;
152
- const WIN_WIDTH = typeof winWidth === 'function' ? winWidth() : winWidth ? winWidth : 'auto';
153
- const uniqueID = useComId();
154
- const idRes = id || uniqueID;
155
- const rootRef = useRef<any>(null);
156
- const inputRef = useRef<any>(null);
157
- const listRef = useRef<any>(null);
158
- const listContentRef = useRef<any>(null);
159
- const optionsRes = options ? (isJSON(options) ? JSON.parse(options as string) : options) : [];
160
-
161
- // return a array of options
162
- let staticOptionsData: OptionConfig[] = optionsRes;
163
-
164
- //
165
- const [firstFetch, setFirstFetch] = useState<boolean>(false);
166
- const [dataInit, setOrginalDataInit] = useState<any[]>(staticOptionsData);
167
- const [orginalData, setOrginalData] = useState<any[]>([]);
168
- const [changedVal, setChangedVal] = useState<string>(value || '');
169
- const [isOpen, setIsOpen] = useState<boolean>(false);
170
- const [hasErr, setHasErr] = useState<boolean>(false);
171
- const [componentFirstLoad, setComponentFirstLoad] = useState<boolean>(false);
172
-
173
-
174
- //performance
175
- const handleChangeFetchSafe = useDebounce((e: any) => {
176
- handleChange(e);
177
- }, 350, [dataInit]);
178
-
179
-
180
- // exposes the following methods
181
- useImperativeHandle(
182
- popupRef,
183
- () => ({
184
- close: () => {
185
- setIsOpen(false);
186
- cancel();
187
- }
188
- }),
189
- [popupRef],
190
- );
191
-
192
- // exposes the following methods
193
- useImperativeHandle(
194
- contentRef,
195
- () => ({
196
- control: () => {
197
- return inputRef.current;
198
- },
199
- clear: (cb?: any) => {
200
- setChangedVal('');
201
- cb?.();
202
- },
203
- set: (value: string, cb?: any) => {
204
- setChangedVal(`${value}`);
205
- cb?.();
206
- }
207
- }),
208
- [contentRef],
209
- );
210
-
211
- // click outside
212
- useClickOutside({
213
- enabled: isOpen && 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
- setIsOpen(false);
226
- cancel();
227
- }
228
- }, [isOpen, rootRef, listRef]);
229
-
230
-
231
-
232
-
233
-
234
- // Add function to the element that should be used as the scrollable area.
235
- const [scrollData, windowScrollUpdate] = useWindowScroll({
236
- performance: ['debounce', 500], // "['debounce', 500]" or "['throttle', 500]"
237
- handle: (scrollData: any) => {
238
- popwinPosInit(false);
239
- }
240
- });
241
-
242
-
243
-
244
- function popwinPosInit(showAct: boolean = true) {
245
- if (listContentRef.current === null || inputRef.current === null) return;
246
-
247
- const contentHeightOffset = 80;
248
- let contentMaxHeight = 0;
249
-
250
- // update modal position
251
- const _modalRef: any = document.querySelector(`#livesearch__options-wrapper-${idRes}`);
252
- const _triggerRef: any = inputRef.current;
253
-
254
- // console.log(getAbsolutePositionOfStage(_triggerRef));
255
-
256
- if (_modalRef === null) return;
257
-
258
- const { x } = getAbsolutePositionOfStage(_triggerRef);
259
- const { y, width, height } = getAbsolutePositionOfStage(_triggerRef);
260
- const _triggerBox = _triggerRef.getBoundingClientRect();
261
- let targetPos = '';
262
-
263
- // STEP 1:
264
- //-----------
265
- // display wrapper
266
- if (showAct) _modalRef.classList.add('active');
267
-
268
-
269
- // STEP 2:
270
- //-----------
271
- // Detect position
272
- if (window.innerHeight - _triggerBox.top > 100) {
273
- targetPos = 'bottom';
274
- } else {
275
- targetPos = 'top';
276
- }
277
-
278
- if (typeof listContentRef.current.dataset.pos === 'undefined') listContentRef.current.dataset.pos = targetPos;
279
-
280
-
281
-
282
- // STEP 3:
283
- //-----------
284
- // Detect content MAX HEIGHT and ACTUAL HEIGHT
285
- let _contentBox = listContentRef.current.getBoundingClientRect();
286
- const _contentActualHeight = listContentRef.current.querySelector('.livesearch__options-contentlist-inner').clientHeight;
287
-
288
-
289
- if (targetPos === 'top') {
290
- contentMaxHeight = _triggerBox.top;
291
-
292
- if (_contentBox.height > _contentActualHeight) {
293
- if (_contentActualHeight > 0) listContentRef.current.style.height = _contentActualHeight + 'px';
294
- } else {
295
- if (_contentActualHeight > 0) listContentRef.current.style.height = _contentActualHeight + 'px';
296
-
297
- // recalculate the height
298
- _contentBox = listContentRef.current.getBoundingClientRect();
299
- if (_contentBox.height > contentMaxHeight) listContentRef.current.style.height = contentMaxHeight - contentHeightOffset + 'px';
300
-
301
- }
302
- }
303
-
304
- if (targetPos === 'bottom') {
305
- contentMaxHeight = window.innerHeight - _triggerBox.bottom;
306
-
307
- if (_contentBox.height > _contentActualHeight) {
308
- if (_contentActualHeight > 0) listContentRef.current.style.height = _contentActualHeight + 'px';
309
- } else {
310
- if (_contentActualHeight > 0) listContentRef.current.style.height = _contentActualHeight + 'px';
311
-
312
- // recalculate the height
313
- _contentBox = listContentRef.current.getBoundingClientRect();
314
- if (_contentBox.height > contentMaxHeight) listContentRef.current.style.height = contentMaxHeight - 10 + 'px';
315
- }
316
-
317
- }
318
-
319
-
320
-
321
- // STEP 4:
322
- //-----------
323
- // Adjust position
324
- if (targetPos === 'top') {
325
- _modalRef.style.left = x + 'px';
326
- //_modalRef.style.top = y - POS_OFFSET - (listContentRef.current.clientHeight) - 2 + 'px';
327
- _modalRef.style.top = 'auto';
328
- _modalRef.style.bottom = (window.innerHeight - _triggerBox.top) + POS_OFFSET + 2 + 'px';
329
- _modalRef.style.setProperty('position', 'fixed', 'important');
330
- _modalRef.classList.add('pos-top');
331
- }
332
-
333
- if (targetPos === 'bottom') {
334
- _modalRef.style.left = x + 'px';
335
- _modalRef.style.bottom = 'auto';
336
- _modalRef.style.top = y + height + POS_OFFSET + 'px';
337
- _modalRef.style.setProperty('position', 'absolute', 'important');
338
- _modalRef.classList.remove('pos-top');
339
- }
340
-
341
-
342
-
343
-
344
-
345
- // STEP 5:
346
- //-----------
347
- // Determine whether it exceeds the far right or left side of the screen
348
- const _modalContent = _modalRef;
349
- const _modalBox = _modalContent.getBoundingClientRect();
350
- if (typeof _modalContent.dataset.offset === 'undefined' && _modalBox.left > 0) {
351
-
352
- // 10 pixels is used to account for some bias in mobile devices
353
- if ((_modalBox.right + 10) > window.innerWidth) {
354
- const _modalOffsetPosition = _modalBox.right - window.innerWidth + EXCEEDED_SIDE_POS_OFFSET;
355
- _modalContent.dataset.offset = _modalOffsetPosition;
356
- _modalContent.style.marginLeft = `-${_modalOffsetPosition}px`;
357
- // console.log('_modalPosition: ', _modalOffsetPosition)
358
- }
359
-
360
-
361
- if ((_modalBox.left - 10) < 0) {
362
- const _modalOffsetPosition = Math.abs(_modalBox.left) + EXCEEDED_SIDE_POS_OFFSET;
363
- _modalContent.dataset.offset = _modalOffsetPosition;
364
- _modalContent.style.marginLeft = `${_modalOffsetPosition}px`;
365
- // console.log('_modalPosition: ', _modalOffsetPosition)
366
- }
367
-
368
-
369
- }
370
-
371
-
372
-
373
- }
374
-
375
-
376
-
377
-
378
- function popwinPosHide() {
379
-
380
- const _modalRef: any = document.querySelector(`#livesearch__options-wrapper-${idRes}`);
381
-
382
- if (_modalRef !== null && listContentRef.current !== null) {
383
-
384
-
385
- // remove classnames and styles
386
- _modalRef.classList.remove('active');
387
- listContentRef.current.style.removeProperty('height');
388
-
389
- // remove data-* attibutes
390
- popwinContainerHeightReset();
391
-
392
- }
393
-
394
-
395
- }
396
-
397
-
398
- function popwinContainerHeightReset() {
399
- if (listContentRef.current === null) return;
400
-
401
- // remove data-* attibutes
402
- listContentRef.current.removeAttribute('data-height');
403
- listContentRef.current.removeAttribute('data-pos');
404
-
405
- }
406
-
407
- //
408
- async function matchData(val: string = '', query: boolean = false, emptyValShowAll: boolean = false) {
409
-
410
- let res: any[] = [];
411
- let filterRes = (data: any[]) => {
412
- return data.filter((item: any) => {
413
-
414
- // Avoid fatal errors causing page crashes
415
- const _queryString = typeof item.queryString !== 'undefined' && item.queryString !== null ? item.queryString : '';
416
- const _val = typeof val !== 'undefined' && val !== null ? val : '';
417
-
418
-
419
- if (emptyValShowAll && val === '') {
420
- return true;
421
- }
422
-
423
- if (allowSpacingRetrive && val == ' ') {
424
- return true;
425
- }
426
-
427
- if (
428
- (
429
- _queryString.split(',').some((l: any) => l.charAt(0) === _val.toLowerCase()) ||
430
- _queryString.split(',').some((l: any) => l.replace(/ /g, '').indexOf(_val.toLowerCase()) >= 0) ||
431
- item.label.toLowerCase().indexOf(_val.toLowerCase()) >= 0
432
- ) &&
433
- _val != ''
434
- ) {
435
- return true;
436
- } else {
437
- return false;
438
- }
439
- });
440
- }
441
-
442
-
443
- if (query) {
444
-
445
- const _oparams: any[] = fetchFuncMethodParams || [];
446
- const _params: any[] = _oparams.map((item: any) => item !== '$QUERY_STRING' ? item : val);
447
- const response: any = await fetchData((_params).join(','));
448
- res = filterRes(response) as never;
449
- return res;
450
- } else {
451
- res = filterRes(dataInit) as never;
452
- return res;
453
- }
454
-
455
-
456
- }
457
-
458
-
459
-
460
- function handleChange(e: any) {
461
- const val = e.target.value;
462
-
463
- setChangedVal(val);
464
-
465
- //
466
- if (!fetchTrigger) {
467
- matchData(val, fetchUpdate, EMPTY_FOR_FETCH).then((response: any) => {
468
-
469
- setOrginalData(response);
470
-
471
-
472
- //
473
- onChange?.(inputRef.current, response, '', listRef.current);
474
-
475
- //
476
- setIsOpen(true);
477
-
478
- // window position
479
- setTimeout(() => {
480
- popwinPosInit();
481
- }, 0);
482
-
483
-
484
-
485
- });
486
- } else {
487
-
488
- //
489
- onChange?.(inputRef.current, orginalData, '', listRef.current);
490
-
491
- // window position
492
- setTimeout(() => {
493
- popwinPosInit();
494
- }, 0);
495
-
496
- }
497
-
498
-
499
-
500
- }
501
-
502
- function cancel() {
503
- setOrginalData([]);
504
- popwinPosHide();
505
- }
506
-
507
-
508
- async function fetchData(params: any) {
509
-
510
- if (typeof fetchFuncAsync === 'object') {
511
-
512
- const response: any = await fetchFuncAsync[`${fetchFuncMethod}`](...params.split(','));
513
- let _ORGIN_DATA = response.data;
514
-
515
- // reset data structure
516
- if (typeof (fetchCallback) === 'function') {
517
- _ORGIN_DATA = fetchCallback(_ORGIN_DATA);
518
- }
519
-
520
- // Determine whether the data structure matches
521
- if (_ORGIN_DATA.length > 0 && typeof _ORGIN_DATA[0].value === 'undefined') {
522
- console.warn('The data structure does not match, please refer to the example in the component documentation.');
523
- setHasErr(true);
524
- _ORGIN_DATA = [];
525
- }
526
-
527
-
528
- //
529
- onFetch?.(_ORGIN_DATA);
530
-
531
- //
532
- setOrginalDataInit(_ORGIN_DATA);
533
-
534
-
535
- //
536
- // window position
537
- if (componentFirstLoad) {
538
-
539
- setTimeout(() => {
540
- popwinPosInit();
541
- }, 500);
542
- }
543
-
544
-
545
- return _ORGIN_DATA;
546
- } else {
547
- return [];
548
- }
549
-
550
-
551
- }
552
-
553
- async function handleSelect(el: any, dataInput: any = false) {
554
-
555
- if (typeof el === 'undefined') return;
556
-
557
-
558
- // update value
559
- if (dataInput) {
560
- const _data = JSON.parse(dataInput);
561
-
562
- onChange?.(inputRef.current, orginalData, _data, listRef.current);
563
- setChangedVal(_data.label);
564
-
565
- } else {
566
- const _curData = typeof el.target !== 'undefined' ? el.target.dataset.itemdata : el.dataset.itemdata;
567
-
568
- const _data = JSON.parse(_curData);
569
-
570
- let res: any = [];
571
-
572
- if (!EMPTY_FOR_FETCH) {
573
- res = await matchData(inputRef.current.value, false, EMPTY_FOR_FETCH);
574
- } else {
575
- res = dataInit;
576
- }
577
-
578
- onChange?.(inputRef.current, res, _data, listRef.current);
579
- setChangedVal(_data.label);
580
- }
581
-
582
-
583
- // cancel
584
- setIsOpen(false);
585
- cancel();
586
- }
587
-
588
- async function handleFetch() {
589
- if (fetchTrigger) {
590
- const res: any = await matchData(changedVal, fetchUpdate, EMPTY_FOR_FETCH);
591
- setOrginalData(res);
592
-
593
-
594
- //
595
- setIsOpen(res.length === 0 ? true : false);
596
-
597
- // window position
598
- setTimeout(() => {
599
- popwinPosInit();
600
- }, 0);
601
-
602
- }
603
- }
604
-
605
- function handleClick() {
606
-
607
- if (!isOpen) {
608
- if (EMPTY_FOR_FETCH) {
609
- setOrginalData(dataInit);
610
- setIsOpen(true);
611
- }
612
-
613
- // window position
614
- setTimeout(() => {
615
- popwinPosInit();
616
- }, 0);
617
- } else {
618
- // cancel
619
- setIsOpen(false);
620
- cancel();
621
- }
622
-
623
-
624
-
625
- onClick?.(inputRef.current, listRef.current)
626
- }
627
-
628
-
629
- function handleBlur(e: any) {
630
-
631
- setIsOpen(false);
632
- if (!fetchTrigger) {
633
- setTimeout(() => {
634
-
635
- //
636
- onBlur?.(inputRef.current, listRef.current);
637
-
638
- //
639
- cancel();
640
-
641
- }, 300);
642
- }
643
-
644
- }
645
-
646
- function handleMouseLeaveTrigger() {
647
- setIsOpen(false);
648
- }
649
-
650
-
651
-
652
- function optionFocus(type: string) {
653
-
654
- return new Promise(function (resolve) {
655
-
656
- // Determine the "active" class name to avoid listening to other unused components of the same type
657
- if (listRef.current === null || !rootRef.current.classList.contains('active')) return;
658
-
659
-
660
- let options = [].slice.call(listRef.current.querySelectorAll('.list-group-item:not(.hide)'));
661
- // Avoid selecting options that are disabled
662
- options = options.filter((options: HTMLElement) => !options.classList.contains('disabled'));
663
-
664
- const currentIndex = options.findIndex((e) => e === listRef.current.querySelector('.list-group-item.active'));
665
-
666
-
667
- // get the next element in the list, "%" will loop around to 0
668
- let nextIndex;
669
- if (type === 'increase') {
670
- nextIndex = currentIndex + 1 % options.length;
671
- } else {
672
- nextIndex = (currentIndex < 0 ? options.length : currentIndex) - 1 % options.length;
673
- }
674
-
675
-
676
-
677
- //only one
678
- if (options.length === 1) nextIndex = 0;
679
-
680
-
681
- if (!isNaN(nextIndex)) {
682
- options.forEach((node: any, index: number) => {
683
- node?.classList.remove('active');
684
- });
685
-
686
- const targetOption = options[nextIndex] as HTMLElement;
687
- if (typeof targetOption !== 'undefined' && !targetOption.classList.contains('no-match')) {
688
- targetOption.classList.add('active');
689
- resolve(targetOption);
690
- }
691
-
692
- }
693
- });
694
-
695
-
696
- }
697
-
698
- async function handleKeyPressed(event: KeyboardEvent<HTMLDivElement>) {
699
- const key = event.code;
700
-
701
- if (!isOpen) return;
702
-
703
- let res: any = null;
704
-
705
- if (key === 'Enter' || key === 'NumpadEnter') {
706
- event.preventDefault();
707
-
708
- // Determine the "active" class name to avoid listening to other unused components of the same type
709
- if (listRef.current === null || !rootRef.current.classList.contains('active')) return;
710
-
711
-
712
- if (listRef.current !== null) {
713
- const currentData = listRef.current.dataset.data;
714
-
715
- if (typeof currentData !== 'undefined') {
716
- handleSelect(null, currentData);
717
-
718
- //
719
- const options = [].slice.call(listRef.current.querySelectorAll('.list-group-item:not(.no-match)'));
720
- options.forEach((node: any) => {
721
- node.classList.remove('active');
722
- });
723
-
724
-
725
- //
726
- onChange?.(inputRef.current, options.map((node: HTMLElement) => JSON.parse(node.dataset.itemdata as any)), JSON.parse(currentData), listRef.current);
727
-
728
- }
729
- }
730
-
731
- }
732
-
733
- if (key === 'ArrowUp') {
734
- res = await optionFocus('decrease');
735
-
736
- }
737
-
738
- if (key === 'ArrowDown') {
739
- res = await optionFocus('increase');
740
- }
741
-
742
- // temporary data
743
- if (res !== null) listRef.current.dataset.data = JSON.stringify({
744
- value: res.dataset.value,
745
- label: res.dataset.label,
746
- queryString: res.dataset.querystring
747
- });
748
- }
749
-
750
-
751
- useEffect(() => {
752
-
753
-
754
- // Component first load
755
- //--------------
756
- if (!componentFirstLoad) {
757
- setComponentFirstLoad(true);
758
- }
759
-
760
-
761
- // update default value
762
- //--------------
763
- setChangedVal(value || '');
764
-
765
-
766
- // data init
767
- //--------------
768
- const _oparams: any[] = fetchFuncMethodParams || [];
769
- const _params: any[] = _oparams.map((item: any) => item !== '$QUERY_STRING' ? item : (fetchTrigger && !fetchUpdate) ? '' : (fetchUpdate ? '------' : (fetchTrigger ? '------' : '')));
770
- if (!firstFetch) {
771
- fetchData((_params).join(','));
772
- setFirstFetch(true); // avoid triggering two data requests if the input value has not changed
773
- }
774
-
775
-
776
-
777
- }, [value, data]);
778
-
779
-
780
- return (
781
- <>
782
-
783
- {label ? <><div className="livesearch__wrapper__label">{typeof label === 'string' ? <label htmlFor={`label-${idRes}`} className="form-label" dangerouslySetInnerHTML={{ __html: `${label}` }}></label> : <label htmlFor={`label-${idRes}`} className="form-label">{label}</label>}</div></> : null}
784
-
785
- <div
786
- ref={rootRef}
787
- className={combinedCls(
788
- 'livesearch__wrapper',
789
- clsWrite(wrapperClassName, 'mb-3 position-relative'),
790
- {
791
- 'active': isOpen
792
- }
793
- )}
794
- onMouseLeave={handleMouseLeaveTrigger}
795
- onKeyDown={handleKeyPressed}
796
- >
797
-
798
-
799
- <SearchBar
800
- wrapperClassName=""
801
- controlClassName={controlClassName}
802
- controlExClassName={controlExClassName}
803
- controlGroupWrapperClassName={controlGroupWrapperClassName}
804
- controlGroupTextClassName={controlGroupTextClassName}
805
- ref={(node) => {
806
- inputRef.current = node;
807
- if (typeof externalRef === 'function') {
808
- externalRef(node);
809
- } else if (externalRef) {
810
- externalRef.current = node;
811
- }
812
- }}
813
- value={changedVal}
814
- label=""
815
- tabIndex={tabIndex}
816
- id={idRes}
817
- name={name}
818
- placeholder={placeholder}
819
- units={units}
820
- iconLeft={iconLeft}
821
- iconRight={iconRight}
822
- minLength={minLength}
823
- maxLength={maxLength}
824
- disabled={disabled}
825
- required={required}
826
- readOnly={readOnly}
827
- style={style}
828
- appearance={appearance}
829
- onChange={(e: any) => {
830
- handleChangeFetchSafe(e);
831
- }}
832
- onBlur={handleBlur}
833
- onSubmit={handleFetch}
834
- onClick={handleClick}
835
- icon={hideIcon ? '' : (!fetchTrigger ? '' : icon)}
836
- btnId={btnId}
837
- autoComplete={typeof autoComplete === 'undefined' ? 'off' : autoComplete}
838
- autoCapitalize={typeof autoCapitalize === 'undefined' ? 'off' : autoCapitalize}
839
- spellCheck={typeof spellCheck === 'undefined' ? false : spellCheck}
840
- isSearchInput={isSearchInput}
841
- onKeyPressedCallback={(e: KeyboardEvent<any>) => {
842
- onKeyboardInput?.(e, inputRef.current, listRef.current);
843
- }}
844
- onPressEnter={(event: any, onComposition: any) => {
845
- onPressEnter?.(event, onComposition);
846
- }}
847
- {...attributes}
848
- />
849
-
850
-
851
- {orginalData && !hasErr ? <>
852
- <RootPortal show={true} containerClassName="LiveSearch">
853
- <div
854
- ref={listRef}
855
- id={`livesearch__options-wrapper-${idRes}`}
856
- className={combinedCls(
857
- 'livesearch__options-wrapper list-group position-absolute border shadow small',
858
- optionsExClassName,
859
- {
860
- 'shadow-none border-0': (orginalData && orginalData.length === 0) && !NO_MATCH_POPUP
861
- }
862
- )}
863
- style={{ zIndex: DEPTH, width: WIN_WIDTH, display: 'none' }}
864
- role="tablist"
865
- >
866
- <div
867
- className={combinedCls(
868
- 'livesearch__options-contentlist rounded',
869
- {
870
- 'd-none': (orginalData && orginalData.length === 0) && !NO_MATCH_POPUP
871
- }
872
- )}
873
- style={{ backgroundColor: 'var(--bs-list-group-bg)' }}
874
- ref={listContentRef}
875
- >
876
- <div className="livesearch__options-contentlist-inner">
877
-
878
-
879
- {/* NO MATCH */}
880
- {orginalData && orginalData.length === 0 ? <>
881
- <button
882
- tabIndex={-1}
883
- type="button"
884
- className="list-group-item list-group-item-action border-top-0 border-bottom-0 no-match livesearch__control-option-item--nomatch"
885
- disabled
886
- >{fetchNoneInfo || 'No match yet'}</button>
887
- </> : null}
888
- {/* /NO MATCH */}
889
-
890
-
891
- {orginalData ? orginalData.map((item, index) => {
892
- const startItemBorder = index === 0 ? 'border-top-0' : '';
893
- const endItemBorder = index === orginalData.length - 1 ? 'border-bottom-0' : '';
894
-
895
- return <button
896
- tabIndex={-1}
897
- type="button"
898
- data-index={index}
899
- key={index}
900
- className={combinedCls(
901
- 'list-group-item list-group-item-action border-start-0 border-end-0 border-top-0 border-bottom-0 livesearch__control-option-item',
902
- startItemBorder,
903
- endItemBorder,
904
- {
905
- 'disabled': item.disabled
906
- }
907
-
908
- )}
909
- data-value={`${item.value}`}
910
- data-label={`${item.label}`}
911
- data-querystring={`${typeof item.queryString === 'undefined' ? '' : item.queryString}`}
912
- data-itemdata={JSON.stringify(item)}
913
- data-list-item-label={`${typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel}`}
914
- role="tab"
915
- dangerouslySetInnerHTML={{
916
- __html: typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel
917
- }}
918
- onClick={handleSelect}
919
- ></button>
920
- }) : null}
921
-
922
- </div>
923
-
924
- </div>
925
-
926
-
927
- </div>
928
-
929
-
930
- </RootPortal>
931
-
932
- </> : null}
933
-
934
-
935
- {hideIcon ? null : <>
936
- {!fetchTrigger ? <>
937
- <span className="livesearch__wrapper-searchbtn">
938
- <button tabIndex={-1} type="button" className="btn border-end-0 rounded-pill" style={{ pointerEvents: 'none' }}>
939
- <svg width="1em" height="1em" fill="#a5a5a5" viewBox="0 0 16 16">
940
- <path d="M12.027 9.92L16 13.95 14 16l-4.075-3.976A6.465 6.465 0 0 1 6.5 13C2.91 13 0 10.083 0 6.5 0 2.91 2.917 0 6.5 0 10.09 0 13 2.917 13 6.5a6.463 6.463 0 0 1-.973 3.42zM1.997 6.452c0 2.48 2.014 4.5 4.5 4.5 2.48 0 4.5-2.015 4.5-4.5 0-2.48-2.015-4.5-4.5-4.5-2.48 0-4.5 2.014-4.5 4.5z" fillRule="evenodd" />
941
- </svg>
942
- </button>
943
-
944
- </span>
945
- </> : null}
946
- </>}
947
-
948
-
949
-
950
-
951
-
952
-
953
- </div>
954
-
955
- </>
956
- )
957
- });
958
-
959
-
960
- export default LiveSearch;