@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,124 @@
|
|
|
1
|
+
import { AvatarVariant } from '.';
|
|
2
|
+
import { styled, Size } from '../../../styled';
|
|
3
|
+
|
|
4
|
+
export const GroupContainer = styled.div<{ size: Size; unStackOnHover: boolean }>`
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
|
|
9
|
+
&:hover {
|
|
10
|
+
div {
|
|
11
|
+
${({ unStackOnHover }) => (unStackOnHover ? 'margin-left: 0;' : '')}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div {
|
|
16
|
+
transition: margin-left 0.2s ease-in-out;
|
|
17
|
+
/* mind the negative sign here */
|
|
18
|
+
margin-left: -${({ theme }) => theme.spacing['5']};
|
|
19
|
+
|
|
20
|
+
:first-child {
|
|
21
|
+
margin-left: ${({ theme }) => theme.spacing[0]};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
${({ size, theme }) => {
|
|
25
|
+
switch (size) {
|
|
26
|
+
case 'tiny':
|
|
27
|
+
return `margin-left: -${theme.spacing['0_25']};`;
|
|
28
|
+
case 'small':
|
|
29
|
+
return `margin-left: -${theme.spacing['1']};`;
|
|
30
|
+
case 'medium':
|
|
31
|
+
return `margin-left: -${theme.spacing['3']};`;
|
|
32
|
+
case 'large':
|
|
33
|
+
return `margin-left: -${theme.spacing['8']};`;
|
|
34
|
+
case 'huge':
|
|
35
|
+
return `margin-left: -${theme.spacing['10']};`;
|
|
36
|
+
}
|
|
37
|
+
}}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export const Container = styled.div<{ size: Size; variant?: AvatarVariant }>`
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
color: ${({ theme }) => theme.colors.text};
|
|
46
|
+
font-weight: 700;
|
|
47
|
+
|
|
48
|
+
img {
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: 100%;
|
|
51
|
+
${({ theme, variant }) => {
|
|
52
|
+
switch (variant) {
|
|
53
|
+
case 'square':
|
|
54
|
+
return 'border-radius: 0;';
|
|
55
|
+
case 'rounded':
|
|
56
|
+
return `border-radius: ${theme.borderRadius['small']};`;
|
|
57
|
+
default:
|
|
58
|
+
return 'border-radius: 50%;';
|
|
59
|
+
}
|
|
60
|
+
}}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
span {
|
|
64
|
+
display: inline-flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
/* 2px is the size of the border */
|
|
68
|
+
width: calc(100% - 2px);
|
|
69
|
+
height: calc(100% - 2px);
|
|
70
|
+
${({ theme, variant }) => {
|
|
71
|
+
switch (variant) {
|
|
72
|
+
case 'square':
|
|
73
|
+
return 'border-radius: 0;';
|
|
74
|
+
case 'rounded':
|
|
75
|
+
return `border-radius: ${theme.borderRadius['small']};`;
|
|
76
|
+
default:
|
|
77
|
+
return 'border-radius: 50%;';
|
|
78
|
+
}
|
|
79
|
+
}}
|
|
80
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
81
|
+
border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
82
|
+
margin-left: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
${({ size, theme }) => {
|
|
86
|
+
switch (size) {
|
|
87
|
+
case 'tiny':
|
|
88
|
+
return `
|
|
89
|
+
width: 1rem;
|
|
90
|
+
height: 1rem;
|
|
91
|
+
font-size: .8rem;
|
|
92
|
+
line-height: .8rem;
|
|
93
|
+
`;
|
|
94
|
+
case 'small':
|
|
95
|
+
return `
|
|
96
|
+
width: 3.125rem;
|
|
97
|
+
height: 3.125rem;
|
|
98
|
+
font-size: ${theme.fontSize.small};
|
|
99
|
+
line-height: 3.125rem;
|
|
100
|
+
`;
|
|
101
|
+
case 'medium':
|
|
102
|
+
return `
|
|
103
|
+
width: 6rem;
|
|
104
|
+
height: 6rem;
|
|
105
|
+
font-size: 2rem;
|
|
106
|
+
line-height: 2rem;
|
|
107
|
+
`;
|
|
108
|
+
case 'large':
|
|
109
|
+
return `
|
|
110
|
+
width: 12.5rem;
|
|
111
|
+
height: 12.5rem;
|
|
112
|
+
font-size: 2.8rem;
|
|
113
|
+
line-height: 2.8rem;
|
|
114
|
+
`;
|
|
115
|
+
case 'huge':
|
|
116
|
+
return `
|
|
117
|
+
width: 16rem;
|
|
118
|
+
height: 16rem;
|
|
119
|
+
font-size: 3rem;
|
|
120
|
+
line-height: 3rem;
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
}}
|
|
124
|
+
`;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { ImageLoadingStatus } from './context';
|
|
3
|
+
|
|
4
|
+
export function useImageLoadingStatus(src?: string) {
|
|
5
|
+
const [loadingStatus, setLoadingStatus] = useState<ImageLoadingStatus>('idle');
|
|
6
|
+
|
|
7
|
+
useLayoutEffect(() => {
|
|
8
|
+
if (!src) {
|
|
9
|
+
setLoadingStatus('error');
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let isMounted = true;
|
|
14
|
+
const image = new window.Image();
|
|
15
|
+
|
|
16
|
+
const updateStatus = (status: ImageLoadingStatus) => () => {
|
|
17
|
+
if (!isMounted) return;
|
|
18
|
+
setLoadingStatus(status);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
setLoadingStatus('loading');
|
|
22
|
+
image.onload = updateStatus('loaded');
|
|
23
|
+
image.onerror = updateStatus('error');
|
|
24
|
+
image.src = src;
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
isMounted = false;
|
|
28
|
+
};
|
|
29
|
+
}, [src]);
|
|
30
|
+
|
|
31
|
+
return loadingStatus;
|
|
32
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
|
|
3
|
+
import { styled } from '../../../styled';
|
|
4
|
+
import { AiOutlineArrowRight as LinkIcon } from 'react-icons/ai';
|
|
5
|
+
import { Chip, ChipProps } from '../../data';
|
|
6
|
+
|
|
7
|
+
const Wrapper = styled.div`
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
padding: 5rem;
|
|
13
|
+
background: ${({ theme }) => theme.colors.background};
|
|
14
|
+
text-align: left;
|
|
15
|
+
|
|
16
|
+
& > div {
|
|
17
|
+
margin: 1rem;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
title: 'Data/Chip',
|
|
23
|
+
component: Chip,
|
|
24
|
+
decorators: [(story) => <Wrapper>{story()}</Wrapper>],
|
|
25
|
+
args: {
|
|
26
|
+
label: 'Default chip',
|
|
27
|
+
color: 'backgroundAccent',
|
|
28
|
+
disabled: false,
|
|
29
|
+
dot: false,
|
|
30
|
+
variant: 'default',
|
|
31
|
+
isLoading: false,
|
|
32
|
+
},
|
|
33
|
+
} as Meta<ChipProps>;
|
|
34
|
+
|
|
35
|
+
export const Default: StoryFn<ChipProps> = (args) => <Chip {...args} />;
|
|
36
|
+
|
|
37
|
+
export const ClickableChip: StoryObj<ChipProps> = {
|
|
38
|
+
args: {
|
|
39
|
+
label: 'Clickable chip',
|
|
40
|
+
onClick: () => {
|
|
41
|
+
/* */
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export const DeletableChip: StoryObj<ChipProps> = {
|
|
46
|
+
args: {
|
|
47
|
+
label: 'Deletable chip',
|
|
48
|
+
onDelete: () => {
|
|
49
|
+
/* */
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const LoadingChip: StoryObj<ChipProps> = {
|
|
55
|
+
args: {
|
|
56
|
+
label: 'loading chip',
|
|
57
|
+
isLoading: true,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const IconChip: StoryObj<ChipProps> = {
|
|
62
|
+
args: {
|
|
63
|
+
label: 'Chip with icon',
|
|
64
|
+
icon: <LinkIcon />,
|
|
65
|
+
showIcon: 'hover',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chip } from '.';
|
|
2
|
+
import { render } from '../../../test/testUtils';
|
|
3
|
+
import { expect, it } from 'vitest';
|
|
4
|
+
|
|
5
|
+
it('Should render <Chip/>', () => {
|
|
6
|
+
const { container } = render(<Chip variant="outline" label="chip label" />);
|
|
7
|
+
expect(container).toMatchSnapshot();
|
|
8
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Chip/> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
display: -webkit-inline-box;
|
|
6
|
+
display: -webkit-inline-flex;
|
|
7
|
+
display: -ms-inline-flexbox;
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
-webkit-align-items: center;
|
|
10
|
+
-webkit-box-align: center;
|
|
11
|
+
-ms-flex-align: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
-webkit-box-pack: justify;
|
|
14
|
+
-webkit-justify-content: space-between;
|
|
15
|
+
-ms-flex-pack: justify;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
padding: 3px 12px;
|
|
18
|
+
border-radius: 1.5rem;
|
|
19
|
+
cursor: auto;
|
|
20
|
+
border: 2px solid transparent;
|
|
21
|
+
background-color: #d3d3d3;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.c0 svg {
|
|
25
|
+
margin-left: 0.5rem;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
fill: white;
|
|
28
|
+
stroke: white;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.c0 span {
|
|
32
|
+
display: block;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
margin-left: 0;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
font-size: 1.225rem;
|
|
37
|
+
color: white;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
<div>
|
|
41
|
+
<div
|
|
42
|
+
class="c0"
|
|
43
|
+
color="gray"
|
|
44
|
+
>
|
|
45
|
+
<span>
|
|
46
|
+
chip label
|
|
47
|
+
</span>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
`;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Chip/> 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
style="padding: 0.5rem; max-width: 100%;"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
style="display: flex; align-items: center; gap: .5rem;"
|
|
10
|
+
>
|
|
11
|
+
<strong
|
|
12
|
+
style="font-size: 1rem;"
|
|
13
|
+
>
|
|
14
|
+
Something went wrong!
|
|
15
|
+
</strong>
|
|
16
|
+
<button
|
|
17
|
+
style="appearance: none; font-size: 0.6em; border: 1px solid currentcolor; padding: 0.1rem 0.2rem; font-weight: bold; border-radius: .25rem;"
|
|
18
|
+
>
|
|
19
|
+
Hide Error
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
<div
|
|
23
|
+
style="height: 0.25rem;"
|
|
24
|
+
/>
|
|
25
|
+
<div>
|
|
26
|
+
<pre
|
|
27
|
+
style="font-size: 0.7em; border: 1px solid red; border-radius: .25rem; padding: 0.3rem; color: red; overflow: auto;"
|
|
28
|
+
>
|
|
29
|
+
<code>
|
|
30
|
+
Passed an incorrect argument to a color function, please pass a string representation of a color.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
</code>
|
|
34
|
+
</pre>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
`;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { forwardRef, ReactElement, cloneElement } from 'react';
|
|
2
|
+
import { AiOutlineClose as Icon } from 'react-icons/ai';
|
|
3
|
+
import { Container } from './style';
|
|
4
|
+
import { AlertVariants, Color } from '../../../styled/types';
|
|
5
|
+
|
|
6
|
+
export type ChipColor = Color | AlertVariants | 'backgroundAccent';
|
|
7
|
+
|
|
8
|
+
export type ShowIcon = 'always' | 'hover';
|
|
9
|
+
|
|
10
|
+
export interface ChipProps {
|
|
11
|
+
label: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
dot?: boolean;
|
|
15
|
+
onClick?: () => void;
|
|
16
|
+
onDelete?: () => void;
|
|
17
|
+
color: ChipColor;
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
icon?: ReactElement;
|
|
20
|
+
showIcon?: ShowIcon;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const Chip = forwardRef<HTMLDivElement, ChipProps>(function Chip(
|
|
24
|
+
{
|
|
25
|
+
color,
|
|
26
|
+
label,
|
|
27
|
+
disabled = false,
|
|
28
|
+
readOnly = false,
|
|
29
|
+
onClick = undefined,
|
|
30
|
+
onDelete = undefined,
|
|
31
|
+
isLoading = false,
|
|
32
|
+
icon,
|
|
33
|
+
showIcon = 'always',
|
|
34
|
+
},
|
|
35
|
+
ref,
|
|
36
|
+
) {
|
|
37
|
+
if (isLoading) {
|
|
38
|
+
return (
|
|
39
|
+
<Container
|
|
40
|
+
ref={ref}
|
|
41
|
+
clickable={!readOnly && !disabled && onClick !== undefined}
|
|
42
|
+
color={color}
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
onClick={onClick ? onClick : undefined}
|
|
45
|
+
className="placeholder"
|
|
46
|
+
showIcon={showIcon}
|
|
47
|
+
>
|
|
48
|
+
<span style={{ minWidth: '70px', minHeight: '15px' }}></span>
|
|
49
|
+
</Container>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Container
|
|
55
|
+
ref={ref}
|
|
56
|
+
clickable={onClick !== undefined}
|
|
57
|
+
color={color}
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
onClick={onClick ? onClick : undefined}
|
|
60
|
+
showIcon={showIcon}
|
|
61
|
+
>
|
|
62
|
+
<span>{label}</span>
|
|
63
|
+
{!onDelete && icon && cloneElement(icon, { size: 12, className: 'icon' })}
|
|
64
|
+
{onDelete && !readOnly && !disabled && <Icon onClick={onDelete} size={12} />}
|
|
65
|
+
</Container>
|
|
66
|
+
);
|
|
67
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { styled } from '../../../styled';
|
|
2
|
+
import { ChipColor, ShowIcon } from '.';
|
|
3
|
+
import { shade } from 'polished';
|
|
4
|
+
|
|
5
|
+
export const Container = styled.div<{
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
color: ChipColor;
|
|
8
|
+
clickable: boolean;
|
|
9
|
+
showIcon: ShowIcon;
|
|
10
|
+
}>`
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
padding: ${({ theme }) => `${theme.spacing['0_25']} ${theme.spacing['0_5']}`};
|
|
15
|
+
border-radius: ${({ theme }) => theme.borderRadius.small};
|
|
16
|
+
cursor: ${({ clickable }): string => (clickable ? 'pointer' : 'auto')};
|
|
17
|
+
width: fit-content;
|
|
18
|
+
height: 20px;
|
|
19
|
+
background-color: ${({ theme, color }) => shade(0.5, theme.colors[color])};
|
|
20
|
+
border: 0.1rem solid ${({ theme, color }) => theme.colors[color]};
|
|
21
|
+
|
|
22
|
+
svg {
|
|
23
|
+
margin-left: ${({ theme }) => theme.spacing['0_5']};
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
transition: width 0.2s ease-in-out;
|
|
26
|
+
will-change: width;
|
|
27
|
+
display: ${({ showIcon }): string => (showIcon === 'always' ? 'inline-block' : 'none')};
|
|
28
|
+
${({ theme, color }) => {
|
|
29
|
+
return `fill: ${theme.colors[color]};`;
|
|
30
|
+
}}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
svg {
|
|
35
|
+
display: inline-block;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
span {
|
|
40
|
+
display: block;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
text-overflow: ellipsis;
|
|
44
|
+
|
|
45
|
+
font-size: ${({ theme }) => theme.fontSize.medium};
|
|
46
|
+
user-select: none;
|
|
47
|
+
color: white;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Console as ConsoleComponent } from '../Console';
|
|
4
|
+
import { Message, MessageType } from './MessageModel';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Data/Console',
|
|
8
|
+
component: ConsoleComponent,
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const MessageTypeMap: MessageType[] = ['command', 'info', 'debug', 'warning', 'error'];
|
|
12
|
+
|
|
13
|
+
export const Console: StoryFn = () => {
|
|
14
|
+
const [messages, setMessages] = useState<Message[]>([]);
|
|
15
|
+
|
|
16
|
+
function listenerFactory() {
|
|
17
|
+
const interval = setInterval(() => {
|
|
18
|
+
const r = Math.floor(Math.random() * 5);
|
|
19
|
+
const newMessage: Message = {
|
|
20
|
+
data: `this is a ${MessageTypeMap[r]} logline`,
|
|
21
|
+
result: '',
|
|
22
|
+
timestamp: new Date().toISOString(),
|
|
23
|
+
type: MessageTypeMap[r],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
setMessages((prev: Message[]) => [...prev, newMessage]);
|
|
27
|
+
}, 200);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
on: () => {
|
|
31
|
+
/* Nothing to do here */
|
|
32
|
+
},
|
|
33
|
+
off: () => clearInterval(interval),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ConsoleComponent
|
|
39
|
+
messages={messages}
|
|
40
|
+
setMessages={setMessages}
|
|
41
|
+
listenerFactory={listenerFactory}
|
|
42
|
+
onExecuteCommand={async () => {
|
|
43
|
+
return {
|
|
44
|
+
type: 'command',
|
|
45
|
+
data: 'response here',
|
|
46
|
+
timestamp: new Date().toISOString(),
|
|
47
|
+
};
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { FC, useEffect, SetStateAction, Dispatch, useRef, forwardRef } from 'react';
|
|
2
|
+
import { Wrapper, Header, MessageContainer } from './style';
|
|
3
|
+
import { ConsoleLine } from './ConsoleLine';
|
|
4
|
+
import { VariableSizeList } from 'react-window';
|
|
5
|
+
import { Message } from './MessageModel';
|
|
6
|
+
import { ConsoleInput } from './ConsoleInput';
|
|
7
|
+
import { useConsoleLiveModeScrolling } from './useConsoleLiveMode';
|
|
8
|
+
import Autosizer from 'react-virtualized-auto-sizer';
|
|
9
|
+
import { AiOutlineDelete as ClearIcon } from 'react-icons/ai';
|
|
10
|
+
import { Button } from '../../../components';
|
|
11
|
+
import { GUTTER_SIZE, LIST_PADDING_SIZE, DEFAULT_LINE_HEIGHT } from './constants';
|
|
12
|
+
|
|
13
|
+
interface RowState {
|
|
14
|
+
height: number;
|
|
15
|
+
collapsed: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ConsoleProps {
|
|
19
|
+
// This should spit out messages of the format Message and add it using the setter.
|
|
20
|
+
listenerFactory: () => {
|
|
21
|
+
on: () => void;
|
|
22
|
+
off: () => void;
|
|
23
|
+
};
|
|
24
|
+
messages: Message[];
|
|
25
|
+
setMessages: Dispatch<SetStateAction<Message[]>>;
|
|
26
|
+
onExecuteCommand: (command: string) => Promise<Message>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Console: FC<ConsoleProps> = ({ listenerFactory, onExecuteCommand, setMessages, messages }) => {
|
|
30
|
+
const rowHeights = useRef<RowState[]>([]);
|
|
31
|
+
|
|
32
|
+
const { consoleMessagesBoxRef, isLiveModeEnabled, setIsLiveModeEnabled, toggleLiveModeOnConsoleScroll } =
|
|
33
|
+
useConsoleLiveModeScrolling(messages);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const { on, off } = listenerFactory();
|
|
37
|
+
on();
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
off();
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const getRowHeight = (index: number) => {
|
|
45
|
+
if (rowHeights.current && rowHeights.current[index]) {
|
|
46
|
+
return rowHeights.current[index].height + GUTTER_SIZE || DEFAULT_LINE_HEIGHT;
|
|
47
|
+
}
|
|
48
|
+
return DEFAULT_LINE_HEIGHT;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const setRowState = (index: number, height: number, collapsed: boolean) => {
|
|
52
|
+
if (consoleMessagesBoxRef.current) {
|
|
53
|
+
consoleMessagesBoxRef.current.resetAfterIndex(index);
|
|
54
|
+
}
|
|
55
|
+
rowHeights.current = {
|
|
56
|
+
...rowHeights.current,
|
|
57
|
+
[index]: { height, collapsed },
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// this is required so that react-window knows the padding of the element
|
|
62
|
+
// again, react-window does not have types, cba to type this.
|
|
63
|
+
//
|
|
64
|
+
const InnerElementType = forwardRef<HTMLDivElement, any>(function InnerConsole({ style, ...rest }, ref) {
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
ref={ref}
|
|
68
|
+
style={{
|
|
69
|
+
...style,
|
|
70
|
+
height: `${style.height + LIST_PADDING_SIZE * 2}px`,
|
|
71
|
+
paddingTop: `${GUTTER_SIZE}px`,
|
|
72
|
+
}}
|
|
73
|
+
{...rest}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Wrapper>
|
|
80
|
+
<Header>
|
|
81
|
+
<Button onClick={() => setIsLiveModeEnabled(true)} disabled={isLiveModeEnabled}>
|
|
82
|
+
Follow
|
|
83
|
+
</Button>
|
|
84
|
+
<Button onClick={() => setMessages([])} color="background" icon={<ClearIcon />}>
|
|
85
|
+
Clear
|
|
86
|
+
</Button>
|
|
87
|
+
</Header>
|
|
88
|
+
<MessageContainer>
|
|
89
|
+
<Autosizer>
|
|
90
|
+
{({ width, height }: { width: number | undefined; height: number | undefined }) => {
|
|
91
|
+
if (width == undefined || height == undefined) {
|
|
92
|
+
return <>Could not render list</>;
|
|
93
|
+
}
|
|
94
|
+
return (
|
|
95
|
+
<VariableSizeList
|
|
96
|
+
itemCount={messages.length}
|
|
97
|
+
itemSize={getRowHeight}
|
|
98
|
+
itemData={messages}
|
|
99
|
+
width={width}
|
|
100
|
+
height={height}
|
|
101
|
+
onScroll={toggleLiveModeOnConsoleScroll}
|
|
102
|
+
innerElementType={InnerElementType}
|
|
103
|
+
ref={consoleMessagesBoxRef}
|
|
104
|
+
>
|
|
105
|
+
{({ data, index, style }) => {
|
|
106
|
+
return (
|
|
107
|
+
<ConsoleLine
|
|
108
|
+
key={`console-line-${index}`}
|
|
109
|
+
index={index}
|
|
110
|
+
message={data[index]}
|
|
111
|
+
style={style}
|
|
112
|
+
collapsed={rowHeights.current[index] ? rowHeights.current[index].collapsed : false}
|
|
113
|
+
setRowState={setRowState}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}}
|
|
117
|
+
</VariableSizeList>
|
|
118
|
+
);
|
|
119
|
+
}}
|
|
120
|
+
</Autosizer>
|
|
121
|
+
</MessageContainer>
|
|
122
|
+
<ConsoleInput setMessages={setMessages} onExecuteCommand={onExecuteCommand} />
|
|
123
|
+
</Wrapper>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ChangeEvent, useRef, KeyboardEvent, Dispatch, FC, SetStateAction, useState } from 'react';
|
|
2
|
+
import { Message } from '../MessageModel';
|
|
3
|
+
import { Container, StyledEnterIcon } from './style';
|
|
4
|
+
import { useSnackbar } from 'notistack';
|
|
5
|
+
|
|
6
|
+
export interface ConsoleInputProps {
|
|
7
|
+
setMessages: Dispatch<SetStateAction<Message[]>>;
|
|
8
|
+
onExecuteCommand: (command: string) => Promise<Message>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ConsoleInput: FC<ConsoleInputProps> = ({ onExecuteCommand, setMessages }) => {
|
|
12
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
13
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
14
|
+
const [input, setInput] = useState('');
|
|
15
|
+
const [commandHistoryIndex, setCommandHistoryIndex] = useState(-1);
|
|
16
|
+
|
|
17
|
+
async function executeCommand() {
|
|
18
|
+
if (input != '') {
|
|
19
|
+
try {
|
|
20
|
+
const message = await onExecuteCommand(input);
|
|
21
|
+
setMessages((prev: Message[]) => [...prev, message]);
|
|
22
|
+
|
|
23
|
+
const commandHistory = JSON.parse(localStorage.getItem('commandHistory') || '[]');
|
|
24
|
+
commandHistory.unshift(input);
|
|
25
|
+
if (commandHistory.length > 50) {
|
|
26
|
+
commandHistory.pop();
|
|
27
|
+
}
|
|
28
|
+
localStorage.setItem('commandHistory', JSON.stringify(commandHistory));
|
|
29
|
+
setCommandHistoryIndex(-1);
|
|
30
|
+
} catch {
|
|
31
|
+
enqueueSnackbar('Something went wrong while executing your command.', {
|
|
32
|
+
variant: 'default',
|
|
33
|
+
type: 'error',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
40
|
+
setInput(e.target.value);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const handleOnKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
44
|
+
if (e.key === 'Enter') {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
executeCommand();
|
|
47
|
+
setInput('');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const commandHistory = JSON.parse(localStorage.getItem('commandHistory') || '[]');
|
|
52
|
+
|
|
53
|
+
if (e.key === 'ArrowUp') {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
if (commandHistoryIndex >= -1 && commandHistoryIndex < commandHistory.length) {
|
|
56
|
+
setCommandHistoryIndex((prevIndex) => prevIndex + 1); // move backwards in command history
|
|
57
|
+
setInput(commandHistory[commandHistoryIndex + 1]);
|
|
58
|
+
}
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (e.key === 'ArrowDown') {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
if (commandHistoryIndex > 0) {
|
|
65
|
+
setCommandHistoryIndex((prevIndex) => prevIndex - 1); // move forward in command history
|
|
66
|
+
setInput(commandHistory[commandHistoryIndex - 1]);
|
|
67
|
+
} else if (commandHistoryIndex === 0) {
|
|
68
|
+
setCommandHistoryIndex(-1);
|
|
69
|
+
setInput(''); // Clear input if moving beyond available commands
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Container>
|
|
77
|
+
<input
|
|
78
|
+
placeholder="Type here to execute a command.."
|
|
79
|
+
onChange={handleOnChange}
|
|
80
|
+
onKeyDown={handleOnKeyDown}
|
|
81
|
+
value={input}
|
|
82
|
+
ref={inputRef}
|
|
83
|
+
/>
|
|
84
|
+
<StyledEnterIcon fill="white" onClick={executeCommand} />
|
|
85
|
+
</Container>
|
|
86
|
+
);
|
|
87
|
+
};
|