@majapisoftwares/ui 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base.css +359 -0
- package/bootstrap/AppProps.d.ts +10 -0
- package/bootstrap/AppProps.js +1 -0
- package/bootstrap/index.d.ts +1 -0
- package/bootstrap/index.js +1 -0
- package/bootstrap/modeScript.d.ts +2 -0
- package/bootstrap/modeScript.js +35 -0
- package/bootstrap/nprogress.d.ts +1 -0
- package/bootstrap/nprogress.js +19 -0
- package/bootstrap/scrolledScript.d.ts +2 -0
- package/bootstrap/scrolledScript.js +27 -0
- package/bootstrap/setupFocusManager.d.ts +1 -0
- package/bootstrap/setupFocusManager.js +13 -0
- package/bootstrap/suppressConsoleLog.d.ts +1 -0
- package/bootstrap/suppressConsoleLog.js +8 -0
- package/components/Accordion/Accordion.d.ts +19 -0
- package/components/Accordion/Accordion.jsx +27 -0
- package/components/Accordion/index.d.ts +3 -0
- package/components/Accordion/index.jsx +3 -0
- package/components/Alert/Alert.d.ts +31 -0
- package/components/Alert/Alert.jsx +53 -0
- package/components/Alert/index.d.ts +3 -0
- package/components/Alert/index.jsx +3 -0
- package/components/Aurora/Aurora.d.ts +10 -0
- package/components/Aurora/Aurora.jsx +189 -0
- package/components/Aurora/index.d.ts +3 -0
- package/components/Aurora/index.jsx +3 -0
- package/components/Autocomplete/Autocomplete.d.ts +7 -0
- package/components/Autocomplete/Autocomplete.jsx +23 -0
- package/components/Autocomplete/UnstyledAutocomplete.d.ts +36 -0
- package/components/Autocomplete/UnstyledAutocomplete.jsx +73 -0
- package/components/Autocomplete/index.d.ts +5 -0
- package/components/Autocomplete/index.jsx +5 -0
- package/components/BackgroundEffects/BottomBlurryPoint.d.ts +3 -0
- package/components/BackgroundEffects/BottomBlurryPoint.jsx +14 -0
- package/components/BackgroundEffects/TopBlurryPoint.d.ts +3 -0
- package/components/BackgroundEffects/TopBlurryPoint.jsx +14 -0
- package/components/Badge/Badge.d.ts +42 -0
- package/components/Badge/Badge.jsx +50 -0
- package/components/Badge/index.d.ts +3 -0
- package/components/Badge/index.jsx +3 -0
- package/components/Breadcrumbs/Breadcrumbs.d.ts +11 -0
- package/components/Breadcrumbs/Breadcrumbs.jsx +42 -0
- package/components/Breadcrumbs/index.d.ts +3 -0
- package/components/Breadcrumbs/index.jsx +3 -0
- package/components/Button/Button.d.ts +111 -0
- package/components/Button/Button.jsx +129 -0
- package/components/Button/UnstyledButton.d.ts +10 -0
- package/components/Button/UnstyledButton.jsx +13 -0
- package/components/Button/index.d.ts +3 -0
- package/components/Button/index.jsx +3 -0
- package/components/Carousel/Carousel.d.ts +19 -0
- package/components/Carousel/Carousel.jsx +55 -0
- package/components/Carousel/index.d.ts +3 -0
- package/components/Carousel/index.jsx +3 -0
- package/components/Checkbox/Checkbox.d.ts +14 -0
- package/components/Checkbox/Checkbox.jsx +45 -0
- package/components/Checkbox/index.d.ts +3 -0
- package/components/Checkbox/index.js +3 -0
- package/components/Code/Code.d.ts +12 -0
- package/components/Code/Code.jsx +25 -0
- package/components/Code/Json.d.ts +5 -0
- package/components/Code/Json.jsx +7 -0
- package/components/Code/index.d.ts +4 -0
- package/components/Code/index.jsx +4 -0
- package/components/ConfirmationButton/ConfirmationButton.d.ts +17 -0
- package/components/ConfirmationButton/ConfirmationButton.jsx +13 -0
- package/components/ConfirmationButton/index.d.ts +3 -0
- package/components/ConfirmationButton/index.jsx +3 -0
- package/components/ContextMenu/ContextMenu.d.ts +28 -0
- package/components/ContextMenu/ContextMenu.jsx +70 -0
- package/components/ContextMenu/index.d.ts +3 -0
- package/components/ContextMenu/index.jsx +3 -0
- package/components/CopyButton/CopyButton.d.ts +7 -0
- package/components/CopyButton/CopyButton.jsx +29 -0
- package/components/CopyButton/index.d.ts +3 -0
- package/components/CopyButton/index.jsx +3 -0
- package/components/DateInput/DateInput.d.ts +6 -0
- package/components/DateInput/DateInput.jsx +19 -0
- package/components/DateInput/DateTimeInput.d.ts +3 -0
- package/components/DateInput/DateTimeInput.jsx +8 -0
- package/components/DateInput/index.d.ts +4 -0
- package/components/DateInput/index.jsx +4 -0
- package/components/DateInput/useRefValue.d.ts +5 -0
- package/components/DateInput/useRefValue.js +48 -0
- package/components/DatePicker/DatePicker.d.ts +19 -0
- package/components/DatePicker/DatePicker.jsx +55 -0
- package/components/DatePicker/index.d.ts +3 -0
- package/components/DatePicker/index.jsx +3 -0
- package/components/DateRangePicker/DateRangePicker.d.ts +16 -0
- package/components/DateRangePicker/DateRangePicker.jsx +56 -0
- package/components/DateRangePicker/index.d.ts +3 -0
- package/components/DateRangePicker/index.jsx +3 -0
- package/components/Dialog/Dialog.d.ts +25 -0
- package/components/Dialog/Dialog.jsx +35 -0
- package/components/Dialog/Dialogs.d.ts +1 -0
- package/components/Dialog/Dialogs.jsx +21 -0
- package/components/Dialog/dialogs.state.d.ts +21 -0
- package/components/Dialog/dialogs.state.js +40 -0
- package/components/Dialog/index.d.ts +6 -0
- package/components/Dialog/index.jsx +7 -0
- package/components/Drawer/Drawer.d.ts +15 -0
- package/components/Drawer/Drawer.jsx +72 -0
- package/components/Drawer/index.d.ts +3 -0
- package/components/Drawer/index.jsx +3 -0
- package/components/DropdownMenu/DropdownMenu.d.ts +33 -0
- package/components/DropdownMenu/DropdownMenu.jsx +74 -0
- package/components/DropdownMenu/index.d.ts +3 -0
- package/components/DropdownMenu/index.jsx +3 -0
- package/components/ErrorBoundary/ErrorBoundary.d.ts +18 -0
- package/components/ErrorBoundary/ErrorBoundary.jsx +32 -0
- package/components/ErrorBoundary/index.d.ts +3 -0
- package/components/ErrorBoundary/index.jsx +3 -0
- package/components/ErrorPage/Error404Page.d.ts +1 -0
- package/components/ErrorPage/Error404Page.jsx +4 -0
- package/components/ErrorPage/Error500Page.d.ts +1 -0
- package/components/ErrorPage/Error500Page.jsx +4 -0
- package/components/ErrorPage/ErrorPage.d.ts +11 -0
- package/components/ErrorPage/ErrorPage.jsx +23 -0
- package/components/FileInput/FileInput.d.ts +47 -0
- package/components/FileInput/FileInput.jsx +144 -0
- package/components/FileInput/PreviewFile.d.ts +13 -0
- package/components/FileInput/PreviewFile.jsx +55 -0
- package/components/FileInput/index.d.ts +3 -0
- package/components/FileInput/index.jsx +3 -0
- package/components/FileSelect/FileSelect.d.ts +31 -0
- package/components/FileSelect/FileSelect.jsx +143 -0
- package/components/FileSelect/index.d.ts +3 -0
- package/components/FileSelect/index.jsx +3 -0
- package/components/Footer/Footer.d.ts +19 -0
- package/components/Footer/Footer.jsx +30 -0
- package/components/Footer/index.d.ts +3 -0
- package/components/Footer/index.jsx +3 -0
- package/components/GridPattern/GridPattern.d.ts +2 -0
- package/components/GridPattern/GridPattern.jsx +12 -0
- package/components/GridPattern/index.d.ts +3 -0
- package/components/GridPattern/index.jsx +3 -0
- package/components/Group/Group.d.ts +5 -0
- package/components/Group/Group.jsx +6 -0
- package/components/Group/index.d.ts +3 -0
- package/components/Group/index.jsx +3 -0
- package/components/Header/Header.d.ts +5 -0
- package/components/Header/Header.jsx +19 -0
- package/components/Header/index.d.ts +3 -0
- package/components/Header/index.jsx +3 -0
- package/components/ImageInput/ImageInput.d.ts +4 -0
- package/components/ImageInput/ImageInput.jsx +8 -0
- package/components/ImageInput/index.d.ts +3 -0
- package/components/ImageInput/index.jsx +3 -0
- package/components/Input/Input.d.ts +14 -0
- package/components/Input/Input.jsx +57 -0
- package/components/Input/InputIcon.d.ts +9 -0
- package/components/Input/InputIcon.jsx +7 -0
- package/components/Input/MultiSelectInput.d.ts +13 -0
- package/components/Input/MultiSelectInput.jsx +28 -0
- package/components/Input/NumericInput.d.ts +6 -0
- package/components/Input/NumericInput.jsx +6 -0
- package/components/Input/PatternInput.d.ts +6 -0
- package/components/Input/PatternInput.jsx +6 -0
- package/components/Input/UnstyledInput.d.ts +22 -0
- package/components/Input/UnstyledInput.jsx +28 -0
- package/components/Input/index.d.ts +6 -0
- package/components/Input/index.jsx +6 -0
- package/components/Input2/InputWrapper.d.ts +11 -0
- package/components/Input2/InputWrapper.jsx +11 -0
- package/components/Link/Link.d.ts +3 -0
- package/components/Link/Link.jsx +9 -0
- package/components/Link/index.d.ts +3 -0
- package/components/Link/index.jsx +3 -0
- package/components/Loading/Loading.d.ts +3 -0
- package/components/Loading/Loading.jsx +13 -0
- package/components/Loading/index.d.ts +3 -0
- package/components/Loading/index.jsx +3 -0
- package/components/Magnet/Magnet.d.ts +13 -0
- package/components/Magnet/Magnet.jsx +50 -0
- package/components/Magnet/index.d.ts +3 -0
- package/components/Magnet/index.jsx +3 -0
- package/components/Markdown/Markdown.d.ts +8 -0
- package/components/Markdown/Markdown.jsx +13 -0
- package/components/Markdown/index.d.ts +3 -0
- package/components/Markdown/index.jsx +3 -0
- package/components/Menu/Menu.d.ts +28 -0
- package/components/Menu/Menu.jsx +54 -0
- package/components/Modal/Modal.d.ts +45 -0
- package/components/Modal/Modal.jsx +65 -0
- package/components/Modal/index.d.ts +4 -0
- package/components/Modal/index.jsx +4 -0
- package/components/Modal/useModalState.d.ts +6 -0
- package/components/Modal/useModalState.js +16 -0
- package/components/ModeToggle/ModeToggle.d.ts +9 -0
- package/components/ModeToggle/ModeToggle.jsx +12 -0
- package/components/ModeToggle/index.d.ts +4 -0
- package/components/ModeToggle/index.jsx +5 -0
- package/components/ModeToggle/useModeToggle.d.ts +1 -0
- package/components/ModeToggle/useModeToggle.js +21 -0
- package/components/MultiSelect/MultiSelect.d.ts +28 -0
- package/components/MultiSelect/MultiSelect.jsx +130 -0
- package/components/MultiSelect/index.d.ts +3 -0
- package/components/MultiSelect/index.jsx +3 -0
- package/components/MultiText/MultiText.d.ts +23 -0
- package/components/MultiText/MultiText.jsx +119 -0
- package/components/MultiText/index.d.ts +3 -0
- package/components/MultiText/index.jsx +3 -0
- package/components/NavigationDrawer/NavigationDrawer.d.ts +9 -0
- package/components/NavigationDrawer/NavigationDrawer.jsx +29 -0
- package/components/NavigationDrawer/NavigationItem.d.ts +13 -0
- package/components/NavigationDrawer/NavigationItem.jsx +24 -0
- package/components/NavigationDrawer/index.d.ts +6 -0
- package/components/NavigationDrawer/index.jsx +6 -0
- package/components/NavigationDrawer/navigationDrawer.state.d.ts +9 -0
- package/components/NavigationDrawer/navigationDrawer.state.js +19 -0
- package/components/NoSsr/NoSsr.d.ts +4 -0
- package/components/NoSsr/NoSsr.jsx +8 -0
- package/components/NoSsr/index.d.ts +3 -0
- package/components/NoSsr/index.jsx +3 -0
- package/components/Noise/Noise.d.ts +11 -0
- package/components/Noise/Noise.jsx +69 -0
- package/components/Noise/index.d.ts +3 -0
- package/components/Noise/index.jsx +3 -0
- package/components/Notifications/Notifications.d.ts +3 -0
- package/components/Notifications/Notifications.jsx +60 -0
- package/components/Notifications/index.d.ts +5 -0
- package/components/Notifications/index.jsx +6 -0
- package/components/Notifications/notifications.state.d.ts +24 -0
- package/components/Notifications/notifications.state.js +41 -0
- package/components/Orb/Orb.d.ts +8 -0
- package/components/Orb/Orb.jsx +258 -0
- package/components/Orb/index.d.ts +3 -0
- package/components/Orb/index.jsx +3 -0
- package/components/Pagination/Pagination.d.ts +13 -0
- package/components/Pagination/Pagination.jsx +64 -0
- package/components/Pagination/index.d.ts +3 -0
- package/components/Pagination/index.jsx +3 -0
- package/components/Particles/Particles.d.ts +18 -0
- package/components/Particles/Particles.jsx +205 -0
- package/components/Particles/index.d.ts +3 -0
- package/components/Particles/index.jsx +3 -0
- package/components/PictureCropInput/PictureCropInput.d.ts +17 -0
- package/components/PictureCropInput/PictureCropInput.jsx +153 -0
- package/components/PictureCropInput/canvasPreview.d.ts +2 -0
- package/components/PictureCropInput/canvasPreview.js +37 -0
- package/components/PictureCropInput/index.d.ts +3 -0
- package/components/PictureCropInput/index.js +3 -0
- package/components/Popover/Popover.d.ts +13 -0
- package/components/Popover/Popover.jsx +22 -0
- package/components/Popover/index.d.ts +3 -0
- package/components/Popover/index.jsx +3 -0
- package/components/Resizable/Resizable.d.ts +12 -0
- package/components/Resizable/Resizable.jsx +54 -0
- package/components/Resizable/index.d.ts +3 -0
- package/components/Resizable/index.jsx +3 -0
- package/components/ScrollArea/ScrollArea.d.ts +9 -0
- package/components/ScrollArea/ScrollArea.jsx +16 -0
- package/components/ScrollArea/index.d.ts +3 -0
- package/components/ScrollArea/index.jsx +3 -0
- package/components/Select/Select.d.ts +24 -0
- package/components/Select/Select.jsx +55 -0
- package/components/Select/index.d.ts +3 -0
- package/components/Select/index.jsx +3 -0
- package/components/Skeleton/Skeleton.d.ts +2 -0
- package/components/Skeleton/Skeleton.jsx +8 -0
- package/components/Skeleton/index.d.ts +3 -0
- package/components/Skeleton/index.jsx +3 -0
- package/components/Slider/Slider.d.ts +10 -0
- package/components/Slider/Slider.jsx +21 -0
- package/components/Slider/index.d.ts +3 -0
- package/components/Slider/index.jsx +3 -0
- package/components/Spotlight/Spotlight.d.ts +30 -0
- package/components/Spotlight/Spotlight.jsx +77 -0
- package/components/Spotlight/index.d.ts +3 -0
- package/components/Spotlight/index.jsx +3 -0
- package/components/SpotlightCard/SpotlightCard.d.ts +7 -0
- package/components/SpotlightCard/SpotlightCard.jsx +35 -0
- package/components/SpotlightCard/index.d.ts +3 -0
- package/components/SpotlightCard/index.jsx +3 -0
- package/components/Stack/Stack.d.ts +4 -0
- package/components/Stack/Stack.jsx +5 -0
- package/components/Stack/index.d.ts +3 -0
- package/components/Stack/index.jsx +3 -0
- package/components/StarBorder/StarBorder.d.ts +11 -0
- package/components/StarBorder/StarBorder.jsx +19 -0
- package/components/StarBorder/index.d.ts +3 -0
- package/components/StarBorder/index.jsx +3 -0
- package/components/Switch/Switch.d.ts +16 -0
- package/components/Switch/Switch.jsx +24 -0
- package/components/Switch/index.d.ts +3 -0
- package/components/Switch/index.jsx +3 -0
- package/components/Table/DataTable.d.ts +57 -0
- package/components/Table/DataTable.jsx +155 -0
- package/components/Table/Table.d.ts +27 -0
- package/components/Table/Table.jsx +31 -0
- package/components/Table/TableActionButton.d.ts +6 -0
- package/components/Table/TableActionButton.jsx +20 -0
- package/components/Table/TableBody.d.ts +6 -0
- package/components/Table/TableBody.jsx +10 -0
- package/components/Table/TableCell.d.ts +9 -0
- package/components/Table/TableCell.jsx +18 -0
- package/components/Table/TableFooter.d.ts +5 -0
- package/components/Table/TableFooter.jsx +5 -0
- package/components/Table/TableFooterWithPagination.d.ts +13 -0
- package/components/Table/TableFooterWithPagination.jsx +57 -0
- package/components/Table/TableHead.d.ts +5 -0
- package/components/Table/TableHead.jsx +9 -0
- package/components/Table/TableHeadContext.d.ts +4 -0
- package/components/Table/TableHeadContext.jsx +3 -0
- package/components/Table/TableHeader.d.ts +7 -0
- package/components/Table/TableHeader.jsx +15 -0
- package/components/Table/TableRow.d.ts +8 -0
- package/components/Table/TableRow.jsx +9 -0
- package/components/Table/index.d.ts +3 -0
- package/components/Table/index.jsx +3 -0
- package/components/Tabs/Tabs.d.ts +9 -0
- package/components/Tabs/Tabs.jsx +13 -0
- package/components/Tabs/index.d.ts +3 -0
- package/components/Tabs/index.jsx +3 -0
- package/components/TabsSwitcher/Tab.d.ts +15 -0
- package/components/TabsSwitcher/Tab.jsx +18 -0
- package/components/TabsSwitcher/TabsSwitcher.d.ts +22 -0
- package/components/TabsSwitcher/TabsSwitcher.jsx +31 -0
- package/components/TabsSwitcher/index.d.ts +4 -0
- package/components/TabsSwitcher/index.jsx +4 -0
- package/components/Text/Text.d.ts +24 -0
- package/components/Text/Text.jsx +28 -0
- package/components/Text/index.d.ts +3 -0
- package/components/Text/index.jsx +3 -0
- package/components/Textarea/Textarea.d.ts +5 -0
- package/components/Textarea/Textarea.jsx +6 -0
- package/components/Textarea/index.d.ts +3 -0
- package/components/Textarea/index.js +3 -0
- package/components/Threads/Threads.d.ts +9 -0
- package/components/Threads/Threads.jsx +203 -0
- package/components/Threads/index.d.ts +3 -0
- package/components/Threads/index.jsx +3 -0
- package/components/Tooltip/Tooltip.d.ts +11 -0
- package/components/Tooltip/Tooltip.jsx +21 -0
- package/components/Tooltip/index.d.ts +3 -0
- package/components/Tooltip/index.jsx +3 -0
- package/components/VisibilityActivatedButton/VisibilityActivatedButton.d.ts +7 -0
- package/components/VisibilityActivatedButton/VisibilityActivatedButton.jsx +18 -0
- package/components/VisibilityActivatedButton/index.d.ts +3 -0
- package/components/VisibilityActivatedButton/index.jsx +3 -0
- package/form.d.ts +82 -0
- package/form.js +113 -0
- package/form2.d.ts +15 -0
- package/form2.jsx +29 -0
- package/hooks/useBeforeUnload.d.ts +1 -0
- package/hooks/useBeforeUnload.js +17 -0
- package/hooks/useDebounceEffect.d.ts +2 -0
- package/hooks/useDebounceEffect.js +14 -0
- package/hooks/useDebouncedValue.d.ts +2 -0
- package/hooks/useDebouncedValue.js +14 -0
- package/hooks/useLagRadar.d.ts +1 -0
- package/hooks/useLagRadar.jsx +124 -0
- package/hooks/useMediaQuery.d.ts +1 -0
- package/hooks/useMediaQuery.js +37 -0
- package/hooks/useMutationWindowCloseProtection.d.ts +2 -0
- package/hooks/useMutationWindowCloseProtection.js +13 -0
- package/hooks/useScroll.d.ts +3 -0
- package/hooks/useScroll.js +47 -0
- package/hooks/useTranslation.d.ts +4 -0
- package/hooks/useTranslation.js +11 -0
- package/hooks/useWhyDidYouUpdate.d.ts +3 -0
- package/hooks/useWhyDidYouUpdate.js +44 -0
- package/imgur.d.ts +1 -0
- package/imgur.js +13 -0
- package/package.json +9 -0
- package/styles/DayPicker.classNames.d.ts +29 -0
- package/styles/DayPicker.classNames.js +30 -0
- package/styles/DayPicker.classNames.ts +81 -0
- package/styles/Dropdown.classNames.d.ts +6 -0
- package/styles/Dropdown.classNames.js +7 -0
- package/styles/Dropdown.classNames.ts +38 -0
- package/styles/Input.css +23 -0
- package/styles/Modal.classNames.d.ts +2 -0
- package/styles/Modal.classNames.js +3 -0
- package/styles/Modal.classNames.ts +15 -0
- package/styles/MultiText.css +40 -0
- package/styles/Pagination.css +19 -0
- package/styles/Tabs.css +23 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/types.d.ts +6 -0
- package/types.js +1 -0
- package/utils/UseState.d.ts +3 -0
- package/utils/UseState.js +1 -0
- package/utils/blobToText.d.ts +1 -0
- package/utils/blobToText.js +13 -0
- package/utils/capitalize.d.ts +1 -0
- package/utils/capitalize.js +6 -0
- package/utils/clsx.d.ts +2 -0
- package/utils/clsx.js +5 -0
- package/utils/copy2DToClipboard.d.ts +1 -0
- package/utils/copy2DToClipboard.js +44 -0
- package/utils/cpfCpnjUtils.d.ts +3 -0
- package/utils/cpfCpnjUtils.js +43 -0
- package/utils/createLocalStorageStateHydration.d.ts +1 -0
- package/utils/createLocalStorageStateHydration.js +18 -0
- package/utils/createStateHydration.d.ts +3 -0
- package/utils/createStateHydration.js +49 -0
- package/utils/csvBlobToJson.d.ts +2 -0
- package/utils/csvBlobToJson.js +60 -0
- package/utils/downloadArrayAsCSV.d.ts +1 -0
- package/utils/downloadArrayAsCSV.js +34 -0
- package/utils/emailRegExp.d.ts +2 -0
- package/utils/emailRegExp.js +3 -0
- package/utils/fakeArray.d.ts +1 -0
- package/utils/fakeArray.js +3 -0
- package/utils/filterBoolean.d.ts +1 -0
- package/utils/filterBoolean.js +3 -0
- package/utils/formatClock.d.ts +1 -0
- package/utils/formatClock.js +21 -0
- package/utils/formatTime.d.ts +2 -0
- package/utils/formatTime.js +40 -0
- package/utils/getInitials.d.ts +4 -0
- package/utils/getInitials.js +8 -0
- package/utils/isBrowser.d.ts +12 -0
- package/utils/isBrowser.js +26 -0
- package/utils/ms.d.ts +6 -0
- package/utils/ms.js +31 -0
- package/utils/preventDefault.d.ts +1 -0
- package/utils/preventDefault.js +3 -0
- package/utils/recursiveChildrenMap.d.ts +2 -0
- package/utils/recursiveChildrenMap.js +16 -0
- package/utils/setSelectionRange.d.ts +1 -0
- package/utils/setSelectionRange.js +55 -0
- package/utils/smoothScrollToHref.d.ts +2 -0
- package/utils/smoothScrollToHref.js +10 -0
- package/utils/stopPropagation.d.ts +2 -0
- package/utils/stopPropagation.js +3 -0
- package/utils/stripHtml.d.ts +1 -0
- package/utils/stripHtml.js +4 -0
- package/utils/stripLineBreak.d.ts +1 -0
- package/utils/stripLineBreak.js +4 -0
- package/utils/stripMarkdown.d.ts +1 -0
- package/utils/stripMarkdown.js +28 -0
- package/utils/xlsxBlobToJson.d.ts +2 -0
- package/utils/xlsxBlobToJson.js +59 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PaginationProps {
|
|
2
|
+
totalItems?: number;
|
|
3
|
+
itemsPerPage?: number;
|
|
4
|
+
currentPage: number;
|
|
5
|
+
onChangePage?: (page: number) => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
pageHref?: (page: number) => string;
|
|
8
|
+
paginationText?: string;
|
|
9
|
+
previousText?: string;
|
|
10
|
+
nextText?: string;
|
|
11
|
+
pagesToClickAmount?: number;
|
|
12
|
+
}
|
|
13
|
+
export default function Pagination({ totalItems, itemsPerPage, currentPage, onChangePage, className, pageHref, paginationText, previousText, nextText, pagesToClickAmount, }: PaginationProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/20/solid";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import clsx from "../../utils/clsx";
|
|
4
|
+
import { range } from "lodash-es";
|
|
5
|
+
import UnstyledButton from "../Button/UnstyledButton";
|
|
6
|
+
export default function Pagination({ totalItems, itemsPerPage, currentPage, onChangePage, className, pageHref, paginationText = "Pagination", previousText = "Previous", nextText = "Next", pagesToClickAmount = 7, }) {
|
|
7
|
+
const [page, setPage] = useState(currentPage);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (page !== currentPage) {
|
|
10
|
+
setPage(currentPage);
|
|
11
|
+
}
|
|
12
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13
|
+
}, [currentPage]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (onChangePage) {
|
|
16
|
+
onChangePage(page);
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
}, [page]);
|
|
20
|
+
const [previousTotalItems, setPreviousTotalItems] = useState(totalItems || 0);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (totalItems !== undefined) {
|
|
23
|
+
setPreviousTotalItems(totalItems);
|
|
24
|
+
}
|
|
25
|
+
}, [totalItems]);
|
|
26
|
+
const pageCount = itemsPerPage !== undefined
|
|
27
|
+
? Math.ceil(previousTotalItems / itemsPerPage) || 1
|
|
28
|
+
: 0;
|
|
29
|
+
const pages = useMemo(() => {
|
|
30
|
+
if (pageCount < pagesToClickAmount) {
|
|
31
|
+
return range(1, pageCount + 1);
|
|
32
|
+
}
|
|
33
|
+
if (page < pagesToClickAmount - 2) {
|
|
34
|
+
return [...range(1, pagesToClickAmount - 1), "...1", pageCount];
|
|
35
|
+
}
|
|
36
|
+
if (page > pageCount - (pagesToClickAmount - 3)) {
|
|
37
|
+
return [
|
|
38
|
+
1,
|
|
39
|
+
"...1",
|
|
40
|
+
...range(pageCount - (pagesToClickAmount - 3), pageCount + 1),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
return [1, "...1", page - 1, page, page + 1, "...2", pageCount];
|
|
44
|
+
}, [page, pageCount, pagesToClickAmount]);
|
|
45
|
+
const handlePageClick = useCallback((page) => (e) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
setPage(page);
|
|
48
|
+
}, []);
|
|
49
|
+
return (<nav className={clsx("ui-pagination", className)} aria-label={paginationText}>
|
|
50
|
+
<UnstyledButton disabled={page === 1} onClick={handlePageClick(page - 1)} href={page !== 1 && pageHref ? pageHref(page - 1) : undefined}>
|
|
51
|
+
<span className="sr-only">{previousText}</span>
|
|
52
|
+
<ChevronLeftIcon className="h-5 w-5" aria-hidden="true"/>
|
|
53
|
+
</UnstyledButton>
|
|
54
|
+
{pages.map((p) => typeof p === "number" ? (<UnstyledButton key={p} onClick={handlePageClick(p)} data-active={page === p ? "" : undefined} href={pageHref ? pageHref(p) : undefined}>
|
|
55
|
+
{p}
|
|
56
|
+
</UnstyledButton>) : (<button key={p} disabled>
|
|
57
|
+
...
|
|
58
|
+
</button>))}
|
|
59
|
+
<UnstyledButton disabled={page === pageCount} onClick={handlePageClick(page + 1)} href={page !== pageCount && pageHref ? pageHref(page + 1) : undefined}>
|
|
60
|
+
<span className="sr-only">{nextText}</span>
|
|
61
|
+
<ChevronRightIcon className="h-5 w-5" aria-hidden="true"/>
|
|
62
|
+
</UnstyledButton>
|
|
63
|
+
</nav>);
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ParticlesProps {
|
|
3
|
+
particleCount?: number;
|
|
4
|
+
particleSpread?: number;
|
|
5
|
+
speed?: number;
|
|
6
|
+
particleColors?: string[];
|
|
7
|
+
moveParticlesOnHover?: boolean;
|
|
8
|
+
particleHoverFactor?: number;
|
|
9
|
+
alphaParticles?: boolean;
|
|
10
|
+
particleBaseSize?: number;
|
|
11
|
+
sizeRandomness?: number;
|
|
12
|
+
cameraDistance?: number;
|
|
13
|
+
disableRotation?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
useWindowMouseMove?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const Particles: React.FC<ParticlesProps>;
|
|
18
|
+
export default Particles;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Camera, Geometry, Mesh, Program, Renderer } from "ogl";
|
|
3
|
+
const defaultColors = ["#ffffff", "#ffffff", "#ffffff"];
|
|
4
|
+
const hexToRgb = (hex) => {
|
|
5
|
+
hex = hex.replace(/^#/, "");
|
|
6
|
+
if (hex.length === 3) {
|
|
7
|
+
hex = hex
|
|
8
|
+
.split("")
|
|
9
|
+
.map((c) => c + c)
|
|
10
|
+
.join("");
|
|
11
|
+
}
|
|
12
|
+
const int = parseInt(hex, 16);
|
|
13
|
+
const r = ((int >> 16) & 255) / 255;
|
|
14
|
+
const g = ((int >> 8) & 255) / 255;
|
|
15
|
+
const b = (int & 255) / 255;
|
|
16
|
+
return [r, g, b];
|
|
17
|
+
};
|
|
18
|
+
const vertex = /* glsl */ `
|
|
19
|
+
attribute vec3 position;
|
|
20
|
+
attribute vec4 random;
|
|
21
|
+
attribute vec3 color;
|
|
22
|
+
|
|
23
|
+
uniform mat4 modelMatrix;
|
|
24
|
+
uniform mat4 viewMatrix;
|
|
25
|
+
uniform mat4 projectionMatrix;
|
|
26
|
+
uniform float uTime;
|
|
27
|
+
uniform float uSpread;
|
|
28
|
+
uniform float uBaseSize;
|
|
29
|
+
uniform float uSizeRandomness;
|
|
30
|
+
|
|
31
|
+
varying vec4 vRandom;
|
|
32
|
+
varying vec3 vColor;
|
|
33
|
+
|
|
34
|
+
void main() {
|
|
35
|
+
vRandom = random;
|
|
36
|
+
vColor = color;
|
|
37
|
+
|
|
38
|
+
vec3 pos = position * uSpread;
|
|
39
|
+
pos.z *= 10.0;
|
|
40
|
+
|
|
41
|
+
vec4 mPos = modelMatrix * vec4(pos, 1.0);
|
|
42
|
+
float t = uTime;
|
|
43
|
+
mPos.x += sin(t * random.z + 6.28 * random.w) * mix(0.1, 1.5, random.x);
|
|
44
|
+
mPos.y += sin(t * random.y + 6.28 * random.x) * mix(0.1, 1.5, random.w);
|
|
45
|
+
mPos.z += sin(t * random.w + 6.28 * random.y) * mix(0.1, 1.5, random.z);
|
|
46
|
+
|
|
47
|
+
vec4 mvPos = viewMatrix * mPos;
|
|
48
|
+
gl_PointSize = (uBaseSize * (1.0 + uSizeRandomness * (random.x - 0.5))) / length(mvPos.xyz);
|
|
49
|
+
gl_Position = projectionMatrix * mvPos;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
const fragment = /* glsl */ `
|
|
53
|
+
precision highp float;
|
|
54
|
+
|
|
55
|
+
uniform float uTime;
|
|
56
|
+
uniform float uAlphaParticles;
|
|
57
|
+
varying vec4 vRandom;
|
|
58
|
+
varying vec3 vColor;
|
|
59
|
+
|
|
60
|
+
void main() {
|
|
61
|
+
vec2 uv = gl_PointCoord.xy;
|
|
62
|
+
float d = length(uv - vec2(0.5));
|
|
63
|
+
|
|
64
|
+
if(uAlphaParticles < 0.5) {
|
|
65
|
+
if(d > 0.5) {
|
|
66
|
+
discard;
|
|
67
|
+
}
|
|
68
|
+
gl_FragColor = vec4(vColor + 0.2 * sin(uv.yxx + uTime + vRandom.y * 6.28), 1.0);
|
|
69
|
+
} else {
|
|
70
|
+
float circle = smoothstep(0.5, 0.4, d) * 0.8;
|
|
71
|
+
gl_FragColor = vec4(vColor + 0.2 * sin(uv.yxx + uTime + vRandom.y * 6.28), circle);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
const Particles = ({ particleCount = 200, particleSpread = 10, speed = 0.1, particleColors, moveParticlesOnHover = false, particleHoverFactor = 1, alphaParticles = false, particleBaseSize = 100, sizeRandomness = 1, cameraDistance = 20, disableRotation = false, className, useWindowMouseMove = false, }) => {
|
|
76
|
+
const containerRef = useRef(null);
|
|
77
|
+
const mouseRef = useRef({ x: 0, y: 0 });
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const container = containerRef.current;
|
|
80
|
+
if (!container)
|
|
81
|
+
return;
|
|
82
|
+
const renderer = new Renderer({ depth: false, alpha: true });
|
|
83
|
+
const gl = renderer.gl;
|
|
84
|
+
container.appendChild(gl.canvas);
|
|
85
|
+
gl.clearColor(0, 0, 0, 0);
|
|
86
|
+
const camera = new Camera(gl, { fov: 15 });
|
|
87
|
+
camera.position.set(0, 0, cameraDistance);
|
|
88
|
+
const resize = () => {
|
|
89
|
+
const width = container.clientWidth;
|
|
90
|
+
const height = container.clientHeight;
|
|
91
|
+
renderer.setSize(width, height);
|
|
92
|
+
camera.perspective({ aspect: gl.canvas.width / gl.canvas.height });
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener("resize", resize, false);
|
|
95
|
+
resize();
|
|
96
|
+
const handleMouseMove = (e) => {
|
|
97
|
+
const rect = container.getBoundingClientRect();
|
|
98
|
+
const x = ((e.clientX - rect.left) / rect.width) * 2 - 1;
|
|
99
|
+
const y = -(((e.clientY - rect.top) / rect.height) * 2 - 1);
|
|
100
|
+
mouseRef.current = { x, y };
|
|
101
|
+
};
|
|
102
|
+
if (moveParticlesOnHover) {
|
|
103
|
+
if (useWindowMouseMove) {
|
|
104
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
container.addEventListener("mousemove", handleMouseMove);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const count = particleCount;
|
|
111
|
+
const positions = new Float32Array(count * 3);
|
|
112
|
+
const randoms = new Float32Array(count * 4);
|
|
113
|
+
const colors = new Float32Array(count * 3);
|
|
114
|
+
const palette = particleColors && particleColors.length > 0
|
|
115
|
+
? particleColors
|
|
116
|
+
: defaultColors;
|
|
117
|
+
for (let i = 0; i < count; i++) {
|
|
118
|
+
let x, y, z, len;
|
|
119
|
+
do {
|
|
120
|
+
x = Math.random() * 2 - 1;
|
|
121
|
+
y = Math.random() * 2 - 1;
|
|
122
|
+
z = Math.random() * 2 - 1;
|
|
123
|
+
len = x * x + y * y + z * z;
|
|
124
|
+
} while (len > 1 || len === 0);
|
|
125
|
+
const r = Math.cbrt(Math.random());
|
|
126
|
+
positions.set([x * r, y * r, z * r], i * 3);
|
|
127
|
+
randoms.set([Math.random(), Math.random(), Math.random(), Math.random()], i * 4);
|
|
128
|
+
const col = hexToRgb(palette[Math.floor(Math.random() * palette.length)]);
|
|
129
|
+
colors.set(col, i * 3);
|
|
130
|
+
}
|
|
131
|
+
const geometry = new Geometry(gl, {
|
|
132
|
+
position: { size: 3, data: positions },
|
|
133
|
+
random: { size: 4, data: randoms },
|
|
134
|
+
color: { size: 3, data: colors },
|
|
135
|
+
});
|
|
136
|
+
const program = new Program(gl, {
|
|
137
|
+
vertex,
|
|
138
|
+
fragment,
|
|
139
|
+
uniforms: {
|
|
140
|
+
uTime: { value: 0 },
|
|
141
|
+
uSpread: { value: particleSpread },
|
|
142
|
+
uBaseSize: { value: particleBaseSize },
|
|
143
|
+
uSizeRandomness: { value: sizeRandomness },
|
|
144
|
+
uAlphaParticles: { value: alphaParticles ? 1 : 0 },
|
|
145
|
+
},
|
|
146
|
+
transparent: true,
|
|
147
|
+
depthTest: false,
|
|
148
|
+
});
|
|
149
|
+
const particles = new Mesh(gl, { mode: gl.POINTS, geometry, program });
|
|
150
|
+
let animationFrameId;
|
|
151
|
+
let lastTime = performance.now();
|
|
152
|
+
let elapsed = 0;
|
|
153
|
+
const update = (t) => {
|
|
154
|
+
animationFrameId = requestAnimationFrame(update);
|
|
155
|
+
const delta = t - lastTime;
|
|
156
|
+
lastTime = t;
|
|
157
|
+
elapsed += delta * speed;
|
|
158
|
+
program.uniforms.uTime.value = elapsed * 0.001;
|
|
159
|
+
if (moveParticlesOnHover) {
|
|
160
|
+
particles.position.x = -mouseRef.current.x * particleHoverFactor;
|
|
161
|
+
particles.position.y = -mouseRef.current.y * particleHoverFactor;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
particles.position.x = 0;
|
|
165
|
+
particles.position.y = 0;
|
|
166
|
+
}
|
|
167
|
+
if (!disableRotation) {
|
|
168
|
+
particles.rotation.x = Math.sin(elapsed * 0.0002) * 0.1;
|
|
169
|
+
particles.rotation.y = Math.cos(elapsed * 0.0005) * 0.15;
|
|
170
|
+
particles.rotation.z += 0.01 * speed;
|
|
171
|
+
}
|
|
172
|
+
renderer.render({ scene: particles, camera });
|
|
173
|
+
};
|
|
174
|
+
animationFrameId = requestAnimationFrame(update);
|
|
175
|
+
return () => {
|
|
176
|
+
window.removeEventListener("resize", resize);
|
|
177
|
+
if (moveParticlesOnHover) {
|
|
178
|
+
if (useWindowMouseMove) {
|
|
179
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
container.removeEventListener("mousemove", handleMouseMove);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
cancelAnimationFrame(animationFrameId);
|
|
186
|
+
if (container.contains(gl.canvas)) {
|
|
187
|
+
container.removeChild(gl.canvas);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
191
|
+
}, [
|
|
192
|
+
particleCount,
|
|
193
|
+
particleSpread,
|
|
194
|
+
speed,
|
|
195
|
+
moveParticlesOnHover,
|
|
196
|
+
particleHoverFactor,
|
|
197
|
+
alphaParticles,
|
|
198
|
+
particleBaseSize,
|
|
199
|
+
sizeRandomness,
|
|
200
|
+
cameraDistance,
|
|
201
|
+
disableRotation,
|
|
202
|
+
]);
|
|
203
|
+
return (<div ref={containerRef} className={`relative h-full w-full ${className}`}/>);
|
|
204
|
+
};
|
|
205
|
+
export default Particles;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import { PixelCrop } from "react-image-crop";
|
|
3
|
+
export type PictureCropInputRef = {
|
|
4
|
+
handleCrop: () => Promise<void>;
|
|
5
|
+
completedCrop: PixelCrop | undefined;
|
|
6
|
+
};
|
|
7
|
+
export default function PictureCropInput({ value, onChange, loading, className, previewSizeClassNames, previewContainerClassName, cropButtonClassName, aspect, ref, }: {
|
|
8
|
+
value: string;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
previewSizeClassNames?: string;
|
|
13
|
+
previewContainerClassName?: string;
|
|
14
|
+
cropButtonClassName?: string;
|
|
15
|
+
aspect?: number;
|
|
16
|
+
ref?: RefObject<PictureCropInputRef | null>;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { useCallback, useEffect, useId, useRef, useState, } from "react";
|
|
2
|
+
import ReactCrop from "react-image-crop";
|
|
3
|
+
import useDebounceEffect from "../../hooks/useDebounceEffect";
|
|
4
|
+
import { canvasPreview } from "./canvasPreview";
|
|
5
|
+
import Skeleton from "../Skeleton";
|
|
6
|
+
import Button from "../Button";
|
|
7
|
+
import { PhotoIcon } from "@heroicons/react/24/outline";
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
import { CheckIcon, TrashIcon } from "@heroicons/react/20/solid";
|
|
10
|
+
import Tooltip from "../Tooltip";
|
|
11
|
+
import { useLatest } from "react-use";
|
|
12
|
+
export default function PictureCropInput({ value, onChange, loading, className, previewSizeClassNames = "h-52 w-52", previewContainerClassName, cropButtonClassName, aspect = 1, ref, }) {
|
|
13
|
+
const id = useId();
|
|
14
|
+
const [src, setSrc] = useState();
|
|
15
|
+
const [crop, setCrop] = useState();
|
|
16
|
+
const cropRef = useLatest(crop);
|
|
17
|
+
const [completedCrop, setCompletedCrop] = useState();
|
|
18
|
+
const previewCanvasRef = useRef(null);
|
|
19
|
+
const imgRef = useRef(null);
|
|
20
|
+
const parentRef = useRef(null);
|
|
21
|
+
const autoCrop = useCallback(() => {
|
|
22
|
+
const smallestSide = Math.min(imgRef.current?.getBoundingClientRect().width || 0, imgRef.current?.getBoundingClientRect().height || 0);
|
|
23
|
+
setCrop({
|
|
24
|
+
unit: "px",
|
|
25
|
+
x: 0,
|
|
26
|
+
y: 0,
|
|
27
|
+
width: smallestSide,
|
|
28
|
+
height: smallestSide,
|
|
29
|
+
});
|
|
30
|
+
}, []);
|
|
31
|
+
const onFileSelect = useCallback(async (event) => {
|
|
32
|
+
const file = event.target.files?.[0];
|
|
33
|
+
if (file) {
|
|
34
|
+
setSrc(URL.createObjectURL(file));
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
autoCrop();
|
|
37
|
+
}, 100);
|
|
38
|
+
}
|
|
39
|
+
}, [autoCrop]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
42
|
+
if (cropRef.current) {
|
|
43
|
+
autoCrop();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const el = parentRef.current;
|
|
47
|
+
if (el) {
|
|
48
|
+
resizeObserver.observe(el);
|
|
49
|
+
}
|
|
50
|
+
return () => {
|
|
51
|
+
if (el) {
|
|
52
|
+
resizeObserver.unobserve(el);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
+
}, []);
|
|
57
|
+
useDebounceEffect(async () => {
|
|
58
|
+
if (completedCrop?.width &&
|
|
59
|
+
completedCrop?.height &&
|
|
60
|
+
imgRef.current &&
|
|
61
|
+
previewCanvasRef.current) {
|
|
62
|
+
// We use canvasPreview as it's much faster than imgPreview.
|
|
63
|
+
await canvasPreview(imgRef.current, previewCanvasRef.current, completedCrop);
|
|
64
|
+
}
|
|
65
|
+
}, 100, [completedCrop]);
|
|
66
|
+
const cropToBlobUrl = useCallback(async () => {
|
|
67
|
+
const image = imgRef.current;
|
|
68
|
+
const previewCanvas = previewCanvasRef.current;
|
|
69
|
+
if (!image || !previewCanvas || !completedCrop) {
|
|
70
|
+
throw new Error("Crop canvas does not exist");
|
|
71
|
+
}
|
|
72
|
+
// This will size relative to the uploaded image
|
|
73
|
+
// size. If you want to size according to what they
|
|
74
|
+
// are looking at on screen, remove scaleX + scaleY
|
|
75
|
+
const scaleX = image.naturalWidth / image.width;
|
|
76
|
+
const scaleY = image.naturalHeight / image.height;
|
|
77
|
+
const offscreen = new OffscreenCanvas(completedCrop.width * scaleX, completedCrop.height * scaleY);
|
|
78
|
+
const ctx = offscreen.getContext("2d");
|
|
79
|
+
if (!ctx) {
|
|
80
|
+
throw new Error("No 2d context");
|
|
81
|
+
}
|
|
82
|
+
ctx.drawImage(previewCanvas, 0, 0, previewCanvas.width, previewCanvas.height, 0, 0, offscreen.width, offscreen.height);
|
|
83
|
+
// You might want { type: "image/jpeg", quality: <0 to 1> } to
|
|
84
|
+
// reduce image size
|
|
85
|
+
const blob = await offscreen.convertToBlob({
|
|
86
|
+
type: "image/png",
|
|
87
|
+
});
|
|
88
|
+
return URL.createObjectURL(blob);
|
|
89
|
+
}, [completedCrop]);
|
|
90
|
+
const handleCrop = useCallback(async () => {
|
|
91
|
+
onChange(await cropToBlobUrl());
|
|
92
|
+
setSrc(undefined);
|
|
93
|
+
}, [cropToBlobUrl, onChange]);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (ref) {
|
|
96
|
+
ref.current = {
|
|
97
|
+
handleCrop,
|
|
98
|
+
completedCrop,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}, [completedCrop, handleCrop, ref]);
|
|
102
|
+
const handleClear = useCallback(() => {
|
|
103
|
+
setCrop(undefined);
|
|
104
|
+
setSrc(undefined);
|
|
105
|
+
}, []);
|
|
106
|
+
return (<div ref={parentRef} className={clsx("flex gap-2", className)}>
|
|
107
|
+
{loading && <Skeleton className={previewSizeClassNames}/>}
|
|
108
|
+
{src && (<>
|
|
109
|
+
<ReactCrop crop={crop} onChange={(c) => setCrop(c)} onComplete={(c) => setCompletedCrop(c)} aspect={aspect} minWidth={50 * aspect} minHeight={50 * aspect} className="max-h-96 max-w-96" keepSelection>
|
|
110
|
+
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
111
|
+
<img alt="Picture" src={src}
|
|
112
|
+
// className="h-96 w-96 object-contain"
|
|
113
|
+
ref={imgRef}/>
|
|
114
|
+
</ReactCrop>
|
|
115
|
+
{completedCrop && (<div className={clsx("flex flex-col gap-2", previewContainerClassName)}>
|
|
116
|
+
<canvas ref={previewCanvasRef} className={previewSizeClassNames} style={{
|
|
117
|
+
objectFit: "cover",
|
|
118
|
+
}}/>
|
|
119
|
+
<div className="flex gap-2">
|
|
120
|
+
<Button onClick={handleCrop} className={clsx("w-full", cropButtonClassName)} leading={<CheckIcon />}>
|
|
121
|
+
Crop
|
|
122
|
+
</Button>
|
|
123
|
+
<Tooltip content="Clear">
|
|
124
|
+
<Button onClick={handleClear} variant="text" icon>
|
|
125
|
+
<TrashIcon />
|
|
126
|
+
</Button>
|
|
127
|
+
</Tooltip>
|
|
128
|
+
</div>
|
|
129
|
+
</div>)}
|
|
130
|
+
</>)}
|
|
131
|
+
{!src && (<>
|
|
132
|
+
{value && (<div className={clsx("flex shrink-0 rounded-sm", previewSizeClassNames)} style={{
|
|
133
|
+
background: value
|
|
134
|
+
? `center / cover url(${value})`
|
|
135
|
+
: undefined,
|
|
136
|
+
}}/>)}
|
|
137
|
+
<input type="file" id={id} className="hidden" onChange={onFileSelect} accept=".jpg,.jpeg,.png"/>
|
|
138
|
+
<Button variant="outlined" className="mb-auto flex items-center gap-3 p-2" onClick={() => document.getElementById(id)?.click()}>
|
|
139
|
+
<div className="flex h-12 w-12 items-center justify-center rounded-sm border border-zinc-800 p-3">
|
|
140
|
+
<PhotoIcon />
|
|
141
|
+
</div>
|
|
142
|
+
<div className="flex flex-col items-start gap-1.5">
|
|
143
|
+
<div className="text-gray-10 text-sm font-medium">
|
|
144
|
+
{value ? "Change" : "Select"} picture
|
|
145
|
+
</div>
|
|
146
|
+
<div className="text-xs text-zinc-500">
|
|
147
|
+
JPG, PNG - Max size 10MB
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</Button>
|
|
151
|
+
</>)}
|
|
152
|
+
</div>);
|
|
153
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const TO_RADIANS = Math.PI / 180;
|
|
2
|
+
export async function canvasPreview(image, canvas, crop, scale = 1, rotate = 0) {
|
|
3
|
+
const ctx = canvas.getContext("2d");
|
|
4
|
+
if (!ctx) {
|
|
5
|
+
throw new Error("No 2d context");
|
|
6
|
+
}
|
|
7
|
+
const scaleX = image.naturalWidth / image.width;
|
|
8
|
+
const scaleY = image.naturalHeight / image.height;
|
|
9
|
+
// devicePixelRatio slightly increases sharpness on retina devices
|
|
10
|
+
// at the expense of slightly slower render times and needing to
|
|
11
|
+
// size the image back down if you want to download/upload and be
|
|
12
|
+
// true to the images natural size.
|
|
13
|
+
const pixelRatio = window.devicePixelRatio;
|
|
14
|
+
// const pixelRatio = 1
|
|
15
|
+
canvas.width = Math.floor(crop.width * scaleX * pixelRatio);
|
|
16
|
+
canvas.height = Math.floor(crop.height * scaleY * pixelRatio);
|
|
17
|
+
ctx.scale(pixelRatio, pixelRatio);
|
|
18
|
+
ctx.imageSmoothingQuality = "high";
|
|
19
|
+
const cropX = crop.x * scaleX;
|
|
20
|
+
const cropY = crop.y * scaleY;
|
|
21
|
+
const rotateRads = rotate * TO_RADIANS;
|
|
22
|
+
const centerX = image.naturalWidth / 2;
|
|
23
|
+
const centerY = image.naturalHeight / 2;
|
|
24
|
+
ctx.save();
|
|
25
|
+
// 5) Move the crop origin to the canvas origin (0,0)
|
|
26
|
+
ctx.translate(-cropX, -cropY);
|
|
27
|
+
// 4) Move the origin to the center of the original position
|
|
28
|
+
ctx.translate(centerX, centerY);
|
|
29
|
+
// 3) Rotate around the origin
|
|
30
|
+
ctx.rotate(rotateRads);
|
|
31
|
+
// 2) Scale the image
|
|
32
|
+
ctx.scale(scale, scale);
|
|
33
|
+
// 1) Move the center of the image to the origin (0,0)
|
|
34
|
+
ctx.translate(-centerX, -centerY);
|
|
35
|
+
ctx.drawImage(image, 0, 0, image.naturalWidth, image.naturalHeight, 0, 0, image.naturalWidth, image.naturalHeight);
|
|
36
|
+
ctx.restore();
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as RPopover from "@radix-ui/react-popover";
|
|
2
|
+
import React, { ComponentProps } from "react";
|
|
3
|
+
declare function PopoverContent({ className, sideOffset, collisionPadding, children, noArrow, ...props }: ComponentProps<typeof RPopover.Content> & {
|
|
4
|
+
noArrow?: boolean;
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function PopoverArrow({ className, ...props }: ComponentProps<typeof RPopover.Arrow>): React.JSX.Element;
|
|
7
|
+
declare const Popover: {
|
|
8
|
+
Content: typeof PopoverContent;
|
|
9
|
+
Root: React.FC<RPopover.PopoverProps>;
|
|
10
|
+
Trigger: React.ForwardRefExoticComponent<RPopover.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
Arrow: typeof PopoverArrow;
|
|
12
|
+
};
|
|
13
|
+
export default Popover;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as RPopover from "@radix-ui/react-popover";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import clsx from "../../utils/clsx";
|
|
4
|
+
import { modalArrowClassName, modalContentClassName, } from "../../styles/Modal.classNames";
|
|
5
|
+
function PopoverContent({ className, sideOffset = 4, collisionPadding = 8, children, noArrow, ...props }) {
|
|
6
|
+
return (<RPopover.Portal>
|
|
7
|
+
<RPopover.Content {...props} className={clsx(modalContentClassName, "ui-popover-content", className)} sideOffset={sideOffset} collisionPadding={collisionPadding}>
|
|
8
|
+
{children}
|
|
9
|
+
{!noArrow && <PopoverArrow />}
|
|
10
|
+
</RPopover.Content>
|
|
11
|
+
</RPopover.Portal>);
|
|
12
|
+
}
|
|
13
|
+
function PopoverArrow({ className, ...props }) {
|
|
14
|
+
return (<RPopover.Arrow {...props} className={clsx(modalArrowClassName, "ui-popover-arrow", className)}/>);
|
|
15
|
+
}
|
|
16
|
+
const Popover = {
|
|
17
|
+
Content: PopoverContent,
|
|
18
|
+
Root: RPopover.Root,
|
|
19
|
+
Trigger: RPopover.Trigger,
|
|
20
|
+
Arrow: PopoverArrow,
|
|
21
|
+
};
|
|
22
|
+
export default Popover;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactElement, ReactNode } from "react";
|
|
2
|
+
export default function Resizable({ children, minWidth, maxWidth, width, onResize, }: {
|
|
3
|
+
children: ReactElement;
|
|
4
|
+
minWidth?: number;
|
|
5
|
+
maxWidth?: number;
|
|
6
|
+
width?: number;
|
|
7
|
+
onResize: (width?: number) => void;
|
|
8
|
+
}): React.ReactElement<{
|
|
9
|
+
className?: string;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
}, string | React.JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { cloneElement, useEffect, useRef, useState, } from "react";
|
|
2
|
+
import { useLatest } from "react-use";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
export default function Resizable({ children, minWidth, maxWidth, width, onResize, }) {
|
|
5
|
+
const [internalWidth, setInternalWidth] = useState(width);
|
|
6
|
+
const [isResizing, setResizing] = useState(false);
|
|
7
|
+
const isResizingRef = useLatest(isResizing);
|
|
8
|
+
const initialMouseXPos = useRef(0);
|
|
9
|
+
const initialWidth = useRef(0);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
onResize(internalWidth);
|
|
12
|
+
}, [internalWidth, onResize]);
|
|
13
|
+
const onMouseDown = (e) => {
|
|
14
|
+
const parent = e.currentTarget?.parentNode;
|
|
15
|
+
const rect = parent.getBoundingClientRect();
|
|
16
|
+
initialWidth.current = rect.width;
|
|
17
|
+
initialMouseXPos.current = e.clientX;
|
|
18
|
+
setResizing(true);
|
|
19
|
+
};
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const onMouseMove = (e) => {
|
|
22
|
+
if (isResizingRef.current) {
|
|
23
|
+
let newWidth = initialWidth.current - (e.clientX - initialMouseXPos.current);
|
|
24
|
+
if (minWidth !== undefined && newWidth < minWidth) {
|
|
25
|
+
newWidth = minWidth;
|
|
26
|
+
}
|
|
27
|
+
if (maxWidth !== undefined && newWidth > maxWidth) {
|
|
28
|
+
newWidth = maxWidth;
|
|
29
|
+
}
|
|
30
|
+
setInternalWidth(newWidth);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const onMouseUp = () => {
|
|
34
|
+
setResizing(false);
|
|
35
|
+
};
|
|
36
|
+
window.addEventListener("mousemove", onMouseMove);
|
|
37
|
+
window.addEventListener("mouseup", onMouseUp);
|
|
38
|
+
return () => {
|
|
39
|
+
window.removeEventListener("mousemove", onMouseMove);
|
|
40
|
+
window.removeEventListener("mouseup", onMouseUp);
|
|
41
|
+
};
|
|
42
|
+
}, [isResizingRef, maxWidth, minWidth, onResize]);
|
|
43
|
+
const child = children;
|
|
44
|
+
return cloneElement(child, {
|
|
45
|
+
className: clsx("relative", child.props.className),
|
|
46
|
+
style: { width: internalWidth },
|
|
47
|
+
children: (<>
|
|
48
|
+
<div className={clsx("absolute bottom-0 left-0 top-0 z-10 w-1 cursor-e-resize select-none transition-colors hover:bg-zinc-700", {
|
|
49
|
+
"bg-zinc-700": isResizing,
|
|
50
|
+
})} onMouseDown={onMouseDown}/>
|
|
51
|
+
{child.props.children}
|
|
52
|
+
</>),
|
|
53
|
+
});
|
|
54
|
+
}
|