@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,28 @@
|
|
|
1
|
+
import clsx from "../../utils/clsx";
|
|
2
|
+
import Link from "../Link";
|
|
3
|
+
export const defaultTextStyles = {
|
|
4
|
+
variant: {
|
|
5
|
+
default: "text-zinc-700 dark:text-zinc-200",
|
|
6
|
+
label: "text-zinc-800 font-medium dark:text-zinc-100",
|
|
7
|
+
secondary: "text-sm text-zinc-500 dark:text-zinc-400",
|
|
8
|
+
},
|
|
9
|
+
size: {
|
|
10
|
+
xs: "text-xs",
|
|
11
|
+
sm: "text-sm",
|
|
12
|
+
base: "text-base",
|
|
13
|
+
lg: "text-lg",
|
|
14
|
+
xl: "text-xl",
|
|
15
|
+
"2xl": "text-2xl",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
function Text({ inline, variant = "default", className, href, target, size = variant !== "label" ? "base" : "sm", ...props }) {
|
|
19
|
+
if (href || variant === "link") {
|
|
20
|
+
return (<Link href={href} target={target} {...props} className={className}/>);
|
|
21
|
+
}
|
|
22
|
+
className = clsx(defaultTextStyles.variant[variant], defaultTextStyles.size[size], className);
|
|
23
|
+
if (inline) {
|
|
24
|
+
return <span {...props} className={className}/>;
|
|
25
|
+
}
|
|
26
|
+
return <div {...props} className={className}/>;
|
|
27
|
+
}
|
|
28
|
+
export default Text;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InputProps } from "../Input";
|
|
2
|
+
import { TextareaAutosizeProps } from "react-textarea-autosize/dist/declarations/src";
|
|
3
|
+
export type TextareaProps = InputProps<false> & Partial<Pick<TextareaAutosizeProps, "maxRows" | "minRows" | "onHeightChange" | "cacheMeasurements">>;
|
|
4
|
+
declare function Textarea(props: TextareaProps): import("react").JSX.Element;
|
|
5
|
+
export default Textarea;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Renderer, Program, Mesh, Triangle, Color } from "ogl";
|
|
3
|
+
const vertexShader = `
|
|
4
|
+
attribute vec2 position;
|
|
5
|
+
attribute vec2 uv;
|
|
6
|
+
varying vec2 vUv;
|
|
7
|
+
void main() {
|
|
8
|
+
vUv = uv;
|
|
9
|
+
gl_Position = vec4(position, 0.0, 1.0);
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
const fragmentShader = `
|
|
13
|
+
precision highp float;
|
|
14
|
+
|
|
15
|
+
uniform float iTime;
|
|
16
|
+
uniform vec3 iResolution;
|
|
17
|
+
uniform vec3 uColor;
|
|
18
|
+
uniform float uAmplitude;
|
|
19
|
+
uniform float uDistance;
|
|
20
|
+
uniform vec2 uMouse;
|
|
21
|
+
|
|
22
|
+
#define PI 3.1415926538
|
|
23
|
+
|
|
24
|
+
const int u_line_count = 40;
|
|
25
|
+
const float u_line_width = 7.0;
|
|
26
|
+
const float u_line_blur = 10.0;
|
|
27
|
+
|
|
28
|
+
float Perlin2D(vec2 P) {
|
|
29
|
+
vec2 Pi = floor(P);
|
|
30
|
+
vec4 Pf_Pfmin1 = P.xyxy - vec4(Pi, Pi + 1.0);
|
|
31
|
+
vec4 Pt = vec4(Pi.xy, Pi.xy + 1.0);
|
|
32
|
+
Pt = Pt - floor(Pt * (1.0 / 71.0)) * 71.0;
|
|
33
|
+
Pt += vec2(26.0, 161.0).xyxy;
|
|
34
|
+
Pt *= Pt;
|
|
35
|
+
Pt = Pt.xzxz * Pt.yyww;
|
|
36
|
+
vec4 hash_x = fract(Pt * (1.0 / 951.135664));
|
|
37
|
+
vec4 hash_y = fract(Pt * (1.0 / 642.949883));
|
|
38
|
+
vec4 grad_x = hash_x - 0.49999;
|
|
39
|
+
vec4 grad_y = hash_y - 0.49999;
|
|
40
|
+
vec4 grad_results = inversesqrt(grad_x * grad_x + grad_y * grad_y)
|
|
41
|
+
* (grad_x * Pf_Pfmin1.xzxz + grad_y * Pf_Pfmin1.yyww);
|
|
42
|
+
grad_results *= 1.4142135623730950;
|
|
43
|
+
vec2 blend = Pf_Pfmin1.xy * Pf_Pfmin1.xy * Pf_Pfmin1.xy
|
|
44
|
+
* (Pf_Pfmin1.xy * (Pf_Pfmin1.xy * 6.0 - 15.0) + 10.0);
|
|
45
|
+
vec4 blend2 = vec4(blend, vec2(1.0 - blend));
|
|
46
|
+
return dot(grad_results, blend2.zxzx * blend2.wwyy);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
float pixel(float count, vec2 resolution) {
|
|
50
|
+
return (1.0 / max(resolution.x, resolution.y)) * count;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
float lineFn(vec2 st, float width, float perc, float offset, vec2 mouse, float time, float amplitude, float distance) {
|
|
54
|
+
float split_offset = (perc * 0.4);
|
|
55
|
+
float split_point = 0.1 + split_offset;
|
|
56
|
+
|
|
57
|
+
float amplitude_normal = smoothstep(split_point, 0.7, st.x);
|
|
58
|
+
float amplitude_strength = 0.5;
|
|
59
|
+
float finalAmplitude = amplitude_normal * amplitude_strength
|
|
60
|
+
* amplitude * (1.0 + (mouse.y - 0.5) * 0.2);
|
|
61
|
+
|
|
62
|
+
float time_scaled = time / 10.0 + (mouse.x - 0.5) * 1.0;
|
|
63
|
+
float blur = smoothstep(split_point, split_point + 0.05, st.x) * perc;
|
|
64
|
+
|
|
65
|
+
float xnoise = mix(
|
|
66
|
+
Perlin2D(vec2(time_scaled, st.x + perc) * 2.5),
|
|
67
|
+
Perlin2D(vec2(time_scaled, st.x + time_scaled) * 3.5) / 1.5,
|
|
68
|
+
st.x * 0.3
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
float y = 0.5 + (perc - 0.5) * distance + xnoise / 2.0 * finalAmplitude;
|
|
72
|
+
|
|
73
|
+
float line_start = smoothstep(
|
|
74
|
+
y + (width / 2.0) + (u_line_blur * pixel(1.0, iResolution.xy) * blur),
|
|
75
|
+
y,
|
|
76
|
+
st.y
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
float line_end = smoothstep(
|
|
80
|
+
y,
|
|
81
|
+
y - (width / 2.0) - (u_line_blur * pixel(1.0, iResolution.xy) * blur),
|
|
82
|
+
st.y
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return clamp(
|
|
86
|
+
(line_start - line_end) * (1.0 - smoothstep(0.0, 1.0, pow(perc, 0.3))),
|
|
87
|
+
0.0,
|
|
88
|
+
1.0
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
93
|
+
vec2 uv = fragCoord / iResolution.xy;
|
|
94
|
+
|
|
95
|
+
float line_strength = 1.0;
|
|
96
|
+
for (int i = 0; i < u_line_count; i++) {
|
|
97
|
+
float p = float(i) / float(u_line_count);
|
|
98
|
+
line_strength *= (1.0 - lineFn(
|
|
99
|
+
uv,
|
|
100
|
+
u_line_width * pixel(1.0, iResolution.xy) * (1.0 - p),
|
|
101
|
+
p,
|
|
102
|
+
(PI * 1.0) * p,
|
|
103
|
+
uMouse,
|
|
104
|
+
iTime,
|
|
105
|
+
uAmplitude,
|
|
106
|
+
uDistance
|
|
107
|
+
));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
float colorVal = 1.0 - line_strength;
|
|
111
|
+
fragColor = vec4(uColor * colorVal, colorVal);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
void main() {
|
|
115
|
+
mainImage(gl_FragColor, gl_FragCoord.xy);
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
const Threads = ({ color = [1, 1, 1], amplitude = 1, distance = 0, enableMouseInteraction = false, ...rest }) => {
|
|
119
|
+
const containerRef = useRef(null);
|
|
120
|
+
const animationFrameId = useRef(undefined);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (!containerRef.current)
|
|
123
|
+
return;
|
|
124
|
+
const container = containerRef.current;
|
|
125
|
+
const renderer = new Renderer({ alpha: true });
|
|
126
|
+
const gl = renderer.gl;
|
|
127
|
+
gl.clearColor(0, 0, 0, 0);
|
|
128
|
+
gl.enable(gl.BLEND);
|
|
129
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
130
|
+
container.appendChild(gl.canvas);
|
|
131
|
+
const geometry = new Triangle(gl);
|
|
132
|
+
const program = new Program(gl, {
|
|
133
|
+
vertex: vertexShader,
|
|
134
|
+
fragment: fragmentShader,
|
|
135
|
+
uniforms: {
|
|
136
|
+
iTime: { value: 0 },
|
|
137
|
+
iResolution: {
|
|
138
|
+
value: new Color(gl.canvas.width, gl.canvas.height, gl.canvas.width / gl.canvas.height),
|
|
139
|
+
},
|
|
140
|
+
uColor: { value: new Color(...color) },
|
|
141
|
+
uAmplitude: { value: amplitude },
|
|
142
|
+
uDistance: { value: distance },
|
|
143
|
+
uMouse: { value: new Float32Array([0.5, 0.5]) },
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
const mesh = new Mesh(gl, { geometry, program });
|
|
147
|
+
function resize() {
|
|
148
|
+
const { clientWidth, clientHeight } = container;
|
|
149
|
+
renderer.setSize(clientWidth, clientHeight);
|
|
150
|
+
program.uniforms.iResolution.value.r = clientWidth;
|
|
151
|
+
program.uniforms.iResolution.value.g = clientHeight;
|
|
152
|
+
program.uniforms.iResolution.value.b = clientWidth / clientHeight;
|
|
153
|
+
}
|
|
154
|
+
window.addEventListener("resize", resize);
|
|
155
|
+
resize();
|
|
156
|
+
const currentMouse = [0.5, 0.5];
|
|
157
|
+
let targetMouse = [0.5, 0.5];
|
|
158
|
+
function handleMouseMove(e) {
|
|
159
|
+
const rect = container.getBoundingClientRect();
|
|
160
|
+
const x = (e.clientX - rect.left) / rect.width;
|
|
161
|
+
const y = 1.0 - (e.clientY - rect.top) / rect.height;
|
|
162
|
+
targetMouse = [x, y];
|
|
163
|
+
}
|
|
164
|
+
function handleMouseLeave() {
|
|
165
|
+
targetMouse = [0.5, 0.5];
|
|
166
|
+
}
|
|
167
|
+
if (enableMouseInteraction) {
|
|
168
|
+
container.addEventListener("mousemove", handleMouseMove);
|
|
169
|
+
container.addEventListener("mouseleave", handleMouseLeave);
|
|
170
|
+
}
|
|
171
|
+
function update(t) {
|
|
172
|
+
if (enableMouseInteraction) {
|
|
173
|
+
const smoothing = 0.05;
|
|
174
|
+
currentMouse[0] += smoothing * (targetMouse[0] - currentMouse[0]);
|
|
175
|
+
currentMouse[1] += smoothing * (targetMouse[1] - currentMouse[1]);
|
|
176
|
+
program.uniforms.uMouse.value[0] = currentMouse[0];
|
|
177
|
+
program.uniforms.uMouse.value[1] = currentMouse[1];
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
program.uniforms.uMouse.value[0] = 0.5;
|
|
181
|
+
program.uniforms.uMouse.value[1] = 0.5;
|
|
182
|
+
}
|
|
183
|
+
program.uniforms.iTime.value = t * 0.001;
|
|
184
|
+
renderer.render({ scene: mesh });
|
|
185
|
+
animationFrameId.current = requestAnimationFrame(update);
|
|
186
|
+
}
|
|
187
|
+
animationFrameId.current = requestAnimationFrame(update);
|
|
188
|
+
return () => {
|
|
189
|
+
if (animationFrameId.current)
|
|
190
|
+
cancelAnimationFrame(animationFrameId.current);
|
|
191
|
+
window.removeEventListener("resize", resize);
|
|
192
|
+
if (enableMouseInteraction) {
|
|
193
|
+
container.removeEventListener("mousemove", handleMouseMove);
|
|
194
|
+
container.removeEventListener("mouseleave", handleMouseLeave);
|
|
195
|
+
}
|
|
196
|
+
if (container.contains(gl.canvas))
|
|
197
|
+
container.removeChild(gl.canvas);
|
|
198
|
+
gl.getExtension("WEBGL_lose_context")?.loseContext();
|
|
199
|
+
};
|
|
200
|
+
}, [color, amplitude, distance, enableMouseInteraction]);
|
|
201
|
+
return (<div ref={containerRef} className="relative h-full w-full" {...rest}/>);
|
|
202
|
+
};
|
|
203
|
+
export default Threads;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode, Ref } from "react";
|
|
2
|
+
declare function Tooltip({ children, content, side, delayDuration, className, arrowClassName, ref, }: {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
content?: ReactNode;
|
|
5
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
6
|
+
delayDuration?: number;
|
|
7
|
+
className?: string;
|
|
8
|
+
arrowClassName?: string;
|
|
9
|
+
ref?: Ref<HTMLButtonElement>;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export default Tooltip;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as RTooltip from "@radix-ui/react-tooltip";
|
|
2
|
+
import clsx from "../../utils/clsx";
|
|
3
|
+
function Tooltip({ children, content, side, delayDuration, className, arrowClassName, ref, }) {
|
|
4
|
+
if (!content) {
|
|
5
|
+
return <>{children}</>;
|
|
6
|
+
}
|
|
7
|
+
return (<RTooltip.Provider>
|
|
8
|
+
<RTooltip.Root delayDuration={delayDuration}>
|
|
9
|
+
<RTooltip.Trigger asChild ref={ref}>
|
|
10
|
+
{children}
|
|
11
|
+
</RTooltip.Trigger>
|
|
12
|
+
<RTooltip.Portal>
|
|
13
|
+
<RTooltip.Content className={clsx("z-20 rounded-sm bg-zinc-950 px-2 py-1 text-center text-sm text-zinc-50 shadow-sm", "dark:bg-zinc-50 dark:text-zinc-950", "data-[state=closed]:animate-fade-out data-[state=delayed-open]:data-[side=bottom]:animate-elastic-slide-up-and-fade data-[state=delayed-open]:data-[side=left]:animate-elastic-slide-right-and-fade data-[state=delayed-open]:data-[side=right]:animate-elastic-slide-left-and-fade data-[state=delayed-open]:data-[side=top]:animate-elastic-slide-down-and-fade will-change-[transform,opacity]", className)} sideOffset={5} side={side}>
|
|
14
|
+
{content}
|
|
15
|
+
<RTooltip.Arrow className={clsx("fill-zinc-950 dark:fill-zinc-50", arrowClassName)}/>
|
|
16
|
+
</RTooltip.Content>
|
|
17
|
+
</RTooltip.Portal>
|
|
18
|
+
</RTooltip.Root>
|
|
19
|
+
</RTooltip.Provider>);
|
|
20
|
+
}
|
|
21
|
+
export default Tooltip;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import Button from "../Button";
|
|
3
|
+
export default function VisibilityActivatedButton({ rootMargin, threshold, root, ...props }: ComponentProps<typeof Button> & {
|
|
4
|
+
root?: Element | Document | null;
|
|
5
|
+
threshold?: number;
|
|
6
|
+
rootMargin?: string;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useIntersection } from "react-use";
|
|
3
|
+
import Button from "../Button";
|
|
4
|
+
export default function VisibilityActivatedButton({ rootMargin, threshold, root, ...props }) {
|
|
5
|
+
const observerRef = useRef(null);
|
|
6
|
+
const intersection = useIntersection(observerRef, {
|
|
7
|
+
root,
|
|
8
|
+
rootMargin,
|
|
9
|
+
threshold,
|
|
10
|
+
});
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (intersection && intersection.isIntersecting) {
|
|
13
|
+
observerRef.current?.click();
|
|
14
|
+
}
|
|
15
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
|
+
}, [intersection?.isIntersecting]);
|
|
17
|
+
return <Button ref={observerRef} {...props}/>;
|
|
18
|
+
}
|
package/form.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { FormEvent } from "react";
|
|
2
|
+
import { ArrayKey, IsTuple, TupleKeys } from "react-hook-form/dist/types/path/common";
|
|
3
|
+
import { Get, PartialDeep, RequiredDeep, WritableDeep } from "type-fest";
|
|
4
|
+
import { DeepPartial } from "redux";
|
|
5
|
+
type Any = any;
|
|
6
|
+
export type DeepMapValues<T, V> = {
|
|
7
|
+
[K in keyof T]: T[K] extends Array<Any> ? DeepMapValues<T[K][0], V> & V : T[K] extends object ? DeepMapValues<T[K], V> : V;
|
|
8
|
+
};
|
|
9
|
+
export type IsEqual<T1, T2> = T1 extends T2 ? (<G>() => G extends T1 ? 1 : 2) extends <G>() => G extends T2 ? 1 : 2 ? true : false : false;
|
|
10
|
+
export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
11
|
+
export type BrowserNativeObject = Date | FileList | File;
|
|
12
|
+
export type FieldValues = Record<string, Any>;
|
|
13
|
+
export type AnyIsEqual<T1, T2> = T1 extends T2 ? IsEqual<T1, T2> extends true ? true : never : never;
|
|
14
|
+
export type PathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? `${K}` : true extends AnyIsEqual<TraversedTypes, V> ? `${K}` : `${K}` | `${K}.${PathInternal<V, TraversedTypes | V>}`;
|
|
15
|
+
export type PathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
|
|
16
|
+
[K in TupleKeys<T>]-?: PathImpl<K & string, T[K], TraversedTypes>;
|
|
17
|
+
}[TupleKeys<T>] : PathImpl<ArrayKey, V, TraversedTypes> : {
|
|
18
|
+
[K in keyof T]-?: PathImpl<K & string, T[K], TraversedTypes>;
|
|
19
|
+
}[keyof T];
|
|
20
|
+
export type Path<T> = T extends Any ? PathInternal<T> : never;
|
|
21
|
+
export type FieldPath<TFieldValues extends FieldValues> = Path<TFieldValues>;
|
|
22
|
+
export type DeepRequiredByValidation<T, V extends {
|
|
23
|
+
[K in keyof T]?: Any;
|
|
24
|
+
}> = {
|
|
25
|
+
[P in keyof T]-?: P extends keyof V ? T[P] extends object ? DeepRequiredByValidation<T[P], V[P]> : DeepRequiredByValidation<NonNullable<T[P]>, V[P]> : T[P];
|
|
26
|
+
};
|
|
27
|
+
export type Validation = {
|
|
28
|
+
required?: string;
|
|
29
|
+
min?: [number, string];
|
|
30
|
+
pattern?: [RegExp, string];
|
|
31
|
+
};
|
|
32
|
+
export declare function createFormState<T extends object, V extends PartialDeep<DeepMapValues<RequiredDeep<T>, Validation>>>(options: {
|
|
33
|
+
defaultValues: T;
|
|
34
|
+
validation?: V;
|
|
35
|
+
}): {
|
|
36
|
+
options: {
|
|
37
|
+
defaultValues: T;
|
|
38
|
+
validation?: V;
|
|
39
|
+
};
|
|
40
|
+
values: DeepRequiredByValidation<T, V>;
|
|
41
|
+
setValue<N extends FieldPath<T>>(name: N, value: DeepPartial<Get<T, N>>): void;
|
|
42
|
+
errors: DeepMapValues<RequiredDeep<T>, {
|
|
43
|
+
message: string;
|
|
44
|
+
}>;
|
|
45
|
+
registeredFields: {
|
|
46
|
+
value: string[];
|
|
47
|
+
} & {
|
|
48
|
+
$$valtioSnapshot: {
|
|
49
|
+
value: string[];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
reset(values?: DeepPartial<T>): void;
|
|
53
|
+
};
|
|
54
|
+
export declare function useForm<T extends ReturnType<typeof createFormState>>(state: T, options?: {
|
|
55
|
+
onSubmit?: (values: T["values"]) => void;
|
|
56
|
+
resetOnUnmount?: boolean;
|
|
57
|
+
}): WritableDeep<import("valtio").Snapshot<T>> & {
|
|
58
|
+
onSubmit: (e: FormEvent<HTMLFormElement>) => void;
|
|
59
|
+
register: <N extends FieldPath<T["values"]>>(name: N, handler?: {
|
|
60
|
+
onChange?: (e: Any) => Any;
|
|
61
|
+
onValueChange?: (e: Any) => Any;
|
|
62
|
+
}) => {
|
|
63
|
+
onChange(event: {
|
|
64
|
+
target: {
|
|
65
|
+
value: Any;
|
|
66
|
+
};
|
|
67
|
+
}): void;
|
|
68
|
+
name: N;
|
|
69
|
+
value: any;
|
|
70
|
+
error: boolean;
|
|
71
|
+
helpText: any;
|
|
72
|
+
required: boolean;
|
|
73
|
+
} | {
|
|
74
|
+
onValueChange(value: Any): void;
|
|
75
|
+
name: N;
|
|
76
|
+
value: any;
|
|
77
|
+
error: boolean;
|
|
78
|
+
helpText: any;
|
|
79
|
+
required: boolean;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export {};
|
package/form.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { proxy, ref, useSnapshot } from "valtio";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { cloneDeep, get, isNil, merge, set, unset } from "lodash-es";
|
|
4
|
+
import { useUnmount } from "react-use";
|
|
5
|
+
export function createFormState(options) {
|
|
6
|
+
const defaultValues = cloneDeep(options.defaultValues);
|
|
7
|
+
const valuesState = proxy(defaultValues);
|
|
8
|
+
const errorsState = proxy({});
|
|
9
|
+
const formState = proxy({
|
|
10
|
+
options,
|
|
11
|
+
values: valuesState,
|
|
12
|
+
setValue(name, value) {
|
|
13
|
+
unset(errorsState, name);
|
|
14
|
+
set(valuesState, name, value);
|
|
15
|
+
},
|
|
16
|
+
errors: errorsState,
|
|
17
|
+
registeredFields: ref({
|
|
18
|
+
value: [],
|
|
19
|
+
}),
|
|
20
|
+
reset(values) {
|
|
21
|
+
const update = merge(cloneDeep(defaultValues), cloneDeep(values));
|
|
22
|
+
for (const key in formState.values) {
|
|
23
|
+
delete formState.values[key];
|
|
24
|
+
}
|
|
25
|
+
for (const key in update) {
|
|
26
|
+
const typedKey = key;
|
|
27
|
+
formState.setValue(typedKey, update[key]);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return formState;
|
|
32
|
+
}
|
|
33
|
+
// noinspection JSUnusedGlobalSymbols
|
|
34
|
+
export function useForm(state, options) {
|
|
35
|
+
const snapshot = useSnapshot(state, {
|
|
36
|
+
sync: true,
|
|
37
|
+
});
|
|
38
|
+
useUnmount(() => {
|
|
39
|
+
if (options?.resetOnUnmount) {
|
|
40
|
+
snapshot.reset();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
...snapshot,
|
|
45
|
+
onSubmit: (e) => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
const fields = Array.from(e.currentTarget.querySelectorAll(`[name],[data-input-name]`)).map((f) => f.getAttribute("name") || f.getAttribute("data-input-name"));
|
|
48
|
+
for (const field of fields) {
|
|
49
|
+
const nameWithoutIndexes = field
|
|
50
|
+
.split(".")
|
|
51
|
+
.filter((n) => isNaN(+n))
|
|
52
|
+
.join(".");
|
|
53
|
+
const validation = get(snapshot.options.validation, nameWithoutIndexes);
|
|
54
|
+
const value = get(snapshot.values, field);
|
|
55
|
+
if (validation?.required &&
|
|
56
|
+
(Array.isArray(value) ? !value.length : !value)) {
|
|
57
|
+
set(state.errors, field, { message: validation.required });
|
|
58
|
+
}
|
|
59
|
+
else if (validation?.pattern &&
|
|
60
|
+
!validation.pattern[0].test(value)) {
|
|
61
|
+
set(state.errors, field, { message: validation.pattern[1] });
|
|
62
|
+
}
|
|
63
|
+
else if (!isNil(validation?.min) &&
|
|
64
|
+
value.length < validation?.min[0]) {
|
|
65
|
+
set(state.errors, field, { message: validation?.min[1] });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (Object.keys(state.errors).length === 0) {
|
|
69
|
+
options?.onSubmit?.(snapshot.values);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.error(state.errors);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
register: useCallback((name, handler) => {
|
|
76
|
+
if (!state.registeredFields.value.includes(name)) {
|
|
77
|
+
state.registeredFields.value.push(name);
|
|
78
|
+
}
|
|
79
|
+
const nameWithoutIndexes = name
|
|
80
|
+
.split(".")
|
|
81
|
+
.filter((n) => isNaN(+n))
|
|
82
|
+
.join(".");
|
|
83
|
+
const value = get(snapshot.values, name);
|
|
84
|
+
const props = {
|
|
85
|
+
name,
|
|
86
|
+
value: !isNil(value) ? value : "",
|
|
87
|
+
error: !!get(snapshot.errors, name),
|
|
88
|
+
// @ts-expect-error the type is correct
|
|
89
|
+
helpText: get(snapshot.errors, name)?.message,
|
|
90
|
+
required: !!get(snapshot.options.validation, nameWithoutIndexes)?.required,
|
|
91
|
+
...(handler?.onChange || !handler?.onValueChange
|
|
92
|
+
? {
|
|
93
|
+
onChange(event) {
|
|
94
|
+
snapshot.setValue(name, (handler?.onChange
|
|
95
|
+
? handler?.onChange(event)
|
|
96
|
+
: event.target.value));
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
: {
|
|
100
|
+
onValueChange(value) {
|
|
101
|
+
snapshot.setValue(name, handler.onValueChange(value));
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
};
|
|
105
|
+
if (!props.helpText) {
|
|
106
|
+
delete props.helpText;
|
|
107
|
+
}
|
|
108
|
+
return props;
|
|
109
|
+
},
|
|
110
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
+
[snapshot]),
|
|
112
|
+
};
|
|
113
|
+
}
|
package/form2.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ControllerFieldState, ControllerProps, ControllerRenderProps, FieldPath, FieldValues, UseFormProps, UseFormReturn, UseFormStateReturn } from "react-hook-form";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export declare function useForm<TSchema extends z.Schema<any, any>, TFieldValues extends FieldValues = z.infer<TSchema>>({ schema, ...props }: UseFormProps<TFieldValues> & {
|
|
5
|
+
schema?: TSchema;
|
|
6
|
+
}): UseFormReturn<TFieldValues>;
|
|
7
|
+
export declare function Controller<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: Omit<ControllerProps<TFieldValues, TName>, "render"> & {
|
|
8
|
+
render: ({ field, fieldState, formState, }: {
|
|
9
|
+
field: ControllerRenderProps<TFieldValues, TName> & {
|
|
10
|
+
error?: string;
|
|
11
|
+
};
|
|
12
|
+
fieldState: ControllerFieldState;
|
|
13
|
+
formState: UseFormStateReturn<TFieldValues>;
|
|
14
|
+
}) => React.ReactElement;
|
|
15
|
+
}): React.JSX.Element;
|
package/form2.jsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Controller as RHFController, useForm as useRHForm, } from "react-hook-form";
|
|
2
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { get } from "lodash-es";
|
|
5
|
+
export function useForm({ schema, ...props }) {
|
|
6
|
+
const jsonProps = JSON.stringify(props);
|
|
7
|
+
const config = useMemo(() => ({
|
|
8
|
+
resolver: schema ? zodResolver(schema) : undefined,
|
|
9
|
+
...props,
|
|
10
|
+
}),
|
|
11
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
|
+
[jsonProps, schema]);
|
|
13
|
+
const formReturn = useRHForm(config);
|
|
14
|
+
const register = formReturn.register;
|
|
15
|
+
formReturn.register = function (name, options) {
|
|
16
|
+
const registerReturn = register(name, options);
|
|
17
|
+
const zodProperty = schema
|
|
18
|
+
?.shape?.[name];
|
|
19
|
+
return {
|
|
20
|
+
...registerReturn,
|
|
21
|
+
error: get(formReturn.formState.errors, name)?.message,
|
|
22
|
+
required: !!zodProperty && !zodProperty.isOptional(),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
return formReturn;
|
|
26
|
+
}
|
|
27
|
+
export function Controller(props) {
|
|
28
|
+
return <RHFController {...props}/>;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useBeforeUnload(message?: string | false): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export default function useBeforeUnload(message) {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (message) {
|
|
5
|
+
const handleBeforeUnload = (e) => {
|
|
6
|
+
e.preventDefault();
|
|
7
|
+
// noinspection JSDeprecatedSymbols
|
|
8
|
+
e.returnValue = message; // This message is not shown in most browsers
|
|
9
|
+
return message; // Some older browsers may display this message
|
|
10
|
+
};
|
|
11
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
12
|
+
return () => {
|
|
13
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}, [message]);
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export default function useDebounceEffect(fn, waitTime, deps) {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
const t = setTimeout(() => {
|
|
5
|
+
// @ts-expect-error trust me
|
|
6
|
+
// eslint-disable-next-line prefer-spread
|
|
7
|
+
fn.apply(undefined, deps);
|
|
8
|
+
}, waitTime);
|
|
9
|
+
return () => {
|
|
10
|
+
clearTimeout(t);
|
|
11
|
+
};
|
|
12
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13
|
+
}, deps);
|
|
14
|
+
}
|