@takaro/lib-components 0.0.1
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 +76 -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 +170 -0
- package/src/components/actions/Button/Button.test.tsx +7 -0
- package/src/components/actions/Button/Button.test.tsx.snap +89 -0
- package/src/components/actions/Button/index.tsx +99 -0
- package/src/components/actions/Button/style.ts +148 -0
- package/src/components/actions/ContextMenu/ContextMenu.stories.tsx +40 -0
- package/src/components/actions/ContextMenu/Group.tsx +34 -0
- package/src/components/actions/ContextMenu/MenuItem.tsx +66 -0
- package/src/components/actions/ContextMenu/index.tsx +217 -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 +67 -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 +89 -0
- package/src/components/actions/Dropdown/index.tsx +22 -0
- package/src/components/actions/Dropdown/useDropdown.tsx +82 -0
- package/src/components/actions/DropdownButton/DropdownButton.stories.tsx +88 -0
- package/src/components/actions/DropdownButton/index.tsx +113 -0
- package/src/components/actions/IconButton/IconButton.stories.tsx +54 -0
- package/src/components/actions/IconButton/IconButton.test.tsx +7 -0
- package/src/components/actions/IconButton/IconButton.test.tsx.snap +46 -0
- package/src/components/actions/IconButton/index.tsx +40 -0
- package/src/components/actions/IconButton/style.ts +75 -0
- package/src/components/actions/ToggleButton/ToggleButton.stories.tsx +84 -0
- package/src/components/actions/ToggleButton/ToggleButton.tsx +48 -0
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +99 -0
- package/src/components/actions/ToggleButton/index.tsx +2 -0
- package/src/components/actions/ToggleButton/style.ts +76 -0
- package/src/components/actions/index.ts +16 -0
- package/src/components/charts/AreaChart/AreaChart.stories.tsx +104 -0
- package/src/components/charts/AreaChart/index.tsx +379 -0
- package/src/components/charts/BarChart/BarChart.stories.tsx +32 -0
- package/src/components/charts/BarChart/index.tsx +287 -0
- package/src/components/charts/BrushHandle.tsx +21 -0
- package/src/components/charts/GeoMercator/GeoMercator.stories.tsx +65 -0
- package/src/components/charts/GeoMercator/index.tsx +141 -0
- package/src/components/charts/GeoMercator/world.d.ts +1 -0
- package/src/components/charts/GeoMercator/world.json +99485 -0
- package/src/components/charts/Heatmap/Heatmap.stories.tsx +55 -0
- package/src/components/charts/Heatmap/index.tsx +228 -0
- package/src/components/charts/LineChart/LineChart.stories.tsx +37 -0
- package/src/components/charts/LineChart/index.tsx +233 -0
- package/src/components/charts/PieChart/PieChart.stories.tsx +43 -0
- package/src/components/charts/PieChart/index.tsx +163 -0
- package/src/components/charts/PointHighlight.tsx +49 -0
- package/src/components/charts/RadarChart/RadarChart.stories.tsx +38 -0
- package/src/components/charts/RadarChart/generators.ts +30 -0
- package/src/components/charts/RadarChart/index.tsx +175 -0
- package/src/components/charts/RadialBarChart/RadialBarChart.stories.tsx +34 -0
- package/src/components/charts/RadialBarChart/index.tsx +165 -0
- package/src/components/charts/RadialLineChart/RadialLineChart.stories.tsx +26 -0
- package/src/components/charts/RadialLineChart/index.tsx +141 -0
- package/src/components/charts/index.tsx +20 -0
- package/src/components/charts/useGradients.tsx +37 -0
- package/src/components/charts/util.ts +40 -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 +132 -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 +7 -0
- package/src/components/data/Chip/Chip.test.tsx.snap +50 -0
- package/src/components/data/Chip/index.tsx +76 -0
- package/src/components/data/Chip/style.ts +84 -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/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 +38 -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 +144 -0
- package/src/components/data/Drawer/DrawerBody.tsx +22 -0
- package/src/components/data/Drawer/DrawerContent.tsx +110 -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 +49 -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 +52 -0
- package/src/components/data/InfiniteScroll/InfiniteScroll.stories.tsx +33 -0
- package/src/components/data/InfiniteScroll/index.tsx +51 -0
- package/src/components/data/LinkCard/index.tsx +28 -0
- package/src/components/data/Stats/Stat.tsx +99 -0
- package/src/components/data/Stats/Stats.stories.tsx +72 -0
- package/src/components/data/Stats/context.tsx +11 -0
- package/src/components/data/Stats/index.tsx +50 -0
- package/src/components/data/Table/Table.stories.tsx +142 -0
- package/src/components/data/Table/index.tsx +365 -0
- package/src/components/data/Table/react-table.d.ts +11 -0
- package/src/components/data/Table/style.ts +75 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +161 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +207 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +89 -0
- package/src/components/data/Table/subcomponents/ColumnVisibility/index.tsx +61 -0
- package/src/components/data/Table/subcomponents/Filter/field.tsx +129 -0
- package/src/components/data/Table/subcomponents/Filter/index.tsx +239 -0
- package/src/components/data/Table/subcomponents/Filter/style.ts +26 -0
- package/src/components/data/Table/subcomponents/Pagination/index.tsx +108 -0
- package/src/components/data/Table/subcomponents/Pagination/style.ts +49 -0
- package/src/components/data/Table/subcomponents/index.ts +4 -0
- package/src/components/data/index.ts +28 -0
- package/src/components/dialogs/Dialog/Dialog.stories.tsx +74 -0
- package/src/components/dialogs/Dialog/DialogBody.tsx +62 -0
- package/src/components/dialogs/Dialog/DialogContent.tsx +46 -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 +77 -0
- package/src/components/feedback/Alert/Alert.test.tsx +7 -0
- package/src/components/feedback/Alert/Alert.test.tsx.snap +146 -0
- package/src/components/feedback/Alert/index.tsx +109 -0
- package/src/components/feedback/Alert/style.ts +87 -0
- package/src/components/feedback/ErrorFallback/ErrorFallback.stories.tsx +10 -0
- package/src/components/feedback/ErrorFallback/index.tsx +48 -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/Loaders/Loaders.stories.tsx +28 -0
- package/src/components/feedback/Loaders/Loading.test.tsx +7 -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 +7 -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/index.ts +2 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.stories.tsx +21 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx +7 -0
- package/src/components/feedback/NetworkDetector/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 +14 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/index.tsx +79 -0
- package/src/components/feedback/Popover/Popover.stories.tsx +33 -0
- package/src/components/feedback/Popover/PopoverContent.tsx +43 -0
- package/src/components/feedback/Popover/PopoverContext.tsx +21 -0
- package/src/components/feedback/Popover/PopoverTrigger.tsx +43 -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 +103 -0
- package/src/components/feedback/QuestionTooltip/QuestionTooltip.stories.tsx +20 -0
- package/src/components/feedback/QuestionTooltip/index.tsx +36 -0
- package/src/components/feedback/Skeleton/Skeleton.stories.tsx +33 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx +7 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx.snap +35 -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 +50 -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 +79 -0
- package/src/components/feedback/index.ts +33 -0
- package/src/components/feedback/snacks/CookieConsent/index.tsx +122 -0
- package/src/components/feedback/snacks/CookieConsent/style.ts +100 -0
- package/src/components/feedback/snacks/Default/default.stories.tsx +72 -0
- package/src/components/feedback/snacks/Default/index.tsx +77 -0
- package/src/components/feedback/snacks/Default/style.ts +59 -0
- package/src/components/feedback/snacks/Drawer/Drawer.stories.tsx +46 -0
- package/src/components/feedback/snacks/Drawer/index.tsx +70 -0
- package/src/components/feedback/snacks/NetworkDetector/index.tsx +70 -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 +124 -0
- package/src/components/inputs/CheckBox/Generic.tsx +96 -0
- package/src/components/inputs/CheckBox/index.tsx +4 -0
- package/src/components/inputs/CheckBox/style.ts +113 -0
- package/src/components/inputs/CodeField/CodeField.stories.tsx +87 -0
- package/src/components/inputs/CodeField/index.tsx +173 -0
- package/src/components/inputs/CodeField/style.ts +50 -0
- package/src/components/inputs/Date/DatePicker/Controlled.tsx +101 -0
- package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +234 -0
- package/src/components/inputs/Date/DatePicker/Generic.tsx +253 -0
- package/src/components/inputs/Date/DatePicker/formats.tsx +32 -0
- package/src/components/inputs/Date/DatePicker/style.ts +43 -0
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +112 -0
- package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +32 -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/QuickSelect/index.tsx +270 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/style.ts +40 -0
- package/src/components/inputs/Date/DateRangePicker/index.tsx +134 -0
- package/src/components/inputs/Date/DateRangePicker/style.ts +51 -0
- package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +150 -0
- package/src/components/inputs/Date/subcomponents/Calendar/style.ts +59 -0
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +186 -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 +32 -0
- package/src/components/inputs/DurationField/Controlled.tsx +69 -0
- package/src/components/inputs/DurationField/Duration.stories.tsx +54 -0
- package/src/components/inputs/DurationField/Generic.tsx +200 -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 +211 -0
- package/src/components/inputs/FileField/Generic.tsx +131 -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 +61 -0
- package/src/components/inputs/RadioGroup/Controlled.tsx +46 -0
- package/src/components/inputs/RadioGroup/Generic.tsx +34 -0
- package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +116 -0
- package/src/components/inputs/RadioGroup/RadioItem.tsx +129 -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/Slider/Controlled.tsx +87 -0
- package/src/components/inputs/Slider/Generic.tsx +73 -0
- package/src/components/inputs/Slider/Slider.stories.tsx +101 -0
- package/src/components/inputs/Slider/handle.tsx +31 -0
- package/src/components/inputs/Slider/index.tsx +5 -0
- package/src/components/inputs/Slider/style.ts +140 -0
- package/src/components/inputs/Switch/Controlled.tsx +58 -0
- package/src/components/inputs/Switch/Generic.tsx +67 -0
- package/src/components/inputs/Switch/Switch.stories.tsx +91 -0
- package/src/components/inputs/Switch/index.ts +5 -0
- package/src/components/inputs/Switch/style.ts +56 -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 +56 -0
- package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +98 -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 +113 -0
- package/src/components/inputs/TextField/TextField.stories.tsx +196 -0
- package/src/components/inputs/TextField/index.ts +5 -0
- package/src/components/inputs/TextField/style.ts +97 -0
- package/src/components/inputs/TextField/util.ts +19 -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 +67 -0
- package/src/components/inputs/layout/Description.tsx +40 -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 +51 -0
- package/src/components/inputs/layout/index.ts +6 -0
- package/src/components/inputs/selects/SelectField/Controlled.tsx +130 -0
- package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +45 -0
- package/src/components/inputs/selects/SelectField/Generic/index.tsx +302 -0
- package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +253 -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 +100 -0
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +300 -0
- package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +260 -0
- package/src/components/inputs/selects/SelectQueryField/index.tsx +5 -0
- package/src/components/inputs/selects/SelectQueryField/style.ts +14 -0
- package/src/components/inputs/selects/SubComponents/Option.tsx +114 -0
- package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +16 -0
- package/src/components/inputs/selects/SubComponents/index.ts +10 -0
- package/src/components/inputs/selects/SubComponents/style.ts +39 -0
- package/src/components/inputs/selects/data.ts +123 -0
- package/src/components/inputs/selects/index.tsx +47 -0
- package/src/components/inputs/selects/sharedStyle.ts +78 -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 +45 -0
- package/src/components/navigation/HorizontalNav/index.tsx +40 -0
- package/src/components/navigation/HorizontalNav/style.ts +83 -0
- package/src/components/navigation/IconNav/IconNav.stories.tsx +46 -0
- package/src/components/navigation/IconNav/index.tsx +49 -0
- package/src/components/navigation/Steppers/SlimStepper/Stepper.stories.tsx +89 -0
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +104 -0
- package/src/components/navigation/Steppers/SlimStepper/style.ts +86 -0
- package/src/components/navigation/Steppers/Stepper/Stepper.stories.tsx +87 -0
- package/src/components/navigation/Steppers/Stepper/index.tsx +114 -0
- package/src/components/navigation/Steppers/Stepper/style.ts +105 -0
- package/src/components/navigation/Steppers/context.tsx +49 -0
- package/src/components/navigation/Steppers/reducer.ts +51 -0
- package/src/components/navigation/Steppers/stepStates.ts +5 -0
- package/src/components/navigation/Tabs/Content.tsx +36 -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 +65 -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 +16 -0
- package/src/components/other/ActionMenu/ActionMenu.stories.tsx +86 -0
- package/src/components/other/ActionMenu/index.tsx +55 -0
- package/src/components/other/ActionMenu/style.ts +48 -0
- package/src/components/other/ClipBoard/ClipBoard.stories.tsx +14 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx +7 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx.snap +70 -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 +115 -0
- package/src/components/other/Collapsible/Collapsible.stories.tsx +19 -0
- package/src/components/other/Collapsible/CollapsibleContent.tsx +22 -0
- package/src/components/other/Collapsible/CollapsibleContext.tsx +17 -0
- package/src/components/other/Collapsible/CollapsibleTrigger.tsx +67 -0
- package/src/components/other/Collapsible/index.tsx +21 -0
- package/src/components/other/Company/index.tsx +45 -0
- package/src/components/other/Company/style.ts +58 -0
- package/src/components/other/Empty/Empty.stories.tsx +24 -0
- package/src/components/other/Empty/Empty.test.tsx +7 -0
- package/src/components/other/Empty/Empty.test.tsx.snap +85 -0
- package/src/components/other/Empty/index.tsx +87 -0
- package/src/components/other/PermissionsGuard/PermissionsGuard.stories.tsx +54 -0
- package/src/components/other/PermissionsGuard/index.tsx +43 -0
- package/src/components/other/index.ts +19 -0
- package/src/components/visual/Card/Card.stories.tsx +19 -0
- package/src/components/visual/Card/index.tsx +49 -0
- package/src/components/visual/Divider/Divider.stories.tsx +19 -0
- package/src/components/visual/Divider/Divider.test.tsx +7 -0
- package/src/components/visual/Divider/Divider.test.tsx.snap +35 -0
- package/src/components/visual/Divider/index.tsx +85 -0
- package/src/components/visual/index.ts +5 -0
- package/src/errors/base.ts +11 -0
- package/src/errors/errors.ts +109 -0
- package/src/errors/index.ts +14 -0
- package/src/helpers/camelCaseToSpaces.ts +5 -0
- package/src/helpers/getInitials.ts +15 -0
- package/src/helpers/getSnackbarProvider.tsx +57 -0
- package/src/helpers/getTransition.ts +9 -0
- package/src/helpers/index.ts +5 -0
- package/src/helpers/makeData.ts +34 -0
- package/src/helpers/regexprs.ts +7 -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 +10 -0
- package/src/hooks/useLocalStorage.tsx +38 -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 +56 -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.stories.mdx +35 -0
- package/src/stories/Elevation.stories.mdx +56 -0
- package/src/stories/Introduction.stories.mdx +17 -0
- package/src/stories/Spacing.stories.mdx +25 -0
- package/src/styled/GlobalStyle.ts +207 -0
- package/src/styled/Snackbar.tsx +42 -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/elevation.ts +20 -0
- package/src/styled/index.ts +11 -0
- package/src/styled/spacing.ts +38 -0
- package/src/styled/theme.ts +87 -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 +31 -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 +19 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useContext, createContext, SetStateAction, Dispatch } from 'react';
|
|
2
|
+
import { useDrawer } from './useDrawer';
|
|
3
|
+
|
|
4
|
+
type ContextType =
|
|
5
|
+
| (ReturnType<typeof useDrawer> & {
|
|
6
|
+
setLabelId: Dispatch<SetStateAction<string | undefined>>;
|
|
7
|
+
setDescriptionId: Dispatch<SetStateAction<string | undefined>>;
|
|
8
|
+
})
|
|
9
|
+
| null;
|
|
10
|
+
|
|
11
|
+
export const DrawerContext = createContext<ContextType>(null);
|
|
12
|
+
|
|
13
|
+
export const useDrawerContext = () => {
|
|
14
|
+
const context = useContext(DrawerContext);
|
|
15
|
+
|
|
16
|
+
if (context == null) {
|
|
17
|
+
throw new Error('Dialog components must be wrapped in <Dialog />');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return context;
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
|
|
4
|
+
export const Container = styled.div`
|
|
5
|
+
/* Should match width of drawercontent */
|
|
6
|
+
width: calc(700px - 1px);
|
|
7
|
+
position: fixed;
|
|
8
|
+
bottom: 0;
|
|
9
|
+
/* should be shown above the rest of drawer (this is relative to DrawerContent) */
|
|
10
|
+
z-index: 1;
|
|
11
|
+
border-top: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
12
|
+
|
|
13
|
+
padding: ${({ theme }) => theme.spacing[2]};
|
|
14
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const DrawerFooter: FC<PropsWithChildren> = ({ children }) => {
|
|
18
|
+
return <Container>{children}</Container>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { forwardRef, HTMLProps, useId, useLayoutEffect } from 'react';
|
|
2
|
+
import { useDrawerContext } from './DrawerContext';
|
|
3
|
+
import { AiOutlineClose as CloseIcon } from 'react-icons/ai';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { IconButton, Tooltip } from '../../../components';
|
|
6
|
+
|
|
7
|
+
const Container = styled.div`
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
align-items: center;
|
|
11
|
+
margin-bottom: ${({ theme }) => theme.spacing[2]};
|
|
12
|
+
padding: ${({ theme }) => `${theme.spacing[2]} ${theme.spacing['2_5']}`};
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
interface DialogHeadingProps extends HTMLProps<HTMLHeadingElement> {
|
|
16
|
+
hasClose?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const DrawerHeading = forwardRef<HTMLHeadingElement, DialogHeadingProps>(
|
|
20
|
+
({ children, hasClose = true, ...props }, ref) => {
|
|
21
|
+
const { setLabelId, setOpen } = useDrawerContext();
|
|
22
|
+
const id = useId();
|
|
23
|
+
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
setLabelId(id);
|
|
26
|
+
return () => setLabelId(undefined);
|
|
27
|
+
}, [id, setLabelId]);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Container>
|
|
31
|
+
<h2 {...props} ref={ref} id={id}>
|
|
32
|
+
{children}
|
|
33
|
+
</h2>
|
|
34
|
+
{hasClose && (
|
|
35
|
+
<Tooltip>
|
|
36
|
+
<Tooltip.Trigger asChild>
|
|
37
|
+
<IconButton
|
|
38
|
+
onClick={() => setOpen(false)}
|
|
39
|
+
icon={<CloseIcon size={18} cursor="pointer" />}
|
|
40
|
+
ariaLabel="Close"
|
|
41
|
+
/>
|
|
42
|
+
</Tooltip.Trigger>
|
|
43
|
+
<Tooltip.Content>Close</Tooltip.Content>
|
|
44
|
+
</Tooltip>
|
|
45
|
+
)}
|
|
46
|
+
</Container>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Skeleton, Drawer } from '../../../components';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
|
|
4
|
+
const Inner = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: ${({ theme }) => theme.spacing[2]};
|
|
8
|
+
margin-top: ${({ theme }) => theme.spacing[2]};
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const DrawerSkeleton = () => {
|
|
12
|
+
return (
|
|
13
|
+
<Drawer initialOpen>
|
|
14
|
+
<Drawer.Content>
|
|
15
|
+
<Drawer.Body>
|
|
16
|
+
<Inner>
|
|
17
|
+
<Skeleton width="100%" height="8vh" variant="rectangular" />
|
|
18
|
+
<Skeleton width="100%" height="12vh" variant="rectangular" />
|
|
19
|
+
<Skeleton width="100%" height="5vh" variant="rectangular" />
|
|
20
|
+
<Skeleton width="100%" height="10vh" variant="rectangular" />
|
|
21
|
+
<Skeleton width="100%" height="15vh" variant="rectangular" />
|
|
22
|
+
<Skeleton width="100%" height="16vh" variant="rectangular" />
|
|
23
|
+
<Skeleton width="100%" height="5vh" variant="rectangular" />
|
|
24
|
+
</Inner>
|
|
25
|
+
</Drawer.Body>
|
|
26
|
+
</Drawer.Content>
|
|
27
|
+
</Drawer>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DrawerOptions, useDrawer } from './useDrawer';
|
|
2
|
+
import { FC, PropsWithChildren } from 'react';
|
|
3
|
+
import { DrawerContext } from './DrawerContext';
|
|
4
|
+
import { DrawerContent } from './DrawerContent';
|
|
5
|
+
import { DrawerHeading } from './DrawerHeading';
|
|
6
|
+
import { DrawerBody } from './DrawerBody';
|
|
7
|
+
import { DrawerFooter } from './DrawerFooter';
|
|
8
|
+
|
|
9
|
+
type SubComponentTypes = {
|
|
10
|
+
Content: typeof DrawerContent;
|
|
11
|
+
Heading: typeof DrawerHeading;
|
|
12
|
+
Body: typeof DrawerBody;
|
|
13
|
+
Footer: typeof DrawerFooter;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Drawer: FC<PropsWithChildren<DrawerOptions>> & SubComponentTypes = ({ children, ...options }) => {
|
|
17
|
+
return <DrawerContext.Provider value={useDrawer(options)}>{children}</DrawerContext.Provider>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
Drawer.Content = DrawerContent;
|
|
21
|
+
Drawer.Heading = DrawerHeading;
|
|
22
|
+
Drawer.Body = DrawerBody;
|
|
23
|
+
Drawer.Footer = DrawerFooter;
|
|
24
|
+
|
|
25
|
+
export { DrawerSkeleton } from './DrawerSkeleton';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { useClick, useDismiss, useFloating, useInteractions } from '@floating-ui/react';
|
|
3
|
+
|
|
4
|
+
export interface DrawerOptions {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
initialOpen?: boolean;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
canDrag?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useDrawer({
|
|
12
|
+
initialOpen = false,
|
|
13
|
+
canDrag = false,
|
|
14
|
+
open: controlledOpen,
|
|
15
|
+
onOpenChange: setControlledOpen,
|
|
16
|
+
}: DrawerOptions) {
|
|
17
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
18
|
+
const [labelId, setLabelId] = useState<string | undefined>();
|
|
19
|
+
const [descriptionId, setDescriptionId] = useState<string | undefined>();
|
|
20
|
+
|
|
21
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
22
|
+
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
23
|
+
|
|
24
|
+
const data = useFloating({
|
|
25
|
+
open,
|
|
26
|
+
onOpenChange: setOpen,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const context = data.context;
|
|
30
|
+
|
|
31
|
+
const interactions = useInteractions([
|
|
32
|
+
useClick(context, {
|
|
33
|
+
enabled: controlledOpen == null,
|
|
34
|
+
}),
|
|
35
|
+
useDismiss(context, { outsidePressEvent: 'mousedown' }),
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
return useMemo(
|
|
39
|
+
() => ({
|
|
40
|
+
open,
|
|
41
|
+
setOpen,
|
|
42
|
+
...interactions,
|
|
43
|
+
...data,
|
|
44
|
+
labelId,
|
|
45
|
+
descriptionId,
|
|
46
|
+
setLabelId,
|
|
47
|
+
setDescriptionId,
|
|
48
|
+
canDrag,
|
|
49
|
+
}),
|
|
50
|
+
[open, setOpen, interactions, data, labelId, descriptionId]
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { InfiniteScroll, InfiniteScrollProps } from '.';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
|
|
6
|
+
const Wrapper = styled.div`
|
|
7
|
+
height: 100vh;
|
|
8
|
+
overflow: scroll;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const Filler = styled.div`
|
|
12
|
+
height: 100vh;
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'Data/InfiniteScroll',
|
|
17
|
+
component: InfiniteScroll,
|
|
18
|
+
args: {
|
|
19
|
+
hasNextPage: true,
|
|
20
|
+
isFetching: false,
|
|
21
|
+
isFetchingNextPage: false,
|
|
22
|
+
fetchNextPage: () => {},
|
|
23
|
+
},
|
|
24
|
+
} as Meta<InfiniteScrollProps>;
|
|
25
|
+
|
|
26
|
+
export const Default: StoryFn<InfiniteScrollProps> = (args) => {
|
|
27
|
+
return (
|
|
28
|
+
<Wrapper>
|
|
29
|
+
<Filler />
|
|
30
|
+
<InfiniteScroll {...args} />
|
|
31
|
+
</Wrapper>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { forwardRef, useEffect } from 'react';
|
|
2
|
+
import { useInView } from 'react-intersection-observer';
|
|
3
|
+
import { useMergeRefs } from '@floating-ui/react';
|
|
4
|
+
import { Button, Spinner } from '../../../components';
|
|
5
|
+
|
|
6
|
+
export interface InfiniteScrollProps {
|
|
7
|
+
isFetchingNextPage: boolean;
|
|
8
|
+
fetchNextPage: () => void;
|
|
9
|
+
isFetching: boolean;
|
|
10
|
+
hasNextPage?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const InfiniteScroll = forwardRef<HTMLElement, InfiniteScrollProps>(
|
|
14
|
+
({ hasNextPage = false, fetchNextPage, isFetching, isFetchingNextPage }, propRef) => {
|
|
15
|
+
const { ref: viewRef, inView } = useInView();
|
|
16
|
+
const ref = useMergeRefs([propRef, viewRef]);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (inView) {
|
|
20
|
+
fetchNextPage();
|
|
21
|
+
}
|
|
22
|
+
}, [inView]);
|
|
23
|
+
|
|
24
|
+
// Fallback: sometimes the inView event does not trigger automatically.
|
|
25
|
+
// the user will have to manually click the button to fetch the next page.
|
|
26
|
+
const handleOnClick = () => {
|
|
27
|
+
fetchNextPage();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{!isFetchingNextPage && hasNextPage && !isFetching && (
|
|
33
|
+
<div
|
|
34
|
+
ref={ref}
|
|
35
|
+
style={{ display: 'flex', height: '100%', width: '100%', justifyContent: 'center', alignItems: 'center' }}
|
|
36
|
+
>
|
|
37
|
+
<Button text="Load more" ref={ref} onClick={handleOnClick} />
|
|
38
|
+
</div>
|
|
39
|
+
)}
|
|
40
|
+
{hasNextPage && isFetchingNextPage && (
|
|
41
|
+
<div
|
|
42
|
+
ref={ref}
|
|
43
|
+
style={{ display: 'flex', height: '100%', width: '100%', justifyContent: 'center', alignItems: 'center' }}
|
|
44
|
+
>
|
|
45
|
+
<Spinner size="medium" />
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FC, ReactElement } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
import { AiOutlineLink as LinkIcon } from 'react-icons/ai';
|
|
4
|
+
import { FiExternalLink as ExternalLinkIcon } from 'react-icons/fi';
|
|
5
|
+
|
|
6
|
+
const Container = styled.li`
|
|
7
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
8
|
+
border: 1px solid ${({ theme }) => theme.colors.secondary};
|
|
9
|
+
padding: ${({ theme }) => theme.spacing['1']};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export interface LinkCardProps {
|
|
13
|
+
icon?: ReactElement;
|
|
14
|
+
label: string;
|
|
15
|
+
href: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const LinkCard: FC<LinkCardProps> = ({ label, href, icon }) => {
|
|
19
|
+
return (
|
|
20
|
+
<Container>
|
|
21
|
+
{icon || <LinkIcon />}
|
|
22
|
+
<span>{label}</span>
|
|
23
|
+
<a href={href}>
|
|
24
|
+
<ExternalLinkIcon />
|
|
25
|
+
</a>
|
|
26
|
+
</Container>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { FC, useContext } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
import { StatContext, Direction } from './context';
|
|
4
|
+
|
|
5
|
+
const Container = styled.div<{ hasBorder: boolean; direction: Direction }>`
|
|
6
|
+
background-color: ${({ theme }) => theme.colors.backgroundAlt};
|
|
7
|
+
padding: ${({ theme }) => theme.spacing['2']};
|
|
8
|
+
|
|
9
|
+
${({ hasBorder, direction, theme }) => {
|
|
10
|
+
if (hasBorder) {
|
|
11
|
+
if (direction === 'vertical') {
|
|
12
|
+
return `
|
|
13
|
+
&:not(:last-child) {
|
|
14
|
+
border-bottom: 1px solid ${theme.colors.secondary};
|
|
15
|
+
}
|
|
16
|
+
&:first-child {
|
|
17
|
+
border-top-left-radius: ${theme.borderRadius.medium};
|
|
18
|
+
border-top-right-radius: ${theme.borderRadius.medium};
|
|
19
|
+
}
|
|
20
|
+
&:last-child {
|
|
21
|
+
border-bottom-left-radius: ${theme.borderRadius.medium};
|
|
22
|
+
border-bottom-right-radius: ${theme.borderRadius.medium};
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
} else if (direction === 'horizontal') {
|
|
26
|
+
return `
|
|
27
|
+
&:not(:last-child) {
|
|
28
|
+
border-right: 1px solid ${theme.colors.secondary};
|
|
29
|
+
}
|
|
30
|
+
&:first-child {
|
|
31
|
+
border-top-left-radius: ${theme.borderRadius.medium};
|
|
32
|
+
border-bottom-left-radius: ${theme.borderRadius.medium};
|
|
33
|
+
}
|
|
34
|
+
&:last-child {
|
|
35
|
+
border-top-right-radius: ${theme.borderRadius.medium};
|
|
36
|
+
border-bottom-right-radius: ${theme.borderRadius.medium};
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
return `
|
|
42
|
+
border-radius: ${theme.borderRadius.medium};
|
|
43
|
+
border: 1px solid ${theme.colors.secondary};
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
}};
|
|
47
|
+
|
|
48
|
+
dt {
|
|
49
|
+
font-size: ${({ theme }) => theme.fontSize.medium};
|
|
50
|
+
font-color: ${({ theme }) => theme.colors.secondary};
|
|
51
|
+
margin-bottom: ${({ theme }) => theme.spacing['0_5']};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
dd {
|
|
55
|
+
font-weight: bold;
|
|
56
|
+
color: ${({ theme }) => theme.colors.white};
|
|
57
|
+
font-size: ${({ theme }) => theme.fontSize.mediumLarge};
|
|
58
|
+
letter-spacing: 1px;
|
|
59
|
+
margin: 0;
|
|
60
|
+
padding: 0;
|
|
61
|
+
|
|
62
|
+
&.placeholder {
|
|
63
|
+
min-width: 80%;
|
|
64
|
+
min-height: 25px;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export interface StatProps {
|
|
70
|
+
description: string;
|
|
71
|
+
value: string;
|
|
72
|
+
// TODO: Add icon support when needed
|
|
73
|
+
// icon?: ReactNode
|
|
74
|
+
isLoading?: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const Stat: FC<StatProps> = ({ description, value, isLoading }) => {
|
|
78
|
+
const { border, direction } = useContext(StatContext);
|
|
79
|
+
|
|
80
|
+
if (isLoading) {
|
|
81
|
+
return (
|
|
82
|
+
<Container hasBorder={border} direction={direction}>
|
|
83
|
+
<div>
|
|
84
|
+
<dt>{description}</dt>
|
|
85
|
+
<dd className="placeholder"></dd>
|
|
86
|
+
</div>
|
|
87
|
+
</Container>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Container hasBorder={border} direction={direction}>
|
|
93
|
+
<div>
|
|
94
|
+
<dt>{description}</dt>
|
|
95
|
+
<dd>{value}</dd>
|
|
96
|
+
</div>
|
|
97
|
+
</Container>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Stats, StatsProps } from '../../../components';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Data/Stat',
|
|
7
|
+
component: Stats,
|
|
8
|
+
args: {
|
|
9
|
+
direction: 'horizontal',
|
|
10
|
+
border: false,
|
|
11
|
+
},
|
|
12
|
+
} as Meta<StatsProps>;
|
|
13
|
+
|
|
14
|
+
export const HorizontalWithBorder: StoryFn<StatsProps> = () => {
|
|
15
|
+
return (
|
|
16
|
+
<div style={{ width: '1000px' }}>
|
|
17
|
+
<Stats direction="horizontal" border>
|
|
18
|
+
<Stats.Stat description="Credits" value="$0.00" />
|
|
19
|
+
<Stats.Stat description="Current month so far" value="$0.00" />
|
|
20
|
+
<Stats.Stat description="Last invoice" value="$0.00" />
|
|
21
|
+
</Stats>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const HorizontalWithoutBorder: StoryFn<StatsProps> = () => {
|
|
27
|
+
return (
|
|
28
|
+
<div style={{ width: '1000px' }}>
|
|
29
|
+
<Stats direction="horizontal" border={false}>
|
|
30
|
+
<Stats.Stat description="Credits" value="$0.00" />
|
|
31
|
+
<Stats.Stat description="Current month so far" value="$0.00" />
|
|
32
|
+
<Stats.Stat description="Last invoice" value="$0.00" />
|
|
33
|
+
</Stats>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const VerticalWithBorder: StoryFn<StatsProps> = () => {
|
|
39
|
+
return (
|
|
40
|
+
<div style={{ width: '300px' }}>
|
|
41
|
+
<Stats direction="vertical" border>
|
|
42
|
+
<Stats.Stat description="Credits" value="$0.00" />
|
|
43
|
+
<Stats.Stat description="Current month so far" value="$0.00" />
|
|
44
|
+
<Stats.Stat description="Last invoice" value="$0.00" />
|
|
45
|
+
</Stats>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const VerticalWithoutBorder: StoryFn<StatsProps> = () => {
|
|
51
|
+
return (
|
|
52
|
+
<div style={{ width: '300px' }}>
|
|
53
|
+
<Stats direction="vertical" border={false}>
|
|
54
|
+
<Stats.Stat description="Credits" value="$0.00" />
|
|
55
|
+
<Stats.Stat description="Current month so far" value="$0.00" />
|
|
56
|
+
<Stats.Stat description="Last invoice" value="$0.00" />
|
|
57
|
+
</Stats>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const LoadingWithoutBorder: StoryFn<StatsProps> = (args) => {
|
|
63
|
+
return (
|
|
64
|
+
<div style={{ width: '700px' }}>
|
|
65
|
+
<Stats direction={args.direction} border={args.border}>
|
|
66
|
+
<Stats.Stat isLoading description="Credits" value="$0.00" />
|
|
67
|
+
<Stats.Stat description="Current month so far" value="$0.00" />
|
|
68
|
+
<Stats.Stat description="Last invoice" value="$0.00" />
|
|
69
|
+
</Stats>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export type Direction = 'horizontal' | 'vertical';
|
|
4
|
+
|
|
5
|
+
interface StatsContextValue {
|
|
6
|
+
border: boolean;
|
|
7
|
+
direction: Direction;
|
|
8
|
+
// TODO: size?: Size;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const StatContext = createContext<StatsContextValue>(null as any);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FC, PropsWithChildren, Children, isValidElement } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
import { Stat } from './Stat';
|
|
4
|
+
import { StatContext, Direction } from './context';
|
|
5
|
+
|
|
6
|
+
export const Container = styled.dl<{ direction: Direction; border: boolean; count: number }>`
|
|
7
|
+
display: grid;
|
|
8
|
+
${({ direction, count }) => {
|
|
9
|
+
return direction === 'horizontal'
|
|
10
|
+
? `grid-template-columns: repeat(${count},1fr)`
|
|
11
|
+
: `grid-template-rows: repeat(${count},1fr)`;
|
|
12
|
+
}};
|
|
13
|
+
border: ${({ border, theme }) => (border ? `1px solid ${theme.colors.secondary}` : 'none')};
|
|
14
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
15
|
+
gap: ${({ theme, direction }) => (direction === 'vertical' ? theme.spacing['2'] : 0)}
|
|
16
|
+
${({ theme, direction }) => (direction === 'horizontal' ? theme.spacing['2'] : 0)};
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export interface StatsProps {
|
|
20
|
+
direction?: Direction;
|
|
21
|
+
border: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface SubComponents {
|
|
25
|
+
Stat: typeof Stat;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const Stats: FC<PropsWithChildren<StatsProps>> & SubComponents = ({
|
|
29
|
+
direction = 'vertical',
|
|
30
|
+
border,
|
|
31
|
+
children,
|
|
32
|
+
}) => {
|
|
33
|
+
// throw error if child is not a Stat component
|
|
34
|
+
Children.forEach(children, (child) => {
|
|
35
|
+
if (!isValidElement(child)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (child.type !== Stat) {
|
|
39
|
+
throw new Error(`Stats component only accepts Stat components as children. Received ${child.type} instead.`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Container direction={direction} border={border} count={Children.count(children)}>
|
|
45
|
+
<StatContext.Provider value={{ border, direction }}>{children}</StatContext.Provider>
|
|
46
|
+
</Container>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
Stats.Stat = Stat;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React, { FC, useEffect } from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Table, TableProps } from '.';
|
|
5
|
+
import { createColumnHelper } from '@tanstack/react-table';
|
|
6
|
+
import { Chip } from '../../../components';
|
|
7
|
+
import { useTableActions } from '../../../hooks';
|
|
8
|
+
|
|
9
|
+
type User = {
|
|
10
|
+
firstName: string;
|
|
11
|
+
lastName: string;
|
|
12
|
+
age: number;
|
|
13
|
+
visits: number;
|
|
14
|
+
status: string;
|
|
15
|
+
progress: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const data: User[] = [
|
|
19
|
+
{
|
|
20
|
+
firstName: 'John',
|
|
21
|
+
lastName: 'Doe',
|
|
22
|
+
age: 32,
|
|
23
|
+
visits: 32,
|
|
24
|
+
status: 'complicated',
|
|
25
|
+
progress: 66,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
firstName: 'Jane',
|
|
29
|
+
lastName: 'Doe',
|
|
30
|
+
age: 30,
|
|
31
|
+
visits: 30,
|
|
32
|
+
status: 'single',
|
|
33
|
+
progress: 100,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
firstName: 'Sam',
|
|
37
|
+
lastName: 'Doe',
|
|
38
|
+
age: 28,
|
|
39
|
+
visits: 28,
|
|
40
|
+
status: 'married',
|
|
41
|
+
progress: 0,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
firstName: 'Sally',
|
|
45
|
+
lastName: 'Doe',
|
|
46
|
+
age: 26,
|
|
47
|
+
visits: 26,
|
|
48
|
+
status: 'single',
|
|
49
|
+
progress: 100,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
firstName: 'Bob',
|
|
53
|
+
lastName: 'Doe',
|
|
54
|
+
age: 24,
|
|
55
|
+
visits: 24,
|
|
56
|
+
status: 'single',
|
|
57
|
+
progress: 100,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
firstName: 'Barbara',
|
|
61
|
+
lastName: 'Doe',
|
|
62
|
+
age: 22,
|
|
63
|
+
visits: 22,
|
|
64
|
+
status: 'single',
|
|
65
|
+
progress: 100,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const columnHelper = createColumnHelper<User>();
|
|
70
|
+
const columns = [
|
|
71
|
+
columnHelper.accessor('firstName', {
|
|
72
|
+
id: 'firstName',
|
|
73
|
+
header: 'First Name',
|
|
74
|
+
cell: (info) => info.getValue(),
|
|
75
|
+
}),
|
|
76
|
+
columnHelper.accessor('lastName', {
|
|
77
|
+
id: 'lastName',
|
|
78
|
+
header: 'Last Name',
|
|
79
|
+
cell: (info) => <i>{info.getValue()}</i>,
|
|
80
|
+
}),
|
|
81
|
+
columnHelper.accessor('age', {
|
|
82
|
+
id: 'age',
|
|
83
|
+
header: 'Age',
|
|
84
|
+
cell: (info) => info.renderValue(),
|
|
85
|
+
}),
|
|
86
|
+
columnHelper.accessor('visits', {
|
|
87
|
+
id: 'visits',
|
|
88
|
+
header: 'Visits',
|
|
89
|
+
}),
|
|
90
|
+
columnHelper.accessor('status', {
|
|
91
|
+
id: 'status',
|
|
92
|
+
header: 'Status',
|
|
93
|
+
cell: (info) => <Chip variant="outline" color="primary" label={info.getValue()} />,
|
|
94
|
+
}),
|
|
95
|
+
columnHelper.accessor('progress', {
|
|
96
|
+
id: 'progress',
|
|
97
|
+
header: 'Profile Progress',
|
|
98
|
+
}),
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
export default {
|
|
102
|
+
title: 'Data/Table',
|
|
103
|
+
component: Table,
|
|
104
|
+
args: {
|
|
105
|
+
sort: false,
|
|
106
|
+
refetching: true,
|
|
107
|
+
isLoading: false,
|
|
108
|
+
},
|
|
109
|
+
} as Meta<TableProps<User>>;
|
|
110
|
+
|
|
111
|
+
const Users: FC<TableProps<User>> = (args) => {
|
|
112
|
+
const { pagination, sorting, columnSearch, columnFilters, rowSelection } = useTableActions<User>();
|
|
113
|
+
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
pagination.setPaginationState({
|
|
116
|
+
...pagination.paginationState,
|
|
117
|
+
pageSize: 1,
|
|
118
|
+
});
|
|
119
|
+
}, []);
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Table
|
|
123
|
+
id="story-table"
|
|
124
|
+
data={data}
|
|
125
|
+
columns={columns}
|
|
126
|
+
pagination={{
|
|
127
|
+
...pagination,
|
|
128
|
+
pageOptions: {
|
|
129
|
+
pageCount: 10,
|
|
130
|
+
total: 20,
|
|
131
|
+
},
|
|
132
|
+
}}
|
|
133
|
+
isLoading={args.isLoading}
|
|
134
|
+
columnFiltering={columnFilters}
|
|
135
|
+
columnSearch={columnSearch}
|
|
136
|
+
rowSelection={rowSelection}
|
|
137
|
+
sorting={sorting}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const TableExample: StoryFn<TableProps<User>> = (args) => <Users {...args} />;
|