@takaro/lib-components 0.0.0-next.0da151e
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/.babelrc +7 -0
- package/@types/files.d.ts +23 -0
- package/@types/react-table-config.d.ts +121 -0
- package/Dockerfile.dev +21 -0
- package/package.json +15 -0
- package/public/images/7-days-to-die/logo.png +0 -0
- package/public/images/csmm-icon.png +0 -0
- package/public/images/milk.png +0 -0
- package/public/images/placeholder-01.jpeg +0 -0
- package/public/images/placeholder-02.jpeg +0 -0
- package/public/images/placeholder-03.jpeg +0 -0
- package/public/images/rust/logo.png +0 -0
- package/readme.md +10 -0
- package/src/components/actions/Button/Button.stories.tsx +149 -0
- package/src/components/actions/Button/Button.test.tsx +8 -0
- package/src/components/actions/Button/Button.test.tsx.snap +89 -0
- package/src/components/actions/Button/__snapshots__/Button.test.tsx.snap +18 -0
- package/src/components/actions/Button/index.tsx +89 -0
- package/src/components/actions/Button/style.ts +142 -0
- package/src/components/actions/ContextMenu/ContextMenu.stories.tsx +41 -0
- package/src/components/actions/ContextMenu/Group.tsx +34 -0
- package/src/components/actions/ContextMenu/MenuItem.tsx +69 -0
- package/src/components/actions/ContextMenu/index.tsx +216 -0
- package/src/components/actions/Dropdown/Dropdown.stories.tsx +88 -0
- package/src/components/actions/Dropdown/DropdownContext.tsx +21 -0
- package/src/components/actions/Dropdown/DropdownMenu.tsx +70 -0
- package/src/components/actions/Dropdown/DropdownMenuGroup.tsx +37 -0
- package/src/components/actions/Dropdown/DropdownMenuItem.tsx +128 -0
- package/src/components/actions/Dropdown/DropdownTrigger.tsx +87 -0
- package/src/components/actions/Dropdown/index.tsx +22 -0
- package/src/components/actions/Dropdown/useDropdown.tsx +89 -0
- package/src/components/actions/DropdownButton/DropdownButton.stories.tsx +88 -0
- package/src/components/actions/DropdownButton/index.tsx +128 -0
- package/src/components/actions/IconButton/IconButton.stories.tsx +54 -0
- package/src/components/actions/IconButton/IconButton.test.tsx +8 -0
- package/src/components/actions/IconButton/IconButton.test.tsx.snap +46 -0
- package/src/components/actions/IconButton/__snapshots__/IconButton.test.tsx.snap +18 -0
- package/src/components/actions/IconButton/getIconSize.ts +16 -0
- package/src/components/actions/IconButton/index.tsx +28 -0
- package/src/components/actions/IconButton/style.ts +51 -0
- package/src/components/actions/ToggleButton/ToggleButton.stories.tsx +85 -0
- package/src/components/actions/ToggleButton/ToggleButton.tsx +48 -0
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +107 -0
- package/src/components/actions/ToggleButton/index.tsx +2 -0
- package/src/components/actions/ToggleButton/style.ts +75 -0
- package/src/components/actions/index.ts +16 -0
- package/src/components/charts/AreaChart/AreaChart.stories.tsx +103 -0
- package/src/components/charts/AreaChart/index.tsx +428 -0
- package/src/components/charts/BarChart/BarChart.stories.tsx +55 -0
- package/src/components/charts/BarChart/index.tsx +420 -0
- package/src/components/charts/BrushHandle.tsx +21 -0
- package/src/components/charts/EmptyChart.tsx +45 -0
- package/src/components/charts/GeoMercator/GeoMercator.stories.tsx +77 -0
- package/src/components/charts/GeoMercator/index.tsx +228 -0
- package/src/components/charts/GeoMercator/iso3166-alpha2-to-alpha3.ts +250 -0
- package/src/components/charts/GeoMercator/world.d.ts +1 -0
- package/src/components/charts/GeoMercator/world.json +99818 -0
- package/src/components/charts/Heatmap/Heatmap.stories.tsx +189 -0
- package/src/components/charts/Heatmap/index.tsx +461 -0
- package/src/components/charts/LineChart/LineChart.stories.tsx +111 -0
- package/src/components/charts/LineChart/index.tsx +353 -0
- package/src/components/charts/PieChart/PieChart.stories.tsx +151 -0
- package/src/components/charts/PieChart/index.tsx +457 -0
- package/src/components/charts/PointHighlight.tsx +49 -0
- package/src/components/charts/RadarChart/RadarChart.stories.tsx +47 -0
- package/src/components/charts/RadarChart/generators.ts +30 -0
- package/src/components/charts/RadarChart/index.tsx +224 -0
- package/src/components/charts/RadialBarChart/RadialBarChart.stories.tsx +59 -0
- package/src/components/charts/RadialBarChart/index.tsx +231 -0
- package/src/components/charts/RadialLineChart/RadialLineChart.stories.tsx +43 -0
- package/src/components/charts/RadialLineChart/index.tsx +231 -0
- package/src/components/charts/ZoomControls.tsx +49 -0
- package/src/components/charts/index.tsx +26 -0
- package/src/components/charts/useGradients.tsx +37 -0
- package/src/components/charts/util.ts +78 -0
- package/src/components/data/Avatar/Avatar.stories.tsx +93 -0
- package/src/components/data/Avatar/context.tsx +20 -0
- package/src/components/data/Avatar/index.tsx +136 -0
- package/src/components/data/Avatar/style.ts +124 -0
- package/src/components/data/Avatar/useImageLoadingStatus.tsx +32 -0
- package/src/components/data/Chip/Chip.stories.tsx +67 -0
- package/src/components/data/Chip/Chip.test.tsx +8 -0
- package/src/components/data/Chip/Chip.test.tsx.snap +50 -0
- package/src/components/data/Chip/__snapshots__/Chip.test.tsx.snap +38 -0
- package/src/components/data/Chip/index.tsx +67 -0
- package/src/components/data/Chip/style.ts +49 -0
- package/src/components/data/Console/Console.stories.tsx +51 -0
- package/src/components/data/Console/Console.tsx +125 -0
- package/src/components/data/Console/ConsoleInput/index.tsx +87 -0
- package/src/components/data/Console/ConsoleInput/style.ts +41 -0
- package/src/components/data/Console/ConsoleLine/index.tsx +127 -0
- package/src/components/data/Console/ConsoleLine/style.ts +76 -0
- package/src/components/data/Console/MessageModel.ts +9 -0
- package/src/components/data/Console/constants.ts +6 -0
- package/src/components/data/Console/index.tsx +4 -0
- package/src/components/data/Console/style.ts +31 -0
- package/src/components/data/Console/useConsoleLiveMode.ts +42 -0
- package/src/components/data/CopyId/CopyId.stories.tsx +36 -0
- package/src/components/data/CopyId/index.tsx +107 -0
- package/src/components/data/CountryList/index.tsx +146 -0
- package/src/components/data/DateFormatter/DateFormatter.stories.tsx +26 -0
- package/src/components/data/DateFormatter/index.tsx +15 -0
- package/src/components/data/Drawer/Drawer.stories.tsx +155 -0
- package/src/components/data/Drawer/DrawerBody.tsx +22 -0
- package/src/components/data/Drawer/DrawerContent.tsx +169 -0
- package/src/components/data/Drawer/DrawerContext.tsx +21 -0
- package/src/components/data/Drawer/DrawerFooter.tsx +19 -0
- package/src/components/data/Drawer/DrawerHeading.tsx +50 -0
- package/src/components/data/Drawer/DrawerSkeleton.tsx +29 -0
- package/src/components/data/Drawer/index.tsx +25 -0
- package/src/components/data/Drawer/useDrawer.tsx +66 -0
- package/src/components/data/InfiniteScroll/InfiniteScroll.stories.tsx +33 -0
- package/src/components/data/InfiniteScroll/index.tsx +54 -0
- package/src/components/data/Stats/Sparkline.tsx +48 -0
- package/src/components/data/Stats/Stat.tsx +192 -0
- package/src/components/data/Stats/Stats.stories.tsx +196 -0
- package/src/components/data/Stats/context.tsx +18 -0
- package/src/components/data/Stats/index.tsx +62 -0
- package/src/components/data/Table/Table.stories.tsx +146 -0
- package/src/components/data/Table/index.tsx +492 -0
- package/src/components/data/Table/react-table.d.ts +14 -0
- package/src/components/data/Table/style.ts +97 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +164 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +207 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +90 -0
- package/src/components/data/Table/subcomponents/ColumnVisibility/index.tsx +70 -0
- package/src/components/data/Table/subcomponents/Filter/field.tsx +127 -0
- package/src/components/data/Table/subcomponents/Filter/index.tsx +228 -0
- package/src/components/data/Table/subcomponents/Filter/style.ts +26 -0
- package/src/components/data/Table/subcomponents/Filter/types.ts +10 -0
- package/src/components/data/Table/subcomponents/Pagination/PagePicker.tsx +109 -0
- package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +37 -0
- package/src/components/data/Table/subcomponents/Pagination/style.ts +49 -0
- package/src/components/data/index.ts +28 -0
- package/src/components/dialogs/Dialog/Dialog.stories.tsx +77 -0
- package/src/components/dialogs/Dialog/DialogBody.tsx +64 -0
- package/src/components/dialogs/Dialog/DialogContent.tsx +44 -0
- package/src/components/dialogs/Dialog/DialogContext.tsx +21 -0
- package/src/components/dialogs/Dialog/DialogHeading.tsx +56 -0
- package/src/components/dialogs/Dialog/index.tsx +20 -0
- package/src/components/dialogs/Dialog/useDialog.tsx +50 -0
- package/src/components/feedback/Alert/Alert.stories.tsx +75 -0
- package/src/components/feedback/Alert/Alert.test.tsx +8 -0
- package/src/components/feedback/Alert/Alert.test.tsx.snap +146 -0
- package/src/components/feedback/Alert/__snapshots__/Alert.test.tsx.snap +44 -0
- package/src/components/feedback/Alert/index.tsx +120 -0
- package/src/components/feedback/Alert/style.ts +97 -0
- package/src/components/feedback/Badge/Badge.stories.tsx +23 -0
- package/src/components/feedback/Badge/index.tsx +47 -0
- package/src/components/feedback/ErrorFallback/ErrorFallback.stories.tsx +10 -0
- package/src/components/feedback/ErrorFallback/index.tsx +49 -0
- package/src/components/feedback/ErrorPage/ErrorPage.stories.tsx +31 -0
- package/src/components/feedback/ErrorPage/index.tsx +193 -0
- package/src/components/feedback/FormError/FormError.stories.tsx +25 -0
- package/src/components/feedback/FormError/index.tsx +54 -0
- package/src/components/feedback/IconTooltip/IconTooltip.stories.tsx +22 -0
- package/src/components/feedback/IconTooltip/index.tsx +51 -0
- package/src/components/feedback/Loaders/Loaders.stories.tsx +28 -0
- package/src/components/feedback/Loaders/Loading.test.tsx +8 -0
- package/src/components/feedback/Loaders/Loading.test.tsx.snap +141 -0
- package/src/components/feedback/Loaders/Loading.tsx +107 -0
- package/src/components/feedback/Loaders/Spinner.test.tsx +8 -0
- package/src/components/feedback/Loaders/Spinner.test.tsx.snap +18 -0
- package/src/components/feedback/Loaders/Spinner.tsx +74 -0
- package/src/components/feedback/Loaders/__snapshots__/Loading.test.tsx.snap +141 -0
- package/src/components/feedback/Loaders/__snapshots__/Spinner.test.tsx.snap +10 -0
- package/src/components/feedback/Loaders/index.ts +2 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.stories.tsx +21 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx +8 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx.snap +3 -0
- package/src/components/feedback/NetworkDetector/__snapshots__/NetworkDetector.test.tsx.snap +3 -0
- package/src/components/feedback/NetworkDetector/index.tsx +41 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.stories.tsx +13 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +15 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/__snapshots__/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/index.tsx +78 -0
- package/src/components/feedback/Popover/Popover.stories.tsx +33 -0
- package/src/components/feedback/Popover/PopoverContent.tsx +46 -0
- package/src/components/feedback/Popover/PopoverContext.tsx +21 -0
- package/src/components/feedback/Popover/PopoverTrigger.tsx +45 -0
- package/src/components/feedback/Popover/index.tsx +22 -0
- package/src/components/feedback/Popover/usePopover.tsx +87 -0
- package/src/components/feedback/ProgressBar/ProgressBar.stories.tsx +38 -0
- package/src/components/feedback/ProgressBar/index.tsx +137 -0
- package/src/components/feedback/Skeleton/Skeleton.stories.tsx +33 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx +8 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx.snap +35 -0
- package/src/components/feedback/Skeleton/__snapshots__/Skeleton.test.tsx.snap +9 -0
- package/src/components/feedback/Skeleton/index.tsx +62 -0
- package/src/components/feedback/Tooltip/Tooltip.stories.tsx +69 -0
- package/src/components/feedback/Tooltip/TooltipContent.tsx +51 -0
- package/src/components/feedback/Tooltip/TooltipContext.tsx +13 -0
- package/src/components/feedback/Tooltip/TooltipTrigger.tsx +39 -0
- package/src/components/feedback/Tooltip/index.tsx +26 -0
- package/src/components/feedback/Tooltip/useTooltip.tsx +82 -0
- package/src/components/feedback/index.ts +37 -0
- package/src/components/feedback/snacks/CookieConsent/index.tsx +125 -0
- package/src/components/feedback/snacks/CookieConsent/style.ts +99 -0
- package/src/components/feedback/snacks/Default/default.stories.tsx +73 -0
- package/src/components/feedback/snacks/Default/index.tsx +78 -0
- package/src/components/feedback/snacks/Default/style.ts +58 -0
- package/src/components/feedback/snacks/Drawer/Drawer.stories.tsx +46 -0
- package/src/components/feedback/snacks/Drawer/index.tsx +85 -0
- package/src/components/feedback/snacks/NetworkDetector/index.tsx +73 -0
- package/src/components/feedback/snacks/index.d.ts +15 -0
- package/src/components/feedback/snacks/index.ts +8 -0
- package/src/components/index.ts +9 -0
- package/src/components/inputs/CheckBox/CheckBox.stories.tsx +64 -0
- package/src/components/inputs/CheckBox/Controlled.tsx +123 -0
- package/src/components/inputs/CheckBox/Generic.tsx +42 -0
- package/src/components/inputs/CheckBox/index.tsx +4 -0
- package/src/components/inputs/CheckBox/style.ts +56 -0
- package/src/components/inputs/CodeField/CodeField.stories.tsx +86 -0
- package/src/components/inputs/CodeField/index.tsx +174 -0
- package/src/components/inputs/CodeField/style.ts +50 -0
- package/src/components/inputs/Date/DatePicker/Controlled.tsx +103 -0
- package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +267 -0
- package/src/components/inputs/Date/DatePicker/Generic.tsx +283 -0
- package/src/components/inputs/Date/DatePicker/formats.tsx +32 -0
- package/src/components/inputs/Date/DatePicker/style.ts +41 -0
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +123 -0
- package/src/components/inputs/Date/DateRangePicker/Controlled.tsx +74 -0
- package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +37 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Absolute.tsx +98 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Relative.tsx +54 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/index.tsx +49 -0
- package/src/components/inputs/Date/DateRangePicker/Generic.tsx +167 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +254 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/style.ts +40 -0
- package/src/components/inputs/Date/DateRangePicker/style.ts +65 -0
- package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +150 -0
- package/src/components/inputs/Date/subcomponents/Calendar/style.ts +61 -0
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +170 -0
- package/src/components/inputs/Date/subcomponents/RelativePicker/style.ts +50 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/TimePicker.stories.tsx +25 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/index.tsx +40 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/style.ts +34 -0
- package/src/components/inputs/Date/types.ts +14 -0
- package/src/components/inputs/DurationField/Controlled.tsx +69 -0
- package/src/components/inputs/DurationField/Duration.stories.tsx +57 -0
- package/src/components/inputs/DurationField/Generic.tsx +197 -0
- package/src/components/inputs/DurationField/__tests__/Generic.test.tsx +12 -0
- package/src/components/inputs/DurationField/index.tsx +5 -0
- package/src/components/inputs/DurationField/style.ts +42 -0
- package/src/components/inputs/EditableField/EditableField.stories.tsx +65 -0
- package/src/components/inputs/EditableField/index.tsx +135 -0
- package/src/components/inputs/EditableField/style.ts +11 -0
- package/src/components/inputs/FileField/Controlled.tsx +104 -0
- package/src/components/inputs/FileField/FileField.stories.tsx +210 -0
- package/src/components/inputs/FileField/Generic.tsx +133 -0
- package/src/components/inputs/FileField/index.tsx +5 -0
- package/src/components/inputs/FileField/style.ts +34 -0
- package/src/components/inputs/InputProps.ts +59 -0
- package/src/components/inputs/RadioGroup/Controlled.tsx +45 -0
- package/src/components/inputs/RadioGroup/Generic.tsx +34 -0
- package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +118 -0
- package/src/components/inputs/RadioGroup/RadioItem.tsx +130 -0
- package/src/components/inputs/RadioGroup/context.tsx +20 -0
- package/src/components/inputs/RadioGroup/index.ts +5 -0
- package/src/components/inputs/RadioGroup/style.ts +3 -0
- package/src/components/inputs/Switch/Controlled.tsx +57 -0
- package/src/components/inputs/Switch/Generic.tsx +40 -0
- package/src/components/inputs/Switch/Switch.stories.tsx +89 -0
- package/src/components/inputs/Switch/index.ts +5 -0
- package/src/components/inputs/Switch/style.ts +62 -0
- package/src/components/inputs/TagField/Controlled.tsx +103 -0
- package/src/components/inputs/TagField/Generic.tsx +138 -0
- package/src/components/inputs/TagField/TagField.stories.tsx +68 -0
- package/src/components/inputs/TagField/index.ts +5 -0
- package/src/components/inputs/TagField/style.ts +25 -0
- package/src/components/inputs/TagField/util.ts +34 -0
- package/src/components/inputs/TextAreaField/Controlled.tsx +101 -0
- package/src/components/inputs/TextAreaField/Generic.tsx +58 -0
- package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +99 -0
- package/src/components/inputs/TextAreaField/index.ts +5 -0
- package/src/components/inputs/TextAreaField/style.ts +28 -0
- package/src/components/inputs/TextField/Controlled.tsx +120 -0
- package/src/components/inputs/TextField/Generic.tsx +138 -0
- package/src/components/inputs/TextField/TextField.stories.tsx +217 -0
- package/src/components/inputs/TextField/index.ts +5 -0
- package/src/components/inputs/TextField/style.ts +103 -0
- package/src/components/inputs/TextField/util.ts +24 -0
- package/src/components/inputs/ValueConfirmationField/ValueConfirmationField.stories.tsx +33 -0
- package/src/components/inputs/ValueConfirmationField/index.tsx +54 -0
- package/src/components/inputs/index.ts +72 -0
- package/src/components/inputs/layout/Description.tsx +33 -0
- package/src/components/inputs/layout/ErrorMessage/ErrorMessage.stories.tsx +28 -0
- package/src/components/inputs/layout/ErrorMessage/index.tsx +63 -0
- package/src/components/inputs/layout/InputWrapper.ts +6 -0
- package/src/components/inputs/layout/Label/index.tsx +71 -0
- package/src/components/inputs/layout/Label/style.ts +50 -0
- package/src/components/inputs/layout/index.ts +8 -0
- package/src/components/inputs/layout/setAriaDescribedBy.ts +3 -0
- package/src/components/inputs/selects/SelectField/Controlled.tsx +127 -0
- package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +48 -0
- package/src/components/inputs/selects/SelectField/Generic/index.tsx +299 -0
- package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +252 -0
- package/src/components/inputs/selects/SelectField/index.ts +5 -0
- package/src/components/inputs/selects/SelectField/style.ts +29 -0
- package/src/components/inputs/selects/SelectQueryField/Controlled.tsx +110 -0
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +401 -0
- package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +280 -0
- package/src/components/inputs/selects/SelectQueryField/index.tsx +5 -0
- package/src/components/inputs/selects/SelectQueryField/style.ts +13 -0
- package/src/components/inputs/selects/SubComponents/Option.tsx +114 -0
- package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +18 -0
- package/src/components/inputs/selects/SubComponents/index.ts +10 -0
- package/src/components/inputs/selects/SubComponents/style.ts +51 -0
- package/src/components/inputs/selects/data.ts +123 -0
- package/src/components/inputs/selects/index.tsx +49 -0
- package/src/components/inputs/selects/sharedStyle.ts +76 -0
- package/src/components/layout/Container/index.ts +21 -0
- package/src/components/layout/index.ts +1 -0
- package/src/components/navigation/HorizontalNav/HorizontalNav.stories.tsx +29 -0
- package/src/components/navigation/HorizontalNav/index.tsx +13 -0
- package/src/components/navigation/HorizontalNav/style.ts +93 -0
- package/src/components/navigation/IconNav/IconNav.stories.tsx +46 -0
- package/src/components/navigation/IconNav/index.tsx +50 -0
- package/src/components/navigation/Steppers/SlimStepper/Stepper.stories.tsx +90 -0
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +104 -0
- package/src/components/navigation/Steppers/SlimStepper/style.ts +85 -0
- package/src/components/navigation/Steppers/Stepper/Stepper.stories.tsx +88 -0
- package/src/components/navigation/Steppers/Stepper/index.tsx +114 -0
- package/src/components/navigation/Steppers/Stepper/style.ts +106 -0
- package/src/components/navigation/Steppers/context.tsx +2 -0
- package/src/components/navigation/Steppers/provider.tsx +18 -0
- package/src/components/navigation/Steppers/reducer.ts +51 -0
- package/src/components/navigation/Steppers/stepStates.ts +5 -0
- package/src/components/navigation/Steppers/useStepper.ts +34 -0
- package/src/components/navigation/Tabs/Content.tsx +39 -0
- package/src/components/navigation/Tabs/Context.tsx +21 -0
- package/src/components/navigation/Tabs/List.tsx +17 -0
- package/src/components/navigation/Tabs/Tabs.stories.tsx +119 -0
- package/src/components/navigation/Tabs/Trigger.tsx +66 -0
- package/src/components/navigation/Tabs/index.tsx +35 -0
- package/src/components/navigation/Tabs/useTabs.tsx +28 -0
- package/src/components/navigation/index.ts +17 -0
- package/src/components/other/ActionMenu/ActionMenu.stories.tsx +81 -0
- package/src/components/other/ActionMenu/index.tsx +62 -0
- package/src/components/other/ActionMenu/style.ts +47 -0
- package/src/components/other/ClipBoard/ClipBoard.stories.tsx +14 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx +8 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx.snap +70 -0
- package/src/components/other/ClipBoard/__snapshots__/ClipBoard.test.tsx.snap +36 -0
- package/src/components/other/ClipBoard/index.tsx +70 -0
- package/src/components/other/CollapseList/CollapseList.stories.tsx +21 -0
- package/src/components/other/CollapseList/index.tsx +110 -0
- package/src/components/other/Collapsible/Collapsible.stories.tsx +19 -0
- package/src/components/other/Collapsible/CollapsibleContent.tsx +29 -0
- package/src/components/other/Collapsible/CollapsibleContext.tsx +17 -0
- package/src/components/other/Collapsible/CollapsibleTrigger.tsx +83 -0
- package/src/components/other/Collapsible/index.tsx +21 -0
- package/src/components/other/Company/index.tsx +44 -0
- package/src/components/other/Company/style.ts +58 -0
- package/src/components/other/Empty/Empty.stories.tsx +28 -0
- package/src/components/other/Empty/Empty.test.tsx +10 -0
- package/src/components/other/Empty/Empty.test.tsx.snap +85 -0
- package/src/components/other/Empty/__snapshots__/Empty.test.tsx.snap +21 -0
- package/src/components/other/Empty/index.tsx +85 -0
- package/src/components/other/PermissionsGuard/PermissionsGuard.stories.tsx +55 -0
- package/src/components/other/PermissionsGuard/hasPermissionsHelper.ts +18 -0
- package/src/components/other/PermissionsGuard/index.tsx +27 -0
- package/src/components/other/Plan/Plan.stories.tsx +21 -0
- package/src/components/other/Plan/index.tsx +92 -0
- package/src/components/other/Plan/style.ts +61 -0
- package/src/components/other/Usage/Usage.stories.tsx +21 -0
- package/src/components/other/Usage/Usage.tsx +35 -0
- package/src/components/other/Usage/UsageCard.stories.tsx +31 -0
- package/src/components/other/Usage/UsageCard.tsx +88 -0
- package/src/components/other/index.ts +27 -0
- package/src/components/visual/Card/Card.stories.tsx +22 -0
- package/src/components/visual/Card/CardBody.tsx +11 -0
- package/src/components/visual/Card/CardTitle.tsx +29 -0
- package/src/components/visual/Card/index.tsx +58 -0
- package/src/components/visual/Divider/Divider.stories.tsx +19 -0
- package/src/components/visual/Divider/Divider.test.tsx +8 -0
- package/src/components/visual/Divider/Divider.test.tsx.snap +35 -0
- package/src/components/visual/Divider/__snapshots__/Divider.test.tsx.snap +13 -0
- package/src/components/visual/Divider/index.tsx +88 -0
- package/src/components/visual/Flag/index.tsx +61 -0
- package/src/components/visual/index.ts +8 -0
- package/src/errors/base.ts +14 -0
- package/src/errors/errors.ts +126 -0
- package/src/errors/index.ts +14 -0
- package/src/helpers/camelCaseToSpaces.ts +5 -0
- package/src/helpers/formatNumber.ts +6 -0
- package/src/helpers/getInitials.ts +16 -0
- package/src/helpers/getSnackbarProvider.tsx +57 -0
- package/src/helpers/getTransition.ts +9 -0
- package/src/helpers/index.ts +6 -0
- package/src/helpers/makeData.ts +34 -0
- package/src/helpers/regexprs.ts +9 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useCallbackRef.tsx +17 -0
- package/src/hooks/useDebounce.tsx +22 -0
- package/src/hooks/useFocus.tsx +12 -0
- package/src/hooks/useLocalStorage.tsx +35 -0
- package/src/hooks/useLockScroll.ts +26 -0
- package/src/hooks/useOnScreen.ts +24 -0
- package/src/hooks/useOutsideAlerter.tsx +15 -0
- package/src/hooks/useTableActions.ts +61 -0
- package/src/hooks/useTheme.tsx +7 -0
- package/src/images/company-icon-primary.svg +3 -0
- package/src/images/company-icon-secondary.svg +3 -0
- package/src/images/index.ts +4 -0
- package/src/index.ts +9 -0
- package/src/stories/Colors.mdx +35 -0
- package/src/stories/Introduction.mdx +17 -0
- package/src/stories/Spacing.mdx +25 -0
- package/src/styled/GlobalStyle.ts +209 -0
- package/src/styled/Snackbar.tsx +41 -0
- package/src/styled/animations.ts +36 -0
- package/src/styled/breakpoint.ts +7 -0
- package/src/styled/device.ts +10 -0
- package/src/styled/index.ts +10 -0
- package/src/styled/spacing.ts +38 -0
- package/src/styled/theme.tsx +110 -0
- package/src/styled/types.ts +5 -0
- package/src/styled/zIndex.ts +31 -0
- package/src/test/__mocks__/fileMock.ts +2 -0
- package/src/test/setupTests.ts +3 -0
- package/src/test/snapshotResolver.js +21 -0
- package/src/test/testUtils.tsx +34 -0
- package/src/types/index.ts +1 -0
- package/src/types/json.ts +5 -0
- package/src/views/LoadingPage.tsx +36 -0
- package/src/views/index.ts +1 -0
- package/tsconfig.json +14 -0
- package/vite.config.mts +17 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Card, CardProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Layout/Card',
|
|
7
|
+
component: Card,
|
|
8
|
+
args: {
|
|
9
|
+
variant: 'default',
|
|
10
|
+
},
|
|
11
|
+
} as Meta<CardProps>;
|
|
12
|
+
|
|
13
|
+
export const Default: StoryFn<CardProps> = (args) => {
|
|
14
|
+
return (
|
|
15
|
+
<Card variant={args.variant} onClick={() => {}}>
|
|
16
|
+
<Card.Title label="This is the title">
|
|
17
|
+
<span>Here we can put logic that goes on the right side</span>
|
|
18
|
+
</Card.Title>
|
|
19
|
+
<Card.Body>this is the body</Card.Body>
|
|
20
|
+
</Card>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
|
|
4
|
+
const Container = styled.div`
|
|
5
|
+
padding: ${({ theme }) => theme.spacing[2]};
|
|
6
|
+
min-width: 20rem;
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
export const CardBody: FC<PropsWithChildren> = (props) => {
|
|
10
|
+
return <Container>{props.children}</Container>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
|
|
4
|
+
const Container = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
justify-content: space-between;
|
|
7
|
+
align-items: center;
|
|
8
|
+
border-bottom: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
9
|
+
padding: ${({ theme }) => theme.spacing[1]};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
const Inner = styled.div`
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: ${({ theme }) => theme.spacing['0_5']};
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
interface CardTitleProps {
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const CardTitle: FC<PropsWithChildren<CardTitleProps>> = (props) => {
|
|
23
|
+
return (
|
|
24
|
+
<Container>
|
|
25
|
+
<h2>{props.label}</h2>
|
|
26
|
+
<Inner>{props.children}</Inner>
|
|
27
|
+
</Container>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { forwardRef, HTMLProps, PropsWithChildren } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
import { CardTitle } from './CardTitle';
|
|
4
|
+
import { CardBody } from './CardBody';
|
|
5
|
+
|
|
6
|
+
type Variant = 'default' | 'outline';
|
|
7
|
+
|
|
8
|
+
const Container = styled.div<{ canClick: boolean; variant: Variant }>`
|
|
9
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
10
|
+
background-color: ${({ theme, variant }) =>
|
|
11
|
+
variant === 'outline' ? theme.colors.background : theme.colors.backgroundAlt};
|
|
12
|
+
border: 0.1rem solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
13
|
+
cursor: ${({ canClick }) => (canClick ? 'pointer' : 'default')};
|
|
14
|
+
height: fit-content;
|
|
15
|
+
|
|
16
|
+
&:focus {
|
|
17
|
+
border-color: ${({ theme, canClick }) => (canClick ? theme.colors.primary : theme.colors.backgroundAccent)};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&:active {
|
|
21
|
+
border-color: ${({ theme, canClick }) => (canClick ? theme.colors.primary : theme.colors.backgroundAccent)};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
overflow: hidden; /* Ensure the container hides content overflow */
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
// Extend HTMLProps for standard HTML attributes and add custom props
|
|
28
|
+
export interface CardProps extends HTMLProps<HTMLDivElement> {
|
|
29
|
+
variant?: Variant;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface SubComponentTypes {
|
|
33
|
+
Title: typeof CardTitle;
|
|
34
|
+
Body: typeof CardBody;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const _Card = forwardRef<HTMLDivElement, PropsWithChildren<CardProps>>(function Card(
|
|
38
|
+
{ children, variant = 'default', ...props },
|
|
39
|
+
ref,
|
|
40
|
+
) {
|
|
41
|
+
const canClick = 'onClick' in props;
|
|
42
|
+
const { className, ...restProps } = props;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
<Container ref={ref} canClick={canClick} variant={variant} className={className} {...restProps}>
|
|
48
|
+
{children}
|
|
49
|
+
</Container>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// TODO: type it correctly instead
|
|
54
|
+
type CardType = typeof _Card & SubComponentTypes;
|
|
55
|
+
export const Card = _Card as CardType;
|
|
56
|
+
|
|
57
|
+
Card.Title = CardTitle;
|
|
58
|
+
Card.Body = CardBody;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Divider, DividerProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Layout/Divider',
|
|
7
|
+
component: Divider,
|
|
8
|
+
args: {
|
|
9
|
+
label: { text: 'label', labelPosition: 'center' },
|
|
10
|
+
},
|
|
11
|
+
} as Meta<DividerProps>;
|
|
12
|
+
|
|
13
|
+
export const Default: StoryFn<DividerProps> = (args) => (
|
|
14
|
+
<div>
|
|
15
|
+
<div>this is the content above</div>
|
|
16
|
+
<Divider {...args} />
|
|
17
|
+
<div> this is the content after</div>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Accordion /> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
position: relative;
|
|
6
|
+
display: -webkit-box;
|
|
7
|
+
display: -webkit-flex;
|
|
8
|
+
display: -ms-flexbox;
|
|
9
|
+
display: flex;
|
|
10
|
+
-webkit-align-items: center;
|
|
11
|
+
-webkit-box-align: center;
|
|
12
|
+
-ms-flex-align: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
width: 70%;
|
|
15
|
+
margin: 1rem auto 1rem auto;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.c1 {
|
|
19
|
+
width: 100%;
|
|
20
|
+
height: 1px;
|
|
21
|
+
background-color: #d3d3d3;
|
|
22
|
+
z-index: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
<div>
|
|
26
|
+
<div
|
|
27
|
+
class="c0"
|
|
28
|
+
spacing="medium"
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
class="c1"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
`;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Color, Size, styled } from '../../../styled';
|
|
3
|
+
|
|
4
|
+
const Container = styled.div<{ size: Size; fullWidth: boolean }>`
|
|
5
|
+
position: relative;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
width: ${({ fullWidth }) => (fullWidth ? '100%' : '70%')};
|
|
9
|
+
|
|
10
|
+
${({ size, theme }) => {
|
|
11
|
+
switch (size) {
|
|
12
|
+
case 'tiny':
|
|
13
|
+
return `margin: ${theme.spacing['0_25']} auto ${theme.spacing['0_25']} auto`;
|
|
14
|
+
case 'small':
|
|
15
|
+
return `margin: ${theme.spacing['0_5']} auto ${theme.spacing['0_5']} auto`;
|
|
16
|
+
case 'medium':
|
|
17
|
+
return `margin: ${theme.spacing['0_75']} auto ${theme.spacing['0_75']} auto`;
|
|
18
|
+
case 'large':
|
|
19
|
+
return `margin: ${theme.spacing['2_5']} auto ${theme.spacing['2_5']} auto`;
|
|
20
|
+
case 'huge':
|
|
21
|
+
return `margin: ${theme.spacing[6]} auto ${theme.spacing[6]} auto`;
|
|
22
|
+
}
|
|
23
|
+
}}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const Label = styled.label<{
|
|
27
|
+
position: 'left' | 'center' | 'right';
|
|
28
|
+
color: Color | 'text' | 'textAlt';
|
|
29
|
+
}>`
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 50%;
|
|
32
|
+
transform: translateY(-50%) translateX(-50%);
|
|
33
|
+
p {
|
|
34
|
+
color: ${({ theme, color }) => theme.colors[color]};
|
|
35
|
+
background-color: ${({ theme }) => theme.colors.backgroundAlt};
|
|
36
|
+
font-size: 1.325rem;
|
|
37
|
+
font-weight: 500;
|
|
38
|
+
padding: ${({ theme }) => `0 ${theme.spacing['0_5']}`};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
${({ position }) => {
|
|
42
|
+
switch (position) {
|
|
43
|
+
case 'left':
|
|
44
|
+
return `
|
|
45
|
+
left: 0;
|
|
46
|
+
`;
|
|
47
|
+
case 'center':
|
|
48
|
+
return `
|
|
49
|
+
left: 50%;
|
|
50
|
+
`;
|
|
51
|
+
case 'right':
|
|
52
|
+
return `
|
|
53
|
+
right: 0
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
}}
|
|
57
|
+
`;
|
|
58
|
+
const Line = styled.div`
|
|
59
|
+
width: 100%;
|
|
60
|
+
height: 1px;
|
|
61
|
+
background-color: ${({ theme }) => theme.colors.backgroundAccent};
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
type LabelProps = {
|
|
65
|
+
text: string;
|
|
66
|
+
labelPosition: 'left' | 'center' | 'right';
|
|
67
|
+
color?: Color | 'text' | 'textAlt';
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export interface DividerProps {
|
|
71
|
+
label?: LabelProps;
|
|
72
|
+
size?: Size;
|
|
73
|
+
fullWidth?: boolean;
|
|
74
|
+
/* TODO: reimplement sizing (this might go automatically with different density options. */
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const Divider: FC<DividerProps> = ({ label, size = 'medium', fullWidth = false }) => {
|
|
78
|
+
return (
|
|
79
|
+
<Container fullWidth={fullWidth} size={size}>
|
|
80
|
+
<Line />
|
|
81
|
+
{label && (
|
|
82
|
+
<Label position={label.labelPosition} color={label.color ? label.color : 'textAlt'}>
|
|
83
|
+
<p>{label.text}</p>
|
|
84
|
+
</Label>
|
|
85
|
+
)}
|
|
86
|
+
</Container>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { styled } from '../../../styled';
|
|
2
|
+
import { FC, ImgHTMLAttributes, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
const FlagImg = styled.img`
|
|
5
|
+
width: 1rem;
|
|
6
|
+
height: 1rem;
|
|
7
|
+
object-fit: cover;
|
|
8
|
+
border-radius: 2px;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const FallbackContainer = styled.div<{ size: number }>`
|
|
12
|
+
width: ${({ size }) => `${size}rem`};
|
|
13
|
+
height: ${({ size }) => `${size}rem`};
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
background-color: ${({ theme }) => theme.colors.backgroundAlt};
|
|
18
|
+
border-radius: 2px;
|
|
19
|
+
font-size: ${({ size }) => `${size * 0.5}rem`};
|
|
20
|
+
color: ${({ theme }) => theme.colors.textAlt};
|
|
21
|
+
font-weight: 600;
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
export interface FlagProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt'> {
|
|
25
|
+
/** 2-letter ISO country code (e.g., 'US', 'FR', 'JP') */
|
|
26
|
+
countryCode: string;
|
|
27
|
+
/** Optional country name for better accessibility */
|
|
28
|
+
countryName?: string;
|
|
29
|
+
/** Size of the flag in rem units */
|
|
30
|
+
size?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const Flag: FC<FlagProps> = ({ countryCode, countryName, size = 1, style, ...props }) => {
|
|
34
|
+
const [imageError, setImageError] = useState(false);
|
|
35
|
+
|
|
36
|
+
if (!countryCode || countryCode.length !== 2) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const uppercaseCode = countryCode.toUpperCase();
|
|
41
|
+
const flagUrl = `https://purecatamphetamine.github.io/country-flag-icons/3x2/${uppercaseCode}.svg`;
|
|
42
|
+
const altText = countryName ? `Flag of ${countryName}` : `Flag of ${uppercaseCode}`;
|
|
43
|
+
|
|
44
|
+
if (imageError) {
|
|
45
|
+
return <FallbackContainer size={size}>{uppercaseCode}</FallbackContainer>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<FlagImg
|
|
50
|
+
src={flagUrl}
|
|
51
|
+
alt={altText}
|
|
52
|
+
onError={() => setImageError(true)}
|
|
53
|
+
style={{
|
|
54
|
+
width: `${size}rem`,
|
|
55
|
+
height: `${size}rem`,
|
|
56
|
+
...style,
|
|
57
|
+
}}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface IErrorOptions {
|
|
2
|
+
meta: unknown;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export class BaseError extends Error {
|
|
6
|
+
constructor(
|
|
7
|
+
public message: string,
|
|
8
|
+
protected options?: Partial<IErrorOptions>,
|
|
9
|
+
) {
|
|
10
|
+
super(message);
|
|
11
|
+
// Ensure the name of this error is the same as the class name
|
|
12
|
+
this.name = this.constructor.name;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { BaseError } from './base';
|
|
3
|
+
import * as Sentry from '@sentry/react';
|
|
4
|
+
import { ValidationError } from 'class-validator';
|
|
5
|
+
|
|
6
|
+
// Define a type for the error message mapping
|
|
7
|
+
export interface ErrorMessageMapping {
|
|
8
|
+
UniqueConstraintError: string;
|
|
9
|
+
ResponseValidationError: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getErrorUserMessage(
|
|
13
|
+
apiError: AxiosError<any> | null,
|
|
14
|
+
errorMessages: Partial<ErrorMessageMapping>,
|
|
15
|
+
): string | string[] | null {
|
|
16
|
+
const defaultMesssage = 'An error occurred. Please try again later.';
|
|
17
|
+
|
|
18
|
+
// If there is no error, return null
|
|
19
|
+
if (apiError === null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const err = transformError(apiError);
|
|
24
|
+
|
|
25
|
+
if (!err) {
|
|
26
|
+
Sentry.captureException(apiError);
|
|
27
|
+
return defaultMesssage;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (err instanceof NotAuthorizedError) {
|
|
31
|
+
return 'You are not authorized to perform this action';
|
|
32
|
+
}
|
|
33
|
+
if (err instanceof ResponseValidationError) {
|
|
34
|
+
return err.parseValidationError();
|
|
35
|
+
}
|
|
36
|
+
if (err instanceof BadRequestError) {
|
|
37
|
+
return err.message;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (err instanceof UniqueConstraintError) {
|
|
41
|
+
if (err.message === 'Unique constraint violation') {
|
|
42
|
+
const messageType = err.constructor.name as keyof ErrorMessageMapping;
|
|
43
|
+
return errorMessages[messageType] || err.message;
|
|
44
|
+
} else {
|
|
45
|
+
return err.message;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return defaultMesssage;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function transformError(apiError: AxiosError<any>) {
|
|
52
|
+
const error = apiError.response?.data.meta.error;
|
|
53
|
+
|
|
54
|
+
if (!error) {
|
|
55
|
+
Sentry.captureException(apiError);
|
|
56
|
+
}
|
|
57
|
+
if (error.code === 'ForbiddenError') {
|
|
58
|
+
return new NotAuthorizedError('Not authorized');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (error.code === 'ConflictError') {
|
|
62
|
+
return new UniqueConstraintError(error.message);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (error.code === 'BadRequestError') {
|
|
66
|
+
return new BadRequestError(error.message);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (error.code === 'ValidationError') {
|
|
70
|
+
return new ResponseValidationError('Validation error', error.details);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class ResponseValidationError extends BaseError {
|
|
75
|
+
constructor(
|
|
76
|
+
message: string,
|
|
77
|
+
public validationErrors: ValidationError[],
|
|
78
|
+
) {
|
|
79
|
+
super(message, { meta: { validationErrors } });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
parseValidationError(): string[] {
|
|
83
|
+
const errorMessages: string[] = [];
|
|
84
|
+
function extractErrors(validationError: ValidationError) {
|
|
85
|
+
if (validationError.constraints) {
|
|
86
|
+
for (const constraint in validationError.constraints) {
|
|
87
|
+
errorMessages.push(validationError.constraints[constraint]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (validationError.children) {
|
|
92
|
+
for (const child of validationError.children) {
|
|
93
|
+
extractErrors(child);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
for (const detail of this.validationErrors) {
|
|
99
|
+
extractErrors(detail);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return errorMessages;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export class InternalServerError extends BaseError {
|
|
107
|
+
constructor() {
|
|
108
|
+
super('Internal server error');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class UniqueConstraintError extends BaseError {
|
|
113
|
+
constructor(message: string) {
|
|
114
|
+
super(message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class BadRequestError extends BaseError {
|
|
119
|
+
constructor(message: string) {
|
|
120
|
+
super(message);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export class ResponseClientError extends BaseError {}
|
|
125
|
+
export class FailedLogOutError extends BaseError {}
|
|
126
|
+
export class NotAuthorizedError extends BaseError {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {
|
|
2
|
+
InternalServerError,
|
|
3
|
+
ResponseClientError,
|
|
4
|
+
ResponseValidationError,
|
|
5
|
+
FailedLogOutError,
|
|
6
|
+
NotAuthorizedError,
|
|
7
|
+
UniqueConstraintError,
|
|
8
|
+
transformError as defineErrorType,
|
|
9
|
+
getErrorUserMessage,
|
|
10
|
+
} from './errors';
|
|
11
|
+
|
|
12
|
+
export type { ErrorMessageMapping } from './errors';
|
|
13
|
+
|
|
14
|
+
export { BaseError } from './base';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// TODO: add custom replace option
|
|
2
|
+
export function getInitials(name: string) {
|
|
3
|
+
if (!name) return '?';
|
|
4
|
+
const replacedName = name.replace(/[._]/g, ' ');
|
|
5
|
+
const parts = replacedName.split(' ');
|
|
6
|
+
|
|
7
|
+
if (parts.length === 1) {
|
|
8
|
+
return parts[0].slice(0, 1);
|
|
9
|
+
}
|
|
10
|
+
if (parts.length === 2) {
|
|
11
|
+
return parts[0].slice(0, 1) + parts[1].slice(0, 1);
|
|
12
|
+
}
|
|
13
|
+
if (parts.length > 2) {
|
|
14
|
+
return parts[0].slice(0, 1) + parts[1].slice(0, 1) + parts[2].slice(0, 1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { FC, PropsWithChildren, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { SnackbarProvider as Provider, SnackbarProviderProps } from 'notistack';
|
|
3
|
+
import {
|
|
4
|
+
DefaultSnack,
|
|
5
|
+
DrawerSnack,
|
|
6
|
+
NetworkDetectorOnlineSnack,
|
|
7
|
+
NetworkDetectorOfflineSnack,
|
|
8
|
+
CookieConsentSnack,
|
|
9
|
+
} from '../components/feedback/snacks';
|
|
10
|
+
|
|
11
|
+
import { ButtonProps } from '../components';
|
|
12
|
+
import { AlertVariants } from '../styled';
|
|
13
|
+
|
|
14
|
+
const snackbarOptions: Partial<SnackbarProviderProps> = {
|
|
15
|
+
anchorOrigin: {
|
|
16
|
+
horizontal: 'right',
|
|
17
|
+
vertical: 'bottom',
|
|
18
|
+
},
|
|
19
|
+
autoHideDuration: 4000,
|
|
20
|
+
hideIconVariant: true,
|
|
21
|
+
maxSnack: 3,
|
|
22
|
+
preventDuplicate: true,
|
|
23
|
+
Components: {
|
|
24
|
+
default: DefaultSnack,
|
|
25
|
+
drawer: DrawerSnack,
|
|
26
|
+
cookieConsent: CookieConsentSnack,
|
|
27
|
+
networkDetectorOffline: NetworkDetectorOfflineSnack,
|
|
28
|
+
networkDetectorOnline: NetworkDetectorOnlineSnack,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const SnackbarProvider: FC<PropsWithChildren<unknown>> = ({ children }) => (
|
|
33
|
+
<Provider {...snackbarOptions}>{children}</Provider>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
declare module 'notistack' {
|
|
37
|
+
interface VariantOverrides {
|
|
38
|
+
/* IMPORTANT: These props need to be kept in sync with the props defined in helpers/getSnackbarProvider */
|
|
39
|
+
default: {
|
|
40
|
+
title?: string;
|
|
41
|
+
button1?: ReactElement<ButtonProps>;
|
|
42
|
+
button2?: ReactElement<ButtonProps>;
|
|
43
|
+
type?: AlertVariants;
|
|
44
|
+
icon?: ReactElement;
|
|
45
|
+
};
|
|
46
|
+
drawer: {
|
|
47
|
+
children: ReactNode | ReactNode[];
|
|
48
|
+
};
|
|
49
|
+
cookieConsent: true;
|
|
50
|
+
networkDetectorOffline: true;
|
|
51
|
+
networkDetectorOnline: true;
|
|
52
|
+
info: false;
|
|
53
|
+
error: false;
|
|
54
|
+
success: false;
|
|
55
|
+
warning: false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getInitials } from './getInitials';
|
|
2
|
+
export { SnackbarProvider } from './getSnackbarProvider';
|
|
3
|
+
export * from './regexprs';
|
|
4
|
+
export { getTransition } from './getTransition';
|
|
5
|
+
export { camelCaseToSpaces } from './camelCaseToSpaces';
|
|
6
|
+
export { formatNumber } from './formatNumber';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
|
|
3
|
+
const range = (len: number) => {
|
|
4
|
+
const arr = [];
|
|
5
|
+
for (let i = 0; i < len; i++) {
|
|
6
|
+
arr.push(i);
|
|
7
|
+
}
|
|
8
|
+
return arr;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const newPerson = () => {
|
|
12
|
+
const statusChance = Math.random();
|
|
13
|
+
return {
|
|
14
|
+
firstName: faker.person.firstName(),
|
|
15
|
+
lastName: faker.person.lastName(),
|
|
16
|
+
age: Math.floor(Math.random() * 30),
|
|
17
|
+
visits: Math.floor(Math.random() * 100),
|
|
18
|
+
progress: Math.floor(Math.random() * 100),
|
|
19
|
+
status: statusChance > 0.66 ? 'relationship' : statusChance > 0.33 ? 'complicated' : 'single',
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function makeData(...lens: number[]) {
|
|
24
|
+
const makeDataLevel: any = (depth = 0) => {
|
|
25
|
+
const len = lens[depth];
|
|
26
|
+
return range(len).map(() => {
|
|
27
|
+
return {
|
|
28
|
+
...newPerson(),
|
|
29
|
+
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
return makeDataLevel();
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const REGEXPR_STEAM_API_KEY = /\w{32}/;
|
|
2
|
+
export const IPV4_REGEX = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/;
|
|
3
|
+
export const IPV4_AND_PORT_REGEX =
|
|
4
|
+
/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):([0-9]{1,5})\b/;
|
|
5
|
+
export const FQDN_AND_PORT_REGEX =
|
|
6
|
+
/^(?=.{4,253}(?::\d{1,5})?$)((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}(?::\d{1,5})?$/;
|
|
7
|
+
|
|
8
|
+
export const IPV6_REGEX =
|
|
9
|
+
/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { useLockBodyScroll, useLockRefScroll } from './useLockScroll';
|
|
2
|
+
export { useOutsideAlerter } from './useOutsideAlerter';
|
|
3
|
+
export { useDebounce } from './useDebounce';
|
|
4
|
+
export { useOnScreen } from './useOnScreen';
|
|
5
|
+
export { useLocalStorage } from './useLocalStorage';
|
|
6
|
+
export { useTheme } from './useTheme';
|
|
7
|
+
export { useTableActions } from './useTableActions';
|
|
8
|
+
export { useCallbackRef } from './useCallbackRef';
|
|
9
|
+
export { useFocus } from './useFocus';
|