@takaro/lib-components 0.0.15 → 0.0.18
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/Dockerfile.dev +1 -1
- package/package.json +5 -7
- package/src/components/actions/Button/Button.test.tsx +2 -1
- package/src/components/actions/Button/__snapshots__/Button.test.tsx.snap +18 -0
- package/src/components/actions/Button/style.ts +1 -0
- package/src/components/actions/DropdownButton/index.tsx +51 -36
- package/src/components/actions/IconButton/IconButton.test.tsx +3 -2
- 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 +2 -16
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +0 -1
- package/src/components/charts/GeoMercator/index.tsx +3 -3
- package/src/components/charts/RadialBarChart/index.tsx +1 -1
- package/src/components/data/Chip/Chip.test.tsx +3 -2
- package/src/components/data/Chip/__snapshots__/Chip.test.tsx.snap +38 -0
- package/src/components/data/Console/Console.tsx +1 -7
- package/src/components/data/Console/ConsoleLine/index.tsx +1 -1
- package/src/components/data/Console/constants.ts +6 -0
- package/src/components/data/Table/index.tsx +30 -1
- package/src/components/data/Table/subcomponents/Filter/field.tsx +2 -3
- package/src/components/data/Table/subcomponents/Filter/index.tsx +1 -11
- package/src/components/data/Table/subcomponents/Filter/types.ts +10 -0
- package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +0 -1
- package/src/components/data/index.ts +0 -3
- package/src/components/dialogs/Dialog/DialogBody.tsx +1 -0
- package/src/components/feedback/Alert/Alert.test.tsx +2 -1
- package/src/components/feedback/Alert/__snapshots__/Alert.test.tsx.snap +44 -0
- package/src/components/feedback/IconTooltip/IconTooltip.stories.tsx +22 -0
- package/src/components/feedback/IconTooltip/index.tsx +50 -0
- package/src/components/feedback/Loaders/Loading.test.tsx +2 -1
- package/src/components/feedback/Loaders/Spinner.test.tsx +2 -1
- 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/NetworkDetector/NetworkDetector.test.tsx +2 -1
- package/src/components/feedback/NetworkDetector/__snapshots__/NetworkDetector.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +2 -1
- package/src/components/feedback/NotificationBanner/__snapshots__/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/ProgressBar/ProgressBar.stories.tsx +2 -1
- package/src/components/feedback/ProgressBar/index.tsx +58 -24
- package/src/components/feedback/Skeleton/Skeleton.test.tsx +2 -1
- package/src/components/feedback/Skeleton/__snapshots__/Skeleton.test.tsx.snap +9 -0
- package/src/components/feedback/Tooltip/TooltipContent.tsx +2 -2
- package/src/components/feedback/Tooltip/useTooltip.tsx +3 -0
- package/src/components/feedback/index.ts +2 -1
- package/src/components/feedback/snacks/Drawer/index.tsx +15 -4
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +1 -1
- package/src/components/inputs/Date/DateRangePicker/Generic.tsx +2 -1
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +1 -17
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +1 -17
- package/src/components/inputs/Date/types.ts +14 -0
- package/src/components/inputs/DurationField/Generic.tsx +0 -1
- package/src/components/inputs/TextField/Controlled.tsx +1 -1
- package/src/components/inputs/TextField/Generic.tsx +79 -56
- package/src/components/inputs/TextField/TextField.stories.tsx +21 -1
- package/src/components/inputs/TextField/style.ts +6 -0
- package/src/components/inputs/TextField/util.ts +7 -2
- package/src/components/inputs/index.ts +1 -0
- package/src/components/inputs/layout/Description.tsx +0 -5
- package/src/components/inputs/layout/Label/style.ts +0 -1
- package/src/components/inputs/layout/index.ts +3 -1
- package/src/components/inputs/layout/setAriaDescribedBy.ts +3 -0
- package/src/components/inputs/selects/SelectField/Controlled.tsx +0 -2
- package/src/components/inputs/selects/SelectField/Generic/index.tsx +11 -14
- package/src/components/inputs/selects/SelectQueryField/Controlled.tsx +2 -2
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +115 -40
- package/src/components/inputs/selects/SelectQueryField/style.ts +0 -1
- package/src/components/inputs/selects/SubComponents/Option.tsx +1 -1
- package/src/components/inputs/selects/sharedStyle.ts +0 -2
- package/src/components/layout/Container/index.ts +1 -1
- package/src/components/layout/index.ts +1 -1
- package/src/components/navigation/HorizontalNav/HorizontalNav.stories.tsx +6 -22
- package/src/components/navigation/HorizontalNav/index.tsx +1 -1
- package/src/components/navigation/HorizontalNav/style.ts +28 -3
- package/src/components/navigation/Steppers/SlimStepper/Stepper.stories.tsx +2 -1
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +4 -4
- package/src/components/navigation/Steppers/Stepper/Stepper.stories.tsx +2 -1
- package/src/components/navigation/Steppers/Stepper/index.tsx +4 -4
- package/src/components/navigation/Steppers/context.tsx +2 -49
- package/src/components/navigation/Steppers/provider.tsx +18 -0
- package/src/components/navigation/Steppers/useStepper.ts +34 -0
- package/src/components/navigation/index.ts +2 -1
- package/src/components/other/ActionMenu/index.tsx +20 -11
- package/src/components/other/ActionMenu/style.ts +2 -2
- package/src/components/other/ClipBoard/ClipBoard.test.tsx +2 -1
- package/src/components/other/ClipBoard/__snapshots__/ClipBoard.test.tsx.snap +36 -0
- package/src/components/other/Empty/Empty.test.tsx +5 -2
- package/src/components/other/Empty/__snapshots__/Empty.test.tsx.snap +21 -0
- package/src/components/other/PermissionsGuard/hasPermissionsHelper.ts +18 -0
- package/src/components/other/PermissionsGuard/index.tsx +1 -17
- package/src/components/other/Plan/Plan.stories.tsx +21 -0
- package/src/components/other/Plan/index.tsx +93 -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 +10 -2
- package/src/components/visual/Card/index.tsx +11 -8
- package/src/components/visual/Divider/Divider.test.tsx +2 -1
- package/src/components/visual/Divider/__snapshots__/Divider.test.tsx.snap +13 -0
- package/src/components/visual/Divider/index.tsx +9 -6
- package/src/errors/errors.ts +1 -1
- package/src/helpers/regexprs.ts +2 -1
- package/tsconfig.json +0 -5
- package/vite.config.mts +17 -0
- package/src/components/data/LinkCard/index.tsx +0 -28
- package/src/components/feedback/QuestionTooltip/QuestionTooltip.stories.tsx +0 -20
- package/src/components/feedback/QuestionTooltip/index.tsx +0 -35
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { Size, styled } from '../../../styled';
|
|
2
|
+
import { Color, Size, styled } from '../../../styled';
|
|
3
3
|
|
|
4
4
|
const Container = styled.div<{ size: Size; fullWidth: boolean }>`
|
|
5
5
|
position: relative;
|
|
@@ -18,21 +18,23 @@ const Container = styled.div<{ size: Size; fullWidth: boolean }>`
|
|
|
18
18
|
case 'large':
|
|
19
19
|
return `margin: ${theme.spacing['2_5']} auto ${theme.spacing['2_5']} auto`;
|
|
20
20
|
case 'huge':
|
|
21
|
-
return `margin: ${theme.spacing[
|
|
21
|
+
return `margin: ${theme.spacing[6]} auto ${theme.spacing[6]} auto`;
|
|
22
22
|
}
|
|
23
23
|
}}
|
|
24
24
|
`;
|
|
25
25
|
|
|
26
26
|
const Label = styled.label<{
|
|
27
27
|
position: 'left' | 'center' | 'right';
|
|
28
|
+
color: Color | 'text' | 'textAlt';
|
|
28
29
|
}>`
|
|
29
30
|
position: absolute;
|
|
30
31
|
top: 50%;
|
|
31
|
-
transform: translateY(-50%);
|
|
32
|
+
transform: translateY(-50%) translateX(-50%);
|
|
32
33
|
p {
|
|
33
|
-
color: ${({ theme }) => theme.colors
|
|
34
|
-
background-color: ${({ theme }) => theme.colors.
|
|
34
|
+
color: ${({ theme, color }) => theme.colors[color]};
|
|
35
|
+
background-color: ${({ theme }) => theme.colors.backgroundAlt};
|
|
35
36
|
font-size: 1.325rem;
|
|
37
|
+
font-weight: 500;
|
|
36
38
|
padding: ${({ theme }) => `0 ${theme.spacing['0_5']}`};
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -62,6 +64,7 @@ const Line = styled.div`
|
|
|
62
64
|
type LabelProps = {
|
|
63
65
|
text: string;
|
|
64
66
|
labelPosition: 'left' | 'center' | 'right';
|
|
67
|
+
color?: Color | 'text' | 'textAlt';
|
|
65
68
|
};
|
|
66
69
|
|
|
67
70
|
export interface DividerProps {
|
|
@@ -76,7 +79,7 @@ export const Divider: FC<DividerProps> = ({ label, size = 'medium', fullWidth =
|
|
|
76
79
|
<Container fullWidth={fullWidth} size={size}>
|
|
77
80
|
<Line />
|
|
78
81
|
{label && (
|
|
79
|
-
<Label position={label.labelPosition}>
|
|
82
|
+
<Label position={label.labelPosition} color={label.color ? label.color : 'textAlt'}>
|
|
80
83
|
<p>{label.text}</p>
|
|
81
84
|
</Label>
|
|
82
85
|
)}
|
package/src/errors/errors.ts
CHANGED
|
@@ -40,7 +40,7 @@ export function getErrorUserMessage(
|
|
|
40
40
|
if (err instanceof UniqueConstraintError) {
|
|
41
41
|
if (err.message === 'Unique constraint violation') {
|
|
42
42
|
const messageType = err.constructor.name as keyof ErrorMessageMapping;
|
|
43
|
-
return errorMessages[messageType] ||
|
|
43
|
+
return errorMessages[messageType] || err.message;
|
|
44
44
|
} else {
|
|
45
45
|
return err.message;
|
|
46
46
|
}
|
package/src/helpers/regexprs.ts
CHANGED
|
@@ -2,7 +2,8 @@ export const REGEXPR_STEAM_API_KEY = /\w{32}/;
|
|
|
2
2
|
export const IPV4_REGEX = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/;
|
|
3
3
|
export const IPV4_AND_PORT_REGEX =
|
|
4
4
|
/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):([0-9]{1,5})\b/;
|
|
5
|
-
export const
|
|
5
|
+
export const FQDN_AND_PORT_REGEX =
|
|
6
|
+
/^(?=.{4,253}(?::\d{1,5})?$)((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}(?::\d{1,5})?$/;
|
|
6
7
|
|
|
7
8
|
export const IPV6_REGEX =
|
|
8
9
|
/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/;
|
package/tsconfig.json
CHANGED
package/vite.config.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import react from '@vitejs/plugin-react-swc';
|
|
4
|
+
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
5
|
+
import checker from 'vite-plugin-checker';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
test: {
|
|
9
|
+
globals: true,
|
|
10
|
+
environment: 'jsdom',
|
|
11
|
+
},
|
|
12
|
+
css: {
|
|
13
|
+
transformer: 'lightningcss',
|
|
14
|
+
},
|
|
15
|
+
plugins: [react(), checker({ typescript: true }), tsconfigPaths()],
|
|
16
|
+
envDir: '../../',
|
|
17
|
+
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { FC, ReactElement } from 'react';
|
|
2
|
-
import { styled } from '../../../styled';
|
|
3
|
-
import { AiOutlineLink as LinkIcon } from 'react-icons/ai';
|
|
4
|
-
import { FiExternalLink as ExternalLinkIcon } from 'react-icons/fi';
|
|
5
|
-
|
|
6
|
-
const Container = styled.li`
|
|
7
|
-
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
8
|
-
border: 1px solid ${({ theme }) => theme.colors.secondary};
|
|
9
|
-
padding: ${({ theme }) => theme.spacing['1']};
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
export interface LinkCardProps {
|
|
13
|
-
icon?: ReactElement;
|
|
14
|
-
label: string;
|
|
15
|
-
href: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const LinkCard: FC<LinkCardProps> = ({ label, href, icon }) => {
|
|
19
|
-
return (
|
|
20
|
-
<Container>
|
|
21
|
-
{icon || <LinkIcon />}
|
|
22
|
-
<span>{label}</span>
|
|
23
|
-
<a href={href}>
|
|
24
|
-
<ExternalLinkIcon />
|
|
25
|
-
</a>
|
|
26
|
-
</Container>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
-
import { QuestionTooltip } from '.';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Feedback/QuestionTooltip',
|
|
7
|
-
component: QuestionTooltip,
|
|
8
|
-
args: {
|
|
9
|
-
placement: 'bottom',
|
|
10
|
-
label: 'this is the tooltip content',
|
|
11
|
-
},
|
|
12
|
-
} as Meta;
|
|
13
|
-
|
|
14
|
-
export const Default: StoryFn = () => {
|
|
15
|
-
return (
|
|
16
|
-
<div>
|
|
17
|
-
<QuestionTooltip>this is the tooltip content</QuestionTooltip>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { Tooltip, TooltipProps } from '../Tooltip';
|
|
3
|
-
import { AiOutlineQuestion as QuestionIcon } from 'react-icons/ai';
|
|
4
|
-
import { styled } from '../../../styled';
|
|
5
|
-
|
|
6
|
-
const TriggerContainer = styled.div`
|
|
7
|
-
background-color: ${({ theme }) => theme.colors.backgroundAlt};
|
|
8
|
-
border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
9
|
-
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
10
|
-
display: flex;
|
|
11
|
-
align-items: center;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
margin-left: ${({ theme }) => theme.spacing['0_5']};
|
|
14
|
-
margin-right: ${({ theme }) => theme.spacing['0_5']};
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
const ContentContainer = styled.div`
|
|
18
|
-
max-width: 450px;
|
|
19
|
-
hyphens: auto;
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
export const QuestionTooltip: FC<TooltipProps> = ({ children }) => {
|
|
23
|
-
return (
|
|
24
|
-
<Tooltip>
|
|
25
|
-
<Tooltip.Trigger asChild>
|
|
26
|
-
<TriggerContainer>
|
|
27
|
-
<QuestionIcon size="18" />
|
|
28
|
-
</TriggerContainer>
|
|
29
|
-
</Tooltip.Trigger>
|
|
30
|
-
<Tooltip.Content>
|
|
31
|
-
<ContentContainer>{children}</ContentContainer>
|
|
32
|
-
</Tooltip.Content>
|
|
33
|
-
</Tooltip>
|
|
34
|
-
);
|
|
35
|
-
};
|