@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,51 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export enum stepTypes {
|
|
4
|
+
SET_STEPS = 'SET_STEPS',
|
|
5
|
+
SET_CURRENT_STEP = 'SET_CURRENT_STEP',
|
|
6
|
+
INCREMENT_CURRENT_STEP = 'INCREMENT_CURRENT_STEP',
|
|
7
|
+
DECREMENT_CURRENT_STEP = 'DECREMNT_CURRENT_STEP',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type StepperState = {
|
|
11
|
+
steps: ReactNode[];
|
|
12
|
+
currentStep: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const defaultStepperState: StepperState = {
|
|
16
|
+
steps: [],
|
|
17
|
+
currentStep: 0,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type ReducerAction =
|
|
21
|
+
| { type: stepTypes.SET_STEPS; payload: { steps: any } }
|
|
22
|
+
| { type: stepTypes.SET_CURRENT_STEP; payload: { amount: number } }
|
|
23
|
+
| { type: stepTypes.INCREMENT_CURRENT_STEP; payload: null }
|
|
24
|
+
| { type: stepTypes.DECREMENT_CURRENT_STEP; payload: null };
|
|
25
|
+
|
|
26
|
+
export const reducer = (state: StepperState, action: ReducerAction) => {
|
|
27
|
+
switch (action.type) {
|
|
28
|
+
case stepTypes.SET_CURRENT_STEP:
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
currentStep: action.payload.amount,
|
|
32
|
+
};
|
|
33
|
+
case stepTypes.SET_STEPS:
|
|
34
|
+
return {
|
|
35
|
+
...state,
|
|
36
|
+
steps: action.payload?.steps,
|
|
37
|
+
};
|
|
38
|
+
case stepTypes.INCREMENT_CURRENT_STEP:
|
|
39
|
+
return {
|
|
40
|
+
...state,
|
|
41
|
+
currentStep: state.currentStep < state.steps.length - 1 ? state.currentStep + 1 : state.currentStep,
|
|
42
|
+
};
|
|
43
|
+
case stepTypes.DECREMENT_CURRENT_STEP:
|
|
44
|
+
return {
|
|
45
|
+
...state,
|
|
46
|
+
currentStep: state.currentStep > 0 ? state.currentStep - 1 : state.currentStep,
|
|
47
|
+
};
|
|
48
|
+
default:
|
|
49
|
+
return state;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { forwardRef, PropsWithChildren } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
import { useTabsContext } from './Context';
|
|
4
|
+
import { motion } from 'framer-motion';
|
|
5
|
+
|
|
6
|
+
const Container = styled(motion.div)`
|
|
7
|
+
padding: ${({ theme }) => theme.spacing['2']};
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
interface ContentProps {
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const variants = {
|
|
15
|
+
visible: { opacity: 1, x: 0 },
|
|
16
|
+
hidden: { opacity: 0, x: '20px' },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Content = forwardRef<HTMLDivElement, PropsWithChildren<ContentProps>>(({ children, value }, ref) => {
|
|
20
|
+
const { value: selectedValue } = useTabsContext();
|
|
21
|
+
|
|
22
|
+
const isHidden = value !== selectedValue;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Container
|
|
26
|
+
ref={ref}
|
|
27
|
+
role="tabpanel"
|
|
28
|
+
aria-labelledby={`tab-content-${value}`}
|
|
29
|
+
hidden={isHidden}
|
|
30
|
+
animate={isHidden ? 'hidden' : 'visible'}
|
|
31
|
+
variants={variants}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</Container>
|
|
35
|
+
);
|
|
36
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import { useTabs } from './useTabs';
|
|
3
|
+
|
|
4
|
+
type ContextType =
|
|
5
|
+
| (ReturnType<typeof useTabs> & {
|
|
6
|
+
setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
7
|
+
setDescriptionId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
8
|
+
})
|
|
9
|
+
| null;
|
|
10
|
+
|
|
11
|
+
export const TabsContext = createContext<ContextType>(null);
|
|
12
|
+
|
|
13
|
+
export const useTabsContext = () => {
|
|
14
|
+
const context = useContext(TabsContext);
|
|
15
|
+
|
|
16
|
+
if (context == null) {
|
|
17
|
+
throw new Error('tabs components must be wrapped in <Tabs /> component');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return context;
|
|
21
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// Contains the triggers that are aligend along the edge of the active content
|
|
2
|
+
import { FC, PropsWithChildren } from 'react';
|
|
3
|
+
import { styled } from '../../../styled';
|
|
4
|
+
|
|
5
|
+
const Container = styled.div`
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
border-bottom: 1px solid ${({ theme }) => theme.colors.background};
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const List: FC<PropsWithChildren> = ({ children }) => {
|
|
12
|
+
return (
|
|
13
|
+
<Container role="tablist" aria-orientation="horizontal">
|
|
14
|
+
{children}
|
|
15
|
+
</Container>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Tabs, TabsProps } from '.';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { Empty, IconButton, Popover } from '../../../components';
|
|
6
|
+
import { AiOutlineTag as TagIcon } from 'react-icons/ai';
|
|
7
|
+
|
|
8
|
+
const Wrapper = styled.div`
|
|
9
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Navigation/Tabs',
|
|
14
|
+
component: Tabs,
|
|
15
|
+
args: {
|
|
16
|
+
placement: 'bottom',
|
|
17
|
+
},
|
|
18
|
+
} as Meta<TabsProps>;
|
|
19
|
+
|
|
20
|
+
export const UnControlled: StoryFn<TabsProps> = () => (
|
|
21
|
+
<Wrapper>
|
|
22
|
+
<Tabs defaultValue="tab1">
|
|
23
|
+
<Tabs.List>
|
|
24
|
+
<Tabs.Trigger value="tab1">Tab 1</Tabs.Trigger>
|
|
25
|
+
<Tabs.Trigger value="tab2">Tab 2</Tabs.Trigger>
|
|
26
|
+
</Tabs.List>
|
|
27
|
+
<Tabs.Content value="tab1">
|
|
28
|
+
<h1>Content 1</h1>
|
|
29
|
+
<p>some long content here</p>
|
|
30
|
+
</Tabs.Content>
|
|
31
|
+
<Tabs.Content value="tab2">
|
|
32
|
+
<h1>Content 2</h1>
|
|
33
|
+
<p>some long content here</p>
|
|
34
|
+
</Tabs.Content>
|
|
35
|
+
</Tabs>
|
|
36
|
+
</Wrapper>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const InnerContent = styled.div`
|
|
40
|
+
min-width: 600px;
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
export const PopOver: StoryFn<TabsProps> = () => {
|
|
44
|
+
const [open, setOpen] = useState<boolean>(false);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
48
|
+
<Popover.Trigger asChild>
|
|
49
|
+
<IconButton icon={<TagIcon />} onClick={() => setOpen(!open)} ariaLabel="open popover" />
|
|
50
|
+
</Popover.Trigger>
|
|
51
|
+
<Popover.Content>
|
|
52
|
+
<Tabs defaultValue="tab1">
|
|
53
|
+
<Tabs.List>
|
|
54
|
+
<Tabs.Trigger value="tab1">Local</Tabs.Trigger>
|
|
55
|
+
<Tabs.Trigger value="tab2">Lambda</Tabs.Trigger>
|
|
56
|
+
</Tabs.List>
|
|
57
|
+
<Tabs.Content value="tab1">
|
|
58
|
+
<InnerContent>
|
|
59
|
+
<Empty
|
|
60
|
+
header="No local environment set up"
|
|
61
|
+
description="You can set up a local environment by running the following command in your terminal:"
|
|
62
|
+
actions={[]}
|
|
63
|
+
/>
|
|
64
|
+
</InnerContent>
|
|
65
|
+
</Tabs.Content>
|
|
66
|
+
<Tabs.Content value="tab2">
|
|
67
|
+
<InnerContent>
|
|
68
|
+
<h3>Content 2</h3>
|
|
69
|
+
<p>some long content here</p>
|
|
70
|
+
</InnerContent>
|
|
71
|
+
</Tabs.Content>
|
|
72
|
+
</Tabs>
|
|
73
|
+
</Popover.Content>
|
|
74
|
+
</Popover>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const EditorContent = styled.div`
|
|
79
|
+
padding: ${({ theme }) => theme.spacing['2']};
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
const Container = styled.div`
|
|
83
|
+
border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
84
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
export const Editor: StoryFn<TabsProps> = () => {
|
|
88
|
+
return (
|
|
89
|
+
<Container>
|
|
90
|
+
<Tabs defaultValue="hello-world.ts">
|
|
91
|
+
<Tabs.List>
|
|
92
|
+
<Tabs.Trigger value="hello-world.ts">hello-world.ts</Tabs.Trigger>
|
|
93
|
+
<Tabs.Trigger value="hello-world.test.ts">hello-world.test.ts</Tabs.Trigger>
|
|
94
|
+
<Tabs.Trigger value="tsconfig.json">tsconfig.json</Tabs.Trigger>
|
|
95
|
+
</Tabs.List>
|
|
96
|
+
<Tabs.Content value="hello-world.ts">
|
|
97
|
+
<EditorContent>
|
|
98
|
+
<h1>hello-world.ts</h1>
|
|
99
|
+
<p>some long content here</p>
|
|
100
|
+
</EditorContent>
|
|
101
|
+
</Tabs.Content>
|
|
102
|
+
<Tabs.Content value="hello-world.test.ts">
|
|
103
|
+
<EditorContent>
|
|
104
|
+
<pre>
|
|
105
|
+
<code>const helloWorld = 'hello world'</code>
|
|
106
|
+
</pre>
|
|
107
|
+
</EditorContent>
|
|
108
|
+
</Tabs.Content>
|
|
109
|
+
<Tabs.Content value="tsconfig.json">
|
|
110
|
+
<EditorContent>
|
|
111
|
+
<pre>
|
|
112
|
+
<code>const helloWorld = 'hello world'</code>
|
|
113
|
+
</pre>
|
|
114
|
+
</EditorContent>
|
|
115
|
+
</Tabs.Content>
|
|
116
|
+
</Tabs>
|
|
117
|
+
</Container>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { forwardRef, PropsWithChildren } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
import { useTabsContext } from './Context';
|
|
4
|
+
import { motion } from 'framer-motion';
|
|
5
|
+
|
|
6
|
+
const Container = styled(motion.button)<{ isActive: boolean }>`
|
|
7
|
+
width: 100%;
|
|
8
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
9
|
+
color: ${({ theme }) => theme.colors.text};
|
|
10
|
+
padding: ${({ theme }) => `${theme.spacing['1']} 0`};
|
|
11
|
+
border-radius: 0;
|
|
12
|
+
border-bottom: 1px solid
|
|
13
|
+
${({ theme, isActive }) => (isActive ? theme.colors.background : theme.colors.backgroundAccent)};
|
|
14
|
+
|
|
15
|
+
&:first-child {
|
|
16
|
+
border-top-left-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
17
|
+
}
|
|
18
|
+
&:last-child {
|
|
19
|
+
border-top-right-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
color: ${({ theme, isActive }) => (isActive ? theme.colors.text : theme.colors.textAlt)};
|
|
23
|
+
|
|
24
|
+
${({ theme, isActive }) => {
|
|
25
|
+
if (!isActive) return;
|
|
26
|
+
|
|
27
|
+
return `
|
|
28
|
+
border-left: 1px solid ${theme.colors.backgroundAccent};
|
|
29
|
+
border-right: 1px solid ${theme.colors.backgroundAccent};
|
|
30
|
+
`;
|
|
31
|
+
}}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
interface TriggerProps {
|
|
35
|
+
value: string;
|
|
36
|
+
asChild?: boolean;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Trigger = forwardRef<HTMLButtonElement, PropsWithChildren<TriggerProps>>(
|
|
41
|
+
({ children, disabled, value }, ref) => {
|
|
42
|
+
const { setValue, value: selectedValue } = useTabsContext();
|
|
43
|
+
|
|
44
|
+
const handleClick = () => {
|
|
45
|
+
if (disabled) return;
|
|
46
|
+
setValue(value);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const isActive = value === selectedValue;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Container
|
|
53
|
+
role="tab"
|
|
54
|
+
ref={ref}
|
|
55
|
+
onClick={handleClick}
|
|
56
|
+
disabled={disabled}
|
|
57
|
+
isActive={isActive}
|
|
58
|
+
aria-selected={isActive}
|
|
59
|
+
aria-controls={`tab-content-${value}`}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
</Container>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PropsWithChildren, FC } from 'react';
|
|
2
|
+
import { Trigger } from './Trigger';
|
|
3
|
+
import { Content } from './Content';
|
|
4
|
+
import { List } from './List';
|
|
5
|
+
import { useTabs } from './useTabs';
|
|
6
|
+
import { TabsContext } from './Context';
|
|
7
|
+
import { styled } from '../../../styled';
|
|
8
|
+
|
|
9
|
+
const Container = styled.div``;
|
|
10
|
+
|
|
11
|
+
export interface TabsProps {
|
|
12
|
+
value?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
// activitationMode?: 'automatic' | 'manual';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface SubComponents {
|
|
19
|
+
Trigger: typeof Trigger;
|
|
20
|
+
Content: typeof Content;
|
|
21
|
+
List: typeof List;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const Tabs: FC<PropsWithChildren<TabsProps>> & SubComponents = ({ children, ...rest }) => {
|
|
25
|
+
const tabs = useTabs(rest);
|
|
26
|
+
return (
|
|
27
|
+
<TabsContext.Provider value={tabs}>
|
|
28
|
+
<Container>{children}</Container>
|
|
29
|
+
</TabsContext.Provider>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
Tabs.Trigger = Trigger;
|
|
34
|
+
Tabs.Content = Content;
|
|
35
|
+
Tabs.List = List;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
interface TabsOptions {
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
onValueChange?: (value: string) => void;
|
|
6
|
+
// activitationMode: 'automatic' | 'manual';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function useTabs({ defaultValue = '', onValueChange }: TabsOptions) {
|
|
10
|
+
const [value, setValue] = useState<string>(defaultValue);
|
|
11
|
+
const [labelId, setLabelId] = useState<string | undefined>();
|
|
12
|
+
const [descriptionId, setDescriptionId] = useState<string | undefined>();
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (onValueChange) {
|
|
16
|
+
onValueChange(value);
|
|
17
|
+
}
|
|
18
|
+
}, [value]);
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
value,
|
|
22
|
+
setValue,
|
|
23
|
+
labelId,
|
|
24
|
+
descriptionId,
|
|
25
|
+
setLabelId,
|
|
26
|
+
setDescriptionId,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { Stepper } from './Steppers/Stepper';
|
|
2
|
+
export type { StepperProps } from './Steppers/Stepper';
|
|
3
|
+
|
|
4
|
+
export { SlimStepper } from './Steppers/SlimStepper';
|
|
5
|
+
export type { SlimStepperProps } from './Steppers/SlimStepper';
|
|
6
|
+
|
|
7
|
+
export { StepperProvider, useStepper } from './Steppers/context';
|
|
8
|
+
|
|
9
|
+
export { IconNav } from './IconNav';
|
|
10
|
+
export type { IconNavProps } from './IconNav';
|
|
11
|
+
|
|
12
|
+
export { HorizontalNav } from './HorizontalNav';
|
|
13
|
+
export type { HorizontalNavProps, HorizontalNavLink } from './HorizontalNav';
|
|
14
|
+
|
|
15
|
+
export { Tabs } from './Tabs';
|
|
16
|
+
export type { TabsProps } from './Tabs';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Action, ActionMenu, ActionMenuProps } from '.';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { styled } from '../../../styled';
|
|
6
|
+
import { useOutsideAlerter } from '../../../hooks';
|
|
7
|
+
import { useFloating } from '@floating-ui/react';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'Other/ActionMenu',
|
|
11
|
+
component: ActionMenu,
|
|
12
|
+
} as Meta<ActionMenuProps>;
|
|
13
|
+
|
|
14
|
+
const Reference = styled.div`
|
|
15
|
+
width: 200px;
|
|
16
|
+
margin: 0 auto;
|
|
17
|
+
background-color: orange;
|
|
18
|
+
`;
|
|
19
|
+
const ParentContainer = styled.div`
|
|
20
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
21
|
+
width: 50%;
|
|
22
|
+
margin: 0 auto;
|
|
23
|
+
height: 30vh;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const Default: StoryFn<ActionMenuProps> = () => {
|
|
27
|
+
const [visible, setVisible] = useState(false);
|
|
28
|
+
const { x, y, refs, strategy } = useFloating();
|
|
29
|
+
const [selected, setSelected] = useState<number>(0);
|
|
30
|
+
const parentRef = useRef<HTMLDivElement>(null);
|
|
31
|
+
useOutsideAlerter(parentRef, () => {
|
|
32
|
+
setVisible(false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setVisible(false);
|
|
37
|
+
}, [selected]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
If you click outside of the gray parent component the popup will be closed. The popup is positioned based on the
|
|
42
|
+
reference element.
|
|
43
|
+
<ParentContainer ref={parentRef}>
|
|
44
|
+
<Reference onClick={() => setVisible(true)} ref={refs.setReference}>
|
|
45
|
+
reference element
|
|
46
|
+
</Reference>
|
|
47
|
+
{visible && (
|
|
48
|
+
<ActionMenu selectedState={[selected, setSelected]} attributes={{ x, y, strategy }} ref={refs.setFloating}>
|
|
49
|
+
<Action
|
|
50
|
+
onClick={() => {
|
|
51
|
+
console.log('action 1 fired');
|
|
52
|
+
}}
|
|
53
|
+
text="action 1"
|
|
54
|
+
>
|
|
55
|
+
action 1
|
|
56
|
+
</Action>
|
|
57
|
+
<Action
|
|
58
|
+
onClick={() => {
|
|
59
|
+
console.log('action 2 fired');
|
|
60
|
+
}}
|
|
61
|
+
text="action 2"
|
|
62
|
+
>
|
|
63
|
+
action 2
|
|
64
|
+
</Action>
|
|
65
|
+
<Action
|
|
66
|
+
onClick={() => {
|
|
67
|
+
console.log('action 3 fired');
|
|
68
|
+
}}
|
|
69
|
+
text="action 3"
|
|
70
|
+
>
|
|
71
|
+
action 3
|
|
72
|
+
</Action>
|
|
73
|
+
<Action
|
|
74
|
+
onClick={() => {
|
|
75
|
+
console.log('action 4 fired');
|
|
76
|
+
}}
|
|
77
|
+
text="action 4"
|
|
78
|
+
>
|
|
79
|
+
action 4
|
|
80
|
+
</Action>
|
|
81
|
+
</ActionMenu>
|
|
82
|
+
)}
|
|
83
|
+
</ParentContainer>
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Children, forwardRef, Dispatch, FC, ReactElement, SetStateAction, PropsWithChildren } from 'react';
|
|
2
|
+
import { Container, Item } from './style';
|
|
3
|
+
import { AiOutlineCheck as CheckMarkIcon } from 'react-icons/ai';
|
|
4
|
+
import { Elevation } from '../../../styled/';
|
|
5
|
+
|
|
6
|
+
export interface ActionMenuProps {
|
|
7
|
+
attributes: {
|
|
8
|
+
x: number | null;
|
|
9
|
+
y: number | null;
|
|
10
|
+
strategy: 'absolute' | 'fixed';
|
|
11
|
+
};
|
|
12
|
+
selectedState: [number, Dispatch<SetStateAction<number>>];
|
|
13
|
+
children: ReactElement | ReactElement[];
|
|
14
|
+
elevation?: Elevation;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const ActionMenu = forwardRef<HTMLUListElement, ActionMenuProps>(
|
|
18
|
+
({ attributes, children, selectedState, elevation = 4 }, ref) => {
|
|
19
|
+
const [selected, setSelected] = selectedState;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Container
|
|
23
|
+
elevation={elevation}
|
|
24
|
+
style={{
|
|
25
|
+
position: attributes.strategy,
|
|
26
|
+
top: attributes.y ? attributes.y + 5 : 0,
|
|
27
|
+
left: attributes.x ?? 0,
|
|
28
|
+
}}
|
|
29
|
+
ref={ref}
|
|
30
|
+
>
|
|
31
|
+
{Children.map(children, (child: ReactElement<ActionProps>, idx) => (
|
|
32
|
+
<Item onClick={() => setSelected(idx)}>
|
|
33
|
+
{child}
|
|
34
|
+
{selected === idx ? (
|
|
35
|
+
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
36
|
+
<CheckMarkIcon size={15} />
|
|
37
|
+
</div>
|
|
38
|
+
) : (
|
|
39
|
+
<div className="checkmark-placeholder"></div>
|
|
40
|
+
)}
|
|
41
|
+
</Item>
|
|
42
|
+
))}
|
|
43
|
+
</Container>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
interface ActionProps {
|
|
49
|
+
onClick: () => unknown;
|
|
50
|
+
text: string;
|
|
51
|
+
// TODO: implement disabled when needed
|
|
52
|
+
}
|
|
53
|
+
export const Action: FC<PropsWithChildren<ActionProps>> = ({ children }) => {
|
|
54
|
+
return <div>{children}</div>;
|
|
55
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Elevation, styled } from '../../../styled';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.ul<{ elevation: Elevation }>`
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
width: fit-content;
|
|
7
|
+
box-shadow: ${({ theme, elevation }) => theme.elevation[elevation]};
|
|
8
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
9
|
+
border: 0.1rem solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
10
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const Item = styled.li`
|
|
14
|
+
display: grid;
|
|
15
|
+
grid-template-columns: ${({ theme }) => `1fr ${theme.spacing[3]}`};
|
|
16
|
+
align-content: center;
|
|
17
|
+
padding: ${({ theme }) => theme.spacing['0_75']};
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
|
|
20
|
+
&:first-child {
|
|
21
|
+
border-top-left-radius: 0.5rem;
|
|
22
|
+
border-top-right-radius: 0.5rem;
|
|
23
|
+
}
|
|
24
|
+
&:last-child {
|
|
25
|
+
border-bottom-left-radius: 0.5rem;
|
|
26
|
+
border-bottom-right-radius: 0.5rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
p {
|
|
30
|
+
color: ${({ theme }): string => theme.colors.secondary};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
background-color: ${({ theme }) => theme.colors.backgroundAlt};
|
|
35
|
+
* {
|
|
36
|
+
color: white;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
svg {
|
|
40
|
+
fill: white;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
svg {
|
|
45
|
+
margin-left: ${({ theme }) => theme.spacing[1]};
|
|
46
|
+
fill: ${({ theme }): string => theme.colors.text};
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { ClipBoard, ClipBoardProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Other/ClipBoard',
|
|
7
|
+
component: ClipBoard,
|
|
8
|
+
args: {
|
|
9
|
+
text: 'https://docs.csmm.app/en/CSMM/advanced-feature-guide-chathook.html#creating-the-listen-hook-for-specific-content-in-a-chatmessage',
|
|
10
|
+
maxWidth: 500,
|
|
11
|
+
},
|
|
12
|
+
} as Meta<ClipBoardProps>;
|
|
13
|
+
|
|
14
|
+
export const Default: StoryFn<ClipBoardProps> = (args) => <ClipBoard {...args} />;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <ClipBoard /> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
position: relative;
|
|
6
|
+
padding: 0;
|
|
7
|
+
outline: 0;
|
|
8
|
+
width: -webkit-fit-content;
|
|
9
|
+
width: -moz-fit-content;
|
|
10
|
+
width: fit-content;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.c0 input {
|
|
14
|
+
width: 200px;
|
|
15
|
+
padding: 8px 30px 8px 8px;
|
|
16
|
+
border: 1px solid #d3d3d3;
|
|
17
|
+
color: #d3d3d3;
|
|
18
|
+
cursor: default;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.c0 input:hover {
|
|
22
|
+
cursor: default;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.c1 {
|
|
26
|
+
position: absolute;
|
|
27
|
+
background-color: white;
|
|
28
|
+
top: 7px;
|
|
29
|
+
right: 7px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.c1 svg {
|
|
33
|
+
fill: #d3d3d3;
|
|
34
|
+
stroke: #d3d3d3;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
<div>
|
|
39
|
+
<div
|
|
40
|
+
class="c0"
|
|
41
|
+
role="button"
|
|
42
|
+
tabindex="-1"
|
|
43
|
+
>
|
|
44
|
+
<input
|
|
45
|
+
aria-describedby="clipboard-input-error"
|
|
46
|
+
aria-invalid="false"
|
|
47
|
+
readonly=""
|
|
48
|
+
type="text"
|
|
49
|
+
value="ClipBoard text"
|
|
50
|
+
/>
|
|
51
|
+
<div
|
|
52
|
+
class="c1"
|
|
53
|
+
>
|
|
54
|
+
<svg
|
|
55
|
+
fill="currentColor"
|
|
56
|
+
height="20"
|
|
57
|
+
stroke="currentColor"
|
|
58
|
+
stroke-width="0"
|
|
59
|
+
viewBox="0 0 1024 1024"
|
|
60
|
+
width="20"
|
|
61
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
62
|
+
>
|
|
63
|
+
<path
|
|
64
|
+
d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"
|
|
65
|
+
/>
|
|
66
|
+
</svg>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
`;
|