@primereact/headless 11.0.0-alpha.9 → 11.0.0-rc.1

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 (592) hide show
  1. package/LICENSE.md +45 -0
  2. package/README.md +35 -0
  3. package/accordion/index.d.ts +3 -0
  4. package/accordion/index.mjs +1 -1
  5. package/accordion/index.mjs.map +1 -1
  6. package/accordion/useAccordion.d.ts +7 -6
  7. package/accordion/useAccordion.props.d.ts +2 -2
  8. package/accordion/useAccordionPanel.d.ts +46 -0
  9. package/accordion/useAccordionPanel.props.d.ts +2 -0
  10. package/animateonscroll/index.d.ts +1 -0
  11. package/animateonscroll/index.mjs +1 -1
  12. package/animateonscroll/index.mjs.map +1 -1
  13. package/animateonscroll/useAnimateOnScroll.d.ts +6 -1
  14. package/animateonscroll/useAnimateOnScroll.props.d.ts +2 -2
  15. package/autocomplete/index.d.ts +3 -0
  16. package/autocomplete/index.mjs +2 -0
  17. package/autocomplete/index.mjs.map +1 -0
  18. package/autocomplete/useAutoComplete.d.ts +198 -0
  19. package/autocomplete/useAutoComplete.props.d.ts +2 -0
  20. package/avatar/index.d.ts +1 -0
  21. package/avatar/index.mjs +1 -1
  22. package/avatar/index.mjs.map +1 -1
  23. package/avatar/useAvatar.d.ts +5 -1
  24. package/avatar/useAvatar.props.d.ts +2 -2
  25. package/avatargroup/index.d.ts +3 -0
  26. package/avatargroup/index.mjs +2 -0
  27. package/avatargroup/index.mjs.map +1 -0
  28. package/avatargroup/useAvatarGroup.d.ts +6 -0
  29. package/avatargroup/useAvatarGroup.props.d.ts +2 -0
  30. package/badge/index.d.ts +1 -0
  31. package/badge/index.mjs +1 -1
  32. package/badge/index.mjs.map +1 -1
  33. package/badge/useBadge.d.ts +7 -1
  34. package/badge/useBadge.props.d.ts +2 -2
  35. package/breadcrumb/index.d.ts +1 -0
  36. package/breadcrumb/index.mjs +1 -1
  37. package/breadcrumb/index.mjs.map +1 -1
  38. package/breadcrumb/useBreadcrumb.d.ts +18 -2
  39. package/breadcrumb/useBreadcrumb.props.d.ts +2 -2
  40. package/button/index.d.ts +1 -0
  41. package/button/index.mjs +1 -1
  42. package/button/index.mjs.map +1 -1
  43. package/button/useButton.d.ts +6 -1
  44. package/button/useButton.props.d.ts +2 -2
  45. package/card/index.d.ts +1 -0
  46. package/card/index.mjs +1 -1
  47. package/card/index.mjs.map +1 -1
  48. package/card/useCard.d.ts +6 -1
  49. package/card/useCard.props.d.ts +2 -2
  50. package/carousel/index.d.ts +1 -0
  51. package/carousel/index.mjs +1 -1
  52. package/carousel/index.mjs.map +1 -1
  53. package/carousel/useCarousel.d.ts +101 -5
  54. package/carousel/useCarousel.props.d.ts +2 -2
  55. package/checkbox/index.d.ts +1 -0
  56. package/checkbox/index.mjs +1 -1
  57. package/checkbox/index.mjs.map +1 -1
  58. package/checkbox/useCheckbox.d.ts +44 -3
  59. package/checkbox/useCheckbox.props.d.ts +2 -2
  60. package/checkboxgroup/index.d.ts +3 -0
  61. package/checkboxgroup/index.mjs +2 -0
  62. package/checkboxgroup/index.mjs.map +1 -0
  63. package/checkboxgroup/useCheckboxGroup.d.ts +11 -0
  64. package/checkboxgroup/useCheckboxGroup.props.d.ts +2 -0
  65. package/chip/index.d.ts +1 -0
  66. package/chip/index.mjs +1 -1
  67. package/chip/index.mjs.map +1 -1
  68. package/chip/useChip.d.ts +9 -3
  69. package/chip/useChip.props.d.ts +2 -2
  70. package/collapsible/index.d.ts +3 -0
  71. package/collapsible/index.mjs +2 -0
  72. package/collapsible/index.mjs.map +1 -0
  73. package/collapsible/useCollapsible.d.ts +33 -0
  74. package/collapsible/useCollapsible.props.d.ts +2 -0
  75. package/compare/index.d.ts +3 -0
  76. package/compare/index.mjs +2 -0
  77. package/compare/index.mjs.map +1 -0
  78. package/compare/useCompare.d.ts +2 -0
  79. package/compare/useCompare.props.d.ts +2 -0
  80. package/contextmenu/index.d.ts +1 -0
  81. package/contextmenu/index.mjs +1 -1
  82. package/contextmenu/index.mjs.map +1 -1
  83. package/contextmenu/submenu/index.d.ts +2 -0
  84. package/contextmenu/submenu/index.mjs +2 -0
  85. package/contextmenu/submenu/index.mjs.map +1 -0
  86. package/contextmenu/submenu/useContextMenuSubmenu.d.ts +121 -0
  87. package/contextmenu/submenu/useContextMenuSubmenu.props.d.ts +2 -0
  88. package/contextmenu/useContextMenu.d.ts +413 -1
  89. package/contextmenu/useContextMenu.props.d.ts +2 -2
  90. package/datatable/features/index.d.ts +28 -0
  91. package/datatable/features/index.mjs +11 -0
  92. package/datatable/features/index.mjs.map +1 -0
  93. package/datatable/features/useDataTableColumnReorder.d.ts +52 -0
  94. package/datatable/features/useDataTableColumnResize.d.ts +20 -0
  95. package/datatable/features/useDataTableEditing.d.ts +69 -0
  96. package/datatable/features/useDataTableExpansion.d.ts +32 -0
  97. package/datatable/features/useDataTableExport.d.ts +43 -0
  98. package/datatable/features/useDataTableFilter.d.ts +95 -0
  99. package/datatable/features/useDataTableGrouping.d.ts +11 -0
  100. package/datatable/features/useDataTableKeyboard.d.ts +23 -0
  101. package/datatable/features/useDataTablePagination.d.ts +32 -0
  102. package/datatable/features/useDataTableRowReorder.d.ts +42 -0
  103. package/datatable/features/useDataTableSelection.d.ts +28 -0
  104. package/datatable/features/useDataTableSort.d.ts +51 -0
  105. package/datatable/features/useDataTableTree.d.ts +31 -0
  106. package/datatable/index.d.ts +7 -0
  107. package/datatable/index.mjs +11 -0
  108. package/datatable/index.mjs.map +1 -0
  109. package/datatable/useDataTable.d.ts +237 -0
  110. package/datatable/useDataTable.props.d.ts +2 -0
  111. package/datatable/useDataTableRow.d.ts +30 -0
  112. package/datatable/useDataTableRow.props.d.ts +2 -0
  113. package/datatable/utils/compareValues.d.ts +20 -0
  114. package/datatable/utils/index.d.ts +1 -0
  115. package/datatable/utils/index.mjs +2 -0
  116. package/datatable/utils/index.mjs.map +1 -0
  117. package/dataview/index.d.ts +1 -0
  118. package/dataview/index.mjs +1 -1
  119. package/dataview/index.mjs.map +1 -1
  120. package/dataview/useDataView.d.ts +25 -1
  121. package/dataview/useDataView.props.d.ts +2 -2
  122. package/datepicker/index.d.ts +1 -0
  123. package/datepicker/index.mjs +1 -1
  124. package/datepicker/index.mjs.map +1 -1
  125. package/datepicker/useDatePicker.d.ts +2 -114
  126. package/datepicker/useDatePicker.props.d.ts +2 -2
  127. package/dialog/index.d.ts +1 -0
  128. package/dialog/index.mjs +1 -1
  129. package/dialog/index.mjs.map +1 -1
  130. package/dialog/useDialog.d.ts +274 -24
  131. package/dialog/useDialog.props.d.ts +2 -2
  132. package/divider/index.d.ts +1 -0
  133. package/divider/index.mjs +1 -1
  134. package/divider/index.mjs.map +1 -1
  135. package/divider/useDivider.d.ts +14 -1
  136. package/divider/useDivider.props.d.ts +2 -2
  137. package/dnd/index.d.ts +11 -0
  138. package/dnd/index.mjs +2 -0
  139. package/dnd/index.mjs.map +1 -0
  140. package/dnd/useDnd.d.ts +45 -0
  141. package/dnd/useDnd.props.d.ts +2 -0
  142. package/dnd/useDraggable.d.ts +14 -0
  143. package/dnd/useDraggable.props.d.ts +2 -0
  144. package/dnd/useDroppable.d.ts +11 -0
  145. package/dnd/useDroppable.props.d.ts +2 -0
  146. package/dnd/useSortable.d.ts +11 -0
  147. package/dnd/useSortable.props.d.ts +2 -0
  148. package/dnd/useSortableContainer.d.ts +24 -0
  149. package/dnd/useSortableContainer.props.d.ts +2 -0
  150. package/drawer/index.d.ts +1 -0
  151. package/drawer/index.mjs +1 -1
  152. package/drawer/index.mjs.map +1 -1
  153. package/drawer/useDrawer.d.ts +78 -16
  154. package/drawer/useDrawer.props.d.ts +2 -2
  155. package/fieldset/index.d.ts +1 -0
  156. package/fieldset/index.mjs +1 -1
  157. package/fieldset/index.mjs.map +1 -1
  158. package/fieldset/useFieldset.d.ts +80 -1
  159. package/fieldset/useFieldset.props.d.ts +2 -2
  160. package/fileupload/index.d.ts +1 -0
  161. package/fileupload/index.mjs +1 -1
  162. package/fileupload/index.mjs.map +1 -1
  163. package/fileupload/useFileUpload.d.ts +73 -4
  164. package/fileupload/useFileUpload.props.d.ts +2 -2
  165. package/floatlabel/index.d.ts +3 -0
  166. package/floatlabel/index.mjs +2 -0
  167. package/floatlabel/index.mjs.map +1 -0
  168. package/floatlabel/useFloatLabel.d.ts +6 -0
  169. package/floatlabel/useFloatLabel.props.d.ts +2 -0
  170. package/fluid/index.d.ts +1 -0
  171. package/fluid/index.mjs +1 -1
  172. package/fluid/index.mjs.map +1 -1
  173. package/fluid/useFluid.d.ts +6 -1
  174. package/fluid/useFluid.props.d.ts +2 -2
  175. package/focustrap/index.d.ts +1 -0
  176. package/focustrap/index.mjs +1 -1
  177. package/focustrap/index.mjs.map +1 -1
  178. package/focustrap/useFocusTrap.d.ts +16 -3
  179. package/focustrap/useFocusTrap.props.d.ts +2 -2
  180. package/gallery/index.d.ts +1 -0
  181. package/gallery/index.mjs +1 -1
  182. package/gallery/index.mjs.map +1 -1
  183. package/gallery/item/index.mjs +1 -1
  184. package/gallery/item/index.mjs.map +1 -1
  185. package/gallery/item/useGalleryItem.d.ts +17 -7
  186. package/gallery/item/useGalleryItem.props.d.ts +2 -2
  187. package/gallery/useGallery.d.ts +147 -6
  188. package/gallery/useGallery.props.d.ts +2 -2
  189. package/iconfield/index.d.ts +1 -0
  190. package/iconfield/index.mjs +1 -1
  191. package/iconfield/index.mjs.map +1 -1
  192. package/iconfield/useIconField.d.ts +6 -1
  193. package/iconfield/useIconField.props.d.ts +2 -2
  194. package/iftalabel/index.d.ts +3 -0
  195. package/iftalabel/index.mjs +2 -0
  196. package/iftalabel/index.mjs.map +1 -0
  197. package/iftalabel/useIftaLabel.d.ts +6 -0
  198. package/iftalabel/useIftaLabel.props.d.ts +2 -0
  199. package/inplace/index.d.ts +1 -0
  200. package/inplace/index.mjs +1 -1
  201. package/inplace/index.mjs.map +1 -1
  202. package/inplace/useInplace.d.ts +21 -2
  203. package/inplace/useInplace.props.d.ts +2 -2
  204. package/{colorpicker → inputcolor}/colorManager.d.ts +3 -2
  205. package/inputcolor/index.d.ts +4 -0
  206. package/inputcolor/index.mjs +2 -0
  207. package/inputcolor/index.mjs.map +1 -0
  208. package/inputcolor/useInputColor.d.ts +119 -0
  209. package/inputcolor/useInputColor.props.d.ts +2 -0
  210. package/inputgroup/index.d.ts +1 -0
  211. package/inputgroup/index.mjs +1 -1
  212. package/inputgroup/index.mjs.map +1 -1
  213. package/inputgroup/useInputGroup.d.ts +6 -1
  214. package/inputgroup/useInputGroup.props.d.ts +2 -2
  215. package/inputnumber/index.d.ts +1 -0
  216. package/inputnumber/index.mjs +1 -1
  217. package/inputnumber/index.mjs.map +1 -1
  218. package/inputnumber/useInputNumber.d.ts +55 -17
  219. package/inputnumber/useInputNumber.props.d.ts +2 -2
  220. package/inputotp/index.d.ts +1 -0
  221. package/inputotp/index.mjs +1 -1
  222. package/inputotp/index.mjs.map +1 -1
  223. package/inputotp/useInputOtp.d.ts +25 -6
  224. package/inputotp/useInputOtp.props.d.ts +2 -2
  225. package/inputpassword/index.d.ts +3 -0
  226. package/inputpassword/index.mjs +2 -0
  227. package/inputpassword/index.mjs.map +1 -0
  228. package/inputpassword/useInputPassword.d.ts +15 -0
  229. package/inputpassword/useInputPassword.props.d.ts +2 -0
  230. package/inputtags/index.d.ts +1 -0
  231. package/inputtags/index.mjs +1 -1
  232. package/inputtags/index.mjs.map +1 -1
  233. package/inputtags/useInputTags.d.ts +42 -12
  234. package/inputtags/useInputTags.props.d.ts +2 -2
  235. package/inputtext/index.d.ts +1 -0
  236. package/inputtext/index.mjs +1 -1
  237. package/inputtext/index.mjs.map +1 -1
  238. package/inputtext/useInputText.d.ts +8 -1
  239. package/inputtext/useInputText.props.d.ts +2 -2
  240. package/knob/index.d.ts +1 -0
  241. package/knob/index.mjs +1 -1
  242. package/knob/index.mjs.map +1 -1
  243. package/knob/useKnob.d.ts +51 -10
  244. package/knob/useKnob.props.d.ts +2 -2
  245. package/label/index.d.ts +1 -0
  246. package/label/index.mjs +1 -1
  247. package/label/index.mjs.map +1 -1
  248. package/label/useLabel.d.ts +6 -1
  249. package/label/useLabel.props.d.ts +2 -2
  250. package/listbox/index.d.ts +3 -0
  251. package/listbox/index.mjs +1 -1
  252. package/listbox/index.mjs.map +1 -1
  253. package/listbox/useListbox.d.ts +56 -18
  254. package/listbox/useListbox.props.d.ts +2 -2
  255. package/listbox/useListboxOption.d.ts +21 -0
  256. package/listbox/useListboxOption.props.d.ts +2 -0
  257. package/menu/checkboxitem/index.d.ts +2 -0
  258. package/menu/checkboxitem/index.mjs +2 -0
  259. package/menu/checkboxitem/index.mjs.map +1 -0
  260. package/menu/checkboxitem/useMenuCheckboxItem.d.ts +112 -0
  261. package/menu/checkboxitem/useMenuCheckboxItem.props.d.ts +2 -0
  262. package/menu/index.d.ts +1 -0
  263. package/menu/index.mjs +1 -1
  264. package/menu/index.mjs.map +1 -1
  265. package/menu/radioitem/index.d.ts +2 -0
  266. package/menu/radioitem/index.mjs +2 -0
  267. package/menu/radioitem/index.mjs.map +1 -0
  268. package/menu/radioitem/useMenuRadioItem.d.ts +106 -0
  269. package/menu/radioitem/useMenuRadioItem.props.d.ts +2 -0
  270. package/menu/submenu/index.d.ts +2 -0
  271. package/menu/submenu/index.mjs +2 -0
  272. package/menu/submenu/index.mjs.map +1 -0
  273. package/menu/submenu/useMenuSubmenu.d.ts +97 -0
  274. package/menu/submenu/useMenuSubmenu.props.d.ts +2 -0
  275. package/menu/useMenu.d.ts +215 -22
  276. package/menu/useMenu.props.d.ts +2 -2
  277. package/message/index.d.ts +1 -0
  278. package/message/index.mjs +1 -1
  279. package/message/index.mjs.map +1 -1
  280. package/message/useMessage.d.ts +13 -1
  281. package/message/useMessage.props.d.ts +2 -2
  282. package/metergroup/index.d.ts +1 -0
  283. package/metergroup/index.mjs +1 -1
  284. package/metergroup/index.mjs.map +1 -1
  285. package/metergroup/useMeterGroup.d.ts +36 -5
  286. package/metergroup/useMeterGroup.props.d.ts +2 -2
  287. package/navigationmenu/index.d.ts +3 -0
  288. package/navigationmenu/index.mjs +2 -0
  289. package/navigationmenu/index.mjs.map +1 -0
  290. package/navigationmenu/useNavigationMenu.d.ts +30 -0
  291. package/navigationmenu/useNavigationMenu.props.d.ts +2 -0
  292. package/orderlist/index.d.ts +3 -0
  293. package/orderlist/index.mjs +2 -0
  294. package/orderlist/index.mjs.map +1 -0
  295. package/orderlist/useOrderList.d.ts +73 -0
  296. package/orderlist/useOrderList.props.d.ts +2 -0
  297. package/organizationchart/index.d.ts +3 -0
  298. package/organizationchart/index.mjs +2 -0
  299. package/organizationchart/index.mjs.map +1 -0
  300. package/organizationchart/useOrganizationChart.d.ts +69 -0
  301. package/organizationchart/useOrganizationChart.props.d.ts +2 -0
  302. package/overlaybadge/index.d.ts +3 -0
  303. package/overlaybadge/index.mjs +2 -0
  304. package/overlaybadge/index.mjs.map +1 -0
  305. package/overlaybadge/useOverlayBadge.d.ts +1 -0
  306. package/overlaybadge/useOverlayBadge.props.d.ts +2 -0
  307. package/package.json +12 -15
  308. package/paginator/index.d.ts +1 -0
  309. package/paginator/index.mjs +1 -1
  310. package/paginator/index.mjs.map +1 -1
  311. package/paginator/usePaginator.d.ts +47 -1
  312. package/paginator/usePaginator.props.d.ts +2 -2
  313. package/panel/index.d.ts +1 -0
  314. package/panel/index.mjs +1 -1
  315. package/panel/index.mjs.map +1 -1
  316. package/panel/usePanel.d.ts +76 -8
  317. package/panel/usePanel.props.d.ts +2 -2
  318. package/picklist/index.d.ts +3 -0
  319. package/picklist/index.mjs +2 -0
  320. package/picklist/index.mjs.map +1 -0
  321. package/picklist/usePickList.d.ts +153 -0
  322. package/picklist/usePickList.props.d.ts +2 -0
  323. package/popover/index.d.ts +1 -0
  324. package/popover/index.mjs +1 -7
  325. package/popover/index.mjs.map +1 -1
  326. package/popover/usePopover.d.ts +65 -12
  327. package/popover/usePopover.props.d.ts +2 -2
  328. package/portal/index.d.ts +1 -0
  329. package/portal/index.mjs +1 -1
  330. package/portal/index.mjs.map +1 -1
  331. package/portal/usePortal.d.ts +4 -2
  332. package/portal/usePortal.props.d.ts +2 -2
  333. package/positioner/index.d.ts +3 -0
  334. package/positioner/index.mjs +2 -0
  335. package/positioner/index.mjs.map +1 -0
  336. package/positioner/usePositioner.anchor.d.ts +7 -0
  337. package/positioner/usePositioner.d.ts +11 -0
  338. package/positioner/usePositioner.fallback.d.ts +13 -0
  339. package/positioner/usePositioner.props.d.ts +2 -0
  340. package/positioner/usePositioner.utils.d.ts +21 -0
  341. package/progressbar/index.d.ts +1 -0
  342. package/progressbar/index.mjs +1 -1
  343. package/progressbar/index.mjs.map +1 -1
  344. package/progressbar/useProgressBar.d.ts +13 -1
  345. package/progressbar/useProgressBar.props.d.ts +2 -2
  346. package/progressspinner/index.d.ts +1 -0
  347. package/progressspinner/index.mjs +1 -1
  348. package/progressspinner/index.mjs.map +1 -1
  349. package/progressspinner/useProgressSpinner.d.ts +50 -1
  350. package/progressspinner/useProgressSpinner.props.d.ts +2 -2
  351. package/radiobutton/index.d.ts +1 -0
  352. package/radiobutton/index.mjs +1 -1
  353. package/radiobutton/index.mjs.map +1 -1
  354. package/radiobutton/useRadioButton.d.ts +41 -3
  355. package/radiobutton/useRadioButton.props.d.ts +2 -2
  356. package/radiobuttongroup/index.d.ts +3 -0
  357. package/radiobuttongroup/index.mjs +2 -0
  358. package/radiobuttongroup/index.mjs.map +1 -0
  359. package/radiobuttongroup/useRadioButtonGroup.d.ts +11 -0
  360. package/radiobuttongroup/useRadioButtonGroup.props.d.ts +2 -0
  361. package/rating/index.d.ts +3 -0
  362. package/rating/index.mjs +1 -1
  363. package/rating/index.mjs.map +1 -1
  364. package/rating/useRating.d.ts +46 -12
  365. package/rating/useRating.props.d.ts +2 -2
  366. package/rating/useRatingOption.d.ts +69 -0
  367. package/rating/useRatingOption.props.d.ts +2 -0
  368. package/scrollarea/index.d.ts +1 -0
  369. package/scrollarea/index.mjs +1 -1
  370. package/scrollarea/index.mjs.map +1 -1
  371. package/scrollarea/useScrollArea.d.ts +120 -15
  372. package/scrollarea/useScrollArea.props.d.ts +2 -2
  373. package/select/index.d.ts +3 -0
  374. package/select/index.mjs +2 -0
  375. package/select/index.mjs.map +1 -0
  376. package/select/useSelect.d.ts +190 -0
  377. package/select/useSelect.props.d.ts +2 -0
  378. package/select/useSelect.test.d.ts +1 -0
  379. package/sidebar/index.d.ts +7 -0
  380. package/sidebar/index.mjs +2 -0
  381. package/sidebar/index.mjs.map +1 -0
  382. package/sidebar/useSidebar.d.ts +117 -0
  383. package/sidebar/useSidebar.props.d.ts +2 -0
  384. package/sidebar/useSidebarLayout.d.ts +24 -0
  385. package/sidebar/useSidebarLayout.props.d.ts +2 -0
  386. package/sidebar/useSidebarMenuItem.d.ts +11 -0
  387. package/sidebar/useSidebarMenuItem.props.d.ts +2 -0
  388. package/skeleton/index.d.ts +1 -0
  389. package/skeleton/index.mjs +1 -1
  390. package/skeleton/index.mjs.map +1 -1
  391. package/skeleton/useSkeleton.d.ts +7 -1
  392. package/skeleton/useSkeleton.props.d.ts +2 -2
  393. package/slider/index.d.ts +1 -0
  394. package/slider/index.mjs +1 -1
  395. package/slider/index.mjs.map +1 -1
  396. package/slider/useSlider.d.ts +81 -48
  397. package/slider/useSlider.props.d.ts +2 -2
  398. package/speeddial/index.d.ts +1 -0
  399. package/speeddial/index.mjs +1 -1
  400. package/speeddial/index.mjs.map +1 -1
  401. package/speeddial/useSpeedDial.d.ts +89 -32
  402. package/speeddial/useSpeedDial.props.d.ts +2 -2
  403. package/splitter/index.d.ts +1 -0
  404. package/splitter/index.mjs +1 -1
  405. package/splitter/index.mjs.map +1 -1
  406. package/splitter/useSplitter.d.ts +57 -14
  407. package/splitter/useSplitter.props.d.ts +2 -2
  408. package/stepper/index.d.ts +1 -0
  409. package/stepper/index.mjs +1 -1
  410. package/stepper/index.mjs.map +1 -1
  411. package/stepper/useStepper.d.ts +47 -2
  412. package/stepper/useStepper.props.d.ts +2 -2
  413. package/styleclass/index.d.ts +1 -0
  414. package/styleclass/index.mjs +1 -1
  415. package/styleclass/index.mjs.map +1 -1
  416. package/styleclass/useStyleClass.d.ts +5 -1
  417. package/styleclass/useStyleClass.props.d.ts +2 -2
  418. package/tabs/index.d.ts +1 -0
  419. package/tabs/index.mjs +1 -1
  420. package/tabs/index.mjs.map +1 -1
  421. package/tabs/useTabs.d.ts +42 -3
  422. package/tabs/useTabs.props.d.ts +2 -2
  423. package/tag/index.d.ts +1 -0
  424. package/tag/index.mjs +1 -1
  425. package/tag/index.mjs.map +1 -1
  426. package/tag/useTag.d.ts +6 -1
  427. package/tag/useTag.props.d.ts +2 -2
  428. package/terminal/index.d.ts +1 -0
  429. package/terminal/index.mjs +1 -1
  430. package/terminal/index.mjs.map +1 -1
  431. package/terminal/useTerminal.d.ts +23 -2
  432. package/terminal/useTerminal.props.d.ts +2 -2
  433. package/textarea/index.d.ts +1 -0
  434. package/textarea/index.mjs +1 -1
  435. package/textarea/index.mjs.map +1 -1
  436. package/textarea/useTextarea.d.ts +9 -2
  437. package/textarea/useTextarea.props.d.ts +2 -2
  438. package/timeline/index.d.ts +1 -0
  439. package/timeline/index.mjs +1 -1
  440. package/timeline/index.mjs.map +1 -1
  441. package/timeline/useTimeline.d.ts +41 -1
  442. package/timeline/useTimeline.props.d.ts +2 -2
  443. package/toast/index.d.ts +1 -1
  444. package/toast/index.mjs +1 -1
  445. package/toast/index.mjs.map +1 -1
  446. package/toast/useToast.d.ts +85 -23
  447. package/toast/useToast.props.d.ts +2 -2
  448. package/toaster/ToastManager.d.ts +14 -0
  449. package/toaster/index.d.ts +4 -0
  450. package/toaster/index.mjs +2 -0
  451. package/toaster/index.mjs.map +1 -0
  452. package/toaster/useToaster.d.ts +50 -0
  453. package/toaster/useToaster.props.d.ts +2 -0
  454. package/togglebutton/index.d.ts +1 -0
  455. package/togglebutton/index.mjs +1 -1
  456. package/togglebutton/index.mjs.map +1 -1
  457. package/togglebutton/useToggleButton.d.ts +5 -3
  458. package/togglebutton/useToggleButton.props.d.ts +2 -2
  459. package/togglebuttongroup/index.d.ts +3 -0
  460. package/togglebuttongroup/index.mjs +2 -0
  461. package/togglebuttongroup/index.mjs.map +1 -0
  462. package/togglebuttongroup/useToggleButtonGroup.d.ts +17 -0
  463. package/togglebuttongroup/useToggleButtonGroup.props.d.ts +2 -0
  464. package/toggleswitch/index.d.ts +3 -0
  465. package/toggleswitch/index.mjs +2 -0
  466. package/toggleswitch/index.mjs.map +1 -0
  467. package/toggleswitch/useToggleSwitch.d.ts +48 -0
  468. package/toggleswitch/useToggleSwitch.props.d.ts +2 -0
  469. package/toolbar/index.d.ts +1 -0
  470. package/toolbar/index.mjs +1 -1
  471. package/toolbar/index.mjs.map +1 -1
  472. package/toolbar/useToolbar.d.ts +7 -1
  473. package/toolbar/useToolbar.props.d.ts +2 -2
  474. package/tooltip/index.d.ts +1 -0
  475. package/tooltip/index.mjs +1 -1
  476. package/tooltip/index.mjs.map +1 -1
  477. package/tooltip/useTooltip.d.ts +43 -24
  478. package/tooltip/useTooltip.props.d.ts +2 -2
  479. package/tooltipmanager/index.d.ts +2 -0
  480. package/tooltipmanager/index.mjs +2 -0
  481. package/tooltipmanager/index.mjs.map +1 -0
  482. package/tooltipmanager/useTooltipManager.d.ts +12 -0
  483. package/tooltipmanager/useTooltipManager.props.d.ts +2 -0
  484. package/tooltipmanager/useTooltipManager.test.d.ts +0 -0
  485. package/tree/TreeDragDropService.d.ts +13 -5
  486. package/tree/index.d.ts +7 -0
  487. package/tree/index.mjs +1 -1
  488. package/tree/index.mjs.map +1 -1
  489. package/tree/useTree.d.ts +96 -16
  490. package/tree/useTree.props.d.ts +2 -2
  491. package/tree/useTreeDragDrop.d.ts +24 -0
  492. package/tree/useTreeFlatten.d.ts +13 -0
  493. package/tree/useTreeKeyboard.d.ts +18 -0
  494. package/tree/useTreeNode.d.ts +45 -0
  495. package/tree/useTreeNode.props.d.ts +2 -0
  496. package/tree/useTreeSelection.d.ts +31 -0
  497. package/utils/itemKey.d.ts +10 -0
  498. package/LICENSE +0 -21
  499. package/colorpicker/index.d.ts +0 -3
  500. package/colorpicker/index.mjs +0 -2
  501. package/colorpicker/index.mjs.map +0 -1
  502. package/colorpicker/input/index.d.ts +0 -2
  503. package/colorpicker/input/index.mjs +0 -2
  504. package/colorpicker/input/index.mjs.map +0 -1
  505. package/colorpicker/input/useColorPickerInput.d.ts +0 -11
  506. package/colorpicker/input/useColorPickerInput.props.d.ts +0 -2
  507. package/colorpicker/slider/index.d.ts +0 -2
  508. package/colorpicker/slider/index.mjs +0 -2
  509. package/colorpicker/slider/index.mjs.map +0 -1
  510. package/colorpicker/slider/useColorPickerSlider.d.ts +0 -13
  511. package/colorpicker/slider/useColorPickerSlider.props.d.ts +0 -2
  512. package/colorpicker/useColorPicker.d.ts +0 -26
  513. package/colorpicker/useColorPicker.props.d.ts +0 -2
  514. package/commandmenu/index.d.ts +0 -2
  515. package/commandmenu/index.mjs +0 -2
  516. package/commandmenu/index.mjs.map +0 -1
  517. package/commandmenu/useCommandMenu.d.ts +0 -11
  518. package/commandmenu/useCommandMenu.props.d.ts +0 -2
  519. package/confirmdialog/index.d.ts +0 -2
  520. package/confirmdialog/index.mjs +0 -2
  521. package/confirmdialog/index.mjs.map +0 -1
  522. package/confirmdialog/useConfirmDialog.d.ts +0 -1
  523. package/confirmdialog/useConfirmDialog.props.d.ts +0 -2
  524. package/confirmpopup/index.d.ts +0 -2
  525. package/confirmpopup/index.mjs +0 -2
  526. package/confirmpopup/index.mjs.map +0 -1
  527. package/confirmpopup/useConfirmPopup.d.ts +0 -25
  528. package/confirmpopup/useConfirmPopup.props.d.ts +0 -2
  529. package/imagecompare/index.d.ts +0 -2
  530. package/imagecompare/index.mjs +0 -2
  531. package/imagecompare/index.mjs.map +0 -1
  532. package/imagecompare/useImageCompare.d.ts +0 -8
  533. package/imagecompare/useImageCompare.props.d.ts +0 -2
  534. package/menu/sub/index.d.ts +0 -2
  535. package/menu/sub/index.mjs +0 -2
  536. package/menu/sub/index.mjs.map +0 -1
  537. package/menu/sub/useMenuSub.d.ts +0 -19
  538. package/menu/sub/useMenuSub.props.d.ts +0 -2
  539. package/orgchart/index.d.ts +0 -2
  540. package/orgchart/index.mjs +0 -2
  541. package/orgchart/index.mjs.map +0 -1
  542. package/orgchart/useOrgChart.d.ts +0 -20
  543. package/orgchart/useOrgChart.props.d.ts +0 -2
  544. package/overlay/index.d.ts +0 -2
  545. package/overlay/index.mjs +0 -2
  546. package/overlay/index.mjs.map +0 -1
  547. package/overlay/useOverlay.d.ts +0 -16
  548. package/overlay/useOverlay.props.d.ts +0 -2
  549. package/password/index.d.ts +0 -2
  550. package/password/index.mjs +0 -2
  551. package/password/index.mjs.map +0 -1
  552. package/password/usePassword.d.ts +0 -35
  553. package/password/usePassword.props.d.ts +0 -2
  554. package/placer/index.d.ts +0 -2
  555. package/placer/index.mjs +0 -2
  556. package/placer/index.mjs.map +0 -1
  557. package/placer/usePlacer.d.ts +0 -12
  558. package/placer/usePlacer.props.d.ts +0 -2
  559. package/switch/index.d.ts +0 -2
  560. package/switch/index.mjs +0 -2
  561. package/switch/index.mjs.map +0 -1
  562. package/switch/useSwitch.d.ts +0 -7
  563. package/switch/useSwitch.props.d.ts +0 -2
  564. package/toast/item/index.css +0 -2
  565. package/toast/item/index.css.map +0 -1
  566. package/toast/item/index.d.ts +0 -2
  567. package/toast/item/index.mjs +0 -2
  568. package/toast/item/index.mjs.map +0 -1
  569. package/toast/item/useToastItem.d.ts +0 -25
  570. package/toast/item/useToastItem.props.d.ts +0 -2
  571. package/toast/toastStore.d.ts +0 -40
  572. package/tooltip/group/index.d.ts +0 -2
  573. package/tooltip/group/index.mjs +0 -2
  574. package/tooltip/group/index.mjs.map +0 -1
  575. package/tooltip/group/useTooltipGroup.d.ts +0 -9
  576. package/tooltip/group/useTooltipGroup.props.d.ts +0 -2
  577. /package/{colorpicker/input/useColorPickerInput.test.d.ts → autocomplete/useAutoComplete.test.d.ts} +0 -0
  578. /package/{colorpicker/slider/useColorPickerSlider.test.d.ts → checkboxgroup/useCheckboxGroup.test.d.ts} +0 -0
  579. /package/{colorpicker/useColorPicker.test.d.ts → collapsible/useCollapsible.test.d.ts} +0 -0
  580. /package/{commandmenu/useCommandMenu.test.d.ts → compare/useCompare.test.d.ts} +0 -0
  581. /package/{confirmdialog/useConfirmDialog.test.d.ts → floatlabel/useFloatLabel.test.d.ts} +0 -0
  582. /package/{confirmpopup/useConfirmPopup.test.d.ts → iftalabel/useIftaLabel.test.d.ts} +0 -0
  583. /package/{imagecompare/useImageCompare.test.d.ts → inputcolor/useInputColor.test.d.ts} +0 -0
  584. /package/{orgchart/useOrgChart.test.d.ts → inputpassword/useInputPassword.test.d.ts} +0 -0
  585. /package/{overlay/useOverlay.test.d.ts → navigationmenu/useNavigationMenu.test.d.ts} +0 -0
  586. /package/{password/usePassword.test.d.ts → organizationchart/useOrganizationChart.test.d.ts} +0 -0
  587. /package/{placer/usePlacer.test.d.ts → overlaybadge/useOverlayBadge.test.d.ts} +0 -0
  588. /package/{progressspinner/useProgressSpinner.test.d.ts → positioner/usePositioner.test.d.ts} +0 -0
  589. /package/{rating/useRating.test.d.ts → radiobuttongroup/useRadioButtonGroup.test.d.ts} +0 -0
  590. /package/{switch/useSwitch.test.d.ts → toaster/useToaster.test.d.ts} +0 -0
  591. /package/{toast/item/useToastItem.test.d.ts → togglebuttongroup/useToggleButtonGroup.test.d.ts} +0 -0
  592. /package/{tooltip/group/useTooltipGroup.test.d.ts → toggleswitch/useToggleSwitch.test.d.ts} +0 -0
@@ -1 +1,80 @@
1
- export declare const useFieldset: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/shared/fieldset").useFieldsetProps, unknown, Record<PropertyKey, unknown>>;
1
+ import * as React from 'react';
2
+ export declare const useFieldset: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/headless/fieldset").UseFieldsetProps, unknown, {
3
+ rootProps: {
4
+ 'data-scope': string;
5
+ 'data-part': string;
6
+ 'data-disabled'?: string | undefined;
7
+ };
8
+ contentProps: {
9
+ 'data-scope': string;
10
+ 'data-part': string;
11
+ id: string | undefined;
12
+ role: "region";
13
+ 'aria-hidden': boolean;
14
+ };
15
+ triggerProps: {
16
+ 'data-scope': string;
17
+ 'data-part': string;
18
+ onClick: (event?: React.SyntheticEvent) => void;
19
+ type: "button";
20
+ tabIndex: number | undefined;
21
+ 'aria-expanded': boolean | undefined;
22
+ 'aria-disabled': true | undefined;
23
+ 'aria-controls': string | undefined;
24
+ };
25
+ indicatorProps: {
26
+ [x: string]: string;
27
+ 'data-scope': string;
28
+ 'data-part': string;
29
+ };
30
+ ref: React.Ref<unknown>;
31
+ elementRef: React.RefObject<HTMLElement | undefined>;
32
+ id?: string | undefined;
33
+ name?: string | undefined;
34
+ type?: import("@primereact/types/core").Types | undefined;
35
+ scope?: string | undefined;
36
+ part?: string | undefined;
37
+ inProps?: import("@primereact/types").SafeRecord<import("@primereact/headless/collapsible").UseCollapsibleProps> | undefined;
38
+ $attrSelector?: string | undefined;
39
+ $primereact: import("@primereact/types/core").Contexts;
40
+ props: import("@primereact/types").SafeRecord<import("@primereact/headless/collapsible").UseCollapsibleProps>;
41
+ attrs: Omit<import("@primereact/types").SafeRecord<import("@primereact/headless/collapsible").UseCollapsibleProps>, keyof import("@primereact/headless/collapsible").UseCollapsibleProps> & Record<PropertyKey, unknown>;
42
+ state: {
43
+ open: boolean | undefined;
44
+ };
45
+ $computedSetup: {
46
+ state: {
47
+ open: boolean | undefined;
48
+ };
49
+ rootProps: {
50
+ 'data-disabled'?: string | undefined;
51
+ 'data-scope': string;
52
+ 'data-part': string;
53
+ };
54
+ triggerProps: {
55
+ [x: string]: string | number | boolean | ((event?: React.SyntheticEvent) => void) | undefined;
56
+ type: "button";
57
+ tabIndex: number | undefined;
58
+ 'aria-expanded': boolean | undefined;
59
+ 'aria-disabled': true | undefined;
60
+ 'aria-controls': string | undefined;
61
+ 'data-scope': string;
62
+ 'data-part': string;
63
+ onClick: (event?: React.SyntheticEvent) => void;
64
+ };
65
+ contentProps: {
66
+ [x: string]: string | boolean | undefined;
67
+ id: string | undefined;
68
+ role: "region";
69
+ 'aria-hidden': boolean;
70
+ 'data-scope': string;
71
+ 'data-part': string;
72
+ };
73
+ open: (event?: React.SyntheticEvent) => void;
74
+ close: (event?: React.SyntheticEvent) => void;
75
+ toggle: (event?: React.SyntheticEvent) => void;
76
+ };
77
+ open: (event?: React.SyntheticEvent) => void;
78
+ close: (event?: React.SyntheticEvent) => void;
79
+ toggle: (event?: React.SyntheticEvent) => void;
80
+ }>;
@@ -1,2 +1,2 @@
1
- import type { useFieldsetProps } from '@primereact/types/shared/fieldset';
2
- export declare const defaultProps: useFieldsetProps;
1
+ import type { UseFieldsetProps } from '@primereact/types/headless/fieldset';
2
+ export declare const defaultProps: UseFieldsetProps;
@@ -1,2 +1,3 @@
1
1
  export * from './useFileUpload';
2
2
  export * from './useFileUpload.props';
3
+ export type * from '@primereact/types/headless/fileupload';
@@ -1,2 +1,2 @@
1
- import{withHeadless as J}from"@primereact/core/headless";import{addClass as Q,isNotEmpty as D,removeClass as B}from"@primeuix/utils";import*as r from"react";var H={name:void 0,url:void 0,multiple:!1,accept:void 0,disabled:!1,auto:!1,maxFileSize:void 0,fileLimit:void 0,withCredentials:!1,customUpload:!1,invalidFileLimitMessage:"Maximum number of files exceeded, limit is {0} at most.",invalidFileSizeMessage:"{0}: Invalid file size, file size should be smaller than {1}.",invalidFileTypeMessage:"{0}: Invalid file type, allowed file types: {1}.",uploadHandler:void 0,onSelect:void 0,onBeforeUpload:void 0,onUpload:void 0,onError:void 0,onProgress:void 0,onBeforeSend:void 0,onClear:void 0,onRemove:void 0};var ie=J({name:"useFileUpload",defaultProps:H,setup({props:t,$primereact:S}){let d=r.useRef(null),c=r.useRef(null),m=r.useRef(0),[l,g]=r.useState([]),[h,T]=r.useState([]),[C,F]=r.useState([]),[U,b]=r.useState(0),u=r.useMemo(()=>D(l),[l]),w=r.useMemo(()=>D(h),[h]),x={files:l,messages:C,progress:U,uploadedFiles:h},P=()=>{u&&E(l)},p=e=>{var f,o;let i=s=>"dataTransfer"in s&&!!s.dataTransfer;u&&g([]);let n=[];t.multiple&&(n=l?[...l]:[]);let a=i(e)?(f=e.dataTransfer)==null?void 0:f.files:(o=e.target)==null?void 0:o.files;if(a){for(let s of Array.from(a))if(!k(s)&&!R()&&O(s)){if(q(s)){let v=s;v.objectURL=window.URL.createObjectURL(s)}n.push(s)}g(n),t.fileLimit&&Z(),t.auto&&D(n)&&!R()&&E(n),t.onSelect&&t.onSelect({originalEvent:e,files:n}),M()}},I=()=>{d.current&&d.current.click()},E=(e=l)=>{var n;let i=(n=e!=null?e:l)!=null?n:[];if(t.customUpload)t.fileLimit&&(m.current+=i.length),t.uploadHandler&&t.uploadHandler({files:i,options:{clear:L,props:t}});else{let a=new XMLHttpRequest,f=new FormData;t.onBeforeUpload&&t.onBeforeUpload({xhr:a,files:i});for(let o of i)f.append(t.name,o,o.name);a.upload.addEventListener("progress",o=>{if(o.lengthComputable){let s=Math.round(o.loaded*100/o.total);b(s)}t.onProgress&&t.onProgress({originalEvent:o,progress:U})}),a.onreadystatechange=()=>{a.readyState===4&&(b(0),a.status>=200&&a.status<300?(t.fileLimit&&(m.current+=i.length),t.onUpload&&t.onUpload({xhr:a,files:i}),T(o=>[...o,...i])):t.onError&&t.onError({xhr:a,files:i}),L())},t.url&&(a.open("POST",t.url,!0),t.onBeforeSend&&t.onBeforeSend({xhr:a,formData:f}),a.withCredentials=!!t.withCredentials,a.send(f))}},L=()=>{g([]),F([]),t.onClear&&t.onClear(),M()},k=e=>{if(l&&l.length){for(let i of l)if(i.name+i.type+i.size===e.name+e.type+e.size)return!0}return!1},O=e=>t.accept&&!A(e)?(F(i=>[...i,t.invalidFileTypeMessage.replace("{0}",e.name).replace("{1}",t.accept)]),!1):t.maxFileSize&&e.size>t.maxFileSize?(F(i=>[...i,t.invalidFileSizeMessage.replace("{0}",e.name).replace("{1}",z(t.maxFileSize))]),!1):!0,A=e=>{let i=t.accept.split(",").map(n=>n.trim());for(let n of i)if(j(n)?y(e.type)===y(n):e.type==n||W(e).toLowerCase()===n.toLowerCase())return!0;return!1},y=e=>e.substring(0,e.indexOf("/")),j=e=>e.indexOf("*")!==-1,W=e=>"."+e.name.split(".").pop(),q=e=>/^image\//.test(e.type),G=e=>{!t.disabled&&(!u||t.multiple)&&(e.stopPropagation(),e.preventDefault())},K=e=>{!t.disabled&&(!u||t.multiple)&&(Q(c.current,"p-fileupload-highlight"),c.current.setAttribute("data-p-highlight","true"),e.stopPropagation(),e.preventDefault())},N=()=>{t.disabled||(B(c.current,"p-fileupload-highlight"),c.current.setAttribute("data-p-highlight","false"))},V=e=>{var i;if(!t.disabled){B(c.current,"p-fileupload-highlight"),c.current.setAttribute("data-p-highlight","false"),e.stopPropagation(),e.preventDefault();let n=(i=e.dataTransfer)==null?void 0:i.files;(t.multiple||n&&n.length===1)&&p(e)}},X=e=>{M();let i=[...l],n=l[e];i.splice(e,1),g(i),t.onRemove&&t.onRemove({file:n})},Y=e=>{let i=[...h];i.splice(e,1),T(i),t.onRemove&&t.onRemove({file:l[e]})},M=()=>{d.current&&(d.current.value="")},z=e=>{var s,v;let a=((v=(s=S==null?void 0:S.config)==null?void 0:s.locale)==null?void 0:v.fileSizeTypes)||["B","KB","MB","GB","TB","PB","EB","ZB","YB"];if(e===0)return`0 ${a[0]}`;let f=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,f)).toFixed(3))} ${a[f]}`},R=()=>t.fileLimit&&t.fileLimit<l.length+m.current,Z=()=>{R()&&F(e=>[...e,t.invalidFileLimitMessage.replace("{0}",t.fileLimit.toString())])};return{state:x,uploadedFileCount:m,hasFiles:u,hasUploadedFiles:w,inputRef:d,contentRef:c,upload:P,onFileSelect:p,choose:I,uploader:E,clear:L,remove:X,removeUploadedFile:Y,formatSize:z,onDragEnter:G,onDragOver:K,onDragLeave:N,onDrop:V}}});export{H as defaultProps,ie as useFileUpload};
1
+ var oe=Object.defineProperty;var I=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var j=(e,r,s)=>r in e?oe(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,p=(e,r)=>{for(var s in r||(r={}))re.call(r,s)&&j(e,s,r[s]);if(I)for(var s of I(r))ce.call(r,s)&&j(e,s,r[s]);return e};import{withHeadless as de}from"@primereact/core/headless";import{addClass as fe,isNotEmpty as S,removeClass as A}from"@primeuix/utils";import*as c from"react";var O={name:void 0,url:void 0,multiple:!1,accept:void 0,disabled:!1,auto:!1,maxFileSize:void 0,fileLimit:void 0,withCredentials:!1,customUpload:!1,invalidFileLimitMessage:"Maximum number of files exceeded, limit is {0} at most.",invalidFileSizeMessage:"{0}: Invalid file size, file size should be smaller than {1}.",invalidFileTypeMessage:"{0}: Invalid file type, allowed file types: {1}.",uploadHandler:void 0,onSelect:void 0,onChange:void 0,onBeforeUpload:void 0,onUpload:void 0,onError:void 0,onProgress:void 0,onBeforeSend:void 0,onClear:void 0,onRemove:void 0};var Se=de({name:"useFileUpload",defaultProps:O,setup({props:e,$primereact:r}){let s=c.useRef(null),u=c.useRef(null),h=c.useRef(0),N=c.useCallback(t=>{s.current=t},[]),W=c.useCallback(t=>{u.current=t},[]),[o,v]=c.useState([]),[F,T]=c.useState([]),[M,P]=c.useState(0),m=c.useMemo(()=>S(o),[o]),q=c.useMemo(()=>S(F),[F]),G={files:o,progress:M,uploadedFiles:F},C=()=>{m&&D(o)},L=t=>{var d,g;let a=l=>"dataTransfer"in l&&!!l.dataTransfer;m&&v([]);let n=[];e.multiple&&(n=o?[...o]:[]);let i=a(t)?(d=t.dataTransfer)==null?void 0:d.files:(g=t.target)==null?void 0:g.files;if(!i)return;let f=[];for(let l of Array.from(i)){if(K(l)||R())continue;let k=V(l);if(k.length){f.push({file:l,errors:k});continue}if(J(l)){let le=l;le.objectURL=window.URL.createObjectURL(l)}n.push(l)}if(v(n),e.fileLimit){let l=$();l&&f.push({errors:[l]})}f.length&&e.onError&&e.onError({type:"validation",rejectedFiles:f}),e.onChange&&e.onChange({acceptedFiles:n,rejectedFiles:f}),e.auto&&S(n)&&!R()&&D(n),e.onSelect&&e.onSelect({originalEvent:t,files:n}),b()},y=()=>{s.current&&s.current.click()},D=(t=o)=>{var n;let a=(n=t!=null?t:o)!=null?n:[];if(e.customUpload)e.fileLimit&&(h.current+=a.length),e.uploadHandler&&e.uploadHandler({files:a,options:{clear:E,props:e}});else{let i=new XMLHttpRequest,f=new FormData;e.onBeforeUpload&&e.onBeforeUpload({xhr:i,files:a});for(let d of a)f.append(e.name,d,d.name);i.upload.addEventListener("progress",d=>{if(d.lengthComputable){let g=Math.round(d.loaded*100/d.total);P(g)}e.onProgress&&e.onProgress({originalEvent:d,progress:M})}),i.onreadystatechange=()=>{i.readyState===4&&(P(0),i.status>=200&&i.status<300?(e.fileLimit&&(h.current+=a.length),e.onUpload&&e.onUpload({xhr:i,files:a}),T(d=>[...d,...a])):e.onError&&e.onError({type:"upload",reason:"upload",xhr:i,files:a}),E())},e.url&&(i.open("POST",e.url,!0),e.onBeforeSend&&e.onBeforeSend({xhr:i,formData:f}),i.withCredentials=!!e.withCredentials,i.send(f))}},E=()=>{v([]),e.onClear&&e.onClear(),e.onChange&&e.onChange({acceptedFiles:[],rejectedFiles:[]}),b()},K=t=>{if(o&&o.length){for(let a of o)if(a.name+a.type+a.size===t.name+t.type+t.size)return!0}return!1},V=t=>{let a=[];return e.accept&&!X(t)&&a.push({reason:"fileType",message:e.invalidFileTypeMessage.replace("{0}",t.name).replace("{1}",e.accept)}),e.maxFileSize&&t.size>e.maxFileSize&&a.push({reason:"fileSize",message:e.invalidFileSizeMessage.replace("{0}",t.name).replace("{1}",B(e.maxFileSize))}),a},X=t=>{let a=e.accept.split(",").map(n=>n.trim());for(let n of a)if(Y(n)?H(t.type)===H(n):t.type==n||Z(t).toLowerCase()===n.toLowerCase())return!0;return!1},H=t=>t.substring(0,t.indexOf("/")),Y=t=>t.indexOf("*")!==-1,Z=t=>"."+t.name.split(".").pop(),J=t=>/^image\//.test(t.type),U=t=>{!e.disabled&&(!m||e.multiple)&&(t.stopPropagation(),t.preventDefault())},z=t=>{!e.disabled&&(!m||e.multiple)&&(fe(u.current,"p-fileupload-highlight"),u.current.setAttribute("data-highlight","true"),t.stopPropagation(),t.preventDefault())},w=()=>{e.disabled||(A(u.current,"p-fileupload-highlight"),u.current.setAttribute("data-highlight","false"))},x=t=>{var a;if(!e.disabled){A(u.current,"p-fileupload-highlight"),u.current.setAttribute("data-highlight","false"),t.stopPropagation(),t.preventDefault();let n=(a=t.dataTransfer)==null?void 0:a.files;(e.multiple||n&&n.length===1)&&L(t)}},Q=t=>{b();let a=[...o],n=o[t];a.splice(t,1),v(a),e.onRemove&&e.onRemove({file:n}),e.onChange&&e.onChange({acceptedFiles:a,rejectedFiles:[]})},_=t=>{let a=[...F];a.splice(t,1),T(a),e.onRemove&&e.onRemove({file:o[t]})},b=()=>{s.current&&(s.current.value="")},B=t=>{var g,l;let i=((l=(g=r==null?void 0:r.config)==null?void 0:g.locale)==null?void 0:l.fileSizeTypes)||["B","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t===0)return`0 ${i[0]}`;let f=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,f)).toFixed(3))} ${i[f]}`},R=()=>e.fileLimit&&e.fileLimit<o.length+h.current,$=()=>R()?{reason:"fileLimit",message:e.invalidFileLimitMessage.replace("{0}",e.fileLimit.toString())}:null,ee=p({"data-scope":"fileupload","data-part":"root"},e.disabled&&{"data-disabled":""}),te={ref:N,"data-scope":"fileupload","data-part":"text",type:"file",accept:e.accept,multiple:e.multiple,disabled:e.disabled,onChange:L},ae={ref:W,"data-scope":"fileupload","data-part":"content",onDragEnter:U,onDragOver:z,onDragLeave:w,onDrop:x},ne=p({"data-scope":"fileupload","data-part":"choose",onClick:y},e.disabled&&{"data-disabled":""}),ie=p({"data-scope":"fileupload","data-part":"upload",onClick:C,disabled:!m},e.disabled&&{"data-disabled":""}),se=p({"data-scope":"fileupload","data-part":"clear",onClick:E,disabled:!m},e.disabled&&{"data-disabled":""});return{state:G,uploadedFileCount:h,hasFiles:m,hasUploadedFiles:q,rootProps:ee,chooseProps:ne,uploadProps:ie,clearProps:se,inputProps:te,contentProps:ae,fileRemoveProps:{"data-scope":"fileupload","data-part":"fileRemove"},fileProps:{"data-scope":"fileupload","data-part":"file"},fileThumbnailProps:{"data-scope":"fileupload","data-part":"fileThumbnail"},fileInfoProps:{"data-scope":"fileupload","data-part":"fileInfo"},fileNameProps:{"data-scope":"fileupload","data-part":"fileName"},fileSizeProps:{"data-scope":"fileupload","data-part":"fileSize"},fileListProps:{"data-scope":"fileupload","data-part":"fileList"},upload:C,onFileSelect:L,choose:y,uploader:D,clear:E,remove:Q,removeUploadedFile:_,formatSize:B,onDragEnter:U,onDragOver:z,onDragLeave:w,onDrop:x}}});export{O as defaultProps,Se as useFileUpload};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fileupload/useFileUpload.ts","../../src/fileupload/useFileUpload.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport { addClass, isNotEmpty, removeClass } from '@primeuix/utils';\nimport * as React from 'react';\nimport { defaultProps } from './useFileUpload.props';\n\nexport const useFileUpload = withHeadless({\n name: 'useFileUpload',\n defaultProps,\n setup({ props, $primereact }) {\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const contentRef = React.useRef<HTMLDivElement | null>(null);\n const uploadedFileCount = React.useRef(0);\n\n const [filesState, setFilesState] = React.useState<File[]>([]);\n const [uploadedFilesState, setUploadedFilesState] = React.useState<File[]>([]);\n const [messagesState, setMessagesState] = React.useState<string[]>([]);\n const [progressState, setProgressState] = React.useState(0);\n\n const hasFiles = React.useMemo(() => isNotEmpty(filesState), [filesState]);\n const hasUploadedFiles = React.useMemo(() => isNotEmpty(uploadedFilesState), [uploadedFilesState]);\n\n const state = {\n files: filesState,\n messages: messagesState,\n progress: progressState,\n uploadedFiles: uploadedFilesState\n };\n\n const upload = () => {\n if (hasFiles) {\n uploader(filesState);\n }\n };\n\n const onFileSelect = (event: React.ChangeEvent<HTMLInputElement> | DragEvent) => {\n const isDragEvent = (e: React.ChangeEvent<HTMLInputElement> | DragEvent): e is DragEvent => 'dataTransfer' in e && !!(e as DragEvent).dataTransfer;\n\n if (hasFiles) {\n setFilesState([]);\n }\n\n let currentFiles: File[] = [];\n\n if (props.multiple) {\n currentFiles = filesState ? [...filesState] : [];\n }\n\n const filesList = isDragEvent(event) ? event.dataTransfer?.files : (event.target as HTMLInputElement | null)?.files;\n\n if (!filesList) {\n return;\n }\n\n for (const file of Array.from(filesList)) {\n if (!isFileSelected(file) && !isFileLimitExceeded()) {\n if (validate(file)) {\n if (isImage(file)) {\n const fileWithUrl = file as File & { objectURL?: string };\n\n fileWithUrl.objectURL = window.URL.createObjectURL(file);\n }\n\n currentFiles.push(file);\n }\n }\n }\n\n setFilesState(currentFiles);\n\n if (props.fileLimit) {\n checkFileLimit();\n }\n\n if (props.auto && isNotEmpty(currentFiles) && !isFileLimitExceeded()) {\n uploader(currentFiles);\n }\n\n if (props.onSelect) {\n props.onSelect({ originalEvent: event, files: currentFiles });\n }\n\n clearInput();\n };\n\n const choose = () => {\n if (inputRef.current) {\n inputRef.current.click();\n }\n };\n\n const uploader = (uploadFiles = filesState) => {\n const filesToUpload = uploadFiles ?? filesState ?? [];\n\n if (props.customUpload) {\n if (props.fileLimit) {\n uploadedFileCount.current += filesToUpload.length;\n }\n\n if (props.uploadHandler) {\n props.uploadHandler({\n files: filesToUpload,\n options: {\n clear,\n props\n }\n });\n }\n } else {\n const xhr = new XMLHttpRequest();\n const formData = new FormData();\n\n if (props.onBeforeUpload) {\n props.onBeforeUpload({\n xhr,\n files: filesToUpload\n });\n }\n\n for (const file of filesToUpload) {\n formData.append(props.name as string, file, file.name);\n }\n\n xhr.upload.addEventListener('progress', (event) => {\n if (event.lengthComputable) {\n const progress = Math.round((event.loaded * 100) / event.total);\n\n setProgressState(progress);\n }\n\n if (props.onProgress) {\n props.onProgress({\n originalEvent: event,\n progress: progressState\n });\n }\n });\n\n xhr.onreadystatechange = () => {\n if (xhr.readyState === 4) {\n setProgressState(0);\n\n if (xhr.status >= 200 && xhr.status < 300) {\n if (props.fileLimit) {\n uploadedFileCount.current += filesToUpload.length;\n }\n\n if (props.onUpload) {\n props.onUpload({\n xhr,\n files: filesToUpload\n });\n }\n\n setUploadedFilesState((prevUploadedFiles) => [...prevUploadedFiles, ...filesToUpload]);\n } else {\n if (props.onError) {\n props.onError({\n xhr,\n files: filesToUpload\n });\n }\n }\n\n clear();\n }\n };\n\n if (props.url) {\n xhr.open('POST', props.url, true);\n\n if (props.onBeforeSend) {\n props.onBeforeSend({\n xhr,\n formData\n });\n }\n\n xhr.withCredentials = !!props.withCredentials;\n\n xhr.send(formData);\n }\n }\n };\n\n const clear = () => {\n setFilesState([]);\n setMessagesState([]);\n\n if (props.onClear) {\n props.onClear();\n }\n\n clearInput();\n };\n\n const isFileSelected = (file: File) => {\n if (filesState && filesState.length) {\n for (const sFile of filesState) {\n if (sFile.name + sFile.type + sFile.size === file.name + file.type + file.size) return true;\n }\n }\n\n return false;\n };\n\n const validate = (file: File) => {\n if (props.accept && !isFileTypeValid(file)) {\n setMessagesState((prevMessages) => [...prevMessages, (props.invalidFileTypeMessage as string).replace('{0}', file.name).replace('{1}', props.accept as string)]);\n\n return false;\n }\n\n if (props.maxFileSize && file.size > props.maxFileSize) {\n setMessagesState((prevMessages) => [...prevMessages, (props.invalidFileSizeMessage as string).replace('{0}', file.name).replace('{1}', formatSize(props.maxFileSize as number))]);\n\n return false;\n }\n\n return true;\n };\n\n const isFileTypeValid = (file: File) => {\n const acceptableTypes = (props.accept as string).split(',').map((type) => type.trim());\n\n for (const type of acceptableTypes) {\n const acceptable = isWildcard(type) ? getTypeClass(file.type) === getTypeClass(type) : file.type == type || getFileExtension(file).toLowerCase() === type.toLowerCase();\n\n if (acceptable) {\n return true;\n }\n }\n\n return false;\n };\n\n const getTypeClass = (fileType: string) => {\n return fileType.substring(0, fileType.indexOf('/'));\n };\n\n const isWildcard = (fileType: string) => {\n return fileType.indexOf('*') !== -1;\n };\n\n const getFileExtension = (file: File) => {\n return '.' + file.name.split('.').pop();\n };\n\n const isImage = (file: File) => {\n return /^image\\//.test(file.type);\n };\n\n const onDragEnter = (event: DragEvent) => {\n if (!props.disabled && (!hasFiles || props.multiple)) {\n event.stopPropagation();\n event.preventDefault();\n }\n };\n\n const onDragOver = (event: DragEvent) => {\n if (!props.disabled && (!hasFiles || props.multiple)) {\n // !isUnstyled &&\n addClass(contentRef.current as HTMLDivElement, 'p-fileupload-highlight');\n (contentRef.current as HTMLDivElement).setAttribute('data-p-highlight', 'true');\n event.stopPropagation();\n event.preventDefault();\n }\n };\n\n const onDragLeave = () => {\n if (!props.disabled) {\n // !isUnstyled &&\n removeClass(contentRef.current as HTMLDivElement, 'p-fileupload-highlight');\n (contentRef.current as HTMLDivElement).setAttribute('data-p-highlight', 'false');\n }\n };\n\n const onDrop = (event: DragEvent) => {\n if (!props.disabled) {\n // !isUnstyled &&\n removeClass(contentRef.current as HTMLDivElement, 'p-fileupload-highlight');\n (contentRef.current as HTMLDivElement).setAttribute('data-p-highlight', 'false');\n event.stopPropagation();\n event.preventDefault();\n\n const files = event.dataTransfer?.files;\n const allowDrop = props.multiple || (files && files.length === 1);\n\n if (allowDrop) {\n onFileSelect(event);\n }\n }\n };\n\n const remove = (index: number) => {\n clearInput();\n const currentFiles = [...filesState];\n const removedFile = filesState[index];\n\n currentFiles.splice(index, 1);\n setFilesState(currentFiles);\n\n if (props.onRemove) {\n props.onRemove({\n file: removedFile\n });\n }\n };\n\n const removeUploadedFile = (index: number) => {\n const currentUploadedFiles = [...uploadedFilesState];\n\n currentUploadedFiles.splice(index, 1);\n setUploadedFilesState(currentUploadedFiles);\n\n if (props.onRemove) {\n props.onRemove({\n file: filesState[index]\n });\n }\n };\n\n const clearInput = () => {\n if (inputRef.current) {\n inputRef.current.value = '';\n }\n };\n\n const formatSize = (bytes: number) => {\n const k = 1024;\n const dm = 3;\n // @ts-expect-error TODO:\n const sizes = $primereact?.config?.locale?.fileSizeTypes || ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\n if (bytes === 0) {\n return `0 ${sizes[0]}`;\n }\n\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n const formattedSize = parseFloat((bytes / Math.pow(k, i)).toFixed(dm));\n\n return `${formattedSize} ${sizes[i]}`;\n };\n\n const isFileLimitExceeded = () => {\n return props.fileLimit && props.fileLimit < filesState.length + uploadedFileCount.current;\n };\n\n const checkFileLimit = () => {\n if (isFileLimitExceeded()) {\n setMessagesState((prevMessages) => [...prevMessages, (props.invalidFileLimitMessage as string).replace('{0}', (props.fileLimit as number).toString())]);\n }\n };\n\n return {\n state,\n uploadedFileCount,\n hasFiles,\n hasUploadedFiles,\n // refs\n inputRef,\n contentRef,\n // methods\n upload,\n onFileSelect,\n choose,\n uploader,\n clear,\n remove,\n removeUploadedFile,\n formatSize,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop\n };\n }\n});\n","import type { useFileUploadProps } from '@primereact/types/shared/fileupload';\n\nexport const defaultProps: useFileUploadProps = {\n name: undefined,\n url: undefined,\n multiple: false,\n accept: undefined,\n disabled: false,\n auto: false,\n maxFileSize: undefined,\n fileLimit: undefined,\n withCredentials: false,\n customUpload: false,\n invalidFileLimitMessage: 'Maximum number of files exceeded, limit is {0} at most.',\n invalidFileSizeMessage: '{0}: Invalid file size, file size should be smaller than {1}.',\n invalidFileTypeMessage: '{0}: Invalid file type, allowed file types: {1}.',\n uploadHandler: undefined,\n onSelect: undefined,\n onBeforeUpload: undefined,\n onUpload: undefined,\n onError: undefined,\n onProgress: undefined,\n onBeforeSend: undefined,\n onClear: undefined,\n onRemove: undefined\n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I,KAAK,IAAI,IAAC,CAAC,EAGlD,MAAO,GAFe,YAAYA,EAAQ,KAAK,IAAI,KAAGE,CAAC,GAAG,QAAQ,CAAE,CAAC,CAE9C,IAAID,EAAMC,CAAC,CAAC,EACvC,EAEMtC,EAAsB,IACjB7B,EAAM,WAAaA,EAAM,UAAYK,EAAW,OAASD,EAAkB,QAGhF6B,EAAiB,IAAM,CACrBJ,EAAoB,GACpBnB,EAAkBmC,GAAiB,CAAC,GAAGA,EAAe7C,EAAM,wBAAmC,QAAQ,MAAQA,EAAM,UAAqB,SAAS,CAAC,CAAC,CAAC,CAE9J,EAEA,MAAO,CACH,MAAAgB,EACA,kBAAAZ,EACA,SAAAS,EACA,iBAAAE,EAEA,SAAAb,EACA,WAAAC,EAEA,OAAAc,EACA,aAAAE,EACA,OAAAgB,EACA,SAAAjB,EACA,MAAAoB,EACA,OAAAsB,EACA,mBAAAG,EACA,WAAAjB,EACA,YAAAO,EACA,WAAAC,EACA,YAAAE,EACA,OAAAE,CACJ,CACJ,CACJ,CAAC","names":["withHeadless","addClass","isNotEmpty","removeClass","React","defaultProps","useFileUpload","withHeadless","defaultProps","props","$primereact","inputRef","contentRef","uploadedFileCount","filesState","setFilesState","uploadedFilesState","setUploadedFilesState","messagesState","setMessagesState","progressState","setProgressState","hasFiles","isNotEmpty","hasUploadedFiles","state","upload","uploader","onFileSelect","event","_a","_b","isDragEvent","e","currentFiles","filesList","file","isFileSelected","isFileLimitExceeded","validate","isImage","fileWithUrl","checkFileLimit","clearInput","choose","uploadFiles","filesToUpload","clear","xhr","formData","progress","prevUploadedFiles","sFile","isFileTypeValid","prevMessages","formatSize","acceptableTypes","type","isWildcard","getTypeClass","getFileExtension","fileType","onDragEnter","onDragOver","addClass","onDragLeave","removeClass","onDrop","files","remove","index","removedFile","removeUploadedFile","currentUploadedFiles","bytes","sizes","i"]}
1
+ {"version":3,"sources":["../../src/fileupload/useFileUpload.ts","../../src/fileupload/useFileUpload.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport { addClass, isNotEmpty, removeClass } from '@primeuix/utils';\nimport * as React from 'react';\nimport { defaultProps } from './useFileUpload.props';\n\nexport const useFileUpload = withHeadless({\n name: 'useFileUpload',\n defaultProps,\n setup({ props, $primereact }) {\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const contentRef = React.useRef<HTMLDivElement | null>(null);\n const uploadedFileCount = React.useRef(0);\n\n const setInputRef = React.useCallback((node: HTMLInputElement | null) => {\n inputRef.current = node;\n }, []);\n\n const setContentRef = React.useCallback((node: HTMLDivElement | null) => {\n contentRef.current = node;\n }, []);\n\n const [filesState, setFilesState] = React.useState<File[]>([]);\n const [uploadedFilesState, setUploadedFilesState] = React.useState<File[]>([]);\n const [progressState, setProgressState] = React.useState(0);\n\n const hasFiles = React.useMemo(() => isNotEmpty(filesState), [filesState]);\n const hasUploadedFiles = React.useMemo(() => isNotEmpty(uploadedFilesState), [uploadedFilesState]);\n\n const state = {\n files: filesState,\n progress: progressState,\n uploadedFiles: uploadedFilesState\n };\n\n const upload = () => {\n if (hasFiles) {\n uploader(filesState);\n }\n };\n\n const onFileSelect = (event: React.ChangeEvent<HTMLInputElement> | DragEvent) => {\n const isDragEvent = (e: React.ChangeEvent<HTMLInputElement> | DragEvent): e is DragEvent => 'dataTransfer' in e && !!(e as DragEvent).dataTransfer;\n\n if (hasFiles) {\n setFilesState([]);\n }\n\n let currentFiles: File[] = [];\n\n if (props.multiple) {\n currentFiles = filesState ? [...filesState] : [];\n }\n\n const filesList = isDragEvent(event) ? event.dataTransfer?.files : (event.target as HTMLInputElement | null)?.files;\n\n if (!filesList) {\n return;\n }\n\n const rejectedFiles: { file?: File; errors: { reason: 'fileType' | 'fileSize' | 'fileLimit'; message: string }[] }[] = [];\n\n for (const file of Array.from(filesList)) {\n if (isFileSelected(file) || isFileLimitExceeded()) {\n continue;\n }\n\n const errors = validate(file);\n\n if (errors.length) {\n rejectedFiles.push({ file, errors });\n continue;\n }\n\n if (isImage(file)) {\n const fileWithUrl = file as File & { objectURL?: string };\n\n fileWithUrl.objectURL = window.URL.createObjectURL(file);\n }\n\n currentFiles.push(file);\n }\n\n setFilesState(currentFiles);\n\n if (props.fileLimit) {\n const limitError = checkFileLimit();\n\n if (limitError) {\n rejectedFiles.push({ errors: [limitError] });\n }\n }\n\n if (rejectedFiles.length && props.onError) {\n props.onError({ type: 'validation', rejectedFiles });\n }\n\n if (props.onChange) {\n props.onChange({ acceptedFiles: currentFiles, rejectedFiles });\n }\n\n if (props.auto && isNotEmpty(currentFiles) && !isFileLimitExceeded()) {\n uploader(currentFiles);\n }\n\n if (props.onSelect) {\n props.onSelect({ originalEvent: event, files: currentFiles });\n }\n\n clearInput();\n };\n\n const choose = () => {\n if (inputRef.current) {\n inputRef.current.click();\n }\n };\n\n const uploader = (uploadFiles = filesState) => {\n const filesToUpload = uploadFiles ?? filesState ?? [];\n\n if (props.customUpload) {\n if (props.fileLimit) {\n uploadedFileCount.current += filesToUpload.length;\n }\n\n if (props.uploadHandler) {\n props.uploadHandler({\n files: filesToUpload,\n options: {\n clear,\n props\n }\n });\n }\n } else {\n const xhr = new XMLHttpRequest();\n const formData = new FormData();\n\n if (props.onBeforeUpload) {\n props.onBeforeUpload({\n xhr,\n files: filesToUpload\n });\n }\n\n for (const file of filesToUpload) {\n formData.append(props.name as string, file, file.name);\n }\n\n xhr.upload.addEventListener('progress', (event) => {\n if (event.lengthComputable) {\n const progress = Math.round((event.loaded * 100) / event.total);\n\n setProgressState(progress);\n }\n\n if (props.onProgress) {\n props.onProgress({\n originalEvent: event,\n progress: progressState\n });\n }\n });\n\n xhr.onreadystatechange = () => {\n if (xhr.readyState === 4) {\n setProgressState(0);\n\n if (xhr.status >= 200 && xhr.status < 300) {\n if (props.fileLimit) {\n uploadedFileCount.current += filesToUpload.length;\n }\n\n if (props.onUpload) {\n props.onUpload({\n xhr,\n files: filesToUpload\n });\n }\n\n setUploadedFilesState((prevUploadedFiles) => [...prevUploadedFiles, ...filesToUpload]);\n } else {\n if (props.onError) {\n props.onError({\n type: 'upload',\n reason: 'upload',\n xhr,\n files: filesToUpload\n });\n }\n }\n\n clear();\n }\n };\n\n if (props.url) {\n xhr.open('POST', props.url, true);\n\n if (props.onBeforeSend) {\n props.onBeforeSend({\n xhr,\n formData\n });\n }\n\n xhr.withCredentials = !!props.withCredentials;\n\n xhr.send(formData);\n }\n }\n };\n\n const clear = () => {\n setFilesState([]);\n\n if (props.onClear) {\n props.onClear();\n }\n\n if (props.onChange) {\n props.onChange({ acceptedFiles: [], rejectedFiles: [] });\n }\n\n clearInput();\n };\n\n const isFileSelected = (file: File) => {\n if (filesState && filesState.length) {\n for (const sFile of filesState) {\n if (sFile.name + sFile.type + sFile.size === file.name + file.type + file.size) return true;\n }\n }\n\n return false;\n };\n\n const validate = (file: File): { reason: 'fileType' | 'fileSize'; message: string }[] => {\n const errors: { reason: 'fileType' | 'fileSize'; message: string }[] = [];\n\n if (props.accept && !isFileTypeValid(file)) {\n errors.push({\n reason: 'fileType',\n message: (props.invalidFileTypeMessage as string).replace('{0}', file.name).replace('{1}', props.accept as string)\n });\n }\n\n if (props.maxFileSize && file.size > props.maxFileSize) {\n errors.push({\n reason: 'fileSize',\n message: (props.invalidFileSizeMessage as string).replace('{0}', file.name).replace('{1}', formatSize(props.maxFileSize as number))\n });\n }\n\n return errors;\n };\n\n const isFileTypeValid = (file: File) => {\n const acceptableTypes = (props.accept as string).split(',').map((type) => type.trim());\n\n for (const type of acceptableTypes) {\n const acceptable = isWildcard(type) ? getTypeClass(file.type) === getTypeClass(type) : file.type == type || getFileExtension(file).toLowerCase() === type.toLowerCase();\n\n if (acceptable) {\n return true;\n }\n }\n\n return false;\n };\n\n const getTypeClass = (fileType: string) => {\n return fileType.substring(0, fileType.indexOf('/'));\n };\n\n const isWildcard = (fileType: string) => {\n return fileType.indexOf('*') !== -1;\n };\n\n const getFileExtension = (file: File) => {\n return '.' + file.name.split('.').pop();\n };\n\n const isImage = (file: File) => {\n return /^image\\//.test(file.type);\n };\n\n const onDragEnter = (event: DragEvent) => {\n if (!props.disabled && (!hasFiles || props.multiple)) {\n event.stopPropagation();\n event.preventDefault();\n }\n };\n\n const onDragOver = (event: DragEvent) => {\n if (!props.disabled && (!hasFiles || props.multiple)) {\n // !isUnstyled &&\n addClass(contentRef.current as HTMLDivElement, 'p-fileupload-highlight');\n (contentRef.current as HTMLDivElement).setAttribute('data-highlight', 'true');\n event.stopPropagation();\n event.preventDefault();\n }\n };\n\n const onDragLeave = () => {\n if (!props.disabled) {\n // !isUnstyled &&\n removeClass(contentRef.current as HTMLDivElement, 'p-fileupload-highlight');\n (contentRef.current as HTMLDivElement).setAttribute('data-highlight', 'false');\n }\n };\n\n const onDrop = (event: DragEvent) => {\n if (!props.disabled) {\n // !isUnstyled &&\n removeClass(contentRef.current as HTMLDivElement, 'p-fileupload-highlight');\n (contentRef.current as HTMLDivElement).setAttribute('data-highlight', 'false');\n event.stopPropagation();\n event.preventDefault();\n\n const files = event.dataTransfer?.files;\n const allowDrop = props.multiple || (files && files.length === 1);\n\n if (allowDrop) {\n onFileSelect(event);\n }\n }\n };\n\n const remove = (index: number) => {\n clearInput();\n const currentFiles = [...filesState];\n const removedFile = filesState[index];\n\n currentFiles.splice(index, 1);\n setFilesState(currentFiles);\n\n if (props.onRemove) {\n props.onRemove({\n file: removedFile\n });\n }\n\n if (props.onChange) {\n props.onChange({ acceptedFiles: currentFiles, rejectedFiles: [] });\n }\n };\n\n const removeUploadedFile = (index: number) => {\n const currentUploadedFiles = [...uploadedFilesState];\n\n currentUploadedFiles.splice(index, 1);\n setUploadedFilesState(currentUploadedFiles);\n\n if (props.onRemove) {\n props.onRemove({\n file: filesState[index]\n });\n }\n };\n\n const clearInput = () => {\n if (inputRef.current) {\n inputRef.current.value = '';\n }\n };\n\n const formatSize = (bytes: number) => {\n const k = 1024;\n const dm = 3;\n // @ts-expect-error TODO:\n const sizes = $primereact?.config?.locale?.fileSizeTypes || ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\n if (bytes === 0) {\n return `0 ${sizes[0]}`;\n }\n\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n const formattedSize = parseFloat((bytes / Math.pow(k, i)).toFixed(dm));\n\n return `${formattedSize} ${sizes[i]}`;\n };\n\n const isFileLimitExceeded = () => {\n return props.fileLimit && props.fileLimit < filesState.length + uploadedFileCount.current;\n };\n\n const checkFileLimit = (): { reason: 'fileLimit'; message: string } | null => {\n if (isFileLimitExceeded()) {\n return {\n reason: 'fileLimit',\n message: (props.invalidFileLimitMessage as string).replace('{0}', (props.fileLimit as number).toString())\n };\n }\n\n return null;\n };\n\n // prop getters\n const rootProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'root' as const,\n ...(props.disabled && { 'data-disabled': '' })\n };\n\n const inputProps = {\n ref: setInputRef,\n 'data-scope': 'fileupload' as const,\n 'data-part': 'text' as const,\n type: 'file' as const,\n accept: props.accept,\n multiple: props.multiple,\n disabled: props.disabled,\n onChange: onFileSelect\n };\n\n const contentProps = {\n ref: setContentRef,\n 'data-scope': 'fileupload' as const,\n 'data-part': 'content' as const,\n onDragEnter: onDragEnter as unknown as React.DragEventHandler<HTMLDivElement>,\n onDragOver: onDragOver as unknown as React.DragEventHandler<HTMLDivElement>,\n onDragLeave: onDragLeave as React.DragEventHandler<HTMLDivElement>,\n onDrop: onDrop as unknown as React.DragEventHandler<HTMLDivElement>\n };\n\n const chooseProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'choose' as const,\n onClick: choose,\n ...(props.disabled && { 'data-disabled': '' })\n };\n\n const uploadProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'upload' as const,\n onClick: upload,\n disabled: !hasFiles,\n ...(props.disabled && { 'data-disabled': '' })\n };\n\n const clearProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'clear' as const,\n onClick: clear,\n disabled: !hasFiles,\n ...(props.disabled && { 'data-disabled': '' })\n };\n\n const fileRemoveProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'fileRemove' as const\n };\n\n const fileProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'file' as const\n };\n\n const fileThumbnailProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'fileThumbnail' as const\n };\n\n const fileInfoProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'fileInfo' as const\n };\n\n const fileNameProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'fileName' as const\n };\n\n const fileSizeProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'fileSize' as const\n };\n\n const fileListProps = {\n 'data-scope': 'fileupload' as const,\n 'data-part': 'fileList' as const\n };\n\n return {\n state,\n uploadedFileCount,\n hasFiles,\n hasUploadedFiles,\n // prop getters\n rootProps,\n chooseProps,\n uploadProps,\n clearProps,\n inputProps,\n contentProps,\n fileRemoveProps,\n fileProps,\n fileThumbnailProps,\n fileInfoProps,\n fileNameProps,\n fileSizeProps,\n fileListProps,\n // methods\n upload,\n onFileSelect,\n choose,\n uploader,\n clear,\n remove,\n removeUploadedFile,\n formatSize,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop\n };\n }\n});\n","import type { UseFileUploadProps } from '@primereact/types/headless/fileupload';\n\nexport const defaultProps: UseFileUploadProps = {\n name: undefined,\n url: undefined,\n multiple: false,\n accept: undefined,\n disabled: false,\n auto: false,\n maxFileSize: undefined,\n fileLimit: undefined,\n withCredentials: false,\n customUpload: false,\n invalidFileLimitMessage: 'Maximum number of files exceeded, limit is {0} at most.',\n invalidFileSizeMessage: '{0}: Invalid file size, file size should be smaller than {1}.',\n invalidFileTypeMessage: '{0}: Invalid file type, allowed file types: {1}.',\n uploadHandler: undefined,\n onSelect: undefined,\n onChange: undefined,\n onBeforeUpload: undefined,\n onUpload: undefined,\n onError: undefined,\n onProgress: undefined,\n onBeforeSend: undefined,\n onClear: undefined,\n onRemove: undefined\n};\n"],"mappings":"+VAAA,OAAS,g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EAEMsD,GAAe,CACjB,IAAKnE,EACL,aAAc,aACd,YAAa,UACb,YAAaiD,EACb,WAAYC,EACZ,YAAaE,EACb,OAAQE,CACZ,EAEMc,GAAcH,EAAA,CAChB,aAAc,aACd,YAAa,SACb,QAASjC,GACLvC,EAAM,UAAY,CAAE,gBAAiB,EAAG,GAG1C4E,GAAcJ,EAAA,CAChB,aAAc,aACd,YAAa,SACb,QAAStD,EACT,SAAU,CAACJ,GACPd,EAAM,UAAY,CAAE,gBAAiB,EAAG,GAG1C6E,GAAaL,EAAA,CACf,aAAc,aACd,YAAa,QACb,QAAS9B,EACT,SAAU,CAAC5B,GACPd,EAAM,UAAY,CAAE,gBAAiB,EAAG,GAsChD,MAAO,CACH,MAAAiB,EACA,kBAAAb,EACA,SAAAU,EACA,iBAAAE,EAEA,UAAAuD,GACA,YAAAI,GACA,YAAAC,GACA,WAAAC,GACA,WAAAJ,GACA,aAAAC,GACA,gBA/CoB,CACpB,aAAc,aACd,YAAa,YACjB,EA6CI,UA3Cc,CACd,aAAc,aACd,YAAa,MACjB,EAyCI,mBAvCuB,CACvB,aAAc,aACd,YAAa,eACjB,EAqCI,cAnCkB,CAClB,aAAc,aACd,YAAa,UACjB,EAiCI,cA/BkB,CAClB,aAAc,aACd,YAAa,UACjB,EA6BI,cA3BkB,CAClB,aAAc,aACd,YAAa,UACjB,EAyBI,cAvBkB,CAClB,aAAc,aACd,YAAa,UACjB,EAsBI,OAAAxD,EACA,aAAAE,EACA,OAAAmB,EACA,SAAApB,EACA,MAAAuB,EACA,OAAAqB,EACA,mBAAAG,EACA,WAAAjB,EACA,YAAAO,EACA,WAAAC,EACA,YAAAE,EACA,OAAAE,CACJ,CACJ,CACJ,CAAC","names":["withHeadless","addClass","isNotEmpty","removeClass","React","defaultProps","useFileUpload","withHeadless","defaultProps","props","$primereact","inputRef","contentRef","uploadedFileCount","setInputRef","node","setContentRef","filesState","setFilesState","uploadedFilesState","setUploadedFilesState","progressState","setProgressState","hasFiles","isNotEmpty","hasUploadedFiles","state","upload","uploader","onFileSelect","event","_a","_b","isDragEvent","e","currentFiles","filesList","rejectedFiles","file","isFileSelected","isFileLimitExceeded","errors","validate","isImage","fileWithUrl","limitError","checkFileLimit","clearInput","choose","uploadFiles","filesToUpload","clear","xhr","formData","progress","prevUploadedFiles","sFile","isFileTypeValid","formatSize","acceptableTypes","type","isWildcard","getTypeClass","getFileExtension","fileType","onDragEnter","onDragOver","addClass","onDragLeave","removeClass","onDrop","files","remove","index","removedFile","removeUploadedFile","currentUploadedFiles","bytes","sizes","i","rootProps","__spreadValues","inputProps","contentProps","chooseProps","uploadProps","clearProps"]}
@@ -1,16 +1,85 @@
1
1
  import * as React from 'react';
2
- export declare const useFileUpload: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/shared/fileupload").useFileUploadProps, unknown, {
2
+ export declare const useFileUpload: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/headless/fileupload").UseFileUploadProps, unknown, {
3
3
  state: {
4
4
  files: File[];
5
- messages: string[];
6
5
  progress: number;
7
6
  uploadedFiles: File[];
8
7
  };
9
8
  uploadedFileCount: React.RefObject<number>;
10
9
  hasFiles: boolean;
11
10
  hasUploadedFiles: boolean;
12
- inputRef: React.RefObject<HTMLInputElement | null>;
13
- contentRef: React.RefObject<HTMLDivElement | null>;
11
+ rootProps: {
12
+ 'data-disabled'?: string | undefined;
13
+ 'data-scope': "fileupload";
14
+ 'data-part': "root";
15
+ };
16
+ chooseProps: {
17
+ 'data-disabled'?: string | undefined;
18
+ 'data-scope': "fileupload";
19
+ 'data-part': "choose";
20
+ onClick: () => void;
21
+ };
22
+ uploadProps: {
23
+ 'data-disabled'?: string | undefined;
24
+ 'data-scope': "fileupload";
25
+ 'data-part': "upload";
26
+ onClick: () => void;
27
+ disabled: boolean;
28
+ };
29
+ clearProps: {
30
+ 'data-disabled'?: string | undefined;
31
+ 'data-scope': "fileupload";
32
+ 'data-part': "clear";
33
+ onClick: () => void;
34
+ disabled: boolean;
35
+ };
36
+ inputProps: {
37
+ ref: (node: HTMLInputElement | null) => void;
38
+ 'data-scope': "fileupload";
39
+ 'data-part': "text";
40
+ type: "file";
41
+ accept: string | undefined;
42
+ multiple: boolean | undefined;
43
+ disabled: boolean | undefined;
44
+ onChange: (event: React.ChangeEvent<HTMLInputElement> | DragEvent) => void;
45
+ };
46
+ contentProps: {
47
+ ref: (node: HTMLDivElement | null) => void;
48
+ 'data-scope': "fileupload";
49
+ 'data-part': "content";
50
+ onDragEnter: React.DragEventHandler<HTMLDivElement>;
51
+ onDragOver: React.DragEventHandler<HTMLDivElement>;
52
+ onDragLeave: React.DragEventHandler<HTMLDivElement>;
53
+ onDrop: React.DragEventHandler<HTMLDivElement>;
54
+ };
55
+ fileRemoveProps: {
56
+ 'data-scope': "fileupload";
57
+ 'data-part': "fileRemove";
58
+ };
59
+ fileProps: {
60
+ 'data-scope': "fileupload";
61
+ 'data-part': "file";
62
+ };
63
+ fileThumbnailProps: {
64
+ 'data-scope': "fileupload";
65
+ 'data-part': "fileThumbnail";
66
+ };
67
+ fileInfoProps: {
68
+ 'data-scope': "fileupload";
69
+ 'data-part': "fileInfo";
70
+ };
71
+ fileNameProps: {
72
+ 'data-scope': "fileupload";
73
+ 'data-part': "fileName";
74
+ };
75
+ fileSizeProps: {
76
+ 'data-scope': "fileupload";
77
+ 'data-part': "fileSize";
78
+ };
79
+ fileListProps: {
80
+ 'data-scope': "fileupload";
81
+ 'data-part': "fileList";
82
+ };
14
83
  upload: () => void;
15
84
  onFileSelect: (event: React.ChangeEvent<HTMLInputElement> | DragEvent) => void;
16
85
  choose: () => void;
@@ -1,2 +1,2 @@
1
- import type { useFileUploadProps } from '@primereact/types/shared/fileupload';
2
- export declare const defaultProps: useFileUploadProps;
1
+ import type { UseFileUploadProps } from '@primereact/types/headless/fileupload';
2
+ export declare const defaultProps: UseFileUploadProps;
@@ -0,0 +1,3 @@
1
+ export * from './useFloatLabel';
2
+ export * from './useFloatLabel.props';
3
+ export type * from '@primereact/types/headless/floatlabel';
@@ -0,0 +1,2 @@
1
+ import{withHeadless as e}from"@primereact/core/headless";var o={};var s=e({name:"useFloatLabel",defaultProps:o,setup(){return{rootProps:{"data-scope":"floatlabel","data-part":"root"}}}});export{o as defaultProps,s as useFloatLabel};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/floatlabel/useFloatLabel.ts","../../src/floatlabel/useFloatLabel.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport { defaultProps } from './useFloatLabel.props';\n\nexport const useFloatLabel = withHeadless({\n name: 'useFloatLabel',\n defaultProps,\n setup() {\n // prop getters\n const rootProps = {\n 'data-scope': 'floatlabel',\n 'data-part': 'root'\n };\n\n return {\n rootProps\n };\n }\n});\n","import type { UseFloatLabelProps } from '@primereact/types/headless/floatlabel';\n\nexport const defaultProps: UseFloatLabelProps = {};\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,4BCEtB,IAAMC,EAAmC,CAAC,EDC1C,IAAMC,EAAgBC,EAAa,CACtC,KAAM,gBACN,aAAAC,EACA,OAAQ,CAOJ,MAAO,CACH,UANc,CACd,aAAc,aACd,YAAa,MACjB,CAIA,CACJ,CACJ,CAAC","names":["withHeadless","defaultProps","useFloatLabel","withHeadless","defaultProps"]}
@@ -0,0 +1,6 @@
1
+ export declare const useFloatLabel: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/headless/floatlabel").UseFloatLabelProps, unknown, {
2
+ rootProps: {
3
+ 'data-scope': string;
4
+ 'data-part': string;
5
+ };
6
+ }>;
@@ -0,0 +1,2 @@
1
+ import type { UseFloatLabelProps } from '@primereact/types/headless/floatlabel';
2
+ export declare const defaultProps: UseFloatLabelProps;
package/fluid/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './useFluid';
2
2
  export * from './useFluid.props';
3
+ export type * from '@primereact/types/headless/fluid';
package/fluid/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{withHeadless as e}from"@primereact/core/headless";var r={};var s=e({name:"useFluid",defaultProps:r});export{r as defaultProps,s as useFluid};
1
+ import{withHeadless as r}from"@primereact/core/headless";var o={};var d=r({name:"useFluid",defaultProps:o,setup(){return{rootProps:{"data-scope":"fluid","data-part":"root"}}}});export{o as defaultProps,d as useFluid};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fluid/useFluid.ts","../../src/fluid/useFluid.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport { defaultProps } from './useFluid.props';\n\nexport const useFluid = withHeadless({\n name: 'useFluid',\n defaultProps\n});\n","import type { useFluidProps } from '@primereact/types/shared/fluid';\n\nexport const defaultProps: useFluidProps = {};\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,4BCEtB,IAAMC,EAA8B,CAAC,EDCrC,IAAMC,EAAWC,EAAa,CACjC,KAAM,WACN,aAAAC,CACJ,CAAC","names":["withHeadless","defaultProps","useFluid","withHeadless","defaultProps"]}
1
+ {"version":3,"sources":["../../src/fluid/useFluid.ts","../../src/fluid/useFluid.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport { defaultProps } from './useFluid.props';\n\nexport const useFluid = withHeadless({\n name: 'useFluid',\n defaultProps,\n setup() {\n // prop getters\n const rootProps = {\n 'data-scope': 'fluid',\n 'data-part': 'root'\n };\n\n return {\n rootProps\n };\n }\n});\n","import type { UseFluidProps } from '@primereact/types/headless/fluid';\n\nexport const defaultProps: UseFluidProps = {};\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,4BCEtB,IAAMC,EAA8B,CAAC,EDCrC,IAAMC,EAAWC,EAAa,CACjC,KAAM,WACN,aAAAC,EACA,OAAQ,CAOJ,MAAO,CACH,UANc,CACd,aAAc,QACd,YAAa,MACjB,CAIA,CACJ,CACJ,CAAC","names":["withHeadless","defaultProps","useFluid","withHeadless","defaultProps"]}
@@ -1 +1,6 @@
1
- export declare const useFluid: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/shared/fluid").useFluidProps, unknown, Record<PropertyKey, unknown>>;
1
+ export declare const useFluid: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/headless/fluid").UseFluidProps, unknown, {
2
+ rootProps: {
3
+ 'data-scope': string;
4
+ 'data-part': string;
5
+ };
6
+ }>;
@@ -1,2 +1,2 @@
1
- import type { useFluidProps } from '@primereact/types/shared/fluid';
2
- export declare const defaultProps: useFluidProps;
1
+ import type { UseFluidProps } from '@primereact/types/headless/fluid';
2
+ export declare const defaultProps: UseFluidProps;
@@ -1,2 +1,3 @@
1
1
  export * from './useFocusTrap';
2
2
  export * from './useFocusTrap.props';
3
+ export type * from '@primereact/types/headless/focustrap';
@@ -1,2 +1,2 @@
1
- var w=Object.defineProperty;var h=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var g=(o,r,n)=>r in o?w(o,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[r]=n,f=(o,r)=>{for(var n in r||(r={}))A.call(r,n)&&g(o,n,r[n]);if(h)for(var n of h(r))O.call(r,n)&&g(o,n,r[n]);return o};import{withHeadless as $}from"@primereact/core/headless";import{useUnmountEffect as I}from"@primereact/hooks/use-unmount-effect";import{mergeProps as v}from"@primeuix/utils";import{focus as E,getFirstFocusableElement as p,getLastFocusableElement as U,isFocusableElement as S}from"@primeuix/utils/dom";import{isNotEmpty as j}from"@primeuix/utils/object";import*as s from"react";var x={disabled:!1,autoFocus:!0,container:null};var V=$({name:"useFocusTrap",defaultProps:x,setup:({props:o,elementRef:r})=>{let{disabled:n,autoFocus:b,container:R}=o,T=s.useRef(null),H=s.useRef(null),d=s.useRef(null),a=s.useRef(null),P={};s.useEffect(()=>{a.current=R||r.current},[R,r]);let m=e=>`:not(.p-hidden-focusable):not([data-p-hidden-focusable="true"])${e!=null?e:""}`,y=e=>{let t=a.current,l=e.relatedTarget,c=H.current;if(!t||!c)return;let u=l===c||!(t!=null&&t.contains(l))?p(t,m()):c;u&&E(u)},k=e=>{let t=a.current,l=e.relatedTarget,c=T.current;if(!t||!c)return;let u=l===c||!(t!=null&&t.contains(l))?U(t,m()):c;u&&E(u)},L=s.useCallback(()=>{if(!b)return;let e=a.current;if(!e)return;let t=p(e,`[autofocus]${m()}`);t||(t=p(e,m())),t&&E(t)},[b,a]),F=s.useCallback(()=>{let e=a.current;!e||n||!(e instanceof Element)||(e.setAttribute("data-p-focus-trap","true"),d.current=new MutationObserver(t=>{for(let l of t)if(l.type==="childList"&&!e.contains(document.activeElement)){let c=i=>{if(!i||!("nodeType"in i))return null;let M=S(i)?S(i,m(""))?i:p(e,m("")):p(i);return j(M)?M:i.nextSibling?c(i.nextSibling):null},u=c(l.nextSibling);u&&E(u)}}),d.current.observe(e,{childList:!0}))},[n,a]),N=()=>{let e=a.current;e&&(e.removeAttribute("data-p-focus-trap"),d.current&&(d.current.disconnect(),d.current=null))},C=()=>{let e={className:"p-hidden-accessible p-hidden-focusable",tabIndex:0,role:"presentation","aria-hidden":!0,"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0};return[s.createElement("span",f({},v(f({ref:T,onFocus:y},e)))),s.createElement("span",f({},v(f({ref:H,onFocus:k},e))))]};return s.useEffect(()=>{a.current&&(n||(F(),L()))},[n,F,L,a]),I(()=>{N()}),{state:P,hiddenElements:n?[null,null]:C()}}});export{x as defaultProps,V as useFocusTrap};
1
+ import{withHeadless as P}from"@primereact/core/headless";import{focus as i,getFirstFocusableElement as m,getLastFocusableElement as S,isFocusableElement as y,toElement as a}from"@primeuix/utils";import{isNotEmpty as w}from"@primeuix/utils/object";import*as s from"react";var v={trapped:!0,autoFocus:!0,initialFocusRef:void 0,onEscape:void 0,onTabFirst:void 0,onTabLast:void 0};var j=P({name:"useFocusTrap",defaultProps:v,setup:({props:h})=>{let{trapped:c,autoFocus:R,initialFocusRef:f,onEscape:p,onTabFirst:b,onTabLast:T}=h,L=s.useRef(null),F=s.useRef(null),d=s.useRef(null),u=s.useRef(null),H=s.useRef(null),r=e=>`:not([data-focus-guard])${e!=null?e:""}`,x=s.useCallback(e=>{if(!c)return;if(b){b(e);return}let t=a(u),l=e.relatedTarget,n=a(F);if(!t||!n)return;let o=l===n||!t.contains(l)?m(t,r()):n;o&&i(o)},[c,b]),C=s.useCallback(e=>{if(!c)return;if(T){T(e);return}let t=a(u),l=e.relatedTarget,n=a(L);if(!t||!n)return;let o=l===n||!t.contains(l)?S(t,r()):n;o&&i(o)},[c,T]),M=s.useCallback(()=>{if(!R)return;let e=a(u);if(!e)return;if(f!=null&&f.current){i(a(f));return}let t=m(e,`[autofocus]${r()}, [data-autofocus]${r()}`);t||(t=m(e,r())),t&&i(t)},[R,f]),E=s.useCallback(e=>{e.key==="Escape"&&(p==null||p(e))},[p]),g=s.useCallback(()=>{let e=a(u);!e||!c||!(e instanceof Element)||(H.current=document.activeElement,e.setAttribute("data-focus-trap",""),e.addEventListener("keydown",E),d.current=new MutationObserver(t=>{for(let l of t)if(l.type==="childList"&&!e.contains(document.activeElement)){let n=l.nextSibling,o=null;for(;n&&!(n instanceof Element&&(y(n)?o=y(n,r(""))?n:m(e,r("")):o=m(n,`[autofocus]${r()}, [data-autofocus]${r()}`),w(o)));)n=n.nextSibling;o&&i(o)}}),d.current.observe(e,{childList:!0}))},[c,E]),k=s.useCallback(()=>{let e=a(u);e&&(e.removeAttribute("data-focus-trap"),e.removeEventListener("keydown",E)),d.current&&(d.current.disconnect(),d.current=null);let t=H.current;t!=null&&t.isConnected&&i(t,{preventScroll:!0}),H.current=null},[E]);return s.useEffect(()=>{if(!(!c||!a(u)))return g(),M(),()=>k()},[c,g,M,k]),{containerRef:u,firstHiddenElementRef:L,lastHiddenElementRef:F,firstHiddenProps:{role:"presentation","aria-hidden":!0,"data-focus-guard":"",onFocus:x},lastHiddenProps:{role:"presentation","aria-hidden":!0,"data-focus-guard":"",onFocus:C}}}});export{v as defaultProps,j as useFocusTrap};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/focustrap/useFocusTrap.tsx","../../src/focustrap/useFocusTrap.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport { useUnmountEffect } from '@primereact/hooks/use-unmount-effect';\nimport { mergeProps } from '@primeuix/utils';\nimport { focus, getFirstFocusableElement, getLastFocusableElement, isFocusableElement } from '@primeuix/utils/dom';\nimport { isNotEmpty } from '@primeuix/utils/object';\nimport * as React from 'react';\nimport { defaultProps } from './useFocusTrap.props';\n\nexport const useFocusTrap = withHeadless({\n name: 'useFocusTrap',\n defaultProps,\n setup: ({ props, elementRef }) => {\n const { disabled, autoFocus, container } = props;\n const firstHiddenElementRef = React.useRef<HTMLSpanElement>(null);\n const lastHiddenElementRef = React.useRef<HTMLSpanElement>(null);\n const observerRef = React.useRef<MutationObserver | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const state = {};\n\n React.useEffect(() => {\n containerRef.current = container || elementRef.current;\n }, [container, elementRef]);\n\n // methods\n const getComputedSelector = (selector?: string) => `:not(.p-hidden-focusable):not([data-p-hidden-focusable=\"true\"])${selector ?? ''}`;\n\n const handleFirstHiddenFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n const containerElement = containerRef.current;\n\n const relatedTarget = event.relatedTarget as HTMLElement | null;\n const lastHiddenElement = lastHiddenElementRef.current;\n\n if (!containerElement || !lastHiddenElement) return;\n\n const fallback = relatedTarget === lastHiddenElement || !containerElement?.contains(relatedTarget) ? getFirstFocusableElement(containerElement, getComputedSelector()) : lastHiddenElement;\n\n if (fallback) {\n focus(fallback as HTMLElement);\n }\n };\n\n const handleLastHiddenFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n const containerElement = containerRef.current;\n\n const relatedTarget = event.relatedTarget as HTMLElement | null;\n const firstHiddenElement = firstHiddenElementRef.current;\n\n if (!containerElement || !firstHiddenElement) return;\n\n const fallback = relatedTarget === firstHiddenElement || !containerElement?.contains(relatedTarget) ? getLastFocusableElement(containerElement, getComputedSelector()) : firstHiddenElement;\n\n if (fallback) {\n focus(fallback as HTMLElement);\n }\n };\n\n const autoElementFocus = React.useCallback(() => {\n if (!autoFocus) return;\n\n const containerElement = containerRef.current;\n\n if (!containerElement) return;\n\n let focusableElement = getFirstFocusableElement(containerElement, `[autofocus]${getComputedSelector()}`);\n\n if (!focusableElement) {\n focusableElement = getFirstFocusableElement(containerElement, getComputedSelector());\n }\n\n if (focusableElement) {\n focus(focusableElement as HTMLElement);\n }\n }, [autoFocus, containerRef]);\n\n const bind = React.useCallback(() => {\n const containerElement = containerRef.current;\n\n if (!containerElement || disabled || !(containerElement instanceof Element)) return;\n\n containerElement.setAttribute('data-p-focus-trap', 'true');\n observerRef.current = new MutationObserver((mutationList) => {\n for (const mutation of mutationList) {\n if (mutation.type === 'childList' && !containerElement.contains(document.activeElement)) {\n const findNextFocusableElement = (_el: Node | null): HTMLElement | null => {\n if (!_el || !('nodeType' in _el)) return null;\n\n const focusableElement = isFocusableElement(_el as HTMLElement)\n ? isFocusableElement(_el as HTMLElement, getComputedSelector(''))\n ? (_el as HTMLElement)\n : getFirstFocusableElement(containerElement, getComputedSelector(''))\n : getFirstFocusableElement(_el as HTMLElement);\n\n return isNotEmpty(focusableElement) ? (focusableElement as HTMLElement) : _el.nextSibling ? findNextFocusableElement(_el.nextSibling) : null;\n };\n\n const nextElement = findNextFocusableElement(mutation.nextSibling);\n\n if (nextElement) {\n focus(nextElement);\n }\n }\n }\n });\n\n observerRef.current.observe(containerElement, { childList: true });\n }, [disabled, containerRef]);\n\n const unbind = () => {\n const containerElement = containerRef.current;\n\n if (!containerElement) return;\n\n containerElement.removeAttribute('data-p-focus-trap');\n\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n };\n\n const createHiddenElements = (): [React.ReactElement | null, React.ReactElement | null] => {\n const hiddenElementProps = {\n className: 'p-hidden-accessible p-hidden-focusable',\n tabIndex: 0,\n role: 'presentation',\n 'aria-hidden': true,\n 'data-p-hidden-accessible': true,\n 'data-p-hidden-focusable': true\n };\n\n const hiddenElements: [React.ReactElement | null, React.ReactElement | null] = [\n <span\n {...mergeProps({\n ref: firstHiddenElementRef,\n onFocus: handleFirstHiddenFocus,\n ...hiddenElementProps\n })}\n />,\n <span\n {...mergeProps({\n ref: lastHiddenElementRef,\n onFocus: handleLastHiddenFocus,\n ...hiddenElementProps\n })}\n />\n ];\n\n return hiddenElements;\n };\n // effects\n\n React.useEffect(() => {\n const containerElement = containerRef.current;\n\n if (!containerElement) return;\n\n if (!disabled) {\n bind();\n autoElementFocus();\n }\n }, [disabled, bind, autoElementFocus, containerRef]);\n\n useUnmountEffect(() => {\n unbind();\n });\n\n return {\n state,\n hiddenElements: !disabled ? createHiddenElements() : ([null, null] as [null, null])\n };\n }\n});\n","import type { useFocusTrapProps } from '@primereact/types/shared/focustrap';\n\nexport const defaultProps: useFocusTrapProps = {\n disabled: false,\n autoFocus: true,\n container: null\n};\n"],"mappings":"yVAAA,OAAS,gBAAAA,MAAoB,4BAC7B,OAAS,oBAAAC,MAAwB,uCACjC,OAAS,cAAAC,MAAkB,kBAC3B,OAAS,SAAAC,EAAO,4BAAAC,EAA0B,2BAAAC,EAAyB,sBAAAC,MAA0B,sBAC7F,OAAS,cAAAC,MAAkB,yBAC3B,UAAYC,MAAW,QCHhB,IAAMC,EAAkC,CAC3C,SAAU,GACV,UAAW,GACX,UAAW,IACf,EDEO,IAAMC,EAAeC,EAAa,CACrC,KAAM,eACN,aAAAC,EACA,MAAO,CAAC,CAAE,MAAAC,EAAO,WAAAC,CAAW,IAAM,CAC9B,GAAM,CAAE,SAAAC,EAAU,UAAAC,EAAW,UAAAC,CAAU,EAAIJ,EACrCK,EAA8B,SAAwB,IAAI,EAC1DC,EAA6B,SAAwB,IAAI,EACzDC,EAAoB,SAAgC,IAAI,EACxDC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D8B,EAAiB,IAAM,CACnBL,EAAO,CACX,CAAC,EAEM,CACH,MAAAxB,EACA,eAAiBP,EAAqC,CAAC,KAAM,IAAI,EAArCgC,EAAqB,CACrD,CACJ,CACJ,CAAC","names":["withHeadless","useUnmountEffect","mergeProps","focus","getFirstFocusableElement","getLastFocusableElement","isFocusableElement","isNotEmpty","React","defaultProps","useFocusTrap","withHeadless","defaultProps","props","elementRef","disabled","autoFocus","container","firstHiddenElementRef","lastHiddenElementRef","observerRef","containerRef","state","getComputedSelector","selector","handleFirstHiddenFocus","event","containerElement","relatedTarget","lastHiddenElement","fallback","getFirstFocusableElement","focus","handleLastHiddenFocus","firstHiddenElement","getLastFocusableElement","autoElementFocus","focusableElement","bind","mutationList","mutation","findNextFocusableElement","_el","isFocusableElement","isNotEmpty","nextElement","unbind","createHiddenElements","hiddenElementProps","__spreadValues","mergeProps","useUnmountEffect"]}
1
+ {"version":3,"sources":["../../src/focustrap/useFocusTrap.tsx","../../src/focustrap/useFocusTrap.props.ts"],"sourcesContent":["import { withHeadless } from '@primereact/core/headless';\nimport { focus, getFirstFocusableElement, getLastFocusableElement, isFocusableElement, toElement } from '@primeuix/utils';\nimport { isNotEmpty } from '@primeuix/utils/object';\nimport * as React from 'react';\nimport { defaultProps } from './useFocusTrap.props';\n\nexport const useFocusTrap = withHeadless({\n name: 'useFocusTrap',\n defaultProps,\n setup: ({ props }) => {\n const { trapped, autoFocus, initialFocusRef, onEscape, onTabFirst, onTabLast } = props;\n const firstHiddenElementRef = React.useRef<HTMLSpanElement>(null);\n const lastHiddenElementRef = React.useRef<HTMLSpanElement>(null);\n const observerRef = React.useRef<MutationObserver | null>(null);\n const containerRef = React.useRef<HTMLElement | null>(null);\n const previousActiveElementRef = React.useRef<HTMLElement | null>(null);\n\n // methods\n const getComputedSelector = (selector?: string) => `:not([data-focus-guard])${selector ?? ''}`;\n\n const onFirstHiddenFocus = React.useCallback(\n (event: React.FocusEvent<HTMLSpanElement>) => {\n if (!trapped) return;\n\n if (onTabFirst) {\n onTabFirst(event);\n\n return;\n }\n\n const containerElement = toElement(containerRef);\n const relatedTarget = event.relatedTarget as HTMLElement | null;\n const lastHiddenElement = toElement(lastHiddenElementRef);\n\n if (!containerElement || !lastHiddenElement) return;\n\n const fallback = relatedTarget === lastHiddenElement || !containerElement.contains(relatedTarget) ? getFirstFocusableElement(containerElement, getComputedSelector()) : lastHiddenElement;\n\n if (fallback) {\n focus(fallback as HTMLElement);\n }\n },\n [trapped, onTabFirst]\n );\n\n const onLastHiddenFocus = React.useCallback(\n (event: React.FocusEvent<HTMLSpanElement>) => {\n if (!trapped) return;\n\n if (onTabLast) {\n onTabLast(event);\n\n return;\n }\n\n const containerElement = toElement(containerRef);\n const relatedTarget = event.relatedTarget as HTMLElement | null;\n const firstHiddenElement = toElement(firstHiddenElementRef);\n\n if (!containerElement || !firstHiddenElement) return;\n\n const fallback = relatedTarget === firstHiddenElement || !containerElement.contains(relatedTarget) ? getLastFocusableElement(containerElement, getComputedSelector()) : firstHiddenElement;\n\n if (fallback) {\n focus(fallback as HTMLElement);\n }\n },\n [trapped, onTabLast]\n );\n\n const autoElementFocus = React.useCallback(() => {\n if (!autoFocus) return;\n\n const containerElement = toElement(containerRef);\n\n if (!containerElement) return;\n\n // 1. initialFocusRef takes priority\n if (initialFocusRef?.current) {\n focus(toElement(initialFocusRef)!);\n\n return;\n }\n\n // 2. [autofocus] or [data-autofocus] attribute\n let focusableElement = getFirstFocusableElement(containerElement, `[autofocus]${getComputedSelector()}, [data-autofocus]${getComputedSelector()}`);\n\n // 3. First focusable element\n if (!focusableElement) {\n focusableElement = getFirstFocusableElement(containerElement, getComputedSelector());\n }\n\n if (focusableElement) {\n focus(focusableElement as HTMLElement);\n }\n }, [autoFocus, initialFocusRef]);\n\n const handleKeyDown = React.useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onEscape?.(event);\n }\n },\n [onEscape]\n );\n\n const bind = React.useCallback(() => {\n const containerElement = toElement(containerRef);\n\n if (!containerElement || !trapped || !(containerElement instanceof Element)) return;\n\n previousActiveElementRef.current = document.activeElement as HTMLElement | null;\n\n containerElement.setAttribute('data-focus-trap', '');\n containerElement.addEventListener('keydown', handleKeyDown);\n\n observerRef.current = new MutationObserver((mutationList) => {\n for (const mutation of mutationList) {\n if (mutation.type === 'childList' && !containerElement.contains(document.activeElement)) {\n let currentNode: Node | null = mutation.nextSibling;\n let nextElement: HTMLElement | null = null;\n\n while (currentNode) {\n if (currentNode instanceof Element) {\n if (isFocusableElement(currentNode)) {\n nextElement = isFocusableElement(currentNode, getComputedSelector('')) ? (currentNode as HTMLElement) : (getFirstFocusableElement(containerElement, getComputedSelector('')) as HTMLElement | null);\n } else {\n nextElement = getFirstFocusableElement(currentNode, `[autofocus]${getComputedSelector()}, [data-autofocus]${getComputedSelector()}`) as HTMLElement | null;\n }\n\n if (isNotEmpty(nextElement)) break;\n }\n\n currentNode = currentNode.nextSibling;\n }\n\n if (nextElement) {\n focus(nextElement);\n }\n }\n }\n });\n\n observerRef.current.observe(containerElement, { childList: true });\n }, [trapped, handleKeyDown]);\n\n const unbind = React.useCallback(() => {\n const containerElement = toElement(containerRef);\n\n if (containerElement) {\n containerElement.removeAttribute('data-focus-trap');\n containerElement.removeEventListener('keydown', handleKeyDown);\n }\n\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n\n const previousElement = previousActiveElementRef.current;\n\n if (previousElement?.isConnected) {\n focus(previousElement, { preventScroll: true });\n }\n\n previousActiveElementRef.current = null;\n }, [handleKeyDown]);\n\n // effects\n React.useEffect(() => {\n if (!trapped) return;\n\n const containerElement = toElement(containerRef);\n\n if (!containerElement) return;\n\n bind();\n autoElementFocus();\n\n return () => unbind();\n }, [trapped, bind, autoElementFocus, unbind]);\n\n // prop getters\n const firstHiddenProps = {\n role: 'presentation' as const,\n 'aria-hidden': true as const,\n 'data-focus-guard': '',\n onFocus: onFirstHiddenFocus\n };\n\n const lastHiddenProps = {\n role: 'presentation' as const,\n 'aria-hidden': true as const,\n 'data-focus-guard': '',\n onFocus: onLastHiddenFocus\n };\n\n return {\n containerRef,\n firstHiddenElementRef,\n lastHiddenElementRef,\n // prop getters\n firstHiddenProps,\n lastHiddenProps\n };\n }\n});\n","import type { UseFocusTrapProps } from '@primereact/types/headless/focustrap';\n\nexport const defaultProps: UseFocusTrapProps = {\n trapped: true,\n autoFocus: true,\n initialFocusRef: undefined,\n onEscape: undefined,\n onTabFirst: undefined,\n onTabLast: undefined\n};\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,4BAC7B,OAAS,SAAAC,EAAO,4BAAAC,EAA0B,2BAAAC,EAAyB,sBAAAC,EAAoB,aAAAC,MAAiB,kBACxG,OAAS,cAAAC,MAAkB,yBAC3B,UAAYC,MAAW,QCDhB,IAAMC,EAAkC,CAC3C,QAAS,GACT,UAAW,GACX,gBAAiB,OACjB,SAAU,OACV,WAAY,OACZ,UAAW,MACf,EDHO,IAAMC,EAAeC,EAAa,CACrC,KAAM,eACN,aAAAC,EACA,MAAO,CAAC,CAAE,MAAAC,CAAM,IAAM,CAClB,GAAM,CAAE,QAAAC,EAAS,UAAAC,EAAW,gBAAAC,EAAiB,SAAAC,EAAU,WAAAC,EAAY,UAAAC,CAAU,EAAIN,EAC3EO,EAA8B,SAAwB,IAAI,EAC1DC,EAA6B,SAAwB,IAAI,EACzDC,EAAoB,SAAgC,IAAI,EACxDC,EAAqB,SAA2B,IAAI,EACpDC,EAAiC,SAA2B,IAAI,EAGhEC,EAAuBC,GAAsB,2BAA2BA,GAAA,KAAAA,EAAY,EAAE,GAEtFC,EAA2B,cAC5BC,GAA6C,CAC1C,GAAI,CAACd,EAAS,OAEd,GAAII,EAAY,CACZA,EAAWU,CAAK,EAEhB,MACJ,CAEA,IAAMC,EAAmBC,EAAUP,CAAY,EACzCQ,EAAgBH,EAAM,cACtBI,EAAoBF,EAAUT,CAAoB,EAExD,GAAI,CAACQ,GAAoB,CAACG,EAAmB,OAE7C,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C,EAiBrC,CACH,aAAA1B,EACA,sBAAAH,EACA,qBAAAC,EAEA,iBAnBqB,CACrB,KAAM,eACN,cAAe,GACf,mBAAoB,GACpB,QAASM,CACb,EAeI,gBAboB,CACpB,KAAM,eACN,cAAe,GACf,mBAAoB,GACpB,QAASS,CACb,CASA,CACJ,CACJ,CAAC","names":["withHeadless","focus","getFirstFocusableElement","getLastFocusableElement","isFocusableElement","toElement","isNotEmpty","React","defaultProps","useFocusTrap","withHeadless","defaultProps","props","trapped","autoFocus","initialFocusRef","onEscape","onTabFirst","onTabLast","firstHiddenElementRef","lastHiddenElementRef","observerRef","containerRef","previousActiveElementRef","getComputedSelector","selector","onFirstHiddenFocus","event","containerElement","toElement","relatedTarget","lastHiddenElement","fallback","getFirstFocusableElement","focus","onLastHiddenFocus","firstHiddenElement","getLastFocusableElement","autoElementFocus","focusableElement","handleKeyDown","bind","mutationList","mutation","currentNode","nextElement","isFocusableElement","isNotEmpty","unbind","previousElement"]}
@@ -1,5 +1,18 @@
1
1
  import * as React from 'react';
2
- export declare const useFocusTrap: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/shared/focustrap").useFocusTrapProps, unknown, {
3
- state: {};
4
- hiddenElements: [React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null, React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null];
2
+ export declare const useFocusTrap: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/headless/focustrap").UseFocusTrapProps, unknown, {
3
+ containerRef: React.RefObject<HTMLElement | null>;
4
+ firstHiddenElementRef: React.RefObject<HTMLSpanElement | null>;
5
+ lastHiddenElementRef: React.RefObject<HTMLSpanElement | null>;
6
+ firstHiddenProps: {
7
+ role: "presentation";
8
+ 'aria-hidden': true;
9
+ 'data-focus-guard': string;
10
+ onFocus: (event: React.FocusEvent<HTMLSpanElement>) => void;
11
+ };
12
+ lastHiddenProps: {
13
+ role: "presentation";
14
+ 'aria-hidden': true;
15
+ 'data-focus-guard': string;
16
+ onFocus: (event: React.FocusEvent<HTMLSpanElement>) => void;
17
+ };
5
18
  }>;
@@ -1,2 +1,2 @@
1
- import type { useFocusTrapProps } from '@primereact/types/shared/focustrap';
2
- export declare const defaultProps: useFocusTrapProps;
1
+ import type { UseFocusTrapProps } from '@primereact/types/headless/focustrap';
2
+ export declare const defaultProps: UseFocusTrapProps;
@@ -1,2 +1,3 @@
1
1
  export * from './useGallery';
2
2
  export * from './useGallery.props';
3
+ export type * from '@primereact/types/headless/gallery';
package/gallery/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{withHeadless as S}from"@primereact/core/headless";import*as t from"react";var h={activeIndex:0,onActiveIndexChange:void 0};var C=S({name:"useGallery",defaultProps:h,setup:({props:y,elementRef:u})=>{let{activeIndex:i=0,onActiveIndexChange:s=void 0}=y,g=t.useRef(null),o=t.useRef([]),x=t.useRef(null),w=t.useRef(null),E=t.useRef(null),I=t.useRef(null),[,b]=t.useState(0),[l,f]=t.useState(i),[d,p]=t.useState(!1);t.useEffect(()=>{f(i)},[i]);let z=e=>{if(!e)return-1;let c=o.current.findIndex(r=>r.current===e);return c===-1?(o.current.push({current:e}),b(r=>r+1),o.current.length-1):c},m=()=>{let e=(l+1)%o.current.length;f(e),s==null||s({originalEvent:void 0,value:e})},v=()=>{let e=(l-1+o.current.length)%o.current.length;f(e),s==null||s({originalEvent:void 0,value:e})},n=e=>()=>{var r;let c=(r=o.current[l])==null?void 0:r.current;if(c){let L=new CustomEvent("gallery-"+e,{detail:{action:e}});c.dispatchEvent(L)}},R=()=>{u.current&&(d?(Object.assign(u.current.style,{position:"relative",top:"",left:"",width:"",height:"",zIndex:""}),document.body.style.overflow="auto",p(!1)):(Object.assign(u.current.style,{position:"fixed",top:"0",left:"0",width:"100dvw",height:"100dvh",zIndex:"9999"}),document.body.style.overflow="hidden",p(!0)),setTimeout(()=>{window.dispatchEvent(new Event("resize"))},100))},a={zoomIn:n("zoom-in"),zoomOut:n("zoom-out"),rotateLeft:n("rotate-left"),rotateRight:n("rotate-right"),flipX:n("flip-x"),flipY:n("flip-y"),download:n("download"),next:m,prev:v,toggleFullScreen:R},H=t.useCallback(e=>{e&&a[e]&&a[e]()},[a]);return{state:{isFullscreen:d,activeIndex:l},registerItem:z,handleNext:m,handlePrev:v,createCustomEvent:n,toggleFullScreen:R,handleClickAction:H,actions:a,contentRef:g,toolbarRef:x,thumbnailRef:w,prevRef:E,nextRef:I}}});export{h as defaultProps,C as useGallery};
1
+ var gt=Object.defineProperty,bt=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var H=(c,n,o)=>n in c?gt(c,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):c[n]=o,i=(c,n)=>{for(var o in n||(n={}))vt.call(n,o)&&H(c,o,n[o]);if(G)for(var o of G(n))Pt.call(n,o)&&H(c,o,n[o]);return c},w=(c,n)=>bt(c,Rt(n));import{withHeadless as ht}from"@primereact/core/headless";import*as e from"react";var M={activeIndex:0,fullscreen:void 0,closeOnEscape:!0,onActiveIndexChange:void 0,onFullscreenChange:void 0,onZoomChange:void 0,onRotateChange:void 0,onFlipChange:void 0};var Tt=ht({name:"useGallery",defaultProps:M,setup:({props:c,id:n,elementRef:o})=>{let{activeIndex:I=0,fullscreen:r,closeOnEscape:K=!0,onActiveIndexChange:d=void 0,onFullscreenChange:p,onZoomChange:g,onRotateChange:b,onFlipChange:R}=c,x=e.useRef(null),s=e.useRef(0),X=e.useRef(null),Y=e.useRef(null),N=e.useRef(null),[m,v]=e.useState(I),E=e.useRef(m);E.current=m;let[q,B]=e.useState(!1),P=r!=null?r:q,[u,U]=e.useState({zoomed:!1,rotated:!1,flipped:!1}),[j,T]=e.useState(null);e.useEffect(()=>{v(I)},[I]),e.useEffect(()=>()=>{s.current=0},[]);let S=e.useCallback(t=>{if(t!==null)return t>=s.current&&(s.current=t+1),t;let a=s.current;return s.current+=1,a},[]),J=e.useCallback(()=>T(null),[]),h=()=>{if(s.current<=0)return;let t=(E.current+1)%s.current;v(t),d==null||d({originalEvent:void 0,value:t})},k=()=>{if(s.current<=0)return;let t=(E.current-1+s.current)%s.current;v(t),d==null||d({originalEvent:void 0,value:t})},L=t=>{t<0||t>=s.current||(v(t),d==null||d({originalEvent:void 0,value:t}))},f=t=>()=>{T({type:t,timestamp:Date.now()})},C=()=>{var t,a,y;if(r!==void 0){p==null||p(!r);return}o.current&&(document.fullscreenElement?(t=document.exitFullscreen)==null||t.call(document):(y=(a=o.current).requestFullscreen)==null||y.call(a))};e.useEffect(()=>{var a,y,F,A,O;if(r===void 0||!o.current)return;let t=document.fullscreenElement===o.current;r&&!t?(F=(y=(a=o.current).requestFullscreen)==null?void 0:y.call(a))==null||F.catch(()=>{}):!r&&document.fullscreenElement&&((O=(A=document.exitFullscreen)==null?void 0:A.call(document))==null||O.catch(()=>{}))},[r]),e.useEffect(()=>{let t=()=>{let a=document.fullscreenElement===o.current;B(a),r!==void 0&&r!==a&&(p==null||p(a))};return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[r,p]);let D=e.useRef(null),Q=e.useCallback(t=>{U({zoomed:t.zoomed,rotated:t.rotated,flipped:t.flipped});let a=D.current;(!a||a.scale!==t.scale)&&(g==null||g(t.scale)),(!a||a.rotation!==t.rotation)&&(b==null||b(t.rotation)),(!a||a.flip.x!==t.flip.x||a.flip.y!==t.flip.y)&&(R==null||R(t.flip)),D.current={scale:t.scale,rotation:t.rotation,flip:t.flip}},[g,b,R]),z={zoomIn:f("zoom-in"),zoomOut:f("zoom-out"),rotateLeft:f("rotate-left"),rotateRight:f("rotate-right"),flipX:f("flip-x"),flipY:f("flip-y"),download:f("download"),next:h,prev:k,toggleFullScreen:C},l=e.useCallback(t=>{t&&z[t]&&z[t]()},[z]),V={isFullscreen:P,activeIndex:m,zoomed:u.zoomed,rotated:u.rotated,flipped:u.flipped,pendingAction:j},W=i(i(i(i({ref:o,id:n,tabIndex:0,"data-scope":"gallery","data-part":"root",onKeyDown:t=>{t.key==="ArrowRight"?(t.preventDefault(),h()):t.key==="ArrowLeft"?(t.preventDefault(),k()):t.key==="Escape"&&K&&P&&(t.preventDefault(),C())}},P&&{"data-fullscreen":""}),u.zoomed&&{"data-zoomed":""}),u.rotated&&{"data-rotated":""}),u.flipped&&{"data-flipped":""}),Z={"data-scope":"gallery","data-part":"next",onClick:h},_={"data-scope":"gallery","data-part":"prev",onClick:k},$={"data-scope":"gallery","data-part":"thumbnail",slide:m},tt={"data-scope":"gallery","data-part":"thumbnailContent"},et=t=>{let a=()=>{t!==void 0&&L(t)};return w(i({"data-scope":"gallery","data-part":"thumbnailItem"},t!==void 0&&m===t&&{"data-active":""}),{onClick:a})},at={"data-scope":"gallery","data-part":"toolbar"},ot=t=>({"data-scope":"gallery","data-part":"toolbarItem",onClick:()=>{l(t)}}),nt={"data-scope":"gallery","data-part":"header"},st={"data-scope":"gallery","data-part":"footer"},rt={"data-scope":"gallery","data-part":"backdrop"},ct={ref:x,"data-scope":"gallery","data-part":"content"},lt={"data-scope":"gallery","data-part":"download","data-action":"download",onClick:()=>l("download")},dt={"data-scope":"gallery","data-part":"flipX","data-action":"flip-x",onClick:()=>l("flipX")},ut={"data-scope":"gallery","data-part":"flipY","data-action":"flip-y",onClick:()=>l("flipY")},it={"data-scope":"gallery","data-part":"rotateLeft","data-action":"rotate-left",onClick:()=>l("rotateLeft")},pt={"data-scope":"gallery","data-part":"rotateRight","data-action":"rotate-right",onClick:()=>l("rotateRight")},ft=w(i({"data-scope":"gallery","data-part":"fullScreen","data-action":"fullscreen"},P&&{"data-fullscreen":""}),{onClick:()=>l("toggleFullScreen")}),mt={"data-scope":"gallery","data-part":"zoomIn","data-action":"zoom-in",disabled:u.zoomed||void 0,onClick:()=>l("zoomIn")},yt={"data-scope":"gallery","data-part":"zoomOut","data-action":"zoom-out",disabled:!u.zoomed||void 0,onClick:()=>l("zoomOut")};return{state:V,registerItem:S,handleNext:h,handlePrev:k,selectItem:L,reportItemState:Q,clearPendingAction:J,toggleFullScreen:C,handleClickAction:l,actions:z,contentRef:x,thumbnailRef:X,prevRef:Y,nextRef:N,rootProps:W,nextProps:Z,prevProps:_,thumbnailProps:$,thumbnailContentProps:tt,thumbnailItemProps:et,toolbarProps:at,toolbarItemProps:ot,headerProps:nt,footerProps:st,backdropProps:rt,contentProps:ct,downloadProps:lt,flipXProps:dt,flipYProps:ut,rotateLeftProps:it,rotateRightProps:pt,fullScreenProps:ft,zoomInProps:mt,zoomOutProps:yt,zoomToggleProps:{"data-scope":"gallery","data-part":"zoomToggle","data-action":"zoom-toggle",onClick:()=>l(u.zoomed?"zoomOut":"zoomIn")},getItemProps:t=>(t>=s.current&&(s.current=t+1),i({"data-scope":"gallery","data-part":"item"},m===t&&{"data-active":""}))}}});export{M as defaultProps,Tt as useGallery};
2
2
  //# sourceMappingURL=index.mjs.map