funda-ui 4.5.682 → 4.5.711

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 (506) hide show
  1. package/.gitattributes +2 -0
  2. package/README.md +105 -4
  3. package/README_PUBLISH.md +126 -0
  4. package/lib/cjs/DragDropList/index.d.ts +1 -0
  5. package/lib/cjs/DragDropList/index.js +4 -6
  6. package/lib/cjs/MultipleSelect/index.d.ts +1 -0
  7. package/lib/cjs/MultipleSelect/index.js +23 -25
  8. package/lib/cjs/Textarea/index.d.ts +1 -0
  9. package/lib/cjs/Textarea/index.js +55 -13
  10. package/lib/cjs/Tree/index.d.ts +1 -0
  11. package/lib/cjs/Tree/index.js +29 -0
  12. package/lib/cjs/Utils/useAutosizeTextArea.d.ts +4 -1
  13. package/lib/cjs/Utils/useAutosizeTextArea.js +37 -2
  14. package/lib/cjs/Utils/useBoundedDrag.d.ts +0 -2
  15. package/lib/cjs/Utils/useBoundedDrag.js +0 -2
  16. package/lib/cjs/Utils/useIsMobile.d.ts +2 -0
  17. package/lib/cjs/Utils/useIsMobile.js +168 -0
  18. package/lib/cjs/index.js +0 -1
  19. package/lib/esm/DragDropList/index.tsx +1 -0
  20. package/lib/esm/MultipleSelect/index.tsx +1 -0
  21. package/lib/esm/Textarea/index.tsx +17 -12
  22. package/lib/esm/Tree/TreeList.tsx +32 -0
  23. package/lib/esm/Tree/index.tsx +3 -0
  24. package/lib/esm/Utils/hooks/useAutosizeTextArea.tsx +39 -4
  25. package/lib/esm/Utils/hooks/useBoundedDrag.tsx +0 -2
  26. package/lib/esm/Utils/hooks/useIsMobile.tsx +56 -0
  27. package/logo.png +0 -0
  28. package/package.json +556 -11
  29. package/preview.png +0 -0
  30. package/{DragDropList → publish/DragDropList}/index.d.ts +1 -0
  31. package/{DragDropList → publish/DragDropList}/index.js +4 -6
  32. package/publish/LICENSE +21 -0
  33. package/{MultipleSelect → publish/MultipleSelect}/index.d.ts +1 -0
  34. package/{MultipleSelect → publish/MultipleSelect}/index.js +23 -25
  35. package/publish/README.md +126 -0
  36. package/{Textarea → publish/Textarea}/index.d.ts +1 -0
  37. package/{Textarea → publish/Textarea}/index.js +55 -13
  38. package/{Tree → publish/Tree}/index.d.ts +1 -0
  39. package/{Tree → publish/Tree}/index.js +29 -0
  40. package/{Utils → publish/Utils}/useAutosizeTextArea.d.ts +4 -1
  41. package/{Utils → publish/Utils}/useAutosizeTextArea.js +37 -2
  42. package/{Utils → publish/Utils}/useBoundedDrag.d.ts +0 -2
  43. package/{Utils → publish/Utils}/useBoundedDrag.js +0 -2
  44. package/publish/Utils/useIsMobile.d.ts +2 -0
  45. package/publish/Utils/useIsMobile.js +168 -0
  46. package/{all.js → publish/all.js} +0 -1
  47. package/publish/lib/cjs/Accordion/index.d.ts +2 -0
  48. package/publish/lib/cjs/Accordion/index.js +1035 -0
  49. package/publish/lib/cjs/BackToTop/index.d.ts +17 -0
  50. package/publish/lib/cjs/BackToTop/index.js +904 -0
  51. package/publish/lib/cjs/CascadingSelect/index.d.ts +60 -0
  52. package/publish/lib/cjs/CascadingSelect/index.js +2943 -0
  53. package/publish/lib/cjs/CascadingSelectE2E/index.d.ts +71 -0
  54. package/publish/lib/cjs/CascadingSelectE2E/index.js +3540 -0
  55. package/publish/lib/cjs/Checkbox/index.d.ts +28 -0
  56. package/publish/lib/cjs/Checkbox/index.js +662 -0
  57. package/publish/lib/cjs/ColorPicker/index.d.ts +27 -0
  58. package/publish/lib/cjs/ColorPicker/index.js +662 -0
  59. package/publish/lib/cjs/Date/index.d.ts +70 -0
  60. package/publish/lib/cjs/Date/index.js +6200 -0
  61. package/publish/lib/cjs/DigitalClock/index.d.ts +7 -0
  62. package/publish/lib/cjs/DigitalClock/index.js +402 -0
  63. package/publish/lib/cjs/DragDropList/index.d.ts +44 -0
  64. package/publish/lib/cjs/DragDropList/index.js +1587 -0
  65. package/publish/lib/cjs/DropdownMenu/index.d.ts +38 -0
  66. package/publish/lib/cjs/DropdownMenu/index.js +1498 -0
  67. package/publish/lib/cjs/DynamicFields/index.d.ts +40 -0
  68. package/publish/lib/cjs/DynamicFields/index.js +810 -0
  69. package/publish/lib/cjs/EventCalendar/index.d.ts +61 -0
  70. package/publish/lib/cjs/EventCalendar/index.js +3740 -0
  71. package/publish/lib/cjs/EventCalendarTimeline/index.d.ts +100 -0
  72. package/publish/lib/cjs/EventCalendarTimeline/index.js +6084 -0
  73. package/publish/lib/cjs/File/index.d.ts +40 -0
  74. package/publish/lib/cjs/File/index.js +1751 -0
  75. package/publish/lib/cjs/HorizontalScrollContent/index.d.ts +14 -0
  76. package/publish/lib/cjs/HorizontalScrollContent/index.js +426 -0
  77. package/publish/lib/cjs/Input/index.d.ts +59 -0
  78. package/publish/lib/cjs/Input/index.js +1455 -0
  79. package/publish/lib/cjs/LiveSearch/index.d.ts +69 -0
  80. package/publish/lib/cjs/LiveSearch/index.js +3626 -0
  81. package/publish/lib/cjs/MasonryLayout/index.d.ts +14 -0
  82. package/publish/lib/cjs/MasonryLayout/index.js +689 -0
  83. package/publish/lib/cjs/ModalDialog/index.d.ts +79 -0
  84. package/publish/lib/cjs/ModalDialog/index.js +1695 -0
  85. package/publish/lib/cjs/ModeSwitch/index.d.ts +17 -0
  86. package/publish/lib/cjs/ModeSwitch/index.js +202 -0
  87. package/publish/lib/cjs/MultilevelDropdownMenu/index.d.ts +20 -0
  88. package/publish/lib/cjs/MultilevelDropdownMenu/index.js +930 -0
  89. package/publish/lib/cjs/MultipleCheckboxes/index.d.ts +41 -0
  90. package/publish/lib/cjs/MultipleCheckboxes/index.js +1717 -0
  91. package/publish/lib/cjs/MultipleSelect/index.d.ts +65 -0
  92. package/publish/lib/cjs/MultipleSelect/index.js +3704 -0
  93. package/publish/lib/cjs/NativeSelect/index.d.ts +37 -0
  94. package/publish/lib/cjs/NativeSelect/index.js +1631 -0
  95. package/publish/lib/cjs/NumberInput/index.d.ts +40 -0
  96. package/publish/lib/cjs/NumberInput/index.js +1188 -0
  97. package/publish/lib/cjs/Pagination/index.d.ts +51 -0
  98. package/publish/lib/cjs/Pagination/index.js +612 -0
  99. package/publish/lib/cjs/Radio/index.d.ts +45 -0
  100. package/publish/lib/cjs/Radio/index.js +1391 -0
  101. package/publish/lib/cjs/RangeSlider/index.d.ts +22 -0
  102. package/publish/lib/cjs/RangeSlider/index.js +2665 -0
  103. package/publish/lib/cjs/RootPortal/index.d.ts +8 -0
  104. package/publish/lib/cjs/RootPortal/index.js +141 -0
  105. package/publish/lib/cjs/ScrollReveal/index.d.ts +21 -0
  106. package/publish/lib/cjs/ScrollReveal/index.js +401 -0
  107. package/publish/lib/cjs/Scrollbar/index.d.ts +17 -0
  108. package/publish/lib/cjs/Scrollbar/index.js +1107 -0
  109. package/publish/lib/cjs/SearchBar/index.d.ts +41 -0
  110. package/publish/lib/cjs/SearchBar/index.js +701 -0
  111. package/publish/lib/cjs/Select/index.d.ts +99 -0
  112. package/publish/lib/cjs/Select/index.js +5697 -0
  113. package/publish/lib/cjs/ShowMoreLess/index.d.ts +36 -0
  114. package/publish/lib/cjs/ShowMoreLess/index.js +387 -0
  115. package/publish/lib/cjs/Switch/index.d.ts +25 -0
  116. package/publish/lib/cjs/Switch/index.js +628 -0
  117. package/publish/lib/cjs/Table/index.d.ts +12 -0
  118. package/publish/lib/cjs/Table/index.js +2062 -0
  119. package/publish/lib/cjs/Tabs/index.d.ts +3 -0
  120. package/publish/lib/cjs/Tabs/index.js +771 -0
  121. package/publish/lib/cjs/TagInput/index.d.ts +31 -0
  122. package/publish/lib/cjs/TagInput/index.js +1144 -0
  123. package/publish/lib/cjs/Textarea/index.d.ts +50 -0
  124. package/publish/lib/cjs/Textarea/index.js +1784 -0
  125. package/publish/lib/cjs/Toast/index.d.ts +34 -0
  126. package/publish/lib/cjs/Toast/index.js +861 -0
  127. package/publish/lib/cjs/Tooltip/index.d.ts +23 -0
  128. package/publish/lib/cjs/Tooltip/index.js +1674 -0
  129. package/publish/lib/cjs/Tree/index.d.ts +62 -0
  130. package/publish/lib/cjs/Tree/index.js +1960 -0
  131. package/publish/lib/cjs/Utils/anim.d.ts +11 -0
  132. package/publish/lib/cjs/Utils/anim.js +400 -0
  133. package/publish/lib/cjs/Utils/bodyScrollLock.d.ts +8 -0
  134. package/publish/lib/cjs/Utils/bodyScrollLock.js +311 -0
  135. package/publish/lib/cjs/Utils/buffer.d.ts +67 -0
  136. package/publish/lib/cjs/Utils/buffer.js +343 -0
  137. package/publish/lib/cjs/Utils/cls.d.ts +15 -0
  138. package/publish/lib/cjs/Utils/cls.js +124 -0
  139. package/publish/lib/cjs/Utils/convert.d.ts +25 -0
  140. package/publish/lib/cjs/Utils/convert.js +109 -0
  141. package/publish/lib/cjs/Utils/date.d.ts +217 -0
  142. package/publish/lib/cjs/Utils/date.js +567 -0
  143. package/publish/lib/cjs/Utils/dom.d.ts +13 -0
  144. package/publish/lib/cjs/Utils/dom.js +215 -0
  145. package/publish/lib/cjs/Utils/easing.d.ts +29 -0
  146. package/publish/lib/cjs/Utils/easing.js +221 -0
  147. package/publish/lib/cjs/Utils/extract.d.ts +28 -0
  148. package/publish/lib/cjs/Utils/extract.js +130 -0
  149. package/publish/lib/cjs/Utils/getElementProperty.d.ts +52 -0
  150. package/publish/lib/cjs/Utils/getElementProperty.js +189 -0
  151. package/publish/lib/cjs/Utils/guid.d.ts +7 -0
  152. package/publish/lib/cjs/Utils/guid.js +67 -0
  153. package/publish/lib/cjs/Utils/initDefaultOptions.d.ts +21 -0
  154. package/publish/lib/cjs/Utils/initDefaultOptions.js +131 -0
  155. package/publish/lib/cjs/Utils/inputsCalculation.d.ts +28 -0
  156. package/publish/lib/cjs/Utils/inputsCalculation.js +188 -0
  157. package/publish/lib/cjs/Utils/math.d.ts +77 -0
  158. package/publish/lib/cjs/Utils/math.js +305 -0
  159. package/publish/lib/cjs/Utils/object.d.ts +18 -0
  160. package/publish/lib/cjs/Utils/object.js +120 -0
  161. package/publish/lib/cjs/Utils/os.d.ts +2 -0
  162. package/publish/lib/cjs/Utils/os.js +104 -0
  163. package/publish/lib/cjs/Utils/performance.d.ts +3 -0
  164. package/publish/lib/cjs/Utils/performance.js +94 -0
  165. package/publish/lib/cjs/Utils/tree.d.ts +40 -0
  166. package/publish/lib/cjs/Utils/tree.js +195 -0
  167. package/publish/lib/cjs/Utils/useAutosizeTextArea.d.ts +10 -0
  168. package/publish/lib/cjs/Utils/useAutosizeTextArea.js +227 -0
  169. package/publish/lib/cjs/Utils/useBoundedDrag.d.ts +125 -0
  170. package/publish/lib/cjs/Utils/useBoundedDrag.js +380 -0
  171. package/publish/lib/cjs/Utils/useClickOutside.d.ts +33 -0
  172. package/publish/lib/cjs/Utils/useClickOutside.js +166 -0
  173. package/publish/lib/cjs/Utils/useComId.d.ts +6 -0
  174. package/publish/lib/cjs/Utils/useComId.js +114 -0
  175. package/publish/lib/cjs/Utils/useDebounce.d.ts +20 -0
  176. package/publish/lib/cjs/Utils/useDebounce.js +138 -0
  177. package/publish/lib/cjs/Utils/useDragDropPosition.d.ts +169 -0
  178. package/publish/lib/cjs/Utils/useDragDropPosition.js +456 -0
  179. package/publish/lib/cjs/Utils/useDraggable.d.ts +62 -0
  180. package/publish/lib/cjs/Utils/useDraggable.js +348 -0
  181. package/publish/lib/cjs/Utils/useInterval.d.ts +5 -0
  182. package/publish/lib/cjs/Utils/useInterval.js +168 -0
  183. package/publish/lib/cjs/Utils/useIsMobile.d.ts +2 -0
  184. package/publish/lib/cjs/Utils/useIsMobile.js +168 -0
  185. package/publish/lib/cjs/Utils/useKeyPress.d.ts +44 -0
  186. package/publish/lib/cjs/Utils/useKeyPress.js +200 -0
  187. package/publish/lib/cjs/Utils/useThrottle.d.ts +2 -0
  188. package/publish/lib/cjs/Utils/useThrottle.js +136 -0
  189. package/publish/lib/cjs/Utils/useWindowScroll.d.ts +12 -0
  190. package/publish/lib/cjs/Utils/useWindowScroll.js +217 -0
  191. package/publish/lib/cjs/Utils/viewport.d.ts +7 -0
  192. package/publish/lib/cjs/Utils/viewport.js +64 -0
  193. package/publish/lib/cjs/index.d.ts +45 -0
  194. package/publish/lib/cjs/index.js +46 -0
  195. package/publish/lib/css/BackToTop/index.css +34 -0
  196. package/publish/lib/css/CascadingSelect/index.css +216 -0
  197. package/publish/lib/css/CascadingSelectE2E/index.css +216 -0
  198. package/publish/lib/css/ColorPicker/index.css +58 -0
  199. package/publish/lib/css/Date/index.css +434 -0
  200. package/publish/lib/css/DragDropList/index.css +188 -0
  201. package/publish/lib/css/DropdownMenu/index.css +151 -0
  202. package/publish/lib/css/EventCalendar/index.css +300 -0
  203. package/publish/lib/css/EventCalendarTimeline/index.css +694 -0
  204. package/publish/lib/css/HorizontalScrollContent/index.css +70 -0
  205. package/publish/lib/css/LiveSearch/index.css +55 -0
  206. package/publish/lib/css/MultilevelDropdownMenu/index.css +38 -0
  207. package/publish/lib/css/MultipleSelect/index.css +313 -0
  208. package/publish/lib/css/RangeSlider/index.css +150 -0
  209. package/publish/lib/css/Scrollbar/index.css +176 -0
  210. package/publish/lib/css/Select/index.css +368 -0
  211. package/publish/lib/css/ShowMoreLess/index.css +23 -0
  212. package/publish/lib/css/Table/index.css +584 -0
  213. package/publish/lib/css/TagInput/index.css +91 -0
  214. package/publish/lib/css/Toast/index.css +201 -0
  215. package/publish/lib/css/Tooltip/index.css +197 -0
  216. package/publish/lib/css/Tree/index.css +232 -0
  217. package/publish/lib/esm/Accordion/Accordion.tsx +184 -0
  218. package/publish/lib/esm/Accordion/AccordionItem.tsx +143 -0
  219. package/publish/lib/esm/Accordion/index.tsx +2 -0
  220. package/publish/lib/esm/BackToTop/index.scss +47 -0
  221. package/publish/lib/esm/BackToTop/index.tsx +177 -0
  222. package/publish/lib/esm/CascadingSelect/Group.tsx +82 -0
  223. package/publish/lib/esm/CascadingSelect/index.scss +291 -0
  224. package/publish/lib/esm/CascadingSelect/index.tsx +1203 -0
  225. package/publish/lib/esm/CascadingSelectE2E/Group.tsx +83 -0
  226. package/publish/lib/esm/CascadingSelectE2E/index.scss +293 -0
  227. package/publish/lib/esm/CascadingSelectE2E/index.tsx +1471 -0
  228. package/publish/lib/esm/Checkbox/index.tsx +193 -0
  229. package/publish/lib/esm/ColorPicker/index.scss +91 -0
  230. package/publish/lib/esm/ColorPicker/index.tsx +204 -0
  231. package/publish/lib/esm/Date/Calendar.tsx +723 -0
  232. package/publish/lib/esm/Date/index.scss +567 -0
  233. package/publish/lib/esm/Date/index.tsx +1683 -0
  234. package/publish/lib/esm/Date/localization/en_US.js +13 -0
  235. package/publish/lib/esm/Date/localization/zh_CN.js +12 -0
  236. package/publish/lib/esm/DigitalClock/index.tsx +74 -0
  237. package/publish/lib/esm/DragDropList/index.scss +245 -0
  238. package/publish/lib/esm/DragDropList/index.tsx +494 -0
  239. package/publish/lib/esm/DropdownMenu/Option.tsx +55 -0
  240. package/publish/lib/esm/DropdownMenu/index.scss +205 -0
  241. package/publish/lib/esm/DropdownMenu/index.tsx +377 -0
  242. package/publish/lib/esm/DynamicFields/index.tsx +404 -0
  243. package/publish/lib/esm/EventCalendar/index.scss +407 -0
  244. package/publish/lib/esm/EventCalendar/index.tsx +1004 -0
  245. package/publish/lib/esm/EventCalendarTimeline/index.scss +926 -0
  246. package/publish/lib/esm/EventCalendarTimeline/index.tsx +2683 -0
  247. package/publish/lib/esm/File/index.tsx +477 -0
  248. package/publish/lib/esm/HorizontalScrollContent/index.scss +87 -0
  249. package/publish/lib/esm/HorizontalScrollContent/index.tsx +171 -0
  250. package/publish/lib/esm/Input/index.tsx +614 -0
  251. package/publish/lib/esm/LiveSearch/index.scss +82 -0
  252. package/publish/lib/esm/LiveSearch/index.tsx +960 -0
  253. package/publish/lib/esm/MasonryLayout/index.tsx +326 -0
  254. package/publish/lib/esm/ModalDialog/index.tsx +552 -0
  255. package/publish/lib/esm/ModeSwitch/index.tsx +82 -0
  256. package/publish/lib/esm/MultilevelDropdownMenu/ItemList.tsx +265 -0
  257. package/publish/lib/esm/MultilevelDropdownMenu/index.scss +79 -0
  258. package/publish/lib/esm/MultilevelDropdownMenu/index.tsx +77 -0
  259. package/publish/lib/esm/MultipleCheckboxes/index.tsx +669 -0
  260. package/publish/lib/esm/MultipleSelect/index.scss +398 -0
  261. package/publish/lib/esm/MultipleSelect/index.tsx +766 -0
  262. package/publish/lib/esm/MultipleSelect/utils/func.ts +61 -0
  263. package/publish/lib/esm/NativeSelect/index.tsx +396 -0
  264. package/publish/lib/esm/NativeSelect/utils/func.ts +49 -0
  265. package/publish/lib/esm/NumberInput/index.tsx +385 -0
  266. package/publish/lib/esm/Pagination/index.tsx +286 -0
  267. package/publish/lib/esm/Pagination/pagination-navigators.tsx +60 -0
  268. package/publish/lib/esm/Radio/index.tsx +670 -0
  269. package/publish/lib/esm/RangeSlider/index.scss +186 -0
  270. package/publish/lib/esm/RangeSlider/index.tsx +241 -0
  271. package/publish/lib/esm/RootPortal/index.tsx +53 -0
  272. package/publish/lib/esm/ScrollReveal/index.tsx +148 -0
  273. package/publish/lib/esm/Scrollbar/index.scss +221 -0
  274. package/publish/lib/esm/Scrollbar/index.tsx +561 -0
  275. package/publish/lib/esm/SearchBar/index.tsx +253 -0
  276. package/publish/lib/esm/Select/index.scss +553 -0
  277. package/publish/lib/esm/Select/index.tsx +2816 -0
  278. package/publish/lib/esm/Select/utils/func.ts +106 -0
  279. package/publish/lib/esm/ShowMoreLess/index.scss +27 -0
  280. package/publish/lib/esm/ShowMoreLess/index.tsx +145 -0
  281. package/publish/lib/esm/Switch/index.tsx +147 -0
  282. package/publish/lib/esm/Table/Table.tsx +257 -0
  283. package/publish/lib/esm/Table/TableBody.tsx +41 -0
  284. package/publish/lib/esm/Table/TableCaption.tsx +34 -0
  285. package/publish/lib/esm/Table/TableCell.tsx +123 -0
  286. package/publish/lib/esm/Table/TableColgroup.tsx +38 -0
  287. package/publish/lib/esm/Table/TableContext.tsx +26 -0
  288. package/publish/lib/esm/Table/TableFoot.tsx +28 -0
  289. package/publish/lib/esm/Table/TableHead.tsx +28 -0
  290. package/publish/lib/esm/Table/TableRow.tsx +76 -0
  291. package/publish/lib/esm/Table/index.scss +418 -0
  292. package/publish/lib/esm/Table/index.tsx +14 -0
  293. package/publish/lib/esm/Table/utils/DragHandleSprite.tsx +46 -0
  294. package/publish/lib/esm/Table/utils/SortSprite.tsx +57 -0
  295. package/publish/lib/esm/Table/utils/TableFilter.tsx +56 -0
  296. package/publish/lib/esm/Table/utils/ToggleSelection.tsx +225 -0
  297. package/publish/lib/esm/Table/utils/func.ts +171 -0
  298. package/publish/lib/esm/Table/utils/hooks/useTableDraggable.tsx +342 -0
  299. package/publish/lib/esm/Table/utils/hooks/useTableKeyPress.tsx +154 -0
  300. package/publish/lib/esm/Table/utils/hooks/useTableResponsive.tsx +92 -0
  301. package/publish/lib/esm/Table/utils/hooks/useTableSort.tsx +143 -0
  302. package/publish/lib/esm/Tabs/TabList.tsx +50 -0
  303. package/publish/lib/esm/Tabs/TabPanel.tsx +44 -0
  304. package/publish/lib/esm/Tabs/Tabs.tsx +282 -0
  305. package/publish/lib/esm/Tabs/index.tsx +3 -0
  306. package/publish/lib/esm/TagInput/index.scss +126 -0
  307. package/publish/lib/esm/TagInput/index.tsx +352 -0
  308. package/publish/lib/esm/Textarea/index.tsx +608 -0
  309. package/publish/lib/esm/Toast/Item.tsx +124 -0
  310. package/publish/lib/esm/Toast/index.scss +269 -0
  311. package/publish/lib/esm/Toast/index.tsx +374 -0
  312. package/publish/lib/esm/Tooltip/index.scss +269 -0
  313. package/publish/lib/esm/Tooltip/index.tsx +312 -0
  314. package/publish/lib/esm/Tree/TreeList.tsx +616 -0
  315. package/publish/lib/esm/Tree/index.scss +386 -0
  316. package/publish/lib/esm/Tree/index.tsx +396 -0
  317. package/publish/lib/esm/Tree/init-height.tsx +27 -0
  318. package/publish/lib/esm/Tree/utils/func.ts +15 -0
  319. package/publish/lib/esm/Utils/hooks/useAutosizeTextArea.tsx +125 -0
  320. package/publish/lib/esm/Utils/hooks/useBoundedDrag.tsx +301 -0
  321. package/publish/lib/esm/Utils/hooks/useClickOutside.tsx +69 -0
  322. package/publish/lib/esm/Utils/hooks/useComId.tsx +13 -0
  323. package/publish/lib/esm/Utils/hooks/useDebounce.tsx +40 -0
  324. package/publish/lib/esm/Utils/hooks/useDragDropPosition.tsx +420 -0
  325. package/publish/lib/esm/Utils/hooks/useDraggable.tsx +265 -0
  326. package/publish/lib/esm/Utils/hooks/useInterval.tsx +74 -0
  327. package/publish/lib/esm/Utils/hooks/useIsMobile.tsx +56 -0
  328. package/publish/lib/esm/Utils/hooks/useKeyPress.tsx +104 -0
  329. package/publish/lib/esm/Utils/hooks/useThrottle.tsx +39 -0
  330. package/publish/lib/esm/Utils/hooks/useWindowScroll.tsx +83 -0
  331. package/publish/lib/esm/Utils/libs/anim.ts +96 -0
  332. package/publish/lib/esm/Utils/libs/buffer.ts +262 -0
  333. package/publish/lib/esm/Utils/libs/cls.ts +64 -0
  334. package/publish/lib/esm/Utils/libs/convert.ts +59 -0
  335. package/publish/lib/esm/Utils/libs/date.ts +578 -0
  336. package/publish/lib/esm/Utils/libs/dom.ts +150 -0
  337. package/publish/lib/esm/Utils/libs/easing.ts +201 -0
  338. package/publish/lib/esm/Utils/libs/extract.ts +86 -0
  339. package/publish/lib/esm/Utils/libs/getElementProperty.ts +150 -0
  340. package/publish/lib/esm/Utils/libs/guid.ts +16 -0
  341. package/publish/lib/esm/Utils/libs/initDefaultOptions.ts +104 -0
  342. package/publish/lib/esm/Utils/libs/inputsCalculation.ts +160 -0
  343. package/publish/lib/esm/Utils/libs/math.ts +276 -0
  344. package/publish/lib/esm/Utils/libs/object.ts +68 -0
  345. package/publish/lib/esm/Utils/libs/os.ts +63 -0
  346. package/publish/lib/esm/Utils/libs/performance.ts +47 -0
  347. package/publish/lib/esm/Utils/libs/tree.ts +119 -0
  348. package/publish/lib/esm/Utils/libs/viewport.ts +20 -0
  349. package/publish/lib/esm/Utils/plugins/bodyScrollLock.ts +286 -0
  350. package/publish/lib/esm/index.js +43 -0
  351. package/publish/package.json +1 -0
  352. /package/{Accordion → publish/Accordion}/index.d.ts +0 -0
  353. /package/{Accordion → publish/Accordion}/index.js +0 -0
  354. /package/{BackToTop → publish/BackToTop}/index.css +0 -0
  355. /package/{BackToTop → publish/BackToTop}/index.d.ts +0 -0
  356. /package/{BackToTop → publish/BackToTop}/index.js +0 -0
  357. /package/{CascadingSelect → publish/CascadingSelect}/index.css +0 -0
  358. /package/{CascadingSelect → publish/CascadingSelect}/index.d.ts +0 -0
  359. /package/{CascadingSelect → publish/CascadingSelect}/index.js +0 -0
  360. /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.css +0 -0
  361. /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.d.ts +0 -0
  362. /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.js +0 -0
  363. /package/{Checkbox → publish/Checkbox}/index.d.ts +0 -0
  364. /package/{Checkbox → publish/Checkbox}/index.js +0 -0
  365. /package/{ColorPicker → publish/ColorPicker}/index.css +0 -0
  366. /package/{ColorPicker → publish/ColorPicker}/index.d.ts +0 -0
  367. /package/{ColorPicker → publish/ColorPicker}/index.js +0 -0
  368. /package/{Date → publish/Date}/index.css +0 -0
  369. /package/{Date → publish/Date}/index.d.ts +0 -0
  370. /package/{Date → publish/Date}/index.js +0 -0
  371. /package/{DigitalClock → publish/DigitalClock}/index.d.ts +0 -0
  372. /package/{DigitalClock → publish/DigitalClock}/index.js +0 -0
  373. /package/{DragDropList → publish/DragDropList}/index.css +0 -0
  374. /package/{DropdownMenu → publish/DropdownMenu}/index.css +0 -0
  375. /package/{DropdownMenu → publish/DropdownMenu}/index.d.ts +0 -0
  376. /package/{DropdownMenu → publish/DropdownMenu}/index.js +0 -0
  377. /package/{DynamicFields → publish/DynamicFields}/index.d.ts +0 -0
  378. /package/{DynamicFields → publish/DynamicFields}/index.js +0 -0
  379. /package/{EventCalendar → publish/EventCalendar}/index.css +0 -0
  380. /package/{EventCalendar → publish/EventCalendar}/index.d.ts +0 -0
  381. /package/{EventCalendar → publish/EventCalendar}/index.js +0 -0
  382. /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.css +0 -0
  383. /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.d.ts +0 -0
  384. /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.js +0 -0
  385. /package/{File → publish/File}/index.d.ts +0 -0
  386. /package/{File → publish/File}/index.js +0 -0
  387. /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.css +0 -0
  388. /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.d.ts +0 -0
  389. /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.js +0 -0
  390. /package/{Input → publish/Input}/index.d.ts +0 -0
  391. /package/{Input → publish/Input}/index.js +0 -0
  392. /package/{LiveSearch → publish/LiveSearch}/index.css +0 -0
  393. /package/{LiveSearch → publish/LiveSearch}/index.d.ts +0 -0
  394. /package/{LiveSearch → publish/LiveSearch}/index.js +0 -0
  395. /package/{MasonryLayout → publish/MasonryLayout}/index.d.ts +0 -0
  396. /package/{MasonryLayout → publish/MasonryLayout}/index.js +0 -0
  397. /package/{ModalDialog → publish/ModalDialog}/index.d.ts +0 -0
  398. /package/{ModalDialog → publish/ModalDialog}/index.js +0 -0
  399. /package/{ModeSwitch → publish/ModeSwitch}/index.d.ts +0 -0
  400. /package/{ModeSwitch → publish/ModeSwitch}/index.js +0 -0
  401. /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.css +0 -0
  402. /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.d.ts +0 -0
  403. /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.js +0 -0
  404. /package/{MultipleCheckboxes → publish/MultipleCheckboxes}/index.d.ts +0 -0
  405. /package/{MultipleCheckboxes → publish/MultipleCheckboxes}/index.js +0 -0
  406. /package/{MultipleSelect → publish/MultipleSelect}/index.css +0 -0
  407. /package/{NativeSelect → publish/NativeSelect}/index.d.ts +0 -0
  408. /package/{NativeSelect → publish/NativeSelect}/index.js +0 -0
  409. /package/{NumberInput → publish/NumberInput}/index.d.ts +0 -0
  410. /package/{NumberInput → publish/NumberInput}/index.js +0 -0
  411. /package/{Pagination → publish/Pagination}/index.d.ts +0 -0
  412. /package/{Pagination → publish/Pagination}/index.js +0 -0
  413. /package/{Radio → publish/Radio}/index.d.ts +0 -0
  414. /package/{Radio → publish/Radio}/index.js +0 -0
  415. /package/{RangeSlider → publish/RangeSlider}/index.css +0 -0
  416. /package/{RangeSlider → publish/RangeSlider}/index.d.ts +0 -0
  417. /package/{RangeSlider → publish/RangeSlider}/index.js +0 -0
  418. /package/{RootPortal → publish/RootPortal}/index.d.ts +0 -0
  419. /package/{RootPortal → publish/RootPortal}/index.js +0 -0
  420. /package/{ScrollReveal → publish/ScrollReveal}/index.d.ts +0 -0
  421. /package/{ScrollReveal → publish/ScrollReveal}/index.js +0 -0
  422. /package/{Scrollbar → publish/Scrollbar}/index.css +0 -0
  423. /package/{Scrollbar → publish/Scrollbar}/index.d.ts +0 -0
  424. /package/{Scrollbar → publish/Scrollbar}/index.js +0 -0
  425. /package/{SearchBar → publish/SearchBar}/index.d.ts +0 -0
  426. /package/{SearchBar → publish/SearchBar}/index.js +0 -0
  427. /package/{Select → publish/Select}/index.css +0 -0
  428. /package/{Select → publish/Select}/index.d.ts +0 -0
  429. /package/{Select → publish/Select}/index.js +0 -0
  430. /package/{ShowMoreLess → publish/ShowMoreLess}/index.css +0 -0
  431. /package/{ShowMoreLess → publish/ShowMoreLess}/index.d.ts +0 -0
  432. /package/{ShowMoreLess → publish/ShowMoreLess}/index.js +0 -0
  433. /package/{Switch → publish/Switch}/index.d.ts +0 -0
  434. /package/{Switch → publish/Switch}/index.js +0 -0
  435. /package/{Table → publish/Table}/index.css +0 -0
  436. /package/{Table → publish/Table}/index.d.ts +0 -0
  437. /package/{Table → publish/Table}/index.js +0 -0
  438. /package/{Tabs → publish/Tabs}/index.d.ts +0 -0
  439. /package/{Tabs → publish/Tabs}/index.js +0 -0
  440. /package/{TagInput → publish/TagInput}/index.css +0 -0
  441. /package/{TagInput → publish/TagInput}/index.d.ts +0 -0
  442. /package/{TagInput → publish/TagInput}/index.js +0 -0
  443. /package/{Toast → publish/Toast}/index.css +0 -0
  444. /package/{Toast → publish/Toast}/index.d.ts +0 -0
  445. /package/{Toast → publish/Toast}/index.js +0 -0
  446. /package/{Tooltip → publish/Tooltip}/index.css +0 -0
  447. /package/{Tooltip → publish/Tooltip}/index.d.ts +0 -0
  448. /package/{Tooltip → publish/Tooltip}/index.js +0 -0
  449. /package/{Tree → publish/Tree}/index.css +0 -0
  450. /package/{Utils → publish/Utils}/anim.d.ts +0 -0
  451. /package/{Utils → publish/Utils}/anim.js +0 -0
  452. /package/{Utils → publish/Utils}/bodyScrollLock.d.ts +0 -0
  453. /package/{Utils → publish/Utils}/bodyScrollLock.js +0 -0
  454. /package/{Utils → publish/Utils}/buffer.d.ts +0 -0
  455. /package/{Utils → publish/Utils}/buffer.js +0 -0
  456. /package/{Utils → publish/Utils}/cls.d.ts +0 -0
  457. /package/{Utils → publish/Utils}/cls.js +0 -0
  458. /package/{Utils → publish/Utils}/convert.d.ts +0 -0
  459. /package/{Utils → publish/Utils}/convert.js +0 -0
  460. /package/{Utils → publish/Utils}/date.d.ts +0 -0
  461. /package/{Utils → publish/Utils}/date.js +0 -0
  462. /package/{Utils → publish/Utils}/dom.d.ts +0 -0
  463. /package/{Utils → publish/Utils}/dom.js +0 -0
  464. /package/{Utils → publish/Utils}/easing.d.ts +0 -0
  465. /package/{Utils → publish/Utils}/easing.js +0 -0
  466. /package/{Utils → publish/Utils}/extract.d.ts +0 -0
  467. /package/{Utils → publish/Utils}/extract.js +0 -0
  468. /package/{Utils → publish/Utils}/getElementProperty.d.ts +0 -0
  469. /package/{Utils → publish/Utils}/getElementProperty.js +0 -0
  470. /package/{Utils → publish/Utils}/guid.d.ts +0 -0
  471. /package/{Utils → publish/Utils}/guid.js +0 -0
  472. /package/{Utils → publish/Utils}/initDefaultOptions.d.ts +0 -0
  473. /package/{Utils → publish/Utils}/initDefaultOptions.js +0 -0
  474. /package/{Utils → publish/Utils}/inputsCalculation.d.ts +0 -0
  475. /package/{Utils → publish/Utils}/inputsCalculation.js +0 -0
  476. /package/{Utils → publish/Utils}/math.d.ts +0 -0
  477. /package/{Utils → publish/Utils}/math.js +0 -0
  478. /package/{Utils → publish/Utils}/object.d.ts +0 -0
  479. /package/{Utils → publish/Utils}/object.js +0 -0
  480. /package/{Utils → publish/Utils}/os.d.ts +0 -0
  481. /package/{Utils → publish/Utils}/os.js +0 -0
  482. /package/{Utils → publish/Utils}/performance.d.ts +0 -0
  483. /package/{Utils → publish/Utils}/performance.js +0 -0
  484. /package/{Utils → publish/Utils}/tree.d.ts +0 -0
  485. /package/{Utils → publish/Utils}/tree.js +0 -0
  486. /package/{Utils → publish/Utils}/useClickOutside.d.ts +0 -0
  487. /package/{Utils → publish/Utils}/useClickOutside.js +0 -0
  488. /package/{Utils → publish/Utils}/useComId.d.ts +0 -0
  489. /package/{Utils → publish/Utils}/useComId.js +0 -0
  490. /package/{Utils → publish/Utils}/useDebounce.d.ts +0 -0
  491. /package/{Utils → publish/Utils}/useDebounce.js +0 -0
  492. /package/{Utils → publish/Utils}/useDragDropPosition.d.ts +0 -0
  493. /package/{Utils → publish/Utils}/useDragDropPosition.js +0 -0
  494. /package/{Utils → publish/Utils}/useDraggable.d.ts +0 -0
  495. /package/{Utils → publish/Utils}/useDraggable.js +0 -0
  496. /package/{Utils → publish/Utils}/useInterval.d.ts +0 -0
  497. /package/{Utils → publish/Utils}/useInterval.js +0 -0
  498. /package/{Utils → publish/Utils}/useKeyPress.d.ts +0 -0
  499. /package/{Utils → publish/Utils}/useKeyPress.js +0 -0
  500. /package/{Utils → publish/Utils}/useThrottle.d.ts +0 -0
  501. /package/{Utils → publish/Utils}/useThrottle.js +0 -0
  502. /package/{Utils → publish/Utils}/useWindowScroll.d.ts +0 -0
  503. /package/{Utils → publish/Utils}/useWindowScroll.js +0 -0
  504. /package/{Utils → publish/Utils}/viewport.d.ts +0 -0
  505. /package/{Utils → publish/Utils}/viewport.js +0 -0
  506. /package/{all.d.ts → publish/all.d.ts} +0 -0
@@ -0,0 +1,1683 @@
1
+ import React, { useState, useRef, useEffect, forwardRef, KeyboardEvent, ChangeEvent, FocusEvent, useImperativeHandle } from 'react';
2
+
3
+ import Input from 'funda-input';
4
+ import RootPortal from 'funda-root-portal';
5
+
6
+ import useComId from 'funda-utils/dist/cjs/useComId';
7
+ import {
8
+ padZero,
9
+ dateFormat,
10
+ isTimeString,
11
+ getNow,
12
+ isValidDate,
13
+ isValidHours,
14
+ isValidMinutesAndSeconds,
15
+ isValidYear,
16
+ isValidMonth,
17
+ isValidDay,
18
+ getCurrentYear,
19
+ getCurrentMonth,
20
+ getCurrentDay,
21
+ getLastDayInMonth
22
+ } from 'funda-utils/dist/cjs/date';
23
+ import useWindowScroll from 'funda-utils/dist/cjs/useWindowScroll';
24
+ import useClickOutside from 'funda-utils/dist/cjs/useClickOutside';
25
+ import {
26
+ getAbsolutePositionOfStage
27
+ } from 'funda-utils/dist/cjs/getElementProperty';
28
+ import { isNumeric } from 'funda-utils/dist/cjs/math';
29
+ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
30
+
31
+ import Calendar from './Calendar';
32
+
33
+
34
+
35
+ // Localization
36
+ import i18n__en_US from './localization/en_US';
37
+ import i18n__zh_CN from './localization/zh_CN';
38
+
39
+
40
+
41
+
42
+
43
+ export type DateProps = {
44
+ contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
45
+ popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
46
+ depth?: number;
47
+ popupClassName?: string;
48
+ triggerClassName?: string;
49
+ wrapperClassName?: string;
50
+ controlClassName?: string;
51
+ controlGroupWrapperClassName?: string;
52
+ controlGroupTextClassName?: string;
53
+ enableEntireAreaPopup?: boolean;
54
+ delimiter?: string;
55
+ hideClearButton?: boolean;
56
+ showToolsWhenHover?: boolean;
57
+ offset?: number;
58
+ exceededSidePosOffset?: number;
59
+ localization?: 'en_US' | 'zh_CN';
60
+ type?: 'date' | 'datetime-local' | 'time';
61
+ onlyTime?: boolean;
62
+ truncateSeconds?: boolean;
63
+ valueUseSlash?: boolean;
64
+ defaultValue?: string;
65
+ value?: string;
66
+ clickInitValue?: string;
67
+ min?: string;
68
+ max?: string;
69
+ placeholder?: string;
70
+ label?: React.ReactNode | string;
71
+ units?: string;
72
+ name?: string;
73
+ alt?: any;
74
+ disabled?: any;
75
+ requiredLabel?: React.ReactNode | string;
76
+ required?: any;
77
+ readOnly?: any;
78
+ iconLeft?: React.ReactNode | string;
79
+ iconRight?: React.ReactNode | string;
80
+
81
+ /** -- */
82
+ id?: string;
83
+ style?: React.CSSProperties;
84
+ autoComplete?: string;
85
+ tabIndex?: number;
86
+ [key: `data-${string}`]: string | undefined;
87
+ onLoad?: (e: any, data: any, allSplittingInputs: any[]) => void;
88
+ onChange?: (e: any, data: any, isValidDate: boolean, allSplittingInputs: any[]) => void;
89
+ onBlur?: (e: any, allSplittingInputs: any[]) => void;
90
+ onFocus?: (e: any, allSplittingInputs: any[]) => void;
91
+ onPressEnter?: (e: any, allSplittingInputs: any[]) => void;
92
+ onOpenPopup?: (allSplittingInputs: any[]) => void;
93
+ onClosePopup?: (allSplittingInputs: any[]) => void;
94
+ //
95
+ onChangeDate?: (currentData: any) => void;
96
+ onChangeMonth?: (currentData: any) => void;
97
+ onChangeYear?: (currentData: any) => void;
98
+ onChangeToday?: (currentData: any) => void;
99
+ onChangeHours?: (currentData: any) => void;
100
+ onChangeMinutes?: (currentData: any) => void;
101
+ onChangeSeconds?: (currentData: any) => void;
102
+ onClear?: (currentData: any) => void;
103
+
104
+
105
+
106
+ // calendar
107
+ langHoursTitle?: string;
108
+ langMinutesTitle?: string;
109
+ langSecondsTitle?: string;
110
+ langWeek?: string[];
111
+ langWeekFull?: string[];
112
+ langMonths?: string[];
113
+ langMonthsFull?: string[];
114
+ langToday?: string;
115
+ };
116
+
117
+
118
+ const Date = forwardRef((props: DateProps, externalRef: any) => {
119
+ const {
120
+ contentRef,
121
+ popupRef,
122
+ depth,
123
+ triggerClassName,
124
+ popupClassName,
125
+ wrapperClassName,
126
+ controlClassName,
127
+ controlGroupWrapperClassName,
128
+ controlGroupTextClassName,
129
+ enableEntireAreaPopup,
130
+ delimiter,
131
+ hideClearButton,
132
+ showToolsWhenHover,
133
+ offset,
134
+ exceededSidePosOffset,
135
+ localization,
136
+ type,
137
+ onlyTime,
138
+ truncateSeconds,
139
+ valueUseSlash,
140
+ disabled,
141
+ requiredLabel,
142
+ required,
143
+ readOnly,
144
+ defaultValue,
145
+ value,
146
+ clickInitValue,
147
+ min,
148
+ max,
149
+ placeholder,
150
+ label,
151
+ units,
152
+ name,
153
+ alt,
154
+ id,
155
+ iconLeft,
156
+ iconRight,
157
+ autoComplete,
158
+ style,
159
+ tabIndex,
160
+ onLoad,
161
+ onChange,
162
+ onBlur,
163
+ onFocus,
164
+ onPressEnter,
165
+ onOpenPopup,
166
+ onClosePopup,
167
+
168
+ //
169
+ onChangeDate,
170
+ onChangeMonth,
171
+ onChangeYear,
172
+ onChangeToday,
173
+ onChangeHours,
174
+ onChangeMinutes,
175
+ onChangeSeconds,
176
+ onClear,
177
+
178
+
179
+ //calendar
180
+ langHoursTitle,
181
+ langMinutesTitle,
182
+ langSecondsTitle,
183
+ langWeek,
184
+ langWeekFull,
185
+ langMonths,
186
+ langMonthsFull,
187
+ langToday,
188
+
189
+ //
190
+ ...attributes
191
+ } = props;
192
+
193
+
194
+ const DEPTH = depth || 1055; // the default value same as bootstrap
195
+ const defaultValueIsEmpty = (s: any) => {
196
+ return typeof s === 'undefined' || s === null || s === 'null' || s === '';
197
+ };
198
+
199
+
200
+
201
+
202
+ // Localization
203
+ let _langHoursTitle = langHoursTitle || 'Hours';
204
+ let _langMinutesTitle = langMinutesTitle || 'Minutes';
205
+ let _langSecondsTitle= langSecondsTitle || 'Seconds';
206
+ let _langWeek = langWeek;
207
+ let _langWeekFull = langWeekFull;
208
+ let _langMonths = langMonths;
209
+ let _langMonthsFull = langMonthsFull;
210
+ let _langToday = langToday;
211
+
212
+ //
213
+ const DELIMITER_DATE = delimiter || '/';
214
+ const DELIMITER_TIME = ':';
215
+ const SHOW_TOOLS_ENABLED = !(typeof showToolsWhenHover === 'undefined' || showToolsWhenHover === false);
216
+ const HIDE_CLEAR_BTN_ENABLED = !(typeof hideClearButton === 'undefined' || hideClearButton === false);
217
+
218
+ //
219
+ const COM_HAS_DATE = typeof onlyTime === 'undefined' || onlyTime === false;
220
+ const COM_HAS_TIME = type === 'datetime-local' || type === 'time';
221
+ const COM_NO_SECONDS = typeof truncateSeconds === 'undefined' || truncateSeconds === false;
222
+
223
+
224
+
225
+ // placeholder
226
+ let datePlaceholder = placeholder || placeholder === '' ? placeholder : 'yyyy/MM/dd HH:mm:ss';
227
+
228
+ if (typeof placeholder === 'undefined') {
229
+ datePlaceholder = `${COM_HAS_DATE ? 'yyyy/MM/dd ' : ''}${COM_HAS_TIME ? `HH:mm${COM_NO_SECONDS ? ':ss' : ''}` : ''}`;
230
+ }
231
+
232
+ if (typeof localization === 'string') {
233
+
234
+ switch (localization) {
235
+ case 'en_US':
236
+ _langHoursTitle = i18n__en_US.hoursTitle;
237
+ _langMinutesTitle = i18n__en_US.minutesTitle;
238
+ _langSecondsTitle = i18n__en_US.secondsTitle;
239
+ _langWeek = i18n__en_US.week;
240
+ _langWeekFull = i18n__en_US.weekFull;
241
+ _langMonths = i18n__en_US.months;
242
+ _langMonthsFull = i18n__en_US.monthsFull;
243
+ _langToday = i18n__en_US.today;
244
+ break;
245
+
246
+ case 'zh_CN':
247
+ _langHoursTitle = i18n__zh_CN.hoursTitle;
248
+ _langMinutesTitle = i18n__zh_CN.minutesTitle;
249
+ _langSecondsTitle = i18n__zh_CN.secondsTitle;
250
+ _langWeek = i18n__zh_CN.week;
251
+ _langWeekFull = i18n__zh_CN.weekFull;
252
+ _langMonths = i18n__zh_CN.months;
253
+ _langMonthsFull = i18n__zh_CN.monthsFull;
254
+ _langToday = i18n__zh_CN.today;
255
+ break;
256
+
257
+ }
258
+
259
+ }
260
+
261
+
262
+
263
+ //
264
+ const POS_OFFSET = Number(offset) || 10;
265
+ const EXCEEDED_SIDE_POS_OFFSET = Number(exceededSidePosOffset) || 15;
266
+ const uniqueID = useComId();
267
+ const idRes = id || uniqueID;
268
+ const rootRef = useRef<any>(null);
269
+ const modalRef = useRef<any>(null);
270
+ const inputRef = useRef<any>(null);
271
+ const listContentRef = useRef<any>(null);
272
+
273
+ const partedInputYear = useRef<HTMLInputElement | null>(null);
274
+ const partedInputMonth = useRef<HTMLInputElement | null>(null);
275
+ const partedInputDay = useRef<HTMLInputElement | null>(null);
276
+ const partedInputHours = useRef<HTMLInputElement | null>(null);
277
+ const partedInputMinutes = useRef<HTMLInputElement | null>(null);
278
+ const partedInputSeconds = useRef<HTMLInputElement | null>(null);
279
+
280
+ const [dateDefaultValueExist, setDateDefaultValueExist] = useState<boolean>(false);
281
+ const [initSplitClickEvOk, setInitSplitClickEvOk] = useState<boolean>(false);
282
+ const [splitVals, setSplitVals] = useState<any[]>(['0000','00','00','00','00','00']);
283
+ const [changedVal, setChangedVal] = useState<string>(value || '');
284
+ const [isShow, setIsShow] = useState<boolean>(false);
285
+ const [dateVal, setDateVal] = useState<string>('');
286
+ const [timeVal, setTimeVal] = useState<string[]>(['00', '00', '00']);
287
+
288
+ const hoursArr = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'];
289
+ const msArr = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'];
290
+
291
+ // blur for popup window
292
+ const popupBlurEnabled = useRef<boolean>(false); // DO NOT USE 'useState()'
293
+
294
+
295
+ // effective element movement on keystroke
296
+ const [focusableSplitInputId, setFocusableSplitInputId] = useState<string>(COM_HAS_DATE ? 'el-year' : 'el-hours');
297
+ const [splitInputsIds] = useState<string[]>(['el-year', 'el-month', 'el-day', 'el-hours', 'el-minutes', 'el-seconds']);
298
+ const splitInputs = useRef(new Map<string, HTMLElement>());
299
+ const splitInputsTabIndex = tabIndex || 0;
300
+
301
+
302
+
303
+ //
304
+ const getAllSplittingInputs = () => {
305
+ return [
306
+ partedInputYear.current,
307
+ partedInputMonth.current,
308
+ partedInputDay.current,
309
+ partedInputHours.current,
310
+ partedInputMinutes.current,
311
+ partedInputSeconds.current
312
+ ];
313
+ };
314
+
315
+ const onlyHHmm = (str: string) => {
316
+ // match HH:mm
317
+ const timePattern = /^([01]\d|2[0-3]):([0-5]\d)$/;
318
+ return timePattern.test(str);
319
+ };
320
+
321
+
322
+ // exposes the following methods
323
+ useImperativeHandle(
324
+ popupRef,
325
+ () => ({
326
+ close: () => {
327
+ popwinPosHide();
328
+ handleBlur(null);
329
+ }
330
+ }),
331
+ [popupRef],
332
+ );
333
+
334
+ useImperativeHandle(
335
+ contentRef,
336
+ () => ({
337
+ control: () => {
338
+ return getAllSplittingInputs();
339
+ },
340
+ clear: (cb?: any) => {
341
+ clearAll();
342
+ cb?.();
343
+ },
344
+ blur: (cb?: any) => {
345
+ getAllSplittingInputs().forEach((el: any) => {
346
+ if (el !== null) el.blur();
347
+ });
348
+
349
+ handleBlur(null);
350
+ cb?.();
351
+ },
352
+ /*
353
+ set('2024-04-18 21:54:09', () => { console.log('callback') }])
354
+ */
355
+ set: (value: any, cb?: any) => {
356
+
357
+ const [curInitSplitClickEvOk, curNoTargetVal, curTargetVal] = getActualDefaultValue(value, true);
358
+ setDateDefaultValueExist(defaultValueIsEmpty(value) ? false : true);
359
+ initValue(curTargetVal);
360
+
361
+ cb?.();
362
+ }
363
+ }),
364
+ [contentRef],
365
+ );
366
+
367
+
368
+ // click outside
369
+ useClickOutside({
370
+ enabled: isShow && rootRef.current,
371
+ isOutside: (event: any) => {
372
+ return event.target.closest(`.date2d__wrapper`) === null && event.target.closest(`.date2d-cal__wrapper`) === null;
373
+ },
374
+ handle: (event: any) => {
375
+ popwinPosHide();
376
+
377
+ //remove focus style
378
+ rootRef.current?.classList.remove('focus');
379
+
380
+ // move out the popup window
381
+ if (popupBlurEnabled.current) {
382
+ onBlur?.(inputRef.current, getAllSplittingInputs());
383
+ popupBlurEnabled.current = false;
384
+ }
385
+ }
386
+ }, [isShow, rootRef]);
387
+
388
+
389
+
390
+
391
+ // Add function to the element that should be used as the scrollable area.
392
+ // const [scrollData, windowScrollUpdate] = useWindowScroll({
393
+ // performance: ['debounce', 50], // "['debounce', 500]" or "['throttle', 500]"
394
+ // handle: (scrollData: any) => {
395
+ // popwinPosHide();
396
+ // }
397
+ // });
398
+
399
+
400
+
401
+ const getFullTimeData = (v: Date | String, padZeroEnabled: boolean = true) => {
402
+
403
+ if (typeof v === 'string' && !isValidDate(v)) {
404
+ return {
405
+ res: '0000-00-00 00:00:00',
406
+ resNoSeconds: '0000-00-00 00:00',
407
+ date: `0000-00-00`,
408
+ year: `0000`,
409
+ month: `00`,
410
+ day: `00`,
411
+ hours: `00`,
412
+ minutes: `00`,
413
+ seconds: `00`
414
+ }
415
+ }
416
+
417
+ const date: any = dateFormat(v as any);
418
+
419
+ const year = date.getFullYear();
420
+ const month = padZero(date.getMonth() + 1, padZeroEnabled);
421
+ const day = padZero(date.getDate(), padZeroEnabled);
422
+ const hours = padZero(date.getHours(), padZeroEnabled);
423
+ const minutes = padZero(date.getMinutes(), padZeroEnabled);
424
+ const seconds = padZero(date.getSeconds(), padZeroEnabled);
425
+ const res = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
426
+ const res2 = `${year}-${month}-${day} ${hours}:${minutes}`;
427
+
428
+ return {
429
+ res: res,
430
+ resNoSeconds: res2,
431
+ date: `${year}-${month}-${day}`,
432
+ year: `${year}`,
433
+ month: `${month}`,
434
+ day: `${day}`,
435
+ hours: `${hours}`,
436
+ minutes: `${minutes}`,
437
+ seconds: `${seconds}`
438
+ }
439
+ };
440
+
441
+
442
+ //
443
+ const MIN: any = typeof min !== 'undefined' && min !== '' && min !== null && isValidDate(min) ? getFullTimeData(min) : '';
444
+ const MAX: any = typeof max !== 'undefined' && max !== '' && max !== null && isValidDate(max) ? getFullTimeData(max) : '';
445
+
446
+ const getActualDefaultValue = (v?: any, init: boolean = false) => {
447
+ const _v = getFullTimeData(getNow());
448
+ const _nowVal: any = `${_v.date} ${_v.hours}:${_v.minutes}:${_v.seconds}`;
449
+
450
+ // expected default value (only HH:mm:ss)
451
+ const _expectedValue = isTimeString(v) || onlyHHmm(v) ? `${_v.date} ${onlyHHmm(v) ? v + ':00' : v}` : v;
452
+
453
+
454
+ if (!init) setInitSplitClickEvOk(true);
455
+
456
+
457
+ if (!initSplitClickEvOk) {
458
+
459
+
460
+ let noTargetVal = typeof clickInitValue === 'undefined' || clickInitValue === null || clickInitValue === 'null' || clickInitValue === '';
461
+ if (!defaultValueIsEmpty(v)) {
462
+ noTargetVal = true;
463
+ }
464
+
465
+ //
466
+ let targetVal: any = noTargetVal ? (defaultValueIsEmpty(v) ? _nowVal : _expectedValue) : clickInitValue;
467
+
468
+ if (typeof v === 'undefined') {
469
+ targetVal = noTargetVal ? _nowVal : clickInitValue;
470
+ }
471
+
472
+ //
473
+ return [false, noTargetVal, targetVal];
474
+ } else {
475
+
476
+
477
+ let targetVal: any = defaultValueIsEmpty(v) ? _nowVal : _expectedValue;
478
+
479
+ if (typeof v === 'undefined') {
480
+ targetVal = _nowVal;
481
+ }
482
+
483
+ return [true, true, targetVal];
484
+ }
485
+
486
+
487
+
488
+ };
489
+
490
+
491
+
492
+ function popwinPosInit() {
493
+
494
+ if (modalRef.current === null || listContentRef.current === null || inputRef.current === null) return;
495
+
496
+
497
+ // update modal position
498
+ const _modalRef: any = modalRef.current;
499
+ const _triggerRef: any = inputRef.current;
500
+
501
+ // console.log(getAbsolutePositionOfStage(_triggerRef));
502
+
503
+ if (_modalRef === null) return;
504
+
505
+ const { x, y, width, height } = getAbsolutePositionOfStage(_triggerRef);
506
+ const _triggerBox = _triggerRef.getBoundingClientRect();
507
+ let targetPos = '';
508
+
509
+
510
+ // STEP 1:
511
+ //-----------
512
+ // Detect position
513
+ if (window.innerHeight - _triggerBox.top > 100) {
514
+ targetPos = 'bottom';
515
+ } else {
516
+ targetPos = 'top';
517
+ }
518
+
519
+ // STEP 2:
520
+ //-----------
521
+ // Adjust position
522
+ if (targetPos === 'top') {
523
+ _modalRef.style.left = x + 'px';
524
+ //_modalRef.style.top = y - POS_OFFSET - (listContentRef.current.clientHeight) - 2 + 'px';
525
+ _modalRef.style.marginTop = 0;
526
+ _modalRef.style.top = 'auto';
527
+ _modalRef.style.bottom = (window.innerHeight - _triggerBox.top) + POS_OFFSET + 2 + 'px';
528
+ _modalRef.style.setProperty('position', 'fixed', 'important');
529
+ _modalRef.style.setProperty('position', 'fixed', 'important');
530
+ _modalRef.classList.add('pos-top');
531
+ }
532
+
533
+ if (targetPos === 'bottom') {
534
+ _modalRef.style.marginTop = 0;
535
+ _modalRef.style.left = x + 'px';
536
+ _modalRef.style.bottom = 'auto';
537
+ _modalRef.style.top = y + height + POS_OFFSET + 'px';
538
+ _modalRef.style.setProperty('position', 'absolute', 'important');
539
+ _modalRef.classList.remove('pos-top');
540
+ }
541
+
542
+ // STEP 3:
543
+ //-----------
544
+ // Determine whether it exceeds the far right or left side of the screen
545
+ // Determine whether it exceeds the max height of the popup
546
+ const _modalContent = _modalRef;
547
+ const _modalBox = _modalContent.getBoundingClientRect();
548
+ if (typeof _modalContent.dataset.offset === 'undefined' && _modalBox.left > 0) {
549
+
550
+ // 10 pixels is used to account for some bias in mobile devices
551
+ if ((_modalBox.right + 10) > window.innerWidth) {
552
+ const _modalOffsetPosition = _modalBox.right - window.innerWidth + EXCEEDED_SIDE_POS_OFFSET;
553
+ _modalContent.dataset.offset = _modalOffsetPosition;
554
+ _modalContent.style.marginLeft = `-${_modalOffsetPosition}px`;
555
+ // console.log('_modalPosition: ', _modalOffsetPosition)
556
+ }
557
+
558
+
559
+ if ((_modalBox.left - 10) < 0) {
560
+ const _modalOffsetPosition = Math.abs(_modalBox.left) + EXCEEDED_SIDE_POS_OFFSET;
561
+ _modalContent.dataset.offset = _modalOffsetPosition;
562
+ _modalContent.style.marginLeft = `${_modalOffsetPosition}px`;
563
+ // console.log('_modalPosition: ', _modalOffsetPosition)
564
+ }
565
+
566
+ if (window.innerHeight - _modalBox.bottom < 0) {
567
+ _modalRef.style.marginTop = `${window.innerHeight - _modalBox.bottom}px`;
568
+ }
569
+
570
+ }
571
+
572
+ }
573
+
574
+ function popwinPosHide() {
575
+ setIsShow(false);
576
+ onClosePopup?.(getAllSplittingInputs());
577
+
578
+ }
579
+
580
+
581
+
582
+ function handleShow() {
583
+ setIsShow(true);
584
+
585
+ setTimeout(() => {
586
+ popwinPosInit();
587
+
588
+ onOpenPopup?.(getAllSplittingInputs());
589
+
590
+ }, 0);
591
+
592
+ // focus
593
+ handleFocus(null);
594
+
595
+ }
596
+
597
+
598
+ function handleFocus(event: FocusEvent<HTMLElement> | null) {
599
+ rootRef.current?.classList.add('focus');
600
+
601
+
602
+ //
603
+ onFocus?.(inputRef.current, getAllSplittingInputs());
604
+
605
+ }
606
+
607
+ function handleChange(event: ChangeEvent<HTMLInputElement>) {
608
+ const val = event.target.value;
609
+
610
+ //
611
+ onChange?.(inputRef.current, val, isValidDate(val), getAllSplittingInputs());
612
+
613
+ }
614
+
615
+
616
+ function handleBlur(event: FocusEvent<HTMLElement> | null) {
617
+
618
+ //remove focus style
619
+ rootRef.current?.classList.remove('focus');
620
+
621
+ //
622
+ onBlur?.(inputRef.current, getAllSplittingInputs());
623
+ }
624
+
625
+
626
+ function handleInitSplitClickEv(e: any) {
627
+ e.preventDefault();
628
+ e.stopPropagation(); // Avoid triggering other inputs
629
+
630
+ e.target.select();
631
+
632
+ resetDefauleValueExist();
633
+
634
+
635
+ const _date = `${splitVals[0]}-${splitVals[1]}-${splitVals[2]}`;
636
+ const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${splitVals[5]}`;
637
+ onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
638
+
639
+ }
640
+
641
+ async function handleKeyPressed(event: KeyboardEvent<HTMLDivElement>) {
642
+ const key = event.code;
643
+
644
+ if (key === 'Enter' || key === 'NumpadEnter') {
645
+ event.preventDefault();
646
+
647
+ getAllSplittingInputs().forEach((el: any) => {
648
+ if (el !== null) el.blur();
649
+ });
650
+
651
+ handleBlur(null);
652
+
653
+ //
654
+ onPressEnter?.(inputRef.current, getAllSplittingInputs());
655
+ }
656
+ }
657
+
658
+ async function handleKeyPressedForSplitInputs(event: KeyboardEvent<HTMLDivElement>) {
659
+ const key = event.code;
660
+ const btnMark = (event.target as any).dataset.mark;
661
+ const move = (key: string) => {
662
+ const currentIndex = splitInputsIds.findIndex((s: string) => s === btnMark);
663
+ const nextIndex = key === 'ArrowLeft' ? currentIndex === splitInputsIds.length - 1 ? 0 : currentIndex - 1 : currentIndex === splitInputsIds.length - 1 ? 0 : currentIndex + 1;
664
+ const nextOption = splitInputsIds.at(nextIndex);
665
+ if (nextOption) {
666
+ setTimeout(() => {
667
+ (splitInputs.current.get(nextOption) as HTMLInputElement)?.select();
668
+ }, 0);
669
+ setFocusableSplitInputId(nextOption);
670
+ }
671
+ };
672
+
673
+ if (key === 'ArrowLeft') {
674
+ move('ArrowLeft');
675
+ }
676
+
677
+ if (key === 'ArrowRight') {
678
+ move('ArrowRight');
679
+ }
680
+ }
681
+
682
+
683
+ function clearAll() {
684
+ setDateDefaultValueExist(false);
685
+ onChange?.(inputRef.current, '', false, getAllSplittingInputs());
686
+ }
687
+
688
+
689
+
690
+ function resetDefauleValueExist() {
691
+ if (!dateDefaultValueExist) setDateDefaultValueExist(true);
692
+ }
693
+
694
+ function resetPopupBlurStatus() {
695
+ if (!popupBlurEnabled.current) popupBlurEnabled.current = true;
696
+ }
697
+
698
+
699
+ function valueResConverter(inputData: any) {
700
+ const v = isValidDate(inputData) ? inputData : `${getFullTimeData(getNow()).date} ${inputData}`;
701
+
702
+
703
+ const _onlyTime = `${getFullTimeData(v).hours}:${getFullTimeData(v).minutes}${truncateSeconds ? `` : `:${getFullTimeData(v).seconds}`}`;
704
+ const _date = `${getFullTimeData(v).year}${valueUseSlash ? `/` : '-'}${getFullTimeData(v).month}${valueUseSlash ? `/` : '-'}${getFullTimeData(v).day}`;
705
+ const _time = COM_HAS_TIME ? ` ${getFullTimeData(v).hours}:${getFullTimeData(v).minutes}${truncateSeconds ? `` : `:${getFullTimeData(v).seconds}`}` : '';
706
+
707
+ return onlyTime ? _onlyTime : `${_date}${_time}`;
708
+ }
709
+
710
+
711
+
712
+ function checkDisabledSeconds(curYear: number | string, curMonth: number, curDay: number | string, curHours: number | string, curMinutes: number | string, curSeconds: number | string) {
713
+ let res: boolean = false;
714
+
715
+ // maximum
716
+ if (MAX !== '') {
717
+ if (Number(curYear) > Number(MAX.year)) {
718
+ res = true;
719
+ }
720
+
721
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) > Number(MAX.month)) {
722
+ res = true;
723
+ }
724
+
725
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) > Number(MAX.day)) {
726
+ res = true;
727
+ }
728
+
729
+
730
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) > Number(MAX.hours) ) {
731
+ res = true;
732
+ }
733
+
734
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) === Number(MAX.hours) && Number(curMinutes) > Number(MAX.minutes) ) {
735
+ res = true;
736
+ }
737
+
738
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) === Number(MAX.hours) && Number(curMinutes) === Number(MAX.minutes) && Number(curSeconds) > Number(MAX.seconds) ) {
739
+ res = true;
740
+ }
741
+ }
742
+
743
+ // minimum
744
+ if (MIN !== '') {
745
+ if (Number(curYear) < Number(MIN.year)) {
746
+ res = true;
747
+ }
748
+
749
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) < Number(MIN.month)) {
750
+ res = true;
751
+ }
752
+
753
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) < Number(MIN.day)) {
754
+ res = true;
755
+ }
756
+
757
+
758
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) < Number(MIN.hours) ) {
759
+ res = true;
760
+ }
761
+
762
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) === Number(MIN.hours) && Number(curMinutes) < Number(MIN.minutes) ) {
763
+ res = true;
764
+ }
765
+
766
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) === Number(MIN.hours) && Number(curMinutes) === Number(MIN.minutes) && Number(curSeconds) < Number(MIN.seconds) ) {
767
+ res = true;
768
+ }
769
+ }
770
+
771
+
772
+ return res;
773
+ }
774
+
775
+
776
+ function checkDisabledMinutes(curYear: number | string, curMonth: number, curDay: number | string, curHours: number | string, curMinutes: number | string) {
777
+ let res: boolean = false;
778
+
779
+ // maximum
780
+ if (MAX !== '') {
781
+ if (Number(curYear) > Number(MAX.year)) {
782
+ res = true;
783
+ }
784
+
785
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) > Number(MAX.month)) {
786
+ res = true;
787
+ }
788
+
789
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) > Number(MAX.day)) {
790
+ res = true;
791
+ }
792
+
793
+
794
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) > Number(MAX.hours) ) {
795
+ res = true;
796
+ }
797
+
798
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) === Number(MAX.hours) && Number(curMinutes) > Number(MAX.minutes) ) {
799
+ res = true;
800
+ }
801
+ }
802
+
803
+ // minimum
804
+ if (MIN !== '') {
805
+ if (Number(curYear) < Number(MIN.year)) {
806
+ res = true;
807
+ }
808
+
809
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) < Number(MIN.month)) {
810
+ res = true;
811
+ }
812
+
813
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) < Number(MIN.day)) {
814
+ res = true;
815
+ }
816
+
817
+
818
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) < Number(MIN.hours) ) {
819
+ res = true;
820
+ }
821
+
822
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) === Number(MIN.hours) && Number(curMinutes) < Number(MIN.minutes) ) {
823
+ res = true;
824
+ }
825
+ }
826
+
827
+
828
+ return res;
829
+ }
830
+
831
+
832
+ function checkDisabledHours(curYear: number | string, curMonth: number, curDay: number | string, curHours: number | string) {
833
+ let res: boolean = false;
834
+
835
+ // maximum
836
+ if (MAX !== '') {
837
+ if (Number(curYear) > Number(MAX.year)) {
838
+ res = true;
839
+ }
840
+
841
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) > Number(MAX.month)) {
842
+ res = true;
843
+ }
844
+
845
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) > Number(MAX.day)) {
846
+ res = true;
847
+ }
848
+
849
+
850
+ if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) > Number(MAX.hours) ) {
851
+ res = true;
852
+ }
853
+ }
854
+
855
+ // minimum
856
+ if (MIN !== '') {
857
+ if (Number(curYear) < Number(MIN.year)) {
858
+ res = true;
859
+ }
860
+
861
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) < Number(MIN.month)) {
862
+ res = true;
863
+ }
864
+
865
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) < Number(MIN.day)) {
866
+ res = true;
867
+ }
868
+
869
+
870
+ if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) < Number(MIN.hours) ) {
871
+ res = true;
872
+ }
873
+ }
874
+
875
+ return res;
876
+ }
877
+
878
+ function initValue(v: any) {
879
+ const _res = valueResConverter(v);
880
+
881
+ setChangedVal(_res);
882
+
883
+ if (isValidDate(v)) {
884
+
885
+ const {
886
+ date,
887
+ year,
888
+ month,
889
+ day,
890
+ hours,
891
+ minutes,
892
+ seconds
893
+ } = getFullTimeData(v);
894
+
895
+
896
+ setDateVal(date);
897
+ setTimeVal([hours, minutes, seconds]);
898
+ setSplitVals([year, month, day, hours, minutes, seconds]);
899
+ }
900
+
901
+ return [_res, v]
902
+
903
+ }
904
+
905
+
906
+ useEffect(() => {
907
+
908
+
909
+ // update default value
910
+ //--------------
911
+ const [curInitSplitClickEvOk, curNoTargetVal, curTargetVal] = getActualDefaultValue(value, true);
912
+ setDateDefaultValueExist(defaultValueIsEmpty(value) ? false : true);
913
+ const [a, b] = initValue(curTargetVal);
914
+ onLoad?.(a, getFullTimeData(b), getAllSplittingInputs());
915
+
916
+
917
+ }, [value]);
918
+
919
+ useEffect(() => {
920
+
921
+ // update default value (It does not re-render the component because the incoming value changes.)
922
+ //--------------
923
+ if (typeof defaultValue !== 'undefined') { //REQUIRED
924
+ const [curInitSplitClickEvOk, curNoTargetVal, curTargetVal] = getActualDefaultValue(defaultValue, true);
925
+ setDateDefaultValueExist(defaultValueIsEmpty(defaultValue) ? false : true);
926
+ const [a, b] = initValue(curTargetVal);
927
+ onLoad?.(a, getFullTimeData(b), getAllSplittingInputs());
928
+ }
929
+
930
+ }, []);
931
+
932
+
933
+ return (
934
+ <>
935
+
936
+ {label ? <>{typeof label === 'string' ? <div className="date2d__label"><label htmlFor={idRes} className="form-label" dangerouslySetInnerHTML={{ __html: `${label}` }}></label></div> : <div className="date2d__label"><label htmlFor={idRes} className="form-label">{label}</label></div>}</> : null}
937
+
938
+
939
+ <div
940
+ ref={rootRef}
941
+ data-overlay-id={`date2d__wrapper-${idRes}`}
942
+ className={combinedCls(
943
+ 'date2d__trigger d-inline-block',
944
+ `is-${type}`,
945
+ triggerClassName,
946
+ {
947
+ 'date2d__trigger--hover-show-tools': SHOW_TOOLS_ENABLED
948
+ }
949
+ )}
950
+ onFocus={handleFocus}
951
+ onBlur={handleBlur}
952
+ onKeyDown={handleKeyPressed}
953
+ onClick={enableEntireAreaPopup ? handleShow : () => {}}
954
+
955
+ >
956
+
957
+
958
+ <div className="date2d__control">
959
+ <Input
960
+ ref={(node) => {
961
+ inputRef.current = node;
962
+ if (typeof externalRef === 'function') {
963
+ externalRef(node);
964
+ } else if (externalRef) {
965
+ externalRef.current = node;
966
+ }
967
+ }}
968
+ tabIndex={-1}
969
+ type="text"
970
+ inputMode="none"
971
+ data-date-info={JSON.stringify(getFullTimeData(changedVal))}
972
+ wrapperClassName={wrapperClassName}
973
+ controlClassName={controlClassName}
974
+ controlExClassName=""
975
+ controlGroupWrapperClassName={controlGroupWrapperClassName}
976
+ controlGroupTextClassName={controlGroupTextClassName}
977
+ id={idRes}
978
+ name={name}
979
+ alt={alt}
980
+ placeholder={datePlaceholder}
981
+ value={!dateDefaultValueExist ? `` : valueResConverter(changedVal)}
982
+ autoComplete="off"
983
+ onChange={handleChange}
984
+ label=""
985
+ units={units}
986
+ iconLeft={iconLeft}
987
+ iconRight={iconRight}
988
+ requiredLabel={requiredLabel}
989
+ required={required}
990
+ appendControl={<>
991
+ <div className="date2d__control__inputplaceholder">
992
+
993
+
994
+ {/*
995
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
996
+ +++++++++++++++++++ Split Inputs +++++++++++++++++++++++++++++
997
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
998
+ */}
999
+ {COM_HAS_DATE ? <>
1000
+ <input
1001
+ ref={(node) => {
1002
+ partedInputYear.current = node;
1003
+ if (node) {
1004
+ splitInputs.current.set(splitInputsIds[0], node);
1005
+ } else {
1006
+ splitInputs.current.delete(splitInputsIds[0]);
1007
+ }
1008
+ }}
1009
+ tabIndex={splitInputsTabIndex}
1010
+ data-mark={`${splitInputsIds[0]}`}
1011
+ onKeyDown={handleKeyPressedForSplitInputs}
1012
+ inputMode="numeric"
1013
+ className="date2d__control__inputplaceholder--year"
1014
+ value={!dateDefaultValueExist ? `` : splitVals[0]}
1015
+ maxLength={4}
1016
+ autoComplete="off"
1017
+ disabled={disabled || null}
1018
+ readOnly={readOnly || null}
1019
+ onClick={handleInitSplitClickEv}
1020
+ onChange={(e: any) => {
1021
+ let _val = e.target.value;
1022
+ if (_val !== '' && !isValidYear(_val) && isNumeric(_val) && Number(_val) > 9999) _val = '9999';
1023
+ if (_val !== '' && !isValidYear(_val) && !isNumeric(_val)) _val = `${getCurrentYear()}`;
1024
+
1025
+
1026
+ const _date = `${_val}-${splitVals[1]}-${splitVals[2]}`;
1027
+ const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${splitVals[5]}`;
1028
+
1029
+
1030
+
1031
+ onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
1032
+ setSplitVals((prevState: string[]) => {
1033
+ return [_val, prevState[1], prevState[2], prevState[3], prevState[4], prevState[5]];
1034
+ });
1035
+
1036
+ // update other data
1037
+ setDateVal(_date);
1038
+ setChangedVal(_full);
1039
+ setTimeVal([splitVals[3], splitVals[4], splitVals[5]]);
1040
+
1041
+
1042
+ }}
1043
+ {...attributes}
1044
+ />
1045
+ {dateDefaultValueExist ? DELIMITER_DATE : null}
1046
+ <input
1047
+ ref={(node) => {
1048
+ partedInputMonth.current = node;
1049
+ if (node) {
1050
+ splitInputs.current.set(splitInputsIds[1], node);
1051
+ } else {
1052
+ splitInputs.current.delete(splitInputsIds[1]);
1053
+ }
1054
+ }}
1055
+ tabIndex={splitInputsTabIndex}
1056
+ data-mark={`${splitInputsIds[1]}`}
1057
+ onKeyDown={handleKeyPressedForSplitInputs}
1058
+ inputMode="numeric"
1059
+ className="date2d__control__inputplaceholder--month"
1060
+ value={!dateDefaultValueExist ? `` : splitVals[1]}
1061
+ maxLength={2}
1062
+ autoComplete="off"
1063
+ disabled={disabled || null}
1064
+ readOnly={readOnly || null}
1065
+ onClick={handleInitSplitClickEv}
1066
+ onChange={(e: any) => {
1067
+ let _val = e.target.value;
1068
+ if (_val !== '' && !isValidMonth(_val) && isNumeric(_val)) {
1069
+ if (Number(_val) > 12) _val = '12';
1070
+ if (Number(_val) < 1 && Number(_val) > 0) _val = '01';
1071
+ }
1072
+ if (_val !== '' && !isValidMonth(_val) && !isNumeric(_val)) _val = `${getCurrentMonth()}`;
1073
+
1074
+
1075
+
1076
+ const _date = `${splitVals[0]}-${_val}-${splitVals[2]}`;
1077
+ const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${splitVals[5]}`;
1078
+
1079
+
1080
+
1081
+ onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
1082
+ setSplitVals((prevState: string[]) => {
1083
+ return [prevState[0], _val, prevState[2], prevState[3], prevState[4], prevState[5]];
1084
+ });
1085
+
1086
+ // update other data
1087
+ setDateVal(_date);
1088
+ setChangedVal(_full);
1089
+ setTimeVal([splitVals[3], splitVals[4], splitVals[5]]);
1090
+
1091
+ }}
1092
+ {...attributes}
1093
+ />
1094
+ {dateDefaultValueExist ? DELIMITER_DATE : null}
1095
+ <input
1096
+ ref={(node) => {
1097
+ partedInputDay.current = node;
1098
+ if (node) {
1099
+ splitInputs.current.set(splitInputsIds[2], node);
1100
+ } else {
1101
+ splitInputs.current.delete(splitInputsIds[2]);
1102
+ }
1103
+ }}
1104
+ tabIndex={splitInputsTabIndex}
1105
+ data-mark={`${splitInputsIds[2]}`}
1106
+ onKeyDown={handleKeyPressedForSplitInputs}
1107
+ inputMode="numeric"
1108
+ className="date2d__control__inputplaceholder--day"
1109
+ value={!dateDefaultValueExist ? `` : splitVals[2]}
1110
+ maxLength={2}
1111
+ autoComplete="off"
1112
+ disabled={disabled || null}
1113
+ readOnly={readOnly || null}
1114
+ onClick={handleInitSplitClickEv}
1115
+ onChange={(e: any) => {
1116
+ let _val = e.target.value;
1117
+
1118
+ const _day = `${splitVals[0]}-${splitVals[1]}-01`;
1119
+ const d = getLastDayInMonth(_day, new window.Date(_day).getMonth() + 1);
1120
+
1121
+ if (_val !== '' && isValidDay(_val) && isNumeric(_val)) {
1122
+ if (Number(_val) > Number(d)) _val = `${d}`;
1123
+ }
1124
+
1125
+ if (_val !== '' && !isValidDay(_val) && isNumeric(_val)) {
1126
+ if (Number(_val) > Number(d)) _val = `${d}`;
1127
+ if (Number(_val) < 1 && Number(_val) > 0) _val = '01';
1128
+ }
1129
+ if (_val !== '' && !isValidDay(_val) && !isNumeric(_val)) _val = `${getCurrentDay()}`;
1130
+
1131
+
1132
+ const _date = `${splitVals[0]}-${splitVals[1]}-${_val}`;
1133
+ const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${splitVals[5]}`;
1134
+
1135
+
1136
+
1137
+
1138
+ onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
1139
+ setSplitVals((prevState: string[]) => {
1140
+ return [prevState[0], prevState[1], _val, prevState[3], prevState[4], prevState[5]];
1141
+ });
1142
+
1143
+ // update other data
1144
+ setDateVal(_date);
1145
+ setChangedVal(_full);
1146
+ setTimeVal([splitVals[3], splitVals[4], splitVals[5]]);
1147
+
1148
+
1149
+ }}
1150
+ {...attributes}
1151
+ />
1152
+ &nbsp;
1153
+
1154
+ </> : null}
1155
+
1156
+ {COM_HAS_TIME ? <>
1157
+ {/* TIME CONTROL */}
1158
+ <input
1159
+ ref={(node) => {
1160
+ partedInputHours.current = node;
1161
+ if (node) {
1162
+ splitInputs.current.set(splitInputsIds[3], node);
1163
+ } else {
1164
+ splitInputs.current.delete(splitInputsIds[3]);
1165
+ }
1166
+ }}
1167
+ tabIndex={splitInputsTabIndex}
1168
+ data-mark={`${splitInputsIds[3]}`}
1169
+ onKeyDown={handleKeyPressedForSplitInputs}
1170
+ inputMode="numeric"
1171
+ className="date2d__control__inputplaceholder--hours"
1172
+ value={!dateDefaultValueExist ? `` : splitVals[3]}
1173
+ maxLength={2}
1174
+ autoComplete="off"
1175
+ disabled={disabled || null}
1176
+ readOnly={readOnly || null}
1177
+ onClick={handleInitSplitClickEv}
1178
+ onChange={(e: any) => {
1179
+ let _val = e.target.value;
1180
+ if (_val !== '' && !isValidHours(_val) && isNumeric(_val) && Number(_val) > 23) _val = '23';
1181
+ if (_val !== '' && !isValidHours(_val) && !isNumeric(_val)) _val = '00';
1182
+
1183
+
1184
+ const _date = `${splitVals[0]}-${splitVals[1]}-${splitVals[2]}`;
1185
+ const _full = `${_date} ${_val}:${splitVals[4]}:${splitVals[5]}`;
1186
+
1187
+
1188
+ onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
1189
+ setSplitVals((prevState: string[]) => {
1190
+ return [prevState[0], prevState[1], prevState[2], _val, prevState[4], prevState[5]];
1191
+ });
1192
+
1193
+ // update other data
1194
+ setDateVal(_date);
1195
+ setChangedVal(_full);
1196
+ setTimeVal([_val, splitVals[4], splitVals[5]]);
1197
+
1198
+
1199
+ }}
1200
+ {...attributes}
1201
+ />
1202
+ {/* TIME CONTROL */}
1203
+
1204
+ {/* TIME CONTROL */}
1205
+ {dateDefaultValueExist ? DELIMITER_TIME : null}
1206
+ <input
1207
+ ref={(node) => {
1208
+ partedInputMinutes.current = node;
1209
+ if (node) {
1210
+ splitInputs.current.set(splitInputsIds[4], node);
1211
+ } else {
1212
+ splitInputs.current.delete(splitInputsIds[4]);
1213
+ }
1214
+ }}
1215
+ tabIndex={splitInputsTabIndex}
1216
+ data-mark={`${splitInputsIds[4]}`}
1217
+ onKeyDown={handleKeyPressedForSplitInputs}
1218
+ inputMode="numeric"
1219
+ className="date2d__control__inputplaceholder--minutes"
1220
+ value={!dateDefaultValueExist ? `` : splitVals[4]}
1221
+ maxLength={2}
1222
+ autoComplete="off"
1223
+ disabled={disabled || null}
1224
+ readOnly={readOnly || null}
1225
+ onClick={handleInitSplitClickEv}
1226
+ onChange={(e: any) => {
1227
+ let _val = e.target.value;
1228
+ if (_val !== '' && !isValidMinutesAndSeconds(_val) && isNumeric(_val) && Number(_val) > 59) _val = '59';
1229
+ if (_val !== '' && !isValidMinutesAndSeconds(_val) && !isNumeric(_val)) _val = '00';
1230
+
1231
+
1232
+ const _date = `${splitVals[0]}-${splitVals[1]}-${splitVals[2]}`;
1233
+ const _full = `${_date} ${splitVals[3]}:${_val}:${splitVals[5]}`;
1234
+
1235
+
1236
+ onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
1237
+ setSplitVals((prevState: string[]) => {
1238
+ return [prevState[0], prevState[1], prevState[2], prevState[3], _val, prevState[5]];
1239
+ });
1240
+
1241
+ // update other data
1242
+ setDateVal(_date);
1243
+ setChangedVal(_full);
1244
+ setTimeVal([splitVals[3], _val, splitVals[5]]);
1245
+
1246
+
1247
+ }}
1248
+ {...attributes}
1249
+ />
1250
+ {/* TIME CONTROL */}
1251
+
1252
+
1253
+ {/* TIME CONTROL */}
1254
+ {(COM_NO_SECONDS) ? <>
1255
+ {dateDefaultValueExist ? DELIMITER_TIME : null}
1256
+ <input
1257
+ ref={(node) => {
1258
+ partedInputSeconds.current = node;
1259
+ if (node) {
1260
+ splitInputs.current.set(splitInputsIds[5], node);
1261
+ } else {
1262
+ splitInputs.current.delete(splitInputsIds[5]);
1263
+ }
1264
+ }}
1265
+ tabIndex={splitInputsTabIndex}
1266
+ data-mark={`${splitInputsIds[5]}`}
1267
+ onKeyDown={handleKeyPressedForSplitInputs}
1268
+ inputMode="numeric"
1269
+ className="date2d__control__inputplaceholder--seconds"
1270
+ value={!dateDefaultValueExist ? `` : splitVals[5]}
1271
+ maxLength={2}
1272
+ autoComplete="off"
1273
+ disabled={disabled || null}
1274
+ readOnly={readOnly || null}
1275
+ onClick={handleInitSplitClickEv}
1276
+ onChange={(e: any) => {
1277
+ let _val = e.target.value;
1278
+ if (_val !== '' && !isValidMinutesAndSeconds(_val) && isNumeric(_val) && Number(_val) > 59) _val = '59';
1279
+ if (_val !== '' && !isValidMinutesAndSeconds(_val) && !isNumeric(_val)) _val = '00';
1280
+
1281
+
1282
+ const _date = `${splitVals[0]}-${splitVals[1]}-${splitVals[2]}`;
1283
+ const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${_val}`;
1284
+
1285
+
1286
+ onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
1287
+ setSplitVals((prevState: string[]) => {
1288
+ return [prevState[0], prevState[1], prevState[2], prevState[3], prevState[4], _val];
1289
+ });
1290
+
1291
+
1292
+ // update other data
1293
+ setDateVal(_date);
1294
+ setChangedVal(_full);
1295
+ setTimeVal([splitVals[3], splitVals[4], _val]);
1296
+
1297
+ }}
1298
+ {...attributes}
1299
+ />
1300
+ </> : null}
1301
+ {/* TIME CONTROL */}
1302
+ </> : null}
1303
+
1304
+
1305
+ {/*
1306
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1307
+ +++++++++++++++++++ /Split Inputs +++++++++++++++++++++++++++++
1308
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1309
+ */}
1310
+
1311
+ </div>
1312
+ </>}
1313
+ style={style}
1314
+ {...attributes}
1315
+ />
1316
+
1317
+ {/* TOOLS */}
1318
+ <span className={combinedCls(
1319
+ 'date2d__control-tools',
1320
+ {
1321
+ 'date2d__control-tools--hover-show-tools': SHOW_TOOLS_ENABLED
1322
+ }
1323
+
1324
+ )}>
1325
+
1326
+ <a
1327
+ tabIndex={-1}
1328
+ href="#"
1329
+ className={combinedCls(
1330
+ 'date2d__control-tools__close',
1331
+ {
1332
+ 'd-none': HIDE_CLEAR_BTN_ENABLED || !dateDefaultValueExist
1333
+ }
1334
+ )} onClick={(e: React.MouseEvent) => {
1335
+ e.preventDefault();
1336
+ e.stopPropagation(); // Avoid triggering pop-ups
1337
+
1338
+ clearAll();
1339
+ onClear?.(getFullTimeData(''));
1340
+ }}
1341
+ ><svg width="12px" height="12px" viewBox="0 0 1024 1024"><path fill="#000" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z" /></svg></a>
1342
+
1343
+ <a
1344
+ tabIndex={-1}
1345
+ href="#"
1346
+ className="date2d__control-tools__trigger"
1347
+ onClick={(e: React.MouseEvent) => {
1348
+ e.preventDefault();
1349
+ e.stopPropagation(); // Avoid triggering pop-ups
1350
+
1351
+ handleShow();
1352
+ }}
1353
+ >
1354
+ <svg width="14px" height="14px" viewBox="0 0 24 24" fill="none">
1355
+ <path d="M3 9H21M9 15L11 17L15 13M7 3V5M17 3V5M6.2 21H17.8C18.9201 21 19.4802 21 19.908 20.782C20.2843 20.5903 20.5903 20.2843 20.782 19.908C21 19.4802 21 18.9201 21 17.8V8.2C21 7.07989 21 6.51984 20.782 6.09202C20.5903 5.71569 20.2843 5.40973 19.908 5.21799C19.4802 5 18.9201 5 17.8 5H6.2C5.0799 5 4.51984 5 4.09202 5.21799C3.71569 5.40973 3.40973 5.71569 3.21799 6.09202C3 6.51984 3 7.07989 3 8.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
1356
+ </svg>
1357
+ </a>
1358
+
1359
+ </span>
1360
+ {/* /TOOLS */}
1361
+
1362
+
1363
+ </div>
1364
+
1365
+
1366
+
1367
+ </div>
1368
+
1369
+
1370
+ <RootPortal show={isShow} containerClassName={combinedCls(
1371
+ 'Date',
1372
+ `Date--${type}`
1373
+ )}>
1374
+ <div
1375
+ ref={modalRef}
1376
+ id={`date2d__wrapper-${idRes}`}
1377
+ className={combinedCls(
1378
+ 'date2d__wrapper',
1379
+ `is-${type}`,
1380
+ popupClassName,
1381
+ 'active'
1382
+ )}
1383
+ style={{
1384
+ display: 'none',
1385
+ zIndex: DEPTH
1386
+ }}
1387
+ {...attributes}
1388
+ >
1389
+
1390
+
1391
+ <div
1392
+ ref={listContentRef}
1393
+ className="date2d__tools-container d-flex flex-row"
1394
+ >
1395
+ {/* CALENDAR */}
1396
+ {COM_HAS_DATE ? <>
1397
+ <div className="date2d__calendar">
1398
+ <Calendar
1399
+ min={min}
1400
+ max={max}
1401
+ customTodayDate={changedVal}
1402
+ langWeek={_langWeek}
1403
+ langWeekFull={_langWeekFull}
1404
+ langMonths={_langMonths}
1405
+ langMonthsFull={_langMonthsFull}
1406
+ langToday={_langToday}
1407
+ onChangeDate={(e: any, currentData: any) => {
1408
+ resetDefauleValueExist();
1409
+
1410
+ //
1411
+ const _v = getFullTimeData(`${currentData.date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1412
+ setDateVal(currentData.date);
1413
+ setChangedVal(`${currentData.date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1414
+ setSplitVals((prevState: string[]) => {
1415
+ return [_v.year, _v.month, _v.day, prevState[3], prevState[4], prevState[5]];
1416
+ });
1417
+ onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
1418
+
1419
+ //
1420
+ onChangeDate?.(_v);
1421
+
1422
+ //
1423
+ resetPopupBlurStatus();
1424
+
1425
+
1426
+ }}
1427
+ onChangeToday={(currentData: any) => {
1428
+ resetDefauleValueExist();
1429
+
1430
+ //
1431
+ const _date = `${currentData.year}-${currentData.month}-${currentData.day}`;
1432
+ const _v = getFullTimeData(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1433
+ setDateVal(`${_date}`);
1434
+ setChangedVal(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1435
+ setSplitVals((prevState: string[]) => {
1436
+ return [_v.year, _v.month, _v.day, prevState[3], prevState[4], prevState[5]];
1437
+ });
1438
+ onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
1439
+
1440
+ //
1441
+ onChangeToday?.(_v);
1442
+
1443
+ //
1444
+ resetPopupBlurStatus();
1445
+
1446
+ }}
1447
+ onChangeMonth={(currentData: any) => {
1448
+ resetDefauleValueExist();
1449
+
1450
+ //
1451
+ const _date = `${currentData.year}-${currentData.month}-${currentData.day}`;
1452
+ const _v = getFullTimeData(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1453
+ setDateVal(_date);
1454
+ setChangedVal(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1455
+ setSplitVals((prevState: string[]) => {
1456
+ return [_v.year, _v.month, _v.day, prevState[3], prevState[4], prevState[5]];
1457
+ });
1458
+ onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
1459
+
1460
+ //
1461
+ onChangeMonth?.(_v);
1462
+
1463
+ //
1464
+ resetPopupBlurStatus();
1465
+
1466
+ }}
1467
+ onChangeYear={(currentData: any) => {
1468
+ resetDefauleValueExist();
1469
+
1470
+ //
1471
+ const _date = `${currentData.year}-${currentData.month}-${currentData.day}`;
1472
+ const _v = getFullTimeData(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1473
+ setDateVal(_date);
1474
+ setChangedVal(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1475
+ setSplitVals((prevState: string[]) => {
1476
+ return [_v.year, _v.month, _v.day, prevState[3], prevState[4], prevState[5]];
1477
+ });
1478
+ onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
1479
+
1480
+ //
1481
+ onChangeYear?.(_v);
1482
+
1483
+ //
1484
+ resetPopupBlurStatus();
1485
+
1486
+
1487
+ }}
1488
+ />
1489
+ </div>
1490
+ </> : null}
1491
+
1492
+ {/* /CALENDAR */}
1493
+
1494
+
1495
+ {COM_HAS_TIME ? <>
1496
+
1497
+ {/* TIME CONTROL */}
1498
+ <div className="date2d__hourslist border-end">
1499
+ <h3>{_langHoursTitle}</h3>
1500
+
1501
+ <ul>
1502
+ {hoursArr.map((hour: string, i: number) => {
1503
+
1504
+ const _curVal = getFullTimeData(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1505
+
1506
+ return <li key={i}>
1507
+ <a
1508
+ data-value={hour}
1509
+ href="#"
1510
+ tabIndex={-1}
1511
+ onClick={(e: React.MouseEvent) => {
1512
+ e.preventDefault();
1513
+ resetDefauleValueExist();
1514
+
1515
+ //
1516
+ const _val = (e.currentTarget as any).dataset.value;
1517
+ const _v = getFullTimeData(`${dateVal} ${_val}:${timeVal[1]}:${timeVal[2]}`);
1518
+
1519
+
1520
+ setChangedVal(`${dateVal} ${_val}:${timeVal[1]}:${timeVal[2]}`);
1521
+ setTimeVal((prevState: string[]) => {
1522
+ return [_val, prevState[1], prevState[2]];
1523
+ });
1524
+ setSplitVals((prevState: string[]) => {
1525
+ return [prevState[0], prevState[1], prevState[2], _v.hours, prevState[4], prevState[5]];
1526
+ });
1527
+ onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
1528
+
1529
+ //
1530
+ onChangeHours?.(_v);
1531
+
1532
+
1533
+ //
1534
+ resetPopupBlurStatus();
1535
+
1536
+ }}
1537
+ className={combinedCls(
1538
+ {
1539
+ 'selected': timeVal[0] == hour,
1540
+ 'disabled': checkDisabledHours(_curVal.year, Number(_curVal.month)-1, _curVal.day, hour)
1541
+ }
1542
+ )}
1543
+ >
1544
+ {hour}
1545
+ </a>
1546
+ </li>
1547
+ })}
1548
+
1549
+ </ul>
1550
+ </div>
1551
+ {/* TIME CONTROL */}
1552
+
1553
+ {/* TIME CONTROL */}
1554
+ <div className="date2d__minuteslist border-end">
1555
+ <h3>{_langMinutesTitle}</h3>
1556
+
1557
+ <ul>
1558
+ {msArr.map((v: string, i: number) => {
1559
+ const _curVal = getFullTimeData(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1560
+
1561
+ return <li key={i}>
1562
+ <a
1563
+ data-value={v}
1564
+ href="#"
1565
+ tabIndex={-1}
1566
+ onClick={(e: React.MouseEvent) => {
1567
+ e.preventDefault();
1568
+ resetDefauleValueExist();
1569
+
1570
+ //
1571
+ const _val = (e.currentTarget as any).dataset.value;
1572
+ const _v = getFullTimeData(`${dateVal} ${timeVal[0]}:${_val}:${timeVal[2]}`);
1573
+
1574
+ setChangedVal(`${dateVal} ${timeVal[0]}:${_val}:${timeVal[2]}`);
1575
+ setTimeVal((prevState: string[]) => {
1576
+ return [prevState[0], _val, prevState[2]];
1577
+ });
1578
+ setSplitVals((prevState: string[]) => {
1579
+ return [prevState[0], prevState[1], prevState[2], prevState[3], _v.minutes, prevState[5]];
1580
+ });
1581
+ onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
1582
+
1583
+ //
1584
+ onChangeMinutes?.(_v);
1585
+
1586
+
1587
+ //
1588
+ resetPopupBlurStatus();
1589
+
1590
+
1591
+ }}
1592
+ className={combinedCls(
1593
+ {
1594
+ 'selected': timeVal[1] == v,
1595
+ 'disabled': checkDisabledMinutes(_curVal.year, Number(_curVal.month)-1, _curVal.day, _curVal.hours, v)
1596
+ }
1597
+ )}
1598
+ >
1599
+
1600
+ {v}
1601
+ </a>
1602
+ </li>
1603
+ })}
1604
+
1605
+ </ul>
1606
+ </div>
1607
+ {/* TIME CONTROL */}
1608
+
1609
+
1610
+ {/* TIME CONTROL */}
1611
+ {(COM_NO_SECONDS) ? <>
1612
+ <div className="date2d__secondslist border-end">
1613
+ <h3>{_langSecondsTitle}</h3>
1614
+
1615
+ <ul>
1616
+ {msArr.map((v: string, i: number) => {
1617
+ const _curVal = getFullTimeData(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
1618
+
1619
+ return <li key={i}>
1620
+ <a
1621
+ data-value={v}
1622
+ href="#"
1623
+ tabIndex={-1}
1624
+ onClick={(e: React.MouseEvent) => {
1625
+ e.preventDefault();
1626
+ resetDefauleValueExist();
1627
+
1628
+ //
1629
+ const _val = (e.currentTarget as any).dataset.value;
1630
+ const _v = getFullTimeData(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${_val}`);
1631
+ setChangedVal(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${_val}`);
1632
+ setTimeVal((prevState: string[]) => {
1633
+ return [prevState[0], prevState[1], _val];
1634
+ });
1635
+ setSplitVals((prevState: string[]) => {
1636
+ return [prevState[0], prevState[1], prevState[2], prevState[3], prevState[5], _v.seconds ];
1637
+ });
1638
+ onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
1639
+
1640
+ //
1641
+ onChangeSeconds?.(_v);
1642
+
1643
+
1644
+ //
1645
+ resetPopupBlurStatus();
1646
+
1647
+ }}
1648
+ className={combinedCls(
1649
+ {
1650
+ 'selected': timeVal[2] == v,
1651
+ 'disabled': checkDisabledSeconds(_curVal.year, Number(_curVal.month)-1, _curVal.day, _curVal.hours, _curVal.minutes, v)
1652
+ }
1653
+ )}
1654
+ >
1655
+
1656
+ {v}
1657
+ </a>
1658
+ </li>
1659
+ })}
1660
+
1661
+ </ul>
1662
+ </div>
1663
+ </> : null}
1664
+ {/* TIME CONTROL */}
1665
+ </> : null}
1666
+
1667
+
1668
+
1669
+ </div>
1670
+
1671
+ </div>
1672
+ </RootPortal>
1673
+
1674
+
1675
+
1676
+
1677
+
1678
+ </>
1679
+ )
1680
+ });
1681
+
1682
+
1683
+ export default Date;