@ssa-ui-kit/core 0.0.24-alpha → 0.0.26-alpha
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/dist/components/AccordionGroup/AccordionContext.d.ts +3 -3
- package/dist/components/AccordionGroup/types.d.ts +1 -1
- package/dist/components/Badge/helpers.d.ts +2 -2
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Button/ButtonText.d.ts +6 -6
- package/dist/components/Button/fixtures.d.ts +6 -6
- package/dist/components/Button/helpers.d.ts +2 -2
- package/dist/components/Button/types.d.ts +5 -5
- package/dist/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/components/Checkbox/CheckboxBase.d.ts +2 -2
- package/dist/components/Checkbox/types.d.ts +2 -2
- package/dist/components/Dropdown/Dropdown.d.ts +3 -3
- package/dist/components/Dropdown/types.d.ts +3 -3
- package/dist/components/DropdownOption/DropdownOption.d.ts +2 -2
- package/dist/components/DropdownOptions/DropdownOptions.d.ts +2 -2
- package/dist/components/DropdownOptions/index.d.ts +1 -1
- package/dist/components/DropdownOptions/types.d.ts +2 -2
- package/dist/components/DropdownToggle/DropdownToggle.d.ts +3 -3
- package/dist/components/DropdownToggle/types.d.ts +1 -1
- package/dist/components/FormCheckbox/FormCheckbox.d.ts +2 -2
- package/dist/components/FormCheckbox/types.d.ts +2 -2
- package/dist/components/FormHelperText/FormHelperText.d.ts +2 -2
- package/dist/components/FormHelperText/types.d.ts +1 -1
- package/dist/components/FormRadioGroup/FormRadioGroup.d.ts +2 -2
- package/dist/components/FormRadioGroup/types.d.ts +2 -2
- package/dist/components/Icon/types.d.ts +2 -2
- package/dist/components/LargeTab/LargeTab.d.ts +2 -2
- package/dist/components/LargeTab/LargeTabBase.d.ts +2 -2
- package/dist/components/MultipleDropdown/MultipleDropdown.context.d.ts +3 -3
- package/dist/components/MultipleDropdown/MultipleDropdown.d.ts +3 -3
- package/dist/components/MultipleDropdown/types.d.ts +3 -3
- package/dist/components/MultipleDropdown/utils.d.ts +2 -2
- package/dist/components/MultipleDropdownOptions/MultipleDropdownOptions.d.ts +2 -2
- package/dist/components/MultipleDropdownOptions/index.d.ts +1 -1
- package/dist/components/MultipleDropdownOptions/types.d.ts +2 -2
- package/dist/components/Popover/PopoverTrigger.d.ts +2 -2
- package/dist/components/Radio/Radio.d.ts +2 -2
- package/dist/components/Radio/types.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
- package/dist/components/RadioGroup/types.d.ts +3 -3
- package/dist/components/ResponsiveImage/ResponsiveImage.d.ts +2 -2
- package/dist/components/ResponsiveImage/types.d.ts +1 -1
- package/dist/components/Switch/Switch.d.ts +2 -2
- package/dist/components/Switch/SwitchContext.d.ts +3 -3
- package/dist/components/Switch/types.d.ts +1 -1
- package/dist/components/Tab/Tab.d.ts +2 -2
- package/dist/components/Tab/TabBase.d.ts +2 -2
- package/dist/components/TabBar/TabBar.d.ts +2 -2
- package/dist/components/TabBar/TabBarContext.d.ts +4 -4
- package/dist/components/TabBar/stories/helpers.d.ts +2 -2
- package/dist/components/TabBar/types.d.ts +9 -11
- package/dist/components/Tooltip/ProgressChartTooltip.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.d.ts +2 -2
- package/dist/components/Tooltip/types.d.ts +12 -14
- package/dist/components/Tooltip/utils.d.ts +2 -2
- package/dist/components/TooltipContent/TooltipContent.d.ts +2 -2
- package/dist/components/TooltipContent/index.d.ts +0 -1
- package/dist/components/TooltipTrigger/TooltipTrigger.d.ts +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -5
- package/src/components/AccordionGroup/AccordionContext.tsx +4 -4
- package/src/components/AccordionGroup/types.ts +1 -1
- package/src/components/Badge/helpers.ts +18 -16
- package/src/components/Button/Button.spec.tsx +8 -8
- package/src/components/Button/Button.tsx +3 -3
- package/src/components/Button/ButtonText.tsx +6 -6
- package/src/components/Button/fixtures.ts +14 -14
- package/src/components/Button/helpers.ts +2 -2
- package/src/components/Button/types.ts +5 -5
- package/src/components/Checkbox/Checkbox.spec.tsx +2 -2
- package/src/components/Checkbox/Checkbox.stories.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +2 -2
- package/src/components/Checkbox/CheckboxBase.tsx +2 -2
- package/src/components/Checkbox/types.ts +2 -2
- package/src/components/Dropdown/Dropdown.stories.tsx +3 -3
- package/src/components/Dropdown/Dropdown.tsx +4 -4
- package/src/components/Dropdown/types.ts +4 -3
- package/src/components/DropdownOption/DropdownOption.tsx +2 -2
- package/src/components/DropdownOptions/DropdownOptions.tsx +2 -2
- package/src/components/DropdownOptions/index.ts +1 -1
- package/src/components/DropdownOptions/types.ts +2 -2
- package/src/components/DropdownToggle/DropdownToggle.tsx +3 -3
- package/src/components/DropdownToggle/types.ts +1 -1
- package/src/components/FormCheckbox/FormCheckbox.tsx +2 -2
- package/src/components/FormCheckbox/types.ts +3 -3
- package/src/components/FormHelperText/FormHelperText.tsx +2 -2
- package/src/components/FormHelperText/types.ts +1 -1
- package/src/components/FormRadioGroup/FormRadioGroup.stories.tsx +2 -2
- package/src/components/FormRadioGroup/FormRadioGroup.tsx +2 -2
- package/src/components/FormRadioGroup/types.ts +3 -3
- package/src/components/Icon/Icons.spec.tsx +6 -6
- package/src/components/Icon/icons/index.tsx +3 -3
- package/src/components/Icon/types.ts +2 -2
- package/src/components/LargeTab/LargeTab.tsx +2 -2
- package/src/components/LargeTab/LargeTabBase.tsx +2 -2
- package/src/components/MultipleDropdown/MultipleDropdown.context.ts +3 -3
- package/src/components/MultipleDropdown/MultipleDropdown.tsx +7 -7
- package/src/components/MultipleDropdown/types.ts +3 -3
- package/src/components/MultipleDropdown/utils.ts +2 -2
- package/src/components/MultipleDropdownOptions/MultipleDropdownOptions.tsx +2 -2
- package/src/components/MultipleDropdownOptions/index.ts +1 -1
- package/src/components/MultipleDropdownOptions/types.ts +2 -2
- package/src/components/Popover/PopoverTrigger.tsx +3 -3
- package/src/components/Radio/Radio.tsx +2 -2
- package/src/components/Radio/types.ts +1 -1
- package/src/components/RadioGroup/RadioGroup.tsx +2 -2
- package/src/components/RadioGroup/types.ts +3 -3
- package/src/components/ResponsiveImage/ResponsiveImage.tsx +2 -2
- package/src/components/ResponsiveImage/types.ts +1 -1
- package/src/components/Switch/Switch.tsx +2 -2
- package/src/components/Switch/SwitchContext.tsx +2 -2
- package/src/components/Switch/types.ts +1 -1
- package/src/components/Tab/Tab.tsx +2 -2
- package/src/components/Tab/TabBase.tsx +2 -3
- package/src/components/TabBar/TabBar.spec.tsx +5 -5
- package/src/components/TabBar/TabBar.tsx +2 -2
- package/src/components/TabBar/TabBarContext.tsx +6 -6
- package/src/components/TabBar/stories/helpers.tsx +4 -4
- package/src/components/TabBar/types.ts +9 -12
- package/src/components/Tooltip/ProgressChartTooltip.tsx +2 -2
- package/src/components/Tooltip/Tooltip.stories.tsx +14 -29
- package/src/components/Tooltip/Tooltip.tsx +2 -2
- package/src/components/Tooltip/types.ts +12 -14
- package/src/components/Tooltip/utils.tsx +2 -2
- package/src/components/TooltipContent/TooltipContent.tsx +6 -28
- package/src/components/TooltipContent/index.ts +0 -1
- package/src/components/TooltipTrigger/TooltipTrigger.tsx +2 -2
- package/src/components/index.ts +1 -1
- package/tsbuildcache +1 -1
- package/dist/components/TooltipContent/constants.d.ts +0 -1
- package/src/components/TooltipContent/constants.ts +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssa-ui-kit/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26-alpha",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"private": false,
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@nivo/line": "0.83.0",
|
|
24
24
|
"@playwright/test": "^1.37.1",
|
|
25
25
|
"@testing-library/jest-dom": "^5.16.5",
|
|
26
|
-
"@types/dompurify": "^3.0.5",
|
|
27
26
|
"@types/testing-library__jest-dom": "^5.14.6",
|
|
28
27
|
"@types/uuid": "^9.0.3",
|
|
29
28
|
"resolve-tspaths": "^0.8.16",
|
|
@@ -37,14 +36,13 @@
|
|
|
37
36
|
"@emotion/react": "^11.11.1",
|
|
38
37
|
"@emotion/styled": "^11.11.0",
|
|
39
38
|
"@floating-ui/react": "0.25.4",
|
|
40
|
-
"dompurify": "^3.1.3",
|
|
41
39
|
"dotenv": "^16.0.3",
|
|
42
40
|
"js-tokens": "^4.0.0",
|
|
43
41
|
"loose-envify": "^1.4.0",
|
|
44
42
|
"scheduler": "^0.23.0",
|
|
45
43
|
"uuid": "^9.0.0",
|
|
46
|
-
"@ssa-ui-kit/
|
|
47
|
-
"@ssa-ui-kit/
|
|
44
|
+
"@ssa-ui-kit/utils": "^0.0.1-alpha",
|
|
45
|
+
"@ssa-ui-kit/hooks": "^0.0.2-alpha"
|
|
48
46
|
},
|
|
49
47
|
"browserslist": [
|
|
50
48
|
">0.1%",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createContext, useState, useContext } from 'react';
|
|
2
|
-
import { AccordionProps,
|
|
2
|
+
import { AccordionProps, AccordionGroupContextProps } from './types';
|
|
3
3
|
|
|
4
|
-
export const AccordionGroupContext = createContext<
|
|
5
|
-
{} as
|
|
4
|
+
export const AccordionGroupContext = createContext<AccordionGroupContextProps>(
|
|
5
|
+
{} as AccordionGroupContextProps,
|
|
6
6
|
);
|
|
7
7
|
|
|
8
8
|
export const useAccordionGroupContext = () => useContext(AccordionGroupContext);
|
|
9
9
|
|
|
10
|
-
const useAccordionGroup = ():
|
|
10
|
+
const useAccordionGroup = (): AccordionGroupContextProps => {
|
|
11
11
|
const [openedAccordions, setOpenedAccordions] = useState<AccordionProps[]>(
|
|
12
12
|
[],
|
|
13
13
|
);
|
|
@@ -51,7 +51,7 @@ export interface AccordionViewProps extends AccordionProps {
|
|
|
51
51
|
contentProps?: Record<string, any>;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export interface
|
|
54
|
+
export interface AccordionGroupContextProps {
|
|
55
55
|
openedAccordions: Array<AccordionProps> | [];
|
|
56
56
|
stayOpen: boolean;
|
|
57
57
|
setOpenedAccordions: (accordions: Array<AccordionProps>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MapIconsType } from '@components/Icon/types';
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
3
|
|
|
4
4
|
export const sizes: Array<keyof MainSizes> = ['small', 'medium', 'large'];
|
|
@@ -13,21 +13,23 @@ export const colors: Array<keyof MainColors> = [
|
|
|
13
13
|
'yellowWarm',
|
|
14
14
|
];
|
|
15
15
|
|
|
16
|
-
export const icons: Array<{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
export const icons: Array<{
|
|
17
|
+
color: keyof MainColors;
|
|
18
|
+
icon: keyof MapIconsType;
|
|
19
|
+
}> = [
|
|
20
|
+
{
|
|
21
|
+
color: 'blueLight',
|
|
22
|
+
icon: 'information',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
color: 'yellowWarm',
|
|
26
|
+
icon: 'warning',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
color: 'pink',
|
|
30
|
+
icon: 'attention',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
31
33
|
|
|
32
34
|
export const HeaderTitle = styled.span`
|
|
33
35
|
text-align: center;
|
|
@@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event';
|
|
|
3
3
|
import Icon from '@components/Icon';
|
|
4
4
|
|
|
5
5
|
import Button from './index';
|
|
6
|
-
import {
|
|
6
|
+
import { ButtonProps } from './types';
|
|
7
7
|
import {
|
|
8
8
|
primaryBtnSpecs,
|
|
9
9
|
secondaryBtnSpecs,
|
|
@@ -23,7 +23,7 @@ function setup(component: JSX.Element) {
|
|
|
23
23
|
const getElTestId = (
|
|
24
24
|
elType: string,
|
|
25
25
|
isDisabled?: boolean,
|
|
26
|
-
variant?:
|
|
26
|
+
variant?: ButtonProps['variant'],
|
|
27
27
|
isHovered?: boolean,
|
|
28
28
|
) => {
|
|
29
29
|
const prefix = isDisabled
|
|
@@ -60,9 +60,9 @@ const testButton = async (spec: TestPropsType) => {
|
|
|
60
60
|
|
|
61
61
|
const { user, getByRole, getByTestId, findByTitle } = setup(
|
|
62
62
|
<Button
|
|
63
|
-
type={type as
|
|
64
|
-
size={size as
|
|
65
|
-
variant={variant as
|
|
63
|
+
type={type as ButtonProps['type']}
|
|
64
|
+
size={size as ButtonProps['size']}
|
|
65
|
+
variant={variant as ButtonProps['variant']}
|
|
66
66
|
text={text}
|
|
67
67
|
endIcon={appendIcon}
|
|
68
68
|
startIcon={prependIcon}
|
|
@@ -116,9 +116,9 @@ const testTertiaryBtnHoverState = async (spec: TestPropsType) => {
|
|
|
116
116
|
|
|
117
117
|
const { user, getByRole, getByTestId, findByTitle } = setup(
|
|
118
118
|
<Button
|
|
119
|
-
type={type as
|
|
120
|
-
size={size as
|
|
121
|
-
variant={variant as
|
|
119
|
+
type={type as ButtonProps['type']}
|
|
120
|
+
size={size as ButtonProps['size']}
|
|
121
|
+
variant={variant as ButtonProps['variant']}
|
|
122
122
|
text={text}
|
|
123
123
|
endIcon={appendIcon}
|
|
124
124
|
startIcon={prependIcon}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
GreyLightButtonText,
|
|
11
11
|
DisabledButtonText,
|
|
12
12
|
} from './ButtonText';
|
|
13
|
-
import {
|
|
13
|
+
import { ButtonProps, ButtonVariants } from './types';
|
|
14
14
|
import {
|
|
15
15
|
large,
|
|
16
16
|
medium,
|
|
@@ -31,7 +31,7 @@ const mapSizes: MainSizes = {
|
|
|
31
31
|
large,
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const mapVariants:
|
|
34
|
+
const mapVariants: ButtonVariants = {
|
|
35
35
|
primary,
|
|
36
36
|
secondary,
|
|
37
37
|
tertiary,
|
|
@@ -39,7 +39,7 @@ const mapVariants: IButtonVariants = {
|
|
|
39
39
|
attention,
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
export const Button = forwardRef<HTMLButtonElement,
|
|
42
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
43
43
|
function Button(
|
|
44
44
|
{
|
|
45
45
|
block = false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useTheme } from '@emotion/react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ColoredButtonTextProps, ButtonTextProps } from './types';
|
|
4
4
|
|
|
5
|
-
export const ButtonText = ({ text, className, testId }:
|
|
5
|
+
export const ButtonText = ({ text, className, testId }: ButtonTextProps) => {
|
|
6
6
|
return (
|
|
7
7
|
<span className={className} data-testid={testId}>
|
|
8
8
|
{text}
|
|
@@ -10,7 +10,7 @@ export const ButtonText = ({ text, className, testId }: IButtonTextProps) => {
|
|
|
10
10
|
);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export const WhiteButtonText = ({ text }:
|
|
13
|
+
export const WhiteButtonText = ({ text }: ColoredButtonTextProps) => {
|
|
14
14
|
const theme = useTheme();
|
|
15
15
|
|
|
16
16
|
return (
|
|
@@ -24,7 +24,7 @@ export const WhiteButtonText = ({ text }: IColoredButtonTextProps) => {
|
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export const GreyButtonText = ({ text }:
|
|
27
|
+
export const GreyButtonText = ({ text }: ColoredButtonTextProps) => {
|
|
28
28
|
const theme = useTheme();
|
|
29
29
|
|
|
30
30
|
return (
|
|
@@ -38,7 +38,7 @@ export const GreyButtonText = ({ text }: IColoredButtonTextProps) => {
|
|
|
38
38
|
);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export const GreyLightButtonText = ({ text }:
|
|
41
|
+
export const GreyLightButtonText = ({ text }: ColoredButtonTextProps) => {
|
|
42
42
|
const theme = useTheme();
|
|
43
43
|
|
|
44
44
|
return (
|
|
@@ -52,7 +52,7 @@ export const GreyLightButtonText = ({ text }: IColoredButtonTextProps) => {
|
|
|
52
52
|
);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
export const DisabledButtonText = ({ text }:
|
|
55
|
+
export const DisabledButtonText = ({ text }: ColoredButtonTextProps) => {
|
|
56
56
|
const theme = useTheme();
|
|
57
57
|
|
|
58
58
|
return (
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Icon from '@components/Icon';
|
|
2
|
-
import {
|
|
2
|
+
import { ButtonProps } from './types';
|
|
3
3
|
|
|
4
4
|
export type TestPropsType = Omit<
|
|
5
|
-
|
|
5
|
+
ButtonProps,
|
|
6
6
|
'isDisabled' | 'startIcon' | 'endIcon'
|
|
7
7
|
> & {
|
|
8
8
|
disabled?: boolean;
|
|
@@ -125,41 +125,41 @@ const baseSpecs: TestPropsType[] = [
|
|
|
125
125
|
export const primaryBtnSpecs = [
|
|
126
126
|
...baseSpecs,
|
|
127
127
|
...baseSpecs.map((s) => ({ ...s, size: undefined })),
|
|
128
|
-
...baseSpecs.map((s) => ({ ...s, size: 'medium' as
|
|
129
|
-
...baseSpecs.map((s) => ({ ...s, size: 'large' as
|
|
128
|
+
...baseSpecs.map((s) => ({ ...s, size: 'medium' as ButtonProps['size'] })),
|
|
129
|
+
...baseSpecs.map((s) => ({ ...s, size: 'large' as ButtonProps['size'] })),
|
|
130
130
|
...baseSpecs.map((s) => ({
|
|
131
131
|
...s,
|
|
132
|
-
size: 'small' as
|
|
133
|
-
type: 'submit' as
|
|
132
|
+
size: 'small' as ButtonProps['size'],
|
|
133
|
+
type: 'submit' as ButtonProps['type'],
|
|
134
134
|
})),
|
|
135
135
|
...baseSpecs.map((s) => ({
|
|
136
136
|
...s,
|
|
137
|
-
size: 'medium' as
|
|
138
|
-
type: 'submit' as
|
|
137
|
+
size: 'medium' as ButtonProps['size'],
|
|
138
|
+
type: 'submit' as ButtonProps['type'],
|
|
139
139
|
})),
|
|
140
140
|
...baseSpecs.map((s) => ({
|
|
141
141
|
...s,
|
|
142
|
-
size: 'large' as
|
|
143
|
-
type: 'submit' as
|
|
142
|
+
size: 'large' as ButtonProps['size'],
|
|
143
|
+
type: 'submit' as ButtonProps['type'],
|
|
144
144
|
})),
|
|
145
145
|
];
|
|
146
146
|
|
|
147
147
|
export const secondaryBtnSpecs = primaryBtnSpecs.map((s) => ({
|
|
148
148
|
...s,
|
|
149
|
-
variant: 'secondary' as
|
|
149
|
+
variant: 'secondary' as ButtonProps['variant'],
|
|
150
150
|
}));
|
|
151
151
|
|
|
152
152
|
export const tertiaryBtnSpecs = primaryBtnSpecs.map((s) => ({
|
|
153
153
|
...s,
|
|
154
|
-
variant: 'tertiary' as
|
|
154
|
+
variant: 'tertiary' as ButtonProps['variant'],
|
|
155
155
|
}));
|
|
156
156
|
|
|
157
157
|
export const infoBtnSpecs = primaryBtnSpecs.map((s) => ({
|
|
158
158
|
...s,
|
|
159
|
-
variant: 'info' as
|
|
159
|
+
variant: 'info' as ButtonProps['variant'],
|
|
160
160
|
}));
|
|
161
161
|
|
|
162
162
|
export const attentionBtnSpecs = primaryBtnSpecs.map((s) => ({
|
|
163
163
|
...s,
|
|
164
|
-
variant: 'attention' as
|
|
164
|
+
variant: 'attention' as ButtonProps['variant'],
|
|
165
165
|
}));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
-
import {
|
|
2
|
+
import { ButtonVariants } from './types';
|
|
3
3
|
|
|
4
4
|
export const sizes: Array<keyof MainSizes> = ['small', 'medium', 'large'];
|
|
5
|
-
export const variants: Array<keyof
|
|
5
|
+
export const variants: Array<keyof ButtonVariants> = [
|
|
6
6
|
'primary',
|
|
7
7
|
'info',
|
|
8
8
|
'secondary',
|
|
@@ -15,13 +15,13 @@ type ButtonAriaProps = Pick<
|
|
|
15
15
|
| 'aria-current'
|
|
16
16
|
>;
|
|
17
17
|
|
|
18
|
-
export interface
|
|
18
|
+
export interface ButtonProps extends ButtonAriaProps {
|
|
19
19
|
block?: boolean;
|
|
20
20
|
size?: keyof MainSizes;
|
|
21
21
|
text?: string;
|
|
22
22
|
startIcon?: React.ReactNode;
|
|
23
23
|
endIcon?: React.ReactNode;
|
|
24
|
-
variant?: keyof
|
|
24
|
+
variant?: keyof ButtonVariants | 'custom';
|
|
25
25
|
type?: 'button' | 'reset' | 'submit';
|
|
26
26
|
isDisabled?: boolean;
|
|
27
27
|
className?: string;
|
|
@@ -29,7 +29,7 @@ export interface IButtonProps extends ButtonAriaProps {
|
|
|
29
29
|
children?: React.ReactNode;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export interface
|
|
32
|
+
export interface ButtonVariants {
|
|
33
33
|
primary: (theme: Theme) => SerializedStyles;
|
|
34
34
|
info: (theme: Theme) => SerializedStyles;
|
|
35
35
|
secondary: (theme: Theme) => SerializedStyles;
|
|
@@ -37,12 +37,12 @@ export interface IButtonVariants {
|
|
|
37
37
|
attention: (theme: Theme) => SerializedStyles;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export type
|
|
40
|
+
export type ButtonTextProps = {
|
|
41
41
|
text: string;
|
|
42
42
|
className?: string;
|
|
43
43
|
testId?: string;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
export type
|
|
46
|
+
export type ColoredButtonTextProps = Required<Pick<ButtonProps, 'size'>> & {
|
|
47
47
|
text: string;
|
|
48
48
|
};
|
|
@@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form';
|
|
|
6
6
|
import Checkbox from '@components/Checkbox';
|
|
7
7
|
import FormCheckbox from '@components/FormCheckbox';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { CheckboxProps } from './types';
|
|
10
10
|
import { getByRole } from '@testing-library/dom';
|
|
11
11
|
|
|
12
12
|
const checkLabel = () => {
|
|
@@ -50,7 +50,7 @@ const checkToggle = async (
|
|
|
50
50
|
checkIcon(labelEl, newIsChecked);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
function setup(props: Omit<
|
|
53
|
+
function setup(props: Omit<CheckboxProps, 'onChange'> = {}) {
|
|
54
54
|
const mockOnChange = jest.fn();
|
|
55
55
|
return {
|
|
56
56
|
user: userEvent.setup(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment } from 'react';
|
|
2
2
|
import type { Meta } from '@storybook/react';
|
|
3
3
|
import Typography from '@components/Typography';
|
|
4
|
-
import Checkbox, {
|
|
4
|
+
import Checkbox, { CheckboxProps } from './index';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'Components/Checkbox',
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
|
|
28
28
|
export const Default = {};
|
|
29
29
|
|
|
30
|
-
const checkboxPropsVariants: Array<
|
|
30
|
+
const checkboxPropsVariants: Array<CheckboxProps & { caption?: string }> = [
|
|
31
31
|
{
|
|
32
32
|
id: 'checked',
|
|
33
33
|
caption: 'Checked by default',
|
|
@@ -3,7 +3,7 @@ import { useTheme } from '@emotion/react';
|
|
|
3
3
|
import { CheckboxBase } from './CheckboxBase';
|
|
4
4
|
import Icon from '@components/Icon';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { CheckboxProps } from './types';
|
|
7
7
|
|
|
8
8
|
const Checkbox = ({
|
|
9
9
|
text,
|
|
@@ -18,7 +18,7 @@ const Checkbox = ({
|
|
|
18
18
|
ref,
|
|
19
19
|
register,
|
|
20
20
|
...rest
|
|
21
|
-
}:
|
|
21
|
+
}: CheckboxProps) => {
|
|
22
22
|
const [isChecked, setIsChecked] = useState(Boolean(initialState));
|
|
23
23
|
const autoGenId = useId();
|
|
24
24
|
const theme = useTheme();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import Label from '@components/Label';
|
|
3
3
|
import { checkboxStyles } from './styles';
|
|
4
|
-
import {
|
|
4
|
+
import { CheckboxProps } from './types';
|
|
5
5
|
|
|
6
|
-
export const CheckboxBase = styled(Label)<Pick<
|
|
6
|
+
export const CheckboxBase = styled(Label)<Pick<CheckboxProps, 'color'>>`
|
|
7
7
|
position: relative;
|
|
8
8
|
display: inline-flex;
|
|
9
9
|
flex-grow: 0;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from 'react-hook-form';
|
|
7
7
|
import { MutableRefObject } from 'react';
|
|
8
8
|
|
|
9
|
-
export interface
|
|
9
|
+
export interface CheckboxProps
|
|
10
10
|
extends Partial<Pick<UseFormReturn, 'register'>> {
|
|
11
11
|
text?: string;
|
|
12
12
|
id?: string;
|
|
@@ -24,7 +24,7 @@ export interface ICheckboxProps
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export type IFormCheckboxProps<T extends FieldValues> = Omit<
|
|
27
|
-
|
|
27
|
+
CheckboxProps,
|
|
28
28
|
'onChange' | 'name'
|
|
29
29
|
> & {
|
|
30
30
|
name: FieldPath<T>;
|
|
@@ -5,10 +5,10 @@ import { css } from '@emotion/react';
|
|
|
5
5
|
import DropdownOption from '@components/DropdownOption';
|
|
6
6
|
|
|
7
7
|
import Dropdown from './Dropdown';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { DropdownProps } from './types';
|
|
9
|
+
import { DropdownOptionProps } from '../..';
|
|
10
10
|
|
|
11
|
-
type Args =
|
|
11
|
+
type Args = DropdownProps<DropdownOptionProps>;
|
|
12
12
|
|
|
13
13
|
const items = [
|
|
14
14
|
{ id: 1, value: 'One lorem ipsum', subText: 'subtext' },
|
|
@@ -7,9 +7,9 @@ import DropdownToggle from '@components/DropdownToggle';
|
|
|
7
7
|
import DropdownArrow from '@components/DropdownArrow';
|
|
8
8
|
import DropdownOptions from '@components/DropdownOptions';
|
|
9
9
|
import DropdownContext from '@components/Dropdown/Dropdown.context';
|
|
10
|
-
import {
|
|
10
|
+
import { DropdownOptionProps } from '@components/DropdownOptions/types';
|
|
11
11
|
|
|
12
|
-
import { DropdownContextType,
|
|
12
|
+
import { DropdownContextType, DropdownProps } from './types';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The structure of the component:
|
|
@@ -28,14 +28,14 @@ const DropdownBase = styled.div`
|
|
|
28
28
|
position: relative;
|
|
29
29
|
`;
|
|
30
30
|
|
|
31
|
-
const Dropdown = <T extends
|
|
31
|
+
const Dropdown = <T extends DropdownOptionProps>({
|
|
32
32
|
selectedItem,
|
|
33
33
|
isDisabled,
|
|
34
34
|
isOpen: isInitOpen,
|
|
35
35
|
children,
|
|
36
36
|
onChange: handleChange,
|
|
37
37
|
className,
|
|
38
|
-
}:
|
|
38
|
+
}: DropdownProps<T>) => {
|
|
39
39
|
const theme = useTheme();
|
|
40
40
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
41
41
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DropdownOptionProps } from '@components/DropdownOptions';
|
|
2
2
|
import { CommonProps } from '@global-types/emotion';
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface DropdownProps<P extends DropdownOptionProps>
|
|
5
|
+
extends CommonProps {
|
|
5
6
|
selectedItem?: P;
|
|
6
7
|
onChange?: (item: P) => void;
|
|
7
8
|
isDisabled?: boolean;
|
|
@@ -13,5 +14,5 @@ export interface IDropdownProps<P extends IDropdownOption> extends CommonProps {
|
|
|
13
14
|
|
|
14
15
|
export interface DropdownContextType {
|
|
15
16
|
onChange: (item?: string) => void;
|
|
16
|
-
activeItem?:
|
|
17
|
+
activeItem?: DropdownOptionProps | null;
|
|
17
18
|
}
|
|
@@ -3,7 +3,7 @@ import { Theme, css } from '@emotion/react';
|
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
4
|
import { CommonProps } from '@global-types/emotion';
|
|
5
5
|
|
|
6
|
-
interface
|
|
6
|
+
interface DropdownItemProps extends CommonProps {
|
|
7
7
|
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
8
8
|
isActive?: boolean;
|
|
9
9
|
isMultiple?: boolean;
|
|
@@ -31,7 +31,7 @@ const multipleStyles = ({ theme, isDisabled }: MultipleStylesProps) => {
|
|
|
31
31
|
`;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const DropdownOption = styled.li<
|
|
34
|
+
const DropdownOption = styled.li<DropdownItemProps>`
|
|
35
35
|
overflow: hidden;
|
|
36
36
|
|
|
37
37
|
height: 34px;
|
|
@@ -5,7 +5,7 @@ import { css } from '@emotion/react';
|
|
|
5
5
|
import { useDropdownContext } from '@components/Dropdown/Dropdown.context';
|
|
6
6
|
import DropdownOption from '@components/DropdownOption';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { DropdownItemsListProps } from './types';
|
|
9
9
|
|
|
10
10
|
const DropdownOptionsBase = styled.ul<{ tabindex?: string }>`
|
|
11
11
|
position: absolute;
|
|
@@ -54,7 +54,7 @@ const DropdownOptions = ({
|
|
|
54
54
|
ariaLabelledby,
|
|
55
55
|
id,
|
|
56
56
|
children,
|
|
57
|
-
}:
|
|
57
|
+
}: DropdownItemsListProps) => {
|
|
58
58
|
const { onChange, activeItem } = useDropdownContext();
|
|
59
59
|
|
|
60
60
|
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './DropdownOptions';
|
|
2
|
-
export type {
|
|
2
|
+
export type { DropdownOptionProps } from './types';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CommonProps } from '@global-types/emotion';
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type DropdownOptionProps = Record<string, string | number>;
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface DropdownItemsListProps extends CommonProps {
|
|
6
6
|
ariaLabelledby?: string;
|
|
7
7
|
id?: string;
|
|
8
8
|
children?: React.ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
3
|
import { focusOutline } from '@styles/safari-focus-outline';
|
|
4
|
-
import {
|
|
4
|
+
import { DropdownToggleProps, MultipleStylesProps } from './types';
|
|
5
5
|
|
|
6
6
|
const multipleStyles = ({ theme, selectedCount = 0 }: MultipleStylesProps) => {
|
|
7
7
|
let borderColor = theme.colors.greyDropdownMain;
|
|
@@ -43,7 +43,7 @@ const multipleStyles = ({ theme, selectedCount = 0 }: MultipleStylesProps) => {
|
|
|
43
43
|
|
|
44
44
|
export const DropdownToggleBase = styled.button<
|
|
45
45
|
Pick<
|
|
46
|
-
|
|
46
|
+
DropdownToggleProps,
|
|
47
47
|
'colors' | 'isOpen' | 'disabled' | 'isMultiple' | 'selectedCount'
|
|
48
48
|
>
|
|
49
49
|
>`
|
|
@@ -121,7 +121,7 @@ const DropdownToggle = ({
|
|
|
121
121
|
ariaControls,
|
|
122
122
|
colors,
|
|
123
123
|
className,
|
|
124
|
-
}:
|
|
124
|
+
}: DropdownToggleProps) => (
|
|
125
125
|
<DropdownToggleBase
|
|
126
126
|
className={className}
|
|
127
127
|
colors={colors}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Theme } from '@emotion/react';
|
|
3
3
|
import { CommonProps } from '@global-types/emotion';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface DropdownToggleProps extends CommonProps {
|
|
6
6
|
onClick: (e: React.MouseEvent<HTMLElement>) => void;
|
|
7
7
|
onFocus: (e: React.FocusEvent<HTMLButtonElement, Element>) => void;
|
|
8
8
|
isOpen: boolean;
|
|
@@ -3,7 +3,7 @@ import type { FieldValues } from 'react-hook-form';
|
|
|
3
3
|
|
|
4
4
|
import Checkbox from '@components/Checkbox';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { FormCheckboxProps } from './types';
|
|
7
7
|
import { ChangeEvent } from 'react';
|
|
8
8
|
|
|
9
9
|
const FormCheckbox = <T extends FieldValues>({
|
|
@@ -11,7 +11,7 @@ const FormCheckbox = <T extends FieldValues>({
|
|
|
11
11
|
name,
|
|
12
12
|
isRequired = false,
|
|
13
13
|
...props
|
|
14
|
-
}:
|
|
14
|
+
}: FormCheckboxProps<T>) => {
|
|
15
15
|
const { field } = useController({
|
|
16
16
|
control,
|
|
17
17
|
name,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Control, FieldPath, FieldValues } from 'react-hook-form';
|
|
2
|
-
import {
|
|
2
|
+
import { CheckboxProps } from '../..';
|
|
3
3
|
|
|
4
|
-
export type
|
|
5
|
-
|
|
4
|
+
export type FormCheckboxProps<T extends FieldValues> = Omit<
|
|
5
|
+
CheckboxProps,
|
|
6
6
|
'onChange' | 'name'
|
|
7
7
|
> & {
|
|
8
8
|
name: FieldPath<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FormHelperTextProps } from './types';
|
|
2
2
|
import { FormHelperTextBase } from './FormHelperTextBase';
|
|
3
3
|
|
|
4
4
|
const FormHelperText = ({
|
|
@@ -6,7 +6,7 @@ const FormHelperText = ({
|
|
|
6
6
|
status,
|
|
7
7
|
disabled,
|
|
8
8
|
children,
|
|
9
|
-
}:
|
|
9
|
+
}: FormHelperTextProps) => {
|
|
10
10
|
status = disabled ? 'basic' : status;
|
|
11
11
|
return (
|
|
12
12
|
<FormHelperTextBase role={role} status={status}>
|