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,2683 +0,0 @@
1
- import React, { useState, useEffect, useMemo, useRef, useCallback, useImperativeHandle } from 'react';
2
-
3
-
4
- import RootPortal from 'funda-root-portal';
5
- import ModalDialog from 'funda-modaldialog';
6
-
7
- import useComId from 'funda-utils/dist/cjs/useComId';
8
- import useClickOutside from 'funda-utils/dist/cjs/useClickOutside';
9
- import {
10
- getAbsolutePositionOfStage
11
- } from 'funda-utils/dist/cjs/getElementProperty';
12
- import { getTodayDate, getCalendarDate, isValidDate, padZero, getDateDetails, getMonthDates, getWeekDatesFromMon } from 'funda-utils/dist/cjs/date';
13
- import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
14
- import getOs from 'funda-utils//dist/cjs/os';
15
-
16
-
17
-
18
- export interface EventsValueConfig {
19
- id: string | number;
20
- date: string,
21
- time: string,
22
- data: string,
23
- dataTooltip?: string,
24
- eventStyles?: React.CSSProperties;
25
- callback?: () => void;
26
- }
27
-
28
- export interface TimelineRowSectionConfig {
29
- id: string | number;
30
- title: string;
31
- }
32
-
33
- export interface TimelineCellListConfig {
34
- date: string;
35
- list: EventsValueConfig[];
36
- }
37
-
38
- export interface TimelineRowListConfig {
39
- listSection: TimelineRowSectionConfig;
40
- eventSources: TimelineCellListConfig[];
41
- }
42
-
43
- export type EventCalendarTimelineProps = {
44
- contentRef?: React.ForwardedRef<any>;
45
- calendarWrapperClassName?: string;
46
- tableWrapperClassName?: string;
47
- tableClassName?: string;
48
- tableHeadClassName?: string;
49
- tableBodyClassName?: string;
50
- tableListStartClassName?: string;
51
- tableListEndClassName?: string;
52
- tableListDividerClassName?: string;
53
- customTodayDate?: string;
54
- multipleCells?: boolean;
55
- appearance?: 'week' | 'month';
56
- appearanceToggle?: boolean;
57
- appearanceWeekTmpl?: (startDate: string, endDate: string) => void;
58
- eventsValue?: TimelineRowListConfig[];
59
- langWeek?: string[];
60
- langWeekFull?: string[];
61
- langMonths?: string[];
62
- langMonthsFull?: string[];
63
- langToday?: string;
64
- langAppearanceLabelMonth?: string;
65
- langAppearanceLabelWeek?: string
66
- iconRemove?: React.ReactNode | string;
67
- iconAdd?: React.ReactNode | string;
68
- cellCloseBtnClassName?: string;
69
- cellCloseBtnLabel?: string | React.ReactNode;
70
- cellAddBtnClassName?: string;
71
- cellAddBtnLabel?: string | React.ReactNode;
72
- forwardAndBackFillDisabled?: boolean;
73
- draggable?: boolean;
74
- showWeek?: boolean;
75
- autoScroll?: boolean;
76
- onChangeDate?: (e: any, currentData: any) => void;
77
- onChangeMonth?: (currentData: any) => void;
78
- onChangeYear?: (currentData: any) => void;
79
- onChangeToday?: (currentData: any) => void;
80
- onChangeWeek?: (startDate: string, endDate: string) => void;
81
- onListRenderComplete?: () => void;
82
- onChangeAppearanceMode?: (mode: string) => void;
83
-
84
-
85
-
86
- // modal dialog
87
- modalMaskOpacity?: string;
88
- modalMaxWidth?: number | string;
89
- modalMinHeight?: number | string;
90
- modalHeading?: React.ReactNode;
91
- modalContent?: React.ReactNode;
92
- modalDeleteContent?: React.ReactNode;
93
- modalCloseBtnClassName?: string;
94
- modalCloseBtnLabel?: string | React.ReactNode;
95
- modalSubmitBtnClassName?: string;
96
- modalSubmitBtnLabel?: string | React.ReactNode;
97
- modalSubmitDeleteBtnClassName?: string;
98
- modalSubmitDeleteBtnLabel?: string | React.ReactNode;
99
- onModalEditOpen?: (currentData: any, openwin: any, type: 'normal' | 'new') => void;
100
- onModalEditClose?: (currentData: any) => void;
101
- onModalDeleteOpen?: (currentData: any, openwin: any) => void;
102
- onModalDeleteClose?: (currentData: any) => void;
103
- onModalEditEvent?: (currentData: any, closewin: any, gridInit: Function) => void;
104
- onModalDeleteEvent?: (currentData: any, closewin: any, gridInit: Function) => void;
105
-
106
- //
107
- onCellMouseEnter?: (el: any) => void;
108
- onCellMouseLeave?: (el: any) => void;
109
- onCellMouseUp?: (el: any, selectedCellsData: any[]) => void;
110
- onCellClick?: (el: any, cellData: any) => void;
111
- onCellDoubleClick?: (el: any, cellData: any) => void;
112
- onKeyPressed?: (el: any, selectedCellsData: any[]) => void;
113
- onKeyCopy?: (el: any, selectedCellsData: any[]) => void;
114
- onKeyPaste?: (el: any, selectedCellsData: any[]) => void;
115
-
116
- // table
117
- tableListSectionTitle?: string | React.ReactNode;
118
- tableCellMinWidth?: number;
119
-
120
- // tooltip
121
- tableTooltipDirection?: string;
122
- tableTooltipOffset?: number;
123
- tableTooltipExceededSidePosOffset?: number;
124
- tableTooltipSize?: string;
125
- tableTooltipDisabled?: boolean;
126
-
127
- /** -- */
128
- id?: string;
129
- }
130
-
131
-
132
- const EventCalendarTimeline = (props: EventCalendarTimelineProps) => {
133
- const {
134
- contentRef,
135
- calendarWrapperClassName,
136
- tableWrapperClassName,
137
- tableClassName,
138
- tableHeadClassName,
139
- tableBodyClassName,
140
- tableListStartClassName,
141
- tableListEndClassName,
142
- tableListDividerClassName,
143
- multipleCells = false,
144
- customTodayDate,
145
- appearance = 'month',
146
- appearanceToggle = true,
147
- appearanceWeekTmpl,
148
- eventsValue,
149
- langWeek,
150
- langWeekFull,
151
- langMonths,
152
- langMonthsFull,
153
- langToday,
154
- langAppearanceLabelMonth,
155
- langAppearanceLabelWeek,
156
- iconRemove,
157
- iconAdd,
158
- cellCloseBtnClassName,
159
- cellCloseBtnLabel,
160
- cellAddBtnClassName,
161
- cellAddBtnLabel,
162
- forwardAndBackFillDisabled,
163
- draggable,
164
- showWeek,
165
- autoScroll,
166
- onChangeDate,
167
- onChangeMonth,
168
- onChangeYear,
169
- onChangeToday,
170
- onChangeWeek,
171
- onListRenderComplete,
172
- onChangeAppearanceMode,
173
-
174
- //
175
- modalMaskOpacity,
176
- modalMaxWidth,
177
- modalMinHeight,
178
- modalHeading,
179
- modalContent,
180
- modalDeleteContent,
181
- modalCloseBtnClassName,
182
- modalCloseBtnLabel,
183
- modalSubmitBtnClassName,
184
- modalSubmitBtnLabel,
185
- modalSubmitDeleteBtnClassName,
186
- modalSubmitDeleteBtnLabel,
187
- onModalEditOpen,
188
- onModalEditClose,
189
- onModalDeleteOpen,
190
- onModalDeleteClose,
191
- onModalEditEvent,
192
- onModalDeleteEvent,
193
-
194
- //
195
- onCellMouseEnter,
196
- onCellMouseLeave,
197
- onCellMouseUp,
198
- onCellClick,
199
- onCellDoubleClick,
200
- onKeyPressed,
201
- onKeyCopy,
202
- onKeyPaste,
203
-
204
- //
205
- tableListSectionTitle,
206
- tableCellMinWidth,
207
-
208
- //
209
- tableTooltipDirection,
210
- tableTooltipOffset,
211
- tableTooltipExceededSidePosOffset,
212
- tableTooltipSize,
213
- tableTooltipDisabled,
214
-
215
- //
216
- id
217
- } = props;
218
-
219
-
220
- //================================================================
221
- // General
222
- //================================================================
223
- const uniqueID = useComId();
224
- const idRes = id || uniqueID;
225
- const DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
226
- const DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
227
- const WEEK = langWeek || ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'];
228
- const WEEK_FULL = langWeekFull || ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'];
229
- const MONTHS = langMonths || ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
230
- const MONTHS_FULL = langMonthsFull || ['January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
231
- const formatToEnglishMonthDay = (inputDate: string) => {
232
- const date = new Date(inputDate);
233
- const month = MONTHS[date.getMonth()];
234
- const day = date.getDate();
235
- return month + ' ' + day;
236
- };
237
- const START_WEEK_ON = 1; // represents "Monday/1" in JavaScript
238
-
239
- // orginal data
240
- const [orginalData, setOrginalData] = useState<TimelineRowListConfig[]>([]);
241
-
242
- //
243
- const FILL_BLANK_DATE_DISABLD = typeof forwardAndBackFillDisabled === 'undefined' ? true : forwardAndBackFillDisabled;
244
-
245
-
246
- //
247
- const now = useMemo(() => new Date(), []);
248
- const [date, setDate] = useState<Date>(now);
249
- const [day, setDay] = useState<number>(date.getDate());
250
- const [month, setMonth] = useState<number>(date.getMonth());
251
- const [year, setYear] = useState<number>(date.getFullYear());
252
- const [startDay, setStartDay] = useState<number>(getStartDayOfMonth(date));
253
-
254
-
255
- // selection tab
256
- // gets the today date time object
257
- const [selectedMonth, setSelectedMonth] = useState<number>(now.getMonth());
258
- const [selectedYear, setSelectedYear] = useState<number>(now.getFullYear());
259
- const [yearsArray, setYearsCollection] = useState<number[]>([]);
260
-
261
- //
262
- const [winYear, setWinYear] = useState<boolean>(false);
263
- const [winMonth, setWinMonth] = useState<boolean>(false);
264
-
265
- // modal dialog
266
- const modalEditHandleRef = useRef<any>();
267
- const modalDeleteHandleRef = useRef<any>();
268
- const EVENTS_ENABLED = typeof modalContent !== 'undefined';
269
- const EVENTS_DELETE_ENABLED = typeof modalDeleteContent !== 'undefined';
270
- const [showEdit, setShowEdit] = useState<boolean>(false);
271
- const [showDelete, setShowDelete] = useState<boolean>(false);
272
-
273
- // table grid
274
- const AUTO_SCROLL = autoScroll || false;
275
- const SHOW_WEEK = showWeek || false;
276
- const BODY_DRAG = draggable || false;
277
- const CELL_MIN_W = typeof tableCellMinWidth === 'undefined' ? (SHOW_WEEK ? 100 : 50) : tableCellMinWidth;
278
- const tableGridRef = useRef<any>(null);
279
- const tableGridHeaderRef = useRef<any>(null);
280
- const scrollHeaderRef = useRef(null);
281
- const scrollBodyRef = useRef(null);
282
- const scrollListRef = useRef(null);
283
-
284
- // Temporary date
285
- const [tempDate, setTempDate] = useState<string>('');
286
-
287
-
288
-
289
- // Open temporary storage for pop-ups
290
- const [tableRowNum, setTableRowNum] = useState<number>(-1);
291
- const [tableCellId, setTableCellId] = useState<number>(-1);
292
-
293
- // table grid tooltip
294
- const CELL_TOOLTIP_EXCEEDED_SIDE_POS_OFFSET = Number(tableTooltipExceededSidePosOffset) || 15;
295
- const CELL_TOOLTIP_POS_OFFSET = typeof tableTooltipOffset === 'undefined' ? 10 : tableTooltipOffset;
296
- const tableTooltipModalRef = useRef<any>(null);
297
- const [isShowTableTooltip, setIsShowTableTooltip] = useState<boolean>(false);
298
- const [tableTooltipContent, setTableTooltipContent] = useState<any>(null);
299
-
300
-
301
- // appearance mode
302
- const [appearanceMode, setAppearanceMode] = useState<string>(appearance);
303
-
304
-
305
- const findMondayAndTruncate = (dates: string[]) => {
306
- const _res = dates.map((s: string) => new Date(s));
307
- // Find the first Monday in the sequence
308
- for (let i = 0; i < _res.length; i++) {
309
- const date = _res[i];
310
- if (date.getDay() === START_WEEK_ON) {
311
- // Return dates starting from Monday onwards
312
- return dates.slice(i);
313
- }
314
- }
315
-
316
- return []; // Return empty array if no Monday found
317
- }
318
-
319
-
320
-
321
- // exposes the following methods
322
- useImperativeHandle(
323
- contentRef,
324
- () => ({
325
- today: () => {
326
- handleTodayChange();
327
- },
328
- next: () => {
329
- handleNextChange();
330
- },
331
- prev: () => {
332
- handlePrevChange();
333
- },
334
- bodyScrollbarInit: () => {
335
- bodyScrollbarInit();
336
- },
337
- gridInit: () => {
338
- tableGridInit();
339
- },
340
- gridInitHeadertitle: () => {
341
- tableGridInitHeadertitle();
342
- },
343
- gridReset: (cb?: any) => {
344
- tableGridReset();
345
- },
346
- resetSelectedCells: () => {
347
- // reset selection area
348
- setSelectedCells([]);
349
- setCopiedCells(null);
350
- },
351
- closeModal: () => {
352
- if (modalEditHandleRef.current) modalEditHandleRef.current.close();
353
- if (modalDeleteHandleRef.current) modalDeleteHandleRef.current.close();
354
- }
355
- }),
356
- [contentRef],
357
- );
358
-
359
-
360
-
361
- //================================================================
362
- // Monthly calendar
363
- //================================================================
364
- //
365
-
366
-
367
- //================================================================
368
- // Weekly calendar
369
- //================================================================
370
- const [weekOffset, setWeekOffset] = useState<number>(0);
371
- const handleNextWeek = () => {
372
- setWeekOffset(weekOffset + 1);
373
- return weekOffset + 1;
374
- };
375
- const handlePreviousWeek = () => {
376
- setWeekOffset(weekOffset - 1)
377
- return weekOffset - 1;
378
- };
379
- const weekDates = getWeekDatesFromMon(weekOffset);
380
- const [displayWeekForHeader, setDisplayWeekForHeader] = useState<string[]>([]);
381
-
382
-
383
-
384
-
385
-
386
- //================================================================
387
- // Drag to activate the selection area
388
- //================================================================
389
- const [isSelecting, setIsSelecting] = useState<boolean>(false);
390
- const [selectedCells, setSelectedCells] = useState<any[]>([]);
391
- const [startCell, setStartCell] = useState<any>(null);
392
-
393
- // Determine whether it is a selected cell
394
- const isCellSelected = (row: number, col: number) => {
395
- return selectedCells.map((item: any) => [item.row, item.col]).some(([r, c]) => r === row && c === col);
396
- };
397
-
398
-
399
- // Start selecting
400
- const handleTableMainCellMouseDown = (e: React.MouseEvent, row: number, col: number, colsOffset: number) => {
401
- const isMultiSelect = e.ctrlKey || e.metaKey; // Check whether the Ctrl or Command key is pressed
402
-
403
- setIsSelecting(true);
404
- setStartCell({ row, col });
405
-
406
- const _el: any = e.currentTarget;
407
-
408
- setIsSelecting(true);
409
- setStartCell({ row, col });
410
-
411
- setSelectedCells((prevSelectedCells: any[]) => {
412
- if (isMultiSelect) {
413
- // Multi-select mode: Add or remove cells
414
- //++++++++++
415
- const cellExists = prevSelectedCells.some(({ row: r, col: c }) => r === row && c === col);
416
- if (cellExists) {
417
- return prevSelectedCells.filter(({ row: r, col: c }) => !(r === row && c === col));
418
- } else {
419
- return [...prevSelectedCells, {
420
- rowData: JSON.parse(_el.dataset.rowinfo),
421
- date: _el.dataset.date,
422
- row: row,
423
- col: col
424
- }];
425
- }
426
- } else {
427
- // Radio Mode: Clear the previous selection, select only the current cell
428
- //++++++++++
429
- return [{
430
- rowData: JSON.parse(_el.dataset.rowinfo),
431
- date: _el.dataset.date,
432
- row: row,
433
- col: col
434
- }];
435
- }
436
- });
437
-
438
- };
439
-
440
- // Selecting now
441
- const handleTableMainCellMouseEnter = (e: React.MouseEvent, row: number, col: number, colsOffset: number) => {
442
-
443
- if (isSelecting && startCell) {
444
-
445
- //########## MODE: WEEK #############
446
- let curDateList: any[] = [];
447
- if (appearanceMode === 'week') {
448
- curDateList = weekDates.map((v: Date) => getCalendarDate(v));
449
- }
450
- //########## /MODE: WEEK #############
451
-
452
- //########## MODE: MONTH #############
453
- if (appearanceMode === 'month') {
454
- curDateList = getMonthDates(year, month + 1);
455
- }
456
- //########## /MODE: MONTH #############
457
-
458
-
459
- const newSelectedCells: any[] = [];
460
- const [minRow, maxRow] = [startCell.row, row].sort((a, b) => a - b);
461
- const [minCol, maxCol] = [startCell.col, col].sort((a, b) => a - b);
462
-
463
-
464
- for (let r = minRow; r <= maxRow; r++) {
465
- for (let c = minCol; c <= maxCol; c++) {
466
-
467
- // query date and row data
468
- const curRowData: any = orginalData[r];
469
- newSelectedCells.push({
470
- rowData: curRowData?.listSection,
471
- date: curDateList[c - colsOffset],
472
- row: r,
473
- col: c
474
- });
475
- }
476
- }
477
- setSelectedCells(newSelectedCells);
478
- }
479
- };
480
-
481
- // Stop selecting
482
- const handleTableMainMouseUp = (e: React.MouseEvent) => {
483
- setIsSelecting(false);
484
- };
485
-
486
- //================================================================
487
- // Copy & Paste
488
- //================================================================
489
- const [copiedCells, setCopiedCells] = useState<{
490
- structure: {
491
- rows: number,
492
- cols: number
493
- },
494
- offset: { row: number, col: number },
495
- cells: any[]
496
- } | null>(null);
497
-
498
- const handleWrapperKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
499
- const isMac = getOs().isOSX;
500
-
501
- //########## MODE: WEEK #############
502
- let curDateList: any[] = [];
503
- if (appearanceMode === 'week') {
504
- curDateList = weekDates.map((v: Date) => getCalendarDate(v));
505
- }
506
- //########## /MODE: WEEK #############
507
-
508
- //########## MODE: MONTH #############
509
- if (appearanceMode === 'month') {
510
- curDateList = getMonthDates(year, month + 1);
511
- }
512
- //########## /MODE: MONTH #############
513
-
514
-
515
- // Listen for copy
516
- if ((isMac && e.metaKey && e.key === 'c') || (!isMac && e.ctrlKey && e.key === 'c')) {
517
-
518
- if (selectedCells.length > 0) {
519
- // Gets the structure of the selected area
520
- const _selectedCellsCoordinates = selectedCells.map(({ row: r, col: c }) => {
521
- return [r, c];
522
- });
523
-
524
- const [minRow, maxRow] = _selectedCellsCoordinates.reduce(
525
- ([min, max], [r]) => [Math.min(min, r), Math.max(max, r)],
526
- [Infinity, -Infinity]
527
- );
528
- const [minCol, maxCol] = _selectedCellsCoordinates.reduce(
529
- ([min, max], [_, c]) => [Math.min(min, c), Math.max(max, c)],
530
- [Infinity, -Infinity]
531
- );
532
-
533
- /*
534
- [Be equal to:]
535
-
536
- // Suppose _selectedCellsCoordinates is an array of selected cells, each of which is in the form of [row, col].
537
- let minRow = Infinity;
538
- let maxRow = -Infinity;
539
- let minCol = Infinity;
540
- let maxCol = -Infinity;
541
-
542
- for (const [row, col] of _selectedCellsCoordinates) {
543
- if (row < minRow) minRow = row;
544
- if (row > maxRow) maxRow = row;
545
- if (col < minCol) minCol = col;
546
- if (col > maxCol) maxCol = col;
547
- }
548
- */
549
-
550
- // Calculate the offset and adjust the cell coordinates
551
- const adjustedCells = _selectedCellsCoordinates.map(([r, c]) => [r - minRow, c - minCol]);
552
-
553
- // The copy result is independent of the data
554
- setCopiedCells({
555
- structure: {
556
- rows: maxRow - minRow + 1,
557
- cols: maxCol - minCol + 1
558
- },
559
- offset: { row: minRow, col: minCol },
560
- cells: adjustedCells
561
- });
562
-
563
-
564
- //
565
- onKeyCopy?.(e, selectedCells);
566
-
567
- }
568
-
569
- }
570
-
571
- // Listen for paste
572
- if ((isMac && e.metaKey && e.key === 'v') || (!isMac && e.ctrlKey && e.key === 'v')) {
573
-
574
-
575
- if (copiedCells && selectedCells.length > 0) {
576
- const { rowsTotal, colsTotal, forwardFillTotal } = getCells();
577
- const { row: targetRow, col: targetCol } = selectedCells[0]; // the first position
578
- const newSelectedCellsCoordinates = copiedCells.cells.map(([r, c]) => [
579
- targetRow + r,
580
- targetCol + c
581
- ]).filter(([r, c]) => r < rowsTotal && c < colsTotal); // Make sure you don't go beyond the scope of the table
582
-
583
- // query date and row data
584
- const newSelectedCells: any[] = [];
585
- newSelectedCellsCoordinates.forEach((item: any[]) => {
586
- const [r, c] = item;
587
- const curRowData: any = orginalData[r];
588
- newSelectedCells.push({
589
- rowData: curRowData?.listSection,
590
- date: curDateList[c - forwardFillTotal],
591
- row: r,
592
- col: c
593
- });
594
- });
595
-
596
-
597
- setSelectedCells(newSelectedCells);
598
-
599
- //
600
- onKeyPaste?.(e, newSelectedCells);
601
- }
602
- }
603
- };
604
-
605
-
606
-
607
- //================================================================
608
- // Other
609
- //================================================================
610
-
611
- // helper buttons
612
- const _delBtn = () => <>
613
- {iconRemove ? <>{iconRemove}</> : <><svg width="20px" height="20px" viewBox="0 0 24 24" fill="none"><path fillRule="evenodd" clipRule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10ZM8 11a1 1 0 1 0 0 2h8a1 1 0 1 0 0-2H8Z" fill="#000" /></svg></>}
614
- {cellCloseBtnLabel || ''}
615
- </>;
616
-
617
- const _addBtn = () => <>
618
- {iconAdd ? <>{iconAdd}</> : <><svg width="20px" height="20px" viewBox="0 0 32 32"><g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd"><g transform="translate(-102.000000, -1037.000000)" fill="#000000"><path d="M124,1054 L119,1054 L119,1059 C119,1059.55 118.552,1060 118,1060 C117.448,1060 117,1059.55 117,1059 L117,1054 L112,1054 C111.448,1054 111,1053.55 111,1053 C111,1052.45 111.448,1052 112,1052 L117,1052 L117,1047 C117,1046.45 117.448,1046 118,1046 C118.552,1046 119,1046.45 119,1047 L119,1052 L124,1052 C124.552,1052 125,1052.45 125,1053 C125,1053.55 124.552,1054 124,1054 L124,1054 Z M130,1037 L106,1037 C103.791,1037 102,1038.79 102,1041 L102,1065 C102,1067.21 103.791,1069 106,1069 L130,1069 C132.209,1069 134,1067.21 134,1065 L134,1041 C134,1038.79 132.209,1037 130,1037 L130,1037 Z"></path></g></g></svg></>}
619
- {cellAddBtnLabel || ''}
620
- </>;
621
-
622
- // click outside
623
- useClickOutside({
624
- enabled: isShowTableTooltip && tableGridRef.current,
625
- isOutside: (event: any) => {
626
- // close dropdown when other dropdown is opened
627
- return (
628
- (tableGridRef.current !== event.target && !tableGridRef.current.contains(event.target as HTMLElement))
629
- )
630
- },
631
- handle: (event: any) => {
632
- hideTableTooltip();
633
- }
634
- }, [isShowTableTooltip, tableGridRef]);
635
-
636
-
637
-
638
-
639
- // cell
640
- const getCells = (type: 'none' | 'forward' | 'back' = 'none') => {
641
-
642
-
643
- //########## MODE: WEEK #############
644
- if (appearanceMode === 'week') {
645
- const curWeek: any[] = [];
646
- weekDates.forEach((date: Date, dayIndex: number) => {
647
- const _dayOfWeek = new Date(date).getDay();
648
- // ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
649
- const _daysIndicator = [7, 1, 2, 3, 4, 5, 6];
650
- const _detail = getDateDetails(date);
651
- const {
652
- year: _temp_year,
653
- month: _temp_month,
654
- day: _temp_day
655
- } = _detail;
656
-
657
- curWeek.push({
658
- month: Number(_temp_month) - 1,
659
- startDay: _daysIndicator[_dayOfWeek],
660
- row: 0,
661
- col: [
662
- dayIndex
663
- ],
664
- dateInfo: [
665
- {
666
- date: getCalendarDate(date),
667
- firstGroup: false,
668
- lastGroup: false,
669
- validDisplayDate: true
670
- }
671
- ],
672
- weekDisplay: [
673
- WEEK[_daysIndicator[_dayOfWeek] - 1]
674
- ],
675
- week: [
676
- _daysIndicator[_dayOfWeek] - 1
677
- ]
678
- });
679
-
680
- });
681
-
682
- return {
683
- rowsTotal: orginalData.length,
684
- colsTotal: curWeek.length,
685
- forwardFillTotal: 0,
686
- list: curWeek
687
- };
688
-
689
- }
690
- //########## /MODE: WEEK #############
691
-
692
-
693
-
694
- //########## MODE: MONTH #############
695
- if (appearanceMode === 'month') {
696
- let currentMonth: any = month;
697
- let currentStartDay: any = startDay;
698
-
699
- // previous month
700
- if (type === 'forward') {
701
- const _date = new Date(year, currentMonth - 1, day);
702
- currentMonth = _date.getMonth();
703
- currentStartDay = getStartDayOfMonth(_date);
704
- }
705
-
706
- // next month
707
- if (type === 'back') {
708
- const _date = new Date(year, currentMonth + 1, day);
709
- currentMonth = _date.getMonth();
710
- currentStartDay = getStartDayOfMonth(_date);
711
- }
712
-
713
-
714
- //
715
- const allDays = Array(days[currentMonth] + (currentStartDay - 1)).fill(null).map((_: any, i: number) => i); // [0,1,..,30,31]
716
- const rows = Math.ceil(allDays.length / 7); // 5
717
-
718
- //
719
- const _tempCells: any[] = Array.from({ length: rows }).fill(null);
720
-
721
- const _getForwardFill = (_year: number, _month: number) => {
722
- // Get the last day of the previous month
723
- const lastDayOfLastMonth = new Date(_year, _month - 1, 0);
724
- const last7Days: Date[] = [];
725
-
726
- // Rewind 7 days forward from the last day
727
- for (let i = 0; i < 7; i++) {
728
- last7Days.unshift(new Date(lastDayOfLastMonth));
729
- lastDayOfLastMonth.setDate(lastDayOfLastMonth.getDate() - 1);
730
- }
731
- return last7Days.map((v: Date) => getCalendarDate(v));
732
- };
733
-
734
- const _getBackFill = (_year: number, _month: number) => {
735
- // Get the first day of the next month
736
- const firstDayOfNextMonth = new Date(_year, _month, 1);
737
- const first7Days: Date[] = [];
738
-
739
- // Rewind 7 days forward from the first day of the next month
740
- for (let i = 0; i < 7; i++) {
741
- first7Days.push(new Date(firstDayOfNextMonth));
742
- firstDayOfNextMonth.setDate(firstDayOfNextMonth.getDate() + 1);
743
- }
744
-
745
- return first7Days.map((v: Date) => getCalendarDate(v));
746
- };
747
-
748
-
749
-
750
- // The remaining date of the previous month
751
- // If the number is 7, the calendar does not include the date of the previous month
752
- const remainPrevDate = findMondayAndTruncate(_getForwardFill(year, month + 1));
753
- const remainPrevDateTotal = remainPrevDate.length === 7 ? 0 : remainPrevDate.length;
754
-
755
-
756
- return {
757
- rowsTotal: orginalData.length,
758
- colsTotal: allDays.length,
759
- forwardFillTotal: remainPrevDateTotal,
760
- list: _tempCells.map((_: any, j: number) => {
761
- const _col = allDays.slice(j * 7, (j + 1) * 7);
762
-
763
- // back fill
764
- const backFillArr: null[] = [];
765
- for (let k = 0; k < 7 - _col.length; k++) {
766
- backFillArr.push(null);
767
- }
768
- _col.splice(_col.length, 0, ...backFillArr as any);
769
-
770
-
771
- //
772
- const isFirstGroup = j === 0;
773
- const isLastGroup = j === _tempCells.length - 1;
774
-
775
-
776
- // forward fill
777
- const __forwardFillDate: string[] = _getForwardFill(year, month + 1);
778
-
779
- // back fill
780
- const __backFillDate: string[] = _getBackFill(year, month + 1);
781
-
782
-
783
- const _getDateShow = (_dayIndex: number, _m: number, _startDay: number, _month: number) => {
784
- const currentDay = typeof _dayIndex === 'number' ? _dayIndex - (_startDay - 2) : 0; // ..., -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, ...
785
-
786
- // date
787
- let _dateShow: any = currentDay > 0 ? `${year}-${_month + 1}-${currentDay}` : '';
788
-
789
- // forward & back
790
- if (isFirstGroup && _dateShow === '') {
791
- _dateShow = __forwardFillDate.at(currentDay - 1);
792
- }
793
-
794
- if (isLastGroup && _dateShow === '') {
795
- _dateShow = __backFillDate.at(_m);
796
- }
797
-
798
-
799
- return {
800
- date: getCalendarDate(_dateShow),
801
- firstGroup: isFirstGroup,
802
- lastGroup: isLastGroup,
803
- validDisplayDate: currentDay > 0 && currentDay <= days[month]
804
- };
805
-
806
- }
807
-
808
- //
809
- return {
810
- month: currentMonth,
811
- startDay: currentStartDay,
812
- row: j,
813
- col: _col,
814
- dateInfo: _col.map((k: number, m: number) => {
815
- const _lastWeekDays: number = _col.filter(Boolean).length;
816
- return _getDateShow(k, m - _lastWeekDays, currentStartDay, currentMonth);
817
- }),
818
- weekDisplay: _col.map((k: number, m: number) => {
819
- return WEEK[m]
820
- }),
821
- week: _col.map((k: number, m: number) => {
822
- return m
823
- }),
824
-
825
- }
826
- })
827
- };
828
-
829
-
830
- }
831
- //########## /MODE: MONTH #############
832
-
833
-
834
- return {
835
- rowsTotal: 0,
836
- colsTotal: 0,
837
- forwardFillTotal: 0,
838
- list: []
839
- };
840
-
841
-
842
- };
843
-
844
- const queryItemObj = () => {
845
- const curRowData: any = orginalData[tableRowNum];
846
- const curDate: string = tempDate !== '' ? tempDate : `${year}-${month + 1}-${day}`;
847
-
848
- if (curRowData) {
849
- const eventSourcesData = curRowData.eventSources;
850
-
851
- const _rowData = eventSourcesData.filter((item: any) => getCalendarDate(item.date as string) === getCalendarDate(curDate));
852
-
853
- let _currentData: any = undefined;
854
- if (_rowData[0]) {
855
- const _items = _rowData[0].list;
856
-
857
-
858
- if (tableCellId === -1) {
859
- // add new
860
- _currentData = {
861
- rowData: curRowData.listSection,
862
- id: 0,
863
- date: getCalendarDate(curDate)
864
- };
865
- } else {
866
- // edit or delete
867
- _currentData = _items.filter((item: any) => item.id == tableCellId)[0];
868
- }
869
-
870
- }
871
-
872
- return _rowData[0] ? _currentData : {
873
- rowData: curRowData.listSection,
874
- id: 0,
875
- date: getCalendarDate(curDate)
876
- };
877
- }
878
- };
879
-
880
-
881
- // ================================================================
882
- // Table Grid drag & drop
883
- // ================================================================
884
- let draggedObj: any = null;
885
- let mouseDown: boolean = false;
886
- let startX: any = 0;
887
- let scrollLeft: any = 0;
888
-
889
- const handleTableDragStart = useCallback((e: any) => {
890
- draggedObj = e.currentTarget;
891
-
892
- mouseDown = true;
893
- draggedObj.classList.add('dragging');
894
-
895
- //
896
- startX = e.pageX - draggedObj.offsetLeft;
897
- scrollLeft = draggedObj.scrollLeft;
898
-
899
-
900
- }, []);
901
-
902
- const handleTableDragEnd = useCallback((e: any) => {
903
- if (draggedObj === null) return;
904
-
905
- mouseDown = false;
906
- draggedObj.classList.remove('dragging');
907
- }, []);
908
-
909
- const handleTableMove = useCallback((e: any) => {
910
- e.preventDefault();
911
- if (!mouseDown) { return; }
912
- const x = e.pageX - draggedObj.offsetLeft;
913
- const scroll = x - startX;
914
- draggedObj.scrollLeft = scrollLeft - scroll;
915
- }, []);
916
-
917
-
918
-
919
-
920
- // ================================================================
921
- // Table Grid Tooltip
922
- // ================================================================
923
-
924
- function handleTableTooltipMouseEnter(e: any, content: any) {
925
- setIsShowTableTooltip(true);
926
-
927
- // update tooltip content
928
- setTableTooltipContent(content);
929
-
930
-
931
- // update modal positiona
932
- const _tableTooltipModalRef: any = tableTooltipModalRef.current;
933
- const _triggerRef: any = e.currentTarget;
934
-
935
- if (_tableTooltipModalRef !== null && _triggerRef !== null) {
936
-
937
- const { x, y, width, height } = getAbsolutePositionOfStage(_triggerRef);
938
-
939
- let pos = _tableTooltipModalRef.dataset.microtipPosition;
940
- if (typeof pos === 'undefined') pos = 'top';
941
-
942
- // TOP
943
- //
944
- if (pos.indexOf('top') >= 0) {
945
- _tableTooltipModalRef.style.left = x + (width / 2) + 'px';
946
- _tableTooltipModalRef.style.top = y - height - CELL_TOOLTIP_POS_OFFSET + 'px';
947
- }
948
-
949
-
950
- // BOTTOM
951
- //
952
- if (pos.indexOf('bottom') >= 0) {
953
- _tableTooltipModalRef.style.left = x + (width / 2) + 'px';
954
- _tableTooltipModalRef.style.top = y + height + CELL_TOOLTIP_POS_OFFSET + 'px';
955
- }
956
-
957
-
958
-
959
- // Determine whether it exceeds the far right or left side of the screen
960
- const _modalContent = _tableTooltipModalRef.querySelector('.custom-event-tl-table__cell-tooltipcontent');
961
- const _modalBox = _modalContent.getBoundingClientRect();
962
- if (typeof _modalContent.dataset.offset === 'undefined' && _modalBox.left > 0) {
963
-
964
- // 10 pixels is used to account for some bias in mobile devices
965
- if ((_modalBox.right + 10) > window.innerWidth) {
966
- const _modalOffsetPosition = _modalBox.right - window.innerWidth + CELL_TOOLTIP_EXCEEDED_SIDE_POS_OFFSET;
967
- _modalContent.dataset.offset = _modalOffsetPosition;
968
- _modalContent.style.marginLeft = `-${_modalOffsetPosition}px`;
969
- // console.log('_modalPosition: ', _modalOffsetPosition)
970
- }
971
-
972
-
973
- if ((_modalBox.left - 10) < 0) {
974
- const _modalOffsetPosition = Math.abs(_modalBox.left) + CELL_TOOLTIP_EXCEEDED_SIDE_POS_OFFSET;
975
- _modalContent.dataset.offset = _modalOffsetPosition;
976
- _modalContent.style.marginLeft = `${_modalOffsetPosition}px`;
977
- // console.log('_modalPosition: ', _modalOffsetPosition)
978
- }
979
-
980
-
981
- }
982
-
983
-
984
-
985
-
986
- }
987
-
988
-
989
-
990
- }
991
-
992
- function handleTableTooltipMouseLeave() {
993
- hideTableTooltip();
994
- }
995
-
996
-
997
- function hideTableTooltip() {
998
- setIsShowTableTooltip(false);
999
- }
1000
-
1001
-
1002
-
1003
- // ================================================================
1004
- // Calendar
1005
- // ================================================================
1006
- function updateTodayDate(inputDate: Date) {
1007
- setDay(inputDate.getDate());
1008
- setMonth(inputDate.getMonth());
1009
- setYear(inputDate.getFullYear());
1010
- setStartDay(getStartDayOfMonth(inputDate));
1011
-
1012
- // update selector
1013
- setSelectedMonth(inputDate.getMonth());
1014
- setSelectedYear(inputDate.getFullYear());
1015
-
1016
-
1017
- setTimeout(() => {
1018
- // initialize table grid
1019
- tableGridInit();
1020
-
1021
- // The scrollbar position is horizontal
1022
- bodyScrollbarInit();
1023
- }, 500);
1024
-
1025
- }
1026
-
1027
-
1028
- function getStartDayOfMonth(date: Date) {
1029
- const startDate = new Date(date.getFullYear(), date.getMonth(), 1).getDay();
1030
- return startDate === 0 ? 7 : startDate;
1031
- }
1032
-
1033
- function isLeapYear(year: number) {
1034
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
1035
- }
1036
-
1037
- const days = isLeapYear(year) ? DAYS_LEAP : DAYS;
1038
-
1039
-
1040
-
1041
- function handlePrevChange() {
1042
-
1043
- //########## MODE: WEEK #############
1044
- if (appearanceMode === 'week') {
1045
- const _latestWeekOffset = handlePreviousWeek();
1046
- const weekDates: Date[] = getWeekDatesFromMon(_latestWeekOffset);
1047
- onChangeWeek?.(getCalendarDate(weekDates.at(0) as Date), getCalendarDate(weekDates.at(-1) as Date));
1048
- }
1049
- //########## /MODE: WEEK #############
1050
-
1051
-
1052
- //########## MODE: MONTH #############
1053
- if (appearanceMode === 'month') {
1054
- setDate((prevState) => {
1055
- const _date = new Date(year, month - 1, day);
1056
-
1057
- // update
1058
- setSelectedMonth(_date.getMonth());
1059
- setSelectedYear(_date.getFullYear());
1060
-
1061
- //
1062
- onChangeMonth?.({
1063
- day: padZero(day),
1064
- month: padZero(_date.getMonth() + 1),
1065
- year: _date.getFullYear().toString()
1066
- });
1067
-
1068
- // restore table grid init status
1069
- restoreTableGridInitStatus();
1070
-
1071
-
1072
-
1073
- return _date;
1074
- });
1075
-
1076
- }
1077
- //########## /MODE: MONTH #############
1078
-
1079
-
1080
- }
1081
-
1082
- function handleNextChange() {
1083
-
1084
-
1085
- //########## MODE: WEEK #############
1086
- if (appearanceMode === 'week') {
1087
- const _latestWeekOffset = handleNextWeek();
1088
- const weekDates: Date[] = getWeekDatesFromMon(_latestWeekOffset);
1089
- onChangeWeek?.(getCalendarDate(weekDates.at(0) as Date), getCalendarDate(weekDates.at(-1) as Date));
1090
- }
1091
- //########## /MODE: WEEK #############
1092
-
1093
-
1094
- //########## MODE: MONTH #############
1095
- if (appearanceMode === 'month') {
1096
- setDate((prevState) => {
1097
- const _date = new Date(year, month + 1, day);
1098
-
1099
- // update
1100
- setSelectedMonth(_date.getMonth());
1101
- setSelectedYear(_date.getFullYear());
1102
-
1103
- //
1104
- onChangeMonth?.({
1105
- day: padZero(day),
1106
- month: padZero(_date.getMonth() + 1),
1107
- year: _date.getFullYear().toString()
1108
- });
1109
-
1110
-
1111
- // restore table grid init status
1112
- restoreTableGridInitStatus();
1113
-
1114
-
1115
- return _date;
1116
- });
1117
- }
1118
- //########## /MODE: MONTH #############
1119
-
1120
-
1121
- }
1122
- function handleDayChange(e: React.MouseEvent, currentDay: number) {
1123
- setDate(new Date(year, month, currentDay));
1124
- }
1125
-
1126
-
1127
- function handleYearChange(currentValue: number) {
1128
- setSelectedYear(currentValue);
1129
- setYear(currentValue);
1130
- setDate(new Date(currentValue, month, day));
1131
-
1132
- // close win
1133
- setWinYear(false);
1134
-
1135
- // restore table grid init status
1136
- restoreTableGridInitStatus();
1137
-
1138
- }
1139
-
1140
-
1141
- function handleMonthChange(currentIndex: number) {
1142
- setSelectedMonth(currentIndex);
1143
- setMonth(currentIndex);
1144
- setDate(new Date(year, currentIndex, day));
1145
-
1146
- // close win
1147
- setWinMonth(false);
1148
-
1149
-
1150
- //
1151
- onChangeMonth?.({
1152
- day: padZero(day),
1153
- month: padZero(currentIndex + 1),
1154
- year: year.toString()
1155
- });
1156
-
1157
- // restore table grid init status
1158
- restoreTableGridInitStatus();
1159
-
1160
- }
1161
-
1162
-
1163
- function handleTodayChange() {
1164
- setSelectedMonth(now.getMonth());
1165
- setSelectedYear(now.getFullYear());
1166
- updateTodayDate(now);
1167
-
1168
- //
1169
- const _now = getTodayDate().split('-');
1170
- onChangeToday?.({
1171
- day: _now[2],
1172
- month: _now[1],
1173
- year: _now[0]
1174
- });
1175
-
1176
- //
1177
- const weekDates: Date[] = getWeekDatesFromMon(0);
1178
- onChangeWeek?.(getCalendarDate(weekDates.at(0) as Date), getCalendarDate(weekDates.at(-1) as Date));
1179
- setWeekOffset(0);
1180
-
1181
-
1182
- // restore table grid init status
1183
- restoreTableGridInitStatus();
1184
-
1185
- }
1186
-
1187
- function handleAppearanceChange(e: React.MouseEvent) {
1188
- const _mode = (e.target as any).dataset.mode;
1189
- setAppearanceMode(_mode);
1190
-
1191
- //
1192
- onChangeAppearanceMode?.(_mode);
1193
- }
1194
-
1195
-
1196
-
1197
-
1198
- function handleShowWinYear() {
1199
- setWinYear((prevState: boolean) => !prevState);
1200
- }
1201
-
1202
- function handleShowWinMonth() {
1203
- setWinMonth((prevState: boolean) => !prevState);
1204
- }
1205
-
1206
-
1207
- // ================================================================
1208
- // Table Grid
1209
- // ================================================================
1210
-
1211
- function generateListSectionUi() {
1212
- return orginalData.map((item: any, i: number) => {
1213
-
1214
- return (
1215
- <tr key={i} role="row" data-index={i}>
1216
- <td role="gridcell" data-resource-index={i} className="custom-event-tl-table__datagrid-cell">
1217
- <div className="custom-event-tl-table__cell-cushion custom-event-tl-table__cell-cushion-title" dangerouslySetInnerHTML={{
1218
- __html: item.listSection.title
1219
- }} />
1220
- </td>
1221
- </tr>
1222
- )
1223
-
1224
- });
1225
- }
1226
-
1227
-
1228
- function generateDaysUi(eventSourcesData: any[] = [], listSectionData: any = '', rowIndex: number = 0, showEvents: boolean = false) {
1229
-
1230
- // colIndex
1231
- let colIndex = 0;
1232
-
1233
- const { forwardFillTotal, list: cellsList } = getCells();
1234
- return cellsList.map((item: any, j: number) => {
1235
-
1236
-
1237
-
1238
- return item.col.map((dayIndex: number, i: number) => {
1239
-
1240
- colIndex++;
1241
-
1242
-
1243
- // date
1244
- const _dateShow = item.dateInfo[i].date;
1245
- const _dateDayShow = _dateShow.split('-').at(-1);
1246
-
1247
- // week day
1248
- const weekDay = item.week[i];
1249
- const _weekDayStr = SHOW_WEEK ? <span dangerouslySetInnerHTML={{
1250
- __html: item.weekDisplay[i]
1251
- }} /> : null;
1252
-
1253
- // helper
1254
- const d = parseFloat(_dateDayShow);
1255
- const _currentData = eventSourcesData.filter((item: any) => getCalendarDate(item.date as string) === _dateShow);
1256
- const isLastCol = colIndex === 7 * cellsList.length;
1257
- const isInteractive = item.dateInfo[i].validDisplayDate; // The date on which the user interaction can occur, e.g. click, modify
1258
- const isForward = item.dateInfo[i].firstGroup && !isInteractive;
1259
- const isBack = item.dateInfo[i].lastGroup && !isInteractive;
1260
-
1261
-
1262
- // days
1263
- //------
1264
- if (!showEvents) {
1265
-
1266
- const _thContent = () => {
1267
-
1268
- return <th
1269
- className={combinedCls(
1270
- 'custom-event-tl-table__cell-cushion-headercontent__container',
1271
- {
1272
- 'empty': !isInteractive,
1273
- 'today': d === now.getDate(),
1274
- 'selected': `${year}-${padZero(month + 1)}-${padZero(day)}` === `${year}-${padZero(month + 1)}-${padZero(d)}`,
1275
- 'last-cell': isLastCol
1276
- }
1277
- )}
1278
- key={"col" + i}
1279
- data-index={colIndex - 1}
1280
- data-datagrid-col={colIndex - 1}
1281
- colSpan={1}
1282
- data-date={_dateShow}
1283
- data-day={_dateDayShow}
1284
- data-week={weekDay}
1285
- style={{ minWidth: CELL_MIN_W + 'px' }}
1286
- onMouseEnter={(e: React.MouseEvent) => {
1287
- onCellMouseEnter?.(e);
1288
- }}
1289
- onMouseDown={(e: React.MouseEvent) => {
1290
- // update row data
1291
- setTableRowNum(-1);
1292
-
1293
- // update cell data
1294
- setTableCellId(-1);
1295
-
1296
- if (_currentData.length > 0) {
1297
- _currentData[0].rowData = listSectionData;
1298
- }
1299
-
1300
- // reset selection area
1301
- setSelectedCells([]);
1302
- setCopiedCells(null);
1303
-
1304
-
1305
- //
1306
- if (isInteractive) {
1307
- handleDayChange(e, d); // update current day
1308
-
1309
- //
1310
- const _now = _dateShow.split('-');
1311
- onChangeDate?.(e, _currentData.length === 0 ? {
1312
- rowData: listSectionData,
1313
- id: 0,
1314
- date: _dateShow,
1315
- day: _now[2],
1316
- month: _now[1],
1317
- year: _now[0]
1318
- } : _currentData[0]);
1319
-
1320
- if (EVENTS_ENABLED) {
1321
- onModalEditOpen?.(_currentData.length === 0 ? {
1322
- rowData: listSectionData,
1323
- id: 0,
1324
- date: _dateShow
1325
- } : _currentData[0], () => setShowEdit(true), 'normal');
1326
-
1327
- // set temporary date
1328
- setTempDate(_dateShow);
1329
- }
1330
- }
1331
-
1332
- }}
1333
- onMouseLeave={(e: React.MouseEvent) => {
1334
- onCellMouseLeave?.(e);
1335
- }}
1336
- onMouseUp={(e: React.MouseEvent) => {
1337
- onCellMouseUp?.(e, selectedCells);
1338
- }}
1339
- >
1340
- {/* forward fill & day & back fill */}
1341
- <div
1342
- className={combinedCls(
1343
- 'custom-event-tl-table__cell-cushion custom-event-tl-table__cell-cushion-headercontent',
1344
- {
1345
- 'disabled': !isInteractive
1346
- }
1347
- )}
1348
- style={{ width: (CELL_MIN_W - 1) + 'px' }}
1349
- >
1350
-
1351
- {d}
1352
- {_weekDayStr}
1353
- </div>
1354
-
1355
-
1356
- </th>;
1357
- };
1358
-
1359
- if (!FILL_BLANK_DATE_DISABLD) {
1360
- return <>{_thContent()}</>;
1361
- } else {
1362
- return isInteractive ? (
1363
- <>{_thContent()}</>
1364
- ) : null;
1365
- }
1366
-
1367
- }
1368
-
1369
-
1370
- // events
1371
- //------
1372
- if (showEvents) {
1373
-
1374
-
1375
- const _eventContent = () => {
1376
-
1377
- if (
1378
- _currentData.length === 0 ||
1379
- !Array.isArray(_currentData) ||
1380
- typeof _currentData[0].list === 'undefined'
1381
- ) {
1382
- return null;
1383
- }
1384
-
1385
- //
1386
- const _items = _currentData[0].list;
1387
-
1388
- return _items.map((cellItem: any, cellItemIndex: number) => {
1389
-
1390
- const _eventContentTooltip = typeof cellItem.dataTooltip === 'undefined' ? '' : <>
1391
- <div
1392
- className="custom-event-tl__day__event-tooltipcontent"
1393
- dangerouslySetInnerHTML={{
1394
- __html: cellItem.dataTooltip
1395
- }}
1396
- ></div>
1397
- </>;
1398
-
1399
- return <div
1400
- className={combinedCls(
1401
- `custom-event-tl-table__cell-cushion-content__item custom-event-tl-table__cell-cushion-content__item-${cellItemIndex}`,
1402
- {
1403
- 'first': cellItemIndex === 0,
1404
- 'last': cellItemIndex === _items.length - 1
1405
- }
1406
- )}
1407
- key={`cell-item-${rowIndex}-${cellItemIndex}}`}
1408
- data-overlay-id={`custom-event-tl-table__cell-tooltipwrapper-${idRes}`}
1409
- data-cell-item-index={cellItemIndex}
1410
- data-date={_dateShow}
1411
- data-day={_dateDayShow}
1412
- data-week={weekDay}
1413
- data-row={rowIndex}
1414
- onMouseEnter={(e: React.MouseEvent) => {
1415
- e.stopPropagation();
1416
-
1417
- if (_eventContentTooltip !== '') {
1418
- if (typeof tableTooltipDisabled === 'undefined' || tableTooltipDisabled === false) {
1419
- handleTableTooltipMouseEnter(e, _eventContentTooltip);
1420
- }
1421
- }
1422
- }}
1423
- onMouseLeave={(e: React.MouseEvent) => {
1424
- e.stopPropagation();
1425
-
1426
- if (_eventContentTooltip !== '') {
1427
- if (typeof tableTooltipDisabled === 'undefined' || tableTooltipDisabled === false) {
1428
- handleTableTooltipMouseLeave();
1429
- }
1430
-
1431
- }
1432
-
1433
- }}
1434
- onClick={(e: React.MouseEvent) => {
1435
- e.stopPropagation();
1436
-
1437
- // update row data
1438
- setTableRowNum(rowIndex);
1439
-
1440
- // update cell data
1441
- setTableCellId(cellItem.id);
1442
-
1443
- cellItem.rowData = listSectionData;
1444
-
1445
-
1446
- // Callback
1447
- cellItem.callback?.();
1448
-
1449
-
1450
- //
1451
- if (isInteractive) {
1452
- handleDayChange(e, d); // update current day
1453
-
1454
- //
1455
- const _now = cellItem.date.split('-');
1456
- onChangeDate?.(e, {
1457
- ...cellItem,
1458
- day: _now[2],
1459
- month: _now[1],
1460
- year: _now[0]
1461
- });
1462
-
1463
- if (EVENTS_ENABLED) {
1464
- onModalEditOpen?.(cellItem, () => setShowEdit(true), 'normal');
1465
-
1466
- // set temporary date
1467
- setTempDate(_dateShow);
1468
- }
1469
- }
1470
- }}
1471
- >
1472
-
1473
-
1474
-
1475
- {/* ITEM */}
1476
- <div
1477
- className="custom-event-tl__day__event"
1478
- style={typeof cellItem !== 'undefined' && (cellItem as any).eventStyles !== 'undefined' ? cellItem.eventStyles : {}}
1479
- dangerouslySetInnerHTML={typeof cellItem.data === 'string' ? {
1480
- __html: cellItem.data
1481
- } : undefined}
1482
- >
1483
- {React.isValidElement(cellItem.data) ? <>{cellItem.data}</> : null}
1484
- </div>
1485
- {/* /ITEM */}
1486
-
1487
- {/* DELETE BUTTON */}
1488
- <div
1489
- className={`custom-event-tl__day__eventdel ${cellCloseBtnClassName || ''}`}
1490
- >
1491
- <a
1492
- href="#"
1493
- tabIndex={-1}
1494
- className="align-middle"
1495
- data-date={_dateShow}
1496
- data-day={_dateDayShow}
1497
- data-week={weekDay}
1498
- data-row={rowIndex}
1499
- onClick={(e: React.MouseEvent) => {
1500
- e.preventDefault();
1501
- e.stopPropagation();
1502
-
1503
- // update row data
1504
- setTableRowNum(rowIndex);
1505
-
1506
- // update cell data
1507
- setTableCellId(cellItem.id);
1508
-
1509
-
1510
- const _existsContent = cellItem;
1511
- if (typeof _existsContent !== 'undefined') {
1512
- _existsContent.rowData = listSectionData;
1513
- }
1514
-
1515
- //
1516
- if (isInteractive) {
1517
- handleDayChange(e, d); // update current day
1518
-
1519
- //
1520
- const _now = _dateShow.split('-');
1521
- onChangeDate?.(e, {
1522
- rowData: listSectionData,
1523
- id: 0,
1524
- date: _dateShow,
1525
- day: _now[2],
1526
- month: _now[1],
1527
- year: _now[0]
1528
- });
1529
-
1530
- if (EVENTS_DELETE_ENABLED) {
1531
- onModalDeleteOpen?.(_existsContent, () => setShowDelete(true));
1532
-
1533
- // set temporary date
1534
- setTempDate(_dateShow);
1535
- }
1536
- }
1537
-
1538
-
1539
-
1540
- }}
1541
- >
1542
- {_delBtn()}
1543
- </a>
1544
-
1545
- </div>
1546
- {/* /DELETE BUTTON */}
1547
- </div>
1548
- });
1549
- };
1550
-
1551
-
1552
-
1553
- const _tdContent = () => {
1554
-
1555
- return <td
1556
- className={combinedCls(
1557
- 'custom-event-tl-table__cell-cushion-content__container custom-event-tl-table__cell-tooltiptrigger',
1558
- {
1559
- 'has-event': eventSourcesData && _currentData.length > 0,
1560
- 'empty': !isInteractive,
1561
- 'today': d === now.getDate(),
1562
- 'selected': isCellSelected(rowIndex, dayIndex),
1563
- 'last-cell': isLastCol
1564
- }
1565
- )}
1566
- key={"col" + i}
1567
- data-index={colIndex - 1}
1568
- colSpan={1}
1569
- data-rowinfo={JSON.stringify(orginalData[rowIndex]?.listSection)}
1570
- data-date={_dateShow}
1571
- data-day={_dateDayShow}
1572
- data-week={weekDay}
1573
- data-row={rowIndex}
1574
- onMouseEnter={(e: React.MouseEvent) => {
1575
- onCellMouseEnter?.(e);
1576
-
1577
- //
1578
- if (multipleCells) handleTableMainCellMouseEnter(e, rowIndex, dayIndex, forwardFillTotal);
1579
- }}
1580
- onMouseDown={(e: React.MouseEvent) => {
1581
- //
1582
- onCellClick?.(e, {
1583
- rowData: orginalData[rowIndex]?.listSection,
1584
- date: _dateShow,
1585
- row: rowIndex,
1586
- col: dayIndex
1587
- });
1588
-
1589
- if (isInteractive) {
1590
- handleDayChange(e, d); // update current day
1591
- onChangeDate?.(e, null);
1592
- }
1593
-
1594
-
1595
- if (multipleCells) handleTableMainCellMouseDown(e, rowIndex, dayIndex, forwardFillTotal);
1596
- }}
1597
-
1598
- onDoubleClick={(e: React.MouseEvent) => {
1599
- //
1600
- onCellDoubleClick?.(e, {
1601
- rowData: orginalData[rowIndex]?.listSection,
1602
- date: _dateShow,
1603
- row: rowIndex,
1604
- col: dayIndex
1605
- });
1606
- }}
1607
- onMouseLeave={(e: React.MouseEvent) => {
1608
- onCellMouseLeave?.(e);
1609
- }}
1610
- onMouseUp={(e: React.MouseEvent) => {
1611
- onCellMouseUp?.(e, selectedCells);
1612
- }}
1613
- >
1614
-
1615
-
1616
- {/* forward fill & day & back fill */}
1617
- <div
1618
- className={combinedCls(
1619
- 'custom-event-tl-table__cell-cushion custom-event-tl-table__cell-cushion-content',
1620
- {
1621
- 'disabled': !isInteractive
1622
- }
1623
- )}
1624
- style={{ width: (CELL_MIN_W - 1) + 'px' }}
1625
- >
1626
-
1627
- {/*++++++++++++++++ EVENT ++++++++++++++++*/}
1628
- {_eventContent() || <><i style={{ userSelect: 'none' }}>&nbsp;</i></>}
1629
- {/*++++++++++++++++ /EVENT ++++++++++++++++*/}
1630
-
1631
- {/* ADD BUTTON */}
1632
- {isForward || isBack ? null : <>
1633
- <div
1634
- className={`custom-event-tl__day__eventadd ${cellAddBtnClassName || ''}`}
1635
- >
1636
- <a
1637
- href="#"
1638
- tabIndex={-1}
1639
- className="align-middle"
1640
- data-date={_dateShow}
1641
- data-day={_dateDayShow}
1642
- data-week={weekDay}
1643
- data-row={rowIndex}
1644
- onClick={(e: React.MouseEvent) => {
1645
- e.preventDefault();
1646
- e.stopPropagation();
1647
-
1648
- // update row data
1649
- setTableRowNum(rowIndex);
1650
-
1651
- // update cell data
1652
- setTableCellId(-1);
1653
-
1654
- //
1655
- if (isInteractive) {
1656
- handleDayChange(e, d); // update current day
1657
-
1658
- //
1659
- const _now = _dateShow.split('-');
1660
- onChangeDate?.(e, {
1661
- rowData: listSectionData,
1662
- id: 0,
1663
- date: _dateShow,
1664
- day: _now[2],
1665
- month: _now[1],
1666
- year: _now[0]
1667
- });
1668
-
1669
- if (EVENTS_ENABLED) {
1670
- onModalEditOpen?.({
1671
- rowData: listSectionData,
1672
- id: 0,
1673
- date: _dateShow
1674
- }, () => setShowEdit(true), 'new');
1675
-
1676
- // set temporary date
1677
- setTempDate(_dateShow);
1678
-
1679
- }
1680
- }
1681
- }}
1682
- >
1683
- {_addBtn()}
1684
- </a>
1685
-
1686
- </div>
1687
- </>}
1688
- {/* /ADD BUTTON */}
1689
- </div>
1690
-
1691
-
1692
- </td>;
1693
- };
1694
-
1695
- if (!FILL_BLANK_DATE_DISABLD) {
1696
- return <>{_tdContent()}</>;
1697
- } else {
1698
- return isInteractive ? (
1699
- <>{_tdContent()}</>
1700
- ) : null;
1701
- }
1702
-
1703
- }
1704
-
1705
-
1706
- });
1707
-
1708
- })
1709
-
1710
- }
1711
-
1712
- function generateColUi() {
1713
-
1714
- {/* //########## MODE: WEEK ############# */ }
1715
- if (appearanceMode === 'week') {
1716
- return Array.from({ length: 7 }).fill(0).map((item: any, i: number) => {
1717
- return (
1718
- <col
1719
- key={"col-placeholder-" + i}
1720
- data-index={i}
1721
- data-datagrid-col={i}
1722
- style={{ minWidth: CELL_MIN_W + 'px' }}
1723
-
1724
- />
1725
- );
1726
- })
1727
- }
1728
-
1729
- {/* //########## /MODE: WEEK ############# */ }
1730
-
1731
-
1732
- {/* //########## MODE: MONTH ############# */ }
1733
- if (appearanceMode === 'month') {
1734
- if (FILL_BLANK_DATE_DISABLD) {
1735
- return Array.from({ length: days[month] }).fill(0).map((item: any, i: number) => {
1736
- return (
1737
- <col
1738
- key={"col-placeholder-" + i}
1739
- data-index={i}
1740
- data-datagrid-col={i}
1741
- style={{ minWidth: CELL_MIN_W + 'px' }}
1742
-
1743
- />
1744
- );
1745
- })
1746
-
1747
- } else {
1748
- // colIndex
1749
- let colIndex = 0;
1750
-
1751
- const { forwardFillTotal, list: cellsList } = getCells();
1752
- return cellsList.map((item: any, j: number) => {
1753
- return item.col.map((dayIndex: number | null, i: number) => {
1754
-
1755
- colIndex++;
1756
-
1757
- // helper
1758
- const isInteractive = item.dateInfo[i].validDisplayDate; // The date on which the user interaction can occur, e.g. click, modify
1759
-
1760
- return (
1761
- <col
1762
- className={combinedCls(
1763
- {
1764
- 'empty': !isInteractive
1765
- }
1766
- )}
1767
- key={"col-placeholder-" + i}
1768
- data-index={colIndex - 1}
1769
- data-datagrid-col={colIndex - 1}
1770
- style={{ minWidth: CELL_MIN_W + 'px' }}
1771
-
1772
- />
1773
- );
1774
-
1775
- });
1776
-
1777
-
1778
- })
1779
- }
1780
- }
1781
- {/* //########## /MODE: MONTH ############# */ }
1782
-
1783
-
1784
-
1785
-
1786
-
1787
-
1788
-
1789
-
1790
- }
1791
-
1792
- function syncTableScrollHeader() {
1793
- const el: any = scrollHeaderRef.current;
1794
- if (el === null) return;
1795
-
1796
- const _latestScrollLeft = el.scrollLeft;
1797
-
1798
- if (scrollBodyRef.current) (scrollBodyRef.current as any).scrollLeft = _latestScrollLeft;
1799
-
1800
-
1801
- }
1802
-
1803
- function syncTableScrollBody() {
1804
- const el: any = scrollBodyRef.current;
1805
- if (el === null) return;
1806
-
1807
- const _latestScrollTop = el.scrollTop;
1808
- const _latestScrollLeft = el.scrollLeft;
1809
-
1810
- if (scrollListRef.current) (scrollListRef.current as any).scrollTop = _latestScrollTop;
1811
- if (scrollHeaderRef.current) (scrollHeaderRef.current as any).scrollLeft = _latestScrollLeft;
1812
-
1813
- }
1814
-
1815
- function syncTableScrollList() {
1816
- const el: any = scrollListRef.current;
1817
- if (el === null) return;
1818
-
1819
- const _latestScrollTop = el.scrollTop;
1820
-
1821
- if (scrollBodyRef.current) (scrollBodyRef.current as any).scrollTop = _latestScrollTop;
1822
-
1823
- }
1824
-
1825
-
1826
-
1827
- function restoreTableGridInitStatus() {
1828
-
1829
- // restore table grid init status
1830
- if (scrollListRef.current) (scrollListRef.current as any).scrollTop = 0;
1831
- if (scrollBodyRef.current) (scrollBodyRef.current as any).scrollLeft = 0;
1832
-
1833
- }
1834
-
1835
-
1836
- function bodyScrollbarInit() {
1837
- if (scrollBodyRef.current === null || tableGridRef.current === null) return;
1838
-
1839
- // The scrollbar position is horizontal
1840
- const targetPos = tableGridRef.current.querySelector('.custom-event-tl-table__datagrid-header__content tbody .today.selected');
1841
- if (targetPos !== null) {
1842
- (scrollBodyRef.current as any).scrollLeft = targetPos.offsetLeft;
1843
- }
1844
-
1845
-
1846
- }
1847
-
1848
-
1849
- function tableGridInitHeadertitle() {
1850
- //
1851
- if (tableGridRef.current === null) return;
1852
-
1853
- const tableGridEl: any = tableGridRef.current;
1854
-
1855
- // initialize cell height
1856
- const headerTitleTrElements = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__title tbody').getElementsByTagName('tr');
1857
- const trElements = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__content tbody').getElementsByTagName('tr');
1858
-
1859
- for (let i = 0; i < headerTitleTrElements.length; i++) {
1860
-
1861
- const targetElement = headerTitleTrElements[i].offsetHeight > trElements[i].offsetHeight ? headerTitleTrElements[i] : trElements[i];
1862
- const tdOHeight = window.getComputedStyle(targetElement).height;
1863
- headerTitleTrElements[i].style.height = tdOHeight;
1864
- trElements[i].style.height = tdOHeight;
1865
-
1866
- }
1867
-
1868
- }
1869
-
1870
- function tableGridInit() {
1871
-
1872
- //
1873
- if (tableGridRef.current === null) return;
1874
-
1875
- const { forwardFillTotal, list: cellsList } = getCells();
1876
- const tableGridEl: any = tableGridRef.current;
1877
- let _curCellMinWidth: number = CELL_MIN_W;
1878
- let _curColCount: number = FILL_BLANK_DATE_DISABLD ? days[month] : 7 * cellsList.length;
1879
-
1880
-
1881
- if (appearanceMode === 'week') {
1882
- _curColCount = 7;
1883
- }
1884
-
1885
- //****************
1886
- // STEP 1-1:
1887
- //****************
1888
- // calculate min width (MODE: WEEK)
1889
- //--------------
1890
- if (appearanceMode === 'week') {
1891
- const tableMaxWidth = tableGridEl.clientWidth;
1892
- const tableHeaderTitleWidth = tableGridEl.querySelector('.custom-event-tl-table__cell-cushion-headertitle').clientWidth;
1893
- const tableDividerWidth = tableGridEl.querySelector('.custom-event-tl-table__timeline-divider').clientWidth;
1894
- const tableBorderWidth = 4;
1895
- const scrollMaxWidth = tableMaxWidth - tableHeaderTitleWidth - tableDividerWidth - tableBorderWidth;
1896
-
1897
- _curCellMinWidth = scrollMaxWidth / 7;
1898
- _curColCount = 7;
1899
-
1900
- // header
1901
- tableGridEl.querySelectorAll('.custom-event-tl-table__cell-cushion-headercontent__container, .custom-event-tl-table__cell-cushion-content').forEach((node: HTMLDivElement) => {
1902
- node.style.width = _curCellMinWidth + 'px';
1903
- });
1904
-
1905
-
1906
- }
1907
-
1908
-
1909
-
1910
- //****************
1911
- // STEP 1-2:
1912
- //****************
1913
- // calculate min width (MODE: MONTH)
1914
- //--------------
1915
- const cellMinWidth = _curCellMinWidth;
1916
- const colCount = _curColCount;
1917
- const scrollableMinWidth = cellMinWidth * colCount;
1918
-
1919
-
1920
- //****************
1921
- // STEP 1-3:
1922
- //****************
1923
- // initialize "header & main" cells
1924
- //--------------
1925
- const headerThContentContainers: any = tableGridEl.querySelector('.custom-event-tl-table__datagrid-header__content tbody').getElementsByTagName('th');
1926
- for (let i = 0; i < headerThContentContainers.length; i++) {
1927
- const curHeaderThContent = headerThContentContainers[i].querySelector('.custom-event-tl-table__cell-cushion-headercontent');
1928
- if (curHeaderThContent !== null) curHeaderThContent.style.width = _curCellMinWidth + 'px';
1929
- }
1930
-
1931
-
1932
- const mainTdContentContainers: any = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__content tbody').getElementsByTagName('td');
1933
- for (let i = 0; i < mainTdContentContainers.length; i++) {
1934
- const curHeaderThContent = mainTdContentContainers[i].querySelector('.custom-event-tl-table__cell-cushion-content');
1935
- if (curHeaderThContent !== null) curHeaderThContent.style.width = _curCellMinWidth + 'px';
1936
- }
1937
-
1938
- const mainTdContentCols: any = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__content colgroup').getElementsByTagName('col')
1939
- for (let i = 0; i < mainTdContentCols.length; i++) {
1940
- mainTdContentCols[i].style.minWidth = _curCellMinWidth + 'px';
1941
- }
1942
-
1943
-
1944
- //****************
1945
- // STEP 2:
1946
- //****************
1947
- // initialize scrollable wrapper (width)
1948
- //--------------
1949
- const _scrollableWrapper: HTMLElement[] = tableGridEl.querySelectorAll('.custom-event-tl-table__scroller-harness');
1950
- [].slice.call(_scrollableWrapper).forEach((el: any) => {
1951
- const scrollType = el.dataset.scroll;
1952
-
1953
- if (appearanceMode === 'week') {
1954
- el.classList.add('custom-event-tl-table__scroller-harness--hideX');
1955
- }
1956
- if (appearanceMode === 'month') {
1957
- el.classList.remove('custom-event-tl-table__scroller-harness--hideX');
1958
- }
1959
-
1960
- if (scrollType !== 'list') {
1961
- const _content = el.querySelector('.custom-event-tl-table__scroller');
1962
- const tableMaxWidth = tableGridEl.clientWidth;
1963
- const tableHeaderTitleWidth = tableGridEl.querySelector('.custom-event-tl-table__cell-cushion-headertitle').clientWidth;
1964
- const tableDividerWidth = tableGridEl.querySelector('.custom-event-tl-table__timeline-divider').clientWidth;
1965
- const tableBorderWidth = 4;
1966
- const scrollMaxWidth = tableMaxWidth - tableHeaderTitleWidth - tableDividerWidth - tableBorderWidth;
1967
-
1968
- el.dataset.width = scrollMaxWidth;
1969
- el.style.maxWidth = el.dataset.width + 'px';
1970
- _content.style.minWidth = scrollableMinWidth + 'px';
1971
-
1972
- }
1973
- });
1974
-
1975
-
1976
- //****************
1977
- // STEP 3:
1978
- //****************
1979
- // initialize cell width
1980
- //--------------
1981
- const tdElementMaxWidth: number = typeof mainTdContentContainers[0] === 'undefined' ? 0 : parseFloat(window.getComputedStyle(mainTdContentContainers[0].querySelector('.custom-event-tl-table__cell-cushion-content')).maxWidth);
1982
-
1983
-
1984
- if (Array.isArray(eventsValue) && eventsValue.length > 0) {
1985
-
1986
- for (let i = 0; i < headerThContentContainers.length; i++) {
1987
-
1988
- const curHeaderThContent = headerThContentContainers[i].querySelector('.custom-event-tl-table__cell-cushion-headercontent');
1989
- const curHeaderThContentMaxWidth = parseFloat(window.getComputedStyle(curHeaderThContent).width);
1990
- const targetElement = headerThContentContainers[i].offsetWidth > mainTdContentContainers[i].offsetWidth ? headerThContentContainers[i] : mainTdContentContainers[i];
1991
- let tdOwidth = parseFloat(window.getComputedStyle(targetElement).width);
1992
-
1993
-
1994
- // check td max width
1995
- if (tdElementMaxWidth > 0 && tdOwidth > tdElementMaxWidth) {
1996
- tdOwidth = tdElementMaxWidth;
1997
- }
1998
-
1999
- // check header th max width
2000
- if (tdElementMaxWidth > 0 && tdElementMaxWidth < curHeaderThContentMaxWidth) {
2001
- tdOwidth = curHeaderThContentMaxWidth;
2002
- }
2003
-
2004
- // Prevent the width from being +1 each time it is initialized
2005
- tdOwidth = tdOwidth - 1;
2006
-
2007
-
2008
- headerThContentContainers[i].querySelector('.custom-event-tl-table__cell-cushion-headercontent').style.width = tdOwidth + 'px';
2009
- mainTdContentCols[i].style.minWidth = tdOwidth + 'px';
2010
-
2011
-
2012
- }
2013
- }
2014
-
2015
-
2016
- //****************
2017
- // STEP 4:
2018
- //****************
2019
- // initialize max width of table content
2020
- //--------------
2021
- if (scrollBodyRef.current !== null && scrollHeaderRef.current !== null) {
2022
- const tableContentWidth = window.getComputedStyle(tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__content')).width;
2023
- const scrollBodyEl: any = scrollBodyRef.current;
2024
- const scrollHeaderEl: any = scrollHeaderRef.current;
2025
-
2026
- scrollBodyEl.style.width = tableContentWidth;
2027
- scrollHeaderEl.style.width = tableContentWidth;
2028
- scrollBodyEl.dataset.width = parseFloat(tableContentWidth);
2029
- scrollHeaderEl.dataset.width = parseFloat(tableContentWidth);
2030
-
2031
- //
2032
- const tableWrapperMaxWidthLatest = tableGridEl.clientWidth;
2033
- if (tableWrapperMaxWidthLatest > parseFloat(tableContentWidth)) {
2034
- tableGridEl.querySelector('.custom-event-tl-table__timeline-table').style.width = tableContentWidth;
2035
- }
2036
-
2037
-
2038
- }
2039
-
2040
-
2041
-
2042
- //****************
2043
- // STEP 5:
2044
- //****************
2045
- // initialize cell height
2046
- //--------------
2047
- tableGridInitHeadertitle();
2048
-
2049
- //****************
2050
- // STEP 6:
2051
- //****************
2052
- //initialize scrollable wrapper (height)
2053
- //--------------
2054
- [].slice.call(_scrollableWrapper).forEach((el: any) => {
2055
- const scrollType = el.dataset.scroll;
2056
- const oldHeight = el.clientHeight;
2057
-
2058
- if (scrollType !== 'header') {
2059
- const tableWrapperMaxHeight = window.getComputedStyle(tableGridEl as HTMLElement).height;
2060
- if (oldHeight > parseFloat(tableWrapperMaxHeight)) {
2061
- el.style.height = tableWrapperMaxHeight;
2062
- }
2063
- }
2064
-
2065
- });
2066
-
2067
-
2068
-
2069
- //****************
2070
- // STEP 7:
2071
- //****************
2072
- // display wrapper
2073
- //--------------
2074
- tableGridEl.classList.remove('invisible');
2075
-
2076
- //****************
2077
- // STEP 1-1:
2078
- //****************
2079
- // calculate min width (MODE: WEEK)
2080
- //--------------
2081
- if (appearanceMode === 'week') {
2082
- const tableMaxWidth = tableGridEl.clientWidth;
2083
- const tableHeaderTitleWidth = tableGridEl.querySelector('.custom-event-tl-table__cell-cushion-headertitle').clientWidth;
2084
- const tableDividerWidth = tableGridEl.querySelector('.custom-event-tl-table__timeline-divider').clientWidth;
2085
- const tableBorderWidth = 4;
2086
- const scrollMaxWidth = tableMaxWidth - tableHeaderTitleWidth - tableDividerWidth - tableBorderWidth;
2087
-
2088
- _curCellMinWidth = scrollMaxWidth / 7;
2089
- _curColCount = 7;
2090
-
2091
- // header content
2092
- tableGridEl.querySelectorAll('.custom-event-tl-table__cell-cushion-headercontent__container, .custom-event-tl-table__cell-cushion-headercontent').forEach((node: HTMLDivElement) => {
2093
- node.style.width = _curCellMinWidth + 'px';
2094
- });
2095
-
2096
- // main content
2097
- tableGridEl.querySelectorAll('.custom-event-tl-table__cell-cushion-content').forEach((node: HTMLDivElement) => {
2098
- node.style.width = _curCellMinWidth + 'px';
2099
- });
2100
-
2101
- }
2102
-
2103
- }
2104
-
2105
-
2106
- function tableGridReset() {
2107
- if (tableGridRef.current === null) return;
2108
-
2109
- const tableGridEl: any = tableGridRef.current;
2110
-
2111
-
2112
- // initialize scrollable wrapper (width & height)
2113
- //--------------
2114
- const _scrollableWrapper = tableGridEl.querySelectorAll('.custom-event-tl-table__scroller-harness');
2115
- [].slice.call(_scrollableWrapper).forEach((el: any) => {
2116
-
2117
- const _content = el.querySelector('.custom-event-tl-table__scroller');
2118
- el.removeAttribute('data-width');
2119
- el.removeAttribute('style');
2120
- _content.removeAttribute('style');
2121
- });
2122
-
2123
-
2124
- // initialize cell height
2125
- //--------------
2126
- const headerTitleTrElements = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__title tbody').getElementsByTagName('tr');
2127
- const trElements = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__content tbody').getElementsByTagName('tr');
2128
-
2129
- for (let i = 0; i < headerTitleTrElements.length; i++) {
2130
- headerTitleTrElements[i].removeAttribute('style');
2131
- trElements[i].removeAttribute('style');
2132
- }
2133
-
2134
-
2135
- }
2136
-
2137
-
2138
-
2139
-
2140
- // ================================================================
2141
- //
2142
- // ================================================================
2143
- //if user change the selectedYear, then udate the years array that is displayed on year tab view
2144
- useEffect(() => {
2145
- const years: number[] = [];
2146
- for (let y = selectedYear - 10; y < selectedYear + 10; y++) {
2147
- years.push(y as never)
2148
- }
2149
- setYearsCollection(years);
2150
- }, [selectedYear]);
2151
-
2152
-
2153
-
2154
- useEffect(() => {
2155
- updateTodayDate(date);
2156
- }, [date]);
2157
-
2158
-
2159
- useEffect(() => {
2160
- // Guaranteed year change triggered by the front and rear buttons
2161
- onChangeYear?.({
2162
- day: padZero(day),
2163
- month: padZero(month + 1),
2164
- year: year.toString()
2165
- });
2166
- }, [year]);
2167
-
2168
-
2169
- useEffect(() => {
2170
-
2171
- const { forwardFillTotal, list: cellsList } = getCells();
2172
- if (typeof appearanceWeekTmpl === 'function') {
2173
- setDisplayWeekForHeader([cellsList.at(0).dateInfo[0].date, cellsList.at(-1).dateInfo[0].date]);
2174
- } else {
2175
- setDisplayWeekForHeader([formatToEnglishMonthDay(cellsList.at(0).dateInfo[0].date), formatToEnglishMonthDay(cellsList.at(-1).dateInfo[0].date)]);
2176
- }
2177
-
2178
- }, [weekOffset]);
2179
-
2180
- useEffect(() => {
2181
-
2182
- // update events value
2183
- if (Array.isArray(eventsValue) && eventsValue.length > 0) setOrginalData(eventsValue);
2184
-
2185
- // update current today
2186
- if (typeof customTodayDate !== 'undefined' && isValidDate(customTodayDate)) {
2187
- const _customNow = new Date(customTodayDate);
2188
- updateTodayDate(_customNow);
2189
- }
2190
-
2191
- // Call a function when the list has been rendered completely
2192
- onListRenderComplete?.();
2193
-
2194
- }, [eventsValue, customTodayDate, appearanceMode]);
2195
-
2196
-
2197
-
2198
- useEffect(() => {
2199
-
2200
- // !!!Please do not use dependencies
2201
- //--------------
2202
- return () => {
2203
-
2204
- // reset table grid
2205
- tableGridReset();
2206
-
2207
- // reset selection area
2208
- setSelectedCells([]);
2209
- setCopiedCells(null);
2210
- }
2211
-
2212
- }, []);
2213
- return (
2214
- <>
2215
-
2216
- {/*/////////////////////////////////////////////////// */}
2217
- {/*//////////////////// Calendar //////////////////// */}
2218
- {/*////////////////////////////////////////////////// */}
2219
-
2220
- <div className={combinedCls(
2221
- `custom-event-tl__wrapper custom-event-tl__wrapper--${appearanceMode}`,
2222
- calendarWrapperClassName
2223
- )}>
2224
-
2225
- {/*++++++++++++++++ MAIN ++++++++++++++++*/}
2226
- <div className="custom-event-tl__header bg-body-tertiary">
2227
- <button tabIndex={-1} type="button" className="custom-event-tl__btn custom-event-tl__btn--prev" onClick={handlePrevChange}>
2228
- <svg width="20px" height="20px" viewBox="0 0 24 24" fill="none">
2229
- <path d="M14.2893 5.70708C13.8988 5.31655 13.2657 5.31655 12.8751 5.70708L7.98768 10.5993C7.20729 11.3805 7.2076 12.6463 7.98837 13.427L12.8787 18.3174C13.2693 18.7079 13.9024 18.7079 14.293 18.3174C14.6835 17.9269 14.6835 17.2937 14.293 16.9032L10.1073 12.7175C9.71678 12.327 9.71678 11.6939 10.1073 11.3033L14.2893 7.12129C14.6799 6.73077 14.6799 6.0976 14.2893 5.70708Z" fill="#000" />
2230
- </svg>
2231
- </button>
2232
-
2233
- {/* //########## MODE: WEEK ############# */}
2234
- {appearanceMode === 'week' ? <>
2235
- <div className="custom-event-tl__header__info">
2236
- {typeof appearanceWeekTmpl === 'function' ? <>{appearanceWeekTmpl(displayWeekForHeader[0], displayWeekForHeader[1])}</> : <>{displayWeekForHeader[0]} - {displayWeekForHeader[1]}</>}
2237
- </div>
2238
- </> : null}
2239
- {/* //########## /MODE: WEEK ############# */}
2240
-
2241
-
2242
- {/* //########## MODE: MONTH ############# */}
2243
- {appearanceMode === 'month' ? <>
2244
- <div className="custom-event-tl__header__btns">
2245
- <button tabIndex={-1} type="button" className={`custom-event-tl__btn ${winMonth ? 'active' : ''}`} onClick={handleShowWinMonth}>
2246
- {MONTHS[month]}
2247
- <svg width="12px" height="12px" viewBox="0 0 24 24"><path d="M11.178 19.569a.998.998 0 0 0 1.644 0l9-13A.999.999 0 0 0 21 5H3a1.002 1.002 0 0 0-.822 1.569l9 13z" fill="#000000" /></svg>
2248
- </button>
2249
- <button tabIndex={-1} type="button" className={`custom-event-tl__btn ${winYear ? 'active' : ''}`} onClick={handleShowWinYear}>
2250
- {year}
2251
- <svg width="12px" height="12px" viewBox="0 0 24 24"><path d="M11.178 19.569a.998.998 0 0 0 1.644 0l9-13A.999.999 0 0 0 21 5H3a1.002 1.002 0 0 0-.822 1.569l9 13z" fill="#000000" /></svg>
2252
- </button>
2253
- </div>
2254
- </> : null}
2255
- {/* //########## /MODE: MONTH ############# */}
2256
-
2257
-
2258
-
2259
- <button tabIndex={-1} type="button" className="custom-event-tl__btn custom-event-tl__btn--next" onClick={handleNextChange}>
2260
- <svg width="20px" height="20px" viewBox="0 0 24 24" fill="none">
2261
- <path d="M9.71069 18.2929C10.1012 18.6834 10.7344 18.6834 11.1249 18.2929L16.0123 13.4006C16.7927 12.6195 16.7924 11.3537 16.0117 10.5729L11.1213 5.68254C10.7308 5.29202 10.0976 5.29202 9.70708 5.68254C9.31655 6.07307 9.31655 6.70623 9.70708 7.09676L13.8927 11.2824C14.2833 11.6729 14.2833 12.3061 13.8927 12.6966L9.71069 16.8787C9.32016 17.2692 9.32016 17.9023 9.71069 18.2929Z" fill="#000" />
2262
- </svg>
2263
- </button>
2264
- </div>
2265
-
2266
-
2267
-
2268
- <div className="custom-event-tl__body">
2269
-
2270
-
2271
- <div className="custom-event-tl__row">
2272
- {/* day */}
2273
-
2274
- {/* /day */}
2275
- </div>
2276
-
2277
- </div>
2278
- {/*++++++++++++++++ /MAIN ++++++++++++++++*/}
2279
-
2280
-
2281
- {/*++++++++++++++++ MONTH SELECTION TAB ++++++++++++++++*/}
2282
- <div className={`custom-event-tl__month-wrapper shadow p-3 mb-5 bg-body-tertiary rounded ${winMonth ? 'active' : ''}`}>
2283
- <div className="custom-event-tl__month-container">
2284
- {MONTHS_FULL.map((month, index) => {
2285
- return <div
2286
- data-month={padZero(index + 1)}
2287
- className={`custom-event-tl__month ${selectedMonth === index ? ' selected' : ''}`}
2288
- key={month + index}
2289
- onClick={() => { handleMonthChange(index) }}
2290
- >{month}</div>
2291
- })}
2292
- </div>
2293
- </div>
2294
- {/*++++++++++++++++ /MONTH SELECTION TAB ++++++++++++++++*/}
2295
-
2296
- {/*++++++++++++++++ YEAR SELECTION TAB ++++++++++++++++*/}
2297
- <div className={`custom-event-tl__year-wrapper shadow p-3 mb-5 bg-body-tertiary rounded ${winYear ? 'active' : ''}`}>
2298
- <div className="custom-event-tl__year-container bg-body-tertiary">
2299
- {yearsArray.map((year, index) => {
2300
- return <div
2301
- data-year={year}
2302
- className={`custom-event-tl__year ${selectedYear === year ? ' selected' : ''}`}
2303
- key={year + index}
2304
- onClick={() => { handleYearChange(year) }}
2305
- >{year}</div>
2306
- })}
2307
- </div>
2308
-
2309
- </div>
2310
- {/*++++++++++++++++ /YEAR SELECTION TAB ++++++++++++++++*/}
2311
-
2312
-
2313
-
2314
- {/*++++++++++++++++ TODAY SELECTION TAB ++++++++++++++++*/}
2315
- <div className="custom-event-tl__today-wrapper p-2">
2316
- <button
2317
- tabIndex={-1}
2318
- type="button"
2319
- className="custom-event-tl__btn custom-event-tl__btn--today"
2320
- onClick={handleTodayChange}
2321
- >
2322
- {langToday || 'Today'}
2323
- </button>
2324
-
2325
- {appearanceToggle ? <>
2326
- <button
2327
- tabIndex={-1}
2328
- type="button"
2329
- className={`custom-event-tl__btn custom-event-tl__btn--appearance ${appearanceMode === 'month' ? 'active' : ''}`}
2330
- data-mode="month"
2331
- onClick={handleAppearanceChange}
2332
- >
2333
- {langAppearanceLabelMonth || 'Month'}
2334
- </button>
2335
- <button
2336
- tabIndex={-1}
2337
- type="button"
2338
- className={`custom-event-tl__btn custom-event-tl__btn--appearance ${appearanceMode === 'week' ? 'active' : ''}`}
2339
- data-mode="week"
2340
- onClick={handleAppearanceChange}
2341
- >
2342
- {langAppearanceLabelWeek || 'Week'}
2343
- </button>
2344
- </> : null}
2345
-
2346
- </div>
2347
- {/*++++++++++++++++ /TODAY SELECTION TAB ++++++++++++++++*/}
2348
-
2349
-
2350
- </div>{/* /.custom-event-tl__wrapper */}
2351
-
2352
-
2353
-
2354
- {/*/////////////////////////////////////////////////// */}
2355
- {/*//////////////////// Table Grid //////////////////// */}
2356
- {/*////////////////////////////////////////////////// */}
2357
- {orginalData.length === 0 ? null : <>
2358
- <div
2359
- ref={tableGridRef}
2360
- className={combinedCls(
2361
- `custom-event-tl-table__timeline-table__wrapper custom-event-tl-table__timeline-table__wrapper--${appearanceMode} invisible`,
2362
- tableWrapperClassName
2363
- )}
2364
- onKeyDown={(e: React.KeyboardEvent<HTMLDivElement>) => {
2365
- onKeyPressed?.(e, selectedCells);
2366
-
2367
- // Copy & Paste
2368
- handleWrapperKeyDown(e);
2369
- }}
2370
- tabIndex={-1} // require "tabIndex" attribute
2371
- >
2372
- <table role="grid" className={combinedCls(
2373
- "custom-event-tl-table__timeline-table",
2374
- tableClassName
2375
- )}>
2376
- <colgroup>
2377
- <col className="custom-event-tl-table__datagrid-header" />
2378
- <col />
2379
- <col />
2380
- </colgroup>
2381
-
2382
- <thead className={combinedCls(
2383
- tableHeadClassName
2384
- )}
2385
- ref={tableGridHeaderRef}
2386
- role="rowgroup"
2387
- >
2388
- <tr role="presentation">
2389
- <th role="presentation">
2390
- {/*<!--///// HEADER LEFT //////-->*/}
2391
- <div className="custom-event-tl-table__timeline-header custom-event-tl-table__timeline-headertitle">
2392
-
2393
- <table role="presentation" className="custom-event-tl-table__datagrid-header__title">
2394
- <colgroup>
2395
- <col />
2396
- </colgroup>
2397
- <thead role="presentation">
2398
- <tr role="row">
2399
- <th role="columnheader">
2400
- <div className="custom-event-tl-table__cell-cushion custom-event-tl-table__cell-cushion-headertitle">
2401
- {tableListSectionTitle || ''}
2402
- </div>
2403
- </th>
2404
- </tr>
2405
- </thead>
2406
- </table>
2407
-
2408
- </div>
2409
- {/*<!--///// /HEADER LEFT //////-->*/}
2410
-
2411
-
2412
-
2413
- </th>
2414
- <th role="presentation" className="custom-event-tl-table__timeline-divider"><div></div></th>
2415
- <th role="presentation">
2416
- <div
2417
- ref={scrollHeaderRef}
2418
- className="custom-event-tl-table__scroller-harness custom-event-tl-table__scroller-harness--hide"
2419
- data-scroll="header"
2420
- onScroll={syncTableScrollHeader}
2421
- >
2422
- <div className="custom-event-tl-table__scroller">
2423
-
2424
- {/*<!--///// HEADER RIGHT //////-->*/}
2425
- <div className="custom-event-tl-table__timeline-header">
2426
-
2427
- <table className="custom-event-tl-table__datagrid-header__content custom-event-tl-table__scrollgrid-sync-table" >
2428
- <tbody>
2429
- <tr>
2430
- {generateDaysUi()}
2431
- </tr>
2432
- </tbody>
2433
- </table>
2434
- </div>
2435
- {/*<!--///// /HEADER RIGHT //////-->*/}
2436
- </div>
2437
- </div>
2438
- </th>
2439
- </tr>
2440
- </thead>
2441
-
2442
-
2443
-
2444
- <tbody className={combinedCls(
2445
- tableBodyClassName
2446
- )}
2447
- role="rowgroup"
2448
- >
2449
- <tr role="presentation" className="custom-event-tl-table__list-section">
2450
- <td
2451
- role="presentation"
2452
- className={combinedCls(
2453
- tableListStartClassName
2454
- )}
2455
-
2456
- >
2457
-
2458
- <div
2459
- ref={scrollListRef}
2460
- className={combinedCls(
2461
- 'custom-event-tl-table__scroller-harness',
2462
- {
2463
- 'autoscroll': AUTO_SCROLL
2464
- }
2465
- )}
2466
- data-scroll="list"
2467
- onScroll={syncTableScrollList}
2468
- >
2469
- <div className="custom-event-tl-table__scroller">
2470
-
2471
- {/*<!--///// RESOURCE LEFT //////-->*/}
2472
- <table role="presentation" className="custom-event-tl-table__datagrid-body__title custom-event-tl-table__scrollgrid-sync-table">
2473
- <colgroup>
2474
- <col />
2475
- </colgroup>
2476
- <tbody role="presentation">
2477
-
2478
- {/*<!-- per row -->*/}
2479
- {generateListSectionUi()}
2480
- {/*<!-- /per row -->*/}
2481
-
2482
- </tbody>
2483
- </table>
2484
- {/*<!--///// /RESOURCE LEFT //////-->*/}
2485
- </div>
2486
- </div>
2487
-
2488
-
2489
- </td>
2490
- <td
2491
- role="presentation"
2492
- className={combinedCls(
2493
- 'custom-event-tl-table__timeline-divider',
2494
- tableListDividerClassName
2495
- )}
2496
- >
2497
- <div></div>
2498
- </td>
2499
- <td
2500
- role="presentation"
2501
- className={combinedCls(
2502
- tableListEndClassName
2503
- )}
2504
- >
2505
-
2506
-
2507
- <div
2508
- ref={scrollBodyRef}
2509
- className={combinedCls(
2510
- 'custom-event-tl-table__scroller-harness',
2511
- {
2512
- 'autoscroll': AUTO_SCROLL
2513
- }
2514
- )}
2515
- data-scroll="body"
2516
- onScroll={syncTableScrollBody}
2517
- onMouseMove={BODY_DRAG ? handleTableMove : () => { }}
2518
- onMouseDown={BODY_DRAG ? handleTableDragStart : () => { }}
2519
- onMouseUp={BODY_DRAG ? handleTableDragEnd : () => { }}
2520
- onMouseLeave={BODY_DRAG ? handleTableDragEnd : () => { }}
2521
- >
2522
- <div className="custom-event-tl-table__scroller">
2523
- {/*<!--///// RESOURCE RIGHT //////-->*/}
2524
- <div className="custom-event-tl-table__timeline-body">
2525
- <table
2526
- className="custom-event-tl-table__datagrid-body__content custom-event-tl-table__scrollgrid-sync-table"
2527
- /* Drag to activate the selection area */
2528
- onMouseLeave={multipleCells ? handleTableMainMouseUp : undefined}
2529
- onMouseUp={multipleCells ? handleTableMainMouseUp : undefined}
2530
-
2531
- >
2532
- <colgroup>
2533
- {generateColUi()}
2534
- </colgroup>
2535
- <tbody>
2536
- {/*<!-- per row -->*/}
2537
- {orginalData.map((item: any, i: number) => {
2538
-
2539
- return (
2540
- <tr key={i}>
2541
- {generateDaysUi(item.eventSources, item.listSection, i, true)}
2542
- </tr>
2543
- )
2544
-
2545
- })}
2546
-
2547
- </tbody>
2548
- </table>
2549
-
2550
- </div>
2551
- {/*<!--///// /RESOURCE RIGHT //////-->*/}
2552
-
2553
-
2554
- </div>
2555
- </div>
2556
-
2557
-
2558
- </td>
2559
- </tr>
2560
- </tbody>
2561
- </table>
2562
-
2563
- </div>{/* /.custom-event-tl-table__timeline-table__wrapper */}
2564
-
2565
-
2566
- </>}
2567
-
2568
-
2569
- {/*/////////////////////////////////////////////////// */}
2570
- {/*//////////////////// Modal //////////////////// */}
2571
- {/*////////////////////////////////////////////////// */}
2572
-
2573
- {/*++++++++++++++++ MODAL ++++++++++++++++*/}
2574
- {EVENTS_ENABLED ? <>
2575
-
2576
- {/*<!-- DELETE -->*/}
2577
- <ModalDialog
2578
- ref={modalDeleteHandleRef}
2579
- show={showDelete}
2580
- maskOpacity={modalMaskOpacity}
2581
- triggerClassName=""
2582
- triggerContent=""
2583
- closeBtnClassName={modalCloseBtnClassName || 'btn btn-secondary'}
2584
- closeBtnLabel={modalCloseBtnLabel || 'Close'}
2585
- submitBtnClassName={modalSubmitDeleteBtnClassName || 'btn btn-danger'}
2586
- submitBtnLabel={modalSubmitDeleteBtnLabel || <>Delete</>}
2587
- onClose={(e) => {
2588
-
2589
- setTimeout(() => {
2590
- setShowDelete(false);
2591
- onModalDeleteClose?.(queryItemObj());
2592
- // set temporary date
2593
- setTempDate('');
2594
- }, 350);
2595
- }}
2596
- onSubmit={async (e: any, closewin: Function, data: any) => {
2597
- onModalDeleteEvent?.(queryItemObj(), closewin, () => {
2598
-
2599
- // initialize table grid
2600
- setTimeout(() => {
2601
- tableGridInitHeadertitle();
2602
- }, 500);
2603
- });
2604
- }}
2605
- >
2606
- {modalDeleteContent || 'Are you sure?'}
2607
-
2608
- </ModalDialog>
2609
- {/*<!-- /DELETE -->*/}
2610
-
2611
-
2612
- {/*<!-- EDIT -->*/}
2613
- <ModalDialog
2614
- ref={modalEditHandleRef}
2615
- show={showEdit}
2616
- maskOpacity={modalMaskOpacity}
2617
- heading={modalHeading}
2618
- maxWidth={modalMaxWidth}
2619
- minHeight={modalMinHeight}
2620
- triggerClassName=""
2621
- triggerContent=""
2622
- closeBtnClassName={modalCloseBtnClassName || 'btn btn-secondary'}
2623
- closeBtnLabel={modalCloseBtnLabel || 'Close'}
2624
- submitBtnClassName={modalSubmitBtnClassName || 'btn btn-primary'}
2625
- submitBtnLabel={modalSubmitBtnLabel || <>Save</>}
2626
- onClose={(e) => {
2627
-
2628
- setTimeout(() => {
2629
- setShowEdit(false);
2630
- onModalEditClose?.(queryItemObj());
2631
- // set temporary date
2632
- setTempDate('');
2633
- }, 350);
2634
- }}
2635
- onSubmit={async (e: any, closewin: Function, data: any) => {
2636
-
2637
- onModalEditEvent?.(queryItemObj(), closewin, () => {
2638
- // initialize table grid
2639
- setTimeout(() => {
2640
- tableGridInitHeadertitle();
2641
- }, 500);
2642
- });
2643
-
2644
-
2645
- }}
2646
- >
2647
- {modalContent}
2648
-
2649
- </ModalDialog>
2650
- {/*<!-- /EDIT -->*/}
2651
-
2652
-
2653
- </> : null}
2654
- {/*++++++++++++++++ /MODAL ++++++++++++++++*/}
2655
-
2656
-
2657
-
2658
- {/*/////////////////////////////////////////////////// */}
2659
- {/*//////////////////// Table Grid Tooltip //////////////////// */}
2660
- {/*////////////////////////////////////////////////// */}
2661
- <RootPortal show={true} containerClassName="EventCalendarTimeline-TooltipModal">
2662
- <div
2663
- ref={tableTooltipModalRef}
2664
- id={`custom-event-tl-table__cell-tooltipwrapper-${idRes}`}
2665
- className={`custom-event-tl-table__cell-tooltipwrapper d-inline-block ${isShowTableTooltip ? 'active' : ''}`}
2666
- role="tooltip"
2667
- data-microtip-position={tableTooltipDirection || 'bottom'}
2668
- data-microtip-size={tableTooltipSize || 'auto'}
2669
- style={{ display: 'none' }}
2670
- >
2671
- <div className="custom-event-tl-table__cell-tooltipcontent">
2672
- {tableTooltipContent}
2673
- </div>
2674
- </div>
2675
- </RootPortal>
2676
-
2677
-
2678
- </>
2679
- )
2680
- };
2681
-
2682
-
2683
- export default EventCalendarTimeline;