@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,420 @@
|
|
|
1
|
+
import { useMemo, useRef, useState, useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Bar } from '@visx/shape';
|
|
4
|
+
import { Group } from '@visx/group';
|
|
5
|
+
import { GridRows, GridColumns } from '@visx/grid';
|
|
6
|
+
import { scaleBand, scaleLinear } from '@visx/scale';
|
|
7
|
+
import { max } from '@visx/vendor/d3-array';
|
|
8
|
+
import { ParentSize } from '@visx/responsive';
|
|
9
|
+
import { Bounds } from '@visx/brush/lib/types';
|
|
10
|
+
import { AxisBottom, AxisLeft } from '@visx/axis';
|
|
11
|
+
import { Brush } from '@visx/brush';
|
|
12
|
+
import { PatternLines } from '@visx/pattern';
|
|
13
|
+
import { shade } from 'polished';
|
|
14
|
+
import { useTooltip, TooltipWithBounds } from '@visx/tooltip';
|
|
15
|
+
import { localPoint } from '@visx/event';
|
|
16
|
+
import { motion } from 'framer-motion';
|
|
17
|
+
|
|
18
|
+
import { useTheme } from '../../../hooks';
|
|
19
|
+
import { ChartProps, InnerChartProps, BrushConfig, TooltipConfig, getDefaultTooltipStyles } from '../util';
|
|
20
|
+
import { BrushHandle } from '../BrushHandle';
|
|
21
|
+
import { EmptyChart } from '../EmptyChart';
|
|
22
|
+
|
|
23
|
+
export interface BarChartProps<T> extends ChartProps {
|
|
24
|
+
data: T[];
|
|
25
|
+
xAccessor: (d: T) => string;
|
|
26
|
+
yAccessor: (d: T) => number;
|
|
27
|
+
/** Bar width as percentage (0-1). 1.0 = bars touch (no gaps), 0.5 = bars take 50% of space. Default: 0.6 */
|
|
28
|
+
barWidth?: number;
|
|
29
|
+
tooltip?: TooltipConfig<T>;
|
|
30
|
+
brush?: BrushConfig;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const defaultMargin = { top: 20, left: 60, bottom: 60, right: 20 };
|
|
34
|
+
const defaultBrushMargin = { top: 10, bottom: 15, left: 60, right: 20 };
|
|
35
|
+
const defaultShowAxisX = true;
|
|
36
|
+
const defaultShowAxisY = true;
|
|
37
|
+
|
|
38
|
+
export const BarChart = <T,>({
|
|
39
|
+
data,
|
|
40
|
+
xAccessor,
|
|
41
|
+
yAccessor,
|
|
42
|
+
name,
|
|
43
|
+
grid = 'none',
|
|
44
|
+
axis,
|
|
45
|
+
barWidth = 0.6,
|
|
46
|
+
tooltip,
|
|
47
|
+
brush,
|
|
48
|
+
animate = true,
|
|
49
|
+
margin = defaultMargin,
|
|
50
|
+
}: BarChartProps<T>) => {
|
|
51
|
+
if (!data || data.length === 0) {
|
|
52
|
+
return <EmptyChart />;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<ParentSize>
|
|
58
|
+
{(parent) => (
|
|
59
|
+
<Chart<T>
|
|
60
|
+
name={name}
|
|
61
|
+
xAccessor={xAccessor}
|
|
62
|
+
yAccessor={yAccessor}
|
|
63
|
+
data={data}
|
|
64
|
+
width={parent.width}
|
|
65
|
+
height={parent.height}
|
|
66
|
+
grid={grid}
|
|
67
|
+
axis={axis}
|
|
68
|
+
barWidth={barWidth}
|
|
69
|
+
tooltip={tooltip}
|
|
70
|
+
brush={brush}
|
|
71
|
+
animate={animate}
|
|
72
|
+
margin={margin}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
</ParentSize>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type InnerBarChartProps<T> = InnerChartProps & BarChartProps<T>;
|
|
81
|
+
|
|
82
|
+
const Chart = <T,>({
|
|
83
|
+
data,
|
|
84
|
+
xAccessor,
|
|
85
|
+
yAccessor,
|
|
86
|
+
width,
|
|
87
|
+
height,
|
|
88
|
+
margin = defaultMargin,
|
|
89
|
+
grid = 'none',
|
|
90
|
+
axis,
|
|
91
|
+
barWidth = 0.6,
|
|
92
|
+
tooltip,
|
|
93
|
+
brush,
|
|
94
|
+
animate = true,
|
|
95
|
+
name,
|
|
96
|
+
}: InnerBarChartProps<T>) => {
|
|
97
|
+
const showAxisX = axis?.showX ?? defaultShowAxisX;
|
|
98
|
+
const showAxisY = axis?.showY ?? defaultShowAxisY;
|
|
99
|
+
const axisXLabel = axis?.labelX;
|
|
100
|
+
const axisYLabel = axis?.labelY;
|
|
101
|
+
const numTicksY = axis?.numTicksY ?? 5;
|
|
102
|
+
|
|
103
|
+
const tooltipAccessor = tooltip?.accessor;
|
|
104
|
+
const showTooltipEnabled = tooltip?.enabled ?? true;
|
|
105
|
+
|
|
106
|
+
const showBrush = brush?.enabled ?? false;
|
|
107
|
+
const brushMargin = brush?.margin ?? defaultBrushMargin;
|
|
108
|
+
const [filteredData, setFilteredData] = useState(data);
|
|
109
|
+
|
|
110
|
+
const brushRef = useRef(null);
|
|
111
|
+
const { hideTooltip, showTooltip, tooltipData, tooltipLeft = 0, tooltipTop = 0 } = useTooltip<T>();
|
|
112
|
+
const [hoveredBar, setHoveredBar] = useState<string | null>(null);
|
|
113
|
+
|
|
114
|
+
const axisHeight = 100;
|
|
115
|
+
const theme = useTheme();
|
|
116
|
+
|
|
117
|
+
const PATTERN_ID = `${name}-brush_pattern`;
|
|
118
|
+
|
|
119
|
+
// bounds
|
|
120
|
+
const xMax = Math.max(width - margin.left - margin.right, 0);
|
|
121
|
+
const yMax = height - margin.top - axisHeight; // 100 for axis
|
|
122
|
+
|
|
123
|
+
const chartSeparation = 30;
|
|
124
|
+
const innerHeight = height - margin.top - margin.bottom;
|
|
125
|
+
const topChartBottomMargin = chartSeparation + 10;
|
|
126
|
+
const topChartHeight = 0.8 * innerHeight - topChartBottomMargin;
|
|
127
|
+
const bottomChartHeight = innerHeight - topChartHeight - chartSeparation;
|
|
128
|
+
|
|
129
|
+
const xBrushMax = Math.max(width - brushMargin.left - brushMargin.right, 0);
|
|
130
|
+
const yBrushMax = Math.max(bottomChartHeight - brushMargin.top - brushMargin.bottom, 0);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
setFilteredData(data);
|
|
134
|
+
}, [data]);
|
|
135
|
+
|
|
136
|
+
const xScale = useMemo(
|
|
137
|
+
() =>
|
|
138
|
+
scaleBand<string>({
|
|
139
|
+
range: [0, xMax],
|
|
140
|
+
round: true,
|
|
141
|
+
domain: filteredData.map(xAccessor),
|
|
142
|
+
padding: 1 - barWidth,
|
|
143
|
+
}),
|
|
144
|
+
[xMax, filteredData, barWidth, xAccessor],
|
|
145
|
+
);
|
|
146
|
+
const yScale = useMemo(
|
|
147
|
+
() =>
|
|
148
|
+
scaleLinear<number>({
|
|
149
|
+
range: [yMax, 0],
|
|
150
|
+
round: true,
|
|
151
|
+
domain: [0, max(filteredData, yAccessor) ?? 0],
|
|
152
|
+
}),
|
|
153
|
+
[yMax, filteredData],
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const xBrushScale = useMemo(
|
|
157
|
+
() =>
|
|
158
|
+
scaleBand<string>({
|
|
159
|
+
range: [0, xBrushMax],
|
|
160
|
+
domain: data.map(xAccessor),
|
|
161
|
+
round: true,
|
|
162
|
+
padding: 1 - barWidth,
|
|
163
|
+
}),
|
|
164
|
+
[xBrushMax, barWidth, xAccessor, data],
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const yBrushScale = useMemo(
|
|
168
|
+
() =>
|
|
169
|
+
scaleLinear({
|
|
170
|
+
range: [yBrushMax, 0],
|
|
171
|
+
domain: [0, Math.max(...data.map(yAccessor))],
|
|
172
|
+
nice: true,
|
|
173
|
+
}),
|
|
174
|
+
[yBrushMax],
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const onBrushChange = (domain: Bounds | null) => {
|
|
178
|
+
if (!domain || !domain.xValues) return;
|
|
179
|
+
const { xValues } = domain;
|
|
180
|
+
|
|
181
|
+
const filtered = data.filter((d) => {
|
|
182
|
+
const xValue = xAccessor(d);
|
|
183
|
+
return xValues.includes(xValue);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
setFilteredData(filtered);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const handleTooltip = useCallback(
|
|
190
|
+
(event: React.TouchEvent<SVGElement> | React.MouseEvent<SVGElement>) => {
|
|
191
|
+
const { x } = localPoint(event) || { x: 0 };
|
|
192
|
+
// x is relative to the SVG, subtract margin to get chart-relative position
|
|
193
|
+
const xRelativeToChart = x - margin.left;
|
|
194
|
+
|
|
195
|
+
// Find the bar that contains this x position
|
|
196
|
+
const xValue = xScale.domain().find((domainValue) => {
|
|
197
|
+
const barX = xScale(domainValue) ?? 0;
|
|
198
|
+
const barWidth = xScale.bandwidth();
|
|
199
|
+
return xRelativeToChart >= barX && xRelativeToChart <= barX + barWidth;
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
if (xValue) {
|
|
203
|
+
const d = filteredData.find((item) => xAccessor(item) === xValue);
|
|
204
|
+
if (d) {
|
|
205
|
+
const tooltipX = (xScale(xValue) ?? 0) + xScale.bandwidth() / 2; // Center of bar
|
|
206
|
+
const tooltipY = yScale(yAccessor(d));
|
|
207
|
+
|
|
208
|
+
setHoveredBar(xValue);
|
|
209
|
+
showTooltip({
|
|
210
|
+
tooltipData: d,
|
|
211
|
+
tooltipLeft: tooltipX,
|
|
212
|
+
tooltipTop: tooltipY,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[xScale, yScale, filteredData, xAccessor, yAccessor, margin.left, showTooltip],
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<div>
|
|
222
|
+
<svg width={width} height={height} role="img" aria-label={`Bar chart: ${name}`}>
|
|
223
|
+
<desc id={`${name}-desc`}>Bar chart showing {filteredData.length} data points</desc>
|
|
224
|
+
{(grid === 'y' || grid === 'xy') && (
|
|
225
|
+
<GridRows
|
|
226
|
+
top={margin.top}
|
|
227
|
+
left={margin.left}
|
|
228
|
+
scale={yScale}
|
|
229
|
+
width={xMax}
|
|
230
|
+
height={yMax}
|
|
231
|
+
stroke={theme.colors.backgroundAccent}
|
|
232
|
+
strokeOpacity={1}
|
|
233
|
+
strokeDasharray="2,2"
|
|
234
|
+
pointerEvents="none"
|
|
235
|
+
/>
|
|
236
|
+
)}
|
|
237
|
+
{(grid === 'x' || grid === 'xy') && (
|
|
238
|
+
<GridColumns
|
|
239
|
+
top={margin.top}
|
|
240
|
+
left={margin.left}
|
|
241
|
+
scale={xScale}
|
|
242
|
+
height={yMax}
|
|
243
|
+
stroke={theme.colors.backgroundAccent}
|
|
244
|
+
strokeOpacity={1}
|
|
245
|
+
strokeDasharray="2,2"
|
|
246
|
+
pointerEvents="none"
|
|
247
|
+
/>
|
|
248
|
+
)}
|
|
249
|
+
{/* Hover highlight */}
|
|
250
|
+
{hoveredBar && (
|
|
251
|
+
<Group top={margin.top} left={margin.left}>
|
|
252
|
+
{(() => {
|
|
253
|
+
const barX = xScale(hoveredBar) ?? 0;
|
|
254
|
+
const barWidth = xScale.bandwidth();
|
|
255
|
+
const stepWidth = xScale.step();
|
|
256
|
+
const highlightX = barX - (stepWidth - barWidth) / 2;
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
<motion.rect
|
|
260
|
+
x={highlightX}
|
|
261
|
+
y={0}
|
|
262
|
+
width={stepWidth}
|
|
263
|
+
height={yMax}
|
|
264
|
+
fill={theme.colors.backgroundAccent}
|
|
265
|
+
opacity={0.15}
|
|
266
|
+
pointerEvents="none"
|
|
267
|
+
initial={{ opacity: 0 }}
|
|
268
|
+
animate={{ opacity: 0.15 }}
|
|
269
|
+
transition={{ duration: 0.15 }}
|
|
270
|
+
/>
|
|
271
|
+
);
|
|
272
|
+
})()}
|
|
273
|
+
</Group>
|
|
274
|
+
)}
|
|
275
|
+
<Group top={margin.top} left={margin.left}>
|
|
276
|
+
{filteredData.map((d, index) => {
|
|
277
|
+
const xVal = xAccessor(d);
|
|
278
|
+
const barWidth = xScale.bandwidth();
|
|
279
|
+
const barHeight = yMax - (yScale(yAccessor(d)) ?? 0);
|
|
280
|
+
return (
|
|
281
|
+
<g key={`bar-${xVal}`} transform={`translate(${xScale(xVal)}, ${yMax})`}>
|
|
282
|
+
<motion.rect
|
|
283
|
+
x={0}
|
|
284
|
+
width={barWidth}
|
|
285
|
+
fill={shade(0.5, theme.colors.primary)}
|
|
286
|
+
stroke={theme.colors.primary}
|
|
287
|
+
initial={animate ? { y: 0, height: 0 } : { y: -barHeight, height: barHeight }}
|
|
288
|
+
animate={{ y: -barHeight, height: barHeight }}
|
|
289
|
+
transition={
|
|
290
|
+
animate
|
|
291
|
+
? {
|
|
292
|
+
duration: 0.6,
|
|
293
|
+
delay: index * 0.05,
|
|
294
|
+
ease: 'easeOut',
|
|
295
|
+
}
|
|
296
|
+
: { duration: 0 }
|
|
297
|
+
}
|
|
298
|
+
/>
|
|
299
|
+
</g>
|
|
300
|
+
);
|
|
301
|
+
})}
|
|
302
|
+
</Group>
|
|
303
|
+
{showTooltipEnabled && (
|
|
304
|
+
<Bar
|
|
305
|
+
x={margin.left}
|
|
306
|
+
y={margin.top}
|
|
307
|
+
width={xMax}
|
|
308
|
+
height={yMax}
|
|
309
|
+
fill="transparent"
|
|
310
|
+
onTouchStart={handleTooltip}
|
|
311
|
+
onTouchMove={handleTooltip}
|
|
312
|
+
onMouseMove={handleTooltip}
|
|
313
|
+
onMouseLeave={() => {
|
|
314
|
+
hideTooltip();
|
|
315
|
+
setHoveredBar(null);
|
|
316
|
+
}}
|
|
317
|
+
/>
|
|
318
|
+
)}
|
|
319
|
+
{showAxisY && (
|
|
320
|
+
<AxisLeft
|
|
321
|
+
top={margin.top}
|
|
322
|
+
left={margin.left}
|
|
323
|
+
numTicks={numTicksY}
|
|
324
|
+
tickStroke={theme.colors.textAlt}
|
|
325
|
+
tickLabelProps={{
|
|
326
|
+
fill: theme.colors.textAlt,
|
|
327
|
+
fontSize: theme.fontSize.small,
|
|
328
|
+
textAnchor: 'end',
|
|
329
|
+
}}
|
|
330
|
+
scale={yScale}
|
|
331
|
+
label={axisYLabel}
|
|
332
|
+
/>
|
|
333
|
+
)}
|
|
334
|
+
|
|
335
|
+
{showAxisX && (
|
|
336
|
+
<AxisBottom
|
|
337
|
+
top={yMax + margin.top}
|
|
338
|
+
left={margin.left}
|
|
339
|
+
tickStroke={theme.colors.textAlt}
|
|
340
|
+
tickLabelProps={{
|
|
341
|
+
fill: theme.colors.textAlt,
|
|
342
|
+
fontSize: theme.fontSize.small,
|
|
343
|
+
textAnchor: 'end',
|
|
344
|
+
angle: -45,
|
|
345
|
+
dy: '0.25em',
|
|
346
|
+
}}
|
|
347
|
+
tickFormat={(value) => {
|
|
348
|
+
const maxLength = 15;
|
|
349
|
+
const str = String(value);
|
|
350
|
+
return str.length > maxLength ? `${str.substring(0, maxLength)}...` : str;
|
|
351
|
+
}}
|
|
352
|
+
scale={xScale}
|
|
353
|
+
label={axisXLabel}
|
|
354
|
+
/>
|
|
355
|
+
)}
|
|
356
|
+
|
|
357
|
+
{showBrush && (
|
|
358
|
+
<>
|
|
359
|
+
{/* brush chart */}
|
|
360
|
+
<Group left={brushMargin.left} top={topChartHeight + topChartBottomMargin + margin.top}>
|
|
361
|
+
{data.map((d) => {
|
|
362
|
+
const xVal = xAccessor(d);
|
|
363
|
+
const barWidth = xBrushScale.bandwidth();
|
|
364
|
+
const barHeight = yBrushMax - (yBrushScale(yAccessor(d)) ?? 0);
|
|
365
|
+
return (
|
|
366
|
+
<Bar
|
|
367
|
+
key={`bar-${xVal}`}
|
|
368
|
+
x={xBrushScale(xVal)}
|
|
369
|
+
y={yBrushMax - barHeight}
|
|
370
|
+
width={barWidth}
|
|
371
|
+
height={barHeight}
|
|
372
|
+
fill={shade(0.5, theme.colors.primary)}
|
|
373
|
+
/>
|
|
374
|
+
);
|
|
375
|
+
})}
|
|
376
|
+
<PatternLines
|
|
377
|
+
id={PATTERN_ID}
|
|
378
|
+
height={8}
|
|
379
|
+
width={8}
|
|
380
|
+
stroke={theme.colors.backgroundAccent}
|
|
381
|
+
strokeWidth={1}
|
|
382
|
+
orientation={['diagonal']}
|
|
383
|
+
/>
|
|
384
|
+
<Brush
|
|
385
|
+
xScale={xBrushScale}
|
|
386
|
+
yScale={yBrushScale}
|
|
387
|
+
width={xBrushMax}
|
|
388
|
+
height={yBrushMax}
|
|
389
|
+
innerRef={brushRef}
|
|
390
|
+
resizeTriggerAreas={['left', 'right']}
|
|
391
|
+
brushDirection="horizontal"
|
|
392
|
+
margin={brushMargin}
|
|
393
|
+
onChange={onBrushChange}
|
|
394
|
+
selectedBoxStyle={{
|
|
395
|
+
fill: `url(#${PATTERN_ID})`,
|
|
396
|
+
stroke: theme.colors.backgroundAccent,
|
|
397
|
+
}}
|
|
398
|
+
useWindowMoveEvents
|
|
399
|
+
handleSize={8}
|
|
400
|
+
renderBrushHandle={(props) => <BrushHandle {...props} />}
|
|
401
|
+
/>
|
|
402
|
+
</Group>
|
|
403
|
+
</>
|
|
404
|
+
)}
|
|
405
|
+
</svg>
|
|
406
|
+
{showTooltipEnabled && tooltipData && (
|
|
407
|
+
<div>
|
|
408
|
+
<TooltipWithBounds
|
|
409
|
+
key={`${name}-tooltip`}
|
|
410
|
+
top={tooltipTop + margin.top}
|
|
411
|
+
left={tooltipLeft + margin.left}
|
|
412
|
+
style={getDefaultTooltipStyles(theme)}
|
|
413
|
+
>
|
|
414
|
+
{tooltipAccessor ? tooltipAccessor(tooltipData) : yAccessor(tooltipData)}
|
|
415
|
+
</TooltipWithBounds>
|
|
416
|
+
</div>
|
|
417
|
+
)}
|
|
418
|
+
</div>
|
|
419
|
+
);
|
|
420
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BrushHandleRenderProps } from '@visx/brush/lib/BrushHandle';
|
|
2
|
+
import { Group } from '@visx/group';
|
|
3
|
+
|
|
4
|
+
export function BrushHandle({ x, height, isBrushActive }: BrushHandleRenderProps) {
|
|
5
|
+
const pathWidth = 8;
|
|
6
|
+
const pathHeight = 15;
|
|
7
|
+
if (!isBrushActive) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (
|
|
11
|
+
<Group left={x + pathWidth / 2} top={(height - pathHeight) / 2}>
|
|
12
|
+
<path
|
|
13
|
+
fill=""
|
|
14
|
+
d="M -4.5 0.5 L 3.5 0.5 L 3.5 15.5 L -4.5 15.5 L -4.5 0.5 M -1.5 4 L -1.5 12 M 0.5 4 L 0.5 12"
|
|
15
|
+
stroke="#999999"
|
|
16
|
+
strokeWidth="1"
|
|
17
|
+
style={{ cursor: 'ew-resize' }}
|
|
18
|
+
/>
|
|
19
|
+
</Group>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { styled } from '../../styled';
|
|
3
|
+
|
|
4
|
+
const Container = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
svg {
|
|
11
|
+
position: absolute;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
path {
|
|
16
|
+
stroke: ${({ theme }) => theme.colors.primary};
|
|
17
|
+
stroke-width: 1;
|
|
18
|
+
fill: none;
|
|
19
|
+
opacity: 0.2;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
p {
|
|
23
|
+
font-size: ${({ theme }) => theme.fontSize.medium};
|
|
24
|
+
color: ${({ theme }) => theme.colors.textAlt};
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
export const EmptyChart: FC = () => {
|
|
29
|
+
return (
|
|
30
|
+
<Container>
|
|
31
|
+
<svg viewBox="0 0 100 100" preserveAspectRatio="none">
|
|
32
|
+
<path
|
|
33
|
+
d="
|
|
34
|
+
M 0,80
|
|
35
|
+
C 10,60 20,90 30,70
|
|
36
|
+
S 50,50 60,60
|
|
37
|
+
S 80,30 90,50
|
|
38
|
+
T 100,40
|
|
39
|
+
"
|
|
40
|
+
></path>
|
|
41
|
+
</svg>
|
|
42
|
+
<p>No data available</p>
|
|
43
|
+
</Container>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { GeoMercator, GeoMercatorProps } from '.';
|
|
4
|
+
import { Card } from '../../../components';
|
|
5
|
+
import { CountryList } from '../../data/CountryList';
|
|
6
|
+
import { styled } from '../../../styled';
|
|
7
|
+
|
|
8
|
+
interface Shape {
|
|
9
|
+
code: string;
|
|
10
|
+
amount: number;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const alpha3: Shape[] = [
|
|
15
|
+
{ code: 'BEL', amount: 10, name: 'Belgium' },
|
|
16
|
+
{ code: 'CAN', amount: 20, name: 'Canada' },
|
|
17
|
+
{ code: 'DEU', amount: 30, name: 'Germany' },
|
|
18
|
+
{ code: 'ESP', amount: 40, name: 'Spain' },
|
|
19
|
+
{ code: 'FRA', amount: 50, name: 'France' },
|
|
20
|
+
{ code: 'GBR', amount: 60, name: 'United Kingdom' },
|
|
21
|
+
{ code: 'GRC', amount: 70, name: 'Greece' },
|
|
22
|
+
{ code: 'ITA', amount: 80, name: 'Italy' },
|
|
23
|
+
{ code: 'NLD', amount: 90, name: 'Netherlands' },
|
|
24
|
+
{ code: 'USA', amount: 100, name: 'United States of America' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
title: 'Charts/GeoMercator',
|
|
29
|
+
component: GeoMercator,
|
|
30
|
+
args: {
|
|
31
|
+
showZoomControls: false,
|
|
32
|
+
allowZoomAndDrag: false,
|
|
33
|
+
},
|
|
34
|
+
} as Meta<GeoMercatorProps<Shape>>;
|
|
35
|
+
|
|
36
|
+
const Wrapper = styled.div`
|
|
37
|
+
width: fit-content;
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const Inner = styled.div`
|
|
41
|
+
width: 800px;
|
|
42
|
+
height: 800px;
|
|
43
|
+
display: flex;
|
|
44
|
+
gap: 1rem;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export const Default: StoryFn<GeoMercatorProps<Shape>> = (args) => {
|
|
48
|
+
const getCountry = (d: Shape) => d.code;
|
|
49
|
+
const getAmount = (d: Shape) => Number(d.amount);
|
|
50
|
+
const tooltipAccessor = (d: Shape) => {
|
|
51
|
+
return `${d.name}:${getAmount(d)}`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Wrapper>
|
|
56
|
+
<Card>
|
|
57
|
+
<Card.Title label="Map" />
|
|
58
|
+
<Card.Body>
|
|
59
|
+
<Inner>
|
|
60
|
+
<div style={{ position: 'relative', flex: 1 }}>
|
|
61
|
+
<GeoMercator<Shape>
|
|
62
|
+
name="geo-mercator"
|
|
63
|
+
xAccessor={getCountry}
|
|
64
|
+
yAccessor={getAmount}
|
|
65
|
+
tooltipAccessor={tooltipAccessor}
|
|
66
|
+
data={alpha3}
|
|
67
|
+
showZoomControls={args.showZoomControls}
|
|
68
|
+
allowZoomAndDrag={args.allowZoomAndDrag}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
<CountryList<Shape> data={alpha3} xAccessor={getCountry} yAccessor={getAmount} />
|
|
72
|
+
</Inner>
|
|
73
|
+
</Card.Body>
|
|
74
|
+
</Card>
|
|
75
|
+
</Wrapper>
|
|
76
|
+
);
|
|
77
|
+
};
|