@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,37 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
|
|
4
|
+
const Container = styled.div<{ divider: boolean; hasChildren: boolean }>`
|
|
5
|
+
padding-bottom: ${({ theme }) => theme.spacing['0_5']};
|
|
6
|
+
border-bottom: ${({ divider, theme, hasChildren }) =>
|
|
7
|
+
divider && hasChildren && `2px solid ${theme.colors.backgroundAccent}`};
|
|
8
|
+
margin-bottom: ${({ divider, theme, hasChildren }) => divider && hasChildren && theme.spacing['0_5']};
|
|
9
|
+
padding-left: 0;
|
|
10
|
+
|
|
11
|
+
& > span {
|
|
12
|
+
opacity: 0.5;
|
|
13
|
+
padding-left: ${({ theme }) => theme.spacing[1]};
|
|
14
|
+
font-weight: 600;
|
|
15
|
+
font-size: ${({ theme }) => theme.fontSize.tiny};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:last-child {
|
|
19
|
+
border-bottom: none;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
interface DropdownGroupProps {
|
|
24
|
+
label?: string;
|
|
25
|
+
divider?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const DropdownMenuGroup: FC<PropsWithChildren<DropdownGroupProps>> = ({ label, divider = false, children }) => {
|
|
29
|
+
const showDivider = divider || label ? true : false;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Container role="group" divider={showDivider} hasChildren={Array.isArray(children) ? children.length !== 0 : true}>
|
|
33
|
+
{label && <span role="presentation">{label}</span>}
|
|
34
|
+
{children}
|
|
35
|
+
</Container>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useListItem } from '@floating-ui/react';
|
|
2
|
+
import { cloneElement, FC, ReactElement, MouseEvent } from 'react';
|
|
3
|
+
import { useDropdownContext } from './DropdownContext';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { AiOutlineClose as UndoIcon, AiOutlineCheck as CheckmarkIcon } from 'react-icons/ai';
|
|
6
|
+
import { motion } from 'framer-motion';
|
|
7
|
+
import { GenericCheckBox } from '../../../components/inputs/CheckBox/Generic';
|
|
8
|
+
|
|
9
|
+
const Container = styled(motion.button)<{ isActive: boolean }>`
|
|
10
|
+
background-color: ${({ theme, isActive }) => (isActive ? theme.colors.secondary : theme.colors.background)};
|
|
11
|
+
color: ${({ theme }) => theme.colors.text};
|
|
12
|
+
border-radius: 0;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: flex-start;
|
|
16
|
+
width: 100%;
|
|
17
|
+
padding: ${({ theme }) => `${theme.spacing['0_75']} ${theme.spacing['0_75']}`};
|
|
18
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
19
|
+
|
|
20
|
+
span {
|
|
21
|
+
margin-left: ${({ theme }) => theme.spacing['0_75']};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:disabled {
|
|
25
|
+
span {
|
|
26
|
+
color: ${({ theme }) => theme.colors.textAlt};
|
|
27
|
+
}
|
|
28
|
+
svg {
|
|
29
|
+
fill: ${({ theme }) => theme.colors.textAlt};
|
|
30
|
+
stroke: ${({ theme }) => theme.colors.textAlt};
|
|
31
|
+
}
|
|
32
|
+
cursor: not-allowed;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
background-color: ${({ theme }) => theme.colors.secondary};
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
interface DropdownMenuItemProps {
|
|
41
|
+
label: string;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
icon?: ReactElement;
|
|
44
|
+
iconPosition?: 'left' | 'right';
|
|
45
|
+
onClick: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
46
|
+
active?: boolean;
|
|
47
|
+
activeStyle?: 'checkbox' | 'undo' | 'checkmark';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const DropdownMenuItem: FC<DropdownMenuItemProps> = ({
|
|
51
|
+
label,
|
|
52
|
+
disabled,
|
|
53
|
+
onClick,
|
|
54
|
+
iconPosition = 'left',
|
|
55
|
+
activeStyle = 'undo',
|
|
56
|
+
active = false,
|
|
57
|
+
icon,
|
|
58
|
+
}) => {
|
|
59
|
+
const { activeIndex, setOpen, getItemProps } = useDropdownContext();
|
|
60
|
+
const { ref, index } = useListItem();
|
|
61
|
+
|
|
62
|
+
const isActive = activeIndex === index;
|
|
63
|
+
|
|
64
|
+
const getIcon = () => {
|
|
65
|
+
if (icon) return cloneElement(icon, { size: 17 });
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
69
|
+
onClick(e);
|
|
70
|
+
|
|
71
|
+
if (activeStyle === 'undo') {
|
|
72
|
+
setOpen(false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const handleMouseUp = () => {
|
|
77
|
+
if (activeStyle === 'undo') {
|
|
78
|
+
setOpen(false);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Container
|
|
84
|
+
type="button"
|
|
85
|
+
onClick={handleClick}
|
|
86
|
+
onMouseUp={handleMouseUp}
|
|
87
|
+
isActive={isActive}
|
|
88
|
+
ref={ref}
|
|
89
|
+
tabIndex={disabled ? -1 : 0}
|
|
90
|
+
role="menuitem"
|
|
91
|
+
disabled={disabled}
|
|
92
|
+
{...getItemProps({
|
|
93
|
+
onClick: handleClick,
|
|
94
|
+
onMouseUp: handleMouseUp,
|
|
95
|
+
})}
|
|
96
|
+
>
|
|
97
|
+
{activeStyle === 'checkbox' && (
|
|
98
|
+
<GenericCheckBox
|
|
99
|
+
onChange={(e) => {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
}}
|
|
102
|
+
value={active}
|
|
103
|
+
hasDescription={false}
|
|
104
|
+
size="tiny"
|
|
105
|
+
hasError={false}
|
|
106
|
+
name={`menu-item-checkbox-${label}`}
|
|
107
|
+
disabled={false}
|
|
108
|
+
readOnly
|
|
109
|
+
id={`menu-item-checkbox-${label}`}
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
<div
|
|
113
|
+
style={{
|
|
114
|
+
width: '100%',
|
|
115
|
+
display: 'flex',
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
justifyContent: iconPosition === 'left' ? 'flex-start' : 'space-between',
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
{icon && iconPosition === 'left' && getIcon()}
|
|
121
|
+
<span>{label}</span>
|
|
122
|
+
{icon && iconPosition === 'right' && getIcon()}
|
|
123
|
+
</div>
|
|
124
|
+
{active && activeStyle === 'undo' && <UndoIcon style={{ marginLeft: '10px' }} size={16} />}
|
|
125
|
+
{active && activeStyle === 'checkmark' && <CheckmarkIcon style={{ marginLeft: '10px' }} size={16} />}
|
|
126
|
+
</Container>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
cloneElement,
|
|
4
|
+
isValidElement,
|
|
5
|
+
HTMLProps,
|
|
6
|
+
PropsWithChildren,
|
|
7
|
+
useState,
|
|
8
|
+
ReactElement,
|
|
9
|
+
ReactNode,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { useDropdownContext } from './DropdownContext';
|
|
12
|
+
import { useMergeRefs } from '@floating-ui/react';
|
|
13
|
+
import { TooltipOptions } from '../../feedback/Tooltip/useTooltip';
|
|
14
|
+
import { Tooltip } from '../../../components';
|
|
15
|
+
|
|
16
|
+
export type DropdownTriggerProps = HTMLProps<HTMLElement> &
|
|
17
|
+
PropsWithChildren<{
|
|
18
|
+
asChild?: boolean;
|
|
19
|
+
tooltipOptions?: TooltipOptions & { content: ReactNode };
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export const DropdownTrigger = forwardRef<HTMLElement, DropdownTriggerProps>(
|
|
23
|
+
(
|
|
24
|
+
{
|
|
25
|
+
children,
|
|
26
|
+
asChild = false,
|
|
27
|
+
tooltipOptions = {
|
|
28
|
+
initialOpen: false,
|
|
29
|
+
placement: 'top', // because dropdown will be below by default
|
|
30
|
+
},
|
|
31
|
+
...props
|
|
32
|
+
},
|
|
33
|
+
propRef
|
|
34
|
+
) => {
|
|
35
|
+
const context = useDropdownContext();
|
|
36
|
+
const childrenRef = (children as any).ref;
|
|
37
|
+
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
|
|
38
|
+
|
|
39
|
+
const [unControlledOpen, setUncontrolledOpen] = useState<boolean>(tooltipOptions?.initialOpen ?? false);
|
|
40
|
+
|
|
41
|
+
const open = tooltipOptions.open ?? unControlledOpen;
|
|
42
|
+
const setOpen = tooltipOptions.onOpenChange ?? setUncontrolledOpen;
|
|
43
|
+
|
|
44
|
+
let inner: ReactElement;
|
|
45
|
+
|
|
46
|
+
// `asChild` allows the user to pass any element as the anchor
|
|
47
|
+
if (asChild && isValidElement(children)) {
|
|
48
|
+
inner = cloneElement(
|
|
49
|
+
children,
|
|
50
|
+
context.getReferenceProps({
|
|
51
|
+
ref,
|
|
52
|
+
...props,
|
|
53
|
+
...children.props,
|
|
54
|
+
onClick(event) {
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
inner = (
|
|
61
|
+
<button
|
|
62
|
+
ref={ref}
|
|
63
|
+
type="button"
|
|
64
|
+
// The user can style the trigger based on the state
|
|
65
|
+
{...context.getReferenceProps({
|
|
66
|
+
...props,
|
|
67
|
+
ref,
|
|
68
|
+
onClick(event) {
|
|
69
|
+
event.stopPropagation();
|
|
70
|
+
},
|
|
71
|
+
})}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
</button>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (tooltipOptions && tooltipOptions.content) {
|
|
79
|
+
return (
|
|
80
|
+
<Tooltip open={open} onOpenChange={setOpen} placement={tooltipOptions.placement}>
|
|
81
|
+
<Tooltip.Trigger>{inner}</Tooltip.Trigger>
|
|
82
|
+
<Tooltip.Content>{tooltipOptions.content}</Tooltip.Content>
|
|
83
|
+
</Tooltip>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return inner;
|
|
88
|
+
}
|
|
89
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PropsWithChildren, FC } from 'react';
|
|
2
|
+
import { UseDropdownOptions, useDropdown } from './useDropdown';
|
|
3
|
+
import { DropdownContext } from './DropdownContext';
|
|
4
|
+
import { DropdownTrigger } from './DropdownTrigger';
|
|
5
|
+
import { DropdownMenu } from './DropdownMenu';
|
|
6
|
+
|
|
7
|
+
interface SubComponents {
|
|
8
|
+
Trigger: typeof DropdownTrigger;
|
|
9
|
+
Menu: typeof DropdownMenu;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type DropdownProps = PropsWithChildren<UseDropdownOptions>;
|
|
13
|
+
|
|
14
|
+
export const Dropdown: FC<DropdownProps> & SubComponents = ({ children, ...restOptions }) => {
|
|
15
|
+
// This can accept any props as options, e.g. `placement`,
|
|
16
|
+
// or other positioning options.
|
|
17
|
+
const dropdown = useDropdown({ ...restOptions });
|
|
18
|
+
return <DropdownContext.Provider value={dropdown}>{children}</DropdownContext.Provider>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Dropdown.Trigger = DropdownTrigger;
|
|
22
|
+
Dropdown.Menu = DropdownMenu;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
autoUpdate,
|
|
4
|
+
offset,
|
|
5
|
+
Placement,
|
|
6
|
+
useFloating,
|
|
7
|
+
useInteractions,
|
|
8
|
+
useRole,
|
|
9
|
+
useDismiss,
|
|
10
|
+
useListNavigation,
|
|
11
|
+
useTypeahead,
|
|
12
|
+
useClick,
|
|
13
|
+
shift,
|
|
14
|
+
} from '@floating-ui/react';
|
|
15
|
+
|
|
16
|
+
export interface UseDropdownOptions {
|
|
17
|
+
initialOpen?: boolean;
|
|
18
|
+
placement?: Placement;
|
|
19
|
+
open?: boolean;
|
|
20
|
+
onOpenChange?: (open: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function useDropdown({
|
|
24
|
+
initialOpen = false,
|
|
25
|
+
placement = 'bottom',
|
|
26
|
+
open: controlledOpen,
|
|
27
|
+
onOpenChange: setControlledOpen,
|
|
28
|
+
}: UseDropdownOptions) {
|
|
29
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
30
|
+
const [labelId, setLabelId] = useState<string | undefined>();
|
|
31
|
+
const [descriptionId, setDescriptionId] = useState<string | undefined>();
|
|
32
|
+
|
|
33
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
34
|
+
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
35
|
+
|
|
36
|
+
const elementsRef = useRef<Array<HTMLButtonElement | null>>([]);
|
|
37
|
+
const labelsRef = useRef<Array<string | null>>([]);
|
|
38
|
+
const [activeIndex, setActiveIndex] = useState<number | null>(null);
|
|
39
|
+
|
|
40
|
+
const { context, ...data } = useFloating({
|
|
41
|
+
placement,
|
|
42
|
+
open,
|
|
43
|
+
onOpenChange: setOpen,
|
|
44
|
+
whileElementsMounted: autoUpdate,
|
|
45
|
+
middleware: [offset({ mainAxis: 10 }), shift()],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const interactions = useInteractions([
|
|
49
|
+
useClick(context, { enabled: controlledOpen == null }),
|
|
50
|
+
useRole(context, { role: 'menu' }),
|
|
51
|
+
useDismiss(context),
|
|
52
|
+
useListNavigation(context, {
|
|
53
|
+
listRef: elementsRef,
|
|
54
|
+
onNavigate: setActiveIndex,
|
|
55
|
+
activeIndex,
|
|
56
|
+
}),
|
|
57
|
+
useTypeahead(context, {
|
|
58
|
+
enabled: context.open,
|
|
59
|
+
activeIndex,
|
|
60
|
+
listRef: labelsRef,
|
|
61
|
+
onMatch: setActiveIndex,
|
|
62
|
+
}),
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
return useMemo(
|
|
66
|
+
() => ({
|
|
67
|
+
open,
|
|
68
|
+
setOpen,
|
|
69
|
+
...interactions,
|
|
70
|
+
context,
|
|
71
|
+
...data,
|
|
72
|
+
labelId,
|
|
73
|
+
descriptionId,
|
|
74
|
+
setLabelId,
|
|
75
|
+
setDescriptionId,
|
|
76
|
+
activeIndex,
|
|
77
|
+
labelsRef,
|
|
78
|
+
elementsRef,
|
|
79
|
+
}),
|
|
80
|
+
[open, setOpen, data, context, labelId, descriptionId, interactions]
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { styled } from '../../../styled';
|
|
4
|
+
import { Action } from '../../../components';
|
|
5
|
+
import { DropdownButton, DropdownButtonProps } from '.';
|
|
6
|
+
|
|
7
|
+
const WrapperDecorator = styled.div`
|
|
8
|
+
padding: 5rem;
|
|
9
|
+
border-radius: 1rem;
|
|
10
|
+
background-color: ${({ theme }): string => theme.colors.background};
|
|
11
|
+
h4 {
|
|
12
|
+
font-weight: 600;
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: 'Actions/DropdownButton',
|
|
18
|
+
component: DropdownButton,
|
|
19
|
+
decorators: [(story) => <WrapperDecorator>{story()}</WrapperDecorator>],
|
|
20
|
+
} as Meta;
|
|
21
|
+
|
|
22
|
+
export const Default: StoryFn<DropdownButtonProps> = () => {
|
|
23
|
+
const [message, setMessage] = useState<string>();
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<DropdownButton>
|
|
28
|
+
<Action
|
|
29
|
+
onClick={() => {
|
|
30
|
+
setMessage('save changes event fired');
|
|
31
|
+
}}
|
|
32
|
+
text="Save changes"
|
|
33
|
+
>
|
|
34
|
+
Save changes
|
|
35
|
+
</Action>
|
|
36
|
+
<Action
|
|
37
|
+
onClick={() => {
|
|
38
|
+
setMessage('Save and schedule event fired');
|
|
39
|
+
}}
|
|
40
|
+
text="Save and schedule"
|
|
41
|
+
>
|
|
42
|
+
Save and schedule
|
|
43
|
+
</Action>
|
|
44
|
+
<Action
|
|
45
|
+
onClick={() => {
|
|
46
|
+
setMessage('save and published fired');
|
|
47
|
+
}}
|
|
48
|
+
text="Save and publish"
|
|
49
|
+
>
|
|
50
|
+
Save and publish
|
|
51
|
+
</Action>
|
|
52
|
+
<Action
|
|
53
|
+
onClick={() => {
|
|
54
|
+
setMessage('Export PDF event fired');
|
|
55
|
+
}}
|
|
56
|
+
text="Export PDF"
|
|
57
|
+
>
|
|
58
|
+
Export PDF
|
|
59
|
+
</Action>
|
|
60
|
+
</DropdownButton>
|
|
61
|
+
<p>{message}</p>
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const Description: StoryFn<DropdownButtonProps> = () => {
|
|
67
|
+
const [message, setMessage] = useState<string>();
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
<DropdownButton>
|
|
72
|
+
<Action onClick={() => setMessage('Merge pull request is fired')} text="Merge pull request">
|
|
73
|
+
<h4>merge pull request</h4>
|
|
74
|
+
<p>All commits from this branch will be added to the base branchh via a merge commit.</p>
|
|
75
|
+
</Action>
|
|
76
|
+
<Action onClick={() => setMessage('Squash and merge is fired')} text="Squash and merge">
|
|
77
|
+
<h4>Squash and merge</h4>
|
|
78
|
+
<p>The 4 commits from this branch will be combined into one commit in the base branch.</p>
|
|
79
|
+
</Action>
|
|
80
|
+
<Action onClick={() => setMessage('Rebase and merge is fired.')} text="Rebase and merge">
|
|
81
|
+
<h4>Rebase and merge</h4>
|
|
82
|
+
<p>the 4 commits from this branch will be rebased and added to the base branch.</p>
|
|
83
|
+
</Action>
|
|
84
|
+
</DropdownButton>
|
|
85
|
+
<p>{message}</p>
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { FC, useState, useEffect, ReactElement, useRef } from 'react';
|
|
2
|
+
import { useOutsideAlerter } from '../../../hooks';
|
|
3
|
+
import { MdChevronRight as ArrowIcon } from 'react-icons/md';
|
|
4
|
+
import { ActionMenu } from '../../../components';
|
|
5
|
+
import { styled } from '../../../styled';
|
|
6
|
+
import { useFloating } from '@floating-ui/react';
|
|
7
|
+
|
|
8
|
+
const Arrow = styled(ArrowIcon)`
|
|
9
|
+
transform: rotate(90deg);
|
|
10
|
+
fill: ${({ theme }) => theme.colors.secondary};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const Wrapper = styled.div``;
|
|
14
|
+
|
|
15
|
+
const DropdownActionContainer = styled.div<{ isVisible: boolean }>`
|
|
16
|
+
font-weight: 500;
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
padding: ${({ theme }) => `${theme.spacing['0_5']} 0`};
|
|
20
|
+
justify-content: center;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
width: 3.2rem;
|
|
23
|
+
border: .1rem solid ${({ theme, isVisible }) => (isVisible ? theme.colors.primary : theme.colors.backgroundAccent)}};
|
|
24
|
+
border-top-right-radius: ${({ theme }) => theme.borderRadius.small}};
|
|
25
|
+
border-bottom-right-radius: ${({ theme }) => theme.borderRadius.small}};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
border-color:${({ theme }) => theme.colors.primary};
|
|
30
|
+
svg {
|
|
31
|
+
fill: ${({ theme }) => theme.colors.primary};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
&:active {
|
|
35
|
+
background-color: transparent;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const CurrentAction = styled.div`
|
|
40
|
+
padding: ${({ theme }) => `${theme.spacing['0_5']} ${theme.spacing[1]}`};
|
|
41
|
+
font-weight: 500;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
min-width: 10rem;
|
|
44
|
+
height: 100%;
|
|
45
|
+
color: ${({ theme }) => theme.colors.text};
|
|
46
|
+
border-top: 0.1rem solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
47
|
+
border-left: 0.1rem solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
48
|
+
border-bottom: 0.1rem solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
49
|
+
border-top-left-radius: ${({ theme }) => theme.borderRadius.small};
|
|
50
|
+
border-bottom-left-radius: ${({ theme }) => theme.borderRadius.small};
|
|
51
|
+
|
|
52
|
+
text-align: center;
|
|
53
|
+
&:hover {
|
|
54
|
+
color: ${({ theme }) => theme.colors.primary};
|
|
55
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
56
|
+
}
|
|
57
|
+
&:active {
|
|
58
|
+
background-color: transparent;
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
const Container = styled.div`
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
67
|
+
width: max-content;
|
|
68
|
+
|
|
69
|
+
&:hover ${DropdownActionContainer} {
|
|
70
|
+
border-left-color: ${({ theme }) => theme.colors.primary};
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
export interface DropdownButtonProps {
|
|
75
|
+
children: ReactElement[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const DropdownButton: FC<DropdownButtonProps> = ({ children }) => {
|
|
79
|
+
const [visible, setVisible] = useState<boolean>(false);
|
|
80
|
+
const [selected, setSelected] = useState<number>(0);
|
|
81
|
+
const { x, y, refs, strategy } = useFloating();
|
|
82
|
+
|
|
83
|
+
const parentRef = useRef<HTMLDivElement>(null);
|
|
84
|
+
|
|
85
|
+
useOutsideAlerter(parentRef, () => {
|
|
86
|
+
setVisible(false);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
setVisible(false);
|
|
91
|
+
}, [selected]);
|
|
92
|
+
|
|
93
|
+
const handleSelectedActionClicked = () => {
|
|
94
|
+
setVisible(false);
|
|
95
|
+
children[selected].props.onClick();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Wrapper ref={parentRef}>
|
|
100
|
+
<Container ref={refs.setReference}>
|
|
101
|
+
<CurrentAction onClick={handleSelectedActionClicked}>{children[selected].props.text}</CurrentAction>
|
|
102
|
+
<DropdownActionContainer onClick={() => setVisible(!visible)} isVisible={visible}>
|
|
103
|
+
<Arrow size={20} />
|
|
104
|
+
</DropdownActionContainer>
|
|
105
|
+
{visible && (
|
|
106
|
+
<ActionMenu selectedState={[selected, setSelected]} attributes={{ x, y, strategy }} ref={refs.setFloating}>
|
|
107
|
+
{children}
|
|
108
|
+
</ActionMenu>
|
|
109
|
+
)}
|
|
110
|
+
</Container>
|
|
111
|
+
</Wrapper>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Tooltip, IconButton, IconButtonProps } from '../../../components';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { AiOutlineBell as Icon } from 'react-icons/ai';
|
|
6
|
+
|
|
7
|
+
const Wrapper = styled.div`
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-evenly;
|
|
11
|
+
padding: 5rem;
|
|
12
|
+
background: ${({ theme }) => theme.colors.background};
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
interface ExtraIconButtonStoryProps {
|
|
16
|
+
tooltipLabel: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
title: 'Actions/IconButton',
|
|
21
|
+
component: IconButton,
|
|
22
|
+
decorators: [(story) => <Wrapper>{story()}</Wrapper>],
|
|
23
|
+
args: {
|
|
24
|
+
size: 'medium',
|
|
25
|
+
color: 'primary',
|
|
26
|
+
icon: <Icon />,
|
|
27
|
+
tooltipLabel: 'This is the tooltip',
|
|
28
|
+
badge: '5',
|
|
29
|
+
},
|
|
30
|
+
} as Meta<IconButtonProps & ExtraIconButtonStoryProps>;
|
|
31
|
+
|
|
32
|
+
export const Default: StoryFn<IconButtonProps & ExtraIconButtonStoryProps> = (args) => (
|
|
33
|
+
<Tooltip>
|
|
34
|
+
<Tooltip.Trigger asChild>
|
|
35
|
+
<IconButton size={args.size} color={args.color} icon={args.icon} ariaLabel={args.tooltipLabel} />
|
|
36
|
+
</Tooltip.Trigger>
|
|
37
|
+
<Tooltip.Content>{args.tooltipLabel}</Tooltip.Content>
|
|
38
|
+
</Tooltip>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export const Badge: StoryFn<IconButtonProps & ExtraIconButtonStoryProps> = (args) => (
|
|
42
|
+
<Tooltip>
|
|
43
|
+
<Tooltip.Trigger asChild>
|
|
44
|
+
<IconButton
|
|
45
|
+
badge={args.badge}
|
|
46
|
+
size={args.size}
|
|
47
|
+
color={args.color}
|
|
48
|
+
icon={args.icon}
|
|
49
|
+
ariaLabel={args.tooltipLabel}
|
|
50
|
+
/>
|
|
51
|
+
</Tooltip.Trigger>
|
|
52
|
+
<Tooltip.Content>{args.tooltipLabel}</Tooltip.Content>
|
|
53
|
+
</Tooltip>
|
|
54
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <IconButton /> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
display: -webkit-box;
|
|
6
|
+
display: -webkit-flex;
|
|
7
|
+
display: -ms-flexbox;
|
|
8
|
+
display: flex;
|
|
9
|
+
-webkit-align-items: center;
|
|
10
|
+
-webkit-box-align: center;
|
|
11
|
+
-ms-flex-align: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
-webkit-box-pack: center;
|
|
14
|
+
-webkit-justify-content: center;
|
|
15
|
+
-ms-flex-pack: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
-webkit-transition: all 0.25s cubic-bezier(0.645,0.045,0.355,1) 0s;
|
|
18
|
+
transition: all 0.25s cubic-bezier(0.645,0.045,0.355,1) 0s;
|
|
19
|
+
background-color: #664DE5;
|
|
20
|
+
border-radius: 1rem;
|
|
21
|
+
border: 3px solid transparent;
|
|
22
|
+
background-clip: padding-box;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
padding: 12px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.c0 svg {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.c0 svg path {
|
|
32
|
+
fill: #ffffff!important;
|
|
33
|
+
stroke: #ffffff!important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
<div>
|
|
37
|
+
<button
|
|
38
|
+
class="c0"
|
|
39
|
+
color="primary"
|
|
40
|
+
>
|
|
41
|
+
<div>
|
|
42
|
+
icon
|
|
43
|
+
</div>
|
|
44
|
+
</button>
|
|
45
|
+
</div>
|
|
46
|
+
`;
|