@brcarddev/frontend-commons 1.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/README.md +241 -0
- package/eslint.config.js +190 -0
- package/package.json +161 -0
- package/src/components/atoms/AudioPlayer/audio-player.stories.tsx +36 -0
- package/src/components/atoms/AudioPlayer/audio-player.test.tsx +20 -0
- package/src/components/atoms/AudioPlayer/audio-player.tsx +13 -0
- package/src/components/atoms/AudioPlayer/index.ts +1 -0
- package/src/components/atoms/Badge/badge.stories.tsx +80 -0
- package/src/components/atoms/Badge/badge.test.tsx +59 -0
- package/src/components/atoms/Badge/badge.tsx +47 -0
- package/src/components/atoms/Badge/index.ts +1 -0
- package/src/components/atoms/Box/box.stories.tsx +37 -0
- package/src/components/atoms/Box/box.test.tsx +47 -0
- package/src/components/atoms/Box/box.tsx +7 -0
- package/src/components/atoms/Box/index.ts +1 -0
- package/src/components/atoms/Button/button.stories.tsx +108 -0
- package/src/components/atoms/Button/button.test.tsx +54 -0
- package/src/components/atoms/Button/button.tsx +96 -0
- package/src/components/atoms/Button/index.ts +1 -0
- package/src/components/atoms/ButtonUpload/button-upload.stories.tsx +137 -0
- package/src/components/atoms/ButtonUpload/button-upload.tsx +304 -0
- package/src/components/atoms/ButtonUpload/index.ts +1 -0
- package/src/components/atoms/Calendar/calendar.stories.tsx +51 -0
- package/src/components/atoms/Calendar/calendar.test.tsx +41 -0
- package/src/components/atoms/Calendar/calendar.tsx +107 -0
- package/src/components/atoms/Calendar/index.ts +1 -0
- package/src/components/atoms/CheckIcon/check-icon.stories.tsx +38 -0
- package/src/components/atoms/CheckIcon/check-icon.test.tsx +270 -0
- package/src/components/atoms/CheckIcon/check-icon.tsx +141 -0
- package/src/components/atoms/CheckIcon/index.ts +1 -0
- package/src/components/atoms/Checkbox/checkbox.stories.tsx +133 -0
- package/src/components/atoms/Checkbox/checkbox.test.tsx +70 -0
- package/src/components/atoms/Checkbox/checkbox.tsx +31 -0
- package/src/components/atoms/Checkbox/index.ts +1 -0
- package/src/components/atoms/Flex/flex.stories.tsx +33 -0
- package/src/components/atoms/Flex/flex.test.tsx +47 -0
- package/src/components/atoms/Flex/flex.tsx +7 -0
- package/src/components/atoms/Flex/index.ts +1 -0
- package/src/components/atoms/Grid/grid.stories.tsx +33 -0
- package/src/components/atoms/Grid/grid.test.tsx +47 -0
- package/src/components/atoms/Grid/grid.tsx +7 -0
- package/src/components/atoms/Grid/index.ts +1 -0
- package/src/components/atoms/Icon/icon.stories.tsx +169 -0
- package/src/components/atoms/Icon/icon.test.tsx +272 -0
- package/src/components/atoms/Icon/icon.tsx +119 -0
- package/src/components/atoms/Icon/index.ts +1 -0
- package/src/components/atoms/Input/index.ts +1 -0
- package/src/components/atoms/Input/input.stories.tsx +704 -0
- package/src/components/atoms/Input/input.test.tsx +86 -0
- package/src/components/atoms/Input/input.tsx +161 -0
- package/src/components/atoms/InputMoney/index.ts +2 -0
- package/src/components/atoms/InputMoney/input-money.stories.tsx +240 -0
- package/src/components/atoms/InputMoney/input-money.test.tsx +98 -0
- package/src/components/atoms/InputMoney/input-money.tsx +254 -0
- package/src/components/atoms/InputPhone/index.ts +2 -0
- package/src/components/atoms/InputPhone/input-phone.stories.tsx +447 -0
- package/src/components/atoms/InputPhone/input-phone.test.tsx +148 -0
- package/src/components/atoms/InputPhone/input-phone.tsx +267 -0
- package/src/components/atoms/InputSearch/index.ts +2 -0
- package/src/components/atoms/InputSearch/input-search.stories.tsx +360 -0
- package/src/components/atoms/InputSearch/input-search.test.tsx +239 -0
- package/src/components/atoms/InputSearch/input-search.tsx +210 -0
- package/src/components/atoms/InputUpload/index.ts +1 -0
- package/src/components/atoms/InputUpload/input-upload.stories.tsx +229 -0
- package/src/components/atoms/InputUpload/input-upload.test.tsx +556 -0
- package/src/components/atoms/InputUpload/input-upload.tsx +434 -0
- package/src/components/atoms/InputWithButton/index.ts +2 -0
- package/src/components/atoms/InputWithButton/input-with-button.stories.tsx +503 -0
- package/src/components/atoms/InputWithButton/input-with-button.test.tsx +128 -0
- package/src/components/atoms/InputWithButton/input-with-button.tsx +170 -0
- package/src/components/atoms/Label/index.ts +1 -0
- package/src/components/atoms/Label/label.stories.tsx +90 -0
- package/src/components/atoms/Label/label.test.tsx +59 -0
- package/src/components/atoms/Label/label.tsx +43 -0
- package/src/components/atoms/Progress/index.ts +1 -0
- package/src/components/atoms/Progress/progress.stories.tsx +30 -0
- package/src/components/atoms/Progress/progress.test.tsx +63 -0
- package/src/components/atoms/Progress/progress.tsx +32 -0
- package/src/components/atoms/RenderCondition/index.ts +1 -0
- package/src/components/atoms/RenderCondition/render-condition.stories.tsx +28 -0
- package/src/components/atoms/RenderCondition/render-condition.test.tsx +27 -0
- package/src/components/atoms/RenderCondition/render-condition.tsx +9 -0
- package/src/components/atoms/RichTextEditor/index.ts +1 -0
- package/src/components/atoms/RichTextEditor/rich-text-editor.stories.tsx +214 -0
- package/src/components/atoms/RichTextEditor/rich-text-editor.test.tsx +442 -0
- package/src/components/atoms/RichTextEditor/rich-text-editor.tsx +202 -0
- package/src/components/atoms/Separator/index.ts +1 -0
- package/src/components/atoms/Separator/separator.stories.tsx +117 -0
- package/src/components/atoms/Separator/separator.test.tsx +50 -0
- package/src/components/atoms/Separator/separator.tsx +28 -0
- package/src/components/atoms/Skeleton/index.ts +1 -0
- package/src/components/atoms/Skeleton/skeleton.stories.tsx +84 -0
- package/src/components/atoms/Skeleton/skeleton.test.tsx +39 -0
- package/src/components/atoms/Skeleton/skeleton.tsx +14 -0
- package/src/components/atoms/Slider/index.ts +1 -0
- package/src/components/atoms/Slider/slider.stories.tsx +28 -0
- package/src/components/atoms/Slider/slider.test.tsx +90 -0
- package/src/components/atoms/Slider/slider.tsx +54 -0
- package/src/components/atoms/Sonner/index.ts +1 -0
- package/src/components/atoms/Sonner/sonner.css +39 -0
- package/src/components/atoms/Sonner/sonner.stories.tsx +261 -0
- package/src/components/atoms/Sonner/sonner.test.tsx +24 -0
- package/src/components/atoms/Sonner/sonner.tsx +13 -0
- package/src/components/atoms/Switch/index.ts +1 -0
- package/src/components/atoms/Switch/switch.stories.tsx +128 -0
- package/src/components/atoms/Switch/switch.test.tsx +70 -0
- package/src/components/atoms/Switch/switch.tsx +61 -0
- package/src/components/atoms/Textarea/index.ts +1 -0
- package/src/components/atoms/Textarea/textarea.stories.tsx +169 -0
- package/src/components/atoms/Textarea/textarea.test.tsx +56 -0
- package/src/components/atoms/Textarea/textarea.tsx +26 -0
- package/src/components/atoms/Toggle/index.ts +1 -0
- package/src/components/atoms/Toggle/toggle.stories.tsx +170 -0
- package/src/components/atoms/Toggle/toggle.test.tsx +62 -0
- package/src/components/atoms/Toggle/toggle.tsx +47 -0
- package/src/components/atoms/Typography/index.ts +1 -0
- package/src/components/atoms/Typography/typography.stories.tsx +95 -0
- package/src/components/atoms/Typography/typography.test.tsx +66 -0
- package/src/components/atoms/Typography/typography.tsx +63 -0
- package/src/components/atoms/UploadImageField/index.ts +1 -0
- package/src/components/atoms/UploadImageField/upload-image-field.stories.tsx +249 -0
- package/src/components/atoms/UploadImageField/upload-image-field.test.tsx +348 -0
- package/src/components/atoms/UploadImageField/upload-image-field.tsx +362 -0
- package/src/components/atoms/VideoPlayer/index.ts +1 -0
- package/src/components/atoms/VideoPlayer/video-player.stories.tsx +37 -0
- package/src/components/atoms/VideoPlayer/video-player.test.tsx +20 -0
- package/src/components/atoms/VideoPlayer/video-player.tsx +26 -0
- package/src/components/atoms/index.ts +31 -0
- package/src/components/icons/alert-circle.tsx +22 -0
- package/src/components/icons/align-center.tsx +22 -0
- package/src/components/icons/align-left.tsx +22 -0
- package/src/components/icons/annotation-dots.tsx +16 -0
- package/src/components/icons/annotation-question.tsx +15 -0
- package/src/components/icons/annotation.tsx +22 -0
- package/src/components/icons/announcement-01.tsx +15 -0
- package/src/components/icons/announcement-02.tsx +15 -0
- package/src/components/icons/apple-logo.tsx +9 -0
- package/src/components/icons/arrow-circle-broken-right.tsx +16 -0
- package/src/components/icons/arrow-down.tsx +9 -0
- package/src/components/icons/arrow-up.tsx +9 -0
- package/src/components/icons/at-sign.tsx +21 -0
- package/src/components/icons/award-01.tsx +15 -0
- package/src/components/icons/award-03.tsx +16 -0
- package/src/components/icons/bank-note-01.tsx +15 -0
- package/src/components/icons/bar-chart-square-02.tsx +9 -0
- package/src/components/icons/bell-01.tsx +9 -0
- package/src/components/icons/bell-04.tsx +16 -0
- package/src/components/icons/bold-01.tsx +22 -0
- package/src/components/icons/book-open-01.tsx +15 -0
- package/src/components/icons/brackets-ellipses.tsx +22 -0
- package/src/components/icons/briefcase-01.tsx +9 -0
- package/src/components/icons/brush-01.tsx +22 -0
- package/src/components/icons/building-02.tsx +9 -0
- package/src/components/icons/building-06.tsx +9 -0
- package/src/components/icons/calendar-minus-02.tsx +15 -0
- package/src/components/icons/calendar.tsx +9 -0
- package/src/components/icons/certificate-01.tsx +16 -0
- package/src/components/icons/chart-breakout-square.tsx +16 -0
- package/src/components/icons/check-circle-02.tsx +16 -0
- package/src/components/icons/check-circle.tsx +15 -0
- package/src/components/icons/check.tsx +21 -0
- package/src/components/icons/chevron-down-double.tsx +16 -0
- package/src/components/icons/chevron-down.tsx +9 -0
- package/src/components/icons/chevron-left-double.tsx +22 -0
- package/src/components/icons/chevron-left.tsx +16 -0
- package/src/components/icons/chevron-right-double.tsx +22 -0
- package/src/components/icons/chevron-right.tsx +16 -0
- package/src/components/icons/chevron-up-double.tsx +16 -0
- package/src/components/icons/clock-rewind.tsx +15 -0
- package/src/components/icons/clock-stopwatch.tsx +15 -0
- package/src/components/icons/coins-hand.tsx +15 -0
- package/src/components/icons/coins-stacked-01.tsx +15 -0
- package/src/components/icons/coins-stacked-02.tsx +15 -0
- package/src/components/icons/container.tsx +9 -0
- package/src/components/icons/copy-02.tsx +16 -0
- package/src/components/icons/copy-04.tsx +21 -0
- package/src/components/icons/corner-down-right.tsx +9 -0
- package/src/components/icons/countries/br.tsx +20 -0
- package/src/components/icons/countries/es.tsx +19 -0
- package/src/components/icons/countries/index.ts +3 -0
- package/src/components/icons/countries/us.tsx +21 -0
- package/src/components/icons/dataflow-03.tsx +15 -0
- package/src/components/icons/dotpoints-01.tsx +22 -0
- package/src/components/icons/dots-vertical.tsx +35 -0
- package/src/components/icons/download-03.tsx +16 -0
- package/src/components/icons/download-cloud-02.tsx +15 -0
- package/src/components/icons/drag.tsx +14 -0
- package/src/components/icons/dropper.tsx +21 -0
- package/src/components/icons/edit-01.tsx +15 -0
- package/src/components/icons/edit-02.tsx +9 -0
- package/src/components/icons/edit-03.tsx +23 -0
- package/src/components/icons/eye.tsx +22 -0
- package/src/components/icons/face-frown.tsx +15 -0
- package/src/components/icons/face-happy.tsx +15 -0
- package/src/components/icons/file-06.tsx +15 -0
- package/src/components/icons/file-attachment-04.tsx +15 -0
- package/src/components/icons/file-download-02.tsx +16 -0
- package/src/components/icons/file-plus-02.tsx +16 -0
- package/src/components/icons/file-search-01.tsx +22 -0
- package/src/components/icons/file-search-03.tsx +15 -0
- package/src/components/icons/filter-lines.tsx +21 -0
- package/src/components/icons/first-category.tsx +16 -0
- package/src/components/icons/first-stage.tsx +19 -0
- package/src/components/icons/folder.tsx +15 -0
- package/src/components/icons/google.tsx +12 -0
- package/src/components/icons/graduation-hat-02.tsx +15 -0
- package/src/components/icons/grid-01.tsx +36 -0
- package/src/components/icons/help-circle.tsx +16 -0
- package/src/components/icons/help-square.tsx +16 -0
- package/src/components/icons/home-line.tsx +21 -0
- package/src/components/icons/icons.stories.tsx +199 -0
- package/src/components/icons/index.ts +140 -0
- package/src/components/icons/info-circle.tsx +15 -0
- package/src/components/icons/italic-01.tsx +22 -0
- package/src/components/icons/last-category.tsx +11 -0
- package/src/components/icons/last-stage.tsx +19 -0
- package/src/components/icons/layout-alt-04.tsx +9 -0
- package/src/components/icons/lightbulb-02.tsx +16 -0
- package/src/components/icons/link-01.tsx +16 -0
- package/src/components/icons/link-broken-01.tsx +16 -0
- package/src/components/icons/linkedin-logo.tsx +17 -0
- package/src/components/icons/lock-01.tsx +21 -0
- package/src/components/icons/log-out-01.tsx +9 -0
- package/src/components/icons/mail-01.tsx +16 -0
- package/src/components/icons/marker-pin-02.tsx +10 -0
- package/src/components/icons/menu-01.tsx +9 -0
- package/src/components/icons/middle-category.tsx +10 -0
- package/src/components/icons/middle-stage.tsx +19 -0
- package/src/components/icons/ms-outlook.tsx +47 -0
- package/src/components/icons/paragraph-spacing.tsx +15 -0
- package/src/components/icons/phone-01.tsx +21 -0
- package/src/components/icons/pie-chart-02.tsx +22 -0
- package/src/components/icons/plus-circle.tsx +15 -0
- package/src/components/icons/portal-logo.tsx +76 -0
- package/src/components/icons/presentation-chart-02.tsx +14 -0
- package/src/components/icons/route.tsx +22 -0
- package/src/components/icons/save-01.tsx +15 -0
- package/src/components/icons/search-lg.tsx +15 -0
- package/src/components/icons/search-sm.tsx +9 -0
- package/src/components/icons/send-03.tsx +15 -0
- package/src/components/icons/settings-01.tsx +17 -0
- package/src/components/icons/settings-03.tsx +14 -0
- package/src/components/icons/share-05.tsx +15 -0
- package/src/components/icons/share-06.tsx +15 -0
- package/src/components/icons/slash-circle-01.tsx +9 -0
- package/src/components/icons/star-01.tsx +9 -0
- package/src/components/icons/step-icon-active.tsx +11 -0
- package/src/components/icons/step-icon-checked.tsx +10 -0
- package/src/components/icons/step-icon-default.tsx +11 -0
- package/src/components/icons/switch-horizontal-01.tsx +9 -0
- package/src/components/icons/table-01.tsx +15 -0
- package/src/components/icons/tag-01.tsx +15 -0
- package/src/components/icons/tag-03.tsx +15 -0
- package/src/components/icons/tool-02.tsx +14 -0
- package/src/components/icons/trash-01.tsx +15 -0
- package/src/components/icons/underline-01.tsx +22 -0
- package/src/components/icons/upload-cloud-02.tsx +15 -0
- package/src/components/icons/user-01.tsx +9 -0
- package/src/components/icons/user-03.tsx +9 -0
- package/src/components/icons/user-check-01.tsx +14 -0
- package/src/components/icons/user-circle.tsx +14 -0
- package/src/components/icons/user-edit.tsx +16 -0
- package/src/components/icons/user-minus-02.tsx +15 -0
- package/src/components/icons/user-plus-01.tsx +22 -0
- package/src/components/icons/user-plus-02.tsx +15 -0
- package/src/components/icons/user-square.tsx +16 -0
- package/src/components/icons/users-01.tsx +14 -0
- package/src/components/icons/users-plus-01.tsx +21 -0
- package/src/components/icons/users-plus.tsx +16 -0
- package/src/components/icons/vertical-drag.tsx +21 -0
- package/src/components/icons/x-circle.tsx +15 -0
- package/src/components/icons/x-close.tsx +9 -0
- package/src/components/icons/zap-fast.tsx +16 -0
- package/src/components/icons/zap.tsx +9 -0
- package/src/components/index.ts +4 -0
- package/src/components/molecules/Accordion/accordion.stories.tsx +81 -0
- package/src/components/molecules/Accordion/accordion.test.tsx +91 -0
- package/src/components/molecules/Accordion/accordion.tsx +65 -0
- package/src/components/molecules/Accordion/index.ts +1 -0
- package/src/components/molecules/Alert/alert.stories.tsx +75 -0
- package/src/components/molecules/Alert/alert.test.tsx +58 -0
- package/src/components/molecules/Alert/alert.tsx +67 -0
- package/src/components/molecules/Alert/index.ts +1 -0
- package/src/components/molecules/AlertDialog/alert-dialog.stories.tsx +55 -0
- package/src/components/molecules/AlertDialog/alert-dialog.test.tsx +34 -0
- package/src/components/molecules/AlertDialog/alert-dialog.tsx +172 -0
- package/src/components/molecules/AlertDialog/index.ts +1 -0
- package/src/components/molecules/Avatar/avatar.stories.tsx +98 -0
- package/src/components/molecules/Avatar/avatar.test.tsx +55 -0
- package/src/components/molecules/Avatar/avatar.tsx +55 -0
- package/src/components/molecules/Avatar/index.ts +1 -0
- package/src/components/molecules/Breadcrumb/breadcrumb.stories.tsx +125 -0
- package/src/components/molecules/Breadcrumb/breadcrumb.test.tsx +118 -0
- package/src/components/molecules/Breadcrumb/breadcrumb.tsx +120 -0
- package/src/components/molecules/Breadcrumb/index.ts +1 -0
- package/src/components/molecules/Card/card.stories.tsx +109 -0
- package/src/components/molecules/Card/card.test.tsx +103 -0
- package/src/components/molecules/Card/card.tsx +78 -0
- package/src/components/molecules/Card/index.ts +1 -0
- package/src/components/molecules/Collapsible/collapsible.stories.tsx +28 -0
- package/src/components/molecules/Collapsible/collapsible.test.tsx +36 -0
- package/src/components/molecules/Collapsible/collapsible.tsx +31 -0
- package/src/components/molecules/Collapsible/index.ts +1 -0
- package/src/components/molecules/ColorPicker/color-picker.stories.tsx +40 -0
- package/src/components/molecules/ColorPicker/color-picker.tsx +106 -0
- package/src/components/molecules/ColorPicker/index.ts +1 -0
- package/src/components/molecules/ColorScale/color-scale.stories.tsx +31 -0
- package/src/components/molecules/ColorScale/color-scale.tsx +74 -0
- package/src/components/molecules/ColorScale/index.ts +1 -0
- package/src/components/molecules/Command/command.stories.tsx +71 -0
- package/src/components/molecules/Command/command.test.tsx +50 -0
- package/src/components/molecules/Command/command.tsx +177 -0
- package/src/components/molecules/Command/index.ts +1 -0
- package/src/components/molecules/ContextMenu/context-menu.stories.tsx +69 -0
- package/src/components/molecules/ContextMenu/context-menu.test.tsx +25 -0
- package/src/components/molecules/ContextMenu/context-menu.tsx +259 -0
- package/src/components/molecules/ContextMenu/index.ts +1 -0
- package/src/components/molecules/DatePicker/date-picker.stories.tsx +204 -0
- package/src/components/molecules/DatePicker/date-picker.test.tsx +27 -0
- package/src/components/molecules/DatePicker/date-picker.tsx +486 -0
- package/src/components/molecules/DatePicker/index.ts +1 -0
- package/src/components/molecules/Dialog/dialog.stories.tsx +48 -0
- package/src/components/molecules/Dialog/dialog.test.tsx +51 -0
- package/src/components/molecules/Dialog/dialog.tsx +150 -0
- package/src/components/molecules/Dialog/index.ts +1 -0
- package/src/components/molecules/Drawer/drawer.stories.tsx +182 -0
- package/src/components/molecules/Drawer/drawer.test.tsx +100 -0
- package/src/components/molecules/Drawer/drawer.tsx +206 -0
- package/src/components/molecules/Drawer/index.ts +1 -0
- package/src/components/molecules/Dropdown/dropdown-async.stories.tsx +15 -0
- package/src/components/molecules/Dropdown/dropdown.stories.tsx +112 -0
- package/src/components/molecules/Dropdown/dropdown.test.tsx +128 -0
- package/src/components/molecules/Dropdown/dropdown.tsx +322 -0
- package/src/components/molecules/Dropdown/index.ts +1 -0
- package/src/components/molecules/DropdownMenu/dropdown-menu.stories.tsx +154 -0
- package/src/components/molecules/DropdownMenu/dropdown-menu.test.tsx +163 -0
- package/src/components/molecules/DropdownMenu/dropdown-menu.tsx +313 -0
- package/src/components/molecules/DropdownMenu/index.ts +1 -0
- package/src/components/molecules/HoverCard/hover-card.stories.tsx +48 -0
- package/src/components/molecules/HoverCard/hover-card.test.tsx +42 -0
- package/src/components/molecules/HoverCard/hover-card.tsx +44 -0
- package/src/components/molecules/HoverCard/index.ts +1 -0
- package/src/components/molecules/InputOTP/index.ts +1 -0
- package/src/components/molecules/InputOTP/input-otp.stories.tsx +52 -0
- package/src/components/molecules/InputOTP/input-otp.test.tsx +28 -0
- package/src/components/molecules/InputOTP/input-otp.tsx +76 -0
- package/src/components/molecules/Menubar/index.ts +1 -0
- package/src/components/molecules/Menubar/menubar.stories.tsx +113 -0
- package/src/components/molecules/Menubar/menubar.test.tsx +42 -0
- package/src/components/molecules/Menubar/menubar.tsx +314 -0
- package/src/components/molecules/NavigationMenu/index.ts +1 -0
- package/src/components/molecules/NavigationMenu/navigation-menu.stories.tsx +143 -0
- package/src/components/molecules/NavigationMenu/navigation-menu.test.tsx +69 -0
- package/src/components/molecules/NavigationMenu/navigation-menu.tsx +174 -0
- package/src/components/molecules/PDFViewer/index.ts +1 -0
- package/src/components/molecules/PDFViewer/pdf-viewer.stories.tsx +34 -0
- package/src/components/molecules/PDFViewer/pdf-viewer.test.tsx +26 -0
- package/src/components/molecules/PDFViewer/pdf-viewer.tsx +358 -0
- package/src/components/molecules/Pagination/index.ts +1 -0
- package/src/components/molecules/Pagination/pagination.stories.tsx +193 -0
- package/src/components/molecules/Pagination/pagination.test.tsx +448 -0
- package/src/components/molecules/Pagination/pagination.tsx +206 -0
- package/src/components/molecules/PaginationDotGroup/index.ts +1 -0
- package/src/components/molecules/PaginationDotGroup/pagination-dot-group.stories.tsx +211 -0
- package/src/components/molecules/PaginationDotGroup/pagination-dot-group.test.tsx +385 -0
- package/src/components/molecules/PaginationDotGroup/pagination-dot-group.tsx +119 -0
- package/src/components/molecules/Popover/index.ts +1 -0
- package/src/components/molecules/Popover/popover-menu.stories.tsx +27 -0
- package/src/components/molecules/Popover/popover.test.tsx +50 -0
- package/src/components/molecules/Popover/popover.tsx +38 -0
- package/src/components/molecules/ProgressSteps/index.ts +1 -0
- package/src/components/molecules/ProgressSteps/progress-steps.stories.tsx +36 -0
- package/src/components/molecules/ProgressSteps/progress-steps.test.tsx +470 -0
- package/src/components/molecules/ProgressSteps/progress-steps.tsx +140 -0
- package/src/components/molecules/RadioGroup/index.ts +1 -0
- package/src/components/molecules/RadioGroup/radio-group.stories.tsx +42 -0
- package/src/components/molecules/RadioGroup/radio-group.test.tsx +22 -0
- package/src/components/molecules/RadioGroup/radio-group.tsx +55 -0
- package/src/components/molecules/Resizable/index.ts +1 -0
- package/src/components/molecules/Resizable/resizable.stories.tsx +52 -0
- package/src/components/molecules/Resizable/resizable.test.tsx +22 -0
- package/src/components/molecules/Resizable/resizable.tsx +55 -0
- package/src/components/molecules/ScrollArea/index.ts +1 -0
- package/src/components/molecules/ScrollArea/scroll-area.stories.tsx +93 -0
- package/src/components/molecules/ScrollArea/scroll-area.test.tsx +28 -0
- package/src/components/molecules/ScrollArea/scroll-area.tsx +57 -0
- package/src/components/molecules/Select/index.ts +1 -0
- package/src/components/molecules/Select/select.stories.tsx +63 -0
- package/src/components/molecules/Select/select.test.tsx +80 -0
- package/src/components/molecules/Select/select.tsx +172 -0
- package/src/components/molecules/Sheet/index.ts +1 -0
- package/src/components/molecules/Sheet/sheet.stories.tsx +141 -0
- package/src/components/molecules/Sheet/sheet.test.tsx +70 -0
- package/src/components/molecules/Sheet/sheet.tsx +133 -0
- package/src/components/molecules/Tabs/index.ts +1 -0
- package/src/components/molecules/Tabs/tabs.stories.tsx +222 -0
- package/src/components/molecules/Tabs/tabs.test.tsx +113 -0
- package/src/components/molecules/Tabs/tabs.tsx +102 -0
- package/src/components/molecules/ToggleGroup/index.ts +1 -0
- package/src/components/molecules/ToggleGroup/toggle-group.stories.tsx +117 -0
- package/src/components/molecules/ToggleGroup/toggle-group.test.tsx +100 -0
- package/src/components/molecules/ToggleGroup/toggle-group.tsx +70 -0
- package/src/components/molecules/Tooltip/index.ts +1 -0
- package/src/components/molecules/Tooltip/tooltip.stories.tsx +133 -0
- package/src/components/molecules/Tooltip/tooltip.test.tsx +58 -0
- package/src/components/molecules/Tooltip/tooltip.tsx +58 -0
- package/src/components/molecules/index.ts +33 -0
- package/src/components/organisms/Carousel/carousel.stories.tsx +94 -0
- package/src/components/organisms/Carousel/carousel.test.tsx +24 -0
- package/src/components/organisms/Carousel/carousel.tsx +383 -0
- package/src/components/organisms/Carousel/index.ts +1 -0
- package/src/components/organisms/Chart/chart.stories.tsx +102 -0
- package/src/components/organisms/Chart/chart.test.tsx +105 -0
- package/src/components/organisms/Chart/chart.tsx +294 -0
- package/src/components/organisms/Chart/index.ts +1 -0
- package/src/components/organisms/FileUpload/FilePreview/file-preview.tsx +55 -0
- package/src/components/organisms/FileUpload/FilePreview/index.ts +1 -0
- package/src/components/organisms/FileUpload/file-upload.stories.tsx +20 -0
- package/src/components/organisms/FileUpload/file-upload.test.tsx +59 -0
- package/src/components/organisms/FileUpload/file-upload.tsx +175 -0
- package/src/components/organisms/FileUpload/file.d.ts +21 -0
- package/src/components/organisms/FileUpload/index.ts +1 -0
- package/src/components/organisms/Form/form.stories.tsx +155 -0
- package/src/components/organisms/Form/form.test.tsx +49 -0
- package/src/components/organisms/Form/form.tsx +133 -0
- package/src/components/organisms/Form/index.ts +1 -0
- package/src/components/organisms/Sidebar/index.ts +1 -0
- package/src/components/organisms/Sidebar/sidebar.stories.tsx +86 -0
- package/src/components/organisms/Sidebar/sidebar.test.tsx +101 -0
- package/src/components/organisms/Sidebar/sidebar.tsx +666 -0
- package/src/components/organisms/Table/index.ts +1 -0
- package/src/components/organisms/Table/table.stories.tsx +86 -0
- package/src/components/organisms/Table/table.test.tsx +42 -0
- package/src/components/organisms/Table/table.tsx +120 -0
- package/src/components/organisms/index.ts +6 -0
- package/src/constants/brazilian-states.ts +29 -0
- package/src/constants/index.ts +1 -0
- package/src/hooks/index.ts +10 -0
- package/src/hooks/useEditorActiveMarks.ts +63 -0
- package/src/hooks/useForm.ts +8 -0
- package/src/hooks/useFormContext.ts +7 -0
- package/src/hooks/useFormField.ts +41 -0
- package/src/hooks/useMobile.ts +61 -0
- package/src/hooks/useOnToggle.ts +28 -0
- package/src/hooks/usePDFNavigation.ts +41 -0
- package/src/hooks/usePDFZoom.ts +35 -0
- package/src/hooks/useSidebar.ts +23 -0
- package/src/hooks/useToast.tsx +63 -0
- package/src/index.css +73 -0
- package/src/main.ts +6 -0
- package/src/theme.css +388 -0
- package/src/utils/api/api.test.ts +64 -0
- package/src/utils/api/api.ts +34 -0
- package/src/utils/api/index.ts +1 -0
- package/src/utils/array/array.test.ts +160 -0
- package/src/utils/array/array.ts +43 -0
- package/src/utils/array/index.ts +1 -0
- package/src/utils/clipboard/clipboard.test.ts +218 -0
- package/src/utils/clipboard/clipboard.ts +40 -0
- package/src/utils/clipboard/index.ts +1 -0
- package/src/utils/cn/cn.test.ts +43 -0
- package/src/utils/cn/cn.ts +6 -0
- package/src/utils/cn/index.ts +1 -0
- package/src/utils/color-utils/color-utils.test.ts +46 -0
- package/src/utils/color-utils/color-utils.ts +97 -0
- package/src/utils/color-utils/index.ts +1 -0
- package/src/utils/countries/countries.ts +69 -0
- package/src/utils/countries/index.ts +1 -0
- package/src/utils/currency/currency.test.ts +114 -0
- package/src/utils/currency/currency.ts +134 -0
- package/src/utils/currency/index.ts +1 -0
- package/src/utils/date/date.test.ts +167 -0
- package/src/utils/date/date.ts +83 -0
- package/src/utils/date/index.ts +1 -0
- package/src/utils/file/file.ts +45 -0
- package/src/utils/file/index.ts +1 -0
- package/src/utils/get-initials/get-initials.test.ts +40 -0
- package/src/utils/get-initials/get-initials.ts +13 -0
- package/src/utils/get-initials/index.ts +1 -0
- package/src/utils/index.ts +14 -0
- package/src/utils/masks/index.ts +1 -0
- package/src/utils/masks/masks.ts +180 -0
- package/src/utils/render-highlighted-text/index.ts +1 -0
- package/src/utils/render-highlighted-text/render-highlighted-text.tsx +25 -0
- package/src/utils/string/index.ts +1 -0
- package/src/utils/string/string.test.ts +171 -0
- package/src/utils/string/string.ts +155 -0
- package/src/utils/video/index.ts +1 -0
- package/src/utils/video/video.ts +9 -0
- package/src/vite-env.d.ts +3 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { MASK_HELPERS } from '../masks';
|
|
2
|
+
|
|
3
|
+
export type CountryCode = typeof COUNTRY_CODES[number];
|
|
4
|
+
|
|
5
|
+
export const COUNTRY_CODES = [
|
|
6
|
+
{ code: '+55', country: 'BR', name: 'Brasil', flag: '🇧🇷', mask: '(__) _ ____-____' },
|
|
7
|
+
{ code: '+1', country: 'US', name: 'Estados Unidos', flag: '🇺🇸', mask: '(___) ___-____' },
|
|
8
|
+
{ code: '+44', country: 'GB', name: 'Reino Unido', flag: '🇬🇧', mask: '____ ______' },
|
|
9
|
+
{ code: '+33', country: 'FR', name: 'França', flag: '🇫🇷', mask: '_ __ __ __ __' },
|
|
10
|
+
{ code: '+49', country: 'DE', name: 'Alemanha', flag: '🇩🇪', mask: '____ ______' },
|
|
11
|
+
{ code: '+34', country: 'ES', name: 'Espanha', flag: '🇪🇸', mask: '___ ___ ___' },
|
|
12
|
+
{ code: '+39', country: 'IT', name: 'Itália', flag: '🇮🇹', mask: '___ ___ ____' },
|
|
13
|
+
{ code: '+31', country: 'NL', name: 'Países Baixos', flag: '🇳🇱', mask: '_ ____ ____' },
|
|
14
|
+
{ code: '+32', country: 'BE', name: 'Bélgica', flag: '🇧🇪', mask: '___ ___ ___' },
|
|
15
|
+
{ code: '+46', country: 'SE', name: 'Suécia', flag: '🇸🇪', mask: '__ ___ ____' },
|
|
16
|
+
{ code: '+47', country: 'NO', name: 'Noruega', flag: '🇳🇴', mask: '___ __ ___' },
|
|
17
|
+
{ code: '+45', country: 'DK', name: 'Dinamarca', flag: '🇩🇰', mask: '__ __ __ __' },
|
|
18
|
+
{ code: '+358', country: 'FI', name: 'Finlândia', flag: '🇫🇮', mask: '__ ___ ____' },
|
|
19
|
+
{ code: '+351', country: 'PT', name: 'Portugal', flag: '🇵🇹', mask: '___ ___ ___' },
|
|
20
|
+
{ code: '+41', country: 'CH', name: 'Suíça', flag: '🇨🇭', mask: '__ ___ ____' },
|
|
21
|
+
{ code: '+43', country: 'AT', name: 'Áustria', flag: '🇦🇹', mask: '___ ___ ____' },
|
|
22
|
+
{ code: '+48', country: 'PL', name: 'Polônia', flag: '🇵🇱', mask: '___ ___ ___' },
|
|
23
|
+
{ code: '+420', country: 'CZ', name: 'República Tcheca', flag: '🇨🇿', mask: '___ ___ ___' },
|
|
24
|
+
{ code: '+36', country: 'HU', name: 'Hungria', flag: '🇭🇺', mask: '__ ___ ____' },
|
|
25
|
+
{ code: '+7', country: 'RU', name: 'Rússia', flag: '🇷🇺', mask: '(___) ___-__-__' },
|
|
26
|
+
{ code: '+86', country: 'CN', name: 'China', flag: '🇨🇳', mask: '___ ____ ____' },
|
|
27
|
+
{ code: '+81', country: 'JP', name: 'Japão', flag: '🇯🇵', mask: '__ ____ ____' },
|
|
28
|
+
{ code: '+82', country: 'KR', name: 'Coreia do Sul', flag: '🇰🇷', mask: '__ ____ ____' },
|
|
29
|
+
{ code: '+91', country: 'IN', name: 'Índia', flag: '🇮🇳', mask: '_____ _____' },
|
|
30
|
+
{ code: '+61', country: 'AU', name: 'Austrália', flag: '🇦🇺', mask: '___ ___ ___' },
|
|
31
|
+
{ code: '+64', country: 'NZ', name: 'Nova Zelândia', flag: '🇳🇿', mask: '___ ___ ____' },
|
|
32
|
+
{ code: '+52', country: 'MX', name: 'México', flag: '🇲🇽', mask: '___ ___ ____' },
|
|
33
|
+
{ code: '+54', country: 'AR', name: 'Argentina', flag: '🇦🇷', mask: '__ ____ ____' },
|
|
34
|
+
{ code: '+56', country: 'CL', name: 'Chile', flag: '🇨🇱', mask: '_ ____ ____' },
|
|
35
|
+
{ code: '+57', country: 'CO', name: 'Colômbia', flag: '🇨🇴', mask: '___ ___ ____' },
|
|
36
|
+
{ code: '+58', country: 'VE', name: 'Venezuela', flag: '🇻🇪', mask: '___ ___ ____' },
|
|
37
|
+
{ code: '+51', country: 'PE', name: 'Peru', flag: '🇵🇪', mask: '___ ___ ___' },
|
|
38
|
+
{ code: '+593', country: 'EC', name: 'Equador', flag: '🇪🇨', mask: '__ ___ ____' },
|
|
39
|
+
{ code: '+595', country: 'PY', name: 'Paraguai', flag: '🇵🇾', mask: '__ ___ ____' },
|
|
40
|
+
{ code: '+598', country: 'UY', name: 'Uruguai', flag: '🇺🇾', mask: '__ ___ ____' },
|
|
41
|
+
] as const;
|
|
42
|
+
|
|
43
|
+
export const formatInternationalPhone = (phone: string, countryCode: string): string => {
|
|
44
|
+
const country = getCountryByCode(countryCode);
|
|
45
|
+
|
|
46
|
+
if (!country) return phone;
|
|
47
|
+
|
|
48
|
+
const numbers = phone.replace(/\D/g, '');
|
|
49
|
+
return MASK_HELPERS.applyMask(numbers, country.mask);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const getCountryByCode = (code: string): CountryCode | undefined => {
|
|
53
|
+
return COUNTRY_CODES.find(country => country.code === code);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const getDefaultCountry = (): CountryCode => {
|
|
57
|
+
return COUNTRY_CODES.find(country => country.country === 'BR') || COUNTRY_CODES[0];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const isValidInternationalPhone = (phone: string, countryCode: string): boolean => {
|
|
61
|
+
const country = getCountryByCode(countryCode);
|
|
62
|
+
|
|
63
|
+
if (!country) return false;
|
|
64
|
+
|
|
65
|
+
const numbers = phone.replace(/\D/g, '');
|
|
66
|
+
const expectedLength = country.mask.replace(/\D/g, '').length;
|
|
67
|
+
|
|
68
|
+
return numbers.length === expectedLength;
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './countries';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { normalizeCurrency } from '../string';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
convertFromCents,
|
|
7
|
+
formatCurrency,
|
|
8
|
+
formatCurrencyFromString,
|
|
9
|
+
displayAmount,
|
|
10
|
+
formatNumberToKOrM,
|
|
11
|
+
currencyShortener,
|
|
12
|
+
maskCurrency,
|
|
13
|
+
} from './currency';
|
|
14
|
+
|
|
15
|
+
describe('Currency Utils', () => {
|
|
16
|
+
describe('convertFromCents', () => {
|
|
17
|
+
it('should convert cents to decimal value', () => {
|
|
18
|
+
expect(convertFromCents('1000')).toBe(10);
|
|
19
|
+
expect(convertFromCents('150')).toBe(1.5);
|
|
20
|
+
expect(convertFromCents('0')).toBe(0);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('formatCurrency', () => {
|
|
25
|
+
it('should format number to currency string', () => {
|
|
26
|
+
expect(normalizeCurrency(formatCurrency(10.5))).toBe('R$ 10,50');
|
|
27
|
+
expect(normalizeCurrency(formatCurrency(1000))).toBe('R$ 1.000,00');
|
|
28
|
+
expect(normalizeCurrency(formatCurrency(0))).toBe('R$ 0,00');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should handle different currencies', () => {
|
|
32
|
+
expect(normalizeCurrency(formatCurrency(10.5, 'USD'))).toBe('US$ 10,50');
|
|
33
|
+
expect(normalizeCurrency(formatCurrency(10.5, 'EUR'))).toBe('€ 10,50');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should handle different locales', () => {
|
|
37
|
+
expect(normalizeCurrency(formatCurrency(10.5, 'USD', 2, 'en-US'))).toBe('$10.50');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should return dash for NaN values', () => {
|
|
41
|
+
expect(formatCurrency(NaN)).toBe('-');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('formatCurrencyFromString', () => {
|
|
46
|
+
it('should format string number to currency', () => {
|
|
47
|
+
expect(normalizeCurrency(formatCurrencyFromString('10.5'))).toBe('R$ 10,50');
|
|
48
|
+
expect(normalizeCurrency(formatCurrencyFromString('1000'))).toBe('R$ 1.000,00');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should handle different currencies', () => {
|
|
52
|
+
expect(normalizeCurrency(formatCurrencyFromString('10.5', 'USD'))).toBe('US$ 10,50');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should return dash for invalid strings', () => {
|
|
56
|
+
expect(normalizeCurrency(formatCurrencyFromString('invalid'))).toBe('-');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('displayAmount', () => {
|
|
61
|
+
it('should display amount within limit', () => {
|
|
62
|
+
expect(displayAmount(5, 10)).toBe('5');
|
|
63
|
+
expect(displayAmount(10, 10)).toBe('+10');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should display limit with plus sign when amount exceeds limit', () => {
|
|
67
|
+
expect(displayAmount(15, 10)).toBe('+10');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should display amount without limit', () => {
|
|
71
|
+
expect(displayAmount(5)).toBe('5');
|
|
72
|
+
expect(displayAmount(100)).toBe('100');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('formatNumberToKOrM', () => {
|
|
77
|
+
it('should format numbers less than 1000', () => {
|
|
78
|
+
expect(formatNumberToKOrM(999)).toBe('999');
|
|
79
|
+
expect(formatNumberToKOrM(0)).toBe('0');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should format numbers in thousands', () => {
|
|
83
|
+
expect(formatNumberToKOrM(1500)).toBe('1.5K');
|
|
84
|
+
expect(formatNumberToKOrM(9999)).toBe('10.0K');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should format numbers in millions', () => {
|
|
88
|
+
expect(formatNumberToKOrM(100000000)).toBe('100M');
|
|
89
|
+
expect(formatNumberToKOrM(150000000)).toBe('150M');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('currencyShortener', () => {
|
|
94
|
+
it('should shorten currency values', () => {
|
|
95
|
+
expect(currencyShortener(1000)).toBe('1.0K');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('maskCurrency', () => {
|
|
100
|
+
it('should mask currency values', () => {
|
|
101
|
+
expect(normalizeCurrency(maskCurrency(10.5))).toBe('R$ 10,50');
|
|
102
|
+
expect(normalizeCurrency(maskCurrency(1000))).toBe('R$ 1.000,00');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should handle different currencies', () => {
|
|
106
|
+
expect(normalizeCurrency(maskCurrency(10.5, 'pt-BR', 'USD'))).toBe('US$ 10,50');
|
|
107
|
+
expect(normalizeCurrency(maskCurrency(10.5, 'pt-BR', 'EUR'))).toBe('€ 10,50');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should handle different locales', () => {
|
|
111
|
+
expect(normalizeCurrency(maskCurrency(10.5, 'en-US', 'USD'))).toBe('$10.50');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export type CurrencyOption = {
|
|
2
|
+
code: string;
|
|
3
|
+
label: string;
|
|
4
|
+
locale: string;
|
|
5
|
+
symbol: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function convertFromCents (value: string): number {
|
|
9
|
+
const cents = parseInt(value, 10);
|
|
10
|
+
|
|
11
|
+
if (isNaN(cents)) return 0;
|
|
12
|
+
|
|
13
|
+
return toMajorUnits(cents);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const CURRENCY_OPTIONS: readonly CurrencyOption[] = [
|
|
17
|
+
{ code: 'BRL', label: 'BRL - Real', locale: 'pt-BR', symbol: 'R$' },
|
|
18
|
+
// { code: 'USD', label: 'USD - Dollar', locale: 'en-US', symbol: '$' },
|
|
19
|
+
// { code: 'EUR', label: 'EUR - Euro', locale: 'de-DE', symbol: '€' },
|
|
20
|
+
// { code: 'GBP', label: 'GBP - Pound', locale: 'en-GB', symbol: '£' },
|
|
21
|
+
] as const;
|
|
22
|
+
|
|
23
|
+
export function currencyShortener (value: number): string {
|
|
24
|
+
return formatNumberToKOrM(value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function displayAmount (amount: number, limit?: number): string {
|
|
28
|
+
if (limit && amount >= limit) return `+${limit.toString()}`;
|
|
29
|
+
|
|
30
|
+
return amount.toString();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function formatCurrency (value: number, currency = 'BRL', decimalPlaces = 2, locale = 'pt-BR'): string {
|
|
34
|
+
const formatter = new Intl.NumberFormat(locale, {
|
|
35
|
+
style: 'currency',
|
|
36
|
+
currency,
|
|
37
|
+
minimumFractionDigits: decimalPlaces,
|
|
38
|
+
maximumFractionDigits: decimalPlaces,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return !isNaN(value) ? formatter.format(value) : '-';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function formatCurrencyFromString (value: string, currency = 'BRL'): string {
|
|
45
|
+
const parsedValue = parseFloat(value);
|
|
46
|
+
|
|
47
|
+
if (isNaN(parsedValue)) {
|
|
48
|
+
return '-';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return formatCurrency(parsedValue, currency);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function formatMinorUnitsToCurrency (
|
|
55
|
+
valueInMinorUnits: number,
|
|
56
|
+
currencyCode: string,
|
|
57
|
+
locale?: string
|
|
58
|
+
): string {
|
|
59
|
+
const currency = getCurrencyByCode(currencyCode) || getDefaultCurrency();
|
|
60
|
+
const resolvedLocale = locale || currency.locale;
|
|
61
|
+
const value = (valueInMinorUnits || 0) / 100;
|
|
62
|
+
return formatCurrency(value, currency.code, 2, resolvedLocale);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function formatMinorUnitsToNumberString (
|
|
66
|
+
valueInMinorUnits: number,
|
|
67
|
+
locale = 'pt-BR'
|
|
68
|
+
): string {
|
|
69
|
+
const value = (valueInMinorUnits || 0) / 100;
|
|
70
|
+
const formatter = new Intl.NumberFormat(locale, {
|
|
71
|
+
style: 'decimal',
|
|
72
|
+
minimumFractionDigits: 2,
|
|
73
|
+
maximumFractionDigits: 2,
|
|
74
|
+
useGrouping: true,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return formatter.format(value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function formatNumberToKOrM (value: number): string {
|
|
81
|
+
const sign = value < 0 ? '-' : '';
|
|
82
|
+
const abs = Math.abs(value);
|
|
83
|
+
|
|
84
|
+
if (abs < 1000) {
|
|
85
|
+
return value.toString();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (abs < 1_000_000) {
|
|
89
|
+
const thousands = abs / 1000;
|
|
90
|
+
|
|
91
|
+
return `${sign}${thousands < 10 ? thousands.toFixed(1) : Math.round(thousands).toString()}K`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const millions = abs / 1_000_000;
|
|
95
|
+
|
|
96
|
+
return `${sign}${millions < 10 ? millions.toFixed(1) : Math.round(millions).toString()}M`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const getCurrencyByCode = (code: string): CurrencyOption | undefined => {
|
|
100
|
+
return CURRENCY_OPTIONS.find(c => c.code === code);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const getDefaultCurrency = (): CurrencyOption => {
|
|
104
|
+
return getCurrencyByCode('BRL') || CURRENCY_OPTIONS[0];
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export function maskCurrency (value: number, locale = 'pt-BR', currency = 'BRL'): string {
|
|
108
|
+
return formatCurrency(value, currency, 2, locale);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function parseCurrencyToMinorUnits (formatted: string): number {
|
|
112
|
+
if (!formatted) return 0;
|
|
113
|
+
|
|
114
|
+
const trimmed = formatted.trim();
|
|
115
|
+
const isNegative = /^-/.test(trimmed) || /-$/.test(trimmed) || (trimmed.includes('(') && trimmed.includes(')'));
|
|
116
|
+
const sign = isNegative ? -1 : 1;
|
|
117
|
+
const numbers = trimmed.replace(/\D/g, '');
|
|
118
|
+
|
|
119
|
+
if (!numbers) return 0;
|
|
120
|
+
|
|
121
|
+
return sign * parseInt(numbers, 10);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function toMajorUnits (minorUnits: number): number {
|
|
125
|
+
if (typeof minorUnits !== 'number' || !isFinite(minorUnits)) return 0;
|
|
126
|
+
|
|
127
|
+
return minorUnits / 100;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function toMinorUnits (majorUnits: number): number {
|
|
131
|
+
if (typeof majorUnits !== 'number' || !isFinite(majorUnits)) return 0;
|
|
132
|
+
|
|
133
|
+
return Math.round(majorUnits * 100);
|
|
134
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './currency';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
getCurrentDate,
|
|
6
|
+
toCurrentTimezone,
|
|
7
|
+
toCurrentTimezoneWithSeconds,
|
|
8
|
+
fromIsoToLocale,
|
|
9
|
+
createISODate,
|
|
10
|
+
formatISODate,
|
|
11
|
+
formatFromFromat,
|
|
12
|
+
fromIsoToMillis,
|
|
13
|
+
convertUnixTime,
|
|
14
|
+
addMonth,
|
|
15
|
+
} from './date';
|
|
16
|
+
|
|
17
|
+
describe('Date Utils', () => {
|
|
18
|
+
const MOCK_ISO_DATE = '2023-01-01T12:00:00.000Z';
|
|
19
|
+
const MOCK_UNIX_TIMESTAMP = 1672560000; // 2023-01-01T12:00:00Z
|
|
20
|
+
let mockDateTime: DateTime;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
mockDateTime = DateTime.fromISO(MOCK_ISO_DATE);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('getCurrentDate', () => {
|
|
27
|
+
it('should return current date in ISO format', () => {
|
|
28
|
+
const today = DateTime.local().toISODate();
|
|
29
|
+
expect(getCurrentDate()).toBe(today);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('toCurrentTimezone', () => {
|
|
34
|
+
it('should format ISO string to local string with default format', () => {
|
|
35
|
+
const expected = mockDateTime.toLocaleString(DateTime.DATETIME_SHORT);
|
|
36
|
+
expect(toCurrentTimezone(MOCK_ISO_DATE)).toBe(expected);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should format ISO string with custom format', () => {
|
|
40
|
+
const customFormat = DateTime.DATE_FULL;
|
|
41
|
+
const expected = mockDateTime.toLocaleString(customFormat);
|
|
42
|
+
expect(toCurrentTimezone(MOCK_ISO_DATE, customFormat)).toBe(expected);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should return dash for empty input', () => {
|
|
46
|
+
expect(toCurrentTimezone('')).toBe('-');
|
|
47
|
+
expect(toCurrentTimezone(undefined)).toBe('-');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('toCurrentTimezoneWithSeconds', () => {
|
|
52
|
+
it('should format ISO string with seconds and replace slashes with dashes', () => {
|
|
53
|
+
const expected = mockDateTime
|
|
54
|
+
.toLocaleString(DateTime.DATETIME_SHORT_WITH_SECONDS)
|
|
55
|
+
.replace(/\//g, '-');
|
|
56
|
+
expect(toCurrentTimezoneWithSeconds(MOCK_ISO_DATE)).toBe(expected);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should return dash for empty input', () => {
|
|
60
|
+
expect(toCurrentTimezoneWithSeconds('')).toBe('-');
|
|
61
|
+
expect(toCurrentTimezoneWithSeconds(null)).toBe('-');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('fromIsoToLocale', () => {
|
|
66
|
+
it('should convert ISO string to local string format', () => {
|
|
67
|
+
const expected = mockDateTime.toLocaleString();
|
|
68
|
+
expect(fromIsoToLocale(MOCK_ISO_DATE)).toBe(expected);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should throw error for invalid ISO string', () => {
|
|
72
|
+
expect(() => fromIsoToLocale('invalid-date')).toThrow();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('createISODate', () => {
|
|
77
|
+
it('should create DateTime object from ISO string', () => {
|
|
78
|
+
const result = createISODate(MOCK_ISO_DATE);
|
|
79
|
+
expect(result).toBeInstanceOf(DateTime);
|
|
80
|
+
expect(result.toISO()).toBe(mockDateTime.toISO());
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should throw error for invalid ISO string', () => {
|
|
84
|
+
expect(() => createISODate('invalid-date')).toThrow();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('formatISODate', () => {
|
|
89
|
+
it('should format ISO string with custom format', () => {
|
|
90
|
+
const format = 'dd/MM/yyyy';
|
|
91
|
+
const expected = mockDateTime.toFormat(format);
|
|
92
|
+
expect(formatISODate(MOCK_ISO_DATE, format)).toBe(expected);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should throw error for invalid ISO string', () => {
|
|
96
|
+
expect(() => formatISODate('invalid-date', 'dd/MM/yyyy')).toThrow();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('formatFromFromat', () => {
|
|
101
|
+
const MOCK_DATE = '01-02-2023';
|
|
102
|
+
const FROM_FORMAT = 'dd-MM-yyyy';
|
|
103
|
+
const TO_FORMAT = 'yyyy/MM/dd';
|
|
104
|
+
|
|
105
|
+
it('should convert date from one format to another', () => {
|
|
106
|
+
const expected = DateTime.fromFormat(MOCK_DATE, FROM_FORMAT).toFormat(TO_FORMAT);
|
|
107
|
+
expect(formatFromFromat(MOCK_DATE, FROM_FORMAT, TO_FORMAT)).toBe(expected);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should throw error for invalid date format', () => {
|
|
111
|
+
expect(() => formatFromFromat('invalid-date', FROM_FORMAT, TO_FORMAT)).toThrow();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('fromIsoToMillis', () => {
|
|
116
|
+
it('should convert ISO string to milliseconds', () => {
|
|
117
|
+
const expected = mockDateTime.toMillis();
|
|
118
|
+
expect(fromIsoToMillis(MOCK_ISO_DATE)).toBe(expected);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should throw error for invalid ISO string', () => {
|
|
122
|
+
expect(() => fromIsoToMillis('invalid-date')).toThrow();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('convertUnixTime', () => {
|
|
127
|
+
it('should convert unix timestamp to local string', () => {
|
|
128
|
+
const expected = DateTime.fromSeconds(MOCK_UNIX_TIMESTAMP, {
|
|
129
|
+
zone: 'utc',
|
|
130
|
+
locale: 'pt-BR',
|
|
131
|
+
}).toLocaleString(DateTime.DATETIME_SHORT);
|
|
132
|
+
expect(convertUnixTime(MOCK_UNIX_TIMESTAMP)).toBe(expected);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should handle zero timestamp', () => {
|
|
136
|
+
const expected = DateTime.fromSeconds(0, {
|
|
137
|
+
zone: 'utc',
|
|
138
|
+
locale: 'pt-BR',
|
|
139
|
+
}).toLocaleString(DateTime.DATETIME_SHORT);
|
|
140
|
+
expect(convertUnixTime(0)).toBe(expected);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe('addMonth', () => {
|
|
145
|
+
it('should add months to DateTime object', () => {
|
|
146
|
+
const monthsToAdd = 2;
|
|
147
|
+
const result = addMonth(mockDateTime, monthsToAdd);
|
|
148
|
+
expect(result.month).toBe(mockDateTime.month + monthsToAdd);
|
|
149
|
+
expect(result.year).toBe(mockDateTime.year);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should handle year rollover when adding months', () => {
|
|
153
|
+
const date = DateTime.fromISO('2023-12-01T12:00:00.000Z');
|
|
154
|
+
const result = addMonth(date, 2);
|
|
155
|
+
expect(result.month).toBe(2);
|
|
156
|
+
expect(result.year).toBe(date.year + 1);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('should handle negative months', () => {
|
|
160
|
+
const monthsToSubtract = -2;
|
|
161
|
+
const result = addMonth(mockDateTime, monthsToSubtract);
|
|
162
|
+
const expectedDate = mockDateTime.minus({ months: 2 });
|
|
163
|
+
expect(result.month).toBe(expectedDate.month);
|
|
164
|
+
expect(result.year).toBe(expectedDate.year);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
|
|
3
|
+
export function addMonth (date: DateTime, month: number): DateTime {
|
|
4
|
+
const result = date.plus({ months: month });
|
|
5
|
+
return result;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function convertUnixTime (unix: number) {
|
|
9
|
+
const unixParsed = Number(unix);
|
|
10
|
+
|
|
11
|
+
const unixConverted = DateTime.fromSeconds(unixParsed, {
|
|
12
|
+
zone: 'utc',
|
|
13
|
+
locale: 'pt-BR',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return unixConverted.toLocaleString(DateTime.DATETIME_SHORT);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createISODate (date: string): DateTime {
|
|
20
|
+
const parsedDate = DateTime.fromISO(date);
|
|
21
|
+
|
|
22
|
+
if (!parsedDate.isValid) {
|
|
23
|
+
throw new Error('Invalid ISO date string');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return parsedDate;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function formatFromFromat (date: string, fromFormat: string, toFormat: string) {
|
|
30
|
+
const dateFormat = DateTime.fromFormat(date, fromFormat);
|
|
31
|
+
|
|
32
|
+
if (!dateFormat.isValid) {
|
|
33
|
+
throw new Error('Invalid date format');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return dateFormat.toFormat(toFormat);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function formatISODate (date: string, format: string): string {
|
|
40
|
+
const parsedDate = DateTime.fromISO(date);
|
|
41
|
+
|
|
42
|
+
if (!parsedDate.isValid) {
|
|
43
|
+
throw new Error('Invalid ISO date string');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return parsedDate.toFormat(format);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function fromIsoToLocale (date: string): string {
|
|
50
|
+
const parsedDate = DateTime.fromISO(date);
|
|
51
|
+
|
|
52
|
+
if (!parsedDate.isValid) {
|
|
53
|
+
throw new Error('Invalid ISO date string');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return parsedDate.toLocaleString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function fromIsoToMillis (date: string): number {
|
|
60
|
+
const parsedDate = DateTime.fromISO(date);
|
|
61
|
+
|
|
62
|
+
if (!parsedDate.isValid) {
|
|
63
|
+
throw new Error('Invalid ISO date string');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return parsedDate.toMillis();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function getCurrentDate (): string | null {
|
|
70
|
+
return DateTime.local().toISODate();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function toCurrentTimezone (date: string | undefined | null, format = DateTime.DATETIME_SHORT): string {
|
|
74
|
+
if (!date) return '-';
|
|
75
|
+
|
|
76
|
+
return DateTime?.fromISO(date)?.toLocaleString(format);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function toCurrentTimezoneWithSeconds (date: string | undefined | null): string {
|
|
80
|
+
if (!date) return '-';
|
|
81
|
+
|
|
82
|
+
return DateTime?.fromISO(date)?.toLocaleString(DateTime.DATETIME_SHORT_WITH_SECONDS).replace(/\//g, '-');
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './date';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const formatFileSize = (bytes: number) => {
|
|
2
|
+
if (bytes === 0) return '0 Bytes';
|
|
3
|
+
|
|
4
|
+
const k = 1024;
|
|
5
|
+
const sizes = [ 'Bytes', 'KB', 'MB', 'GB' ];
|
|
6
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
7
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function getMimeTypeByExtension(extension: string): string {
|
|
11
|
+
const mimeTypes: { [key: string]: string } = {
|
|
12
|
+
'.3gp': 'video/3gpp',
|
|
13
|
+
'.avi': 'video/x-msvideo',
|
|
14
|
+
'.bmp': 'image/bmp',
|
|
15
|
+
'.csv': 'text/csv',
|
|
16
|
+
'.doc': 'application/msword',
|
|
17
|
+
'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
18
|
+
'.gif': 'image/gif',
|
|
19
|
+
'.htm': 'text/html',
|
|
20
|
+
'.html': 'text/html',
|
|
21
|
+
'.jpeg': 'image/jpeg',
|
|
22
|
+
'.jpg': 'image/jpeg',
|
|
23
|
+
'.json': 'application/json',
|
|
24
|
+
'.mp3': 'audio/mpeg',
|
|
25
|
+
'.mp4': 'video/mp4',
|
|
26
|
+
'.mpeg': 'video/mpeg',
|
|
27
|
+
'.pdf': 'application/pdf',
|
|
28
|
+
'.png': 'image/png',
|
|
29
|
+
'.ppt': 'application/vnd.ms-powerpoint',
|
|
30
|
+
'.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
31
|
+
'.svg': 'image/svg+xml',
|
|
32
|
+
'.tif': 'image/tiff',
|
|
33
|
+
'.tiff': 'image/tiff',
|
|
34
|
+
'.txt': 'text/plain',
|
|
35
|
+
'.wav': 'audio/wav',
|
|
36
|
+
'.xls': 'application/vnd.ms-excel',
|
|
37
|
+
'.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
38
|
+
'.xml': 'application/xml',
|
|
39
|
+
'.zip': 'application/zip',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const mimeType = mimeTypes[extension.toLowerCase()];
|
|
43
|
+
|
|
44
|
+
return mimeType;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './file';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { getInitials } from './get-initials';
|
|
4
|
+
|
|
5
|
+
describe('getInitials utility', () => {
|
|
6
|
+
it('should return empty string when input is empty', () => {
|
|
7
|
+
expect(getInitials('')).toBe('');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should return empty string when input is only spaces', () => {
|
|
11
|
+
expect(getInitials(' ')).toBe('');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should return the first letter of a single name, capitalized', () => {
|
|
15
|
+
expect(getInitials('alice')).toBe('A');
|
|
16
|
+
expect(getInitials(' bob ')).toBe('B');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should return initials from first and last words of a full name', () => {
|
|
20
|
+
expect(getInitials('John Doe')).toBe('JD');
|
|
21
|
+
expect(getInitials('Marie Curie')).toBe('MC');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return initials using first and last word, ignoring middle names', () => {
|
|
25
|
+
expect(getInitials('Ada Lovelace Byron')).toBe('AB');
|
|
26
|
+
expect(getInitials('Jean Baptiste Pierre Antoine de Monet')).toBe('JM');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should handle mixed casing and trim spaces correctly', () => {
|
|
30
|
+
expect(getInitials(' aDa lOvElAcE ')).toBe('AL');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should return correct initials for hyphenated names', () => {
|
|
34
|
+
expect(getInitials('Mary-Jane Watson')).toBe('MW');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should not throw if name is a string with only one character', () => {
|
|
38
|
+
expect(getInitials('Q')).toBe('Q');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function getInitials(name: string) {
|
|
2
|
+
if (!name) return '';
|
|
3
|
+
|
|
4
|
+
const words = name.trim().split(' ').filter(Boolean);
|
|
5
|
+
|
|
6
|
+
if (words.length === 0) return '';
|
|
7
|
+
|
|
8
|
+
if (words.length === 1) {
|
|
9
|
+
return words[0][0].toUpperCase();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (words[0][0] + words[words.length - 1][0]).toUpperCase();
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-initials';
|