primereact 10.0.0 → 10.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/README.md +1 -1
  2. package/accordion/accordion.esm.js +0 -1
  3. package/api/api.esm.js +0 -1
  4. package/autocomplete/autocomplete.esm.js +8 -7
  5. package/autocomplete/autocomplete.esm.min.js +1 -1
  6. package/avatar/avatar.esm.js +0 -1
  7. package/avatargroup/avatargroup.esm.js +0 -1
  8. package/badge/badge.esm.js +0 -1
  9. package/blockui/blockui.esm.js +3 -1
  10. package/blockui/blockui.esm.min.js +1 -1
  11. package/breadcrumb/breadcrumb.esm.js +0 -1
  12. package/button/button.esm.js +0 -1
  13. package/calendar/calendar.esm.js +2 -1
  14. package/calendar/calendar.esm.min.js +1 -1
  15. package/card/card.esm.js +0 -1
  16. package/carousel/carousel.esm.js +7 -8
  17. package/carousel/carousel.esm.min.js +1 -1
  18. package/cascadeselect/cascadeselect.esm.js +0 -1
  19. package/chart/chart.esm.js +0 -1
  20. package/checkbox/checkbox.esm.js +0 -1
  21. package/chip/chip.esm.js +0 -1
  22. package/chips/chips.esm.js +0 -1
  23. package/colorpicker/colorpicker.esm.js +0 -1
  24. package/column/column.esm.js +0 -1
  25. package/columngroup/columngroup.esm.js +0 -1
  26. package/componentbase/componentbase.cjs.js +12 -7
  27. package/componentbase/componentbase.cjs.min.js +1 -1
  28. package/componentbase/componentbase.esm.js +23 -13
  29. package/componentbase/componentbase.esm.min.js +1 -1
  30. package/componentbase/componentbase.js +12 -7
  31. package/componentbase/componentbase.min.js +1 -1
  32. package/confirmdialog/confirmdialog.esm.js +0 -1
  33. package/confirmpopup/confirmpopup.esm.js +0 -1
  34. package/contextmenu/contextmenu.esm.js +0 -1
  35. package/core/core.js +12 -7
  36. package/core/core.min.js +1 -1
  37. package/csstransition/csstransition.esm.js +0 -1
  38. package/datascroller/datascroller.esm.js +0 -1
  39. package/datatable/datatable.esm.js +0 -1
  40. package/dataview/dataview.esm.js +0 -1
  41. package/deferredcontent/deferredcontent.esm.js +0 -1
  42. package/dialog/dialog.esm.js +2 -1
  43. package/dialog/dialog.esm.min.js +1 -1
  44. package/divider/divider.esm.js +0 -1
  45. package/dock/dock.esm.js +0 -1
  46. package/dropdown/dropdown.esm.js +0 -1
  47. package/editor/editor.esm.js +0 -1
  48. package/fieldset/fieldset.esm.js +0 -1
  49. package/fileupload/fileupload.esm.js +0 -1
  50. package/galleria/galleria.esm.js +11 -7
  51. package/galleria/galleria.esm.min.js +1 -1
  52. package/hooks/hooks.esm.js +0 -6
  53. package/iconbase/iconbase.esm.js +0 -1
  54. package/icons/angledoubledown/index.esm.js +0 -1
  55. package/icons/angledoubleleft/index.esm.js +0 -1
  56. package/icons/angledoubleright/index.esm.js +0 -1
  57. package/icons/angledoubleup/index.esm.js +0 -1
  58. package/icons/angledown/index.esm.js +0 -1
  59. package/icons/angleleft/index.esm.js +0 -1
  60. package/icons/angleright/index.esm.js +0 -1
  61. package/icons/angleup/index.esm.js +0 -1
  62. package/icons/arrowdown/index.esm.js +0 -1
  63. package/icons/arrowup/index.esm.js +0 -1
  64. package/icons/ban/index.esm.js +0 -1
  65. package/icons/bars/index.esm.js +0 -1
  66. package/icons/calendar/index.esm.js +0 -1
  67. package/icons/check/index.esm.js +0 -1
  68. package/icons/chevrondown/index.esm.js +0 -1
  69. package/icons/chevronleft/index.esm.js +0 -1
  70. package/icons/chevronright/index.esm.js +0 -1
  71. package/icons/chevronup/index.esm.js +0 -1
  72. package/icons/download/index.esm.js +0 -1
  73. package/icons/exclamationtriangle/index.esm.js +0 -1
  74. package/icons/eye/index.esm.js +0 -1
  75. package/icons/eyeslash/index.esm.js +0 -1
  76. package/icons/filter/index.esm.js +0 -1
  77. package/icons/filterslash/index.esm.js +0 -1
  78. package/icons/infocircle/index.esm.js +0 -1
  79. package/icons/minus/index.esm.js +0 -1
  80. package/icons/pencil/index.esm.js +0 -1
  81. package/icons/plus/index.esm.js +0 -1
  82. package/icons/refresh/index.esm.js +0 -1
  83. package/icons/search/index.esm.js +0 -1
  84. package/icons/searchminus/index.esm.js +0 -1
  85. package/icons/searchplus/index.esm.js +0 -1
  86. package/icons/sortalt/index.esm.js +0 -1
  87. package/icons/sortamountdown/index.esm.js +0 -1
  88. package/icons/sortamountupalt/index.esm.js +0 -1
  89. package/icons/spinner/index.esm.js +0 -1
  90. package/icons/star/index.esm.js +0 -1
  91. package/icons/starfill/index.esm.js +0 -1
  92. package/icons/thlarge/index.esm.js +0 -1
  93. package/icons/times/index.esm.js +0 -1
  94. package/icons/timescircle/index.esm.js +0 -1
  95. package/icons/trash/index.esm.js +0 -1
  96. package/icons/undo/index.esm.js +0 -1
  97. package/icons/upload/index.esm.js +0 -1
  98. package/icons/windowmaximize/index.esm.js +0 -1
  99. package/icons/windowminimize/index.esm.js +0 -1
  100. package/image/image.esm.js +2 -1
  101. package/image/image.esm.min.js +1 -1
  102. package/inplace/inplace.esm.js +0 -1
  103. package/inputmask/inputmask.esm.js +0 -1
  104. package/inputnumber/inputnumber.esm.js +0 -1
  105. package/inputswitch/inputswitch.esm.js +0 -1
  106. package/inputtext/inputtext.esm.js +0 -1
  107. package/inputtextarea/inputtextarea.esm.js +0 -1
  108. package/keyfilter/keyfilter.esm.js +0 -1
  109. package/knob/knob.esm.js +0 -1
  110. package/listbox/listbox.esm.js +0 -1
  111. package/megamenu/megamenu.esm.js +0 -1
  112. package/mention/mention.esm.js +0 -1
  113. package/menu/menu.esm.js +0 -1
  114. package/menubar/menubar.esm.js +0 -1
  115. package/message/message.esm.js +0 -1
  116. package/messages/messages.esm.js +1 -2
  117. package/messages/messages.esm.min.js +1 -1
  118. package/multiselect/multiselect.esm.js +0 -1
  119. package/multistatecheckbox/multistatecheckbox.esm.js +0 -1
  120. package/orderlist/orderlist.esm.js +9 -5
  121. package/orderlist/orderlist.esm.min.js +1 -1
  122. package/organizationchart/organizationchart.esm.js +0 -1
  123. package/overlaypanel/overlaypanel.esm.js +0 -1
  124. package/overlayservice/overlayservice.esm.js +0 -1
  125. package/package.json +2 -2
  126. package/paginator/paginator.esm.js +0 -1
  127. package/panel/panel.esm.js +0 -1
  128. package/panelmenu/panelmenu.esm.js +0 -1
  129. package/passthrough/index.esm.js +0 -1
  130. package/passthrough/tailwind/index.cjs.js +2 -4
  131. package/passthrough/tailwind/index.cjs.min.js +1 -1
  132. package/passthrough/tailwind/index.esm.js +149 -148
  133. package/passthrough/tailwind/index.esm.min.js +1 -1
  134. package/passthrough/tailwind/index.js +2 -4
  135. package/passthrough/tailwind/index.min.js +1 -1
  136. package/password/password.esm.js +0 -1
  137. package/picklist/picklist.esm.js +0 -1
  138. package/portal/portal.esm.js +0 -1
  139. package/primereact.all.cjs.js +12 -7
  140. package/primereact.all.cjs.min.js +1 -1
  141. package/primereact.all.esm.js +70 -42
  142. package/primereact.all.esm.min.js +1 -1
  143. package/primereact.all.js +12 -7
  144. package/primereact.all.min.js +1 -1
  145. package/progressbar/progressbar.esm.js +0 -1
  146. package/progressspinner/progressspinner.esm.js +0 -1
  147. package/radiobutton/radiobutton.esm.js +0 -1
  148. package/rating/rating.esm.js +0 -1
  149. package/ripple/ripple.esm.js +0 -1
  150. package/row/row.esm.js +0 -1
  151. package/scrollpanel/scrollpanel.esm.js +0 -1
  152. package/scrolltop/scrolltop.esm.js +0 -1
  153. package/selectbutton/selectbutton.esm.js +0 -1
  154. package/sidebar/sidebar.esm.js +2 -1
  155. package/sidebar/sidebar.esm.min.js +1 -1
  156. package/skeleton/skeleton.esm.js +0 -1
  157. package/slidemenu/slidemenu.esm.js +0 -1
  158. package/slider/slider.esm.js +0 -1
  159. package/speeddial/speeddial.esm.js +0 -1
  160. package/splitbutton/splitbutton.esm.js +0 -1
  161. package/splitter/splitter.esm.js +0 -1
  162. package/steps/steps.esm.js +0 -1
  163. package/styleclass/styleclass.esm.js +0 -1
  164. package/tabmenu/tabmenu.esm.js +0 -1
  165. package/tabview/tabview.esm.js +0 -1
  166. package/tag/tag.esm.js +0 -1
  167. package/terminal/terminal.esm.js +0 -1
  168. package/terminalservice/terminalservice.esm.js +0 -1
  169. package/tieredmenu/tieredmenu.esm.js +0 -1
  170. package/timeline/timeline.esm.js +0 -1
  171. package/toast/toast.esm.js +0 -1
  172. package/togglebutton/togglebutton.esm.js +0 -1
  173. package/toolbar/toolbar.esm.js +0 -1
  174. package/tooltip/tooltip.esm.js +0 -1
  175. package/tree/tree.esm.js +0 -1
  176. package/treeselect/treeselect.esm.js +0 -1
  177. package/treetable/treetable.esm.js +0 -1
  178. package/tristatecheckbox/tristatecheckbox.esm.js +0 -1
  179. package/utils/utils.esm.js +0 -1
  180. package/virtualscroller/virtualscroller.esm.js +0 -1
  181. package/web-types.json +1 -1
  182. package/accordion/accordion.esm.min.mjs +0 -1
  183. package/accordion/accordion.esm.mjs +0 -420
  184. package/api/api.esm.min.mjs +0 -1
  185. package/api/api.esm.mjs +0 -943
  186. package/autocomplete/autocomplete.esm.min.mjs +0 -1
  187. package/autocomplete/autocomplete.esm.mjs +0 -1128
  188. package/avatar/avatar.esm.min.mjs +0 -1
  189. package/avatar/avatar.esm.mjs +0 -244
  190. package/avatargroup/avatargroup.esm.min.mjs +0 -1
  191. package/avatargroup/avatargroup.esm.mjs +0 -54
  192. package/badge/badge.esm.min.mjs +0 -1
  193. package/badge/badge.esm.mjs +0 -109
  194. package/blockui/blockui.esm.min.mjs +0 -1
  195. package/blockui/blockui.esm.mjs +0 -267
  196. package/breadcrumb/breadcrumb.esm.min.mjs +0 -1
  197. package/breadcrumb/breadcrumb.esm.mjs +0 -350
  198. package/button/button.esm.min.mjs +0 -1
  199. package/button/button.esm.mjs +0 -294
  200. package/calendar/calendar.esm.min.mjs +0 -1
  201. package/calendar/calendar.esm.mjs +0 -3474
  202. package/card/card.esm.min.mjs +0 -1
  203. package/card/card.esm.mjs +0 -97
  204. package/carousel/carousel.esm.min.mjs +0 -1
  205. package/carousel/carousel.esm.mjs +0 -800
  206. package/cascadeselect/cascadeselect.esm.min.mjs +0 -1
  207. package/cascadeselect/cascadeselect.esm.mjs +0 -818
  208. package/chart/chart.esm.min.mjs +0 -1
  209. package/chart/chart.esm.mjs +0 -154
  210. package/checkbox/checkbox.esm.min.mjs +0 -1
  211. package/checkbox/checkbox.esm.mjs +0 -356
  212. package/chip/chip.esm.min.mjs +0 -1
  213. package/chip/chip.esm.mjs +0 -247
  214. package/chips/chips.esm.min.mjs +0 -1
  215. package/chips/chips.esm.mjs +0 -500
  216. package/colorpicker/colorpicker.esm.min.mjs +0 -1
  217. package/colorpicker/colorpicker.esm.mjs +0 -787
  218. package/column/column.esm.min.mjs +0 -1
  219. package/column/column.esm.mjs +0 -7
  220. package/columngroup/columngroup.esm.min.mjs +0 -1
  221. package/columngroup/columngroup.esm.mjs +0 -5
  222. package/componentbase/componentbase.esm.min.mjs +0 -1
  223. package/componentbase/componentbase.esm.mjs +0 -328
  224. package/confirmdialog/confirmdialog.esm.min.mjs +0 -1
  225. package/confirmdialog/confirmdialog.esm.mjs +0 -375
  226. package/confirmpopup/confirmpopup.esm.min.mjs +0 -1
  227. package/confirmpopup/confirmpopup.esm.mjs +0 -609
  228. package/contextmenu/contextmenu.esm.min.mjs +0 -1
  229. package/contextmenu/contextmenu.esm.mjs +0 -663
  230. package/csstransition/csstransition.esm.min.mjs +0 -1
  231. package/csstransition/csstransition.esm.mjs +0 -137
  232. package/datascroller/datascroller.esm.min.mjs +0 -1
  233. package/datascroller/datascroller.esm.mjs +0 -319
  234. package/datatable/datatable.esm.min.mjs +0 -1
  235. package/datatable/datatable.esm.mjs +0 -6635
  236. package/dataview/dataview.esm.min.mjs +0 -1
  237. package/dataview/dataview.esm.mjs +0 -505
  238. package/deferredcontent/deferredcontent.esm.min.mjs +0 -1
  239. package/deferredcontent/deferredcontent.esm.mjs +0 -132
  240. package/dialog/dialog.esm.min.mjs +0 -1
  241. package/dialog/dialog.esm.mjs +0 -984
  242. package/divider/divider.esm.min.mjs +0 -1
  243. package/divider/divider.esm.mjs +0 -78
  244. package/dock/dock.esm.min.mjs +0 -1
  245. package/dock/dock.esm.mjs +0 -347
  246. package/dropdown/dropdown.esm.min.mjs +0 -1
  247. package/dropdown/dropdown.esm.mjs +0 -1379
  248. package/editor/editor.esm.min.mjs +0 -1
  249. package/editor/editor.esm.mjs +0 -337
  250. package/fieldset/fieldset.esm.min.mjs +0 -1
  251. package/fieldset/fieldset.esm.mjs +0 -269
  252. package/fileupload/fileupload.esm.min.mjs +0 -1
  253. package/fileupload/fileupload.esm.mjs +0 -1004
  254. package/galleria/galleria.esm.min.mjs +0 -1
  255. package/galleria/galleria.esm.mjs +0 -1094
  256. package/hooks/hooks.esm.min.mjs +0 -1
  257. package/hooks/hooks.esm.mjs +0 -1036
  258. package/iconbase/iconbase.esm.min.mjs +0 -1
  259. package/iconbase/iconbase.esm.mjs +0 -32
  260. package/icons/angledoubledown/index.esm.min.mjs +0 -1
  261. package/icons/angledoubledown/index.esm.mjs +0 -38
  262. package/icons/angledoubleleft/index.esm.min.mjs +0 -1
  263. package/icons/angledoubleleft/index.esm.mjs +0 -38
  264. package/icons/angledoubleright/index.esm.min.mjs +0 -1
  265. package/icons/angledoubleright/index.esm.mjs +0 -38
  266. package/icons/angledoubleup/index.esm.min.mjs +0 -1
  267. package/icons/angledoubleup/index.esm.mjs +0 -38
  268. package/icons/angledown/index.esm.min.mjs +0 -1
  269. package/icons/angledown/index.esm.mjs +0 -36
  270. package/icons/angleleft/index.esm.min.mjs +0 -1
  271. package/icons/angleleft/index.esm.mjs +0 -36
  272. package/icons/angleright/index.esm.min.mjs +0 -1
  273. package/icons/angleright/index.esm.mjs +0 -36
  274. package/icons/angleup/index.esm.min.mjs +0 -1
  275. package/icons/angleup/index.esm.mjs +0 -36
  276. package/icons/arrowdown/index.esm.min.mjs +0 -1
  277. package/icons/arrowdown/index.esm.mjs +0 -660
  278. package/icons/arrowup/index.esm.min.mjs +0 -1
  279. package/icons/arrowup/index.esm.mjs +0 -660
  280. package/icons/ban/index.esm.min.mjs +0 -1
  281. package/icons/ban/index.esm.mjs +0 -658
  282. package/icons/bars/index.esm.min.mjs +0 -1
  283. package/icons/bars/index.esm.mjs +0 -38
  284. package/icons/calendar/index.esm.min.mjs +0 -1
  285. package/icons/calendar/index.esm.mjs +0 -36
  286. package/icons/check/index.esm.min.mjs +0 -1
  287. package/icons/check/index.esm.mjs +0 -36
  288. package/icons/chevrondown/index.esm.min.mjs +0 -1
  289. package/icons/chevrondown/index.esm.mjs +0 -36
  290. package/icons/chevronleft/index.esm.min.mjs +0 -1
  291. package/icons/chevronleft/index.esm.mjs +0 -36
  292. package/icons/chevronright/index.esm.min.mjs +0 -1
  293. package/icons/chevronright/index.esm.mjs +0 -36
  294. package/icons/chevronup/index.esm.min.mjs +0 -1
  295. package/icons/chevronup/index.esm.mjs +0 -36
  296. package/icons/download/index.esm.min.mjs +0 -1
  297. package/icons/download/index.esm.mjs +0 -660
  298. package/icons/exclamationtriangle/index.esm.min.mjs +0 -1
  299. package/icons/exclamationtriangle/index.esm.mjs +0 -664
  300. package/icons/eye/index.esm.min.mjs +0 -1
  301. package/icons/eye/index.esm.mjs +0 -38
  302. package/icons/eyeslash/index.esm.min.mjs +0 -1
  303. package/icons/eyeslash/index.esm.mjs +0 -660
  304. package/icons/filter/index.esm.min.mjs +0 -1
  305. package/icons/filter/index.esm.mjs +0 -658
  306. package/icons/filterslash/index.esm.min.mjs +0 -1
  307. package/icons/filterslash/index.esm.mjs +0 -660
  308. package/icons/infocircle/index.esm.min.mjs +0 -1
  309. package/icons/infocircle/index.esm.mjs +0 -660
  310. package/icons/minus/index.esm.min.mjs +0 -1
  311. package/icons/minus/index.esm.mjs +0 -36
  312. package/icons/pencil/index.esm.min.mjs +0 -1
  313. package/icons/pencil/index.esm.mjs +0 -658
  314. package/icons/plus/index.esm.min.mjs +0 -1
  315. package/icons/plus/index.esm.mjs +0 -658
  316. package/icons/refresh/index.esm.min.mjs +0 -1
  317. package/icons/refresh/index.esm.mjs +0 -660
  318. package/icons/search/index.esm.min.mjs +0 -1
  319. package/icons/search/index.esm.mjs +0 -660
  320. package/icons/searchminus/index.esm.min.mjs +0 -1
  321. package/icons/searchminus/index.esm.mjs +0 -660
  322. package/icons/searchplus/index.esm.min.mjs +0 -1
  323. package/icons/searchplus/index.esm.mjs +0 -660
  324. package/icons/sortalt/index.esm.min.mjs +0 -1
  325. package/icons/sortalt/index.esm.mjs +0 -667
  326. package/icons/sortamountdown/index.esm.min.mjs +0 -1
  327. package/icons/sortamountdown/index.esm.mjs +0 -673
  328. package/icons/sortamountupalt/index.esm.min.mjs +0 -1
  329. package/icons/sortamountupalt/index.esm.mjs +0 -673
  330. package/icons/spinner/index.esm.min.mjs +0 -1
  331. package/icons/spinner/index.esm.mjs +0 -658
  332. package/icons/star/index.esm.min.mjs +0 -1
  333. package/icons/star/index.esm.mjs +0 -658
  334. package/icons/starfill/index.esm.min.mjs +0 -1
  335. package/icons/starfill/index.esm.mjs +0 -658
  336. package/icons/thlarge/index.esm.min.mjs +0 -1
  337. package/icons/thlarge/index.esm.mjs +0 -660
  338. package/icons/times/index.esm.min.mjs +0 -1
  339. package/icons/times/index.esm.mjs +0 -36
  340. package/icons/timescircle/index.esm.min.mjs +0 -1
  341. package/icons/timescircle/index.esm.mjs +0 -660
  342. package/icons/trash/index.esm.min.mjs +0 -1
  343. package/icons/trash/index.esm.mjs +0 -660
  344. package/icons/undo/index.esm.min.mjs +0 -1
  345. package/icons/undo/index.esm.mjs +0 -660
  346. package/icons/upload/index.esm.min.mjs +0 -1
  347. package/icons/upload/index.esm.mjs +0 -660
  348. package/icons/windowmaximize/index.esm.min.mjs +0 -1
  349. package/icons/windowmaximize/index.esm.mjs +0 -660
  350. package/icons/windowminimize/index.esm.min.mjs +0 -1
  351. package/icons/windowminimize/index.esm.mjs +0 -660
  352. package/image/image.esm.min.mjs +0 -1
  353. package/image/image.esm.mjs +0 -1163
  354. package/inplace/inplace.esm.min.mjs +0 -1
  355. package/inplace/inplace.esm.mjs +0 -242
  356. package/inputmask/inputmask.esm.min.mjs +0 -1
  357. package/inputmask/inputmask.esm.mjs +0 -559
  358. package/inputnumber/inputnumber.esm.min.mjs +0 -1
  359. package/inputnumber/inputnumber.esm.mjs +0 -1208
  360. package/inputswitch/inputswitch.esm.min.mjs +0 -1
  361. package/inputswitch/inputswitch.esm.mjs +0 -290
  362. package/inputtext/inputtext.esm.min.mjs +0 -1
  363. package/inputtext/inputtext.esm.mjs +0 -170
  364. package/inputtextarea/inputtextarea.esm.min.mjs +0 -1
  365. package/inputtextarea/inputtextarea.esm.mjs +0 -219
  366. package/keyfilter/keyfilter.esm.min.mjs +0 -1
  367. package/keyfilter/keyfilter.esm.mjs +0 -107
  368. package/knob/knob.esm.min.mjs +0 -1
  369. package/knob/knob.esm.mjs +0 -317
  370. package/listbox/listbox.esm.min.mjs +0 -1
  371. package/listbox/listbox.esm.mjs +0 -809
  372. package/megamenu/megamenu.esm.min.mjs +0 -1
  373. package/megamenu/megamenu.esm.mjs +0 -715
  374. package/mention/mention.esm.min.mjs +0 -1
  375. package/mention/mention.esm.mjs +0 -770
  376. package/menu/menu.esm.min.mjs +0 -1
  377. package/menu/menu.esm.mjs +0 -484
  378. package/menubar/menubar.esm.min.mjs +0 -1
  379. package/menubar/menubar.esm.mjs +0 -583
  380. package/message/message.esm.min.mjs +0 -1
  381. package/message/message.esm.mjs +0 -168
  382. package/messages/messages.esm.min.mjs +0 -1
  383. package/messages/messages.esm.mjs +0 -438
  384. package/multiselect/multiselect.esm.min.mjs +0 -1
  385. package/multiselect/multiselect.esm.mjs +0 -1723
  386. package/multistatecheckbox/multistatecheckbox.esm.min.mjs +0 -1
  387. package/multistatecheckbox/multistatecheckbox.esm.mjs +0 -351
  388. package/orderlist/orderlist.esm.min.mjs +0 -1
  389. package/orderlist/orderlist.esm.mjs +0 -820
  390. package/organizationchart/organizationchart.esm.min.mjs +0 -1
  391. package/organizationchart/organizationchart.esm.mjs +0 -479
  392. package/overlaypanel/overlaypanel.esm.min.mjs +0 -1
  393. package/overlaypanel/overlaypanel.esm.mjs +0 -515
  394. package/overlayservice/overlayservice.esm.min.mjs +0 -1
  395. package/overlayservice/overlayservice.esm.mjs +0 -6
  396. package/paginator/paginator.esm.min.mjs +0 -1
  397. package/paginator/paginator.esm.mjs +0 -932
  398. package/panel/panel.esm.min.mjs +0 -1
  399. package/panel/panel.esm.mjs +0 -315
  400. package/panelmenu/panelmenu.esm.min.mjs +0 -1
  401. package/panelmenu/panelmenu.esm.mjs +0 -644
  402. package/passthrough/index.esm.min.mjs +0 -1
  403. package/passthrough/index.esm.mjs +0 -70
  404. package/passthrough/tailwind/index.esm.min.mjs +0 -1
  405. package/passthrough/tailwind/index.esm.mjs +0 -3513
  406. package/password/password.esm.min.mjs +0 -1
  407. package/password/password.esm.mjs +0 -566
  408. package/picklist/picklist.esm.min.mjs +0 -1
  409. package/picklist/picklist.esm.mjs +0 -1118
  410. package/portal/portal.esm.min.mjs +0 -1
  411. package/portal/portal.esm.mjs +0 -109
  412. package/primereact.all.esm.min.mjs +0 -1
  413. package/primereact.all.esm.mjs +0 -51669
  414. package/progressbar/progressbar.esm.min.mjs +0 -1
  415. package/progressbar/progressbar.esm.mjs +0 -189
  416. package/progressspinner/progressspinner.esm.min.mjs +0 -1
  417. package/progressspinner/progressspinner.esm.mjs +0 -87
  418. package/radiobutton/radiobutton.esm.min.mjs +0 -1
  419. package/radiobutton/radiobutton.esm.mjs +0 -328
  420. package/rating/rating.esm.min.mjs +0 -1
  421. package/rating/rating.esm.mjs +0 -272
  422. package/ripple/ripple.esm.min.mjs +0 -1
  423. package/ripple/ripple.esm.mjs +0 -99
  424. package/row/row.esm.min.mjs +0 -1
  425. package/row/row.esm.mjs +0 -35
  426. package/scrollpanel/scrollpanel.esm.min.mjs +0 -1
  427. package/scrollpanel/scrollpanel.esm.mjs +0 -209
  428. package/scrolltop/scrolltop.esm.min.mjs +0 -1
  429. package/scrolltop/scrolltop.esm.mjs +0 -268
  430. package/selectbutton/selectbutton.esm.min.mjs +0 -1
  431. package/selectbutton/selectbutton.esm.mjs +0 -326
  432. package/sidebar/sidebar.esm.min.mjs +0 -1
  433. package/sidebar/sidebar.esm.mjs +0 -544
  434. package/skeleton/skeleton.esm.min.mjs +0 -1
  435. package/skeleton/skeleton.esm.mjs +0 -124
  436. package/slidemenu/slidemenu.esm.min.mjs +0 -1
  437. package/slidemenu/slidemenu.esm.mjs +0 -688
  438. package/slider/slider.esm.min.mjs +0 -1
  439. package/slider/slider.esm.mjs +0 -477
  440. package/speeddial/speeddial.esm.min.mjs +0 -1
  441. package/speeddial/speeddial.esm.mjs +0 -520
  442. package/splitbutton/splitbutton.esm.min.mjs +0 -1
  443. package/splitbutton/splitbutton.esm.mjs +0 -544
  444. package/splitter/splitter.esm.min.mjs +0 -1
  445. package/splitter/splitter.esm.mjs +0 -465
  446. package/steps/steps.esm.min.mjs +0 -1
  447. package/steps/steps.esm.mjs +0 -293
  448. package/styleclass/styleclass.esm.min.mjs +0 -1
  449. package/styleclass/styleclass.esm.mjs +0 -268
  450. package/tabmenu/tabmenu.esm.min.mjs +0 -1
  451. package/tabmenu/tabmenu.esm.mjs +0 -331
  452. package/tabview/tabview.esm.min.mjs +0 -1
  453. package/tabview/tabview.esm.mjs +0 -677
  454. package/tag/tag.esm.min.mjs +0 -1
  455. package/tag/tag.esm.mjs +0 -116
  456. package/terminal/terminal.esm.min.mjs +0 -1
  457. package/terminal/terminal.esm.mjs +0 -279
  458. package/terminalservice/terminalservice.esm.min.mjs +0 -1
  459. package/terminalservice/terminalservice.esm.mjs +0 -6
  460. package/tieredmenu/tieredmenu.esm.min.mjs +0 -1
  461. package/tieredmenu/tieredmenu.esm.mjs +0 -698
  462. package/timeline/timeline.esm.min.mjs +0 -1
  463. package/timeline/timeline.esm.mjs +0 -163
  464. package/toast/toast.esm.min.mjs +0 -1
  465. package/toast/toast.esm.mjs +0 -738
  466. package/togglebutton/togglebutton.esm.min.mjs +0 -1
  467. package/togglebutton/togglebutton.esm.mjs +0 -216
  468. package/toolbar/toolbar.esm.min.mjs +0 -1
  469. package/toolbar/toolbar.esm.mjs +0 -78
  470. package/tooltip/tooltip.esm.min.mjs +0 -1
  471. package/tooltip/tooltip.esm.mjs +0 -695
  472. package/tree/tree.esm.min.mjs +0 -1
  473. package/tree/tree.esm.mjs +0 -1402
  474. package/treeselect/treeselect.esm.min.mjs +0 -1
  475. package/treeselect/treeselect.esm.mjs +0 -929
  476. package/treetable/treetable.esm.min.mjs +0 -1
  477. package/treetable/treetable.esm.mjs +0 -3093
  478. package/tristatecheckbox/tristatecheckbox.esm.min.mjs +0 -1
  479. package/tristatecheckbox/tristatecheckbox.esm.mjs +0 -291
  480. package/utils/utils.esm.min.mjs +0 -1
  481. package/utils/utils.esm.mjs +0 -2382
  482. package/virtualscroller/virtualscroller.esm.min.mjs +0 -1
  483. package/virtualscroller/virtualscroller.esm.mjs +0 -971
@@ -1,3474 +0,0 @@
1
- 'use client';
2
- import * as React from 'react';
3
- import PrimeReact, { PrimeReactContext, localeOptions, localeOption } from 'primereact/api';
4
- import { Button } from 'primereact/button';
5
- import { ComponentBase, useHandleStyle } from 'primereact/componentbase';
6
- import { usePrevious, useOverlayListener, useMountEffect, useUpdateEffect, useUnmountEffect } from 'primereact/hooks';
7
- import { CalendarIcon } from 'primereact/icons/calendar';
8
- import { ChevronDownIcon } from 'primereact/icons/chevrondown';
9
- import { ChevronLeftIcon } from 'primereact/icons/chevronleft';
10
- import { ChevronRightIcon } from 'primereact/icons/chevronright';
11
- import { ChevronUpIcon } from 'primereact/icons/chevronup';
12
- import { InputText } from 'primereact/inputtext';
13
- import { OverlayService } from 'primereact/overlayservice';
14
- import { Ripple } from 'primereact/ripple';
15
- import { classNames, mergeProps, UniqueComponentId, DomHandler, ObjectUtils, mask, ZIndexUtils, IconUtils } from 'primereact/utils';
16
- import { CSSTransition } from 'primereact/csstransition';
17
- import { Portal } from 'primereact/portal';
18
-
19
- function _extends() {
20
- _extends = Object.assign ? Object.assign.bind() : function (target) {
21
- for (var i = 1; i < arguments.length; i++) {
22
- var source = arguments[i];
23
- for (var key in source) {
24
- if (Object.prototype.hasOwnProperty.call(source, key)) {
25
- target[key] = source[key];
26
- }
27
- }
28
- }
29
- return target;
30
- };
31
- return _extends.apply(this, arguments);
32
- }
33
-
34
- function _typeof(o) {
35
- "@babel/helpers - typeof";
36
-
37
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
38
- return typeof o;
39
- } : function (o) {
40
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
41
- }, _typeof(o);
42
- }
43
-
44
- function _toPrimitive(input, hint) {
45
- if (_typeof(input) !== "object" || input === null) return input;
46
- var prim = input[Symbol.toPrimitive];
47
- if (prim !== undefined) {
48
- var res = prim.call(input, hint || "default");
49
- if (_typeof(res) !== "object") return res;
50
- throw new TypeError("@@toPrimitive must return a primitive value.");
51
- }
52
- return (hint === "string" ? String : Number)(input);
53
- }
54
-
55
- function _toPropertyKey(arg) {
56
- var key = _toPrimitive(arg, "string");
57
- return _typeof(key) === "symbol" ? key : String(key);
58
- }
59
-
60
- function _defineProperty(obj, key, value) {
61
- key = _toPropertyKey(key);
62
- if (key in obj) {
63
- Object.defineProperty(obj, key, {
64
- value: value,
65
- enumerable: true,
66
- configurable: true,
67
- writable: true
68
- });
69
- } else {
70
- obj[key] = value;
71
- }
72
- return obj;
73
- }
74
-
75
- function _arrayLikeToArray$1(arr, len) {
76
- if (len == null || len > arr.length) len = arr.length;
77
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
78
- return arr2;
79
- }
80
-
81
- function _arrayWithoutHoles(arr) {
82
- if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
83
- }
84
-
85
- function _iterableToArray(iter) {
86
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
87
- }
88
-
89
- function _unsupportedIterableToArray$1(o, minLen) {
90
- if (!o) return;
91
- if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
92
- var n = Object.prototype.toString.call(o).slice(8, -1);
93
- if (n === "Object" && o.constructor) n = o.constructor.name;
94
- if (n === "Map" || n === "Set") return Array.from(o);
95
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
96
- }
97
-
98
- function _nonIterableSpread() {
99
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
100
- }
101
-
102
- function _toConsumableArray(arr) {
103
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread();
104
- }
105
-
106
- function _arrayWithHoles(arr) {
107
- if (Array.isArray(arr)) return arr;
108
- }
109
-
110
- function _iterableToArrayLimit(r, l) {
111
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
112
- if (null != t) {
113
- var e,
114
- n,
115
- i,
116
- u,
117
- a = [],
118
- f = !0,
119
- o = !1;
120
- try {
121
- if (i = (t = t.call(r)).next, 0 === l) {
122
- if (Object(t) !== t) return;
123
- f = !1;
124
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
125
- } catch (r) {
126
- o = !0, n = r;
127
- } finally {
128
- try {
129
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
130
- } finally {
131
- if (o) throw n;
132
- }
133
- }
134
- return a;
135
- }
136
- }
137
-
138
- function _nonIterableRest() {
139
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
140
- }
141
-
142
- function _slicedToArray(arr, i) {
143
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();
144
- }
145
-
146
- var styles = "\n@layer primereact {\n .p-calendar {\n position: relative;\n display: inline-flex;\n max-width: 100%;\n }\n \n .p-calendar .p-inputtext {\n flex: 1 1 auto;\n width: 1%;\n }\n \n .p-calendar-w-btn-right .p-inputtext {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n \n .p-calendar-w-btn-right .p-datepicker-trigger {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n \n .p-calendar-w-btn-left .p-inputtext {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n \n .p-calendar-w-btn-left .p-datepicker-trigger {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n \n /* Fluid */\n .p-fluid .p-calendar {\n display: flex;\n }\n \n .p-fluid .p-calendar .p-inputtext {\n width: 1%;\n }\n \n /* Datepicker */\n .p-calendar .p-datepicker {\n min-width: 100%;\n }\n \n .p-datepicker {\n width: auto;\n position: absolute;\n top: 0;\n left: 0;\n }\n \n .p-datepicker-inline {\n display: inline-block;\n position: static;\n overflow-x: auto;\n }\n \n /* Header */\n .p-datepicker-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n \n .p-datepicker-header .p-datepicker-title {\n margin: 0 auto;\n }\n \n .p-datepicker-prev,\n .p-datepicker-next {\n cursor: pointer;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n overflow: hidden;\n position: relative;\n }\n \n /* Multiple Month DatePicker */\n .p-datepicker-multiple-month .p-datepicker-group-container {\n display: flex;\n }\n \n .p-datepicker-multiple-month .p-datepicker-group-container .p-datepicker-group {\n flex: 1 1 auto;\n }\n \n /* Multiple Month DatePicker */\n .p-datepicker-multiple-month .p-datepicker-group-container {\n display: flex;\n }\n \n /* DatePicker Table */\n .p-datepicker table {\n width: 100%;\n border-collapse: collapse;\n }\n \n .p-datepicker td > span {\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n margin: 0 auto;\n overflow: hidden;\n position: relative;\n }\n \n /* Month Picker */\n .p-monthpicker-month {\n width: 33.3%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n overflow: hidden;\n position: relative;\n }\n \n /* Button Bar */\n .p-datepicker-buttonbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n \n /* Time Picker */\n .p-timepicker {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n \n .p-timepicker button {\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n overflow: hidden;\n position: relative;\n }\n \n .p-timepicker > div {\n display: flex;\n align-items: center;\n flex-direction: column;\n }\n \n /* Touch UI */\n .p-datepicker-touch-ui,\n .p-calendar .p-datepicker-touch-ui {\n position: fixed;\n top: 50%;\n left: 50%;\n min-width: 80vw;\n transform: translate(-50%, -50%);\n }\n \n /* Year Picker */\n .p-yearpicker-year {\n width: 50%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n overflow: hidden;\n position: relative;\n }\n}\n";
147
- var classes = {
148
- root: function root(_ref) {
149
- var _classNames;
150
- var props = _ref.props,
151
- focusedState = _ref.focusedState,
152
- isFilled = _ref.isFilled;
153
- return classNames('p-calendar p-component p-inputwrapper', (_classNames = {}, _defineProperty(_classNames, "p-calendar-w-btn p-calendar-w-btn-".concat(props.iconPos), props.showIcon), _defineProperty(_classNames, 'p-calendar-disabled', props.disabled), _defineProperty(_classNames, 'p-calendar-timeonly', props.timeOnly), _defineProperty(_classNames, 'p-inputwrapper-filled', props.value || isFilled), _defineProperty(_classNames, 'p-inputwrapper-focus', focusedState), _classNames));
154
- },
155
- dropdownButton: 'p-datepicker-trigger',
156
- buttonbar: 'p-datepicker-buttonbar',
157
- todayButton: 'p-button-text',
158
- clearButton: 'p-button-text',
159
- footer: 'p-datepicker-footer',
160
- yearPicker: 'p-yearpicker',
161
- year: function year(_ref2) {
162
- var isYearSelected = _ref2.isYearSelected,
163
- isSelectable = _ref2.isSelectable,
164
- y = _ref2.y;
165
- return classNames('p-yearpicker-year', {
166
- 'p-highlight': isYearSelected(y),
167
- 'p-disabled': !isSelectable(0, -1, y)
168
- });
169
- },
170
- monthPicker: 'p-monthpicker',
171
- month: function month(_ref3) {
172
- var isMonthSelected = _ref3.isMonthSelected,
173
- isSelectable = _ref3.isSelectable,
174
- i = _ref3.i,
175
- currentYear = _ref3.currentYear;
176
- return classNames('p-monthpicker-month', {
177
- 'p-highlight': isMonthSelected(i),
178
- 'p-disabled': !isSelectable(0, i, currentYear)
179
- });
180
- },
181
- hourPicker: 'p-hour-picker',
182
- secondPicker: 'p-second-picker',
183
- minutePicker: 'p-minute-picker',
184
- millisecondPicker: 'p-millisecond-picker',
185
- ampmPicker: 'p-ampm-picker',
186
- separatorContainer: 'p-separator',
187
- dayLabel: function dayLabel(_ref4) {
188
- var className = _ref4.className;
189
- return className;
190
- },
191
- day: function day(_ref5) {
192
- var date = _ref5.date;
193
- return classNames({
194
- 'p-datepicker-other-month': date.otherMonth,
195
- 'p-datepicker-today': date.today
196
- });
197
- },
198
- panel: function panel(_ref6) {
199
- var panelClassName = _ref6.panelClassName;
200
- return panelClassName;
201
- },
202
- previousIcon: 'p-datepicker-prev-icon',
203
- previousButton: 'p-datepicker-prev',
204
- nextIcon: 'p-datepicker-next-icon',
205
- nextButton: 'p-datepicker-next',
206
- incrementButton: 'p-link',
207
- decrementButton: 'p-link',
208
- title: 'p-datepicker-title',
209
- timePicker: 'p-timepicker',
210
- monthTitle: 'p-datepicker-month p-link',
211
- yearTitle: 'p-datepicker-year p-link',
212
- decadeTitle: 'p-datepicker-decade',
213
- header: 'p-datepicker-header',
214
- groupContainer: 'p-datepicker-group-container',
215
- group: 'p-datepicker-group',
216
- select: function select(_ref7) {
217
- var props = _ref7.props;
218
- return props.monthNavigator && props.view !== 'month' ? 'p-datepicker-month' : props.yearNavigator ? 'p-datepicker-year' : undefined;
219
- },
220
- weekHeader: 'p-datepicker-weekheader p-disabled',
221
- weekNumber: 'p-datepicker-weeknumber',
222
- weekLabelContainer: 'p-disabled',
223
- container: 'p-datepicker-calendar-container',
224
- table: 'p-datepicker-calendar',
225
- transition: 'p-connected-overlay'
226
- };
227
- var CalendarBase = ComponentBase.extend({
228
- defaultProps: {
229
- __TYPE: 'Calendar',
230
- appendTo: null,
231
- ariaLabelledBy: null,
232
- autoZIndex: true,
233
- autoFocus: false,
234
- baseZIndex: 0,
235
- className: null,
236
- clearButtonClassName: 'p-button-secondary',
237
- dateFormat: null,
238
- dateTemplate: null,
239
- decadeTemplate: null,
240
- decrementIcon: null,
241
- disabled: false,
242
- disabledDates: null,
243
- disabledDays: null,
244
- enabledDates: null,
245
- footerTemplate: null,
246
- formatDateTime: null,
247
- headerTemplate: null,
248
- hideOnDateTimeSelect: false,
249
- hourFormat: '24',
250
- icon: null,
251
- iconPos: 'right',
252
- id: null,
253
- incrementIcon: null,
254
- inline: false,
255
- inputClassName: null,
256
- inputId: null,
257
- inputMode: 'none',
258
- inputRef: null,
259
- inputStyle: null,
260
- keepInvalid: false,
261
- locale: null,
262
- mask: null,
263
- maskSlotChar: '_',
264
- maxDate: null,
265
- maxDateCount: null,
266
- minDate: null,
267
- monthNavigator: false,
268
- monthNavigatorTemplate: null,
269
- name: null,
270
- nextIcon: null,
271
- numberOfMonths: 1,
272
- onBlur: null,
273
- onChange: null,
274
- onClearButtonClick: null,
275
- onFocus: null,
276
- onHide: null,
277
- onInput: null,
278
- onMonthChange: null,
279
- onSelect: null,
280
- onShow: null,
281
- onTodayButtonClick: null,
282
- onViewDateChange: null,
283
- onVisibleChange: null,
284
- panelClassName: null,
285
- panelStyle: null,
286
- parseDateTime: null,
287
- placeholder: null,
288
- prevIcon: null,
289
- readOnlyInput: false,
290
- required: false,
291
- selectOtherMonths: false,
292
- selectionMode: 'single',
293
- shortYearCutoff: '+10',
294
- showButtonBar: false,
295
- showIcon: false,
296
- showMillisec: false,
297
- showMinMaxRange: false,
298
- showOnFocus: true,
299
- showOtherMonths: true,
300
- showSeconds: false,
301
- showTime: false,
302
- showWeek: false,
303
- stepHour: 1,
304
- stepMillisec: 1,
305
- stepMinute: 1,
306
- stepSecond: 1,
307
- style: null,
308
- tabIndex: null,
309
- timeOnly: false,
310
- todayButtonClassName: 'p-button-secondary',
311
- tooltip: null,
312
- tooltipOptions: null,
313
- touchUI: false,
314
- transitionOptions: null,
315
- value: null,
316
- view: 'date',
317
- viewDate: null,
318
- visible: false,
319
- yearNavigator: false,
320
- yearNavigatorTemplate: null,
321
- yearRange: null,
322
- children: undefined
323
- },
324
- css: {
325
- classes: classes,
326
- styles: styles
327
- }
328
- });
329
-
330
- var CalendarPanel = /*#__PURE__*/React.forwardRef(function (props, ref) {
331
- var cx = props.cx;
332
- var createElement = function createElement() {
333
- var panelProps = mergeProps({
334
- className: cx('panel', {
335
- panelClassName: props.className
336
- }),
337
- style: props.style,
338
- onClick: props.onClick,
339
- onMouseUp: props.onMouseUp
340
- }, props.ptm('panel', {
341
- hostName: props.hostName
342
- }));
343
- var transitionProps = mergeProps({
344
- classNames: cx('transition'),
345
- "in": props["in"],
346
- timeout: {
347
- enter: 120,
348
- exit: 100
349
- },
350
- options: props.transitionOptions,
351
- unmountOnExit: true,
352
- onEnter: props.onEnter,
353
- onEntered: props.onEntered,
354
- onExit: props.onExit,
355
- onExited: props.onExited
356
- }, props.ptm('transition', {
357
- hostName: props.hostName
358
- }));
359
- return /*#__PURE__*/React.createElement(CSSTransition, _extends({
360
- nodeRef: ref
361
- }, transitionProps), /*#__PURE__*/React.createElement("div", _extends({
362
- ref: ref
363
- }, panelProps), props.children));
364
- };
365
- var element = createElement();
366
- return props.inline ? element : /*#__PURE__*/React.createElement(Portal, {
367
- element: element,
368
- appendTo: props.appendTo
369
- });
370
- });
371
- CalendarPanel.displayName = 'CalendarPanel';
372
-
373
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
374
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
375
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
376
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
377
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
378
- var Calendar = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (inProps, ref) {
379
- var context = React.useContext(PrimeReactContext);
380
- var props = CalendarBase.getProps(inProps, context);
381
- var _React$useState = React.useState(false),
382
- _React$useState2 = _slicedToArray(_React$useState, 2),
383
- focusedState = _React$useState2[0],
384
- setFocusedState = _React$useState2[1];
385
- var _React$useState3 = React.useState(false),
386
- _React$useState4 = _slicedToArray(_React$useState3, 2),
387
- overlayVisibleState = _React$useState4[0],
388
- setOverlayVisibleState = _React$useState4[1];
389
- var _React$useState5 = React.useState(null),
390
- _React$useState6 = _slicedToArray(_React$useState5, 2),
391
- viewDateState = _React$useState6[0],
392
- setViewDateState = _React$useState6[1];
393
- var metaData = {
394
- props: props,
395
- state: {
396
- focused: focusedState,
397
- overlayVisible: overlayVisibleState,
398
- viewDate: viewDateState
399
- }
400
- };
401
- var _CalendarBase$setMeta = CalendarBase.setMetaData(metaData),
402
- ptm = _CalendarBase$setMeta.ptm,
403
- cx = _CalendarBase$setMeta.cx,
404
- isUnstyled = _CalendarBase$setMeta.isUnstyled;
405
- useHandleStyle(CalendarBase.css.styles, isUnstyled, {
406
- name: 'calendar'
407
- });
408
- var elementRef = React.useRef(null);
409
- var overlayRef = React.useRef(null);
410
- var inputRef = React.useRef(props.inputRef);
411
- var navigation = React.useRef(null);
412
- var ignoreFocusFunctionality = React.useRef(false);
413
- var timePickerTimer = React.useRef(null);
414
- var viewStateChanged = React.useRef(false);
415
- var touchUIMask = React.useRef(null);
416
- var overlayEventListener = React.useRef(null);
417
- var touchUIMaskClickListener = React.useRef(null);
418
- var isOverlayClicked = React.useRef(false);
419
- var ignoreMaskChange = React.useRef(false);
420
- var previousButton = React.useRef(false);
421
- var nextButton = React.useRef(false);
422
- var onChangeRef = React.useRef(null);
423
- var _React$useState7 = React.useState('date'),
424
- _React$useState8 = _slicedToArray(_React$useState7, 2),
425
- currentView = _React$useState8[0],
426
- setCurrentView = _React$useState8[1];
427
- var _React$useState9 = React.useState(null),
428
- _React$useState10 = _slicedToArray(_React$useState9, 2),
429
- currentMonth = _React$useState10[0],
430
- setCurrentMonth = _React$useState10[1];
431
- var _React$useState11 = React.useState(null),
432
- _React$useState12 = _slicedToArray(_React$useState11, 2),
433
- currentYear = _React$useState12[0],
434
- setCurrentYear = _React$useState12[1];
435
- var _React$useState13 = React.useState([]),
436
- _React$useState14 = _slicedToArray(_React$useState13, 2),
437
- yearOptions = _React$useState14[0],
438
- setYearOptions = _React$useState14[1];
439
- var previousValue = usePrevious(props.value);
440
- var visible = props.inline || (props.onVisibleChange ? props.visible : overlayVisibleState);
441
- var attributeSelector = UniqueComponentId();
442
- var _useOverlayListener = useOverlayListener({
443
- target: elementRef,
444
- overlay: overlayRef,
445
- listener: function listener(event, _ref) {
446
- var type = _ref.type,
447
- valid = _ref.valid;
448
- if (valid) {
449
- type === 'outside' ? !isOverlayClicked.current && !isNavIconClicked(event.target) && hide('outside') : hide();
450
- }
451
- isOverlayClicked.current = false;
452
- },
453
- when: !(props.touchUI || props.inline) && visible
454
- }),
455
- _useOverlayListener2 = _slicedToArray(_useOverlayListener, 2),
456
- bindOverlayListener = _useOverlayListener2[0],
457
- unbindOverlayListener = _useOverlayListener2[1];
458
- var getDateFormat = function getDateFormat() {
459
- return props.dateFormat || localeOption('dateFormat', props.locale);
460
- };
461
- var onInputFocus = function onInputFocus(event) {
462
- if (ignoreFocusFunctionality.current) {
463
- setFocusedState(true);
464
- ignoreFocusFunctionality.current = false;
465
- } else {
466
- if (props.showOnFocus && !visible) {
467
- show();
468
- }
469
- setFocusedState(true);
470
- props.onFocus && props.onFocus(event);
471
- }
472
- };
473
- var onInputBlur = function onInputBlur(event) {
474
- !props.keepInvalid && updateInputfield(props.value);
475
- props.onBlur && props.onBlur(event);
476
- setFocusedState(false);
477
- };
478
- var onInputKeyDown = function onInputKeyDown(event) {
479
- switch (event.which) {
480
- //escape
481
- case 27:
482
- {
483
- hide();
484
- break;
485
- }
486
-
487
- //tab
488
- case 9:
489
- {
490
- visible && trapFocus(event);
491
- props.touchUI && disableModality();
492
- break;
493
- }
494
- }
495
- };
496
- var onUserInput = function onUserInput(event) {
497
- updateValueOnInput(event, event.target.value);
498
- props.onInput && props.onInput(event);
499
- };
500
- var updateValueOnInput = function updateValueOnInput(event, rawValue) {
501
- try {
502
- var value = parseValueFromString(rawValue);
503
- if (isValidSelection(value)) {
504
- updateModel(event, value);
505
- updateViewDate(event, value.length ? value[0] : value);
506
- }
507
- } catch (err) {
508
- //invalid date
509
- var _value = props.keepInvalid ? rawValue : null;
510
- updateModel(event, _value);
511
- }
512
- };
513
- var reFocusInputField = function reFocusInputField() {
514
- if (!props.inline && inputRef.current) {
515
- ignoreFocusFunctionality.current = true;
516
- DomHandler.focus(inputRef.current);
517
- }
518
- };
519
- var isValidSelection = function isValidSelection(value) {
520
- var isValid = true;
521
- if (isSingleSelection()) {
522
- if (!(isSelectable(value.getDate(), value.getMonth(), value.getFullYear(), false) && isSelectableTime(value))) {
523
- isValid = false;
524
- }
525
- } else if (value.every(function (v) {
526
- return isSelectable(v.getDate(), v.getMonth(), v.getFullYear(), false) && isSelectableTime(v);
527
- })) {
528
- if (isRangeSelection()) {
529
- isValid = value.length > 1 && value[1] > value[0] ? true : false;
530
- }
531
- }
532
- return isValid;
533
- };
534
- var onButtonClick = function onButtonClick() {
535
- visible ? hide() : show();
536
- };
537
- var onPrevButtonClick = function onPrevButtonClick(event) {
538
- navigation.current = {
539
- backward: true,
540
- button: true
541
- };
542
- navBackward(event);
543
- };
544
- var onNextButtonClick = function onNextButtonClick(event) {
545
- navigation.current = {
546
- backward: false,
547
- button: true
548
- };
549
- navForward(event);
550
- };
551
- var onContainerButtonKeydown = function onContainerButtonKeydown(event) {
552
- switch (event.which) {
553
- //tab
554
- case 9:
555
- trapFocus(event);
556
- break;
557
-
558
- //escape
559
- case 27:
560
- hide(null, reFocusInputField);
561
- event.preventDefault();
562
- break;
563
- }
564
- };
565
- var trapFocus = function trapFocus(event) {
566
- event.preventDefault();
567
- var focusableElements = DomHandler.getFocusableElements(overlayRef.current);
568
- if (focusableElements && focusableElements.length > 0) {
569
- if (!document.activeElement) {
570
- focusableElements[0].focus();
571
- } else {
572
- var focusedIndex = focusableElements.indexOf(document.activeElement);
573
- if (event.shiftKey) {
574
- if (focusedIndex === -1 || focusedIndex === 0) focusableElements[focusableElements.length - 1].focus();else focusableElements[focusedIndex - 1].focus();
575
- } else {
576
- if (focusedIndex === -1 || focusedIndex === focusableElements.length - 1) focusableElements[0].focus();else focusableElements[focusedIndex + 1].focus();
577
- }
578
- }
579
- }
580
- };
581
- var updateFocus = function updateFocus() {
582
- if (navigation.current) {
583
- if (navigation.current.button) {
584
- initFocusableCell();
585
- if (navigation.current.backward) previousButton.current.focus();else nextButton.current.focus();
586
- } else {
587
- var cell;
588
- if (navigation.current.backward) {
589
- var cells = DomHandler.find(overlayRef.current, 'table td span:not([data-p-disabled="true"])');
590
- cell = cells[cells.length - 1];
591
- } else {
592
- cell = DomHandler.findSingle(overlayRef.current, 'table td span:not([data-p-disabled="true"])');
593
- }
594
- if (cell) {
595
- cell.tabIndex = '0';
596
- cell.focus();
597
- }
598
- }
599
- navigation.current = null;
600
- } else {
601
- initFocusableCell();
602
- }
603
- };
604
- var initFocusableCell = function initFocusableCell() {
605
- var cell;
606
- if (props.view === 'month') {
607
- var cells = DomHandler.find(overlayRef.current, '[data-pc-section="monthpicker"] [data-pc-section="month"]');
608
- var selectedCell = DomHandler.findSingle(overlayRef.current, '[data-pc-section="monthpicker"] [data-pc-section="month"][data-p-highlight="true"]');
609
- cells.forEach(function (cell) {
610
- return cell.tabIndex = -1;
611
- });
612
- cell = selectedCell || cells[0];
613
- } else {
614
- cell = DomHandler.findSingle(overlayRef.current, 'span[data-p-highlight="true"]');
615
- if (!cell) {
616
- var todayCell = DomHandler.findSingle(overlayRef.current, 'td.p-datepicker-today span:not(.p-disabled)');
617
- cell = todayCell || DomHandler.findSingle(overlayRef.current, 'table td span:not([data-p-disabled="true"])');
618
- }
619
- }
620
- if (cell) {
621
- cell.tabIndex = '0';
622
- }
623
- };
624
- var navBackward = function navBackward(event) {
625
- if (props.disabled) {
626
- event.preventDefault();
627
- return;
628
- }
629
- var newViewDate = cloneDate(getViewDate());
630
- newViewDate.setDate(1);
631
- if (currentView === 'date') {
632
- if (newViewDate.getMonth() === 0) {
633
- newViewDate.setMonth(11);
634
- newViewDate.setFullYear(decrementYear());
635
- setCurrentMonth(11);
636
- } else {
637
- newViewDate.setMonth(newViewDate.getMonth() - 1);
638
- setCurrentMonth(function (prevState) {
639
- return prevState - 1;
640
- });
641
- }
642
- } else if (currentView === 'month') {
643
- var newYear = newViewDate.getFullYear() - 1;
644
- if (props.yearNavigator) {
645
- var minYear = parseInt(props.yearRange.split(':')[0], 10);
646
- if (newYear < minYear) {
647
- newYear = minYear;
648
- }
649
- }
650
- newViewDate.setFullYear(newYear);
651
- }
652
- if (currentView === 'month') {
653
- newViewDate.setFullYear(decrementYear());
654
- } else if (currentView === 'year') {
655
- newViewDate.setFullYear(decrementDecade());
656
- }
657
- updateViewDate(event, newViewDate);
658
- event.preventDefault();
659
- };
660
- var navForward = function navForward(event) {
661
- if (props.disabled) {
662
- event.preventDefault();
663
- return;
664
- }
665
- var newViewDate = cloneDate(getViewDate());
666
- newViewDate.setDate(1);
667
- if (currentView === 'date') {
668
- if (newViewDate.getMonth() === 11) {
669
- newViewDate.setMonth(0);
670
- newViewDate.setFullYear(incrementYear());
671
- setCurrentMonth(0);
672
- } else {
673
- newViewDate.setMonth(newViewDate.getMonth() + 1);
674
- setCurrentMonth(function (prevState) {
675
- return prevState + 1;
676
- });
677
- }
678
- } else if (currentView === 'month') {
679
- var newYear = newViewDate.getFullYear() + 1;
680
- if (props.yearNavigator) {
681
- var maxYear = parseInt(props.yearRange.split(':')[1], 10);
682
- if (newYear > maxYear) {
683
- newYear = maxYear;
684
- }
685
- }
686
- newViewDate.setFullYear(newYear);
687
- }
688
- if (currentView === 'month') {
689
- newViewDate.setFullYear(incrementYear());
690
- } else if (currentView === 'year') {
691
- newViewDate.setFullYear(incrementDecade());
692
- }
693
- updateViewDate(event, newViewDate);
694
- event.preventDefault();
695
- };
696
- var populateYearOptions = function populateYearOptions(start, end) {
697
- var _yearOptions = [];
698
- for (var i = start; i <= end; i++) {
699
- yearOptions.push(i);
700
- }
701
- setYearOptions(_yearOptions);
702
- };
703
- var decrementYear = function decrementYear() {
704
- var _currentYear = currentYear - 1;
705
- setCurrentYear(_currentYear);
706
- if (props.yearNavigator && _currentYear < yearOptions[0]) {
707
- var difference = yearOptions[yearOptions.length - 1] - yearOptions[0];
708
- populateYearOptions(yearOptions[0] - difference, yearOptions[yearOptions.length - 1] - difference);
709
- }
710
- return _currentYear;
711
- };
712
- var incrementYear = function incrementYear() {
713
- var _currentYear = currentYear + 1;
714
- setCurrentYear(_currentYear);
715
- if (props.yearNavigator && _currentYear.current > yearOptions[yearOptions.length - 1]) {
716
- var difference = yearOptions[yearOptions.length - 1] - yearOptions[0];
717
- populateYearOptions(yearOptions[0] + difference, yearOptions[yearOptions.length - 1] + difference);
718
- }
719
- return _currentYear;
720
- };
721
- var onMonthDropdownChange = function onMonthDropdownChange(event, value) {
722
- var currentViewDate = getViewDate();
723
- var newViewDate = cloneDate(currentViewDate);
724
- newViewDate.setMonth(parseInt(value, 10));
725
- updateViewDate(event, newViewDate);
726
- };
727
- var onYearDropdownChange = function onYearDropdownChange(event, value) {
728
- var currentViewDate = getViewDate();
729
- var newViewDate = cloneDate(currentViewDate);
730
- newViewDate.setFullYear(parseInt(value, 10));
731
- updateViewDate(event, newViewDate);
732
- };
733
- var onTodayButtonClick = function onTodayButtonClick(event) {
734
- var today = new Date();
735
- var dateMeta = {
736
- day: today.getDate(),
737
- month: today.getMonth(),
738
- year: today.getFullYear(),
739
- today: true,
740
- selectable: true
741
- };
742
- var timeMeta = {
743
- hours: today.getHours(),
744
- minutes: today.getMinutes(),
745
- seconds: today.getSeconds(),
746
- milliseconds: today.getMilliseconds()
747
- };
748
- updateViewDate(event, today);
749
- onDateSelect(event, dateMeta, timeMeta);
750
- props.onTodayButtonClick && props.onTodayButtonClick(event);
751
- };
752
- var onClearButtonClick = function onClearButtonClick(event) {
753
- updateModel(event, null);
754
- updateInputfield(null);
755
- hide();
756
- props.onClearButtonClick && props.onClearButtonClick(event);
757
- };
758
- var onPanelClick = function onPanelClick(event) {
759
- if (!props.inline) {
760
- OverlayService.emit('overlay-click', {
761
- originalEvent: event,
762
- target: elementRef.current
763
- });
764
- }
765
- };
766
- var onPanelMouseUp = function onPanelMouseUp(event) {
767
- onPanelClick(event);
768
- };
769
- var onTimePickerElementMouseDown = function onTimePickerElementMouseDown(event, type, direction) {
770
- if (!props.disabled) {
771
- repeat(event, null, type, direction);
772
- event.preventDefault();
773
- }
774
- };
775
- var onTimePickerElementMouseUp = function onTimePickerElementMouseUp() {
776
- if (!props.disabled) {
777
- clearTimePickerTimer();
778
- }
779
- };
780
- var onTimePickerElementMouseLeave = function onTimePickerElementMouseLeave() {
781
- if (!props.disabled) {
782
- clearTimePickerTimer();
783
- }
784
- };
785
- var repeat = function repeat(event, interval, type, direction) {
786
- clearTimePickerTimer();
787
- timePickerTimer.current = setTimeout(function () {
788
- repeat(event, 100, type, direction);
789
- }, interval || 500);
790
- switch (type) {
791
- case 0:
792
- if (direction === 1) incrementHour(event);else decrementHour(event);
793
- break;
794
- case 1:
795
- if (direction === 1) incrementMinute(event);else decrementMinute(event);
796
- break;
797
- case 2:
798
- if (direction === 1) incrementSecond(event);else decrementSecond(event);
799
- break;
800
- case 3:
801
- if (direction === 1) incrementMilliSecond(event);else decrementMilliSecond(event);
802
- break;
803
- }
804
- };
805
- var clearTimePickerTimer = function clearTimePickerTimer() {
806
- if (timePickerTimer.current) {
807
- clearTimeout(timePickerTimer.current);
808
- }
809
- };
810
- var incrementHour = function incrementHour(event) {
811
- var currentTime = getCurrentDateTime();
812
- var currentHour = currentTime.getHours();
813
- var newHour = currentHour + props.stepHour;
814
- newHour = newHour >= 24 ? newHour - 24 : newHour;
815
- if (validateHour(newHour, currentTime)) {
816
- if (props.maxDate && props.maxDate.toDateString() === currentTime.toDateString() && props.maxDate.getHours() === newHour) {
817
- if (props.maxDate.getMinutes() < currentTime.getMinutes()) {
818
- if (props.maxDate.getSeconds() < currentTime.getSeconds()) {
819
- if (props.maxDate.getMilliseconds() < currentTime.getMilliseconds()) {
820
- updateTime(event, newHour, props.maxDate.getMinutes(), props.maxDate.getSeconds(), props.maxDate.getMilliseconds());
821
- } else {
822
- updateTime(event, newHour, props.maxDate.getMinutes(), props.maxDate.getSeconds(), currentTime.getMilliseconds());
823
- }
824
- } else {
825
- updateTime(event, newHour, props.maxDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
826
- }
827
- } else if (props.maxDate.getMinutes() === currentTime.getMinutes()) {
828
- if (props.maxDate.getSeconds() < currentTime.getSeconds()) {
829
- if (props.maxDate.getMilliseconds() < currentTime.getMilliseconds()) {
830
- updateTime(event, newHour, props.maxDate.getMinutes(), props.maxDate.getSeconds(), props.maxDate.getMilliseconds());
831
- } else {
832
- updateTime(event, newHour, props.maxDate.getMinutes(), props.maxDate.getSeconds(), currentTime.getMilliseconds());
833
- }
834
- } else {
835
- updateTime(event, newHour, props.maxDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
836
- }
837
- } else {
838
- updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
839
- }
840
- } else {
841
- updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
842
- }
843
- }
844
- event.preventDefault();
845
- };
846
- var decrementHour = function decrementHour(event) {
847
- var currentTime = getCurrentDateTime();
848
- var currentHour = currentTime.getHours();
849
- var newHour = currentHour - props.stepHour;
850
- newHour = newHour < 0 ? newHour + 24 : newHour;
851
- if (validateHour(newHour, currentTime)) {
852
- if (props.minDate && props.minDate.toDateString() === currentTime.toDateString() && props.minDate.getHours() === newHour) {
853
- if (props.minDate.getMinutes() > currentTime.getMinutes()) {
854
- if (props.minDate.getSeconds() > currentTime.getSeconds()) {
855
- if (props.minDate.getMilliseconds() > currentTime.getMilliseconds()) {
856
- updateTime(event, newHour, props.minDate.getMinutes(), props.minDate.getSeconds(), props.minDate.getMilliseconds());
857
- } else {
858
- updateTime(event, newHour, props.minDate.getMinutes(), props.minDate.getSeconds(), currentTime.getMilliseconds());
859
- }
860
- } else {
861
- updateTime(event, newHour, props.minDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
862
- }
863
- } else if (props.minDate.getMinutes() === currentTime.getMinutes()) {
864
- if (props.minDate.getSeconds() > currentTime.getSeconds()) {
865
- if (props.minDate.getMilliseconds() > currentTime.getMilliseconds()) {
866
- updateTime(event, newHour, props.minDate.getMinutes(), props.minDate.getSeconds(), props.minDate.getMilliseconds());
867
- } else {
868
- updateTime(event, newHour, props.minDate.getMinutes(), props.minDate.getSeconds(), currentTime.getMilliseconds());
869
- }
870
- } else {
871
- updateTime(event, newHour, props.minDate.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
872
- }
873
- } else {
874
- updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
875
- }
876
- } else {
877
- updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
878
- }
879
- }
880
- event.preventDefault();
881
- };
882
- var doStepMinute = function doStepMinute(currentMinute, step) {
883
- if (props.stepMinute <= 1) {
884
- return step ? currentMinute + step : currentMinute;
885
- }
886
- if (!step) {
887
- step = props.stepMinute;
888
- if (currentMinute % step === 0) {
889
- return currentMinute;
890
- }
891
- }
892
- return Math.floor((currentMinute + step) / step) * step;
893
- };
894
- var incrementMinute = function incrementMinute(event) {
895
- var currentTime = getCurrentDateTime();
896
- var currentMinute = currentTime.getMinutes();
897
- var newMinute = doStepMinute(currentMinute, props.stepMinute);
898
- newMinute = newMinute > 59 ? newMinute - 60 : newMinute;
899
- if (validateMinute(newMinute, currentTime)) {
900
- if (props.maxDate && props.maxDate.toDateString() === currentTime.toDateString() && props.maxDate.getMinutes() === newMinute) {
901
- if (props.maxDate.getSeconds() < currentTime.getSeconds()) {
902
- if (props.maxDate.getMilliseconds() < currentTime.getMilliseconds()) {
903
- updateTime(event, currentTime.getHours(), newMinute, props.maxDate.getSeconds(), props.maxDate.getMilliseconds());
904
- } else {
905
- updateTime(event, currentTime.getHours(), newMinute, props.maxDate.getSeconds(), currentTime.getMilliseconds());
906
- }
907
- } else {
908
- updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds(), currentTime.getMilliseconds());
909
- }
910
- } else {
911
- updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds(), currentTime.getMilliseconds());
912
- }
913
- }
914
- event.preventDefault();
915
- };
916
- var decrementMinute = function decrementMinute(event) {
917
- var currentTime = getCurrentDateTime();
918
- var currentMinute = currentTime.getMinutes();
919
- var newMinute = doStepMinute(currentMinute, -props.stepMinute);
920
- newMinute = newMinute < 0 ? newMinute + 60 : newMinute;
921
- if (validateMinute(newMinute, currentTime)) {
922
- if (props.minDate && props.minDate.toDateString() === currentTime.toDateString() && props.minDate.getMinutes() === newMinute) {
923
- if (props.minDate.getSeconds() > currentTime.getSeconds()) {
924
- if (props.minDate.getMilliseconds() > currentTime.getMilliseconds()) {
925
- updateTime(event, currentTime.getHours(), newMinute, props.minDate.getSeconds(), props.minDate.getMilliseconds());
926
- } else {
927
- updateTime(event, currentTime.getHours(), newMinute, props.minDate.getSeconds(), currentTime.getMilliseconds());
928
- }
929
- } else {
930
- updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds(), currentTime.getMilliseconds());
931
- }
932
- } else {
933
- updateTime(event, currentTime.getHours(), newMinute, currentTime.getSeconds(), currentTime.getMilliseconds());
934
- }
935
- }
936
- event.preventDefault();
937
- };
938
- var incrementSecond = function incrementSecond(event) {
939
- var currentTime = getCurrentDateTime();
940
- var currentSecond = currentTime.getSeconds();
941
- var newSecond = currentSecond + props.stepSecond;
942
- newSecond = newSecond > 59 ? newSecond - 60 : newSecond;
943
- if (validateSecond(newSecond, currentTime)) {
944
- if (props.maxDate && props.maxDate.toDateString() === currentTime.toDateString() && props.maxDate.getSeconds() === newSecond) {
945
- if (props.maxDate.getMilliseconds() < currentTime.getMilliseconds()) {
946
- updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, props.maxDate.getMilliseconds());
947
- } else {
948
- updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, currentTime.getMilliseconds());
949
- }
950
- } else {
951
- updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, currentTime.getMilliseconds());
952
- }
953
- }
954
- event.preventDefault();
955
- };
956
- var decrementSecond = function decrementSecond(event) {
957
- var currentTime = getCurrentDateTime();
958
- var currentSecond = currentTime.getSeconds();
959
- var newSecond = currentSecond - props.stepSecond;
960
- newSecond = newSecond < 0 ? newSecond + 60 : newSecond;
961
- if (validateSecond(newSecond, currentTime)) {
962
- if (props.minDate && props.minDate.toDateString() === currentTime.toDateString() && props.minDate.getSeconds() === newSecond) {
963
- if (props.minDate.getMilliseconds() > currentTime.getMilliseconds()) {
964
- updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, props.minDate.getMilliseconds());
965
- } else {
966
- updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, currentTime.getMilliseconds());
967
- }
968
- } else {
969
- updateTime(event, currentTime.getHours(), currentTime.getMinutes(), newSecond, currentTime.getMilliseconds());
970
- }
971
- }
972
- event.preventDefault();
973
- };
974
- var incrementMilliSecond = function incrementMilliSecond(event) {
975
- var currentTime = getCurrentDateTime();
976
- var currentMillisecond = currentTime.getMilliseconds();
977
- var newMillisecond = currentMillisecond + props.stepMillisec;
978
- newMillisecond = newMillisecond > 999 ? newMillisecond - 1000 : newMillisecond;
979
- if (validateMillisecond(newMillisecond, currentTime)) {
980
- updateTime(event, currentTime.getHours(), currentTime.getMinutes(), currentTime.getSeconds(), newMillisecond);
981
- }
982
- event.preventDefault();
983
- };
984
- var decrementMilliSecond = function decrementMilliSecond(event) {
985
- var currentTime = getCurrentDateTime();
986
- var currentMillisecond = currentTime.getMilliseconds();
987
- var newMillisecond = currentMillisecond - props.stepMillisec;
988
- newMillisecond = newMillisecond < 0 ? newMillisecond + 999 : newMillisecond;
989
- if (validateMillisecond(newMillisecond, currentTime)) {
990
- updateTime(event, currentTime.getHours(), currentTime.getMinutes(), currentTime.getSeconds(), newMillisecond);
991
- }
992
- event.preventDefault();
993
- };
994
- var toggleAmPm = function toggleAmPm(event) {
995
- var currentTime = getCurrentDateTime();
996
- var currentHour = currentTime.getHours();
997
- var newHour = currentHour >= 12 ? currentHour - 12 : currentHour + 12;
998
- if (validateHour(convertTo24Hour(newHour, !(currentHour > 11)), currentTime)) {
999
- updateTime(event, newHour, currentTime.getMinutes(), currentTime.getSeconds(), currentTime.getMilliseconds());
1000
- }
1001
- event.preventDefault();
1002
- };
1003
- var getViewDate = function getViewDate(date) {
1004
- var propValue = props.value;
1005
- var viewDate = date || (props.onViewDateChange ? props.viewDate : viewDateState);
1006
- if (Array.isArray(propValue)) {
1007
- propValue = propValue[0];
1008
- }
1009
- return viewDate && isValidDate(viewDate) ? viewDate : propValue && isValidDate(propValue) ? propValue : new Date();
1010
- };
1011
- var getCurrentDateTime = function getCurrentDateTime() {
1012
- if (isSingleSelection()) {
1013
- return props.value && props.value instanceof Date ? cloneDate(props.value) : getViewDate();
1014
- } else if (isMultipleSelection()) {
1015
- if (props.value && props.value.length) {
1016
- return cloneDate(props.value[props.value.length - 1]);
1017
- }
1018
- } else if (isRangeSelection()) {
1019
- if (props.value && props.value.length) {
1020
- var startDate = cloneDate(props.value[0]);
1021
- var endDate = cloneDate(props.value[1]);
1022
- return endDate || startDate;
1023
- }
1024
- }
1025
- return new Date();
1026
- };
1027
- var cloneDate = function cloneDate(date) {
1028
- return isValidDate(date) ? new Date(date.valueOf()) : date;
1029
- };
1030
- var isValidDate = function isValidDate(date) {
1031
- return date instanceof Date && !isNaN(date);
1032
- };
1033
- var convertTo24Hour = function convertTo24Hour(hour, pm) {
1034
- if (props.hourFormat == '12') {
1035
- return hour === 12 ? pm ? 12 : 0 : pm ? hour + 12 : hour;
1036
- }
1037
- return hour;
1038
- };
1039
- var validateHour = function validateHour(hour, value) {
1040
- var valid = true;
1041
- var valueDateString = value ? value.toDateString() : null;
1042
- if (props.minDate && valueDateString && props.minDate.toDateString() === valueDateString) {
1043
- if (props.minDate.getHours() > hour) {
1044
- valid = false;
1045
- }
1046
- }
1047
- if (props.maxDate && valueDateString && props.maxDate.toDateString() === valueDateString) {
1048
- if (props.maxDate.getHours() < hour) {
1049
- valid = false;
1050
- }
1051
- }
1052
- return valid;
1053
- };
1054
- var validateMinute = function validateMinute(minute, value) {
1055
- var valid = true;
1056
- var valueDateString = value ? value.toDateString() : null;
1057
- if (props.minDate && valueDateString && props.minDate.toDateString() === valueDateString) {
1058
- if (value.getHours() === props.minDate.getHours()) {
1059
- if (props.minDate.getMinutes() > minute) {
1060
- valid = false;
1061
- }
1062
- }
1063
- }
1064
- if (props.maxDate && valueDateString && props.maxDate.toDateString() === valueDateString) {
1065
- if (value.getHours() === props.maxDate.getHours()) {
1066
- if (props.maxDate.getMinutes() < minute) {
1067
- valid = false;
1068
- }
1069
- }
1070
- }
1071
- return valid;
1072
- };
1073
- var validateSecond = function validateSecond(second, value) {
1074
- var valid = true;
1075
- var valueDateString = value ? value.toDateString() : null;
1076
- if (props.minDate && valueDateString && props.minDate.toDateString() === valueDateString) {
1077
- if (value.getHours() === props.minDate.getHours() && value.getMinutes() === props.minDate.getMinutes()) {
1078
- if (props.minDate.getSeconds() > second) {
1079
- valid = false;
1080
- }
1081
- }
1082
- }
1083
- if (props.maxDate && valueDateString && props.maxDate.toDateString() === valueDateString) {
1084
- if (value.getHours() === props.maxDate.getHours() && value.getMinutes() === props.maxDate.getMinutes()) {
1085
- if (props.maxDate.getSeconds() < second) {
1086
- valid = false;
1087
- }
1088
- }
1089
- }
1090
- return valid;
1091
- };
1092
- var validateMillisecond = function validateMillisecond(millisecond, value) {
1093
- var valid = true;
1094
- var valueDateString = value ? value.toDateString() : null;
1095
- if (props.minDate && valueDateString && props.minDate.toDateString() === valueDateString) {
1096
- if (value.getHours() === props.minDate.getHours() && value.getSeconds() === props.minDate.getSeconds() && value.getMinutes() === props.minDate.getMinutes()) {
1097
- if (props.minDate.getMilliseconds() > millisecond) {
1098
- valid = false;
1099
- }
1100
- }
1101
- }
1102
- if (props.maxDate && valueDateString && props.maxDate.toDateString() === valueDateString) {
1103
- if (value.getHours() === props.maxDate.getHours() && value.getSeconds() === props.maxDate.getSeconds() && value.getMinutes() === props.maxDate.getMinutes()) {
1104
- if (props.maxDate.getMilliseconds() < millisecond) {
1105
- valid = false;
1106
- }
1107
- }
1108
- }
1109
- return valid;
1110
- };
1111
- var validateDate = function validateDate(value) {
1112
- if (props.yearNavigator) {
1113
- var viewYear = value.getFullYear();
1114
- var minRangeYear = props.yearRange ? parseInt(props.yearRange.split(':')[0], 10) : null;
1115
- var maxRangeYear = props.yearRange ? parseInt(props.yearRange.split(':')[1], 10) : null;
1116
- var minYear = props.minDate && minRangeYear != null ? Math.max(props.minDate.getFullYear(), minRangeYear) : props.minDate || minRangeYear;
1117
- var maxYear = props.maxDate && maxRangeYear != null ? Math.min(props.maxDate.getFullYear(), maxRangeYear) : props.maxDate || maxRangeYear;
1118
- if (minYear && minYear > viewYear) {
1119
- viewYear = minYear;
1120
- }
1121
- if (maxYear && maxYear < viewYear) {
1122
- viewYear = maxYear;
1123
- }
1124
- value.setFullYear(viewYear);
1125
- }
1126
- if (props.monthNavigator && props.view !== 'month') {
1127
- var viewMonth = value.getMonth();
1128
- var viewMonthWithMinMax = parseInt(isInMinYear(value) && Math.max(props.minDate.getMonth(), viewMonth).toString() || isInMaxYear(value) && Math.min(props.maxDate.getMonth(), viewMonth).toString() || viewMonth);
1129
- value.setMonth(viewMonthWithMinMax);
1130
- }
1131
- };
1132
- var updateTime = function updateTime(event, hour, minute, second, millisecond) {
1133
- var newDateTime = getCurrentDateTime();
1134
- newDateTime.setHours(hour);
1135
- newDateTime.setMinutes(minute);
1136
- newDateTime.setSeconds(second);
1137
- newDateTime.setMilliseconds(millisecond);
1138
- if (isMultipleSelection()) {
1139
- if (props.value && props.value.length) {
1140
- var value = _toConsumableArray(props.value);
1141
- value[value.length - 1] = newDateTime;
1142
- newDateTime = value;
1143
- } else {
1144
- newDateTime = [newDateTime];
1145
- }
1146
- } else if (isRangeSelection()) {
1147
- if (props.value && props.value.length) {
1148
- var startDate = props.value[0];
1149
- var endDate = props.value[1];
1150
- newDateTime = endDate ? [startDate, newDateTime] : [newDateTime, null];
1151
- } else {
1152
- newDateTime = [newDateTime, null];
1153
- }
1154
- }
1155
- updateModel(event, newDateTime);
1156
- if (props.onSelect) {
1157
- props.onSelect({
1158
- originalEvent: event,
1159
- value: newDateTime
1160
- });
1161
- }
1162
- updateInputfield(newDateTime);
1163
- };
1164
- var updateViewDate = function updateViewDate(event, value) {
1165
- validateDate(value);
1166
- if (props.onViewDateChange) {
1167
- props.onViewDateChange({
1168
- originalEvent: event,
1169
- value: value
1170
- });
1171
- } else {
1172
- viewStateChanged.current = true;
1173
- setViewDateState(value);
1174
- }
1175
- setCurrentMonth(value.getMonth());
1176
- setCurrentYear(value.getFullYear());
1177
- };
1178
- var setNavigationState = function setNavigationState(newViewDate) {
1179
- if (!newViewDate || !props.showMinMaxRange || props.view !== 'date' || !overlayRef.current) {
1180
- return;
1181
- }
1182
- var navPrev = DomHandler.findSingle(overlayRef.current, '[data-pc-section="previousbutton"]');
1183
- var navNext = DomHandler.findSingle(overlayRef.current, '[data-pc-section="nextbutton"]');
1184
- if (props.disabled) {
1185
- !isUnstyled() && DomHandler.addClass(navPrev, 'p-disabled');
1186
- navPrev.setAttribute('data-p-disabled', true);
1187
- !isUnstyled() && DomHandler.addClass(navNext, 'p-disabled');
1188
- navNext.setAttribute('data-p-disabled', true);
1189
- return;
1190
- }
1191
-
1192
- // previous (check first day of month at 00:00:00)
1193
- if (props.minDate) {
1194
- var firstDayOfMonth = cloneDate(newViewDate);
1195
- if (firstDayOfMonth.getMonth() === 0) {
1196
- firstDayOfMonth.setMonth(11, 1);
1197
- firstDayOfMonth.setFullYear(firstDayOfMonth.getFullYear() - 1);
1198
- } else {
1199
- firstDayOfMonth.setMonth(firstDayOfMonth.getMonth(), 1);
1200
- }
1201
- firstDayOfMonth.setHours(0);
1202
- firstDayOfMonth.setMinutes(0);
1203
- firstDayOfMonth.setSeconds(0);
1204
- if (props.minDate > firstDayOfMonth) {
1205
- DomHandler.addClass(navPrev, 'p-disabled');
1206
- } else {
1207
- DomHandler.removeClass(navPrev, 'p-disabled');
1208
- }
1209
- }
1210
-
1211
- // next (check last day of month at 11:59:59)
1212
- if (props.maxDate) {
1213
- var lastDayOfMonth = cloneDate(newViewDate);
1214
- if (lastDayOfMonth.getMonth() === 11) {
1215
- lastDayOfMonth.setMonth(0, 1);
1216
- lastDayOfMonth.setFullYear(lastDayOfMonth.getFullYear() + 1);
1217
- } else {
1218
- lastDayOfMonth.setMonth(lastDayOfMonth.getMonth() + 1, 1);
1219
- }
1220
- lastDayOfMonth.setHours(0);
1221
- lastDayOfMonth.setMinutes(0);
1222
- lastDayOfMonth.setSeconds(0);
1223
- lastDayOfMonth.setSeconds(-1);
1224
- if (props.maxDate < lastDayOfMonth) {
1225
- DomHandler.addClass(navNext, 'p-disabled');
1226
- } else {
1227
- DomHandler.removeClass(navNext, 'p-disabled');
1228
- }
1229
- }
1230
- };
1231
- var onDateCellKeydown = function onDateCellKeydown(event, date, groupIndex) {
1232
- var cellContent = event.currentTarget;
1233
- var cell = cellContent.parentElement;
1234
- switch (event.which) {
1235
- //down arrow
1236
- case 40:
1237
- {
1238
- cellContent.tabIndex = '-1';
1239
- var cellIndex = DomHandler.index(cell);
1240
- var nextRow = cell.parentElement.nextElementSibling;
1241
- if (nextRow) {
1242
- var focusCell = nextRow.children[cellIndex].children[0];
1243
- if (DomHandler.hasClass(focusCell, 'p-disabled')) {
1244
- navigation.current = {
1245
- backward: false
1246
- };
1247
- navForward(event);
1248
- } else {
1249
- nextRow.children[cellIndex].children[0].tabIndex = '0';
1250
- nextRow.children[cellIndex].children[0].focus();
1251
- }
1252
- } else {
1253
- navigation.current = {
1254
- backward: false
1255
- };
1256
- navForward(event);
1257
- }
1258
- event.preventDefault();
1259
- break;
1260
- }
1261
-
1262
- //up arrow
1263
- case 38:
1264
- {
1265
- cellContent.tabIndex = '-1';
1266
- var _cellIndex = DomHandler.index(cell);
1267
- var prevRow = cell.parentElement.previousElementSibling;
1268
- if (prevRow) {
1269
- var _focusCell = prevRow.children[_cellIndex].children[0];
1270
- if (DomHandler.hasClass(_focusCell, 'p-disabled')) {
1271
- navigation.current = {
1272
- backward: true
1273
- };
1274
- navBackward(event);
1275
- } else {
1276
- _focusCell.tabIndex = '0';
1277
- _focusCell.focus();
1278
- }
1279
- } else {
1280
- navigation.current = {
1281
- backward: true
1282
- };
1283
- navBackward(event);
1284
- }
1285
- event.preventDefault();
1286
- break;
1287
- }
1288
-
1289
- //left arrow
1290
- case 37:
1291
- {
1292
- cellContent.tabIndex = '-1';
1293
- var prevCell = cell.previousElementSibling;
1294
- if (prevCell) {
1295
- var _focusCell2 = prevCell.children[0];
1296
- if (DomHandler.hasClass(_focusCell2, 'p-disabled')) {
1297
- navigateToMonth(true, groupIndex, event);
1298
- } else {
1299
- _focusCell2.tabIndex = '0';
1300
- _focusCell2.focus();
1301
- }
1302
- } else {
1303
- navigateToMonth(true, groupIndex, event);
1304
- }
1305
- event.preventDefault();
1306
- break;
1307
- }
1308
-
1309
- //right arrow
1310
- case 39:
1311
- {
1312
- cellContent.tabIndex = '-1';
1313
- var nextCell = cell.nextElementSibling;
1314
- if (nextCell) {
1315
- var _focusCell3 = nextCell.children[0];
1316
- if (DomHandler.hasClass(_focusCell3, 'p-disabled')) {
1317
- navigateToMonth(false, groupIndex, event);
1318
- } else {
1319
- _focusCell3.tabIndex = '0';
1320
- _focusCell3.focus();
1321
- }
1322
- } else {
1323
- navigateToMonth(false, groupIndex, event);
1324
- }
1325
- event.preventDefault();
1326
- break;
1327
- }
1328
-
1329
- //enter
1330
- case 13:
1331
- {
1332
- onDateSelect(event, date);
1333
- event.preventDefault();
1334
- break;
1335
- }
1336
-
1337
- //escape
1338
- case 27:
1339
- {
1340
- hide(null, reFocusInputField);
1341
- event.preventDefault();
1342
- break;
1343
- }
1344
-
1345
- //tab
1346
- case 9:
1347
- {
1348
- trapFocus(event);
1349
- break;
1350
- }
1351
- }
1352
- };
1353
- var navigateToMonth = function navigateToMonth(prev, groupIndex, event) {
1354
- if (prev) {
1355
- if (props.numberOfMonths === 1 || groupIndex === 0) {
1356
- navigation.current = {
1357
- backward: true
1358
- };
1359
- navBackward(event);
1360
- } else {
1361
- var prevMonthContainer = overlayRef.current.children[groupIndex - 1];
1362
- var cells = DomHandler.find(prevMonthContainer, 'table td span:not([data-p-disabled="true"])');
1363
- var focusCell = cells[cells.length - 1];
1364
- focusCell.tabIndex = '0';
1365
- focusCell.focus();
1366
- }
1367
- } else {
1368
- if (props.numberOfMonths === 1 || groupIndex === props.numberOfMonths - 1) {
1369
- navigation.current = {
1370
- backward: false
1371
- };
1372
- navForward(event);
1373
- } else {
1374
- var nextMonthContainer = overlayRef.current.children[groupIndex + 1];
1375
- var _focusCell4 = DomHandler.findSingle(nextMonthContainer, 'table td span:not([data-p-disabled="true"])');
1376
- _focusCell4.tabIndex = '0';
1377
- _focusCell4.focus();
1378
- }
1379
- }
1380
- };
1381
- var onMonthCellKeydown = function onMonthCellKeydown(event, index) {
1382
- var cell = event.currentTarget;
1383
- switch (event.which) {
1384
- //arrows
1385
- case 38:
1386
- case 40:
1387
- {
1388
- cell.tabIndex = '-1';
1389
- var cells = cell.parentElement.children;
1390
- var cellIndex = DomHandler.index(cell);
1391
- var nextCell = cells[event.which === 40 ? cellIndex + 3 : cellIndex - 3];
1392
- if (nextCell) {
1393
- nextCell.tabIndex = '0';
1394
- nextCell.focus();
1395
- }
1396
- event.preventDefault();
1397
- break;
1398
- }
1399
-
1400
- //left arrow
1401
- case 37:
1402
- {
1403
- cell.tabIndex = '-1';
1404
- var prevCell = cell.previousElementSibling;
1405
- if (prevCell) {
1406
- prevCell.tabIndex = '0';
1407
- prevCell.focus();
1408
- }
1409
- event.preventDefault();
1410
- break;
1411
- }
1412
-
1413
- //right arrow
1414
- case 39:
1415
- {
1416
- cell.tabIndex = '-1';
1417
- var _nextCell = cell.nextElementSibling;
1418
- if (_nextCell) {
1419
- _nextCell.tabIndex = '0';
1420
- _nextCell.focus();
1421
- }
1422
- event.preventDefault();
1423
- break;
1424
- }
1425
-
1426
- //enter
1427
- case 13:
1428
- {
1429
- onMonthSelect(event, index);
1430
- event.preventDefault();
1431
- break;
1432
- }
1433
-
1434
- //escape
1435
- case 27:
1436
- {
1437
- hide(null, reFocusInputField);
1438
- event.preventDefault();
1439
- break;
1440
- }
1441
-
1442
- //tab
1443
- case 9:
1444
- {
1445
- trapFocus(event);
1446
- break;
1447
- }
1448
- }
1449
- };
1450
- var onDateSelect = function onDateSelect(event, dateMeta, timeMeta) {
1451
- if (props.disabled || !dateMeta.selectable) {
1452
- event.preventDefault();
1453
- return;
1454
- }
1455
- DomHandler.find(overlayRef.current, 'table td span:not([data-p-disabled="true"])').forEach(function (cell) {
1456
- return cell.tabIndex = -1;
1457
- });
1458
- event.currentTarget.focus();
1459
- if (isMultipleSelection()) {
1460
- if (isSelected(dateMeta)) {
1461
- var value = props.value.filter(function (date, i) {
1462
- return !isDateEquals(date, dateMeta);
1463
- });
1464
- updateModel(event, value);
1465
- updateInputfield(value);
1466
- } else if (!props.maxDateCount || !props.value || props.maxDateCount > props.value.length) {
1467
- selectDate(event, dateMeta, timeMeta);
1468
- }
1469
- } else {
1470
- selectDate(event, dateMeta, timeMeta);
1471
- }
1472
- if (!props.inline && isSingleSelection() && (!props.showTime || props.hideOnDateTimeSelect)) {
1473
- setTimeout(function () {
1474
- hide('dateselect');
1475
- }, 100);
1476
- if (touchUIMask.current) {
1477
- disableModality();
1478
- }
1479
- }
1480
- event.preventDefault();
1481
- };
1482
- var selectTime = function selectTime(date, timeMeta) {
1483
- if (props.showTime) {
1484
- var hours, minutes, seconds, milliseconds;
1485
- if (timeMeta) {
1486
- hours = timeMeta.hours;
1487
- minutes = timeMeta.minutes;
1488
- seconds = timeMeta.seconds;
1489
- milliseconds = timeMeta.milliseconds;
1490
- } else {
1491
- var time = getCurrentDateTime();
1492
- var _ref2 = [time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds()];
1493
- hours = _ref2[0];
1494
- minutes = _ref2[1];
1495
- seconds = _ref2[2];
1496
- milliseconds = _ref2[3];
1497
- }
1498
- date.setHours(hours);
1499
- date.setMinutes(minutes);
1500
- date.setSeconds(seconds);
1501
- date.setMilliseconds(milliseconds);
1502
- }
1503
- };
1504
- var selectDate = function selectDate(event, dateMeta, timeMeta) {
1505
- var date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
1506
- selectTime(date, timeMeta);
1507
- if (props.minDate && props.minDate > date) {
1508
- date = props.minDate;
1509
- }
1510
- if (props.maxDate && props.maxDate < date) {
1511
- date = props.maxDate;
1512
- }
1513
- var selectedValues = date;
1514
- if (isSingleSelection()) {
1515
- updateModel(event, date);
1516
- } else if (isMultipleSelection()) {
1517
- selectedValues = props.value ? [].concat(_toConsumableArray(props.value), [date]) : [date];
1518
- updateModel(event, selectedValues);
1519
- } else if (isRangeSelection()) {
1520
- if (props.value && props.value.length) {
1521
- var startDate = props.value[0];
1522
- var endDate = props.value[1];
1523
- if (!endDate) {
1524
- if (date.getTime() >= startDate.getTime()) {
1525
- endDate = date;
1526
- } else {
1527
- endDate = startDate;
1528
- startDate = date;
1529
- }
1530
- } else {
1531
- startDate = date;
1532
- endDate = null;
1533
- }
1534
- selectedValues = [startDate, endDate];
1535
- updateModel(event, selectedValues);
1536
- } else {
1537
- selectedValues = [date, null];
1538
- updateModel(event, selectedValues);
1539
- }
1540
- }
1541
- if (props.onSelect) {
1542
- props.onSelect({
1543
- originalEvent: event,
1544
- value: date
1545
- });
1546
- }
1547
- updateInputfield(selectedValues);
1548
- };
1549
- var decrementDecade = function decrementDecade() {
1550
- var _currentYear = currentYear - 10;
1551
- setCurrentYear(_currentYear);
1552
- return _currentYear;
1553
- };
1554
- var incrementDecade = function incrementDecade() {
1555
- var _currentYear = currentYear + 10;
1556
- setCurrentYear(_currentYear);
1557
- return _currentYear;
1558
- };
1559
- var switchToMonthView = function switchToMonthView(event) {
1560
- setCurrentView('month');
1561
- event.preventDefault();
1562
- };
1563
- var switchToYearView = function switchToYearView(event) {
1564
- setCurrentView('year');
1565
- event.preventDefault();
1566
- };
1567
- var onMonthSelect = function onMonthSelect(event, month) {
1568
- if (props.view === 'month') {
1569
- onDateSelect(event, {
1570
- year: currentYear,
1571
- month: month,
1572
- day: 1,
1573
- selectable: true
1574
- });
1575
- event.preventDefault();
1576
- } else {
1577
- setCurrentMonth(month);
1578
- createMonthsMeta(month, currentYear);
1579
- var currentDate = cloneDate(getCurrentDateTime());
1580
- currentDate.setDate(1); // #2948 always set to 1st of month
1581
- currentDate.setMonth(month);
1582
- currentDate.setYear(currentYear);
1583
- setViewDateState(currentDate);
1584
- setCurrentView('date');
1585
- props.onMonthChange && props.onMonthChange({
1586
- month: month + 1,
1587
- year: currentYear
1588
- });
1589
- }
1590
- };
1591
- var onYearSelect = function onYearSelect(event, year) {
1592
- if (props.view === 'year') {
1593
- onDateSelect(event, {
1594
- year: year,
1595
- month: 0,
1596
- day: 1,
1597
- selectable: true
1598
- });
1599
- } else {
1600
- setCurrentYear(year);
1601
- setCurrentView('month');
1602
- props.onMonthChange && props.onMonthChange({
1603
- month: currentMonth + 1,
1604
- year: year
1605
- });
1606
- }
1607
- };
1608
- var updateModel = function updateModel(event, value) {
1609
- if (props.onChange) {
1610
- var newValue = cloneDate(value);
1611
- viewStateChanged.current = true;
1612
- onChangeRef.current({
1613
- originalEvent: event,
1614
- value: newValue,
1615
- stopPropagation: function stopPropagation() {
1616
- event.stopPropagation();
1617
- },
1618
- preventDefault: function preventDefault() {
1619
- event.preventDefault();
1620
- },
1621
- target: {
1622
- name: props.name,
1623
- id: props.id,
1624
- value: newValue
1625
- }
1626
- });
1627
- }
1628
- };
1629
- var show = function show(type) {
1630
- if (props.onVisibleChange) {
1631
- props.onVisibleChange({
1632
- visible: true,
1633
- type: type
1634
- });
1635
- } else {
1636
- setOverlayVisibleState(true);
1637
- overlayEventListener.current = function (e) {
1638
- if (!isOutsideClicked(e)) {
1639
- isOverlayClicked.current = true;
1640
- }
1641
- };
1642
- OverlayService.on('overlay-click', overlayEventListener.current);
1643
- }
1644
- };
1645
- var hide = function hide(type, callback) {
1646
- var _hideCallback = function _hideCallback() {
1647
- viewStateChanged.current = false;
1648
- ignoreFocusFunctionality.current = false;
1649
- isOverlayClicked.current = false;
1650
- callback && callback();
1651
- OverlayService.off('overlay-click', overlayEventListener.current);
1652
- overlayEventListener.current = null;
1653
- };
1654
- props.touchUI && disableModality();
1655
- if (props.onVisibleChange) {
1656
- props.onVisibleChange({
1657
- visible: type !== 'dateselect',
1658
- // false only if selecting a value to close panel
1659
- type: type,
1660
- callback: _hideCallback
1661
- });
1662
- } else {
1663
- setOverlayVisibleState(false);
1664
- _hideCallback();
1665
- }
1666
- };
1667
- var onOverlayEnter = function onOverlayEnter() {
1668
- var styles = props.touchUI ? {
1669
- position: 'fixed',
1670
- top: '50%',
1671
- left: '50%',
1672
- transform: 'translate(-50%, -50%)'
1673
- } : !props.inline ? {
1674
- position: 'absolute',
1675
- top: '0',
1676
- left: '0'
1677
- } : undefined;
1678
- DomHandler.addStyles(overlayRef.current, styles);
1679
- if (props.autoZIndex) {
1680
- var key = props.touchUI ? 'modal' : 'overlay';
1681
- ZIndexUtils.set(key, overlayRef.current, context && context.autoZIndex || PrimeReact.autoZIndex, props.baseZIndex || context && context.zIndex[key] || PrimeReact.zIndex[key]);
1682
- }
1683
- alignOverlay();
1684
- };
1685
- var onOverlayEntered = function onOverlayEntered() {
1686
- bindOverlayListener();
1687
- props.onShow && props.onShow();
1688
- DomHandler.focusFirstElement(overlayRef.current);
1689
- setFocusedState(false);
1690
- };
1691
- var onOverlayExit = function onOverlayExit() {
1692
- unbindOverlayListener();
1693
- };
1694
- var onOverlayExited = function onOverlayExited() {
1695
- ZIndexUtils.clear(overlayRef.current);
1696
- props.onHide && props.onHide();
1697
- };
1698
- var appendDisabled = function appendDisabled() {
1699
- return props.appendTo === 'self' || props.inline;
1700
- };
1701
- var alignOverlay = function alignOverlay() {
1702
- if (props.touchUI) {
1703
- enableModality();
1704
- } else if (overlayRef && overlayRef.current && inputRef && inputRef.current) {
1705
- DomHandler.alignOverlay(overlayRef.current, inputRef.current, props.appendTo || context && context.appendTo || PrimeReact.appendTo);
1706
- if (appendDisabled()) {
1707
- DomHandler.relativePosition(overlayRef.current, inputRef.current);
1708
- } else {
1709
- if (props.view === 'date') {
1710
- overlayRef.current.style.width = DomHandler.getOuterWidth(overlayRef.current) + 'px';
1711
- overlayRef.current.style.minWidth = DomHandler.getOuterWidth(inputRef.current) + 'px';
1712
- } else {
1713
- overlayRef.current.style.width = DomHandler.getOuterWidth(inputRef.current) + 'px';
1714
- }
1715
- DomHandler.absolutePosition(overlayRef.current, inputRef.current);
1716
- }
1717
- }
1718
- };
1719
- var enableModality = function enableModality() {
1720
- if (!touchUIMask.current) {
1721
- touchUIMask.current = document.createElement('div');
1722
- touchUIMask.current.style.zIndex = String(ZIndexUtils.get(overlayRef.current) - 1);
1723
- !isUnstyled() && DomHandler.addMultipleClasses(touchUIMask.current, 'p-component-overlay p-datepicker-mask p-datepicker-mask-scrollblocker p-component-overlay-enter');
1724
- touchUIMaskClickListener.current = function () {
1725
- disableModality();
1726
- hide();
1727
- };
1728
- touchUIMask.current.addEventListener('click', touchUIMaskClickListener.current);
1729
- document.body.appendChild(touchUIMask.current);
1730
- DomHandler.addClass(document.body, 'p-overflow-hidden');
1731
- document.body.style.setProperty('--scrollbar-width', DomHandler.calculateScrollbarWidth() + 'px');
1732
- }
1733
- };
1734
- var disableModality = function disableModality() {
1735
- if (touchUIMask.current) {
1736
- if (isUnstyled) {
1737
- destroyMask();
1738
- } else {
1739
- DomHandler.addClass(touchUIMask.current, 'p-component-overlay-leave');
1740
- touchUIMask.current.addEventListener('animationend', function () {
1741
- destroyMask();
1742
- });
1743
- }
1744
- }
1745
- };
1746
- var destroyMask = function destroyMask() {
1747
- if (touchUIMask.current) {
1748
- touchUIMask.current.removeEventListener('click', touchUIMaskClickListener.current);
1749
- touchUIMaskClickListener.current = null;
1750
- document.body.removeChild(touchUIMask.current);
1751
- touchUIMask.current = null;
1752
- }
1753
- var bodyChildren = document.body.children;
1754
- var hasBlockerMasks;
1755
- for (var i = 0; i < bodyChildren.length; i++) {
1756
- var bodyChild = bodyChildren[i];
1757
- if (DomHandler.hasClass(bodyChild, 'p-datepicker-mask-scrollblocker')) {
1758
- hasBlockerMasks = true;
1759
- break;
1760
- }
1761
- }
1762
- if (!hasBlockerMasks) {
1763
- DomHandler.removeClass(document.body, 'p-overflow-hidden');
1764
- document.body.style.removeProperty('--scrollbar-width');
1765
- }
1766
- };
1767
- var isOutsideClicked = function isOutsideClicked(event) {
1768
- return elementRef.current && !(elementRef.current.isSameNode(event.target) || isNavIconClicked(event.target) || elementRef.current.contains(event.target) || overlayRef.current && overlayRef.current.contains(event.target));
1769
- };
1770
- var isNavIconClicked = function isNavIconClicked(target) {
1771
- return previousButton.current && (previousButton.current.isSameNode(target) || previousButton.current.contains(target)) || nextButton.current && (nextButton.current.isSameNode(target) || nextButton.current.contains(target));
1772
- };
1773
- var getFirstDayOfMonthIndex = function getFirstDayOfMonthIndex(month, year) {
1774
- var day = new Date();
1775
- day.setDate(1);
1776
- day.setMonth(month);
1777
- day.setFullYear(year);
1778
- var dayIndex = day.getDay() + getSundayIndex();
1779
- return dayIndex >= 7 ? dayIndex - 7 : dayIndex;
1780
- };
1781
- var getDaysCountInMonth = function getDaysCountInMonth(month, year) {
1782
- return 32 - daylightSavingAdjust(new Date(year, month, 32)).getDate();
1783
- };
1784
- var getDaysCountInPrevMonth = function getDaysCountInPrevMonth(month, year) {
1785
- var prev = getPreviousMonthAndYear(month, year);
1786
- return getDaysCountInMonth(prev.month, prev.year);
1787
- };
1788
- var daylightSavingAdjust = function daylightSavingAdjust(date) {
1789
- if (!date) {
1790
- return null;
1791
- }
1792
- date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
1793
- return date;
1794
- };
1795
- var getPreviousMonthAndYear = function getPreviousMonthAndYear(month, year) {
1796
- var m, y;
1797
- if (month === 0) {
1798
- m = 11;
1799
- y = year - 1;
1800
- } else {
1801
- m = month - 1;
1802
- y = year;
1803
- }
1804
- return {
1805
- month: m,
1806
- year: y
1807
- };
1808
- };
1809
- var getNextMonthAndYear = function getNextMonthAndYear(month, year) {
1810
- var m, y;
1811
- if (month === 11) {
1812
- m = 0;
1813
- y = year + 1;
1814
- } else {
1815
- m = month + 1;
1816
- y = year;
1817
- }
1818
- return {
1819
- month: m,
1820
- year: y
1821
- };
1822
- };
1823
- var getSundayIndex = function getSundayIndex() {
1824
- var firstDayOfWeek = localeOption('firstDayOfWeek', props.locale);
1825
- return firstDayOfWeek > 0 ? 7 - firstDayOfWeek : 0;
1826
- };
1827
- var createWeekDaysMeta = function createWeekDaysMeta() {
1828
- var weekDays = [];
1829
- var _localeOptions = localeOptions(props.locale),
1830
- dayIndex = _localeOptions.firstDayOfWeek,
1831
- dayNamesMin = _localeOptions.dayNamesMin;
1832
- for (var i = 0; i < 7; i++) {
1833
- weekDays.push(dayNamesMin[dayIndex]);
1834
- dayIndex = dayIndex === 6 ? 0 : ++dayIndex;
1835
- }
1836
- return weekDays;
1837
- };
1838
- var createMonthsMeta = function createMonthsMeta(month, year) {
1839
- var months = [];
1840
- for (var i = 0; i < props.numberOfMonths; i++) {
1841
- var m = month + i;
1842
- var y = year;
1843
- if (m > 11) {
1844
- m = m % 11 - 1;
1845
- y = year + 1;
1846
- }
1847
- months.push(createMonthMeta(m, y));
1848
- }
1849
- return months;
1850
- };
1851
- var createMonthMeta = function createMonthMeta(month, year) {
1852
- var dates = [];
1853
- var firstDay = getFirstDayOfMonthIndex(month, year);
1854
- var daysLength = getDaysCountInMonth(month, year);
1855
- var prevMonthDaysLength = getDaysCountInPrevMonth(month, year);
1856
- var dayNo = 1;
1857
- var today = new Date();
1858
- var weekNumbers = [];
1859
- var monthRows = Math.ceil((daysLength + firstDay) / 7);
1860
- for (var i = 0; i < monthRows; i++) {
1861
- var week = [];
1862
- if (i === 0) {
1863
- for (var j = prevMonthDaysLength - firstDay + 1; j <= prevMonthDaysLength; j++) {
1864
- var prev = getPreviousMonthAndYear(month, year);
1865
- week.push({
1866
- day: j,
1867
- month: prev.month,
1868
- year: prev.year,
1869
- otherMonth: true,
1870
- today: isToday(today, j, prev.month, prev.year),
1871
- selectable: isSelectable(j, prev.month, prev.year, true)
1872
- });
1873
- }
1874
- var remainingDaysLength = 7 - week.length;
1875
- for (var _j = 0; _j < remainingDaysLength; _j++) {
1876
- week.push({
1877
- day: dayNo,
1878
- month: month,
1879
- year: year,
1880
- today: isToday(today, dayNo, month, year),
1881
- selectable: isSelectable(dayNo, month, year, false)
1882
- });
1883
- dayNo++;
1884
- }
1885
- } else {
1886
- for (var _j2 = 0; _j2 < 7; _j2++) {
1887
- if (dayNo > daysLength) {
1888
- var next = getNextMonthAndYear(month, year);
1889
- week.push({
1890
- day: dayNo - daysLength,
1891
- month: next.month,
1892
- year: next.year,
1893
- otherMonth: true,
1894
- today: isToday(today, dayNo - daysLength, next.month, next.year),
1895
- selectable: isSelectable(dayNo - daysLength, next.month, next.year, true)
1896
- });
1897
- } else {
1898
- week.push({
1899
- day: dayNo,
1900
- month: month,
1901
- year: year,
1902
- today: isToday(today, dayNo, month, year),
1903
- selectable: isSelectable(dayNo, month, year, false)
1904
- });
1905
- }
1906
- dayNo++;
1907
- }
1908
- }
1909
- if (props.showWeek) {
1910
- weekNumbers.push(getWeekNumber(new Date(week[0].year, week[0].month, week[0].day)));
1911
- }
1912
- dates.push(week);
1913
- }
1914
- return {
1915
- month: month,
1916
- year: year,
1917
- dates: dates,
1918
- weekNumbers: weekNumbers
1919
- };
1920
- };
1921
- var getWeekNumber = function getWeekNumber(date) {
1922
- var checkDate = cloneDate(date);
1923
- checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
1924
- var time = checkDate.getTime();
1925
- checkDate.setMonth(0);
1926
- checkDate.setDate(1);
1927
- return Math.floor(Math.round((time - checkDate.getTime()) / 86400000) / 7) + 1;
1928
- };
1929
- var isSelectable = function isSelectable(day, month, year, otherMonth) {
1930
- var validMin = true;
1931
- var validMax = true;
1932
- var validDate = true;
1933
- var validDay = true;
1934
- var validMonth = true;
1935
- if (props.minDate) {
1936
- if (props.minDate.getFullYear() > year) {
1937
- validMin = false;
1938
- } else if (props.minDate.getFullYear() === year) {
1939
- if (month > -1 && props.minDate.getMonth() > month) {
1940
- validMin = false;
1941
- } else if (month > -1 && props.minDate.getMonth() === month) {
1942
- if (day > 0 && props.minDate.getDate() > day) {
1943
- validMin = false;
1944
- }
1945
- }
1946
- }
1947
- }
1948
- if (props.maxDate) {
1949
- if (props.maxDate.getFullYear() < year) {
1950
- validMax = false;
1951
- } else if (props.maxDate.getFullYear() === year) {
1952
- if (month > -1 && props.maxDate.getMonth() < month) {
1953
- validMax = false;
1954
- } else if (month > -1 && props.maxDate.getMonth() === month) {
1955
- if (day > 0 && props.maxDate.getDate() < day) {
1956
- validMax = false;
1957
- }
1958
- }
1959
- }
1960
- }
1961
- if (props.disabledDates || props.enabledDates) {
1962
- validDate = !isDateDisabled(day, month, year);
1963
- }
1964
- if (props.disabledDays && currentView === 'date') {
1965
- validDay = !isDayDisabled(day, month, year);
1966
- }
1967
- if (props.selectOtherMonths === false && otherMonth) {
1968
- validMonth = false;
1969
- }
1970
- return validMin && validMax && validDate && validDay && validMonth;
1971
- };
1972
- var isSelectableTime = function isSelectableTime(value) {
1973
- var validMin = true;
1974
- var validMax = true;
1975
- if (props.minDate && props.minDate.toDateString() === value.toDateString()) {
1976
- if (props.minDate.getHours() > value.getHours()) {
1977
- validMin = false;
1978
- } else if (props.minDate.getHours() === value.getHours()) {
1979
- if (props.minDate.getMinutes() > value.getMinutes()) {
1980
- validMin = false;
1981
- } else if (props.minDate.getMinutes() === value.getMinutes()) {
1982
- if (props.minDate.getSeconds() > value.getSeconds()) {
1983
- validMin = false;
1984
- } else if (props.minDate.getSeconds() === value.getSeconds()) {
1985
- if (props.minDate.getMilliseconds() > value.getMilliseconds()) {
1986
- validMin = false;
1987
- }
1988
- }
1989
- }
1990
- }
1991
- }
1992
- if (props.maxDate && props.maxDate.toDateString() === value.toDateString()) {
1993
- if (props.maxDate.getHours() < value.getHours()) {
1994
- validMax = false;
1995
- } else if (props.maxDate.getHours() === value.getHours()) {
1996
- if (props.maxDate.getMinutes() < value.getMinutes()) {
1997
- validMax = false;
1998
- } else if (props.maxDate.getMinutes() === value.getMinutes()) {
1999
- if (props.maxDate.getSeconds() < value.getSeconds()) {
2000
- validMax = false;
2001
- } else if (props.maxDate.getSeconds() === value.getSeconds()) {
2002
- if (props.maxDate.getMilliseconds() < value.getMilliseconds()) {
2003
- validMax = false;
2004
- }
2005
- }
2006
- }
2007
- }
2008
- }
2009
- return validMin && validMax;
2010
- };
2011
- var isSelected = function isSelected(dateMeta) {
2012
- if (props.value) {
2013
- if (isSingleSelection()) {
2014
- return isDateEquals(props.value, dateMeta);
2015
- } else if (isMultipleSelection()) {
2016
- var selected = false;
2017
- var _iterator = _createForOfIteratorHelper(props.value),
2018
- _step;
2019
- try {
2020
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2021
- var date = _step.value;
2022
- selected = isDateEquals(date, dateMeta);
2023
- if (selected) {
2024
- break;
2025
- }
2026
- }
2027
- } catch (err) {
2028
- _iterator.e(err);
2029
- } finally {
2030
- _iterator.f();
2031
- }
2032
- return selected;
2033
- } else if (isRangeSelection()) {
2034
- if (props.value[1]) return isDateEquals(props.value[0], dateMeta) || isDateEquals(props.value[1], dateMeta) || isDateBetween(props.value[0], props.value[1], dateMeta);else {
2035
- return isDateEquals(props.value[0], dateMeta);
2036
- }
2037
- }
2038
- } else {
2039
- return false;
2040
- }
2041
- };
2042
- var isComparable = function isComparable() {
2043
- return props.value != null && typeof props.value !== 'string';
2044
- };
2045
- var isMonthSelected = function isMonthSelected(month) {
2046
- if (isComparable()) {
2047
- var value = isRangeSelection() ? props.value[0] : props.value;
2048
- if (isMultipleSelection()) {
2049
- return value.some(function (currentValue) {
2050
- return currentValue.getMonth() === month && currentValue.getFullYear() === currentYear;
2051
- });
2052
- } else {
2053
- return value.getMonth() === month && value.getFullYear() === currentYear;
2054
- }
2055
- }
2056
- return false;
2057
- };
2058
- var isYearSelected = function isYearSelected(year) {
2059
- if (isComparable()) {
2060
- var value = isRangeSelection() ? props.value[0] : props.value;
2061
- if (isMultipleSelection()) {
2062
- return value.some(function (currentValue) {
2063
- return currentValue.getFullYear() === year;
2064
- });
2065
- } else {
2066
- return value.getFullYear() === year;
2067
- }
2068
- }
2069
- return false;
2070
- };
2071
- var switchViewButtonDisabled = function switchViewButtonDisabled() {
2072
- return props.numberOfMonths > 1 || props.disabled;
2073
- };
2074
- var isDateEquals = function isDateEquals(value, dateMeta) {
2075
- if (value && value instanceof Date) return value.getDate() === dateMeta.day && value.getMonth() === dateMeta.month && value.getFullYear() === dateMeta.year;else return false;
2076
- };
2077
- var isDateBetween = function isDateBetween(start, end, dateMeta) {
2078
- var between = false;
2079
- if (start && end) {
2080
- var date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
2081
- return start.getTime() <= date.getTime() && end.getTime() >= date.getTime();
2082
- }
2083
- return between;
2084
- };
2085
- var isSingleSelection = function isSingleSelection() {
2086
- return props.selectionMode === 'single';
2087
- };
2088
- var isRangeSelection = function isRangeSelection() {
2089
- return props.selectionMode === 'range';
2090
- };
2091
- var isMultipleSelection = function isMultipleSelection() {
2092
- return props.selectionMode === 'multiple';
2093
- };
2094
- var isToday = function isToday(today, day, month, year) {
2095
- return today.getDate() === day && today.getMonth() === month && today.getFullYear() === year;
2096
- };
2097
- var isDateDisabled = function isDateDisabled(day, month, year) {
2098
- if (props.disabledDates) {
2099
- return props.disabledDates.some(function (d) {
2100
- return d.getFullYear() === year && d.getMonth() === month && d.getDate() === day;
2101
- });
2102
- }
2103
- if (props.enabledDates) {
2104
- return !props.enabledDates.some(function (d) {
2105
- return d.getFullYear() === year && d.getMonth() === month && d.getDate() === day;
2106
- });
2107
- }
2108
- return false;
2109
- };
2110
- var isDayDisabled = function isDayDisabled(day, month, year) {
2111
- if (props.disabledDays) {
2112
- var weekday = new Date(year, month, day);
2113
- var weekdayNumber = weekday.getDay();
2114
- return props.disabledDays.indexOf(weekdayNumber) !== -1;
2115
- }
2116
- return false;
2117
- };
2118
- var updateInputfield = function updateInputfield(value) {
2119
- if (!inputRef.current) {
2120
- return;
2121
- }
2122
- var formattedValue = '';
2123
- if (value) {
2124
- try {
2125
- if (isSingleSelection()) {
2126
- formattedValue = isValidDate(value) ? formatDateTime(value) : props.keepInvalid ? value : '';
2127
- } else if (isMultipleSelection()) {
2128
- for (var i = 0; i < value.length; i++) {
2129
- var selectedValue = value[i];
2130
- var dateAsString = isValidDate(selectedValue) ? formatDateTime(selectedValue) : '';
2131
- formattedValue += dateAsString;
2132
- if (i !== value.length - 1) {
2133
- formattedValue += ', ';
2134
- }
2135
- }
2136
- } else if (isRangeSelection()) {
2137
- if (value && value.length) {
2138
- var startDate = value[0];
2139
- var endDate = value[1];
2140
- formattedValue = isValidDate(startDate) ? formatDateTime(startDate) : '';
2141
- if (endDate) {
2142
- formattedValue += isValidDate(endDate) ? ' - ' + formatDateTime(endDate) : '';
2143
- }
2144
- }
2145
- }
2146
- } catch (err) {
2147
- formattedValue = value;
2148
- }
2149
- }
2150
- inputRef.current.value = formattedValue;
2151
- };
2152
- var formatDateTime = function formatDateTime(date) {
2153
- if (props.formatDateTime) {
2154
- return props.formatDateTime(date);
2155
- }
2156
- var formattedValue = null;
2157
- if (date) {
2158
- if (props.timeOnly) {
2159
- formattedValue = formatTime(date);
2160
- } else {
2161
- formattedValue = formatDate(date, getDateFormat());
2162
- if (props.showTime) {
2163
- formattedValue += ' ' + formatTime(date);
2164
- }
2165
- }
2166
- }
2167
- return formattedValue;
2168
- };
2169
- var formatDate = function formatDate(date, format) {
2170
- if (!date) {
2171
- return '';
2172
- }
2173
- var iFormat;
2174
- var lookAhead = function lookAhead(match) {
2175
- var matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
2176
- if (matches) {
2177
- iFormat++;
2178
- }
2179
- return matches;
2180
- },
2181
- formatNumber = function formatNumber(match, value, len) {
2182
- var num = '' + value;
2183
- if (lookAhead(match)) {
2184
- while (num.length < len) {
2185
- num = '0' + num;
2186
- }
2187
- }
2188
- return num;
2189
- },
2190
- formatName = function formatName(match, value, shortNames, longNames) {
2191
- return lookAhead(match) ? longNames[value] : shortNames[value];
2192
- };
2193
- var output = '';
2194
- var literal = false;
2195
- var _localeOptions2 = localeOptions(props.locale),
2196
- dayNamesShort = _localeOptions2.dayNamesShort,
2197
- dayNames = _localeOptions2.dayNames,
2198
- monthNamesShort = _localeOptions2.monthNamesShort,
2199
- monthNames = _localeOptions2.monthNames;
2200
- if (date) {
2201
- for (iFormat = 0; iFormat < format.length; iFormat++) {
2202
- if (literal) {
2203
- if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
2204
- literal = false;
2205
- } else {
2206
- output += format.charAt(iFormat);
2207
- }
2208
- } else {
2209
- switch (format.charAt(iFormat)) {
2210
- case 'd':
2211
- output += formatNumber('d', date.getDate(), 2);
2212
- break;
2213
- case 'D':
2214
- output += formatName('D', date.getDay(), dayNamesShort, dayNames);
2215
- break;
2216
- case 'o':
2217
- output += formatNumber('o', Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
2218
- break;
2219
- case 'm':
2220
- output += formatNumber('m', date.getMonth() + 1, 2);
2221
- break;
2222
- case 'M':
2223
- output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
2224
- break;
2225
- case 'y':
2226
- output += lookAhead('y') ? date.getFullYear() : (date.getFullYear() % 100 < 10 ? '0' : '') + date.getFullYear() % 100;
2227
- break;
2228
- case '@':
2229
- output += date.getTime();
2230
- break;
2231
- case '!':
2232
- output += date.getTime() * 10000 + ticksTo1970;
2233
- break;
2234
- case "'":
2235
- if (lookAhead("'")) {
2236
- output += "'";
2237
- } else {
2238
- literal = true;
2239
- }
2240
- break;
2241
- default:
2242
- output += format.charAt(iFormat);
2243
- }
2244
- }
2245
- }
2246
- }
2247
- return output;
2248
- };
2249
- var formatTime = function formatTime(date) {
2250
- if (!date) {
2251
- return '';
2252
- }
2253
- var output = '';
2254
- var hours = date.getHours();
2255
- var minutes = date.getMinutes();
2256
- var seconds = date.getSeconds();
2257
- var milliseconds = date.getMilliseconds();
2258
- if (props.hourFormat === '12' && hours > 11 && hours !== 12) {
2259
- hours -= 12;
2260
- }
2261
- if (props.hourFormat === '12') {
2262
- output += hours === 0 ? 12 : hours < 10 ? '0' + hours : hours;
2263
- } else {
2264
- output += hours < 10 ? '0' + hours : hours;
2265
- }
2266
- output += ':';
2267
- output += minutes < 10 ? '0' + minutes : minutes;
2268
- if (props.showSeconds) {
2269
- output += ':';
2270
- output += seconds < 10 ? '0' + seconds : seconds;
2271
- }
2272
- if (props.showMillisec) {
2273
- output += '.';
2274
- output += milliseconds < 100 ? (milliseconds < 10 ? '00' : '0') + milliseconds : milliseconds;
2275
- }
2276
- if (props.hourFormat === '12') {
2277
- output += date.getHours() > 11 ? ' PM' : ' AM';
2278
- }
2279
- return output;
2280
- };
2281
- var parseValueFromString = function parseValueFromString(text) {
2282
- if (!text || text.trim().length === 0) {
2283
- return null;
2284
- }
2285
- var value;
2286
- if (isSingleSelection()) {
2287
- value = parseDateTime(text);
2288
- } else if (isMultipleSelection()) {
2289
- var tokens = text.split(',');
2290
- value = [];
2291
- var _iterator2 = _createForOfIteratorHelper(tokens),
2292
- _step2;
2293
- try {
2294
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2295
- var token = _step2.value;
2296
- value.push(parseDateTime(token.trim()));
2297
- }
2298
- } catch (err) {
2299
- _iterator2.e(err);
2300
- } finally {
2301
- _iterator2.f();
2302
- }
2303
- } else if (isRangeSelection()) {
2304
- var _tokens = text.split(' - ');
2305
- value = [];
2306
- for (var i = 0; i < _tokens.length; i++) {
2307
- value[i] = parseDateTime(_tokens[i].trim());
2308
- }
2309
- }
2310
- return value;
2311
- };
2312
- var parseDateTime = function parseDateTime(text) {
2313
- if (props.parseDateTime) {
2314
- return props.parseDateTime(text);
2315
- }
2316
- var date;
2317
- var parts = text.split(' ');
2318
- if (props.timeOnly) {
2319
- date = new Date();
2320
- populateTime(date, parts[0], parts[1]);
2321
- } else {
2322
- if (props.showTime) {
2323
- date = parseDate(parts[0], getDateFormat());
2324
- populateTime(date, parts[1], parts[2]);
2325
- } else {
2326
- date = parseDate(text, getDateFormat());
2327
- }
2328
- }
2329
- return date;
2330
- };
2331
- var populateTime = function populateTime(value, timeString, ampm) {
2332
- if (props.hourFormat === '12' && ampm !== 'PM' && ampm !== 'AM') {
2333
- throw new Error('Invalid Time');
2334
- }
2335
- var time = parseTime(timeString, ampm);
2336
- value.setHours(time.hour);
2337
- value.setMinutes(time.minute);
2338
- value.setSeconds(time.second);
2339
- value.setMilliseconds(time.millisecond);
2340
- };
2341
- var parseTime = function parseTime(value, ampm) {
2342
- value = props.showMillisec ? value.replace('.', ':') : value;
2343
- var tokens = value.split(':');
2344
- var validTokenLength = props.showSeconds ? 3 : 2;
2345
- validTokenLength = props.showMillisec ? validTokenLength + 1 : validTokenLength;
2346
- if (tokens.length !== validTokenLength || tokens[0].length !== 2 || tokens[1].length !== 2 || props.showSeconds && tokens[2].length !== 2 || props.showMillisec && tokens[3].length !== 3) {
2347
- throw new Error('Invalid time');
2348
- }
2349
- var h = parseInt(tokens[0], 10);
2350
- var m = parseInt(tokens[1], 10);
2351
- var s = props.showSeconds ? parseInt(tokens[2], 10) : null;
2352
- var ms = props.showMillisec ? parseInt(tokens[3], 10) : null;
2353
- if (isNaN(h) || isNaN(m) || h > 23 || m > 59 || props.hourFormat === '12' && h > 12 || props.showSeconds && (isNaN(s) || s > 59) || props.showMillisec && (isNaN(s) || s > 1000)) {
2354
- throw new Error('Invalid time');
2355
- } else {
2356
- if (props.hourFormat === '12' && h !== 12 && ampm === 'PM') {
2357
- h += 12;
2358
- }
2359
- return {
2360
- hour: h,
2361
- minute: m,
2362
- second: s,
2363
- millisecond: ms
2364
- };
2365
- }
2366
- };
2367
-
2368
- // Ported from jquery-ui datepicker parseDate
2369
- var parseDate = function parseDate(value, format) {
2370
- if (format == null || value == null) {
2371
- throw new Error('Invalid arguments');
2372
- }
2373
- value = _typeof(value) === 'object' ? value.toString() : value + '';
2374
- if (value === '') {
2375
- return null;
2376
- }
2377
- var iFormat,
2378
- dim,
2379
- extra,
2380
- iValue = 0,
2381
- shortYearCutoff = typeof props.shortYearCutoff !== 'string' ? props.shortYearCutoff : new Date().getFullYear() % 100 + parseInt(props.shortYearCutoff, 10),
2382
- year = -1,
2383
- month = -1,
2384
- day = -1,
2385
- doy = -1,
2386
- literal = false,
2387
- date,
2388
- lookAhead = function lookAhead(match) {
2389
- var matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
2390
- if (matches) {
2391
- iFormat++;
2392
- }
2393
- return matches;
2394
- },
2395
- getNumber = function getNumber(match) {
2396
- var isDoubled = lookAhead(match),
2397
- size = match === '@' ? 14 : match === '!' ? 20 : match === 'y' && isDoubled ? 4 : match === 'o' ? 3 : 2,
2398
- minSize = match === 'y' ? size : 1,
2399
- digits = new RegExp('^\\d{' + minSize + ',' + size + '}'),
2400
- num = value.substring(iValue).match(digits);
2401
- if (!num) {
2402
- throw new Error('Missing number at position ' + iValue);
2403
- }
2404
- iValue += num[0].length;
2405
- return parseInt(num[0], 10);
2406
- },
2407
- getName = function getName(match, shortNames, longNames) {
2408
- var index = -1;
2409
- var arr = lookAhead(match) ? longNames : shortNames;
2410
- var names = [];
2411
- for (var i = 0; i < arr.length; i++) {
2412
- names.push([i, arr[i]]);
2413
- }
2414
- names.sort(function (a, b) {
2415
- return -(a[1].length - b[1].length);
2416
- });
2417
- for (var _i = 0; _i < names.length; _i++) {
2418
- var name = names[_i][1];
2419
- if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
2420
- index = names[_i][0];
2421
- iValue += name.length;
2422
- break;
2423
- }
2424
- }
2425
- if (index !== -1) {
2426
- return index + 1;
2427
- } else {
2428
- throw new Error('Unknown name at position ' + iValue);
2429
- }
2430
- },
2431
- checkLiteral = function checkLiteral() {
2432
- if (value.charAt(iValue) !== format.charAt(iFormat)) {
2433
- throw new Error('Unexpected literal at position ' + iValue);
2434
- }
2435
- iValue++;
2436
- };
2437
- if (props.view === 'month') {
2438
- day = 1;
2439
- }
2440
- if (props.view === 'year') {
2441
- day = 1;
2442
- month = 1;
2443
- }
2444
- var _localeOptions3 = localeOptions(props.locale),
2445
- dayNamesShort = _localeOptions3.dayNamesShort,
2446
- dayNames = _localeOptions3.dayNames,
2447
- monthNamesShort = _localeOptions3.monthNamesShort,
2448
- monthNames = _localeOptions3.monthNames;
2449
- for (iFormat = 0; iFormat < format.length; iFormat++) {
2450
- if (literal) {
2451
- if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
2452
- literal = false;
2453
- } else {
2454
- checkLiteral();
2455
- }
2456
- } else {
2457
- switch (format.charAt(iFormat)) {
2458
- case 'd':
2459
- day = getNumber('d');
2460
- break;
2461
- case 'D':
2462
- getName('D', dayNamesShort, dayNames);
2463
- break;
2464
- case 'o':
2465
- doy = getNumber('o');
2466
- break;
2467
- case 'm':
2468
- month = getNumber('m');
2469
- break;
2470
- case 'M':
2471
- month = getName('M', monthNamesShort, monthNames);
2472
- break;
2473
- case 'y':
2474
- year = getNumber('y');
2475
- break;
2476
- case '@':
2477
- date = new Date(getNumber('@'));
2478
- year = date.getFullYear();
2479
- month = date.getMonth() + 1;
2480
- day = date.getDate();
2481
- break;
2482
- case '!':
2483
- date = new Date((getNumber('!') - ticksTo1970) / 10000);
2484
- year = date.getFullYear();
2485
- month = date.getMonth() + 1;
2486
- day = date.getDate();
2487
- break;
2488
- case "'":
2489
- if (lookAhead("'")) {
2490
- checkLiteral();
2491
- } else {
2492
- literal = true;
2493
- }
2494
- break;
2495
- default:
2496
- checkLiteral();
2497
- }
2498
- }
2499
- }
2500
- if (iValue < value.length) {
2501
- extra = value.substr(iValue);
2502
- if (!/^\s+/.test(extra)) {
2503
- throw new Error('Extra/unparsed characters found in date: ' + extra);
2504
- }
2505
- }
2506
- if (year === -1) {
2507
- year = new Date().getFullYear();
2508
- } else if (year < 100) {
2509
- year += new Date().getFullYear() - new Date().getFullYear() % 100 + (year <= shortYearCutoff ? 0 : -100);
2510
- }
2511
- if (doy > -1) {
2512
- month = 1;
2513
- day = doy;
2514
- do {
2515
- dim = getDaysCountInMonth(year, month - 1);
2516
- if (day <= dim) {
2517
- break;
2518
- }
2519
- month++;
2520
- day -= dim;
2521
- } while (true);
2522
- }
2523
- date = daylightSavingAdjust(new Date(year, month - 1, day));
2524
- if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
2525
- throw new Error('Invalid date'); // E.g. 31/02/00
2526
- }
2527
-
2528
- return date;
2529
- };
2530
- var isInMinYear = function isInMinYear(viewDate) {
2531
- return props.minDate && props.minDate.getFullYear() === viewDate.getFullYear();
2532
- };
2533
- var isInMaxYear = function isInMaxYear(viewDate) {
2534
- return props.maxDate && props.maxDate.getFullYear() === viewDate.getFullYear();
2535
- };
2536
- React.useEffect(function () {
2537
- ObjectUtils.combinedRefs(inputRef, props.inputRef);
2538
- }, [inputRef, props.inputRef]);
2539
- useMountEffect(function () {
2540
- var viewDate = getViewDate(props.viewDate);
2541
- validateDate(viewDate);
2542
- setViewDateState(viewDate);
2543
- setCurrentMonth(viewDate.getMonth());
2544
- setCurrentYear(viewDate.getFullYear());
2545
- setCurrentView(props.view);
2546
- if (props.inline) {
2547
- overlayRef && overlayRef.current.setAttribute(attributeSelector, '');
2548
- if (!props.disabled) {
2549
- initFocusableCell();
2550
- if (props.numberOfMonths === 1) {
2551
- overlayRef.current.style.width = DomHandler.getOuterWidth(overlayRef.current) + 'px';
2552
- }
2553
- }
2554
- }
2555
- if (props.value) {
2556
- updateInputfield(props.value);
2557
- setValue(props.value);
2558
- }
2559
- if (props.autoFocus) {
2560
- // delay showing until rendered so `alignPanel()` method aligns the popup in the right location
2561
- setTimeout(function () {
2562
- return DomHandler.focus(inputRef.current, props.autoFocus);
2563
- }, 200);
2564
- }
2565
- });
2566
- React.useEffect(function () {
2567
- // see https://github.com/primefaces/primereact/issues/4030
2568
- onChangeRef.current = props.onChange;
2569
- }, [props.onChange]);
2570
- React.useEffect(function () {
2571
- var unbindMaskEvents = null;
2572
- if (props.mask) {
2573
- unbindMaskEvents = mask(inputRef.current, {
2574
- mask: props.mask,
2575
- slotChar: props.maskSlotChar,
2576
- readOnly: props.readOnlyInput || props.disabled,
2577
- onChange: function onChange(e) {
2578
- !ignoreMaskChange.current && updateValueOnInput(e.originalEvent, e.value);
2579
- ignoreMaskChange.current = false;
2580
- },
2581
- onBlur: function onBlur() {
2582
- ignoreMaskChange.current = true;
2583
- }
2584
- }).unbindEvents;
2585
- }
2586
- return function () {
2587
- props.mask && unbindMaskEvents && unbindMaskEvents();
2588
- };
2589
- // eslint-disable-next-line react-hooks/exhaustive-deps
2590
- }, [props.disabled, props.mask, props.readOnlyInput]);
2591
- useUpdateEffect(function () {
2592
- setCurrentView(props.view);
2593
- }, [props.view]);
2594
- useUpdateEffect(function () {
2595
- if (!props.onViewDateChange && !viewStateChanged.current) {
2596
- setValue(props.value);
2597
- }
2598
- }, [props.onViewDateChange, props.value]);
2599
- useUpdateEffect(function () {
2600
- var newDate = props.value;
2601
- if (previousValue !== newDate) {
2602
- updateInputfield(newDate);
2603
-
2604
- // #3516 view date not updated when value set programatically
2605
- if (!visible && newDate) {
2606
- var viewDate = newDate;
2607
- if (isMultipleSelection()) {
2608
- if (newDate.length) {
2609
- viewDate = newDate[newDate.length - 1];
2610
- }
2611
- } else if (isRangeSelection()) {
2612
- if (newDate.length) {
2613
- var startDate = newDate[0];
2614
- var endDate = newDate[1];
2615
- viewDate = endDate || startDate;
2616
- }
2617
- }
2618
- if (viewDate instanceof Date) {
2619
- validateDate(viewDate);
2620
- setViewDateState(viewDate);
2621
- setCurrentMonth(viewDate.getMonth());
2622
- setCurrentYear(viewDate.getFullYear());
2623
- }
2624
- }
2625
- }
2626
- }, [props.value, visible]);
2627
- useUpdateEffect(function () {
2628
- updateInputfield(props.value);
2629
- }, [props.dateFormat, props.hourFormat, props.timeOnly, props.showSeconds, props.showMillisec, props.showTime]);
2630
- useUpdateEffect(function () {
2631
- if (overlayRef.current) {
2632
- setNavigationState(viewDateState);
2633
- updateFocus();
2634
- }
2635
- });
2636
- useUnmountEffect(function () {
2637
- if (touchUIMask.current) {
2638
- disableModality();
2639
- touchUIMask.current = null;
2640
- }
2641
- ZIndexUtils.clear(overlayRef.current);
2642
- });
2643
- React.useImperativeHandle(ref, function () {
2644
- return {
2645
- props: props,
2646
- show: show,
2647
- hide: hide,
2648
- getCurrentDateTime: getCurrentDateTime,
2649
- getViewDate: getViewDate,
2650
- updateViewDate: updateViewDate,
2651
- focus: function focus() {
2652
- return DomHandler.focus(inputRef.current);
2653
- },
2654
- getElement: function getElement() {
2655
- return elementRef.current;
2656
- },
2657
- getOverlay: function getOverlay() {
2658
- return overlayRef.current;
2659
- },
2660
- getInput: function getInput() {
2661
- return inputRef.current;
2662
- }
2663
- };
2664
- });
2665
- var setValue = function setValue(propValue) {
2666
- if (Array.isArray(propValue)) {
2667
- propValue = propValue[0];
2668
- }
2669
- var prevPropValue = previousValue;
2670
- if (Array.isArray(prevPropValue)) {
2671
- prevPropValue = prevPropValue[0];
2672
- }
2673
- if (!prevPropValue && propValue || propValue && propValue instanceof Date && propValue.getTime() !== prevPropValue.getTime()) {
2674
- var viewDate = props.viewDate && isValidDate(props.viewDate) ? props.viewDate : propValue && isValidDate(propValue) ? propValue : new Date();
2675
- validateDate(viewDate);
2676
- setViewDateState(viewDate);
2677
- viewStateChanged.current = true;
2678
- }
2679
- };
2680
- var createBackwardNavigator = function createBackwardNavigator(isVisible) {
2681
- var navigatorProps = isVisible ? {
2682
- onClick: onPrevButtonClick,
2683
- onKeyDown: function onKeyDown(e) {
2684
- return onContainerButtonKeydown(e);
2685
- }
2686
- } : {
2687
- style: {
2688
- visibility: 'hidden'
2689
- }
2690
- };
2691
- var previousIconProps = mergeProps({
2692
- className: cx('previousIcon')
2693
- }, ptm('previousIcon'));
2694
- var icon = props.prevIcon || /*#__PURE__*/React.createElement(ChevronLeftIcon, previousIconProps);
2695
- var backwardNavigatorIcon = IconUtils.getJSXIcon(icon, _objectSpread({}, previousIconProps), {
2696
- props: props
2697
- });
2698
- var previousButtonProps = mergeProps(_objectSpread({
2699
- type: 'button',
2700
- className: cx('previousButton')
2701
- }, navigatorProps), ptm('previousButton'));
2702
- return /*#__PURE__*/React.createElement("button", _extends({
2703
- ref: previousButton
2704
- }, previousButtonProps), backwardNavigatorIcon, /*#__PURE__*/React.createElement(Ripple, null));
2705
- };
2706
- var createForwardNavigator = function createForwardNavigator(isVisible) {
2707
- var navigatorProps = isVisible ? {
2708
- onClick: onNextButtonClick,
2709
- onKeyDown: function onKeyDown(e) {
2710
- return onContainerButtonKeydown(e);
2711
- }
2712
- } : {
2713
- style: {
2714
- visibility: 'hidden'
2715
- }
2716
- };
2717
- var nextIconProps = mergeProps({
2718
- className: cx('nextIcon')
2719
- }, ptm('nextIcon'));
2720
- var icon = props.nextIcon || /*#__PURE__*/React.createElement(ChevronRightIcon, nextIconProps);
2721
- var forwardNavigatorIcon = IconUtils.getJSXIcon(icon, _objectSpread({}, nextIconProps), {
2722
- props: props
2723
- });
2724
- var nextButtonProps = mergeProps(_objectSpread({
2725
- type: 'button',
2726
- className: cx('nextButton')
2727
- }, navigatorProps), ptm('nextButton'));
2728
- return /*#__PURE__*/React.createElement("button", _extends({
2729
- ref: nextButton
2730
- }, nextButtonProps), forwardNavigatorIcon, /*#__PURE__*/React.createElement(Ripple, null));
2731
- };
2732
- var createTitleMonthElement = function createTitleMonthElement(month) {
2733
- var monthNames = localeOption('monthNames', props.locale);
2734
- if (props.monthNavigator && props.view !== 'month') {
2735
- var viewDate = getViewDate();
2736
- var viewMonth = viewDate.getMonth();
2737
- var displayedMonthOptions = monthNames.map(function (month, index) {
2738
- return (!isInMinYear(viewDate) || index >= props.minDate.getMonth()) && (!isInMaxYear(viewDate) || index <= props.maxDate.getMonth()) ? {
2739
- label: month,
2740
- value: index,
2741
- index: index
2742
- } : null;
2743
- }).filter(function (option) {
2744
- return !!option;
2745
- });
2746
- var displayedMonthNames = displayedMonthOptions.map(function (option) {
2747
- return option.label;
2748
- });
2749
- var selectProps = mergeProps({
2750
- className: cx('select'),
2751
- onChange: function onChange(e) {
2752
- return onMonthDropdownChange(e, e.target.value);
2753
- },
2754
- value: viewMonth
2755
- }, ptm('select'));
2756
- var _content = /*#__PURE__*/React.createElement("select", selectProps, displayedMonthOptions.map(function (option) {
2757
- var optionProps = mergeProps({
2758
- value: option.value
2759
- }, ptm('option'));
2760
- return /*#__PURE__*/React.createElement("option", _extends({}, optionProps, {
2761
- key: option.label
2762
- }), option.label);
2763
- }));
2764
- if (props.monthNavigatorTemplate) {
2765
- var defaultContentOptions = {
2766
- onChange: onMonthDropdownChange,
2767
- className: 'p-datepicker-month',
2768
- value: viewMonth,
2769
- names: displayedMonthNames,
2770
- options: displayedMonthOptions,
2771
- element: _content,
2772
- props: props
2773
- };
2774
- return ObjectUtils.getJSXElement(props.monthNavigatorTemplate, defaultContentOptions);
2775
- }
2776
- return _content;
2777
- }
2778
- var monthTitleProps = mergeProps({
2779
- className: cx('monthTitle'),
2780
- onClick: switchToMonthView,
2781
- disabled: switchViewButtonDisabled()
2782
- }, ptm('monthTitle'));
2783
- return currentView === 'date' && /*#__PURE__*/React.createElement("button", monthTitleProps, monthNames[month]);
2784
- };
2785
- var createTitleYearElement = function createTitleYearElement(metaYear) {
2786
- if (props.yearNavigator) {
2787
- var _yearOptions2 = [];
2788
- var years = props.yearRange.split(':');
2789
- var yearStart = parseInt(years[0], 10);
2790
- var yearEnd = parseInt(years[1], 10);
2791
- for (var i = yearStart; i <= yearEnd; i++) {
2792
- _yearOptions2.push(i);
2793
- }
2794
- var viewDate = getViewDate();
2795
- var viewYear = viewDate.getFullYear();
2796
- var displayedYearNames = _yearOptions2.filter(function (year) {
2797
- return !(props.minDate && props.minDate.getFullYear() > year) && !(props.maxDate && props.maxDate.getFullYear() < year);
2798
- });
2799
- var selectProps = mergeProps({
2800
- className: cx('select'),
2801
- onChange: function onChange(e) {
2802
- return onYearDropdownChange(e, e.target.value);
2803
- },
2804
- value: viewYear
2805
- }, ptm('select'));
2806
- var _content2 = /*#__PURE__*/React.createElement("select", selectProps, displayedYearNames.map(function (year) {
2807
- var optionProps = mergeProps({
2808
- value: year
2809
- }, ptm('option'));
2810
- return /*#__PURE__*/React.createElement("option", _extends({}, optionProps, {
2811
- key: year
2812
- }), year);
2813
- }));
2814
- if (props.yearNavigatorTemplate) {
2815
- var options = displayedYearNames.map(function (name, i) {
2816
- return {
2817
- label: name,
2818
- value: name,
2819
- index: i
2820
- };
2821
- });
2822
- var defaultContentOptions = {
2823
- onChange: onYearDropdownChange,
2824
- className: 'p-datepicker-year',
2825
- value: viewYear,
2826
- names: displayedYearNames,
2827
- options: options,
2828
- element: _content2,
2829
- props: props
2830
- };
2831
- return ObjectUtils.getJSXElement(props.yearNavigatorTemplate, defaultContentOptions);
2832
- }
2833
- return _content2;
2834
- }
2835
- var displayYear = props.numberOfMonths > 1 ? metaYear : currentYear;
2836
- var yearTitleProps = mergeProps({
2837
- className: cx('yearTitle'),
2838
- onClick: function onClick(e) {
2839
- return switchToYearView(e);
2840
- },
2841
- disabled: switchViewButtonDisabled()
2842
- }, ptm('yearTitle'));
2843
- return currentView !== 'year' && /*#__PURE__*/React.createElement("button", yearTitleProps, displayYear);
2844
- };
2845
- var createTitleDecadeElement = function createTitleDecadeElement() {
2846
- var years = yearPickerValues();
2847
- var decadeTitleProps = mergeProps({
2848
- className: cx('decadeTitle')
2849
- }, ptm('decadeTitle'));
2850
- if (currentView === 'year') {
2851
- var decadeTitleTextProps = mergeProps(ptm('decadeTitleText'));
2852
- return /*#__PURE__*/React.createElement("span", decadeTitleProps, props.decadeTemplate ? props.decadeTemplate(years) : /*#__PURE__*/React.createElement("span", decadeTitleTextProps, "".concat(yearPickerValues()[0], " - ").concat(yearPickerValues()[yearPickerValues().length - 1])));
2853
- }
2854
- return null;
2855
- };
2856
- var createTitle = function createTitle(monthMetaData) {
2857
- var month = createTitleMonthElement(monthMetaData.month);
2858
- var year = createTitleYearElement(monthMetaData.year);
2859
- var decade = createTitleDecadeElement();
2860
- var titleProps = mergeProps({
2861
- className: cx('title')
2862
- }, ptm('title'));
2863
- var showMonthAfterYear = localeOption('showMonthAfterYear', props.locale);
2864
- return /*#__PURE__*/React.createElement("div", titleProps, showMonthAfterYear ? year : month, showMonthAfterYear ? month : year, decade);
2865
- };
2866
- var createDayNames = function createDayNames(weekDays) {
2867
- var weekDayProps = mergeProps(ptm('weekDay'));
2868
- var tableHeaderCellProps = mergeProps({
2869
- scope: 'col'
2870
- }, ptm('tableHeaderCell'));
2871
- var dayNames = weekDays.map(function (weekDay, index) {
2872
- return /*#__PURE__*/React.createElement("th", _extends({}, tableHeaderCellProps, {
2873
- key: "".concat(weekDay, "-").concat(index)
2874
- }), /*#__PURE__*/React.createElement("span", weekDayProps, weekDay));
2875
- });
2876
- if (props.showWeek) {
2877
- var weekHeaderProps = mergeProps({
2878
- scope: 'col',
2879
- className: cx('weekHeader'),
2880
- 'data-p-disabled': props.showWeek
2881
- }, ptm('weekHeader', {
2882
- context: {
2883
- disabled: props.showWeek
2884
- }
2885
- }));
2886
- var weekLabel = mergeProps(ptm('weekLabel'));
2887
- var weekHeader = /*#__PURE__*/React.createElement("th", _extends({}, weekHeaderProps, {
2888
- key: "wn"
2889
- }), /*#__PURE__*/React.createElement("span", weekLabel, localeOption('weekHeader', props.locale)));
2890
- return [weekHeader].concat(_toConsumableArray(dayNames));
2891
- }
2892
- return dayNames;
2893
- };
2894
- var createDateCellContent = function createDateCellContent(date, className, groupIndex) {
2895
- var content = props.dateTemplate ? props.dateTemplate(date) : date.day;
2896
- var dayLabelProps = mergeProps({
2897
- className: cx('dayLabel', {
2898
- className: className
2899
- }),
2900
- onClick: function onClick(e) {
2901
- return onDateSelect(e, date);
2902
- },
2903
- onKeyDown: function onKeyDown(e) {
2904
- return onDateCellKeydown(e, date, groupIndex);
2905
- },
2906
- 'data-p-highlight': isSelected(date),
2907
- 'data-p-disabled': !date.selectable
2908
- }, ptm('dayLabel', {
2909
- context: {
2910
- selected: isSelected(date),
2911
- disabled: !date.selectable
2912
- }
2913
- }));
2914
- return /*#__PURE__*/React.createElement("span", dayLabelProps, content, /*#__PURE__*/React.createElement(Ripple, null));
2915
- };
2916
- var createWeek = function createWeek(weekDates, weekNumber, groupIndex) {
2917
- var week = weekDates.map(function (date) {
2918
- var selected = isSelected(date);
2919
- var dateClassName = classNames({
2920
- 'p-highlight': selected,
2921
- 'p-disabled': !date.selectable
2922
- });
2923
- var content = date.otherMonth && !props.showOtherMonths ? null : createDateCellContent(date, dateClassName, groupIndex);
2924
- var dayProps = mergeProps({
2925
- className: cx('day', {
2926
- date: date
2927
- }),
2928
- 'data-p-today': date.today,
2929
- 'data-p-other-month': date.otherMonth
2930
- }, ptm('day', {
2931
- context: {
2932
- date: date,
2933
- today: date.today,
2934
- otherMonth: date.otherMonth
2935
- }
2936
- }));
2937
- return /*#__PURE__*/React.createElement("td", _extends({}, dayProps, {
2938
- key: date.day
2939
- }), content);
2940
- });
2941
- if (props.showWeek) {
2942
- var weekNumberProps = mergeProps({
2943
- className: cx('weekNumber')
2944
- }, ptm('weekNumber'));
2945
- var weekLabelContainerProps = mergeProps({
2946
- className: cx('weekLabelContainer'),
2947
- 'data-p-disabled': props.showWeek
2948
- }, ptm('weekLabelContainer', {
2949
- context: {
2950
- disabled: props.showWeek
2951
- }
2952
- }));
2953
- var weekNumberCell = /*#__PURE__*/React.createElement("td", _extends({}, weekNumberProps, {
2954
- key: 'wn' + weekNumber
2955
- }), /*#__PURE__*/React.createElement("span", weekLabelContainerProps, weekNumber));
2956
- return [weekNumberCell].concat(_toConsumableArray(week));
2957
- }
2958
- return week;
2959
- };
2960
- var createDates = function createDates(monthMetaData, groupIndex) {
2961
- var tableBodyRowProps = mergeProps(ptm('tableBodyRowProps'));
2962
- return monthMetaData.dates.map(function (weekDates, index) {
2963
- return /*#__PURE__*/React.createElement("tr", _extends({}, tableBodyRowProps, {
2964
- key: index
2965
- }), createWeek(weekDates, monthMetaData.weekNumbers[index], groupIndex));
2966
- });
2967
- };
2968
- var createDateViewGrid = function createDateViewGrid(monthMetaData, weekDays, groupIndex) {
2969
- var dayNames = createDayNames(weekDays);
2970
- var dates = createDates(monthMetaData, groupIndex);
2971
- var containerProps = mergeProps({
2972
- className: cx('container'),
2973
- key: UniqueComponentId('calendar_container_')
2974
- }, ptm('container'));
2975
- var tableProps = mergeProps({
2976
- className: cx('table')
2977
- }, ptm('table'));
2978
- var tableHeaderProps = mergeProps(ptm('tableHeader'));
2979
- var tableHeaderRowProps = mergeProps(ptm('tableHeaderRow'));
2980
- var tableBodyProps = mergeProps(ptm('tableBody'));
2981
- return currentView === 'date' && /*#__PURE__*/React.createElement("div", containerProps, /*#__PURE__*/React.createElement("table", tableProps, /*#__PURE__*/React.createElement("thead", tableHeaderProps, /*#__PURE__*/React.createElement("tr", tableHeaderRowProps, dayNames)), /*#__PURE__*/React.createElement("tbody", tableBodyProps, dates)));
2982
- };
2983
- var createMonth = function createMonth(monthMetaData, index) {
2984
- var weekDays = createWeekDaysMeta();
2985
- var backwardNavigator = createBackwardNavigator(index === 0);
2986
- var forwardNavigator = createForwardNavigator(props.numberOfMonths === 1 || index === props.numberOfMonths - 1);
2987
- var title = createTitle(monthMetaData);
2988
- var dateViewGrid = createDateViewGrid(monthMetaData, weekDays, index);
2989
- var header = props.headerTemplate ? props.headerTemplate() : null;
2990
- var monthKey = monthMetaData.month + '-' + monthMetaData.year;
2991
- var groupProps = mergeProps({
2992
- className: cx('group')
2993
- }, ptm('group'));
2994
- var headerProps = mergeProps({
2995
- className: cx('header'),
2996
- key: index
2997
- }, ptm('header'));
2998
- return /*#__PURE__*/React.createElement("div", _extends({}, groupProps, {
2999
- key: monthKey
3000
- }), /*#__PURE__*/React.createElement("div", headerProps, header, backwardNavigator, title, forwardNavigator), dateViewGrid);
3001
- };
3002
- var createMonths = function createMonths(monthsMetaData) {
3003
- var groups = monthsMetaData.map(createMonth);
3004
- var groupContainerProps = mergeProps({
3005
- className: cx('groupContainer')
3006
- }, ptm('groupContainer'));
3007
- return /*#__PURE__*/React.createElement("div", groupContainerProps, groups);
3008
- };
3009
- var createDateView = function createDateView() {
3010
- var viewDate = getViewDate();
3011
- var monthsMetaData = createMonthsMeta(viewDate.getMonth(), viewDate.getFullYear());
3012
- var months = createMonths(monthsMetaData);
3013
- return months;
3014
- };
3015
- var monthPickerValues = function monthPickerValues() {
3016
- var monthPickerValues = [];
3017
- var monthNamesShort = localeOption('monthNamesShort', props.locale);
3018
- for (var i = 0; i <= 11; i++) {
3019
- monthPickerValues.push(monthNamesShort[i]);
3020
- }
3021
- return monthPickerValues;
3022
- };
3023
- var yearPickerValues = function yearPickerValues() {
3024
- var yearPickerValues = [];
3025
- var base = currentYear - currentYear % 10;
3026
- for (var i = 0; i < 10; i++) {
3027
- yearPickerValues.push(base + i);
3028
- }
3029
- return yearPickerValues;
3030
- };
3031
- var createMonthYearView = function createMonthYearView() {
3032
- var backwardNavigator = createBackwardNavigator(true);
3033
- var forwardNavigator = createForwardNavigator(true);
3034
- var yearElement = createTitleYearElement(getViewDate().getFullYear());
3035
- var decade = createTitleDecadeElement();
3036
- var groupContainerProps = mergeProps({
3037
- className: cx('groupContainer')
3038
- }, ptm('groupContainer'));
3039
- var groupProps = mergeProps({
3040
- className: cx('group')
3041
- }, ptm('group'));
3042
- var headerProps = mergeProps({
3043
- className: cx('header')
3044
- }, ptm('header'));
3045
- var titleProps = mergeProps({
3046
- className: cx('title')
3047
- }, ptm('title'));
3048
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", groupContainerProps, /*#__PURE__*/React.createElement("div", groupProps, /*#__PURE__*/React.createElement("div", headerProps, backwardNavigator, /*#__PURE__*/React.createElement("div", titleProps, yearElement, decade), forwardNavigator))));
3049
- };
3050
- var createDatePicker = function createDatePicker() {
3051
- if (!props.timeOnly) {
3052
- if (props.view === 'date') {
3053
- return createDateView();
3054
- } else {
3055
- return createMonthYearView();
3056
- }
3057
- }
3058
- return null;
3059
- };
3060
- var incrementIconProps = mergeProps(ptm('incrementIcon'));
3061
- var decrementIconProps = mergeProps(ptm('decrementIcon'));
3062
- var incrementIcon = IconUtils.getJSXIcon(props.incrementIcon || /*#__PURE__*/React.createElement(ChevronUpIcon, incrementIconProps), _objectSpread({}, incrementIconProps), {
3063
- props: props
3064
- });
3065
- var decrementIcon = IconUtils.getJSXIcon(props.decrementIcon || /*#__PURE__*/React.createElement(ChevronDownIcon, decrementIconProps), _objectSpread({}, decrementIconProps), {
3066
- props: props
3067
- });
3068
- var createHourPicker = function createHourPicker() {
3069
- var currentTime = getCurrentDateTime();
3070
- var minute = doStepMinute(currentTime.getMinutes());
3071
- var hour = currentTime.getHours();
3072
-
3073
- // #3770 account for step minutes rolling to next hour
3074
- hour = minute > 59 ? hour + 1 : hour;
3075
- if (props.hourFormat === '12') {
3076
- if (hour === 0) hour = 12;else if (hour > 11 && hour !== 12) hour = hour - 12;
3077
- }
3078
- var hourProps = mergeProps(ptm('hour'));
3079
- var hourDisplay = hour < 10 ? '0' + hour : hour;
3080
- var hourPickerProps = mergeProps({
3081
- className: cx('hourPicker')
3082
- }, ptm('hourPicker'));
3083
- var incrementButtonProps = mergeProps({
3084
- type: 'button',
3085
- className: cx('incrementButton'),
3086
- onMouseDown: function onMouseDown(e) {
3087
- return onTimePickerElementMouseDown(e, 0, 1);
3088
- },
3089
- onMouseUp: onTimePickerElementMouseUp,
3090
- onMouseLeave: onTimePickerElementMouseLeave,
3091
- onKeyDown: function onKeyDown(e) {
3092
- return onContainerButtonKeydown(e);
3093
- }
3094
- }, ptm('incrementButton'));
3095
- var decrementButtonProps = mergeProps({
3096
- type: 'button',
3097
- className: cx('decrementButton'),
3098
- onMouseDown: function onMouseDown(e) {
3099
- return onTimePickerElementMouseDown(e, 0, -1);
3100
- },
3101
- onMouseUp: onTimePickerElementMouseUp,
3102
- onMouseLeave: onTimePickerElementMouseLeave,
3103
- onKeyDown: function onKeyDown(e) {
3104
- return onContainerButtonKeydown(e);
3105
- }
3106
- }, ptm('decrementButton'));
3107
- return /*#__PURE__*/React.createElement("div", hourPickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", hourProps, hourDisplay), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
3108
- };
3109
- var createMinutePicker = function createMinutePicker() {
3110
- var currentTime = getCurrentDateTime();
3111
- var minute = doStepMinute(currentTime.getMinutes());
3112
- minute = minute > 59 ? minute - 60 : minute;
3113
- var minuteProps = mergeProps(ptm('minute'));
3114
- var minuteDisplay = minute < 10 ? '0' + minute : minute;
3115
- var minutePickerProps = mergeProps({
3116
- className: cx('minutePicker')
3117
- }, ptm('minutePicker'));
3118
- var incrementButtonProps = mergeProps({
3119
- type: 'button',
3120
- className: cx('incrementButton'),
3121
- onMouseDown: function onMouseDown(e) {
3122
- return onTimePickerElementMouseDown(e, 1, 1);
3123
- },
3124
- onMouseUp: onTimePickerElementMouseUp,
3125
- onMouseLeave: onTimePickerElementMouseLeave,
3126
- onKeyDown: function onKeyDown(e) {
3127
- return onContainerButtonKeydown(e);
3128
- }
3129
- }, ptm('incrementButton'));
3130
- var decrementButtonProps = mergeProps({
3131
- type: 'button',
3132
- className: cx('decrementButton'),
3133
- onMouseDown: function onMouseDown(e) {
3134
- return onTimePickerElementMouseDown(e, 1, -1);
3135
- },
3136
- onMouseUp: onTimePickerElementMouseUp,
3137
- onMouseLeave: onTimePickerElementMouseLeave,
3138
- onKeyDown: function onKeyDown(e) {
3139
- return onContainerButtonKeydown(e);
3140
- }
3141
- }, ptm('decrementButton'));
3142
- return /*#__PURE__*/React.createElement("div", minutePickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", minuteProps, minuteDisplay), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
3143
- };
3144
- var createSecondPicker = function createSecondPicker() {
3145
- if (props.showSeconds) {
3146
- var currentTime = getCurrentDateTime();
3147
- var secondProps = mergeProps(ptm('second'));
3148
- var second = currentTime.getSeconds();
3149
- var secondDisplay = second < 10 ? '0' + second : second;
3150
- var secondPickerProps = mergeProps({
3151
- className: cx('secondPicker')
3152
- }, ptm('secondPicker'));
3153
- var incrementButtonProps = mergeProps({
3154
- type: 'button',
3155
- className: cx('incrementButton'),
3156
- onMouseDown: function onMouseDown(e) {
3157
- return onTimePickerElementMouseDown(e, 2, 1);
3158
- },
3159
- onMouseUp: onTimePickerElementMouseUp,
3160
- onMouseLeave: onTimePickerElementMouseLeave,
3161
- onKeyDown: function onKeyDown(e) {
3162
- return onContainerButtonKeydown(e);
3163
- }
3164
- }, ptm('incrementButton'));
3165
- var decrementButtonProps = mergeProps({
3166
- type: 'button',
3167
- className: cx('decrementButton'),
3168
- onMouseDown: function onMouseDown(e) {
3169
- return onTimePickerElementMouseDown(e, 2, -1);
3170
- },
3171
- onMouseUp: onTimePickerElementMouseUp,
3172
- onMouseLeave: onTimePickerElementMouseLeave,
3173
- onKeyDown: function onKeyDown(e) {
3174
- return onContainerButtonKeydown(e);
3175
- }
3176
- }, ptm('decrementButton'));
3177
- return /*#__PURE__*/React.createElement("div", secondPickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", secondProps, secondDisplay), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
3178
- }
3179
- return null;
3180
- };
3181
- var createMiliSecondPicker = function createMiliSecondPicker() {
3182
- if (props.showMillisec) {
3183
- var currentTime = getCurrentDateTime();
3184
- var millisecondProps = mergeProps(ptm('millisecond'));
3185
- var millisecond = currentTime.getMilliseconds();
3186
- var millisecondDisplay = millisecond < 100 ? (millisecond < 10 ? '00' : '0') + millisecond : millisecond;
3187
- var millisecondPickerProps = mergeProps({
3188
- className: cx('millisecondPicker')
3189
- }, ptm('millisecondPicker'));
3190
- var incrementButtonProps = mergeProps({
3191
- type: 'button',
3192
- className: cx('incrementButton'),
3193
- onMouseDown: function onMouseDown(e) {
3194
- return onTimePickerElementMouseDown(e, 3, 1);
3195
- },
3196
- onMouseUp: onTimePickerElementMouseUp,
3197
- onMouseLeave: onTimePickerElementMouseLeave,
3198
- onKeyDown: function onKeyDown(e) {
3199
- return onContainerButtonKeydown(e);
3200
- }
3201
- }, ptm('incrementButton'));
3202
- var decrementButtonProps = mergeProps({
3203
- type: 'button',
3204
- className: cx('decrementButton'),
3205
- onMouseDown: function onMouseDown(e) {
3206
- return onTimePickerElementMouseDown(e, 3, -1);
3207
- },
3208
- onMouseUp: onTimePickerElementMouseUp,
3209
- onMouseLeave: onTimePickerElementMouseLeave,
3210
- onKeyDown: function onKeyDown(e) {
3211
- return onContainerButtonKeydown(e);
3212
- }
3213
- }, ptm('decrementButton'));
3214
- return /*#__PURE__*/React.createElement("div", millisecondPickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", millisecondProps, millisecondDisplay), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
3215
- }
3216
- return null;
3217
- };
3218
- var createAmPmPicker = function createAmPmPicker() {
3219
- if (props.hourFormat === '12') {
3220
- var currentTime = getCurrentDateTime();
3221
- var hour = currentTime.getHours();
3222
- var display = hour > 11 ? 'PM' : 'AM';
3223
- var ampmProps = mergeProps(ptm('ampm'));
3224
- var ampmPickerProps = mergeProps({
3225
- className: cx('ampmPicker')
3226
- }, ptm('ampmPicker'));
3227
- var incrementButtonProps = mergeProps({
3228
- type: 'button',
3229
- className: cx('incrementButton'),
3230
- onClick: function onClick(e) {
3231
- return toggleAmPm(e);
3232
- }
3233
- }, ptm('incrementButton'));
3234
- var decrementButtonProps = mergeProps({
3235
- type: 'button',
3236
- className: cx('decrementButton'),
3237
- onClick: function onClick(e) {
3238
- return toggleAmPm(e);
3239
- }
3240
- }, ptm('decrementButton'));
3241
- return /*#__PURE__*/React.createElement("div", ampmPickerProps, /*#__PURE__*/React.createElement("button", incrementButtonProps, incrementIcon, /*#__PURE__*/React.createElement(Ripple, null)), /*#__PURE__*/React.createElement("span", ampmProps, display), /*#__PURE__*/React.createElement("button", decrementButtonProps, decrementIcon, /*#__PURE__*/React.createElement(Ripple, null)));
3242
- }
3243
- return null;
3244
- };
3245
- var createSeparator = function createSeparator(separator) {
3246
- var separatorContainerProps = mergeProps({
3247
- className: cx('separatorContainer')
3248
- }, ptm('separatorContainer'));
3249
- var separatorProps = mergeProps(ptm('separator'));
3250
- return /*#__PURE__*/React.createElement("div", separatorContainerProps, /*#__PURE__*/React.createElement("span", separatorProps, separator));
3251
- };
3252
- var createTimePicker = function createTimePicker() {
3253
- if ((props.showTime || props.timeOnly) && currentView === 'date') {
3254
- var timePickerProps = mergeProps({
3255
- className: cx('timePicker')
3256
- }, ptm('timePicker'));
3257
- return /*#__PURE__*/React.createElement("div", timePickerProps, createHourPicker(), createSeparator(':'), createMinutePicker(), props.showSeconds && createSeparator(':'), createSecondPicker(), props.showMillisec && createSeparator('.'), createMiliSecondPicker(), props.hourFormat === '12' && createSeparator(':'), createAmPmPicker());
3258
- }
3259
- return null;
3260
- };
3261
- var createInputElement = function createInputElement() {
3262
- if (!props.inline) {
3263
- return /*#__PURE__*/React.createElement(InputText, {
3264
- ref: inputRef,
3265
- id: props.inputId,
3266
- name: props.name,
3267
- type: "text",
3268
- className: props.inputClassName,
3269
- style: props.inputStyle,
3270
- readOnly: props.readOnlyInput,
3271
- disabled: props.disabled,
3272
- required: props.required,
3273
- autoComplete: "off",
3274
- placeholder: props.placeholder,
3275
- tabIndex: props.tabIndex,
3276
- onInput: onUserInput,
3277
- onFocus: onInputFocus,
3278
- onBlur: onInputBlur,
3279
- onKeyDown: onInputKeyDown,
3280
- "aria-labelledby": props.ariaLabelledBy,
3281
- inputMode: props.inputMode,
3282
- tooltip: props.tooltip,
3283
- tooltipOptions: props.tooltipOptions,
3284
- pt: ptm('input'),
3285
- __parentMetadata: {
3286
- parent: metaData
3287
- }
3288
- });
3289
- }
3290
- return null;
3291
- };
3292
- var createButton = function createButton() {
3293
- if (props.showIcon) {
3294
- return /*#__PURE__*/React.createElement(Button, {
3295
- type: "button",
3296
- icon: props.icon || /*#__PURE__*/React.createElement(CalendarIcon, null),
3297
- onClick: onButtonClick,
3298
- tabIndex: "-1",
3299
- disabled: props.disabled,
3300
- className: cx('dropdownButton'),
3301
- pt: ptm('dropdownButton'),
3302
- __parentMetadata: {
3303
- parent: metaData
3304
- }
3305
- });
3306
- }
3307
- return null;
3308
- };
3309
- var createContent = function createContent() {
3310
- var input = createInputElement();
3311
- var button = createButton();
3312
- if (props.iconPos === 'left') {
3313
- return /*#__PURE__*/React.createElement(React.Fragment, null, button, input);
3314
- }
3315
- return /*#__PURE__*/React.createElement(React.Fragment, null, input, button);
3316
- };
3317
- var createButtonBar = function createButtonBar() {
3318
- if (props.showButtonBar) {
3319
- var _localeOptions4 = localeOptions(props.locale),
3320
- today = _localeOptions4.today,
3321
- clear = _localeOptions4.clear;
3322
- var buttonbarProps = mergeProps({
3323
- className: cx('buttonbar')
3324
- }, ptm('buttonbar'));
3325
- return /*#__PURE__*/React.createElement("div", buttonbarProps, /*#__PURE__*/React.createElement(Button, {
3326
- type: "button",
3327
- label: today,
3328
- onClick: onTodayButtonClick,
3329
- onKeyDown: function onKeyDown(e) {
3330
- return onContainerButtonKeydown(e);
3331
- },
3332
- className: classNames(props.todayButtonClassName, cx('todayButton')),
3333
- pt: ptm('todayButton')
3334
- }), /*#__PURE__*/React.createElement(Button, {
3335
- type: "button",
3336
- label: clear,
3337
- onClick: onClearButtonClick,
3338
- onKeyDown: function onKeyDown(e) {
3339
- return onContainerButtonKeydown(e);
3340
- },
3341
- className: classNames(props.clearButtonClassName, cx('clearButton')),
3342
- pt: ptm('clearButton')
3343
- }));
3344
- }
3345
- return null;
3346
- };
3347
- var createFooter = function createFooter() {
3348
- if (props.footerTemplate) {
3349
- var _content3 = props.footerTemplate();
3350
- var footerProps = mergeProps({
3351
- className: cx('footer')
3352
- }, ptm('footer'));
3353
- return /*#__PURE__*/React.createElement("div", footerProps, _content3);
3354
- }
3355
- return null;
3356
- };
3357
- var createMonthPicker = function createMonthPicker() {
3358
- if (currentView === 'month') {
3359
- var monthPickerProps = mergeProps({
3360
- className: cx('monthPicker')
3361
- }, ptm('monthPicker'));
3362
- return /*#__PURE__*/React.createElement("div", monthPickerProps, monthPickerValues().map(function (m, i) {
3363
- var monthProps = mergeProps({
3364
- className: cx('month', {
3365
- isMonthSelected: isMonthSelected,
3366
- isSelectable: isSelectable,
3367
- i: i,
3368
- currentYear: currentYear
3369
- }),
3370
- onClick: function onClick(event) {
3371
- return onMonthSelect(event, i);
3372
- },
3373
- onKeyDown: function onKeyDown(event) {
3374
- return onMonthCellKeydown(event, i);
3375
- },
3376
- 'data-p-disabled': !m.selectable,
3377
- 'data-p-highlight': isMonthSelected(i)
3378
- }, ptm('month', {
3379
- context: {
3380
- month: m,
3381
- monthIndex: i,
3382
- selected: isMonthSelected(i),
3383
- disabled: !m.selectable
3384
- }
3385
- }));
3386
- return /*#__PURE__*/React.createElement("span", _extends({}, monthProps, {
3387
- key: "month".concat(i + 1)
3388
- }), m);
3389
- }));
3390
- }
3391
- return null;
3392
- };
3393
- var createYearPicker = function createYearPicker() {
3394
- if (currentView === 'year') {
3395
- var yearPickerProps = mergeProps({
3396
- className: cx('yearPicker')
3397
- }, ptm('yearPicker'));
3398
- return /*#__PURE__*/React.createElement("div", yearPickerProps, yearPickerValues().map(function (y, i) {
3399
- var yearProps = mergeProps({
3400
- className: cx('year', {
3401
- isYearSelected: isYearSelected,
3402
- isSelectable: isSelectable,
3403
- y: y
3404
- }),
3405
- onClick: function onClick(event) {
3406
- return onYearSelect(event, y);
3407
- },
3408
- 'data-p-highlight': isYearSelected(y),
3409
- 'data-p-disabled': !isSelectable(0, -1, y)
3410
- }, ptm('year', {
3411
- context: {
3412
- year: y,
3413
- yearIndex: i,
3414
- selected: isYearSelected(i),
3415
- disabled: !y.selectable
3416
- }
3417
- }));
3418
- return /*#__PURE__*/React.createElement("span", _extends({}, yearProps, {
3419
- key: "year".concat(i + 1)
3420
- }), y);
3421
- }));
3422
- }
3423
- return null;
3424
- };
3425
- var panelClassName = classNames('p-datepicker p-component', props.panelClassName, {
3426
- 'p-datepicker-inline': props.inline,
3427
- 'p-disabled': props.disabled,
3428
- 'p-datepicker-timeonly': props.timeOnly,
3429
- 'p-datepicker-multiple-month': props.numberOfMonths > 1,
3430
- 'p-datepicker-monthpicker': currentView === 'month',
3431
- 'p-datepicker-touch-ui': props.touchUI,
3432
- 'p-input-filled': context && context.inputStyle === 'filled' || PrimeReact.inputStyle === 'filled',
3433
- 'p-ripple-disabled': context && context.ripple === false || PrimeReact.ripple === false
3434
- });
3435
- var content = createContent();
3436
- var datePicker = createDatePicker();
3437
- var timePicker = createTimePicker();
3438
- var buttonBar = createButtonBar();
3439
- var footer = createFooter();
3440
- var monthPicker = createMonthPicker();
3441
- var yearPicker = createYearPicker();
3442
- var isFilled = DomHandler.hasClass(inputRef.current, 'p-filled') && inputRef.current.value !== '';
3443
- var rootProps = mergeProps({
3444
- id: props.id,
3445
- className: classNames(props.className, cx('root', {
3446
- focusedState: focusedState,
3447
- isFilled: isFilled
3448
- })),
3449
- style: props.style
3450
- }, CalendarBase.getOtherProps(props), ptm('root'));
3451
- return /*#__PURE__*/React.createElement("span", _extends({
3452
- ref: elementRef
3453
- }, rootProps), content, /*#__PURE__*/React.createElement(CalendarPanel, {
3454
- hostName: "Calendar",
3455
- ref: overlayRef,
3456
- className: panelClassName,
3457
- style: props.panelStyle,
3458
- appendTo: props.appendTo,
3459
- inline: props.inline,
3460
- onClick: onPanelClick,
3461
- onMouseUp: onPanelMouseUp,
3462
- "in": visible,
3463
- onEnter: onOverlayEnter,
3464
- onEntered: onOverlayEntered,
3465
- onExit: onOverlayExit,
3466
- onExited: onOverlayExited,
3467
- transitionOptions: props.transitionOptions,
3468
- ptm: ptm,
3469
- cx: cx
3470
- }, datePicker, timePicker, monthPicker, yearPicker, buttonBar, footer));
3471
- }));
3472
- Calendar.displayName = 'Calendar';
3473
-
3474
- export { Calendar };