@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,231 @@
|
|
|
1
|
+
import { MouseEvent, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import { ParentSize } from '@visx/responsive';
|
|
4
|
+
import { Group } from '@visx/group';
|
|
5
|
+
import { LineRadial } from '@visx/shape';
|
|
6
|
+
import { scaleTime, scaleLog, NumberLike } from '@visx/scale';
|
|
7
|
+
import { GridAngle, GridRadial } from '@visx/grid';
|
|
8
|
+
import { AxisLeft } from '@visx/axis';
|
|
9
|
+
import { motion } from 'framer-motion';
|
|
10
|
+
import { extent } from '@visx/vendor/d3-array';
|
|
11
|
+
import { curveBasisOpen } from '@visx/curve';
|
|
12
|
+
import { useTooltipInPortal, useTooltip } from '@visx/tooltip';
|
|
13
|
+
import { localPoint } from '@visx/event';
|
|
14
|
+
|
|
15
|
+
import { InnerChartProps, getDefaultTooltipStyles, TooltipConfig, ChartProps } from '../util';
|
|
16
|
+
import { useTheme } from '../../../hooks';
|
|
17
|
+
import { useGradients } from '../useGradients';
|
|
18
|
+
import { EmptyChart } from '../EmptyChart';
|
|
19
|
+
|
|
20
|
+
const formatTicks = (val: NumberLike) => String(val);
|
|
21
|
+
|
|
22
|
+
export interface RadialLineChartProps<T> extends ChartProps {
|
|
23
|
+
data: T[];
|
|
24
|
+
xAccessor: (d: T) => number;
|
|
25
|
+
yAccessor: (d: T) => number;
|
|
26
|
+
/** Tooltip configuration */
|
|
27
|
+
tooltip?: TooltipConfig<T>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const defaultMargin = { top: 10, right: 0, bottom: 25, left: 40 };
|
|
31
|
+
export const RadialLineChart = <T,>({
|
|
32
|
+
data,
|
|
33
|
+
yAccessor,
|
|
34
|
+
xAccessor,
|
|
35
|
+
name,
|
|
36
|
+
margin = defaultMargin,
|
|
37
|
+
animate = true,
|
|
38
|
+
tooltip,
|
|
39
|
+
}: RadialLineChartProps<T>) => {
|
|
40
|
+
const hasData = data && data.length > 0;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<ParentSize>
|
|
45
|
+
{hasData
|
|
46
|
+
? (parent) => (
|
|
47
|
+
<Chart<T>
|
|
48
|
+
name={name}
|
|
49
|
+
data={data}
|
|
50
|
+
width={parent.width}
|
|
51
|
+
height={parent.height}
|
|
52
|
+
margin={margin}
|
|
53
|
+
yAccessor={yAccessor}
|
|
54
|
+
xAccessor={xAccessor}
|
|
55
|
+
tooltip={tooltip}
|
|
56
|
+
animate={animate}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
: () => <EmptyChart />}
|
|
60
|
+
</ParentSize>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type InnerRadialLineChartProps<T> = InnerChartProps & RadialLineChartProps<T>;
|
|
66
|
+
|
|
67
|
+
const Chart = <T,>({
|
|
68
|
+
width,
|
|
69
|
+
xAccessor,
|
|
70
|
+
yAccessor,
|
|
71
|
+
data,
|
|
72
|
+
name,
|
|
73
|
+
height,
|
|
74
|
+
tooltip,
|
|
75
|
+
animate = true,
|
|
76
|
+
}: InnerRadialLineChartProps<T>) => {
|
|
77
|
+
const tooltipAccessor = tooltip?.accessor;
|
|
78
|
+
const theme = useTheme();
|
|
79
|
+
const gradients = useGradients(name);
|
|
80
|
+
|
|
81
|
+
const { tooltipData, tooltipLeft, tooltipTop, tooltipOpen, hideTooltip, showTooltip } = useTooltip<T>();
|
|
82
|
+
const { containerRef, TooltipInPortal } = useTooltipInPortal({
|
|
83
|
+
detectBounds: true,
|
|
84
|
+
scroll: true,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const xScale = scaleTime<number>({
|
|
88
|
+
range: [0, Math.PI * 2],
|
|
89
|
+
domain: extent(data, xAccessor) as [number, number],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const yScale = scaleLog<number>({
|
|
93
|
+
domain: extent(data, yAccessor) as [number, number],
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const angle = (d: T) => xScale(xAccessor(d)) ?? 0;
|
|
97
|
+
const radius = (d: T) => yScale(yAccessor(d)) ?? 0;
|
|
98
|
+
const padding = 15;
|
|
99
|
+
|
|
100
|
+
const handleMouseOver = useCallback(
|
|
101
|
+
(event: MouseEvent, dataPoint: T) => {
|
|
102
|
+
if (!tooltipAccessor) return;
|
|
103
|
+
|
|
104
|
+
const target = event.target as SVGElement;
|
|
105
|
+
const coords = localPoint(target.ownerSVGElement!, event);
|
|
106
|
+
|
|
107
|
+
showTooltip({
|
|
108
|
+
tooltipLeft: coords?.x,
|
|
109
|
+
tooltipTop: coords?.y,
|
|
110
|
+
tooltipData: dataPoint,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
[tooltipAccessor, showTooltip],
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// Update scale output to match component dimensions
|
|
117
|
+
yScale.range([0, height / 2 - padding]);
|
|
118
|
+
const reverseYScale = yScale.copy().range(yScale.range().reverse());
|
|
119
|
+
|
|
120
|
+
return width < 10 ? null : (
|
|
121
|
+
<svg ref={containerRef} width={width} height={height}>
|
|
122
|
+
{gradients.chart.gradient}
|
|
123
|
+
<rect width={width} height={height} fill={theme.colors.background} rx={14} />
|
|
124
|
+
<Group top={height / 2} left={width / 2}>
|
|
125
|
+
<GridAngle
|
|
126
|
+
scale={xScale}
|
|
127
|
+
outerRadius={height / 2 - padding}
|
|
128
|
+
stroke={theme.colors.backgroundAccent}
|
|
129
|
+
strokeWidth={1}
|
|
130
|
+
strokeOpacity={0.3}
|
|
131
|
+
strokeDasharray="5,2"
|
|
132
|
+
numTicks={20}
|
|
133
|
+
/>
|
|
134
|
+
<GridRadial
|
|
135
|
+
scale={yScale}
|
|
136
|
+
numTicks={5}
|
|
137
|
+
stroke={theme.colors.backgroundAccent}
|
|
138
|
+
strokeWidth={1}
|
|
139
|
+
fill={theme.colors.backgroundAccent}
|
|
140
|
+
fillOpacity={0.1}
|
|
141
|
+
strokeOpacity={0.2}
|
|
142
|
+
/>
|
|
143
|
+
<AxisLeft
|
|
144
|
+
top={-height / 2 + padding}
|
|
145
|
+
scale={reverseYScale}
|
|
146
|
+
numTicks={5}
|
|
147
|
+
tickStroke="none"
|
|
148
|
+
tickLabelProps={{
|
|
149
|
+
fontSize: 8,
|
|
150
|
+
fill: theme.colors.text,
|
|
151
|
+
fillOpacity: 1,
|
|
152
|
+
textAnchor: 'middle',
|
|
153
|
+
dx: '1em',
|
|
154
|
+
dy: '-0.5em',
|
|
155
|
+
paintOrder: 'stroke',
|
|
156
|
+
}}
|
|
157
|
+
tickFormat={formatTicks}
|
|
158
|
+
hideAxisLine
|
|
159
|
+
/>
|
|
160
|
+
<LineRadial<T> angle={angle} radius={radius} curve={curveBasisOpen}>
|
|
161
|
+
{({ path }) => {
|
|
162
|
+
const d = path(data) || '';
|
|
163
|
+
return (
|
|
164
|
+
<motion.path
|
|
165
|
+
d={d}
|
|
166
|
+
strokeWidth={3}
|
|
167
|
+
strokeOpacity={0.8}
|
|
168
|
+
strokeLinecap="round"
|
|
169
|
+
fill="none"
|
|
170
|
+
stroke={theme.colors.primary}
|
|
171
|
+
initial={animate ? { pathLength: 0 } : { pathLength: 1 }}
|
|
172
|
+
animate={{ pathLength: 1 }}
|
|
173
|
+
transition={
|
|
174
|
+
animate
|
|
175
|
+
? {
|
|
176
|
+
duration: 1.5,
|
|
177
|
+
ease: 'easeInOut',
|
|
178
|
+
}
|
|
179
|
+
: { duration: 0 }
|
|
180
|
+
}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
}}
|
|
184
|
+
</LineRadial>
|
|
185
|
+
{tooltipAccessor &&
|
|
186
|
+
data.map((d, i) => {
|
|
187
|
+
const angleVal = angle(d);
|
|
188
|
+
const radiusVal = radius(d);
|
|
189
|
+
const x = Math.cos(angleVal - Math.PI / 2) * radiusVal;
|
|
190
|
+
const y = Math.sin(angleVal - Math.PI / 2) * radiusVal;
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<g key={`data-point-${i}`}>
|
|
194
|
+
{/* Invisible hit area for tooltip - no need for visible dots */}
|
|
195
|
+
<motion.circle
|
|
196
|
+
cx={x}
|
|
197
|
+
cy={y}
|
|
198
|
+
r={12}
|
|
199
|
+
fill="transparent"
|
|
200
|
+
style={{ cursor: 'pointer' }}
|
|
201
|
+
onMouseOut={hideTooltip}
|
|
202
|
+
onMouseOver={(e) => handleMouseOver(e, d)}
|
|
203
|
+
initial={animate ? { scale: 0 } : { scale: 1 }}
|
|
204
|
+
animate={{ scale: 1 }}
|
|
205
|
+
transition={
|
|
206
|
+
animate
|
|
207
|
+
? {
|
|
208
|
+
duration: 0.3,
|
|
209
|
+
delay: 1.5,
|
|
210
|
+
ease: 'easeOut',
|
|
211
|
+
}
|
|
212
|
+
: { duration: 0 }
|
|
213
|
+
}
|
|
214
|
+
/>
|
|
215
|
+
</g>
|
|
216
|
+
);
|
|
217
|
+
})}
|
|
218
|
+
</Group>
|
|
219
|
+
{tooltipOpen && tooltipData && tooltipAccessor && (
|
|
220
|
+
<TooltipInPortal
|
|
221
|
+
key={`tooltip-${name}`}
|
|
222
|
+
top={tooltipTop}
|
|
223
|
+
left={tooltipLeft}
|
|
224
|
+
style={getDefaultTooltipStyles(theme)}
|
|
225
|
+
>
|
|
226
|
+
{tooltipAccessor(tooltipData)}
|
|
227
|
+
</TooltipInPortal>
|
|
228
|
+
)}
|
|
229
|
+
</svg>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ProvidedZoom } from '@visx/zoom/lib/types';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { styled } from '../../styled';
|
|
4
|
+
import { Button, IconButton, Tooltip } from '../../components';
|
|
5
|
+
import { AiOutlinePlus as ZoomInIcon, AiOutlineMinus as ZoomOutIcon } from 'react-icons/ai';
|
|
6
|
+
|
|
7
|
+
const Controls = styled.div`
|
|
8
|
+
position: absolute;
|
|
9
|
+
bottom: 2rem;
|
|
10
|
+
right: 3rem;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: flex-end;
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
interface ZoomControlsProps {
|
|
17
|
+
zoom: ProvidedZoom<SVGSVGElement>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ZoomControls: FC<ZoomControlsProps> = ({ zoom }) => {
|
|
21
|
+
return (
|
|
22
|
+
<Controls>
|
|
23
|
+
<Tooltip placement="left">
|
|
24
|
+
<Tooltip.Trigger asChild>
|
|
25
|
+
<IconButton
|
|
26
|
+
icon={<ZoomInIcon />}
|
|
27
|
+
ariaLabel="zoom in"
|
|
28
|
+
onClick={() => zoom.scale({ scaleX: 1.2, scaleY: 1.2 })}
|
|
29
|
+
/>
|
|
30
|
+
</Tooltip.Trigger>
|
|
31
|
+
<Tooltip.Content>Zoom in</Tooltip.Content>
|
|
32
|
+
</Tooltip>
|
|
33
|
+
<Tooltip placement="left">
|
|
34
|
+
<Tooltip.Trigger asChild>
|
|
35
|
+
<IconButton
|
|
36
|
+
icon={<ZoomOutIcon />}
|
|
37
|
+
ariaLabel="zoom in"
|
|
38
|
+
onClick={() => zoom.scale({ scaleX: 0.8, scaleY: 0.8 })}
|
|
39
|
+
/>
|
|
40
|
+
</Tooltip.Trigger>
|
|
41
|
+
<Tooltip.Content>Zoom out</Tooltip.Content>
|
|
42
|
+
</Tooltip>
|
|
43
|
+
<Button size="tiny" onClick={zoom.reset}>
|
|
44
|
+
Reset
|
|
45
|
+
</Button>
|
|
46
|
+
{/*<Button size="tiny" onClick={zoom.center} text="Center" />*/}
|
|
47
|
+
</Controls>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { BarChart } from './BarChart';
|
|
2
|
+
export type { BarChartProps } from './BarChart';
|
|
3
|
+
|
|
4
|
+
export { AreaChart } from './AreaChart';
|
|
5
|
+
export type { AreaChartProps } from './AreaChart';
|
|
6
|
+
|
|
7
|
+
export { HeatMap } from './Heatmap';
|
|
8
|
+
export type { HeatmapProps } from './Heatmap';
|
|
9
|
+
|
|
10
|
+
export { PieChart } from './PieChart';
|
|
11
|
+
export type { PieChartProps } from './PieChart';
|
|
12
|
+
|
|
13
|
+
export { RadarChart } from './RadarChart';
|
|
14
|
+
export type { RadarChartProps } from './RadarChart';
|
|
15
|
+
|
|
16
|
+
export { RadialLineChart } from './RadialLineChart';
|
|
17
|
+
export type { RadialLineChartProps } from './RadialLineChart';
|
|
18
|
+
|
|
19
|
+
export { LineChart } from './LineChart';
|
|
20
|
+
export type { LineChartProps } from './LineChart';
|
|
21
|
+
|
|
22
|
+
export { RadialBarChart } from './RadialBarChart';
|
|
23
|
+
export type { RadialBarChartProps } from './RadialBarChart';
|
|
24
|
+
|
|
25
|
+
export { GeoMercator } from './GeoMercator';
|
|
26
|
+
export type { GeoMercatorProps } from './GeoMercator';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LinearGradient } from '@visx/gradient';
|
|
2
|
+
import { useTheme } from '../../hooks';
|
|
3
|
+
|
|
4
|
+
export const useGradients = (name: string) => {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
|
|
7
|
+
// Constructing the gradient IDs
|
|
8
|
+
const BACKGROUND_GRADIENT_ID = `background-gradient-${name}`;
|
|
9
|
+
const AREA_GRADIENT_ID = `area-gradient-${name}`;
|
|
10
|
+
|
|
11
|
+
// Gradient elements
|
|
12
|
+
const backgroundGradient = (
|
|
13
|
+
<LinearGradient id={BACKGROUND_GRADIENT_ID} from={theme.colors.background} to={theme.colors.background} />
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const areaGradient = (
|
|
17
|
+
<LinearGradient
|
|
18
|
+
id={AREA_GRADIENT_ID}
|
|
19
|
+
from={theme.colors.primary}
|
|
20
|
+
to={theme.colors.primary}
|
|
21
|
+
fromOpacity={0.6}
|
|
22
|
+
toOpacity={0.2}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Returning both gradient elements and their IDs
|
|
27
|
+
return {
|
|
28
|
+
background: {
|
|
29
|
+
gradient: backgroundGradient,
|
|
30
|
+
id: BACKGROUND_GRADIENT_ID,
|
|
31
|
+
},
|
|
32
|
+
chart: {
|
|
33
|
+
gradient: areaGradient,
|
|
34
|
+
id: AREA_GRADIENT_ID,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { defaultStyles } from '@visx/tooltip';
|
|
2
|
+
import { ThemeType } from '../../styled';
|
|
3
|
+
|
|
4
|
+
export interface Margin {
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
left: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AxisConfig {
|
|
12
|
+
showX?: boolean;
|
|
13
|
+
showY?: boolean;
|
|
14
|
+
labelX?: string;
|
|
15
|
+
labelY?: string;
|
|
16
|
+
numTicksX?: number;
|
|
17
|
+
numTicksY?: number;
|
|
18
|
+
/** Whether to include zero in the Y-axis domain. Default: false (auto-scale from min) */
|
|
19
|
+
includeZeroY?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface TooltipConfig<T> {
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
accessor?: (d: T, ...additionalArgs: any[]) => string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface BrushConfig {
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
margin?: Margin;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type LegendPosition = 'top' | 'right' | 'bottom' | 'left' | 'none';
|
|
33
|
+
|
|
34
|
+
/** Grid display options for charts */
|
|
35
|
+
export type GridDisplay = 'none' | 'x' | 'y' | 'xy';
|
|
36
|
+
|
|
37
|
+
export interface ChartProps {
|
|
38
|
+
/// Unique identifier for the chart
|
|
39
|
+
name: string;
|
|
40
|
+
/** Display grid lines. Options: 'none', 'x', 'y', 'xy'. Default: 'none' */
|
|
41
|
+
grid?: GridDisplay;
|
|
42
|
+
/** Axis configuration */
|
|
43
|
+
axis?: AxisConfig;
|
|
44
|
+
/** Enable or disable animations. Default: true */
|
|
45
|
+
animate?: boolean;
|
|
46
|
+
/** Chart margins */
|
|
47
|
+
margin?: Margin;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface InnerChartProps extends ChartProps {
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const getDefaultTooltipStyles = (theme: ThemeType) => ({
|
|
56
|
+
...defaultStyles,
|
|
57
|
+
background: theme.colors.background,
|
|
58
|
+
border: `1px solid ${theme.colors.backgroundAccent}`,
|
|
59
|
+
borderRadius: theme.borderRadius.small,
|
|
60
|
+
color: theme.colors.text,
|
|
61
|
+
fontSize: theme.fontSize.small,
|
|
62
|
+
whiteSpace: 'pre-wrap' as const,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export const getChartColors = (theme: ThemeType) => [
|
|
66
|
+
theme.colors.primary, // Primary color: '#664de5' (Vibrant purple)
|
|
67
|
+
'#FFD700', // Gold for a contrasting yet harmonious color
|
|
68
|
+
'#87CEEB', // Sky blue to complement the purple
|
|
69
|
+
'#FF69B4', // Hot pink for a playful, vibrant look
|
|
70
|
+
'#32CD32', // Lime green for nature-inspired freshness
|
|
71
|
+
'#FF8C00', // Dark orange for warmth
|
|
72
|
+
'#9370DB', // Medium purple for variety
|
|
73
|
+
'#20B2AA', // Light sea green for coolness
|
|
74
|
+
'#FF6347', // Tomato red for emphasis
|
|
75
|
+
'#4682B4', // Steel blue for professionalism
|
|
76
|
+
'#DAA520', // Goldenrod for richness
|
|
77
|
+
'#8B4789', // Dark orchid for depth
|
|
78
|
+
];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { styled } from '../../../styled';
|
|
4
|
+
import { Avatar, AvatarGroupProps, AvatarProps } from '.';
|
|
5
|
+
import { getInitials } from '../../../helpers';
|
|
6
|
+
|
|
7
|
+
const Wrapper = styled.div`
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: auto auto auto auto auto;
|
|
10
|
+
grid-gap: 2rem;
|
|
11
|
+
padding: 5rem;
|
|
12
|
+
background: ${({ theme }) => theme.colors.background};
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
const placeholder01 = 'images/placeholder-01.jpeg';
|
|
16
|
+
const placeholder02 = 'images/placeholder-02.jpeg';
|
|
17
|
+
const placeholder03 = 'images/placeholder-03.jpeg';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
title: 'Data/Avatar',
|
|
21
|
+
component: Avatar,
|
|
22
|
+
decorators: [(story) => <Wrapper>{story()}</Wrapper>],
|
|
23
|
+
argTypes: {
|
|
24
|
+
variant: {
|
|
25
|
+
options: ['square', 'rounded', 'circle'],
|
|
26
|
+
control: {
|
|
27
|
+
type: 'radio',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
args: {
|
|
32
|
+
size: 'medium',
|
|
33
|
+
unstackOnHover: false,
|
|
34
|
+
variant: 'circle',
|
|
35
|
+
max: 3,
|
|
36
|
+
},
|
|
37
|
+
} as Meta<AvatarProps & AvatarGroupProps>;
|
|
38
|
+
|
|
39
|
+
export const Default: StoryFn<AvatarProps> = (args) => (
|
|
40
|
+
<Avatar size={args.size} variant={args.variant}>
|
|
41
|
+
<Avatar.Image src={placeholder01} />
|
|
42
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
43
|
+
</Avatar>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const Fallback: StoryFn = () => (
|
|
47
|
+
<>
|
|
48
|
+
<Avatar size="tiny">
|
|
49
|
+
<Avatar.Image src="/broken" />
|
|
50
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
51
|
+
</Avatar>
|
|
52
|
+
<Avatar size="small">
|
|
53
|
+
<Avatar.Image src="/broken" />
|
|
54
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
55
|
+
</Avatar>
|
|
56
|
+
<Avatar size="medium">
|
|
57
|
+
<Avatar.Image src="/broken" />
|
|
58
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
59
|
+
</Avatar>
|
|
60
|
+
<Avatar size="large">
|
|
61
|
+
<Avatar.Image src="/broken" />
|
|
62
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
63
|
+
</Avatar>
|
|
64
|
+
<Avatar size="huge">
|
|
65
|
+
<Avatar.Image src="/broken" />
|
|
66
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
67
|
+
</Avatar>
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
export const Group: StoryFn<AvatarProps & AvatarGroupProps> = (args) => (
|
|
71
|
+
<Avatar.Group max={args.max} unstackOnHover={args.unstackOnHover}>
|
|
72
|
+
<Avatar size={args.size} variant={args.variant}>
|
|
73
|
+
<Avatar.Image src={placeholder01} />
|
|
74
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
75
|
+
</Avatar>
|
|
76
|
+
<Avatar size={args.size} variant={args.variant}>
|
|
77
|
+
<Avatar.Image src={placeholder02} />
|
|
78
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
79
|
+
</Avatar>
|
|
80
|
+
<Avatar size={args.size} variant={args.variant}>
|
|
81
|
+
<Avatar.Image src={placeholder03} />
|
|
82
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
83
|
+
</Avatar>
|
|
84
|
+
<Avatar size={args.size} variant={args.variant}>
|
|
85
|
+
<Avatar.Image src={placeholder01} />
|
|
86
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
87
|
+
</Avatar>
|
|
88
|
+
<Avatar size={args.size} variant={args.variant}>
|
|
89
|
+
<Avatar.Image src={placeholder02} />
|
|
90
|
+
<Avatar.FallBack>{getInitials('Harry Potter')}</Avatar.FallBack>
|
|
91
|
+
</Avatar>
|
|
92
|
+
</Avatar.Group>
|
|
93
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
4
|
+
|
|
5
|
+
type AvatarContextValue = {
|
|
6
|
+
imageLoadingStatus: ImageLoadingStatus;
|
|
7
|
+
onImageLoadingStatusChange: (status: ImageLoadingStatus) => void;
|
|
8
|
+
} | null;
|
|
9
|
+
|
|
10
|
+
export const AvatarContext = createContext<AvatarContextValue>(null);
|
|
11
|
+
|
|
12
|
+
export const useAvatarContext = () => {
|
|
13
|
+
const context = useContext(AvatarContext);
|
|
14
|
+
|
|
15
|
+
if (context == null) {
|
|
16
|
+
throw new Error('Avatar components must be wrapped in <Avatar />');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return context;
|
|
20
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
FC,
|
|
4
|
+
forwardRef,
|
|
5
|
+
ImgHTMLAttributes,
|
|
6
|
+
PropsWithChildren,
|
|
7
|
+
ReactElement,
|
|
8
|
+
useEffect,
|
|
9
|
+
useLayoutEffect,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import { Size } from '../../../styled/types';
|
|
13
|
+
import { Container, GroupContainer } from './style';
|
|
14
|
+
import { AvatarContext, ImageLoadingStatus, useAvatarContext } from './context';
|
|
15
|
+
import { useCallbackRef } from '../../../hooks';
|
|
16
|
+
import { useImageLoadingStatus } from './useImageLoadingStatus';
|
|
17
|
+
import { Skeleton } from '../../../components';
|
|
18
|
+
|
|
19
|
+
// * -------------------------------------------------------------------------------------------------
|
|
20
|
+
// * Avatar Image
|
|
21
|
+
// * -----------------------------------------------------------------------------------------------*/
|
|
22
|
+
|
|
23
|
+
interface AvatarImageProps extends ImgHTMLAttributes<HTMLImageElement> {
|
|
24
|
+
onLoadingStatusChange?: (status: ImageLoadingStatus) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const AvatarImage = forwardRef<HTMLImageElement, AvatarImageProps>(
|
|
28
|
+
({ onLoadingStatusChange, src, ...imageProps }, ref) => {
|
|
29
|
+
const context = useAvatarContext();
|
|
30
|
+
const imageLoadingStatus = useImageLoadingStatus(src);
|
|
31
|
+
const handleLoadingStatusChange = useCallbackRef((status: ImageLoadingStatus) => {
|
|
32
|
+
if (onLoadingStatusChange) {
|
|
33
|
+
onLoadingStatusChange(status);
|
|
34
|
+
}
|
|
35
|
+
context.onImageLoadingStatusChange(status);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
if (imageLoadingStatus !== 'idle') {
|
|
40
|
+
handleLoadingStatusChange(imageLoadingStatus);
|
|
41
|
+
}
|
|
42
|
+
}, [imageLoadingStatus, handleLoadingStatusChange]);
|
|
43
|
+
|
|
44
|
+
if (imageLoadingStatus === 'loading') {
|
|
45
|
+
return <Skeleton variant="circular" width="100%" height="100%" />;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return imageLoadingStatus === 'loaded' ? <img {...imageProps} ref={ref} src={src} /> : null;
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
AvatarImage.displayName = 'AvatarImage';
|
|
52
|
+
|
|
53
|
+
// * -------------------------------------------------------------------------------------------------
|
|
54
|
+
// * FallBack
|
|
55
|
+
// * -----------------------------------------------------------------------------------------------*/
|
|
56
|
+
|
|
57
|
+
interface AvatarFallBackProps {
|
|
58
|
+
delayMs?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const AvatarFallBack = forwardRef<HTMLSpanElement, PropsWithChildren<AvatarFallBackProps>>(
|
|
62
|
+
({ children, delayMs = 250 }, ref) => {
|
|
63
|
+
const { imageLoadingStatus } = useAvatarContext();
|
|
64
|
+
const [canRender, setCanRender] = useState(delayMs === undefined);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (delayMs !== undefined) {
|
|
68
|
+
const timerId = window.setTimeout(() => setCanRender(true), delayMs);
|
|
69
|
+
return () => window.clearTimeout(timerId);
|
|
70
|
+
}
|
|
71
|
+
}, [delayMs]);
|
|
72
|
+
|
|
73
|
+
return canRender && imageLoadingStatus !== 'loaded' ? <span ref={ref}>{children}</span> : null;
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
AvatarFallBack.displayName = 'AvatarFallBack';
|
|
77
|
+
|
|
78
|
+
// * -------------------------------------------------------------------------------------------------
|
|
79
|
+
// * FallBack
|
|
80
|
+
// * -----------------------------------------------------------------------------------------------*/
|
|
81
|
+
|
|
82
|
+
export interface AvatarGroupProps {
|
|
83
|
+
/// Max amount of avatars that should be shown
|
|
84
|
+
max?: number;
|
|
85
|
+
/// Unstack avatar on hover
|
|
86
|
+
unstackOnHover?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const AvatarGroup: FC<PropsWithChildren<AvatarGroupProps>> = ({ max = 3, children, unstackOnHover = false }) => {
|
|
90
|
+
// get size of first child
|
|
91
|
+
const size = (Children.toArray(children)[0] as ReactElement<AvatarProps>).props.size;
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<GroupContainer size={size ?? 'medium'} unStackOnHover={unstackOnHover}>
|
|
95
|
+
{Children.toArray(children).slice(0, Math.min(Children.count(children), max))}
|
|
96
|
+
</GroupContainer>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// * -------------------------------------------------------------------------------------------------
|
|
101
|
+
// * Avatar
|
|
102
|
+
// * -----------------------------------------------------------------------------------------------*/
|
|
103
|
+
|
|
104
|
+
interface SubComponentTypes {
|
|
105
|
+
FallBack: typeof AvatarFallBack;
|
|
106
|
+
Image: typeof AvatarImage;
|
|
107
|
+
Group: typeof AvatarGroup;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type AvatarVariant = 'square' | 'rounded' | 'circle';
|
|
111
|
+
|
|
112
|
+
export interface AvatarProps {
|
|
113
|
+
size?: Size;
|
|
114
|
+
variant?: AvatarVariant;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// TODO: skeleton loading
|
|
118
|
+
export const Avatar: FC<PropsWithChildren<AvatarProps>> & SubComponentTypes = ({
|
|
119
|
+
size = 'medium',
|
|
120
|
+
variant,
|
|
121
|
+
children,
|
|
122
|
+
}) => {
|
|
123
|
+
const [imageLoadingStatus, setImageLoadingStatus] = useState<ImageLoadingStatus>('idle');
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<AvatarContext.Provider value={{ imageLoadingStatus, onImageLoadingStatusChange: setImageLoadingStatus }}>
|
|
127
|
+
<Container size={size} variant={variant}>
|
|
128
|
+
{children}
|
|
129
|
+
</Container>
|
|
130
|
+
</AvatarContext.Provider>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
Avatar.FallBack = AvatarFallBack;
|
|
135
|
+
Avatar.Image = AvatarImage;
|
|
136
|
+
Avatar.Group = AvatarGroup;
|