@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.
- package/LICENSE.md +45 -0
- package/README.md +35 -0
- package/accordion/index.d.ts +3 -0
- package/accordion/index.mjs +1 -1
- package/accordion/index.mjs.map +1 -1
- package/accordion/useAccordion.d.ts +7 -6
- package/accordion/useAccordion.props.d.ts +2 -2
- package/accordion/useAccordionPanel.d.ts +46 -0
- package/accordion/useAccordionPanel.props.d.ts +2 -0
- package/animateonscroll/index.d.ts +1 -0
- package/animateonscroll/index.mjs +1 -1
- package/animateonscroll/index.mjs.map +1 -1
- package/animateonscroll/useAnimateOnScroll.d.ts +6 -1
- package/animateonscroll/useAnimateOnScroll.props.d.ts +2 -2
- package/autocomplete/index.d.ts +3 -0
- package/autocomplete/index.mjs +2 -0
- package/autocomplete/index.mjs.map +1 -0
- package/autocomplete/useAutoComplete.d.ts +198 -0
- package/autocomplete/useAutoComplete.props.d.ts +2 -0
- package/avatar/index.d.ts +1 -0
- package/avatar/index.mjs +1 -1
- package/avatar/index.mjs.map +1 -1
- package/avatar/useAvatar.d.ts +5 -1
- package/avatar/useAvatar.props.d.ts +2 -2
- package/avatargroup/index.d.ts +3 -0
- package/avatargroup/index.mjs +2 -0
- package/avatargroup/index.mjs.map +1 -0
- package/avatargroup/useAvatarGroup.d.ts +6 -0
- package/avatargroup/useAvatarGroup.props.d.ts +2 -0
- package/badge/index.d.ts +1 -0
- package/badge/index.mjs +1 -1
- package/badge/index.mjs.map +1 -1
- package/badge/useBadge.d.ts +7 -1
- package/badge/useBadge.props.d.ts +2 -2
- package/breadcrumb/index.d.ts +1 -0
- package/breadcrumb/index.mjs +1 -1
- package/breadcrumb/index.mjs.map +1 -1
- package/breadcrumb/useBreadcrumb.d.ts +18 -2
- package/breadcrumb/useBreadcrumb.props.d.ts +2 -2
- package/button/index.d.ts +1 -0
- package/button/index.mjs +1 -1
- package/button/index.mjs.map +1 -1
- package/button/useButton.d.ts +6 -1
- package/button/useButton.props.d.ts +2 -2
- package/card/index.d.ts +1 -0
- package/card/index.mjs +1 -1
- package/card/index.mjs.map +1 -1
- package/card/useCard.d.ts +6 -1
- package/card/useCard.props.d.ts +2 -2
- package/carousel/index.d.ts +1 -0
- package/carousel/index.mjs +1 -1
- package/carousel/index.mjs.map +1 -1
- package/carousel/useCarousel.d.ts +101 -5
- package/carousel/useCarousel.props.d.ts +2 -2
- package/checkbox/index.d.ts +1 -0
- package/checkbox/index.mjs +1 -1
- package/checkbox/index.mjs.map +1 -1
- package/checkbox/useCheckbox.d.ts +44 -3
- package/checkbox/useCheckbox.props.d.ts +2 -2
- package/checkboxgroup/index.d.ts +3 -0
- package/checkboxgroup/index.mjs +2 -0
- package/checkboxgroup/index.mjs.map +1 -0
- package/checkboxgroup/useCheckboxGroup.d.ts +11 -0
- package/checkboxgroup/useCheckboxGroup.props.d.ts +2 -0
- package/chip/index.d.ts +1 -0
- package/chip/index.mjs +1 -1
- package/chip/index.mjs.map +1 -1
- package/chip/useChip.d.ts +9 -3
- package/chip/useChip.props.d.ts +2 -2
- package/collapsible/index.d.ts +3 -0
- package/collapsible/index.mjs +2 -0
- package/collapsible/index.mjs.map +1 -0
- package/collapsible/useCollapsible.d.ts +33 -0
- package/collapsible/useCollapsible.props.d.ts +2 -0
- package/compare/index.d.ts +3 -0
- package/compare/index.mjs +2 -0
- package/compare/index.mjs.map +1 -0
- package/compare/useCompare.d.ts +2 -0
- package/compare/useCompare.props.d.ts +2 -0
- package/contextmenu/index.d.ts +1 -0
- package/contextmenu/index.mjs +1 -1
- package/contextmenu/index.mjs.map +1 -1
- package/contextmenu/submenu/index.d.ts +2 -0
- package/contextmenu/submenu/index.mjs +2 -0
- package/contextmenu/submenu/index.mjs.map +1 -0
- package/contextmenu/submenu/useContextMenuSubmenu.d.ts +121 -0
- package/contextmenu/submenu/useContextMenuSubmenu.props.d.ts +2 -0
- package/contextmenu/useContextMenu.d.ts +413 -1
- package/contextmenu/useContextMenu.props.d.ts +2 -2
- package/datatable/features/index.d.ts +28 -0
- package/datatable/features/index.mjs +11 -0
- package/datatable/features/index.mjs.map +1 -0
- package/datatable/features/useDataTableColumnReorder.d.ts +52 -0
- package/datatable/features/useDataTableColumnResize.d.ts +20 -0
- package/datatable/features/useDataTableEditing.d.ts +69 -0
- package/datatable/features/useDataTableExpansion.d.ts +32 -0
- package/datatable/features/useDataTableExport.d.ts +43 -0
- package/datatable/features/useDataTableFilter.d.ts +95 -0
- package/datatable/features/useDataTableGrouping.d.ts +11 -0
- package/datatable/features/useDataTableKeyboard.d.ts +23 -0
- package/datatable/features/useDataTablePagination.d.ts +32 -0
- package/datatable/features/useDataTableRowReorder.d.ts +42 -0
- package/datatable/features/useDataTableSelection.d.ts +28 -0
- package/datatable/features/useDataTableSort.d.ts +51 -0
- package/datatable/features/useDataTableTree.d.ts +31 -0
- package/datatable/index.d.ts +7 -0
- package/datatable/index.mjs +11 -0
- package/datatable/index.mjs.map +1 -0
- package/datatable/useDataTable.d.ts +237 -0
- package/datatable/useDataTable.props.d.ts +2 -0
- package/datatable/useDataTableRow.d.ts +30 -0
- package/datatable/useDataTableRow.props.d.ts +2 -0
- package/datatable/utils/compareValues.d.ts +20 -0
- package/datatable/utils/index.d.ts +1 -0
- package/datatable/utils/index.mjs +2 -0
- package/datatable/utils/index.mjs.map +1 -0
- package/dataview/index.d.ts +1 -0
- package/dataview/index.mjs +1 -1
- package/dataview/index.mjs.map +1 -1
- package/dataview/useDataView.d.ts +25 -1
- package/dataview/useDataView.props.d.ts +2 -2
- package/datepicker/index.d.ts +1 -0
- package/datepicker/index.mjs +1 -1
- package/datepicker/index.mjs.map +1 -1
- package/datepicker/useDatePicker.d.ts +2 -114
- package/datepicker/useDatePicker.props.d.ts +2 -2
- package/dialog/index.d.ts +1 -0
- package/dialog/index.mjs +1 -1
- package/dialog/index.mjs.map +1 -1
- package/dialog/useDialog.d.ts +274 -24
- package/dialog/useDialog.props.d.ts +2 -2
- package/divider/index.d.ts +1 -0
- package/divider/index.mjs +1 -1
- package/divider/index.mjs.map +1 -1
- package/divider/useDivider.d.ts +14 -1
- package/divider/useDivider.props.d.ts +2 -2
- package/dnd/index.d.ts +11 -0
- package/dnd/index.mjs +2 -0
- package/dnd/index.mjs.map +1 -0
- package/dnd/useDnd.d.ts +45 -0
- package/dnd/useDnd.props.d.ts +2 -0
- package/dnd/useDraggable.d.ts +14 -0
- package/dnd/useDraggable.props.d.ts +2 -0
- package/dnd/useDroppable.d.ts +11 -0
- package/dnd/useDroppable.props.d.ts +2 -0
- package/dnd/useSortable.d.ts +11 -0
- package/dnd/useSortable.props.d.ts +2 -0
- package/dnd/useSortableContainer.d.ts +24 -0
- package/dnd/useSortableContainer.props.d.ts +2 -0
- package/drawer/index.d.ts +1 -0
- package/drawer/index.mjs +1 -1
- package/drawer/index.mjs.map +1 -1
- package/drawer/useDrawer.d.ts +78 -16
- package/drawer/useDrawer.props.d.ts +2 -2
- package/fieldset/index.d.ts +1 -0
- package/fieldset/index.mjs +1 -1
- package/fieldset/index.mjs.map +1 -1
- package/fieldset/useFieldset.d.ts +80 -1
- package/fieldset/useFieldset.props.d.ts +2 -2
- package/fileupload/index.d.ts +1 -0
- package/fileupload/index.mjs +1 -1
- package/fileupload/index.mjs.map +1 -1
- package/fileupload/useFileUpload.d.ts +73 -4
- package/fileupload/useFileUpload.props.d.ts +2 -2
- package/floatlabel/index.d.ts +3 -0
- package/floatlabel/index.mjs +2 -0
- package/floatlabel/index.mjs.map +1 -0
- package/floatlabel/useFloatLabel.d.ts +6 -0
- package/floatlabel/useFloatLabel.props.d.ts +2 -0
- package/fluid/index.d.ts +1 -0
- package/fluid/index.mjs +1 -1
- package/fluid/index.mjs.map +1 -1
- package/fluid/useFluid.d.ts +6 -1
- package/fluid/useFluid.props.d.ts +2 -2
- package/focustrap/index.d.ts +1 -0
- package/focustrap/index.mjs +1 -1
- package/focustrap/index.mjs.map +1 -1
- package/focustrap/useFocusTrap.d.ts +16 -3
- package/focustrap/useFocusTrap.props.d.ts +2 -2
- package/gallery/index.d.ts +1 -0
- package/gallery/index.mjs +1 -1
- package/gallery/index.mjs.map +1 -1
- package/gallery/item/index.mjs +1 -1
- package/gallery/item/index.mjs.map +1 -1
- package/gallery/item/useGalleryItem.d.ts +17 -7
- package/gallery/item/useGalleryItem.props.d.ts +2 -2
- package/gallery/useGallery.d.ts +147 -6
- package/gallery/useGallery.props.d.ts +2 -2
- package/iconfield/index.d.ts +1 -0
- package/iconfield/index.mjs +1 -1
- package/iconfield/index.mjs.map +1 -1
- package/iconfield/useIconField.d.ts +6 -1
- package/iconfield/useIconField.props.d.ts +2 -2
- package/iftalabel/index.d.ts +3 -0
- package/iftalabel/index.mjs +2 -0
- package/iftalabel/index.mjs.map +1 -0
- package/iftalabel/useIftaLabel.d.ts +6 -0
- package/iftalabel/useIftaLabel.props.d.ts +2 -0
- package/inplace/index.d.ts +1 -0
- package/inplace/index.mjs +1 -1
- package/inplace/index.mjs.map +1 -1
- package/inplace/useInplace.d.ts +21 -2
- package/inplace/useInplace.props.d.ts +2 -2
- package/{colorpicker → inputcolor}/colorManager.d.ts +3 -2
- package/inputcolor/index.d.ts +4 -0
- package/inputcolor/index.mjs +2 -0
- package/inputcolor/index.mjs.map +1 -0
- package/inputcolor/useInputColor.d.ts +119 -0
- package/inputcolor/useInputColor.props.d.ts +2 -0
- package/inputgroup/index.d.ts +1 -0
- package/inputgroup/index.mjs +1 -1
- package/inputgroup/index.mjs.map +1 -1
- package/inputgroup/useInputGroup.d.ts +6 -1
- package/inputgroup/useInputGroup.props.d.ts +2 -2
- package/inputnumber/index.d.ts +1 -0
- package/inputnumber/index.mjs +1 -1
- package/inputnumber/index.mjs.map +1 -1
- package/inputnumber/useInputNumber.d.ts +55 -17
- package/inputnumber/useInputNumber.props.d.ts +2 -2
- package/inputotp/index.d.ts +1 -0
- package/inputotp/index.mjs +1 -1
- package/inputotp/index.mjs.map +1 -1
- package/inputotp/useInputOtp.d.ts +25 -6
- package/inputotp/useInputOtp.props.d.ts +2 -2
- package/inputpassword/index.d.ts +3 -0
- package/inputpassword/index.mjs +2 -0
- package/inputpassword/index.mjs.map +1 -0
- package/inputpassword/useInputPassword.d.ts +15 -0
- package/inputpassword/useInputPassword.props.d.ts +2 -0
- package/inputtags/index.d.ts +1 -0
- package/inputtags/index.mjs +1 -1
- package/inputtags/index.mjs.map +1 -1
- package/inputtags/useInputTags.d.ts +42 -12
- package/inputtags/useInputTags.props.d.ts +2 -2
- package/inputtext/index.d.ts +1 -0
- package/inputtext/index.mjs +1 -1
- package/inputtext/index.mjs.map +1 -1
- package/inputtext/useInputText.d.ts +8 -1
- package/inputtext/useInputText.props.d.ts +2 -2
- package/knob/index.d.ts +1 -0
- package/knob/index.mjs +1 -1
- package/knob/index.mjs.map +1 -1
- package/knob/useKnob.d.ts +51 -10
- package/knob/useKnob.props.d.ts +2 -2
- package/label/index.d.ts +1 -0
- package/label/index.mjs +1 -1
- package/label/index.mjs.map +1 -1
- package/label/useLabel.d.ts +6 -1
- package/label/useLabel.props.d.ts +2 -2
- package/listbox/index.d.ts +3 -0
- package/listbox/index.mjs +1 -1
- package/listbox/index.mjs.map +1 -1
- package/listbox/useListbox.d.ts +56 -18
- package/listbox/useListbox.props.d.ts +2 -2
- package/listbox/useListboxOption.d.ts +21 -0
- package/listbox/useListboxOption.props.d.ts +2 -0
- package/menu/checkboxitem/index.d.ts +2 -0
- package/menu/checkboxitem/index.mjs +2 -0
- package/menu/checkboxitem/index.mjs.map +1 -0
- package/menu/checkboxitem/useMenuCheckboxItem.d.ts +112 -0
- package/menu/checkboxitem/useMenuCheckboxItem.props.d.ts +2 -0
- package/menu/index.d.ts +1 -0
- package/menu/index.mjs +1 -1
- package/menu/index.mjs.map +1 -1
- package/menu/radioitem/index.d.ts +2 -0
- package/menu/radioitem/index.mjs +2 -0
- package/menu/radioitem/index.mjs.map +1 -0
- package/menu/radioitem/useMenuRadioItem.d.ts +106 -0
- package/menu/radioitem/useMenuRadioItem.props.d.ts +2 -0
- package/menu/submenu/index.d.ts +2 -0
- package/menu/submenu/index.mjs +2 -0
- package/menu/submenu/index.mjs.map +1 -0
- package/menu/submenu/useMenuSubmenu.d.ts +97 -0
- package/menu/submenu/useMenuSubmenu.props.d.ts +2 -0
- package/menu/useMenu.d.ts +215 -22
- package/menu/useMenu.props.d.ts +2 -2
- package/message/index.d.ts +1 -0
- package/message/index.mjs +1 -1
- package/message/index.mjs.map +1 -1
- package/message/useMessage.d.ts +13 -1
- package/message/useMessage.props.d.ts +2 -2
- package/metergroup/index.d.ts +1 -0
- package/metergroup/index.mjs +1 -1
- package/metergroup/index.mjs.map +1 -1
- package/metergroup/useMeterGroup.d.ts +36 -5
- package/metergroup/useMeterGroup.props.d.ts +2 -2
- package/navigationmenu/index.d.ts +3 -0
- package/navigationmenu/index.mjs +2 -0
- package/navigationmenu/index.mjs.map +1 -0
- package/navigationmenu/useNavigationMenu.d.ts +30 -0
- package/navigationmenu/useNavigationMenu.props.d.ts +2 -0
- package/orderlist/index.d.ts +3 -0
- package/orderlist/index.mjs +2 -0
- package/orderlist/index.mjs.map +1 -0
- package/orderlist/useOrderList.d.ts +73 -0
- package/orderlist/useOrderList.props.d.ts +2 -0
- package/organizationchart/index.d.ts +3 -0
- package/organizationchart/index.mjs +2 -0
- package/organizationchart/index.mjs.map +1 -0
- package/organizationchart/useOrganizationChart.d.ts +69 -0
- package/organizationchart/useOrganizationChart.props.d.ts +2 -0
- package/overlaybadge/index.d.ts +3 -0
- package/overlaybadge/index.mjs +2 -0
- package/overlaybadge/index.mjs.map +1 -0
- package/overlaybadge/useOverlayBadge.d.ts +1 -0
- package/overlaybadge/useOverlayBadge.props.d.ts +2 -0
- package/package.json +12 -15
- package/paginator/index.d.ts +1 -0
- package/paginator/index.mjs +1 -1
- package/paginator/index.mjs.map +1 -1
- package/paginator/usePaginator.d.ts +47 -1
- package/paginator/usePaginator.props.d.ts +2 -2
- package/panel/index.d.ts +1 -0
- package/panel/index.mjs +1 -1
- package/panel/index.mjs.map +1 -1
- package/panel/usePanel.d.ts +76 -8
- package/panel/usePanel.props.d.ts +2 -2
- package/picklist/index.d.ts +3 -0
- package/picklist/index.mjs +2 -0
- package/picklist/index.mjs.map +1 -0
- package/picklist/usePickList.d.ts +153 -0
- package/picklist/usePickList.props.d.ts +2 -0
- package/popover/index.d.ts +1 -0
- package/popover/index.mjs +1 -7
- package/popover/index.mjs.map +1 -1
- package/popover/usePopover.d.ts +65 -12
- package/popover/usePopover.props.d.ts +2 -2
- package/portal/index.d.ts +1 -0
- package/portal/index.mjs +1 -1
- package/portal/index.mjs.map +1 -1
- package/portal/usePortal.d.ts +4 -2
- package/portal/usePortal.props.d.ts +2 -2
- package/positioner/index.d.ts +3 -0
- package/positioner/index.mjs +2 -0
- package/positioner/index.mjs.map +1 -0
- package/positioner/usePositioner.anchor.d.ts +7 -0
- package/positioner/usePositioner.d.ts +11 -0
- package/positioner/usePositioner.fallback.d.ts +13 -0
- package/positioner/usePositioner.props.d.ts +2 -0
- package/positioner/usePositioner.utils.d.ts +21 -0
- package/progressbar/index.d.ts +1 -0
- package/progressbar/index.mjs +1 -1
- package/progressbar/index.mjs.map +1 -1
- package/progressbar/useProgressBar.d.ts +13 -1
- package/progressbar/useProgressBar.props.d.ts +2 -2
- package/progressspinner/index.d.ts +1 -0
- package/progressspinner/index.mjs +1 -1
- package/progressspinner/index.mjs.map +1 -1
- package/progressspinner/useProgressSpinner.d.ts +50 -1
- package/progressspinner/useProgressSpinner.props.d.ts +2 -2
- package/radiobutton/index.d.ts +1 -0
- package/radiobutton/index.mjs +1 -1
- package/radiobutton/index.mjs.map +1 -1
- package/radiobutton/useRadioButton.d.ts +41 -3
- package/radiobutton/useRadioButton.props.d.ts +2 -2
- package/radiobuttongroup/index.d.ts +3 -0
- package/radiobuttongroup/index.mjs +2 -0
- package/radiobuttongroup/index.mjs.map +1 -0
- package/radiobuttongroup/useRadioButtonGroup.d.ts +11 -0
- package/radiobuttongroup/useRadioButtonGroup.props.d.ts +2 -0
- package/rating/index.d.ts +3 -0
- package/rating/index.mjs +1 -1
- package/rating/index.mjs.map +1 -1
- package/rating/useRating.d.ts +46 -12
- package/rating/useRating.props.d.ts +2 -2
- package/rating/useRatingOption.d.ts +69 -0
- package/rating/useRatingOption.props.d.ts +2 -0
- package/scrollarea/index.d.ts +1 -0
- package/scrollarea/index.mjs +1 -1
- package/scrollarea/index.mjs.map +1 -1
- package/scrollarea/useScrollArea.d.ts +120 -15
- package/scrollarea/useScrollArea.props.d.ts +2 -2
- package/select/index.d.ts +3 -0
- package/select/index.mjs +2 -0
- package/select/index.mjs.map +1 -0
- package/select/useSelect.d.ts +190 -0
- package/select/useSelect.props.d.ts +2 -0
- package/select/useSelect.test.d.ts +1 -0
- package/sidebar/index.d.ts +7 -0
- package/sidebar/index.mjs +2 -0
- package/sidebar/index.mjs.map +1 -0
- package/sidebar/useSidebar.d.ts +117 -0
- package/sidebar/useSidebar.props.d.ts +2 -0
- package/sidebar/useSidebarLayout.d.ts +24 -0
- package/sidebar/useSidebarLayout.props.d.ts +2 -0
- package/sidebar/useSidebarMenuItem.d.ts +11 -0
- package/sidebar/useSidebarMenuItem.props.d.ts +2 -0
- package/skeleton/index.d.ts +1 -0
- package/skeleton/index.mjs +1 -1
- package/skeleton/index.mjs.map +1 -1
- package/skeleton/useSkeleton.d.ts +7 -1
- package/skeleton/useSkeleton.props.d.ts +2 -2
- package/slider/index.d.ts +1 -0
- package/slider/index.mjs +1 -1
- package/slider/index.mjs.map +1 -1
- package/slider/useSlider.d.ts +81 -48
- package/slider/useSlider.props.d.ts +2 -2
- package/speeddial/index.d.ts +1 -0
- package/speeddial/index.mjs +1 -1
- package/speeddial/index.mjs.map +1 -1
- package/speeddial/useSpeedDial.d.ts +89 -32
- package/speeddial/useSpeedDial.props.d.ts +2 -2
- package/splitter/index.d.ts +1 -0
- package/splitter/index.mjs +1 -1
- package/splitter/index.mjs.map +1 -1
- package/splitter/useSplitter.d.ts +57 -14
- package/splitter/useSplitter.props.d.ts +2 -2
- package/stepper/index.d.ts +1 -0
- package/stepper/index.mjs +1 -1
- package/stepper/index.mjs.map +1 -1
- package/stepper/useStepper.d.ts +47 -2
- package/stepper/useStepper.props.d.ts +2 -2
- package/styleclass/index.d.ts +1 -0
- package/styleclass/index.mjs +1 -1
- package/styleclass/index.mjs.map +1 -1
- package/styleclass/useStyleClass.d.ts +5 -1
- package/styleclass/useStyleClass.props.d.ts +2 -2
- package/tabs/index.d.ts +1 -0
- package/tabs/index.mjs +1 -1
- package/tabs/index.mjs.map +1 -1
- package/tabs/useTabs.d.ts +42 -3
- package/tabs/useTabs.props.d.ts +2 -2
- package/tag/index.d.ts +1 -0
- package/tag/index.mjs +1 -1
- package/tag/index.mjs.map +1 -1
- package/tag/useTag.d.ts +6 -1
- package/tag/useTag.props.d.ts +2 -2
- package/terminal/index.d.ts +1 -0
- package/terminal/index.mjs +1 -1
- package/terminal/index.mjs.map +1 -1
- package/terminal/useTerminal.d.ts +23 -2
- package/terminal/useTerminal.props.d.ts +2 -2
- package/textarea/index.d.ts +1 -0
- package/textarea/index.mjs +1 -1
- package/textarea/index.mjs.map +1 -1
- package/textarea/useTextarea.d.ts +9 -2
- package/textarea/useTextarea.props.d.ts +2 -2
- package/timeline/index.d.ts +1 -0
- package/timeline/index.mjs +1 -1
- package/timeline/index.mjs.map +1 -1
- package/timeline/useTimeline.d.ts +41 -1
- package/timeline/useTimeline.props.d.ts +2 -2
- package/toast/index.d.ts +1 -1
- package/toast/index.mjs +1 -1
- package/toast/index.mjs.map +1 -1
- package/toast/useToast.d.ts +85 -23
- package/toast/useToast.props.d.ts +2 -2
- package/toaster/ToastManager.d.ts +14 -0
- package/toaster/index.d.ts +4 -0
- package/toaster/index.mjs +2 -0
- package/toaster/index.mjs.map +1 -0
- package/toaster/useToaster.d.ts +50 -0
- package/toaster/useToaster.props.d.ts +2 -0
- package/togglebutton/index.d.ts +1 -0
- package/togglebutton/index.mjs +1 -1
- package/togglebutton/index.mjs.map +1 -1
- package/togglebutton/useToggleButton.d.ts +5 -3
- package/togglebutton/useToggleButton.props.d.ts +2 -2
- package/togglebuttongroup/index.d.ts +3 -0
- package/togglebuttongroup/index.mjs +2 -0
- package/togglebuttongroup/index.mjs.map +1 -0
- package/togglebuttongroup/useToggleButtonGroup.d.ts +17 -0
- package/togglebuttongroup/useToggleButtonGroup.props.d.ts +2 -0
- package/toggleswitch/index.d.ts +3 -0
- package/toggleswitch/index.mjs +2 -0
- package/toggleswitch/index.mjs.map +1 -0
- package/toggleswitch/useToggleSwitch.d.ts +48 -0
- package/toggleswitch/useToggleSwitch.props.d.ts +2 -0
- package/toolbar/index.d.ts +1 -0
- package/toolbar/index.mjs +1 -1
- package/toolbar/index.mjs.map +1 -1
- package/toolbar/useToolbar.d.ts +7 -1
- package/toolbar/useToolbar.props.d.ts +2 -2
- package/tooltip/index.d.ts +1 -0
- package/tooltip/index.mjs +1 -1
- package/tooltip/index.mjs.map +1 -1
- package/tooltip/useTooltip.d.ts +43 -24
- package/tooltip/useTooltip.props.d.ts +2 -2
- package/tooltipmanager/index.d.ts +2 -0
- package/tooltipmanager/index.mjs +2 -0
- package/tooltipmanager/index.mjs.map +1 -0
- package/tooltipmanager/useTooltipManager.d.ts +12 -0
- package/tooltipmanager/useTooltipManager.props.d.ts +2 -0
- package/tooltipmanager/useTooltipManager.test.d.ts +0 -0
- package/tree/TreeDragDropService.d.ts +13 -5
- package/tree/index.d.ts +7 -0
- package/tree/index.mjs +1 -1
- package/tree/index.mjs.map +1 -1
- package/tree/useTree.d.ts +96 -16
- package/tree/useTree.props.d.ts +2 -2
- package/tree/useTreeDragDrop.d.ts +24 -0
- package/tree/useTreeFlatten.d.ts +13 -0
- package/tree/useTreeKeyboard.d.ts +18 -0
- package/tree/useTreeNode.d.ts +45 -0
- package/tree/useTreeNode.props.d.ts +2 -0
- package/tree/useTreeSelection.d.ts +31 -0
- package/utils/itemKey.d.ts +10 -0
- package/LICENSE +0 -21
- package/colorpicker/index.d.ts +0 -3
- package/colorpicker/index.mjs +0 -2
- package/colorpicker/index.mjs.map +0 -1
- package/colorpicker/input/index.d.ts +0 -2
- package/colorpicker/input/index.mjs +0 -2
- package/colorpicker/input/index.mjs.map +0 -1
- package/colorpicker/input/useColorPickerInput.d.ts +0 -11
- package/colorpicker/input/useColorPickerInput.props.d.ts +0 -2
- package/colorpicker/slider/index.d.ts +0 -2
- package/colorpicker/slider/index.mjs +0 -2
- package/colorpicker/slider/index.mjs.map +0 -1
- package/colorpicker/slider/useColorPickerSlider.d.ts +0 -13
- package/colorpicker/slider/useColorPickerSlider.props.d.ts +0 -2
- package/colorpicker/useColorPicker.d.ts +0 -26
- package/colorpicker/useColorPicker.props.d.ts +0 -2
- package/commandmenu/index.d.ts +0 -2
- package/commandmenu/index.mjs +0 -2
- package/commandmenu/index.mjs.map +0 -1
- package/commandmenu/useCommandMenu.d.ts +0 -11
- package/commandmenu/useCommandMenu.props.d.ts +0 -2
- package/confirmdialog/index.d.ts +0 -2
- package/confirmdialog/index.mjs +0 -2
- package/confirmdialog/index.mjs.map +0 -1
- package/confirmdialog/useConfirmDialog.d.ts +0 -1
- package/confirmdialog/useConfirmDialog.props.d.ts +0 -2
- package/confirmpopup/index.d.ts +0 -2
- package/confirmpopup/index.mjs +0 -2
- package/confirmpopup/index.mjs.map +0 -1
- package/confirmpopup/useConfirmPopup.d.ts +0 -25
- package/confirmpopup/useConfirmPopup.props.d.ts +0 -2
- package/imagecompare/index.d.ts +0 -2
- package/imagecompare/index.mjs +0 -2
- package/imagecompare/index.mjs.map +0 -1
- package/imagecompare/useImageCompare.d.ts +0 -8
- package/imagecompare/useImageCompare.props.d.ts +0 -2
- package/menu/sub/index.d.ts +0 -2
- package/menu/sub/index.mjs +0 -2
- package/menu/sub/index.mjs.map +0 -1
- package/menu/sub/useMenuSub.d.ts +0 -19
- package/menu/sub/useMenuSub.props.d.ts +0 -2
- package/orgchart/index.d.ts +0 -2
- package/orgchart/index.mjs +0 -2
- package/orgchart/index.mjs.map +0 -1
- package/orgchart/useOrgChart.d.ts +0 -20
- package/orgchart/useOrgChart.props.d.ts +0 -2
- package/overlay/index.d.ts +0 -2
- package/overlay/index.mjs +0 -2
- package/overlay/index.mjs.map +0 -1
- package/overlay/useOverlay.d.ts +0 -16
- package/overlay/useOverlay.props.d.ts +0 -2
- package/password/index.d.ts +0 -2
- package/password/index.mjs +0 -2
- package/password/index.mjs.map +0 -1
- package/password/usePassword.d.ts +0 -35
- package/password/usePassword.props.d.ts +0 -2
- package/placer/index.d.ts +0 -2
- package/placer/index.mjs +0 -2
- package/placer/index.mjs.map +0 -1
- package/placer/usePlacer.d.ts +0 -12
- package/placer/usePlacer.props.d.ts +0 -2
- package/switch/index.d.ts +0 -2
- package/switch/index.mjs +0 -2
- package/switch/index.mjs.map +0 -1
- package/switch/useSwitch.d.ts +0 -7
- package/switch/useSwitch.props.d.ts +0 -2
- package/toast/item/index.css +0 -2
- package/toast/item/index.css.map +0 -1
- package/toast/item/index.d.ts +0 -2
- package/toast/item/index.mjs +0 -2
- package/toast/item/index.mjs.map +0 -1
- package/toast/item/useToastItem.d.ts +0 -25
- package/toast/item/useToastItem.props.d.ts +0 -2
- package/toast/toastStore.d.ts +0 -40
- package/tooltip/group/index.d.ts +0 -2
- package/tooltip/group/index.mjs +0 -2
- package/tooltip/group/index.mjs.map +0 -1
- package/tooltip/group/useTooltipGroup.d.ts +0 -9
- package/tooltip/group/useTooltipGroup.props.d.ts +0 -2
- /package/{colorpicker/input/useColorPickerInput.test.d.ts → autocomplete/useAutoComplete.test.d.ts} +0 -0
- /package/{colorpicker/slider/useColorPickerSlider.test.d.ts → checkboxgroup/useCheckboxGroup.test.d.ts} +0 -0
- /package/{colorpicker/useColorPicker.test.d.ts → collapsible/useCollapsible.test.d.ts} +0 -0
- /package/{commandmenu/useCommandMenu.test.d.ts → compare/useCompare.test.d.ts} +0 -0
- /package/{confirmdialog/useConfirmDialog.test.d.ts → floatlabel/useFloatLabel.test.d.ts} +0 -0
- /package/{confirmpopup/useConfirmPopup.test.d.ts → iftalabel/useIftaLabel.test.d.ts} +0 -0
- /package/{imagecompare/useImageCompare.test.d.ts → inputcolor/useInputColor.test.d.ts} +0 -0
- /package/{orgchart/useOrgChart.test.d.ts → inputpassword/useInputPassword.test.d.ts} +0 -0
- /package/{overlay/useOverlay.test.d.ts → navigationmenu/useNavigationMenu.test.d.ts} +0 -0
- /package/{password/usePassword.test.d.ts → organizationchart/useOrganizationChart.test.d.ts} +0 -0
- /package/{placer/usePlacer.test.d.ts → overlaybadge/useOverlayBadge.test.d.ts} +0 -0
- /package/{progressspinner/useProgressSpinner.test.d.ts → positioner/usePositioner.test.d.ts} +0 -0
- /package/{rating/useRating.test.d.ts → radiobuttongroup/useRadioButtonGroup.test.d.ts} +0 -0
- /package/{switch/useSwitch.test.d.ts → toaster/useToaster.test.d.ts} +0 -0
- /package/{toast/item/useToastItem.test.d.ts → togglebuttongroup/useToggleButtonGroup.test.d.ts} +0 -0
- /package/{tooltip/group/useTooltipGroup.test.d.ts → toggleswitch/useToggleSwitch.test.d.ts} +0 -0
|
@@ -1 +1,80 @@
|
|
|
1
|
-
|
|
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 {
|
|
2
|
-
export declare const defaultProps:
|
|
1
|
+
import type { UseFieldsetProps } from '@primereact/types/headless/fieldset';
|
|
2
|
+
export declare const defaultProps: UseFieldsetProps;
|
package/fileupload/index.d.ts
CHANGED
package/fileupload/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{withHeadless as
|
|
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
|
package/fileupload/index.mjs.map
CHANGED
|
@@ -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};\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,4BAC7B,OAAS,YAAAC,EAAU,cAAAC,EAAY,eAAAC,MAAmB,kBAClD,UAAYC,MAAW,QCAhB,IAAMC,EAAmC,CAC5C,KAAM,OACN,IAAK,OACL,SAAU,GACV,OAAQ,OACR,SAAU,GACV,KAAM,GACN,YAAa,OACb,UAAW,OACX,gBAAiB,GACjB,aAAc,GACd,wBAAyB,0DACzB,uBAAwB,gEACxB,uBAAwB,mDACxB,cAAe,OACf,SAAU,OACV,eAAg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,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,gBAAAA,OAAoB,4BAC7B,OAAS,YAAAC,GAAU,cAAAC,EAAY,eAAAC,MAAmB,kBAClD,UAAYC,MAAW,QCAhB,IAAMC,EAAmC,CAC5C,KAAM,OACN,IAAK,OACL,SAAU,GACV,OAAQ,OACR,SAAU,GACV,KAAM,GACN,YAAa,OACb,UAAW,OACX,gBAAiB,GACjB,aAAc,GACd,wBAAyB,0DACzB,uBAAwB,gEACxB,uBAAwB,mDACxB,cAAe,OACf,SAAU,OACV,SAAU,OACV,eAAgB,OAChB,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E,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/
|
|
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
|
-
|
|
13
|
-
|
|
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 {
|
|
2
|
-
export declare const defaultProps:
|
|
1
|
+
import type { UseFileUploadProps } from '@primereact/types/headless/fileupload';
|
|
2
|
+
export declare const defaultProps: UseFileUploadProps;
|
|
@@ -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"]}
|
package/fluid/index.d.ts
CHANGED
package/fluid/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{withHeadless as
|
|
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
|
package/fluid/index.mjs.map
CHANGED
|
@@ -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 {
|
|
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"]}
|
package/fluid/useFluid.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export declare const useFluid: (inProps?: unknown) => import("@primereact/types/core").HeadlessInstance<import("@primereact/types/
|
|
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 {
|
|
2
|
-
export declare const defaultProps:
|
|
1
|
+
import type { UseFluidProps } from '@primereact/types/headless/fluid';
|
|
2
|
+
export declare const defaultProps: UseFluidProps;
|
package/focustrap/index.d.ts
CHANGED
package/focustrap/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
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
|
package/focustrap/index.mjs.map
CHANGED
|
@@ -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,E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,EACN,EACL,EACA,gBAAC,OAAAC,EAAA,GACOC,EAAWD,EAAA,CACX,IAAK9B,EACL,QAASc,GACNe,EACN,EACL,CACJ,CAGJ,EAGA,OAAM,YAAU,IAAM,CACO3B,EAAa,UAIjCN,IACDuB,EAAK,EACLF,EAAiB,GAEzB,EAAG,CAACrB,EAAUuB,EAAMF,EAAkBf,CAAY,CAAC,EAEnD8B,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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,EAAK,CAAC,EAGlD1B,EAAyB,QAAU,IACvC,EAAG,CAACiB,CAAa,CAAC,EAGlB,OAAM,YAAU,IAAM,CAKlB,GAJI,GAAC3B,GAID,CAFqBgB,EAAUP,CAAY,GAI/C,OAAAmB,EAAK,EACLH,EAAiB,EAEV,IAAMU,EAAO,CACxB,EAAG,CAACnC,EAAS4B,EAAMH,EAAkBU,CAAM,CAAC,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/
|
|
3
|
-
|
|
4
|
-
|
|
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 {
|
|
2
|
-
export declare const defaultProps:
|
|
1
|
+
import type { UseFocusTrapProps } from '@primereact/types/headless/focustrap';
|
|
2
|
+
export declare const defaultProps: UseFocusTrapProps;
|
package/gallery/index.d.ts
CHANGED
package/gallery/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{withHeadless as
|
|
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
|