@takaro/lib-components 0.0.0-next.0da151e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +7 -0
- package/@types/files.d.ts +23 -0
- package/@types/react-table-config.d.ts +121 -0
- package/Dockerfile.dev +21 -0
- package/package.json +15 -0
- package/public/images/7-days-to-die/logo.png +0 -0
- package/public/images/csmm-icon.png +0 -0
- package/public/images/milk.png +0 -0
- package/public/images/placeholder-01.jpeg +0 -0
- package/public/images/placeholder-02.jpeg +0 -0
- package/public/images/placeholder-03.jpeg +0 -0
- package/public/images/rust/logo.png +0 -0
- package/readme.md +10 -0
- package/src/components/actions/Button/Button.stories.tsx +149 -0
- package/src/components/actions/Button/Button.test.tsx +8 -0
- package/src/components/actions/Button/Button.test.tsx.snap +89 -0
- package/src/components/actions/Button/__snapshots__/Button.test.tsx.snap +18 -0
- package/src/components/actions/Button/index.tsx +89 -0
- package/src/components/actions/Button/style.ts +142 -0
- package/src/components/actions/ContextMenu/ContextMenu.stories.tsx +41 -0
- package/src/components/actions/ContextMenu/Group.tsx +34 -0
- package/src/components/actions/ContextMenu/MenuItem.tsx +69 -0
- package/src/components/actions/ContextMenu/index.tsx +216 -0
- package/src/components/actions/Dropdown/Dropdown.stories.tsx +88 -0
- package/src/components/actions/Dropdown/DropdownContext.tsx +21 -0
- package/src/components/actions/Dropdown/DropdownMenu.tsx +70 -0
- package/src/components/actions/Dropdown/DropdownMenuGroup.tsx +37 -0
- package/src/components/actions/Dropdown/DropdownMenuItem.tsx +128 -0
- package/src/components/actions/Dropdown/DropdownTrigger.tsx +87 -0
- package/src/components/actions/Dropdown/index.tsx +22 -0
- package/src/components/actions/Dropdown/useDropdown.tsx +89 -0
- package/src/components/actions/DropdownButton/DropdownButton.stories.tsx +88 -0
- package/src/components/actions/DropdownButton/index.tsx +128 -0
- package/src/components/actions/IconButton/IconButton.stories.tsx +54 -0
- package/src/components/actions/IconButton/IconButton.test.tsx +8 -0
- package/src/components/actions/IconButton/IconButton.test.tsx.snap +46 -0
- package/src/components/actions/IconButton/__snapshots__/IconButton.test.tsx.snap +18 -0
- package/src/components/actions/IconButton/getIconSize.ts +16 -0
- package/src/components/actions/IconButton/index.tsx +28 -0
- package/src/components/actions/IconButton/style.ts +51 -0
- package/src/components/actions/ToggleButton/ToggleButton.stories.tsx +85 -0
- package/src/components/actions/ToggleButton/ToggleButton.tsx +48 -0
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +107 -0
- package/src/components/actions/ToggleButton/index.tsx +2 -0
- package/src/components/actions/ToggleButton/style.ts +75 -0
- package/src/components/actions/index.ts +16 -0
- package/src/components/charts/AreaChart/AreaChart.stories.tsx +103 -0
- package/src/components/charts/AreaChart/index.tsx +428 -0
- package/src/components/charts/BarChart/BarChart.stories.tsx +55 -0
- package/src/components/charts/BarChart/index.tsx +420 -0
- package/src/components/charts/BrushHandle.tsx +21 -0
- package/src/components/charts/EmptyChart.tsx +45 -0
- package/src/components/charts/GeoMercator/GeoMercator.stories.tsx +77 -0
- package/src/components/charts/GeoMercator/index.tsx +228 -0
- package/src/components/charts/GeoMercator/iso3166-alpha2-to-alpha3.ts +250 -0
- package/src/components/charts/GeoMercator/world.d.ts +1 -0
- package/src/components/charts/GeoMercator/world.json +99818 -0
- package/src/components/charts/Heatmap/Heatmap.stories.tsx +189 -0
- package/src/components/charts/Heatmap/index.tsx +461 -0
- package/src/components/charts/LineChart/LineChart.stories.tsx +111 -0
- package/src/components/charts/LineChart/index.tsx +353 -0
- package/src/components/charts/PieChart/PieChart.stories.tsx +151 -0
- package/src/components/charts/PieChart/index.tsx +457 -0
- package/src/components/charts/PointHighlight.tsx +49 -0
- package/src/components/charts/RadarChart/RadarChart.stories.tsx +47 -0
- package/src/components/charts/RadarChart/generators.ts +30 -0
- package/src/components/charts/RadarChart/index.tsx +224 -0
- package/src/components/charts/RadialBarChart/RadialBarChart.stories.tsx +59 -0
- package/src/components/charts/RadialBarChart/index.tsx +231 -0
- package/src/components/charts/RadialLineChart/RadialLineChart.stories.tsx +43 -0
- package/src/components/charts/RadialLineChart/index.tsx +231 -0
- package/src/components/charts/ZoomControls.tsx +49 -0
- package/src/components/charts/index.tsx +26 -0
- package/src/components/charts/useGradients.tsx +37 -0
- package/src/components/charts/util.ts +78 -0
- package/src/components/data/Avatar/Avatar.stories.tsx +93 -0
- package/src/components/data/Avatar/context.tsx +20 -0
- package/src/components/data/Avatar/index.tsx +136 -0
- package/src/components/data/Avatar/style.ts +124 -0
- package/src/components/data/Avatar/useImageLoadingStatus.tsx +32 -0
- package/src/components/data/Chip/Chip.stories.tsx +67 -0
- package/src/components/data/Chip/Chip.test.tsx +8 -0
- package/src/components/data/Chip/Chip.test.tsx.snap +50 -0
- package/src/components/data/Chip/__snapshots__/Chip.test.tsx.snap +38 -0
- package/src/components/data/Chip/index.tsx +67 -0
- package/src/components/data/Chip/style.ts +49 -0
- package/src/components/data/Console/Console.stories.tsx +51 -0
- package/src/components/data/Console/Console.tsx +125 -0
- package/src/components/data/Console/ConsoleInput/index.tsx +87 -0
- package/src/components/data/Console/ConsoleInput/style.ts +41 -0
- package/src/components/data/Console/ConsoleLine/index.tsx +127 -0
- package/src/components/data/Console/ConsoleLine/style.ts +76 -0
- package/src/components/data/Console/MessageModel.ts +9 -0
- package/src/components/data/Console/constants.ts +6 -0
- package/src/components/data/Console/index.tsx +4 -0
- package/src/components/data/Console/style.ts +31 -0
- package/src/components/data/Console/useConsoleLiveMode.ts +42 -0
- package/src/components/data/CopyId/CopyId.stories.tsx +36 -0
- package/src/components/data/CopyId/index.tsx +107 -0
- package/src/components/data/CountryList/index.tsx +146 -0
- package/src/components/data/DateFormatter/DateFormatter.stories.tsx +26 -0
- package/src/components/data/DateFormatter/index.tsx +15 -0
- package/src/components/data/Drawer/Drawer.stories.tsx +155 -0
- package/src/components/data/Drawer/DrawerBody.tsx +22 -0
- package/src/components/data/Drawer/DrawerContent.tsx +169 -0
- package/src/components/data/Drawer/DrawerContext.tsx +21 -0
- package/src/components/data/Drawer/DrawerFooter.tsx +19 -0
- package/src/components/data/Drawer/DrawerHeading.tsx +50 -0
- package/src/components/data/Drawer/DrawerSkeleton.tsx +29 -0
- package/src/components/data/Drawer/index.tsx +25 -0
- package/src/components/data/Drawer/useDrawer.tsx +66 -0
- package/src/components/data/InfiniteScroll/InfiniteScroll.stories.tsx +33 -0
- package/src/components/data/InfiniteScroll/index.tsx +54 -0
- package/src/components/data/Stats/Sparkline.tsx +48 -0
- package/src/components/data/Stats/Stat.tsx +192 -0
- package/src/components/data/Stats/Stats.stories.tsx +196 -0
- package/src/components/data/Stats/context.tsx +18 -0
- package/src/components/data/Stats/index.tsx +62 -0
- package/src/components/data/Table/Table.stories.tsx +146 -0
- package/src/components/data/Table/index.tsx +492 -0
- package/src/components/data/Table/react-table.d.ts +14 -0
- package/src/components/data/Table/style.ts +97 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +164 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +207 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +90 -0
- package/src/components/data/Table/subcomponents/ColumnVisibility/index.tsx +70 -0
- package/src/components/data/Table/subcomponents/Filter/field.tsx +127 -0
- package/src/components/data/Table/subcomponents/Filter/index.tsx +228 -0
- package/src/components/data/Table/subcomponents/Filter/style.ts +26 -0
- package/src/components/data/Table/subcomponents/Filter/types.ts +10 -0
- package/src/components/data/Table/subcomponents/Pagination/PagePicker.tsx +109 -0
- package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +37 -0
- package/src/components/data/Table/subcomponents/Pagination/style.ts +49 -0
- package/src/components/data/index.ts +28 -0
- package/src/components/dialogs/Dialog/Dialog.stories.tsx +77 -0
- package/src/components/dialogs/Dialog/DialogBody.tsx +64 -0
- package/src/components/dialogs/Dialog/DialogContent.tsx +44 -0
- package/src/components/dialogs/Dialog/DialogContext.tsx +21 -0
- package/src/components/dialogs/Dialog/DialogHeading.tsx +56 -0
- package/src/components/dialogs/Dialog/index.tsx +20 -0
- package/src/components/dialogs/Dialog/useDialog.tsx +50 -0
- package/src/components/feedback/Alert/Alert.stories.tsx +75 -0
- package/src/components/feedback/Alert/Alert.test.tsx +8 -0
- package/src/components/feedback/Alert/Alert.test.tsx.snap +146 -0
- package/src/components/feedback/Alert/__snapshots__/Alert.test.tsx.snap +44 -0
- package/src/components/feedback/Alert/index.tsx +120 -0
- package/src/components/feedback/Alert/style.ts +97 -0
- package/src/components/feedback/Badge/Badge.stories.tsx +23 -0
- package/src/components/feedback/Badge/index.tsx +47 -0
- package/src/components/feedback/ErrorFallback/ErrorFallback.stories.tsx +10 -0
- package/src/components/feedback/ErrorFallback/index.tsx +49 -0
- package/src/components/feedback/ErrorPage/ErrorPage.stories.tsx +31 -0
- package/src/components/feedback/ErrorPage/index.tsx +193 -0
- package/src/components/feedback/FormError/FormError.stories.tsx +25 -0
- package/src/components/feedback/FormError/index.tsx +54 -0
- package/src/components/feedback/IconTooltip/IconTooltip.stories.tsx +22 -0
- package/src/components/feedback/IconTooltip/index.tsx +51 -0
- package/src/components/feedback/Loaders/Loaders.stories.tsx +28 -0
- package/src/components/feedback/Loaders/Loading.test.tsx +8 -0
- package/src/components/feedback/Loaders/Loading.test.tsx.snap +141 -0
- package/src/components/feedback/Loaders/Loading.tsx +107 -0
- package/src/components/feedback/Loaders/Spinner.test.tsx +8 -0
- package/src/components/feedback/Loaders/Spinner.test.tsx.snap +18 -0
- package/src/components/feedback/Loaders/Spinner.tsx +74 -0
- package/src/components/feedback/Loaders/__snapshots__/Loading.test.tsx.snap +141 -0
- package/src/components/feedback/Loaders/__snapshots__/Spinner.test.tsx.snap +10 -0
- package/src/components/feedback/Loaders/index.ts +2 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.stories.tsx +21 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx +8 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx.snap +3 -0
- package/src/components/feedback/NetworkDetector/__snapshots__/NetworkDetector.test.tsx.snap +3 -0
- package/src/components/feedback/NetworkDetector/index.tsx +41 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.stories.tsx +13 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +15 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/__snapshots__/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/index.tsx +78 -0
- package/src/components/feedback/Popover/Popover.stories.tsx +33 -0
- package/src/components/feedback/Popover/PopoverContent.tsx +46 -0
- package/src/components/feedback/Popover/PopoverContext.tsx +21 -0
- package/src/components/feedback/Popover/PopoverTrigger.tsx +45 -0
- package/src/components/feedback/Popover/index.tsx +22 -0
- package/src/components/feedback/Popover/usePopover.tsx +87 -0
- package/src/components/feedback/ProgressBar/ProgressBar.stories.tsx +38 -0
- package/src/components/feedback/ProgressBar/index.tsx +137 -0
- package/src/components/feedback/Skeleton/Skeleton.stories.tsx +33 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx +8 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx.snap +35 -0
- package/src/components/feedback/Skeleton/__snapshots__/Skeleton.test.tsx.snap +9 -0
- package/src/components/feedback/Skeleton/index.tsx +62 -0
- package/src/components/feedback/Tooltip/Tooltip.stories.tsx +69 -0
- package/src/components/feedback/Tooltip/TooltipContent.tsx +51 -0
- package/src/components/feedback/Tooltip/TooltipContext.tsx +13 -0
- package/src/components/feedback/Tooltip/TooltipTrigger.tsx +39 -0
- package/src/components/feedback/Tooltip/index.tsx +26 -0
- package/src/components/feedback/Tooltip/useTooltip.tsx +82 -0
- package/src/components/feedback/index.ts +37 -0
- package/src/components/feedback/snacks/CookieConsent/index.tsx +125 -0
- package/src/components/feedback/snacks/CookieConsent/style.ts +99 -0
- package/src/components/feedback/snacks/Default/default.stories.tsx +73 -0
- package/src/components/feedback/snacks/Default/index.tsx +78 -0
- package/src/components/feedback/snacks/Default/style.ts +58 -0
- package/src/components/feedback/snacks/Drawer/Drawer.stories.tsx +46 -0
- package/src/components/feedback/snacks/Drawer/index.tsx +85 -0
- package/src/components/feedback/snacks/NetworkDetector/index.tsx +73 -0
- package/src/components/feedback/snacks/index.d.ts +15 -0
- package/src/components/feedback/snacks/index.ts +8 -0
- package/src/components/index.ts +9 -0
- package/src/components/inputs/CheckBox/CheckBox.stories.tsx +64 -0
- package/src/components/inputs/CheckBox/Controlled.tsx +123 -0
- package/src/components/inputs/CheckBox/Generic.tsx +42 -0
- package/src/components/inputs/CheckBox/index.tsx +4 -0
- package/src/components/inputs/CheckBox/style.ts +56 -0
- package/src/components/inputs/CodeField/CodeField.stories.tsx +86 -0
- package/src/components/inputs/CodeField/index.tsx +174 -0
- package/src/components/inputs/CodeField/style.ts +50 -0
- package/src/components/inputs/Date/DatePicker/Controlled.tsx +103 -0
- package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +267 -0
- package/src/components/inputs/Date/DatePicker/Generic.tsx +283 -0
- package/src/components/inputs/Date/DatePicker/formats.tsx +32 -0
- package/src/components/inputs/Date/DatePicker/style.ts +41 -0
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +123 -0
- package/src/components/inputs/Date/DateRangePicker/Controlled.tsx +74 -0
- package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +37 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Absolute.tsx +98 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Relative.tsx +54 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/index.tsx +49 -0
- package/src/components/inputs/Date/DateRangePicker/Generic.tsx +167 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +254 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/style.ts +40 -0
- package/src/components/inputs/Date/DateRangePicker/style.ts +65 -0
- package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +150 -0
- package/src/components/inputs/Date/subcomponents/Calendar/style.ts +61 -0
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +170 -0
- package/src/components/inputs/Date/subcomponents/RelativePicker/style.ts +50 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/TimePicker.stories.tsx +25 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/index.tsx +40 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/style.ts +34 -0
- package/src/components/inputs/Date/types.ts +14 -0
- package/src/components/inputs/DurationField/Controlled.tsx +69 -0
- package/src/components/inputs/DurationField/Duration.stories.tsx +57 -0
- package/src/components/inputs/DurationField/Generic.tsx +197 -0
- package/src/components/inputs/DurationField/__tests__/Generic.test.tsx +12 -0
- package/src/components/inputs/DurationField/index.tsx +5 -0
- package/src/components/inputs/DurationField/style.ts +42 -0
- package/src/components/inputs/EditableField/EditableField.stories.tsx +65 -0
- package/src/components/inputs/EditableField/index.tsx +135 -0
- package/src/components/inputs/EditableField/style.ts +11 -0
- package/src/components/inputs/FileField/Controlled.tsx +104 -0
- package/src/components/inputs/FileField/FileField.stories.tsx +210 -0
- package/src/components/inputs/FileField/Generic.tsx +133 -0
- package/src/components/inputs/FileField/index.tsx +5 -0
- package/src/components/inputs/FileField/style.ts +34 -0
- package/src/components/inputs/InputProps.ts +59 -0
- package/src/components/inputs/RadioGroup/Controlled.tsx +45 -0
- package/src/components/inputs/RadioGroup/Generic.tsx +34 -0
- package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +118 -0
- package/src/components/inputs/RadioGroup/RadioItem.tsx +130 -0
- package/src/components/inputs/RadioGroup/context.tsx +20 -0
- package/src/components/inputs/RadioGroup/index.ts +5 -0
- package/src/components/inputs/RadioGroup/style.ts +3 -0
- package/src/components/inputs/Switch/Controlled.tsx +57 -0
- package/src/components/inputs/Switch/Generic.tsx +40 -0
- package/src/components/inputs/Switch/Switch.stories.tsx +89 -0
- package/src/components/inputs/Switch/index.ts +5 -0
- package/src/components/inputs/Switch/style.ts +62 -0
- package/src/components/inputs/TagField/Controlled.tsx +103 -0
- package/src/components/inputs/TagField/Generic.tsx +138 -0
- package/src/components/inputs/TagField/TagField.stories.tsx +68 -0
- package/src/components/inputs/TagField/index.ts +5 -0
- package/src/components/inputs/TagField/style.ts +25 -0
- package/src/components/inputs/TagField/util.ts +34 -0
- package/src/components/inputs/TextAreaField/Controlled.tsx +101 -0
- package/src/components/inputs/TextAreaField/Generic.tsx +58 -0
- package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +99 -0
- package/src/components/inputs/TextAreaField/index.ts +5 -0
- package/src/components/inputs/TextAreaField/style.ts +28 -0
- package/src/components/inputs/TextField/Controlled.tsx +120 -0
- package/src/components/inputs/TextField/Generic.tsx +138 -0
- package/src/components/inputs/TextField/TextField.stories.tsx +217 -0
- package/src/components/inputs/TextField/index.ts +5 -0
- package/src/components/inputs/TextField/style.ts +103 -0
- package/src/components/inputs/TextField/util.ts +24 -0
- package/src/components/inputs/ValueConfirmationField/ValueConfirmationField.stories.tsx +33 -0
- package/src/components/inputs/ValueConfirmationField/index.tsx +54 -0
- package/src/components/inputs/index.ts +72 -0
- package/src/components/inputs/layout/Description.tsx +33 -0
- package/src/components/inputs/layout/ErrorMessage/ErrorMessage.stories.tsx +28 -0
- package/src/components/inputs/layout/ErrorMessage/index.tsx +63 -0
- package/src/components/inputs/layout/InputWrapper.ts +6 -0
- package/src/components/inputs/layout/Label/index.tsx +71 -0
- package/src/components/inputs/layout/Label/style.ts +50 -0
- package/src/components/inputs/layout/index.ts +8 -0
- package/src/components/inputs/layout/setAriaDescribedBy.ts +3 -0
- package/src/components/inputs/selects/SelectField/Controlled.tsx +127 -0
- package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +48 -0
- package/src/components/inputs/selects/SelectField/Generic/index.tsx +299 -0
- package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +252 -0
- package/src/components/inputs/selects/SelectField/index.ts +5 -0
- package/src/components/inputs/selects/SelectField/style.ts +29 -0
- package/src/components/inputs/selects/SelectQueryField/Controlled.tsx +110 -0
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +401 -0
- package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +280 -0
- package/src/components/inputs/selects/SelectQueryField/index.tsx +5 -0
- package/src/components/inputs/selects/SelectQueryField/style.ts +13 -0
- package/src/components/inputs/selects/SubComponents/Option.tsx +114 -0
- package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +18 -0
- package/src/components/inputs/selects/SubComponents/index.ts +10 -0
- package/src/components/inputs/selects/SubComponents/style.ts +51 -0
- package/src/components/inputs/selects/data.ts +123 -0
- package/src/components/inputs/selects/index.tsx +49 -0
- package/src/components/inputs/selects/sharedStyle.ts +76 -0
- package/src/components/layout/Container/index.ts +21 -0
- package/src/components/layout/index.ts +1 -0
- package/src/components/navigation/HorizontalNav/HorizontalNav.stories.tsx +29 -0
- package/src/components/navigation/HorizontalNav/index.tsx +13 -0
- package/src/components/navigation/HorizontalNav/style.ts +93 -0
- package/src/components/navigation/IconNav/IconNav.stories.tsx +46 -0
- package/src/components/navigation/IconNav/index.tsx +50 -0
- package/src/components/navigation/Steppers/SlimStepper/Stepper.stories.tsx +90 -0
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +104 -0
- package/src/components/navigation/Steppers/SlimStepper/style.ts +85 -0
- package/src/components/navigation/Steppers/Stepper/Stepper.stories.tsx +88 -0
- package/src/components/navigation/Steppers/Stepper/index.tsx +114 -0
- package/src/components/navigation/Steppers/Stepper/style.ts +106 -0
- package/src/components/navigation/Steppers/context.tsx +2 -0
- package/src/components/navigation/Steppers/provider.tsx +18 -0
- package/src/components/navigation/Steppers/reducer.ts +51 -0
- package/src/components/navigation/Steppers/stepStates.ts +5 -0
- package/src/components/navigation/Steppers/useStepper.ts +34 -0
- package/src/components/navigation/Tabs/Content.tsx +39 -0
- package/src/components/navigation/Tabs/Context.tsx +21 -0
- package/src/components/navigation/Tabs/List.tsx +17 -0
- package/src/components/navigation/Tabs/Tabs.stories.tsx +119 -0
- package/src/components/navigation/Tabs/Trigger.tsx +66 -0
- package/src/components/navigation/Tabs/index.tsx +35 -0
- package/src/components/navigation/Tabs/useTabs.tsx +28 -0
- package/src/components/navigation/index.ts +17 -0
- package/src/components/other/ActionMenu/ActionMenu.stories.tsx +81 -0
- package/src/components/other/ActionMenu/index.tsx +62 -0
- package/src/components/other/ActionMenu/style.ts +47 -0
- package/src/components/other/ClipBoard/ClipBoard.stories.tsx +14 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx +8 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx.snap +70 -0
- package/src/components/other/ClipBoard/__snapshots__/ClipBoard.test.tsx.snap +36 -0
- package/src/components/other/ClipBoard/index.tsx +70 -0
- package/src/components/other/CollapseList/CollapseList.stories.tsx +21 -0
- package/src/components/other/CollapseList/index.tsx +110 -0
- package/src/components/other/Collapsible/Collapsible.stories.tsx +19 -0
- package/src/components/other/Collapsible/CollapsibleContent.tsx +29 -0
- package/src/components/other/Collapsible/CollapsibleContext.tsx +17 -0
- package/src/components/other/Collapsible/CollapsibleTrigger.tsx +83 -0
- package/src/components/other/Collapsible/index.tsx +21 -0
- package/src/components/other/Company/index.tsx +44 -0
- package/src/components/other/Company/style.ts +58 -0
- package/src/components/other/Empty/Empty.stories.tsx +28 -0
- package/src/components/other/Empty/Empty.test.tsx +10 -0
- package/src/components/other/Empty/Empty.test.tsx.snap +85 -0
- package/src/components/other/Empty/__snapshots__/Empty.test.tsx.snap +21 -0
- package/src/components/other/Empty/index.tsx +85 -0
- package/src/components/other/PermissionsGuard/PermissionsGuard.stories.tsx +55 -0
- package/src/components/other/PermissionsGuard/hasPermissionsHelper.ts +18 -0
- package/src/components/other/PermissionsGuard/index.tsx +27 -0
- package/src/components/other/Plan/Plan.stories.tsx +21 -0
- package/src/components/other/Plan/index.tsx +92 -0
- package/src/components/other/Plan/style.ts +61 -0
- package/src/components/other/Usage/Usage.stories.tsx +21 -0
- package/src/components/other/Usage/Usage.tsx +35 -0
- package/src/components/other/Usage/UsageCard.stories.tsx +31 -0
- package/src/components/other/Usage/UsageCard.tsx +88 -0
- package/src/components/other/index.ts +27 -0
- package/src/components/visual/Card/Card.stories.tsx +22 -0
- package/src/components/visual/Card/CardBody.tsx +11 -0
- package/src/components/visual/Card/CardTitle.tsx +29 -0
- package/src/components/visual/Card/index.tsx +58 -0
- package/src/components/visual/Divider/Divider.stories.tsx +19 -0
- package/src/components/visual/Divider/Divider.test.tsx +8 -0
- package/src/components/visual/Divider/Divider.test.tsx.snap +35 -0
- package/src/components/visual/Divider/__snapshots__/Divider.test.tsx.snap +13 -0
- package/src/components/visual/Divider/index.tsx +88 -0
- package/src/components/visual/Flag/index.tsx +61 -0
- package/src/components/visual/index.ts +8 -0
- package/src/errors/base.ts +14 -0
- package/src/errors/errors.ts +126 -0
- package/src/errors/index.ts +14 -0
- package/src/helpers/camelCaseToSpaces.ts +5 -0
- package/src/helpers/formatNumber.ts +6 -0
- package/src/helpers/getInitials.ts +16 -0
- package/src/helpers/getSnackbarProvider.tsx +57 -0
- package/src/helpers/getTransition.ts +9 -0
- package/src/helpers/index.ts +6 -0
- package/src/helpers/makeData.ts +34 -0
- package/src/helpers/regexprs.ts +9 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useCallbackRef.tsx +17 -0
- package/src/hooks/useDebounce.tsx +22 -0
- package/src/hooks/useFocus.tsx +12 -0
- package/src/hooks/useLocalStorage.tsx +35 -0
- package/src/hooks/useLockScroll.ts +26 -0
- package/src/hooks/useOnScreen.ts +24 -0
- package/src/hooks/useOutsideAlerter.tsx +15 -0
- package/src/hooks/useTableActions.ts +61 -0
- package/src/hooks/useTheme.tsx +7 -0
- package/src/images/company-icon-primary.svg +3 -0
- package/src/images/company-icon-secondary.svg +3 -0
- package/src/images/index.ts +4 -0
- package/src/index.ts +9 -0
- package/src/stories/Colors.mdx +35 -0
- package/src/stories/Introduction.mdx +17 -0
- package/src/stories/Spacing.mdx +25 -0
- package/src/styled/GlobalStyle.ts +209 -0
- package/src/styled/Snackbar.tsx +41 -0
- package/src/styled/animations.ts +36 -0
- package/src/styled/breakpoint.ts +7 -0
- package/src/styled/device.ts +10 -0
- package/src/styled/index.ts +10 -0
- package/src/styled/spacing.ts +38 -0
- package/src/styled/theme.tsx +110 -0
- package/src/styled/types.ts +5 -0
- package/src/styled/zIndex.ts +31 -0
- package/src/test/__mocks__/fileMock.ts +2 -0
- package/src/test/setupTests.ts +3 -0
- package/src/test/snapshotResolver.js +21 -0
- package/src/test/testUtils.tsx +34 -0
- package/src/types/index.ts +1 -0
- package/src/types/json.ts +5 -0
- package/src/views/LoadingPage.tsx +36 -0
- package/src/views/index.ts +1 -0
- package/tsconfig.json +14 -0
- package/vite.config.mts +17 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useContext, createContext } from 'react';
|
|
2
|
+
import { useDialog } from './useDialog';
|
|
3
|
+
|
|
4
|
+
type ContextType =
|
|
5
|
+
| (ReturnType<typeof useDialog> & {
|
|
6
|
+
setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
7
|
+
setDescriptionId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
8
|
+
})
|
|
9
|
+
| null;
|
|
10
|
+
|
|
11
|
+
export const DialogContext = createContext<ContextType>(null);
|
|
12
|
+
|
|
13
|
+
export const useDialogContext = () => {
|
|
14
|
+
const context = useContext(DialogContext);
|
|
15
|
+
|
|
16
|
+
if (context == null) {
|
|
17
|
+
throw new Error('Dialog components must be wrapped in <Dialog />');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return context;
|
|
21
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { forwardRef, HTMLProps, useId, useLayoutEffect } from 'react';
|
|
2
|
+
import { useDialogContext } from './DialogContext';
|
|
3
|
+
import { AiOutlineClose as CloseIcon } from 'react-icons/ai';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { IconButton, Tooltip } from '../../../components';
|
|
6
|
+
|
|
7
|
+
const Container = styled.div`
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
align-items: center;
|
|
11
|
+
|
|
12
|
+
h4 {
|
|
13
|
+
font-size: ${({ theme }) => theme.fontSize.tiny};
|
|
14
|
+
}
|
|
15
|
+
margin-bottom: ${({ theme }) => theme.spacing[2]};
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
interface DialogHeadingProps extends HTMLProps<HTMLHeadingElement> {
|
|
19
|
+
hasClose?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const DialogHeading = forwardRef<HTMLHeadingElement, DialogHeadingProps>(function DialogHeading(
|
|
23
|
+
{ children, hasClose = true, ...props },
|
|
24
|
+
ref,
|
|
25
|
+
) {
|
|
26
|
+
const { setLabelId, setOpen } = useDialogContext();
|
|
27
|
+
const id = useId();
|
|
28
|
+
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
setLabelId(id);
|
|
31
|
+
return () => setLabelId(undefined);
|
|
32
|
+
}, [id, setLabelId]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Container>
|
|
36
|
+
<h4 {...props} ref={ref} id={id}>
|
|
37
|
+
{children}
|
|
38
|
+
</h4>
|
|
39
|
+
{hasClose && (
|
|
40
|
+
<Tooltip>
|
|
41
|
+
<Tooltip.Trigger asChild>
|
|
42
|
+
<IconButton
|
|
43
|
+
onClick={(e) => {
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
setOpen(false);
|
|
46
|
+
}}
|
|
47
|
+
ariaLabel="Close dialog"
|
|
48
|
+
icon={<CloseIcon cursor="pointer" />}
|
|
49
|
+
/>
|
|
50
|
+
</Tooltip.Trigger>
|
|
51
|
+
<Tooltip.Content>Close dialog</Tooltip.Content>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
)}
|
|
54
|
+
</Container>
|
|
55
|
+
);
|
|
56
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DialogOptions, useDialog } from './useDialog';
|
|
2
|
+
import { FC, PropsWithChildren } from 'react';
|
|
3
|
+
import { DialogContext } from './DialogContext';
|
|
4
|
+
import { DialogContent } from './DialogContent';
|
|
5
|
+
import { DialogBody } from './DialogBody';
|
|
6
|
+
import { DialogHeading } from './DialogHeading';
|
|
7
|
+
|
|
8
|
+
interface SubComponentTypes {
|
|
9
|
+
Content: typeof DialogContent;
|
|
10
|
+
Body: typeof DialogBody;
|
|
11
|
+
Heading: typeof DialogHeading;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const Dialog: FC<PropsWithChildren<DialogOptions>> & SubComponentTypes = ({ children, ...options }) => {
|
|
15
|
+
return <DialogContext.Provider value={useDialog(options)}>{children}</DialogContext.Provider>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Dialog.Content = DialogContent;
|
|
19
|
+
Dialog.Body = DialogBody;
|
|
20
|
+
Dialog.Heading = DialogHeading;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { useClick, useDismiss, useFloating, useInteractions, useRole } from '@floating-ui/react';
|
|
3
|
+
|
|
4
|
+
export interface DialogOptions {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
initialOpen?: boolean;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useDialog({
|
|
11
|
+
initialOpen = false,
|
|
12
|
+
open: controlledOpen,
|
|
13
|
+
onOpenChange: setControlledOpen,
|
|
14
|
+
}: DialogOptions) {
|
|
15
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
16
|
+
const [labelId, setLabelId] = useState<string | undefined>();
|
|
17
|
+
const [descriptionId, setDescriptionId] = useState<string | undefined>();
|
|
18
|
+
|
|
19
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
20
|
+
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
21
|
+
|
|
22
|
+
const data = useFloating({
|
|
23
|
+
open,
|
|
24
|
+
onOpenChange: setOpen,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const context = data.context;
|
|
28
|
+
|
|
29
|
+
const interactions = useInteractions([
|
|
30
|
+
useClick(context, {
|
|
31
|
+
enabled: controlledOpen == null,
|
|
32
|
+
}),
|
|
33
|
+
useDismiss(context, { outsidePressEvent: 'mousedown', bubbles: false }),
|
|
34
|
+
useRole(context, { role: 'dialog' }),
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
return useMemo(
|
|
38
|
+
() => ({
|
|
39
|
+
open,
|
|
40
|
+
setOpen,
|
|
41
|
+
...interactions,
|
|
42
|
+
...data,
|
|
43
|
+
labelId,
|
|
44
|
+
descriptionId,
|
|
45
|
+
setLabelId,
|
|
46
|
+
setDescriptionId,
|
|
47
|
+
}),
|
|
48
|
+
[open, setOpen, interactions, data, labelId, descriptionId],
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Alert, AlertProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Feedback/Alert',
|
|
7
|
+
component: Alert,
|
|
8
|
+
args: {
|
|
9
|
+
text: 'This is the title',
|
|
10
|
+
variant: 'info',
|
|
11
|
+
},
|
|
12
|
+
} as Meta<AlertProps>;
|
|
13
|
+
|
|
14
|
+
export const Default: StoryFn<AlertProps> = (args) => <Alert {...args} />;
|
|
15
|
+
|
|
16
|
+
export const TitleOnly: StoryObj<AlertProps> = {
|
|
17
|
+
args: {
|
|
18
|
+
title: 'Important Notice',
|
|
19
|
+
variant: 'info',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const WithList: StoryObj<AlertProps> = {
|
|
24
|
+
args: {
|
|
25
|
+
title: 'There were errors with your submission',
|
|
26
|
+
text: [
|
|
27
|
+
'Your password must be at least 8 characters',
|
|
28
|
+
'Your password must include at least one pro wrestling finishing move',
|
|
29
|
+
],
|
|
30
|
+
variant: 'error',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Warning: StoryObj<AlertProps> = {
|
|
35
|
+
args: {
|
|
36
|
+
title: 'Attention required',
|
|
37
|
+
text: 'This is a warning! Please read this carefully before you continue!',
|
|
38
|
+
variant: 'warning',
|
|
39
|
+
action: {
|
|
40
|
+
execute: () => {
|
|
41
|
+
/* */
|
|
42
|
+
},
|
|
43
|
+
text: 'View status',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const SingleLine: StoryObj<AlertProps> = {
|
|
49
|
+
args: {
|
|
50
|
+
text: 'This is a single line now',
|
|
51
|
+
variant: 'info',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const SingleLineWithAction: StoryObj<AlertProps> = {
|
|
56
|
+
args: {
|
|
57
|
+
text: 'This is a single line now',
|
|
58
|
+
variant: 'error',
|
|
59
|
+
action: {
|
|
60
|
+
execute: () => {},
|
|
61
|
+
text: 'details',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const SingleLineLongWithAction: StoryObj<AlertProps> = {
|
|
67
|
+
args: {
|
|
68
|
+
text: 'This is a very very very very very very very very very very long line that stretches to 2 lines',
|
|
69
|
+
variant: 'error',
|
|
70
|
+
action: {
|
|
71
|
+
execute: () => {},
|
|
72
|
+
text: 'details',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Alert } from '.';
|
|
2
|
+
import { render } from '../../../test/testUtils';
|
|
3
|
+
import { expect, it } from 'vitest';
|
|
4
|
+
|
|
5
|
+
it('Should render <Alert/>', () => {
|
|
6
|
+
const { container } = render(<Alert text="Alert text" title="Alert title" variant="info" />);
|
|
7
|
+
expect(container).toMatchSnapshot();
|
|
8
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Alert/> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
width: 100%;
|
|
6
|
+
padding: 1rem 1.2rem;
|
|
7
|
+
border-radius: 1rem;
|
|
8
|
+
margin: 1.5rem auto 1.5rem auto;
|
|
9
|
+
background-color: #d9d2f9;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.c0 h2 {
|
|
13
|
+
font-size: 1.825rem;
|
|
14
|
+
display: -webkit-box;
|
|
15
|
+
display: -webkit-flex;
|
|
16
|
+
display: -ms-flexbox;
|
|
17
|
+
display: flex;
|
|
18
|
+
-webkit-align-items: center;
|
|
19
|
+
-webkit-box-align: center;
|
|
20
|
+
-ms-flex-align: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
font-weight: 700;
|
|
23
|
+
-webkit-box-pack: start;
|
|
24
|
+
-webkit-justify-content: flex-start;
|
|
25
|
+
-ms-flex-pack: start;
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.c0 p {
|
|
30
|
+
margin-top: 1.5rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.c0 p,
|
|
34
|
+
.c0 li {
|
|
35
|
+
font-size: 1.325rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.c0 ul {
|
|
39
|
+
margin-left: 15px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.c0 ul li {
|
|
43
|
+
list-style-type: disc;
|
|
44
|
+
margin-top: 0.5rem;
|
|
45
|
+
margin-bottom: 0.5rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.c0 h2 {
|
|
49
|
+
color: #331ab2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.c0 p,
|
|
53
|
+
.c0 li {
|
|
54
|
+
color: #331ab2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.c0::marker {
|
|
58
|
+
color: #331ab2;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.c1 {
|
|
62
|
+
display: grid;
|
|
63
|
+
grid-template-columns: 40px 1fr;
|
|
64
|
+
-webkit-align-items: center;
|
|
65
|
+
-webkit-box-align: center;
|
|
66
|
+
-ms-flex-align: center;
|
|
67
|
+
align-items: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.c2 {
|
|
71
|
+
display: -webkit-box;
|
|
72
|
+
display: -webkit-flex;
|
|
73
|
+
display: -ms-flexbox;
|
|
74
|
+
display: flex;
|
|
75
|
+
-webkit-align-items: center;
|
|
76
|
+
-webkit-box-align: center;
|
|
77
|
+
-ms-flex-align: center;
|
|
78
|
+
align-items: center;
|
|
79
|
+
-webkit-box-pack: center;
|
|
80
|
+
-webkit-justify-content: center;
|
|
81
|
+
-ms-flex-pack: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
margin-right: 1.4rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.c2 svg {
|
|
87
|
+
fill: #664DE5;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.c3 {
|
|
91
|
+
display: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.c3 button {
|
|
95
|
+
margin-top: 2rem;
|
|
96
|
+
margin-right: 2rem;
|
|
97
|
+
padding: 0.8rem 0.5rem 0.8rem 0.5rem;
|
|
98
|
+
border-radius: 0.5rem;
|
|
99
|
+
background-color: #b2a6f2;
|
|
100
|
+
font-size: 1.3rem;
|
|
101
|
+
border: none;
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
font-weight: 700;
|
|
104
|
+
color: #331ab2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
<div>
|
|
108
|
+
<div
|
|
109
|
+
class="c0"
|
|
110
|
+
style="opacity: 0;"
|
|
111
|
+
>
|
|
112
|
+
<div
|
|
113
|
+
class="c1"
|
|
114
|
+
>
|
|
115
|
+
<div
|
|
116
|
+
class="c2"
|
|
117
|
+
>
|
|
118
|
+
<svg
|
|
119
|
+
fill="currentColor"
|
|
120
|
+
height="24"
|
|
121
|
+
stroke="currentColor"
|
|
122
|
+
stroke-width="0"
|
|
123
|
+
viewBox="0 0 1024 1024"
|
|
124
|
+
width="24"
|
|
125
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
126
|
+
>
|
|
127
|
+
<path
|
|
128
|
+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"
|
|
129
|
+
/>
|
|
130
|
+
</svg>
|
|
131
|
+
</div>
|
|
132
|
+
<h2>
|
|
133
|
+
Alert title
|
|
134
|
+
</h2>
|
|
135
|
+
<div />
|
|
136
|
+
<p>
|
|
137
|
+
Alert text
|
|
138
|
+
</p>
|
|
139
|
+
<div />
|
|
140
|
+
<div
|
|
141
|
+
class="c3"
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
`;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Alert/> 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
aria-atomic="true"
|
|
7
|
+
aria-live="polite"
|
|
8
|
+
class="sc-aXZVg dfhkGl"
|
|
9
|
+
role="status"
|
|
10
|
+
style="opacity: 0; will-change: opacity;"
|
|
11
|
+
>
|
|
12
|
+
<div
|
|
13
|
+
class="sc-gEvEer ciCPPR"
|
|
14
|
+
>
|
|
15
|
+
<div
|
|
16
|
+
class="sc-eqUAAy hqcNUj"
|
|
17
|
+
>
|
|
18
|
+
<svg
|
|
19
|
+
fill="currentColor"
|
|
20
|
+
height="24"
|
|
21
|
+
stroke="currentColor"
|
|
22
|
+
stroke-width="0"
|
|
23
|
+
viewBox="0 0 1024 1024"
|
|
24
|
+
width="24"
|
|
25
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
+
>
|
|
27
|
+
<path
|
|
28
|
+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"
|
|
29
|
+
/>
|
|
30
|
+
</svg>
|
|
31
|
+
</div>
|
|
32
|
+
<h2>
|
|
33
|
+
Alert title
|
|
34
|
+
</h2>
|
|
35
|
+
<p>
|
|
36
|
+
Alert text
|
|
37
|
+
</p>
|
|
38
|
+
<div
|
|
39
|
+
class="sc-fqkvVR huFkoW action"
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
`;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { forwardRef, isValidElement, MouseEvent, ReactElement, useState } from 'react';
|
|
2
|
+
import { Container, Grid, IconContainer, ButtonContainer } from './style';
|
|
3
|
+
import {
|
|
4
|
+
AiFillCheckCircle as Success,
|
|
5
|
+
AiFillCloseCircle as Error,
|
|
6
|
+
AiOutlineWarning as Warning,
|
|
7
|
+
AiFillInfoCircle as Info,
|
|
8
|
+
} from 'react-icons/ai';
|
|
9
|
+
import { AnimatePresence } from 'framer-motion';
|
|
10
|
+
import { Button } from '../../../components';
|
|
11
|
+
|
|
12
|
+
export type AlertVariants = 'success' | 'error' | 'warning' | 'info';
|
|
13
|
+
|
|
14
|
+
type Action = {
|
|
15
|
+
execute: () => void;
|
|
16
|
+
text: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface AlertProps {
|
|
20
|
+
variant: AlertVariants;
|
|
21
|
+
title?: string;
|
|
22
|
+
text?: string | string[] | ReactElement;
|
|
23
|
+
dismiss?: boolean;
|
|
24
|
+
action?: Action;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(
|
|
28
|
+
{ variant, title, text, dismiss = false, action },
|
|
29
|
+
ref,
|
|
30
|
+
) {
|
|
31
|
+
const [visible, setVisible] = useState(true);
|
|
32
|
+
const hasTitle = !!title;
|
|
33
|
+
const hasText = !!text;
|
|
34
|
+
const hasContent = hasTitle || hasText;
|
|
35
|
+
// Use center alignment when we have only one content line (title OR text, not both)
|
|
36
|
+
// Use start alignment when we have multiple lines (title AND text, or text as an array)
|
|
37
|
+
const useStartAlignment = (hasTitle && hasText) || Array.isArray(text);
|
|
38
|
+
|
|
39
|
+
const handleExecute = (e: MouseEvent<HTMLButtonElement>) => {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
action?.execute();
|
|
43
|
+
};
|
|
44
|
+
const handleDismiss = (e: MouseEvent<HTMLButtonElement>) => {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
e.stopPropagation();
|
|
47
|
+
setVisible(false);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function getIcon() {
|
|
51
|
+
switch (variant) {
|
|
52
|
+
case 'success':
|
|
53
|
+
return <Success size={24} />;
|
|
54
|
+
case 'error':
|
|
55
|
+
return <Error size={24} />;
|
|
56
|
+
case 'warning':
|
|
57
|
+
return <Warning size={24} />;
|
|
58
|
+
case 'info':
|
|
59
|
+
return <Info size={24} />;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function renderText() {
|
|
64
|
+
if (isValidElement(text)) {
|
|
65
|
+
return text;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (typeof text === 'string') {
|
|
69
|
+
return <p>{text}</p>;
|
|
70
|
+
} else if (Array.isArray(text)) {
|
|
71
|
+
return <ul>{text?.map((message, index) => <li key={index}>{message}</li>)}</ul>;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Determine ARIA role based on variant
|
|
76
|
+
const getAriaRole = () => {
|
|
77
|
+
return variant === 'error' || variant === 'warning' ? 'alert' : 'status';
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const getAriaLive = () => {
|
|
81
|
+
return variant === 'error' || variant === 'warning' ? 'assertive' : 'polite';
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<AnimatePresence>
|
|
86
|
+
{visible && (
|
|
87
|
+
<Container
|
|
88
|
+
animate={{ opacity: 1 }}
|
|
89
|
+
exit={{ opacity: 0 }}
|
|
90
|
+
$hasTitle={hasTitle}
|
|
91
|
+
initial={{ opacity: 0 }}
|
|
92
|
+
$variant={variant}
|
|
93
|
+
transition={{ duration: 0.2 }}
|
|
94
|
+
ref={ref}
|
|
95
|
+
role={getAriaRole()}
|
|
96
|
+
aria-live={getAriaLive()}
|
|
97
|
+
aria-atomic="true"
|
|
98
|
+
>
|
|
99
|
+
<Grid $useStartAlignment={useStartAlignment}>
|
|
100
|
+
<IconContainer variant={variant}>{getIcon()}</IconContainer>
|
|
101
|
+
{title && <h2>{title}</h2>}
|
|
102
|
+
{renderText()}
|
|
103
|
+
<ButtonContainer hasContent={hasContent} show={!!(dismiss || action)} variant={variant} className="action">
|
|
104
|
+
{action && (
|
|
105
|
+
<Button size="small" variant="outline" onClick={handleExecute} color={variant}>
|
|
106
|
+
{action.text}
|
|
107
|
+
</Button>
|
|
108
|
+
)}
|
|
109
|
+
{dismiss && (
|
|
110
|
+
<Button size="small" color="white" variant="outline" onClick={handleDismiss}>
|
|
111
|
+
Dismiss
|
|
112
|
+
</Button>
|
|
113
|
+
)}
|
|
114
|
+
</ButtonContainer>
|
|
115
|
+
</Grid>
|
|
116
|
+
</Container>
|
|
117
|
+
)}
|
|
118
|
+
</AnimatePresence>
|
|
119
|
+
);
|
|
120
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { styled } from '../../../styled';
|
|
2
|
+
import { AlertVariants } from '.';
|
|
3
|
+
import { motion } from 'framer-motion';
|
|
4
|
+
import { shade } from 'polished';
|
|
5
|
+
|
|
6
|
+
// Since this actually a motion.div we are passing props to that only should be consumed by styled compmonents
|
|
7
|
+
// and not being passed the the underlying react node, we can prefix the prop names with `$`to turn it into
|
|
8
|
+
// a transient prop.
|
|
9
|
+
export const Container = styled(motion.div)<{
|
|
10
|
+
$variant: AlertVariants;
|
|
11
|
+
$hasTitle: boolean;
|
|
12
|
+
}>`
|
|
13
|
+
width: 100%;
|
|
14
|
+
padding: ${({ theme }) => theme.spacing['0_75']};
|
|
15
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
16
|
+
margin: ${({ theme }) => `${theme.spacing['1_5']} auto`};
|
|
17
|
+
h2 {
|
|
18
|
+
font-size: ${({ theme }) => theme.fontSize.mediumLarge};
|
|
19
|
+
font-weight: 700;
|
|
20
|
+
margin: 0;
|
|
21
|
+
text-align: left;
|
|
22
|
+
}
|
|
23
|
+
p {
|
|
24
|
+
margin-top: ${({ theme, $hasTitle }) => ($hasTitle ? theme.spacing['0_25'] : theme.spacing[0])};
|
|
25
|
+
margin-bottom: 0;
|
|
26
|
+
hyphens: auto;
|
|
27
|
+
text-align: left;
|
|
28
|
+
font-size: ${({ theme }) => theme.fontSize.medium};
|
|
29
|
+
}
|
|
30
|
+
li {
|
|
31
|
+
font-size: ${({ theme }) => theme.fontSize.medium};
|
|
32
|
+
text-align: left;
|
|
33
|
+
}
|
|
34
|
+
ul {
|
|
35
|
+
margin-left: ${({ theme }) => theme.spacing['1_5']};
|
|
36
|
+
margin-top: ${({ theme, $hasTitle }) => ($hasTitle ? theme.spacing['0_25'] : theme.spacing[0])};
|
|
37
|
+
margin-bottom: 0;
|
|
38
|
+
li {
|
|
39
|
+
list-style-type: disc;
|
|
40
|
+
margin-top: ${({ theme }) => theme.spacing['0_5']};
|
|
41
|
+
margin-bottom: ${({ theme }) => theme.spacing['0_5']};
|
|
42
|
+
&::marker {
|
|
43
|
+
font-size: ${({ theme }) => theme.fontSize.medium};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/* set background color equal to provided type */
|
|
48
|
+
${({ $variant, theme }): string => {
|
|
49
|
+
return `
|
|
50
|
+
background-color: ${shade('0.5', theme.colors[$variant])};
|
|
51
|
+
border: 1px solid ${theme.colors[$variant]};
|
|
52
|
+
h2 {
|
|
53
|
+
color: white;
|
|
54
|
+
}
|
|
55
|
+
p, li {
|
|
56
|
+
color: white;
|
|
57
|
+
}
|
|
58
|
+
::marker {
|
|
59
|
+
color: white;
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
}}
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
export const Grid = styled.div<{ $useStartAlignment: boolean }>`
|
|
66
|
+
display: grid;
|
|
67
|
+
grid-template-columns: 40px 1fr;
|
|
68
|
+
align-items: ${({ $useStartAlignment }) => ($useStartAlignment ? 'start' : 'center')};
|
|
69
|
+
gap: ${({ theme }) => theme.spacing['0_5']};
|
|
70
|
+
|
|
71
|
+
p,
|
|
72
|
+
ul,
|
|
73
|
+
.action {
|
|
74
|
+
grid-column: 2;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
export const IconContainer = styled.div<{ variant: AlertVariants }>`
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
svg {
|
|
83
|
+
fill: white;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
export const ButtonContainer = styled.div<{
|
|
88
|
+
show: boolean;
|
|
89
|
+
variant: AlertVariants;
|
|
90
|
+
hasContent: boolean;
|
|
91
|
+
}>`
|
|
92
|
+
display: ${({ show }): string => (show ? 'flex' : 'none')};
|
|
93
|
+
align-items: center;
|
|
94
|
+
flex-wrap: wrap;
|
|
95
|
+
gap: ${({ theme }) => theme.spacing['0_5']};
|
|
96
|
+
margin-top: ${({ theme, hasContent }): string => (hasContent ? theme.spacing['1'] : theme.spacing[0])};
|
|
97
|
+
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Badge, BadgeProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Feedback/Badge',
|
|
7
|
+
component: Badge,
|
|
8
|
+
args: {
|
|
9
|
+
variant: 'warning',
|
|
10
|
+
animate: false,
|
|
11
|
+
},
|
|
12
|
+
} as Meta<BadgeProps>;
|
|
13
|
+
|
|
14
|
+
export const Default: StoryFn<BadgeProps> = (args) => (
|
|
15
|
+
<div>
|
|
16
|
+
<h2 style={{ backgroundColor: 'orange', position: 'relative', width: 'fit-content' }}>
|
|
17
|
+
this is the title{' '}
|
|
18
|
+
<Badge variant={args.variant} animate={args.animate}>
|
|
19
|
+
here
|
|
20
|
+
</Badge>
|
|
21
|
+
</h2>
|
|
22
|
+
</div>
|
|
23
|
+
);
|