@ssa-ui-kit/core 0.0.25-alpha → 0.0.27-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 +11 -11
- package/dist/components/Tooltip/utils.d.ts +2 -2
- package/dist/components/TooltipContent/TooltipContent.d.ts +2 -2
- package/dist/components/TooltipTrigger/TooltipTrigger.d.ts +2 -2
- package/dist/components/WithVisibleLG/WithVisibleLG.d.ts +10 -0
- package/dist/components/WithVisibleLG/index.d.ts +1 -0
- package/dist/components/WithVisibleMD/WithVisibleMD.d.ts +6 -0
- package/dist/components/WithVisibleMD/index.d.ts +1 -0
- package/dist/components/WithVisibleSM/WithVisibleSM.d.ts +6 -0
- package/dist/components/WithVisibleSM/index.d.ts +1 -0
- package/dist/components/WithVisibleUpToLG/WithVisibleUpToLG.d.ts +6 -0
- package/dist/components/WithVisibleUpToLG/index.d.ts +1 -0
- package/dist/components/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- 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.tsx +2 -2
- package/src/components/Tooltip/types.ts +11 -11
- package/src/components/Tooltip/utils.tsx +2 -2
- package/src/components/TooltipContent/TooltipContent.tsx +2 -2
- package/src/components/TooltipTrigger/TooltipTrigger.tsx +2 -2
- package/src/components/WithVisibleLG/WithVisibleLG.spec.tsx +27 -0
- package/src/components/WithVisibleLG/WithVisibleLG.tsx +22 -0
- package/src/components/WithVisibleLG/index.ts +1 -0
- package/src/components/WithVisibleMD/WithVisibleMD.spec.tsx +27 -0
- package/src/components/WithVisibleMD/WithVisibleMD.tsx +23 -0
- package/src/components/WithVisibleMD/index.ts +1 -0
- package/src/components/WithVisibleSM/WithVisibleSM.spec.tsx +27 -0
- package/src/components/WithVisibleSM/WithVisibleSM.tsx +22 -0
- package/src/components/WithVisibleSM/index.ts +1 -0
- package/src/components/WithVisibleUpToLG/WithVisibleUpToLG.spec.tsx +27 -0
- package/src/components/WithVisibleUpToLG/WithVisibleUpToLG.tsx +24 -0
- package/src/components/WithVisibleUpToLG/index.ts +1 -0
- package/src/components/index.ts +5 -1
- package/tsbuildcache +1 -1
|
@@ -3,7 +3,7 @@ import type { FieldValues } from 'react-hook-form';
|
|
|
3
3
|
|
|
4
4
|
import RadioGroup from '@components/RadioGroup';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { FormRadioGroupProps } from './types';
|
|
7
7
|
import { ChangeEvent } from 'react';
|
|
8
8
|
|
|
9
9
|
const FormRadioGroup = <T extends FieldValues>({
|
|
@@ -12,7 +12,7 @@ const FormRadioGroup = <T extends FieldValues>({
|
|
|
12
12
|
control,
|
|
13
13
|
children,
|
|
14
14
|
...props
|
|
15
|
-
}:
|
|
15
|
+
}: FormRadioGroupProps<T>) => {
|
|
16
16
|
const { field } = useController<T>({
|
|
17
17
|
control,
|
|
18
18
|
name,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FieldPath, Control, FieldValues } from 'react-hook-form';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { RadioGroupProps } from '@components/RadioGroup/types';
|
|
4
4
|
import { CommonProps } from '@global-types/emotion';
|
|
5
5
|
|
|
6
|
-
export type
|
|
7
|
-
|
|
6
|
+
export type FormRadioGroupProps<T extends FieldValues> = Omit<
|
|
7
|
+
RadioGroupProps,
|
|
8
8
|
'name' | 'onChange'
|
|
9
9
|
> & {
|
|
10
10
|
name: FieldPath<T>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { css, SerializedStyles } from '@emotion/react';
|
|
2
2
|
import Icon from '@components/Icon';
|
|
3
3
|
import { iconsList } from '@components/Icon';
|
|
4
|
+
import { MapIconsType } from './types';
|
|
4
5
|
import { screen } from '../../../customTest';
|
|
5
|
-
import { IMapIcons } from './types';
|
|
6
6
|
|
|
7
7
|
const renderIcon = async (
|
|
8
|
-
icon: keyof
|
|
8
|
+
icon: keyof MapIconsType,
|
|
9
9
|
size?: number,
|
|
10
10
|
css?: SerializedStyles,
|
|
11
11
|
) => {
|
|
@@ -42,14 +42,14 @@ const checkFillOrStrokeAttrs = (
|
|
|
42
42
|
describe('Icons', () => {
|
|
43
43
|
iconsList.forEach((iconName) => {
|
|
44
44
|
it(`Renders "${iconName}" icon with attributes`, async () => {
|
|
45
|
-
const [, path] = await renderIcon(iconName as keyof
|
|
45
|
+
const [, path] = await renderIcon(iconName as keyof MapIconsType);
|
|
46
46
|
|
|
47
47
|
checkFillOrStrokeAttrs(path, iconName);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
it(`Renders "${iconName}" icon with custom styles`, async () => {
|
|
51
51
|
const [icon] = await renderIcon(
|
|
52
|
-
iconName as keyof
|
|
52
|
+
iconName as keyof MapIconsType,
|
|
53
53
|
undefined,
|
|
54
54
|
css`
|
|
55
55
|
background-color: magenta;
|
|
@@ -62,7 +62,7 @@ describe('Icons', () => {
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
it(`Renders "${iconName}" icon with the default size`, async () => {
|
|
65
|
-
const [icon] = await renderIcon(iconName as keyof
|
|
65
|
+
const [icon] = await renderIcon(iconName as keyof MapIconsType);
|
|
66
66
|
|
|
67
67
|
expect(icon).toBeInTheDocument();
|
|
68
68
|
const width = (icon as unknown as SVGElement).getAttribute('width');
|
|
@@ -74,7 +74,7 @@ describe('Icons', () => {
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
it(`Renders "${iconName}" icon with a custom size`, async () => {
|
|
77
|
-
const [icon] = await renderIcon(iconName as keyof
|
|
77
|
+
const [icon] = await renderIcon(iconName as keyof MapIconsType, 12);
|
|
78
78
|
|
|
79
79
|
expect(icon).toBeInTheDocument();
|
|
80
80
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IconProps,
|
|
1
|
+
import { IconProps, MapIconsType } from '../types';
|
|
2
2
|
|
|
3
3
|
import { Calendar } from './Calendar';
|
|
4
4
|
import { Diet } from './Diet';
|
|
@@ -110,10 +110,10 @@ const componentsList = [
|
|
|
110
110
|
Unlock,
|
|
111
111
|
];
|
|
112
112
|
|
|
113
|
-
const iconsMap:
|
|
113
|
+
const iconsMap: MapIconsType = iconsList.reduce((res, name, index) => {
|
|
114
114
|
res[name] = componentsList[index];
|
|
115
115
|
return res;
|
|
116
|
-
}, {} as
|
|
116
|
+
}, {} as MapIconsType);
|
|
117
117
|
|
|
118
118
|
const IconMapComponent = ({ name, color, ...props }: IconProps) => {
|
|
119
119
|
const Component = iconsMap[name];
|
|
@@ -6,9 +6,9 @@ export interface SVGProps extends React.SVGProps<SVGSVGElement> {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface IconProps extends Omit<SVGProps, 'fill'> {
|
|
9
|
-
name: keyof
|
|
9
|
+
name: keyof MapIconsType;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type MapIconsType = {
|
|
13
13
|
[key in (typeof iconsList)[number]]: React.ElementType;
|
|
14
14
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTheme } from '@emotion/react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { LargeTabProps } from '@components/TabBar/types';
|
|
4
4
|
|
|
5
5
|
import { LargeTabBase } from './LargeTabBase';
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ const LargeTab = ({
|
|
|
13
13
|
onClick,
|
|
14
14
|
ariaControls,
|
|
15
15
|
tabId,
|
|
16
|
-
}:
|
|
16
|
+
}: LargeTabProps) => {
|
|
17
17
|
const theme = useTheme();
|
|
18
18
|
return (
|
|
19
19
|
<LargeTabBase
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
-
import {
|
|
2
|
+
import { LargeTabProps } from '@components/TabBar/types';
|
|
3
3
|
|
|
4
|
-
export const LargeTabBase = styled.button<Pick<
|
|
4
|
+
export const LargeTabBase = styled.button<Pick<LargeTabProps, 'isActive'>>`
|
|
5
5
|
width: 100px;
|
|
6
6
|
max-width: 100px;
|
|
7
7
|
height: 60px;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
import { DropdownContextType } from './types';
|
|
4
|
-
import {
|
|
4
|
+
import { DropdownOptionType } from '@components/MultipleDropdownOptions';
|
|
5
5
|
|
|
6
6
|
const MultipleDropdownContext = React.createContext<
|
|
7
|
-
DropdownContextType<
|
|
7
|
+
DropdownContextType<DropdownOptionType>
|
|
8
8
|
>({
|
|
9
9
|
allItems: {},
|
|
10
10
|
isMultiple: false,
|
|
@@ -13,7 +13,7 @@ const MultipleDropdownContext = React.createContext<
|
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
export function useMultipleDropdownContext(): DropdownContextType<
|
|
16
|
+
export function useMultipleDropdownContext(): DropdownContextType<DropdownOptionType> {
|
|
17
17
|
return React.useContext(MultipleDropdownContext);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -10,9 +10,9 @@ import DropdownToggle from '@components/DropdownToggle';
|
|
|
10
10
|
import DropdownArrow from '@components/DropdownArrow';
|
|
11
11
|
import MultipleDropdownOptions from '@components/MultipleDropdownOptions';
|
|
12
12
|
import MultipleDropdownContext from '@components/MultipleDropdown/MultipleDropdown.context';
|
|
13
|
-
import {
|
|
13
|
+
import { DropdownOptionProps } from '@components/DropdownOptions/types';
|
|
14
14
|
|
|
15
|
-
import { DropdownContextType,
|
|
15
|
+
import { DropdownContextType, DropdownProps } from './types';
|
|
16
16
|
import { getActiveItems } from '@components/MultipleDropdown/utils';
|
|
17
17
|
import MultipleDropdownNotification from '@components/MultipleDropdownNotification';
|
|
18
18
|
|
|
@@ -33,7 +33,7 @@ const DropdownPlaceholderLabel = styled.div`
|
|
|
33
33
|
* Aria attributes are set according to
|
|
34
34
|
* https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-select-only.html
|
|
35
35
|
**/
|
|
36
|
-
function MultipleDropdownInner<T extends
|
|
36
|
+
function MultipleDropdownInner<T extends DropdownOptionProps>(
|
|
37
37
|
{
|
|
38
38
|
selectedItems = [],
|
|
39
39
|
isDisabled,
|
|
@@ -45,7 +45,7 @@ function MultipleDropdownInner<T extends IDropdownOption>(
|
|
|
45
45
|
children,
|
|
46
46
|
onChange: handleChange,
|
|
47
47
|
className,
|
|
48
|
-
}:
|
|
48
|
+
}: DropdownProps<T>,
|
|
49
49
|
ref?: React.ForwardedRef<HTMLDivElement | null>,
|
|
50
50
|
) {
|
|
51
51
|
const theme = useTheme();
|
|
@@ -69,7 +69,7 @@ function MultipleDropdownInner<T extends IDropdownOption>(
|
|
|
69
69
|
[JSON.stringify(selectedItems)],
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
const onChange = (item:
|
|
72
|
+
const onChange = (item: DropdownOptionProps) => {
|
|
73
73
|
if (isDisabled || !item) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
@@ -148,7 +148,7 @@ function MultipleDropdownInner<T extends IDropdownOption>(
|
|
|
148
148
|
setItems(childItems);
|
|
149
149
|
}, [memoSelectedItems, children]);
|
|
150
150
|
|
|
151
|
-
const contextValue: DropdownContextType<
|
|
151
|
+
const contextValue: DropdownContextType<DropdownOptionProps> = React.useMemo(
|
|
152
152
|
() => ({ onChange, allItems: optionsWithKey, isMultiple }),
|
|
153
153
|
[onChange, optionsWithKey, isMultiple],
|
|
154
154
|
);
|
|
@@ -211,7 +211,7 @@ function MultipleDropdownInner<T extends IDropdownOption>(
|
|
|
211
211
|
|
|
212
212
|
const MultipleDropdown = React.forwardRef<
|
|
213
213
|
HTMLDivElement,
|
|
214
|
-
|
|
214
|
+
DropdownProps<DropdownOptionProps>
|
|
215
215
|
>(MultipleDropdownInner);
|
|
216
216
|
|
|
217
217
|
export default MultipleDropdown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DropdownOptionProps } from '@components/DropdownOptions/types';
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type DropdownProps<P extends DropdownOptionProps> = {
|
|
4
4
|
selectedItems?: P[];
|
|
5
5
|
isMultiple?: boolean;
|
|
6
6
|
isDisabled?: boolean;
|
|
@@ -13,7 +13,7 @@ export type IDropdownProps<P extends IDropdownOption> = {
|
|
|
13
13
|
onChange?: (selectedItem: string | number, isSelected: boolean) => void;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export interface DropdownContextType<T extends
|
|
16
|
+
export interface DropdownContextType<T extends DropdownOptionProps> {
|
|
17
17
|
onChange: (item: T) => void;
|
|
18
18
|
isMultiple?: boolean;
|
|
19
19
|
allItems: Record<string | number, T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DropdownOptionProps } from '../..';
|
|
2
2
|
|
|
3
3
|
const getActiveItem = <T>({
|
|
4
4
|
activeItem,
|
|
@@ -20,7 +20,7 @@ interface GetActiveItems<T> {
|
|
|
20
20
|
placeholder: string;
|
|
21
21
|
}
|
|
22
22
|
export const getActiveItems = <
|
|
23
|
-
T extends Record<string | number,
|
|
23
|
+
T extends Record<string | number, DropdownOptionProps>,
|
|
24
24
|
>({
|
|
25
25
|
allItems = {} as T,
|
|
26
26
|
placeholder,
|
|
@@ -5,8 +5,8 @@ import Checkbox from '@components/Checkbox';
|
|
|
5
5
|
import { useMultipleDropdownContext } from '@components/MultipleDropdown/MultipleDropdown.context';
|
|
6
6
|
import DropdownOption from '@components/DropdownOption';
|
|
7
7
|
|
|
8
|
-
import { IDropdownItemsListProps } from './types';
|
|
9
8
|
import { checkboxStyles } from '@components/Checkbox/styles';
|
|
9
|
+
import { DropdownItemsListProps } from './types';
|
|
10
10
|
|
|
11
11
|
const DropdownOptionsBase = styled.ul<{ tabindex?: string }>`
|
|
12
12
|
position: absolute;
|
|
@@ -83,7 +83,7 @@ const MultipleDropdownOptions = ({
|
|
|
83
83
|
ariaLabelledby,
|
|
84
84
|
id,
|
|
85
85
|
children,
|
|
86
|
-
}:
|
|
86
|
+
}: DropdownItemsListProps) => {
|
|
87
87
|
const { onChange, allItems, isMultiple } = useMultipleDropdownContext();
|
|
88
88
|
|
|
89
89
|
const toggleItem = (value: string | number, isDisabled: boolean) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './MultipleDropdownOptions';
|
|
2
|
-
export type {
|
|
2
|
+
export type { DropdownOptionType } from './types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type DropdownOptionType = Record<string, string | number>;
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface DropdownItemsListProps {
|
|
4
4
|
ariaLabelledby?: string;
|
|
5
5
|
id?: string;
|
|
6
6
|
children?: React.ReactNode;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useMergeRefs } from '@floating-ui/react';
|
|
3
3
|
import Button from '@components/Button';
|
|
4
|
-
import {
|
|
4
|
+
import { ButtonProps } from '@components/Button/types';
|
|
5
5
|
import { usePopoverContext } from './hooks/usePopoverContext';
|
|
6
|
-
import {
|
|
6
|
+
import { PopoverTriggerProps } from './types';
|
|
7
7
|
|
|
8
8
|
export const PopoverTrigger = React.forwardRef<
|
|
9
9
|
HTMLElement,
|
|
10
|
-
React.HTMLProps<HTMLElement> &
|
|
10
|
+
React.HTMLProps<HTMLElement> & ButtonProps & PopoverTriggerProps
|
|
11
11
|
>(function PopoverTrigger(
|
|
12
12
|
{ children, asChild = false, dataTestId = 'trigger-button', ...props },
|
|
13
13
|
propRef,
|
|
@@ -4,7 +4,7 @@ import { useTheme } from '@emotion/react';
|
|
|
4
4
|
import Icon from '@components/Icon';
|
|
5
5
|
|
|
6
6
|
import { RadioBase } from './RadioBase';
|
|
7
|
-
import {
|
|
7
|
+
import { RadioProps } from './types';
|
|
8
8
|
|
|
9
9
|
const Radio = ({
|
|
10
10
|
id,
|
|
@@ -16,7 +16,7 @@ const Radio = ({
|
|
|
16
16
|
onChange,
|
|
17
17
|
text,
|
|
18
18
|
className,
|
|
19
|
-
}:
|
|
19
|
+
}: RadioProps) => {
|
|
20
20
|
const theme = useTheme();
|
|
21
21
|
|
|
22
22
|
const autoGenId = useId();
|
|
@@ -3,7 +3,7 @@ import { Children, isValidElement, cloneElement, useState } from 'react';
|
|
|
3
3
|
import Radio from '@components/Radio';
|
|
4
4
|
|
|
5
5
|
import { RadioGroupBase } from './RadioGroupBase';
|
|
6
|
-
import {
|
|
6
|
+
import { RadioGroupProps } from './types';
|
|
7
7
|
|
|
8
8
|
const RadioGroup = ({
|
|
9
9
|
name,
|
|
@@ -12,7 +12,7 @@ const RadioGroup = ({
|
|
|
12
12
|
onChange,
|
|
13
13
|
children,
|
|
14
14
|
className,
|
|
15
|
-
}:
|
|
15
|
+
}: RadioGroupProps) => {
|
|
16
16
|
const [activeValue, setActiveValue] = useState(initialState);
|
|
17
17
|
|
|
18
18
|
const onRadioValueChange = (value: string) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RadioProps } from '@components/Radio/types';
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface RadioGroupProps {
|
|
4
4
|
name: string;
|
|
5
5
|
isRequired?: boolean;
|
|
6
6
|
initialState?: string;
|
|
7
7
|
className?: string;
|
|
8
8
|
onChange: (value: string) => void;
|
|
9
|
-
children: React.ReactElement<
|
|
9
|
+
children: React.ReactElement<RadioProps>[];
|
|
10
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResponsiveImageProps } from './types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A simple wrapper over the `<img />` tag.
|
|
@@ -7,7 +7,7 @@ import { IResponsiveImageProps } from './types';
|
|
|
7
7
|
* when testing srcSet, and use Hard Reload to force the
|
|
8
8
|
* browser to load an image of another resolution.
|
|
9
9
|
* */
|
|
10
|
-
const ResponsiveImage = ({ src, alt, ...props }:
|
|
10
|
+
const ResponsiveImage = ({ src, alt, ...props }: ResponsiveImageProps) => {
|
|
11
11
|
return <img src={src} alt={alt} {...props} />;
|
|
12
12
|
};
|
|
13
13
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import SwitchBase from './SwitchBase';
|
|
2
2
|
import { useSwitchContext } from './SwitchContext';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { SwitchProps } from './types';
|
|
5
5
|
|
|
6
|
-
const Switch = ({ label, isDisabled = false }:
|
|
6
|
+
const Switch = ({ label, isDisabled = false }: SwitchProps) => {
|
|
7
7
|
const { isOn, toggle } = useSwitchContext();
|
|
8
8
|
|
|
9
9
|
return (
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createContext, useState, useCallback, useContext } from 'react';
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface SwitchContext {
|
|
4
4
|
isOn: boolean;
|
|
5
5
|
toggle: () => void;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export const SwitchContext = createContext<
|
|
8
|
+
export const SwitchContext = createContext<SwitchContext>({
|
|
9
9
|
isOn: true,
|
|
10
10
|
toggle: () => {
|
|
11
11
|
/* default no-op */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SmallTabProps } from '@components/TabBar/types';
|
|
2
2
|
|
|
3
3
|
import { TabBase } from './TabBase';
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ const Tab = ({
|
|
|
8
8
|
text,
|
|
9
9
|
ariaControls,
|
|
10
10
|
tabId,
|
|
11
|
-
}:
|
|
11
|
+
}: SmallTabProps) => {
|
|
12
12
|
return (
|
|
13
13
|
<TabBase
|
|
14
14
|
role="tab"
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
+
import { SmallTabProps } from '@components/TabBar/types';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const TabBase = styled.button<Pick<ISmallTabProps, 'isActive'>>`
|
|
4
|
+
export const TabBase = styled.button<Pick<SmallTabProps, 'isActive'>>`
|
|
6
5
|
height: 34px;
|
|
7
6
|
border: 0;
|
|
8
7
|
outline: 0;
|
|
@@ -7,10 +7,10 @@ import LargeTab from '@components/LargeTab';
|
|
|
7
7
|
|
|
8
8
|
import { TabBarWrapper, TabContents } from './stories/helpers';
|
|
9
9
|
import TabBar, { TabBarContextProvider } from './index';
|
|
10
|
-
import {
|
|
10
|
+
import { SmallTabProps, TabProps } from './types';
|
|
11
11
|
import { ReactNode } from 'react';
|
|
12
12
|
|
|
13
|
-
interface TabTest extends Pick<
|
|
13
|
+
interface TabTest extends Pick<SmallTabProps, 'tabId'> {
|
|
14
14
|
controls: string;
|
|
15
15
|
topText?: string;
|
|
16
16
|
bottomText?: string;
|
|
@@ -187,7 +187,7 @@ const componentTabBarTests: ComponentTabBarTests = (
|
|
|
187
187
|
};
|
|
188
188
|
|
|
189
189
|
describe('TabBar', () => {
|
|
190
|
-
const renderContent = (tab?:
|
|
190
|
+
const renderContent = (tab?: SmallTabProps): React.ReactNode => {
|
|
191
191
|
return (
|
|
192
192
|
<TabContents
|
|
193
193
|
id={tab?.ariaControls}
|
|
@@ -216,7 +216,7 @@ describe('TabBar', () => {
|
|
|
216
216
|
tabId={tab.tabId}
|
|
217
217
|
text={tab.text || ''}
|
|
218
218
|
ariaControls={tab.controls}
|
|
219
|
-
renderContent={tab.renderContent as
|
|
219
|
+
renderContent={tab.renderContent as TabProps['renderContent']}
|
|
220
220
|
/>
|
|
221
221
|
),
|
|
222
222
|
(tab) => [tab.text || ''],
|
|
@@ -282,7 +282,7 @@ describe('TabBar', () => {
|
|
|
282
282
|
topText={tab.topText || ''}
|
|
283
283
|
bottomText={tab.bottomText || ''}
|
|
284
284
|
ariaControls={tab.controls}
|
|
285
|
-
renderContent={tab.renderContent as
|
|
285
|
+
renderContent={tab.renderContent as TabProps['renderContent']}
|
|
286
286
|
/>
|
|
287
287
|
),
|
|
288
288
|
(tab) => [tab.topText || '', tab.bottomText || ''],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import { Children, cloneElement, isValidElement } from 'react';
|
|
3
3
|
import { useTabBarContext } from './TabBarContext';
|
|
4
|
-
import {
|
|
4
|
+
import { TabBarProps } from './types';
|
|
5
5
|
|
|
6
6
|
const TabBarBase = styled.div``;
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ const TabBarBase = styled.div``;
|
|
|
12
12
|
* component to decide where to render the contents of the
|
|
13
13
|
* selected tab.
|
|
14
14
|
* */
|
|
15
|
-
const TabBar = ({ children }:
|
|
15
|
+
const TabBar = ({ children }: TabBarProps) => {
|
|
16
16
|
const { activeTab, setActiveTab } = useTabBarContext();
|
|
17
17
|
const activeTabId = activeTab?.tabId;
|
|
18
18
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createContext, useState, useContext } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TabProps, TabBarContextProps } from './types';
|
|
3
3
|
|
|
4
|
-
const defaultTab:
|
|
4
|
+
const defaultTab: TabProps = {
|
|
5
5
|
tabId: Number.NaN,
|
|
6
6
|
renderContent() {
|
|
7
7
|
return null;
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export const TabBarContext = createContext<
|
|
11
|
+
export const TabBarContext = createContext<TabBarContextProps>({
|
|
12
12
|
activeTab: defaultTab,
|
|
13
13
|
setActiveTab() {
|
|
14
14
|
/* default no-op */
|
|
@@ -17,8 +17,8 @@ export const TabBarContext = createContext<ITabBarContext>({
|
|
|
17
17
|
|
|
18
18
|
export const useTabBarContext = () => useContext(TabBarContext);
|
|
19
19
|
|
|
20
|
-
const useTabBar = (initialTab?:
|
|
21
|
-
const [tab, setTab] = useState<
|
|
20
|
+
const useTabBar = (initialTab?: TabProps): TabBarContextProps => {
|
|
21
|
+
const [tab, setTab] = useState<TabProps | undefined>(initialTab);
|
|
22
22
|
|
|
23
23
|
return {
|
|
24
24
|
activeTab: tab,
|
|
@@ -30,7 +30,7 @@ export const TabBarContextProvider = ({
|
|
|
30
30
|
initialTab = defaultTab,
|
|
31
31
|
children,
|
|
32
32
|
}: {
|
|
33
|
-
initialTab?:
|
|
33
|
+
initialTab?: TabProps;
|
|
34
34
|
children: React.ReactNode;
|
|
35
35
|
}) => {
|
|
36
36
|
const { activeTab, setActiveTab } = useTabBar(initialTab);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Fragment, useLayoutEffect } from 'react';
|
|
3
|
+
import { DecoratorFunction } from '@storybook/types';
|
|
3
4
|
import { useTabBarContext, TabBarContextProvider } from '@components/TabBar';
|
|
4
|
-
import { ITab } from '../types';
|
|
5
5
|
import TabBar from '../TabBar';
|
|
6
|
-
import {
|
|
6
|
+
import { TabProps } from '../types';
|
|
7
7
|
|
|
8
8
|
type Args = Parameters<typeof TabBar>[0];
|
|
9
9
|
|
|
@@ -13,8 +13,8 @@ export const TabBarWrapper = ({
|
|
|
13
13
|
renderContent,
|
|
14
14
|
}: {
|
|
15
15
|
children: React.ReactNode;
|
|
16
|
-
selectedTabId?:
|
|
17
|
-
renderContent?:
|
|
16
|
+
selectedTabId?: TabProps['tabId'];
|
|
17
|
+
renderContent?: TabProps['renderContent'];
|
|
18
18
|
}) => {
|
|
19
19
|
const { activeTab, setActiveTab } = useTabBarContext();
|
|
20
20
|
useLayoutEffect(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonProps } from '@global-types/emotion';
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface TabProps extends CommonProps {
|
|
4
4
|
tabId: number | string;
|
|
5
5
|
renderContent: (
|
|
6
6
|
tab?: {
|
|
@@ -11,29 +11,26 @@ export interface ITab extends CommonProps {
|
|
|
11
11
|
},
|
|
12
12
|
arg?: unknown,
|
|
13
13
|
) => React.ReactNode;
|
|
14
|
-
[prop: string | number | symbol]: unknown;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ITabProps extends ITab {
|
|
18
14
|
isActive?: boolean;
|
|
19
15
|
onClick?: () => void;
|
|
20
16
|
ariaControls?: string;
|
|
17
|
+
[prop: string | number | symbol]: unknown;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export interface
|
|
20
|
+
export interface SmallTabProps extends TabProps {
|
|
24
21
|
text: string;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
|
-
export interface
|
|
24
|
+
export interface LargeTabProps extends TabProps {
|
|
28
25
|
topText: string;
|
|
29
26
|
bottomText: string;
|
|
30
27
|
}
|
|
31
28
|
|
|
32
|
-
export interface
|
|
33
|
-
children: React.ReactElement<React.PropsWithChildren<
|
|
29
|
+
export interface TabBarProps {
|
|
30
|
+
children: React.ReactElement<React.PropsWithChildren<TabProps>>[];
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
export interface
|
|
37
|
-
activeTab?:
|
|
38
|
-
setActiveTab: (tab?:
|
|
33
|
+
export interface TabBarContextProps {
|
|
34
|
+
activeTab?: TabProps;
|
|
35
|
+
setActiveTab: (tab?: TabProps) => void;
|
|
39
36
|
}
|
|
@@ -3,7 +3,7 @@ import Icon from '@components/Icon';
|
|
|
3
3
|
import Typography from '@components/Typography';
|
|
4
4
|
|
|
5
5
|
import { TooltipContentBase } from './TooltipContentBase';
|
|
6
|
-
import {
|
|
6
|
+
import { ProgressChartTooltipProps } from './types';
|
|
7
7
|
import { mapSizes } from './utils';
|
|
8
8
|
|
|
9
9
|
export const ProgressChartTooltip = ({
|
|
@@ -12,7 +12,7 @@ export const ProgressChartTooltip = ({
|
|
|
12
12
|
valueFormatted,
|
|
13
13
|
iconName,
|
|
14
14
|
barProps = {},
|
|
15
|
-
}:
|
|
15
|
+
}: ProgressChartTooltipProps) => {
|
|
16
16
|
const { color } = barProps;
|
|
17
17
|
|
|
18
18
|
return (
|