@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
package/.babelrc
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare module '*.svg' {
|
|
2
|
+
const content: string;
|
|
3
|
+
export default content;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.png' {
|
|
6
|
+
const content: string;
|
|
7
|
+
export default content;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module '*.jpg' {
|
|
11
|
+
const content: string;
|
|
12
|
+
export default content;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module '*.jpeg' {
|
|
16
|
+
const content: string;
|
|
17
|
+
export default content;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module '*.mp3' {
|
|
21
|
+
const content: string;
|
|
22
|
+
export default content;
|
|
23
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-table
|
|
2
|
+
import {
|
|
3
|
+
UseColumnOrderInstanceProps,
|
|
4
|
+
UseColumnOrderState,
|
|
5
|
+
UseExpandedHooks,
|
|
6
|
+
UseExpandedInstanceProps,
|
|
7
|
+
UseExpandedOptions,
|
|
8
|
+
UseExpandedRowProps,
|
|
9
|
+
UseExpandedState,
|
|
10
|
+
UseFiltersColumnOptions,
|
|
11
|
+
UseFiltersColumnProps,
|
|
12
|
+
UseFiltersInstanceProps,
|
|
13
|
+
UseFiltersOptions,
|
|
14
|
+
UseFiltersState,
|
|
15
|
+
UseGlobalFiltersColumnOptions,
|
|
16
|
+
UseGlobalFiltersInstanceProps,
|
|
17
|
+
UseGlobalFiltersOptions,
|
|
18
|
+
UseGlobalFiltersState,
|
|
19
|
+
UseGroupByCellProps,
|
|
20
|
+
UseGroupByColumnOptions,
|
|
21
|
+
UseGroupByColumnProps,
|
|
22
|
+
UseGroupByHooks,
|
|
23
|
+
UseGroupByInstanceProps,
|
|
24
|
+
UseGroupByOptions,
|
|
25
|
+
UseGroupByRowProps,
|
|
26
|
+
UseGroupByState,
|
|
27
|
+
UsePaginationInstanceProps,
|
|
28
|
+
UsePaginationOptions,
|
|
29
|
+
UsePaginationState,
|
|
30
|
+
UseResizeColumnsColumnOptions,
|
|
31
|
+
UseResizeColumnsColumnProps,
|
|
32
|
+
UseResizeColumnsOptions,
|
|
33
|
+
UseResizeColumnsState,
|
|
34
|
+
UseRowSelectHooks,
|
|
35
|
+
UseRowSelectInstanceProps,
|
|
36
|
+
UseRowSelectOptions,
|
|
37
|
+
UseRowSelectRowProps,
|
|
38
|
+
UseRowSelectState,
|
|
39
|
+
UseRowStateCellProps,
|
|
40
|
+
UseRowStateInstanceProps,
|
|
41
|
+
UseRowStateOptions,
|
|
42
|
+
UseRowStateRowProps,
|
|
43
|
+
UseRowStateState,
|
|
44
|
+
UseSortByColumnOptions,
|
|
45
|
+
UseSortByColumnProps,
|
|
46
|
+
UseSortByHooks,
|
|
47
|
+
UseSortByInstanceProps,
|
|
48
|
+
UseSortByOptions,
|
|
49
|
+
UseSortByState
|
|
50
|
+
} from 'react-table';
|
|
51
|
+
|
|
52
|
+
declare module 'react-table' {
|
|
53
|
+
// take this file as-is, or comment out the sections that don't apply to your plugin configuration
|
|
54
|
+
|
|
55
|
+
export interface TableOptions<D extends Record<string, unknown>>
|
|
56
|
+
extends UseExpandedOptions<D>,
|
|
57
|
+
UseFiltersOptions<D>,
|
|
58
|
+
UseGlobalFiltersOptions<D>,
|
|
59
|
+
UseGroupByOptions<D>,
|
|
60
|
+
UsePaginationOptions<D>,
|
|
61
|
+
UseResizeColumnsOptions<D>,
|
|
62
|
+
UseRowSelectOptions<D>,
|
|
63
|
+
UseRowStateOptions<D>,
|
|
64
|
+
UseSortByOptions<D>,
|
|
65
|
+
// note that having Record here allows you to add anything to the options, this matches the spirit of the
|
|
66
|
+
// underlying js library, but might be cleaner if it's replaced by a more specific type that matches your
|
|
67
|
+
// feature set, this is a safe default.
|
|
68
|
+
Record<string, any> {}
|
|
69
|
+
|
|
70
|
+
export interface Hooks<D extends Record<string, unknown> = Record<string, unknown>>
|
|
71
|
+
extends UseExpandedHooks<D>,
|
|
72
|
+
UseGroupByHooks<D>,
|
|
73
|
+
UseRowSelectHooks<D>,
|
|
74
|
+
UseSortByHooks<D> {}
|
|
75
|
+
|
|
76
|
+
export interface TableInstance<D extends Record<string, unknown> = Record<string, unknown>>
|
|
77
|
+
extends UseColumnOrderInstanceProps<D>,
|
|
78
|
+
UseExpandedInstanceProps<D>,
|
|
79
|
+
UseFiltersInstanceProps<D>,
|
|
80
|
+
UseGlobalFiltersInstanceProps<D>,
|
|
81
|
+
UseGroupByInstanceProps<D>,
|
|
82
|
+
UsePaginationInstanceProps<D>,
|
|
83
|
+
UseRowSelectInstanceProps<D>,
|
|
84
|
+
UseRowStateInstanceProps<D>,
|
|
85
|
+
UseSortByInstanceProps<D> {}
|
|
86
|
+
|
|
87
|
+
export interface TableState<D extends Record<string, unknown> = Record<string, unknown>>
|
|
88
|
+
extends UseColumnOrderState<D>,
|
|
89
|
+
UseExpandedState<D>,
|
|
90
|
+
UseFiltersState<D>,
|
|
91
|
+
UseGlobalFiltersState<D>,
|
|
92
|
+
UseGroupByState<D>,
|
|
93
|
+
UsePaginationState<D>,
|
|
94
|
+
UseResizeColumnsState<D>,
|
|
95
|
+
UseRowSelectState<D>,
|
|
96
|
+
UseRowStateState<D>,
|
|
97
|
+
UseSortByState<D> {}
|
|
98
|
+
|
|
99
|
+
export interface ColumnInterface<D extends Record<string, unknown> = Record<string, unknown>>
|
|
100
|
+
extends UseFiltersColumnOptions<D>,
|
|
101
|
+
UseGlobalFiltersColumnOptions<D>,
|
|
102
|
+
UseGroupByColumnOptions<D>,
|
|
103
|
+
UseResizeColumnsColumnOptions<D>,
|
|
104
|
+
UseSortByColumnOptions<D> {}
|
|
105
|
+
|
|
106
|
+
export interface ColumnInstance<D extends Record<string, unknown> = Record<string, unknown>>
|
|
107
|
+
extends UseFiltersColumnProps<D>,
|
|
108
|
+
UseGroupByColumnProps<D>,
|
|
109
|
+
UseResizeColumnsColumnProps<D>,
|
|
110
|
+
UseSortByColumnProps<D> {}
|
|
111
|
+
|
|
112
|
+
export interface Cell<D extends Record<string, unknown> = Record<string, unknown>>
|
|
113
|
+
extends UseGroupByCellProps<D>,
|
|
114
|
+
UseRowStateCellProps<D> {}
|
|
115
|
+
|
|
116
|
+
export interface Row<D extends Record<string, unknown> = Record<string, unknown>>
|
|
117
|
+
extends UseExpandedRowProps<D>,
|
|
118
|
+
UseGroupByRowProps<D>,
|
|
119
|
+
UseRowSelectRowProps<D>,
|
|
120
|
+
UseRowStateRowProps<D> {}
|
|
121
|
+
}
|
package/Dockerfile.dev
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
FROM node:24.11.0-alpine AS build
|
|
2
|
+
|
|
3
|
+
ENV NODE_ENV=development
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
|
|
6
|
+
# root
|
|
7
|
+
COPY package*.json ./
|
|
8
|
+
COPY tsconfig.react.json ./
|
|
9
|
+
|
|
10
|
+
# ui
|
|
11
|
+
COPY packages/ui/*.json ./packages/ui/
|
|
12
|
+
|
|
13
|
+
# Install before src changes so it does not need to be rebuilt so often.
|
|
14
|
+
RUN npm ci
|
|
15
|
+
|
|
16
|
+
COPY packages/ui/.storybook ./packages/ui/.storybook
|
|
17
|
+
COPY packages/ui/public ./packages/ui/public
|
|
18
|
+
COPY packages/ui/src ./packages/ui/src
|
|
19
|
+
|
|
20
|
+
WORKDIR /app/packages/ui
|
|
21
|
+
CMD ["npm", "run", "start"]
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@takaro/lib-components",
|
|
3
|
+
"version": "0.0.0-next.0da151e",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Takaro UI is a simple and customizable component library to build React apps faster within the Takaro eco system",
|
|
6
|
+
"license": "AGPL-3.0-or-later",
|
|
7
|
+
"main": "src/index.ts",
|
|
8
|
+
"types": "src/index.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "storybook build -c ../../.storybook",
|
|
11
|
+
"start:dev": "storybook dev --no-open -c ../../.storybook -p 13002",
|
|
12
|
+
"test:unit": "CI=true vitest",
|
|
13
|
+
"test:snapshot": "vitest -u"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/readme.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Ui
|
|
2
|
+
|
|
3
|
+
Ui is a package that does not run on its own and the core should always be included with other packages.
|
|
4
|
+
|
|
5
|
+
The dockerfiles however contain the storybook build.
|
|
6
|
+
|
|
7
|
+
# Note
|
|
8
|
+
|
|
9
|
+
Keep typescript at 4.2.2. Otherwise storybook-docgen will not work.
|
|
10
|
+
Could maybe be fixed by upgrading all the plugins, but cba atm, it is too fragile :)
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { styled } from '../../../styled';
|
|
4
|
+
import { Button, ButtonProps } from '.';
|
|
5
|
+
import { AiFillCloud as Icon } from 'react-icons/ai';
|
|
6
|
+
|
|
7
|
+
const Wrapper = styled.div`
|
|
8
|
+
width: 100%;
|
|
9
|
+
display: grid;
|
|
10
|
+
grid-template-columns: repeat(4, auto);
|
|
11
|
+
grid-gap: 2rem;
|
|
12
|
+
padding: 5rem;
|
|
13
|
+
background: ${({ theme }) => theme.colors.background};
|
|
14
|
+
|
|
15
|
+
div {
|
|
16
|
+
button {
|
|
17
|
+
margin: 15px 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
title: 'Actions/Button',
|
|
24
|
+
component: Button,
|
|
25
|
+
decorators: [(story) => <Wrapper>{story()}</Wrapper>],
|
|
26
|
+
args: {
|
|
27
|
+
size: 'medium',
|
|
28
|
+
children: 'basic button',
|
|
29
|
+
variant: 'default',
|
|
30
|
+
type: 'button',
|
|
31
|
+
disabled: false,
|
|
32
|
+
isLoading: false,
|
|
33
|
+
color: 'primary',
|
|
34
|
+
onClick: undefined,
|
|
35
|
+
},
|
|
36
|
+
} as Meta<ButtonProps>;
|
|
37
|
+
|
|
38
|
+
export const Default: StoryFn<ButtonProps> = (args) => <Button {...args} />;
|
|
39
|
+
|
|
40
|
+
export const Examples = () => (
|
|
41
|
+
<>
|
|
42
|
+
{/* Default */}
|
|
43
|
+
<Button
|
|
44
|
+
onClick={() => {
|
|
45
|
+
/* */
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
Default Button
|
|
49
|
+
</Button>
|
|
50
|
+
<Button
|
|
51
|
+
icon={<Icon size={20} />}
|
|
52
|
+
onClick={() => {
|
|
53
|
+
/* */
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
Icon Button
|
|
57
|
+
</Button>
|
|
58
|
+
<Button
|
|
59
|
+
disabled
|
|
60
|
+
onClick={() => {
|
|
61
|
+
/* */
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
Disabled Button
|
|
65
|
+
</Button>
|
|
66
|
+
<Button
|
|
67
|
+
isLoading
|
|
68
|
+
onClick={() => {
|
|
69
|
+
/* */
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
Loading Button
|
|
73
|
+
</Button>
|
|
74
|
+
|
|
75
|
+
{/* Outline */}
|
|
76
|
+
<Button
|
|
77
|
+
onClick={() => {
|
|
78
|
+
/* */
|
|
79
|
+
}}
|
|
80
|
+
variant="outline"
|
|
81
|
+
>
|
|
82
|
+
Outlined Button
|
|
83
|
+
</Button>
|
|
84
|
+
<Button
|
|
85
|
+
icon={<Icon size={20} />}
|
|
86
|
+
onClick={() => {
|
|
87
|
+
/* */
|
|
88
|
+
}}
|
|
89
|
+
variant="outline"
|
|
90
|
+
>
|
|
91
|
+
Icon Button
|
|
92
|
+
</Button>
|
|
93
|
+
<Button
|
|
94
|
+
disabled
|
|
95
|
+
onClick={() => {
|
|
96
|
+
/* */
|
|
97
|
+
}}
|
|
98
|
+
variant="outline"
|
|
99
|
+
>
|
|
100
|
+
Disabled Button
|
|
101
|
+
</Button>
|
|
102
|
+
<Button
|
|
103
|
+
isLoading
|
|
104
|
+
onClick={() => {
|
|
105
|
+
/* */
|
|
106
|
+
}}
|
|
107
|
+
variant="outline"
|
|
108
|
+
>
|
|
109
|
+
Loading Button
|
|
110
|
+
</Button>
|
|
111
|
+
|
|
112
|
+
{/* Clear */}
|
|
113
|
+
<Button
|
|
114
|
+
onClick={() => {
|
|
115
|
+
/* */
|
|
116
|
+
}}
|
|
117
|
+
variant="clear"
|
|
118
|
+
>
|
|
119
|
+
Clear Button
|
|
120
|
+
</Button>
|
|
121
|
+
<Button
|
|
122
|
+
icon={<Icon size={20} />}
|
|
123
|
+
onClick={() => {
|
|
124
|
+
/* */
|
|
125
|
+
}}
|
|
126
|
+
variant="clear"
|
|
127
|
+
>
|
|
128
|
+
Icon Button
|
|
129
|
+
</Button>
|
|
130
|
+
<Button
|
|
131
|
+
disabled
|
|
132
|
+
onClick={() => {
|
|
133
|
+
/* */
|
|
134
|
+
}}
|
|
135
|
+
variant="clear"
|
|
136
|
+
>
|
|
137
|
+
Disabled Button
|
|
138
|
+
</Button>
|
|
139
|
+
<Button
|
|
140
|
+
isLoading
|
|
141
|
+
onClick={() => {
|
|
142
|
+
/* */
|
|
143
|
+
}}
|
|
144
|
+
variant="clear"
|
|
145
|
+
>
|
|
146
|
+
Loading Button
|
|
147
|
+
</Button>
|
|
148
|
+
</>
|
|
149
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Button } from '.';
|
|
2
|
+
import { expect, it } from 'vitest';
|
|
3
|
+
import { render } from '../../../test/testUtils';
|
|
4
|
+
|
|
5
|
+
it('Should render <Button/>', () => {
|
|
6
|
+
const { container } = render(<Button>button text</Button>);
|
|
7
|
+
expect(container).toMatchSnapshot();
|
|
8
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Button/> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
display: -webkit-box;
|
|
6
|
+
display: -webkit-flex;
|
|
7
|
+
display: -ms-flexbox;
|
|
8
|
+
display: flex;
|
|
9
|
+
-webkit-align-items: center;
|
|
10
|
+
-webkit-box-align: center;
|
|
11
|
+
-ms-flex-align: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
-webkit-box-pack: center;
|
|
14
|
+
-webkit-justify-content: center;
|
|
15
|
+
-ms-flex-pack: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
width: -webkit-fit-content;
|
|
18
|
+
width: -moz-fit-content;
|
|
19
|
+
width: fit-content;
|
|
20
|
+
border-radius: 0.8rem;
|
|
21
|
+
background: #664DE5;
|
|
22
|
+
background-size: 200% auto;
|
|
23
|
+
font-weight: 900;
|
|
24
|
+
border: 2px solid none;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
line-height: 19px;
|
|
27
|
+
-webkit-letter-spacing: 0;
|
|
28
|
+
-moz-letter-spacing: 0;
|
|
29
|
+
-ms-letter-spacing: 0;
|
|
30
|
+
letter-spacing: 0;
|
|
31
|
+
box-shadow: rgb(0 0 0 / 5%) 0px 15px 30px 0px;
|
|
32
|
+
-webkit-transition: all 0.3s cubic-bezier(0.25,0.8,0.25,1);
|
|
33
|
+
transition: all 0.3s cubic-bezier(0.25,0.8,0.25,1);
|
|
34
|
+
padding: 11px 18px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.c0 span {
|
|
38
|
+
margin-left: 0px;
|
|
39
|
+
color: white;
|
|
40
|
+
font-size: 1.25rem;
|
|
41
|
+
font-weight: 800;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.c0 span:hover {
|
|
45
|
+
color: white;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.c0:focus {
|
|
49
|
+
outline: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.c0:hover {
|
|
53
|
+
background-position: right center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.c0:disabled {
|
|
57
|
+
cursor: default;
|
|
58
|
+
background: #d3d3d3;
|
|
59
|
+
border-color: transparent;
|
|
60
|
+
color: white;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.c0:disabled span {
|
|
64
|
+
color: white;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.c0:disabled:hover span {
|
|
68
|
+
color: white;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.c0 svg {
|
|
72
|
+
display: none;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
fill: white;
|
|
75
|
+
stroke: white;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
<div>
|
|
79
|
+
<button
|
|
80
|
+
class="c0"
|
|
81
|
+
color="primary"
|
|
82
|
+
type="button"
|
|
83
|
+
>
|
|
84
|
+
<span>
|
|
85
|
+
button text
|
|
86
|
+
</span>
|
|
87
|
+
</button>
|
|
88
|
+
</div>
|
|
89
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Button/> 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<button
|
|
6
|
+
class="sc-ggqIjW dRTgIR"
|
|
7
|
+
color="primary"
|
|
8
|
+
tabindex="0"
|
|
9
|
+
type="button"
|
|
10
|
+
>
|
|
11
|
+
|
|
12
|
+
<span>
|
|
13
|
+
button text
|
|
14
|
+
</span>
|
|
15
|
+
|
|
16
|
+
</button>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { JSX, cloneElement, forwardRef, MouseEvent as ReactMouseEvent, ReactElement, PropsWithChildren } from 'react';
|
|
2
|
+
import { Spinner } from '../../../components';
|
|
3
|
+
import { ButtonColor, Default, Outline, Clear } from './style';
|
|
4
|
+
import { Size, Variant } from '../../../styled';
|
|
5
|
+
|
|
6
|
+
export interface ButtonProps {
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
onClick?: (event: ReactMouseEvent<HTMLButtonElement, MouseEvent>) => unknown;
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
icon?: ReactElement;
|
|
11
|
+
iconPosition?: 'left' | 'right';
|
|
12
|
+
className?: string;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
size?: Size;
|
|
15
|
+
type?: 'submit' | 'reset' | 'button';
|
|
16
|
+
// TODO: clear should be renamed to text
|
|
17
|
+
variant?: Variant | 'clear';
|
|
18
|
+
color?: ButtonColor | 'white';
|
|
19
|
+
/// When nesting forms a button can be linked to only fire the form with the given name.
|
|
20
|
+
form?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const Button = forwardRef<HTMLButtonElement, PropsWithChildren<ButtonProps>>(function Button(
|
|
24
|
+
{
|
|
25
|
+
icon,
|
|
26
|
+
iconPosition = 'left',
|
|
27
|
+
size = 'medium',
|
|
28
|
+
type = 'button',
|
|
29
|
+
isLoading = false,
|
|
30
|
+
className,
|
|
31
|
+
children,
|
|
32
|
+
form,
|
|
33
|
+
color = 'primary',
|
|
34
|
+
disabled = false,
|
|
35
|
+
fullWidth = false,
|
|
36
|
+
variant = 'default',
|
|
37
|
+
onClick = () => {},
|
|
38
|
+
},
|
|
39
|
+
ref,
|
|
40
|
+
) {
|
|
41
|
+
function getIcon(): JSX.Element {
|
|
42
|
+
if (isLoading) return <Spinner color={variant === 'default' ? 'white' : color} size="small" />;
|
|
43
|
+
|
|
44
|
+
if (icon) return cloneElement(icon, { size: 20 });
|
|
45
|
+
|
|
46
|
+
return <></>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getVariant(): JSX.Element {
|
|
50
|
+
const props = {
|
|
51
|
+
className: className,
|
|
52
|
+
color: color,
|
|
53
|
+
disabled: disabled,
|
|
54
|
+
iconPosition: iconPosition,
|
|
55
|
+
form: form,
|
|
56
|
+
icon: !!icon,
|
|
57
|
+
isLoading: isLoading,
|
|
58
|
+
onClick: !disabled || !isLoading ? onClick : undefined,
|
|
59
|
+
size: size,
|
|
60
|
+
fullWidth: fullWidth,
|
|
61
|
+
type: type,
|
|
62
|
+
ref: ref,
|
|
63
|
+
tabIndex: disabled ? -1 : 0,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
switch (variant) {
|
|
67
|
+
case 'default':
|
|
68
|
+
return (
|
|
69
|
+
<Default {...props}>
|
|
70
|
+
{iconPosition === 'left' && getIcon()} <span>{children}</span> {iconPosition === 'right' && getIcon()}
|
|
71
|
+
</Default>
|
|
72
|
+
);
|
|
73
|
+
case 'outline':
|
|
74
|
+
return (
|
|
75
|
+
<Outline {...props}>
|
|
76
|
+
{iconPosition === 'left' && getIcon()} <span>{children}</span> {iconPosition === 'right' && getIcon()}
|
|
77
|
+
</Outline>
|
|
78
|
+
);
|
|
79
|
+
case 'clear':
|
|
80
|
+
return (
|
|
81
|
+
<Clear {...props}>
|
|
82
|
+
{iconPosition === 'left' && getIcon()} <span>{children}</span> {iconPosition === 'right' && getIcon()}
|
|
83
|
+
</Clear>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return getVariant();
|
|
89
|
+
});
|