@takaro/lib-components 0.0.1 → 0.0.4
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/package.json +4 -5
- package/src/components/actions/Button/index.tsx +68 -70
- package/src/components/actions/Button/style.ts +1 -1
- package/src/components/actions/ContextMenu/Group.tsx +1 -1
- package/src/components/actions/ContextMenu/MenuItem.tsx +4 -1
- package/src/components/actions/ContextMenu/index.tsx +11 -12
- package/src/components/actions/Dropdown/DropdownMenu.tsx +5 -2
- package/src/components/actions/Dropdown/DropdownTrigger.tsx +55 -57
- package/src/components/actions/Dropdown/useDropdown.tsx +1 -1
- package/src/components/actions/IconButton/index.tsx +11 -10
- package/src/components/actions/IconButton/style.ts +5 -2
- package/src/components/actions/ToggleButton/ToggleButton.tsx +26 -28
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +3 -8
- package/src/components/actions/ToggleButton/style.ts +5 -7
- package/src/components/charts/AreaChart/index.tsx +7 -8
- package/src/components/charts/BarChart/index.tsx +4 -4
- package/src/components/charts/GeoMercator/index.tsx +1 -1
- package/src/components/charts/Heatmap/index.tsx +3 -4
- package/src/components/charts/LineChart/index.tsx +3 -3
- package/src/components/charts/PieChart/index.tsx +1 -1
- package/src/components/charts/RadarChart/index.tsx +1 -1
- package/src/components/charts/RadialBarChart/index.tsx +1 -1
- package/src/components/charts/index.tsx +3 -0
- package/src/components/data/Avatar/index.tsx +7 -3
- package/src/components/data/Avatar/style.ts +2 -2
- package/src/components/data/Chip/index.tsx +39 -41
- package/src/components/data/Chip/style.ts +3 -2
- package/src/components/data/Console/Console.tsx +14 -12
- package/src/components/data/CopyId/index.tsx +3 -2
- package/src/components/data/Drawer/Drawer.stories.tsx +3 -5
- package/src/components/data/Drawer/DrawerContent.tsx +1 -1
- package/src/components/data/Drawer/DrawerHeading.tsx +30 -29
- package/src/components/data/Drawer/useDrawer.tsx +1 -1
- package/src/components/data/InfiniteScroll/index.tsx +37 -36
- package/src/components/data/Table/Table.stories.tsx +6 -2
- package/src/components/data/Table/index.tsx +63 -44
- package/src/components/data/Table/style.ts +3 -2
- package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +22 -19
- package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +3 -3
- package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +2 -1
- package/src/components/data/Table/subcomponents/Filter/field.tsx +2 -3
- package/src/components/data/Table/subcomponents/Filter/index.tsx +6 -10
- package/src/components/data/Table/subcomponents/Pagination/{index.tsx → PagePicker.tsx} +7 -7
- package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +37 -0
- package/src/components/data/Table/subcomponents/Pagination/style.ts +1 -1
- package/src/components/dialogs/Dialog/Dialog.stories.tsx +1 -2
- package/src/components/dialogs/Dialog/DialogBody.tsx +18 -17
- package/src/components/dialogs/Dialog/DialogContent.tsx +30 -28
- package/src/components/dialogs/Dialog/DialogHeading.tsx +1 -1
- package/src/components/dialogs/Dialog/useDialog.tsx +1 -1
- package/src/components/feedback/Alert/index.tsx +74 -73
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +1 -1
- package/src/components/feedback/NotificationBanner/index.tsx +1 -1
- package/src/components/feedback/Popover/PopoverContent.tsx +4 -1
- package/src/components/feedback/Popover/PopoverTrigger.tsx +33 -31
- package/src/components/feedback/Popover/usePopover.tsx +1 -1
- package/src/components/feedback/ProgressBar/index.tsx +1 -1
- package/src/components/feedback/QuestionTooltip/index.tsx +1 -2
- package/src/components/feedback/Tooltip/TooltipContent.tsx +4 -1
- package/src/components/feedback/Tooltip/TooltipTrigger.tsx +3 -3
- package/src/components/feedback/Tooltip/useTooltip.tsx +1 -1
- package/src/components/feedback/snacks/CookieConsent/index.tsx +5 -2
- package/src/components/feedback/snacks/Default/index.tsx +51 -50
- package/src/components/feedback/snacks/Drawer/index.tsx +22 -21
- package/src/components/feedback/snacks/NetworkDetector/index.tsx +35 -31
- package/src/components/inputs/CheckBox/Controlled.tsx +2 -3
- package/src/components/inputs/CheckBox/Generic.tsx +18 -72
- package/src/components/inputs/CheckBox/style.ts +40 -97
- package/src/components/inputs/CodeField/CodeField.stories.tsx +4 -5
- package/src/components/inputs/CodeField/index.tsx +1 -0
- package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +2 -3
- package/src/components/inputs/Date/DatePicker/Generic.tsx +20 -10
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +12 -1
- package/src/components/inputs/Date/DateRangePicker/Controlled.tsx +74 -0
- package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +11 -6
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Absolute.tsx +3 -3
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Relative.tsx +1 -1
- package/src/components/inputs/Date/DateRangePicker/DateSelector/index.tsx +1 -1
- package/src/components/inputs/Date/DateRangePicker/{index.tsx → Generic.tsx} +43 -11
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +1 -1
- package/src/components/inputs/Date/DateRangePicker/style.ts +19 -5
- package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +1 -1
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +1 -1
- package/src/components/inputs/DurationField/Generic.tsx +149 -152
- package/src/components/inputs/FileField/FileField.stories.tsx +6 -6
- package/src/components/inputs/FileField/Generic.tsx +101 -99
- package/src/components/inputs/InputProps.ts +0 -2
- package/src/components/inputs/RadioGroup/Controlled.tsx +1 -2
- package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +6 -4
- package/src/components/inputs/RadioGroup/RadioItem.tsx +54 -53
- package/src/components/inputs/Slider/Generic.tsx +1 -1
- package/src/components/inputs/Slider/Slider.stories.tsx +1 -1
- package/src/components/inputs/Slider/handle.tsx +1 -0
- package/src/components/inputs/Switch/Controlled.tsx +1 -2
- package/src/components/inputs/Switch/Generic.tsx +18 -45
- package/src/components/inputs/Switch/Switch.stories.tsx +2 -4
- package/src/components/inputs/Switch/style.ts +44 -38
- package/src/components/inputs/TagField/Generic.tsx +109 -109
- package/src/components/inputs/TextAreaField/Generic.tsx +41 -39
- package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +2 -3
- package/src/components/inputs/TextField/Generic.tsx +81 -79
- package/src/components/inputs/TextField/TextField.stories.tsx +3 -4
- package/src/components/inputs/index.ts +3 -2
- package/src/components/inputs/layout/Description.tsx +1 -2
- package/src/components/inputs/layout/InputWrapper.ts +2 -2
- package/src/components/inputs/selects/SelectField/Controlled.tsx +1 -2
- package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +4 -1
- package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +9 -10
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +200 -197
- package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +1 -1
- package/src/components/inputs/selects/SubComponents/Option.tsx +3 -3
- package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +1 -1
- package/src/components/inputs/selects/SubComponents/style.ts +18 -4
- package/src/components/inputs/selects/index.tsx +5 -2
- package/src/components/inputs/selects/sharedStyle.ts +1 -0
- package/src/components/navigation/HorizontalNav/index.tsx +5 -32
- package/src/components/navigation/HorizontalNav/style.ts +11 -26
- package/src/components/navigation/IconNav/index.tsx +1 -1
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +1 -1
- package/src/components/navigation/Steppers/SlimStepper/style.ts +1 -2
- package/src/components/navigation/Steppers/Stepper/index.tsx +1 -1
- package/src/components/navigation/Steppers/context.tsx +2 -2
- package/src/components/navigation/Tabs/Content.tsx +4 -1
- package/src/components/navigation/Tabs/Trigger.tsx +24 -23
- package/src/components/navigation/index.ts +1 -1
- package/src/components/other/ActionMenu/ActionMenu.stories.tsx +1 -2
- package/src/components/other/ActionMenu/index.tsx +30 -29
- package/src/components/other/Collapsible/CollapsibleTrigger.tsx +8 -4
- package/src/components/other/Company/index.tsx +25 -26
- package/src/components/other/Empty/Empty.stories.tsx +1 -1
- package/src/components/other/Empty/index.tsx +1 -3
- package/src/components/other/PermissionsGuard/index.tsx +2 -2
- package/src/components/visual/Card/index.tsx +4 -1
- package/src/errors/base.ts +4 -1
- package/src/errors/errors.ts +19 -2
- package/src/helpers/getSnackbarProvider.tsx +3 -3
- package/src/helpers/regexprs.ts +1 -0
- package/src/hooks/useFocus.tsx +3 -1
- package/src/hooks/useOnScreen.ts +1 -1
- package/src/hooks/useTableActions.ts +10 -5
- package/src/styled/GlobalStyle.ts +2 -1
- package/src/styled/zIndex.ts +1 -1
- package/src/test/testUtils.tsx +3 -0
- package/src/components/data/Table/subcomponents/index.ts +0 -4
|
@@ -26,84 +26,85 @@ export interface AlertProps {
|
|
|
26
26
|
action?: Action;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const Alert = forwardRef<HTMLDivElement, AlertProps>(
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(
|
|
30
|
+
{ variant, title, text, dismiss = false, elevation = 4, action },
|
|
31
|
+
ref,
|
|
32
|
+
) {
|
|
33
|
+
const [visible, setVisible] = useState(true);
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
const hasTitle = title ? true : false;
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const handleExecute = (e: MouseEvent<HTMLButtonElement>) => {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
action?.execute();
|
|
41
|
+
};
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const handleDismiss = (e: MouseEvent<HTMLButtonElement>) => {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
setVisible(false);
|
|
47
|
+
};
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
49
|
+
function getIcon() {
|
|
50
|
+
switch (variant) {
|
|
51
|
+
case 'success':
|
|
52
|
+
return <Success size={24} />;
|
|
53
|
+
case 'error':
|
|
54
|
+
return <Error size={24} />;
|
|
55
|
+
case 'warning':
|
|
56
|
+
return <Warning size={24} />;
|
|
57
|
+
case 'info':
|
|
58
|
+
return <Info size={24} />;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
}
|
|
61
|
+
return (
|
|
62
|
+
<AnimatePresence>
|
|
63
|
+
{visible && (
|
|
64
|
+
<Container
|
|
65
|
+
animate={{ opacity: 1 }}
|
|
66
|
+
exit={{ opacity: 0 }}
|
|
67
|
+
$hasTitle={hasTitle}
|
|
68
|
+
initial={{ opacity: 0 }}
|
|
69
|
+
$variant={variant}
|
|
70
|
+
$elevation={elevation}
|
|
71
|
+
transition={{ duration: 0.2 }}
|
|
72
|
+
ref={ref}
|
|
73
|
+
role="status"
|
|
74
|
+
>
|
|
75
|
+
<Grid hasTitle={hasTitle}>
|
|
76
|
+
<IconContainer variant={variant}>{getIcon()}</IconContainer>
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
{/* If title is declared set title, otherwise put everything on single line */}
|
|
79
|
+
{title && (
|
|
80
|
+
<>
|
|
81
|
+
<h2>{title}</h2>
|
|
82
|
+
<div />
|
|
83
|
+
</>
|
|
84
|
+
)}
|
|
85
|
+
{typeof text === 'string' ? (
|
|
86
|
+
<p>{text}</p>
|
|
87
|
+
) : (
|
|
88
|
+
text && (
|
|
89
|
+
<ul>
|
|
90
|
+
{text.map((message) => (
|
|
91
|
+
<li key={'message-' + message}>{message}</li>
|
|
92
|
+
))}
|
|
93
|
+
</ul>
|
|
94
|
+
)
|
|
95
|
+
)}
|
|
96
|
+
{hasTitle ? <div /> : null}
|
|
97
|
+
<ButtonContainer hasTitle={hasTitle} show={dismiss || action ? true : false} variant={variant}>
|
|
98
|
+
{action && (
|
|
99
|
+
<Button size="small" variant="outline" onClick={handleExecute} text={action.text} color={variant} />
|
|
82
100
|
)}
|
|
83
|
-
{
|
|
84
|
-
<
|
|
85
|
-
) : (
|
|
86
|
-
text && (
|
|
87
|
-
<ul>
|
|
88
|
-
{text.map((message) => (
|
|
89
|
-
<li>{message}</li>
|
|
90
|
-
))}
|
|
91
|
-
</ul>
|
|
92
|
-
)
|
|
101
|
+
{dismiss && (
|
|
102
|
+
<Button size="small" color="white" variant="outline" onClick={handleDismiss} text="Dismiss" />
|
|
93
103
|
)}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
)}
|
|
102
|
-
</ButtonContainer>
|
|
103
|
-
</Grid>
|
|
104
|
-
</Container>
|
|
105
|
-
)}
|
|
106
|
-
</AnimatePresence>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
);
|
|
104
|
+
</ButtonContainer>
|
|
105
|
+
</Grid>
|
|
106
|
+
</Container>
|
|
107
|
+
)}
|
|
108
|
+
</AnimatePresence>
|
|
109
|
+
);
|
|
110
|
+
});
|
|
@@ -8,7 +8,7 @@ it('Should render <NotificationBanner/>', () => {
|
|
|
8
8
|
document.body.appendChild(notificationBannerPortal);
|
|
9
9
|
|
|
10
10
|
const { container } = render(
|
|
11
|
-
<NotificationBanner description="Notification banner description" title="Notification banner title"
|
|
11
|
+
<NotificationBanner description="Notification banner description" title="Notification banner title" />,
|
|
12
12
|
);
|
|
13
13
|
expect(container).toMatchSnapshot();
|
|
14
14
|
});
|
|
@@ -10,7 +10,10 @@ const Container = styled.div`
|
|
|
10
10
|
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
|
-
export const PopoverContent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>((
|
|
13
|
+
export const PopoverContent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>(function PopoverContent(
|
|
14
|
+
{ style, ...props },
|
|
15
|
+
propRef,
|
|
16
|
+
) {
|
|
14
17
|
const theme = useTheme();
|
|
15
18
|
const { context: floatingContext, arrowRef, ...context } = usePopoverContext();
|
|
16
19
|
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
@@ -1,43 +1,45 @@
|
|
|
1
1
|
import { forwardRef, cloneElement, isValidElement, HTMLProps, PropsWithChildren } from 'react';
|
|
2
2
|
import { usePopoverContext } from './PopoverContext';
|
|
3
3
|
import { useMergeRefs } from '@floating-ui/react';
|
|
4
|
+
import { ReactNode } from '@tanstack/react-router';
|
|
4
5
|
|
|
5
6
|
export type PopoverTriggerProps = HTMLProps<HTMLElement> &
|
|
6
7
|
PropsWithChildren<{
|
|
7
8
|
asChild?: boolean;
|
|
8
9
|
}>;
|
|
9
10
|
|
|
10
|
-
export const PopoverTrigger = forwardRef<HTMLElement, PopoverTriggerProps>(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
export const PopoverTrigger = forwardRef<HTMLElement, PopoverTriggerProps>(function PopoverTrigger(
|
|
12
|
+
{ children, asChild = false, ...props },
|
|
13
|
+
propRef,
|
|
14
|
+
) {
|
|
15
|
+
const context = usePopoverContext();
|
|
16
|
+
const childrenRef = (children as ReactNode).ref;
|
|
17
|
+
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<button
|
|
33
|
-
ref={ref}
|
|
34
|
-
type="button"
|
|
35
|
-
// The user can style the trigger based on the state
|
|
36
|
-
data-state={context.open ? 'open' : 'closed'}
|
|
37
|
-
{...context.getReferenceProps(props)}
|
|
38
|
-
>
|
|
39
|
-
{children}
|
|
40
|
-
</button>
|
|
19
|
+
// `asChild` allows the user to pass any element as the anchor
|
|
20
|
+
if (asChild && isValidElement(children)) {
|
|
21
|
+
return cloneElement(
|
|
22
|
+
children,
|
|
23
|
+
context.getReferenceProps({
|
|
24
|
+
ref,
|
|
25
|
+
...props,
|
|
26
|
+
...children.props,
|
|
27
|
+
'data-state': context.open ? 'open' : 'closed',
|
|
28
|
+
onFocus: props.onFocus,
|
|
29
|
+
onBlur: props.onBlur,
|
|
30
|
+
}),
|
|
41
31
|
);
|
|
42
32
|
}
|
|
43
|
-
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<button
|
|
36
|
+
ref={ref}
|
|
37
|
+
type="button"
|
|
38
|
+
// The user can style the trigger based on the state
|
|
39
|
+
data-state={context.open ? 'open' : 'closed'}
|
|
40
|
+
{...context.getReferenceProps(props)}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</button>
|
|
44
|
+
);
|
|
45
|
+
});
|
|
@@ -69,7 +69,7 @@ const Progress = styled.div<{ color: Color; progress: number }>`
|
|
|
69
69
|
color
|
|
70
70
|
].slice(
|
|
71
71
|
1,
|
|
72
|
-
theme.colors[color].length
|
|
72
|
+
theme.colors[color].length,
|
|
73
73
|
)}' fill-opacity='1' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E")`};
|
|
74
74
|
}
|
|
75
75
|
`;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { Tooltip } from '../Tooltip';
|
|
2
|
+
import { Tooltip, TooltipProps } from '../Tooltip';
|
|
3
3
|
import { AiOutlineQuestion as QuestionIcon } from 'react-icons/ai';
|
|
4
4
|
import { styled } from '../../../styled';
|
|
5
|
-
import { TooltipProps } from '../Tooltip';
|
|
6
5
|
|
|
7
6
|
const TriggerContainer = styled.div`
|
|
8
7
|
background-color: ${({ theme }) => theme.colors.backgroundAlt};
|
|
@@ -17,7 +17,10 @@ const Container = styled.div<{ elevation: Elevation }>`
|
|
|
17
17
|
z-index: ${({ theme }) => theme.zIndex.tooltip};
|
|
18
18
|
`;
|
|
19
19
|
|
|
20
|
-
export const TooltipContent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>((
|
|
20
|
+
export const TooltipContent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>(function TooltipContent(
|
|
21
|
+
{ style, ...props },
|
|
22
|
+
propRef,
|
|
23
|
+
) {
|
|
21
24
|
const theme = useTheme();
|
|
22
25
|
const { floatingStyles, open, arrowRef, context, getFloatingProps } = useTooltipContext();
|
|
23
26
|
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
@@ -12,7 +12,7 @@ interface TooltipTriggerProps {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement> & TooltipTriggerProps>(
|
|
15
|
-
({ children, asChild = false, ...props }, propRef)
|
|
15
|
+
function TooltipTrigger({ children, asChild = false, ...props }, propRef) {
|
|
16
16
|
const context = useTooltipContext();
|
|
17
17
|
const childrenRef = (children as any).ref;
|
|
18
18
|
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
|
|
@@ -26,7 +26,7 @@ export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement> & T
|
|
|
26
26
|
...children.props,
|
|
27
27
|
ref,
|
|
28
28
|
'data-state': context.open ? 'open' : 'closed',
|
|
29
|
-
})
|
|
29
|
+
}),
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -35,5 +35,5 @@ export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement> & T
|
|
|
35
35
|
{children}
|
|
36
36
|
</Container>
|
|
37
37
|
);
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
39
|
);
|
|
@@ -20,7 +20,10 @@ type FormInputs = {
|
|
|
20
20
|
analytical: boolean;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export const CookieConsentSnack = forwardRef<HTMLDivElement, CustomContentProps>((
|
|
23
|
+
export const CookieConsentSnack = forwardRef<HTMLDivElement, CustomContentProps>(function CookieConsentSnack(
|
|
24
|
+
{ id },
|
|
25
|
+
ref,
|
|
26
|
+
) {
|
|
24
27
|
const { closeSnackbar } = useSnackbar();
|
|
25
28
|
const [showDetails, setShowDetails] = useState<boolean>(false);
|
|
26
29
|
|
|
@@ -30,7 +33,7 @@ export const CookieConsentSnack = forwardRef<HTMLDivElement, CustomContentProps>
|
|
|
30
33
|
functional: z.boolean(),
|
|
31
34
|
analytical: z.boolean(),
|
|
32
35
|
}),
|
|
33
|
-
[]
|
|
36
|
+
[],
|
|
34
37
|
);
|
|
35
38
|
|
|
36
39
|
const onSubmit: SubmitHandler<FormInputs> = async () => {
|
|
@@ -22,56 +22,57 @@ export interface DefaultSnackProps extends CustomContentProps {
|
|
|
22
22
|
icon?: ReactElement;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const DefaultSnack = forwardRef<HTMLDivElement, DefaultSnackProps>(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
export const DefaultSnack = forwardRef<HTMLDivElement, DefaultSnackProps>(function DefaultSnack(
|
|
26
|
+
{ id, message, title, button1, button2, type = 'info', icon },
|
|
27
|
+
ref,
|
|
28
|
+
) {
|
|
29
|
+
const { closeSnackbar } = useSnackbar();
|
|
30
|
+
const theme = useTheme();
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
const getIcon = () => {
|
|
33
|
+
switch (type) {
|
|
34
|
+
case 'info':
|
|
35
|
+
return <InfoIcon fill={theme.colors.info} size={15} />;
|
|
36
|
+
case 'success':
|
|
37
|
+
return <CheckMarkIcon fill={theme.colors.success} size={15} />;
|
|
38
|
+
case 'warning':
|
|
39
|
+
return <WarningIcon fill={theme.colors.warning} size={15} />;
|
|
40
|
+
case 'error':
|
|
41
|
+
return <ErrorIcon fill={theme.colors.warning} size={15} />;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const handleDismiss = useCallback(() => {
|
|
46
|
+
closeSnackbar(id);
|
|
47
|
+
}, [id, closeSnackbar]);
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
49
|
+
return (
|
|
50
|
+
<Wrapper ref={ref}>
|
|
51
|
+
<ContentContainer>
|
|
52
|
+
<IconContainer variant={type}>
|
|
53
|
+
{icon ? cloneElement(icon, { size: 15, fill: theme.colors[type] }) : getIcon()}
|
|
54
|
+
</IconContainer>
|
|
55
|
+
<TextContainer>
|
|
56
|
+
{title && <h3>{title}</h3>}
|
|
57
|
+
<h5>{message}</h5>
|
|
58
|
+
{button1 && (
|
|
59
|
+
<ButtonContainer>
|
|
60
|
+
<>
|
|
61
|
+
{button1}
|
|
62
|
+
{button2 && button2}
|
|
63
|
+
</>
|
|
64
|
+
</ButtonContainer>
|
|
65
|
+
)}
|
|
66
|
+
</TextContainer>
|
|
67
|
+
<div style={{ width: '25px' }}>
|
|
68
|
+
<Tooltip>
|
|
69
|
+
<Tooltip.Trigger asChild>
|
|
70
|
+
<IconButton icon={<CloseIcon />} ariaLabel="Dismiss snack popup" onClick={handleDismiss} />
|
|
71
|
+
</Tooltip.Trigger>
|
|
72
|
+
<Tooltip.Content>Dismiss</Tooltip.Content>
|
|
73
|
+
</Tooltip>
|
|
74
|
+
</div>
|
|
75
|
+
</ContentContainer>
|
|
76
|
+
</Wrapper>
|
|
77
|
+
);
|
|
78
|
+
});
|
|
@@ -45,26 +45,27 @@ const Content = styled.div<{ expanded: boolean }>`
|
|
|
45
45
|
border-radius-top-right: 0;
|
|
46
46
|
`;
|
|
47
47
|
|
|
48
|
-
export const DrawerSnack = forwardRef<HTMLDivElement, PropsWithChildren<CustomContentProps>>(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
export const DrawerSnack = forwardRef<HTMLDivElement, PropsWithChildren<CustomContentProps>>(function DrawerSnack(
|
|
49
|
+
{ id, message, children },
|
|
50
|
+
ref,
|
|
51
|
+
) {
|
|
52
|
+
const { closeSnackbar } = useSnackbar();
|
|
53
|
+
const [expanded, setExpanded] = useState<boolean>(false);
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
const handleClose = () => {
|
|
56
|
+
closeSnackbar(id);
|
|
57
|
+
};
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
);
|
|
59
|
+
return (
|
|
60
|
+
<Wrapper ref={ref} data-testid={id}>
|
|
61
|
+
<Container expanded={expanded}>
|
|
62
|
+
<h4>{message}</h4>
|
|
63
|
+
<div>
|
|
64
|
+
<ArrowDownIcon onClick={() => setExpanded(!expanded)} size={16} />
|
|
65
|
+
<CloseIcon onClick={handleClose} size={16} />
|
|
66
|
+
</div>
|
|
67
|
+
</Container>
|
|
68
|
+
<Content expanded={expanded}>{children}</Content>
|
|
69
|
+
</Wrapper>
|
|
70
|
+
);
|
|
71
|
+
});
|
|
@@ -32,39 +32,43 @@ const CloseIconContainer = styled.div`
|
|
|
32
32
|
}
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
|
-
export const NetworkDetectorOfflineSnack = forwardRef<HTMLDivElement, CustomContentProps>(
|
|
36
|
-
|
|
35
|
+
export const NetworkDetectorOfflineSnack = forwardRef<HTMLDivElement, CustomContentProps>(
|
|
36
|
+
function NetworkDetectorOfflineSnack({ id, message }, ref) {
|
|
37
|
+
const { closeSnackbar } = useSnackbar();
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const handleClose = () => {
|
|
40
|
+
closeSnackbar(id);
|
|
41
|
+
};
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
43
|
+
return (
|
|
44
|
+
<Container ref={ref}>
|
|
45
|
+
<WifiOffIcon size={18} style={{ stroke: 'black' }} />
|
|
46
|
+
<p>{message}</p>
|
|
47
|
+
<CloseIconContainer>
|
|
48
|
+
<CloseIcon onClick={handleClose} size={18} style={{ cursor: 'pointer' }} />
|
|
49
|
+
</CloseIconContainer>
|
|
50
|
+
</Container>
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
);
|
|
52
54
|
|
|
53
|
-
export const NetworkDetectorOnlineSnack = forwardRef<HTMLDivElement, CustomContentProps>(
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
export const NetworkDetectorOnlineSnack = forwardRef<HTMLDivElement, CustomContentProps>(
|
|
56
|
+
function NetworkDetectorOnlineSnack({ id, message }, ref) {
|
|
57
|
+
const theme = useTheme();
|
|
58
|
+
const { closeSnackbar } = useSnackbar();
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
const handleClose = () => {
|
|
61
|
+
closeSnackbar(id);
|
|
62
|
+
};
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
64
|
+
return (
|
|
65
|
+
<Container ref={ref}>
|
|
66
|
+
<WifiIcon size={20} style={{ stroke: theme.colors.success }} />
|
|
67
|
+
<p>{message}</p>
|
|
68
|
+
<CloseIconContainer>
|
|
69
|
+
<CloseIcon onClick={handleClose} size={18} style={{ cursor: 'pointer' }} />
|
|
70
|
+
</CloseIconContainer>
|
|
71
|
+
</Container>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { useController } from 'react-hook-form';
|
|
3
3
|
import { GenericCheckBox } from '.';
|
|
4
|
-
import { Container,
|
|
4
|
+
import { Container, LoadingCheckBox } from './style';
|
|
5
5
|
|
|
6
6
|
import { defaultInputProps, defaultInputPropsFactory, ControlledInputProps } from '../InputProps';
|
|
7
7
|
import { Label, ErrorMessage, InputWrapper, Description } from '../layout';
|
|
@@ -54,7 +54,7 @@ export const ControlledCheckBox: FC<ControlledCheckBoxProps> = (props) => {
|
|
|
54
54
|
htmlFor={name}
|
|
55
55
|
/>
|
|
56
56
|
)}
|
|
57
|
-
<
|
|
57
|
+
<LoadingCheckBox className="placeholder" />
|
|
58
58
|
{/* CASE: show label after <CheckBox /> */}
|
|
59
59
|
{labelPosition === 'right' && label && (
|
|
60
60
|
<Label
|
|
@@ -101,7 +101,6 @@ export const ControlledCheckBox: FC<ControlledCheckBoxProps> = (props) => {
|
|
|
101
101
|
onChange={field.onChange}
|
|
102
102
|
onBlur={field.onBlur}
|
|
103
103
|
value={field.value}
|
|
104
|
-
ref={field.ref}
|
|
105
104
|
/>
|
|
106
105
|
|
|
107
106
|
{/* CASE: show label after <CheckBox /> */}
|