@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.
Files changed (144) hide show
  1. package/package.json +4 -5
  2. package/src/components/actions/Button/index.tsx +68 -70
  3. package/src/components/actions/Button/style.ts +1 -1
  4. package/src/components/actions/ContextMenu/Group.tsx +1 -1
  5. package/src/components/actions/ContextMenu/MenuItem.tsx +4 -1
  6. package/src/components/actions/ContextMenu/index.tsx +11 -12
  7. package/src/components/actions/Dropdown/DropdownMenu.tsx +5 -2
  8. package/src/components/actions/Dropdown/DropdownTrigger.tsx +55 -57
  9. package/src/components/actions/Dropdown/useDropdown.tsx +1 -1
  10. package/src/components/actions/IconButton/index.tsx +11 -10
  11. package/src/components/actions/IconButton/style.ts +5 -2
  12. package/src/components/actions/ToggleButton/ToggleButton.tsx +26 -28
  13. package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +3 -8
  14. package/src/components/actions/ToggleButton/style.ts +5 -7
  15. package/src/components/charts/AreaChart/index.tsx +7 -8
  16. package/src/components/charts/BarChart/index.tsx +4 -4
  17. package/src/components/charts/GeoMercator/index.tsx +1 -1
  18. package/src/components/charts/Heatmap/index.tsx +3 -4
  19. package/src/components/charts/LineChart/index.tsx +3 -3
  20. package/src/components/charts/PieChart/index.tsx +1 -1
  21. package/src/components/charts/RadarChart/index.tsx +1 -1
  22. package/src/components/charts/RadialBarChart/index.tsx +1 -1
  23. package/src/components/charts/index.tsx +3 -0
  24. package/src/components/data/Avatar/index.tsx +7 -3
  25. package/src/components/data/Avatar/style.ts +2 -2
  26. package/src/components/data/Chip/index.tsx +39 -41
  27. package/src/components/data/Chip/style.ts +3 -2
  28. package/src/components/data/Console/Console.tsx +14 -12
  29. package/src/components/data/CopyId/index.tsx +3 -2
  30. package/src/components/data/Drawer/Drawer.stories.tsx +3 -5
  31. package/src/components/data/Drawer/DrawerContent.tsx +1 -1
  32. package/src/components/data/Drawer/DrawerHeading.tsx +30 -29
  33. package/src/components/data/Drawer/useDrawer.tsx +1 -1
  34. package/src/components/data/InfiniteScroll/index.tsx +37 -36
  35. package/src/components/data/Table/Table.stories.tsx +6 -2
  36. package/src/components/data/Table/index.tsx +63 -44
  37. package/src/components/data/Table/style.ts +3 -2
  38. package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +22 -19
  39. package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +3 -3
  40. package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +2 -1
  41. package/src/components/data/Table/subcomponents/Filter/field.tsx +2 -3
  42. package/src/components/data/Table/subcomponents/Filter/index.tsx +6 -10
  43. package/src/components/data/Table/subcomponents/Pagination/{index.tsx → PagePicker.tsx} +7 -7
  44. package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +37 -0
  45. package/src/components/data/Table/subcomponents/Pagination/style.ts +1 -1
  46. package/src/components/dialogs/Dialog/Dialog.stories.tsx +1 -2
  47. package/src/components/dialogs/Dialog/DialogBody.tsx +18 -17
  48. package/src/components/dialogs/Dialog/DialogContent.tsx +30 -28
  49. package/src/components/dialogs/Dialog/DialogHeading.tsx +1 -1
  50. package/src/components/dialogs/Dialog/useDialog.tsx +1 -1
  51. package/src/components/feedback/Alert/index.tsx +74 -73
  52. package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +1 -1
  53. package/src/components/feedback/NotificationBanner/index.tsx +1 -1
  54. package/src/components/feedback/Popover/PopoverContent.tsx +4 -1
  55. package/src/components/feedback/Popover/PopoverTrigger.tsx +33 -31
  56. package/src/components/feedback/Popover/usePopover.tsx +1 -1
  57. package/src/components/feedback/ProgressBar/index.tsx +1 -1
  58. package/src/components/feedback/QuestionTooltip/index.tsx +1 -2
  59. package/src/components/feedback/Tooltip/TooltipContent.tsx +4 -1
  60. package/src/components/feedback/Tooltip/TooltipTrigger.tsx +3 -3
  61. package/src/components/feedback/Tooltip/useTooltip.tsx +1 -1
  62. package/src/components/feedback/snacks/CookieConsent/index.tsx +5 -2
  63. package/src/components/feedback/snacks/Default/index.tsx +51 -50
  64. package/src/components/feedback/snacks/Drawer/index.tsx +22 -21
  65. package/src/components/feedback/snacks/NetworkDetector/index.tsx +35 -31
  66. package/src/components/inputs/CheckBox/Controlled.tsx +2 -3
  67. package/src/components/inputs/CheckBox/Generic.tsx +18 -72
  68. package/src/components/inputs/CheckBox/style.ts +40 -97
  69. package/src/components/inputs/CodeField/CodeField.stories.tsx +4 -5
  70. package/src/components/inputs/CodeField/index.tsx +1 -0
  71. package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +2 -3
  72. package/src/components/inputs/Date/DatePicker/Generic.tsx +20 -10
  73. package/src/components/inputs/Date/DateRangePicker/Context.tsx +12 -1
  74. package/src/components/inputs/Date/DateRangePicker/Controlled.tsx +74 -0
  75. package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +11 -6
  76. package/src/components/inputs/Date/DateRangePicker/DateSelector/Absolute.tsx +3 -3
  77. package/src/components/inputs/Date/DateRangePicker/DateSelector/Relative.tsx +1 -1
  78. package/src/components/inputs/Date/DateRangePicker/DateSelector/index.tsx +1 -1
  79. package/src/components/inputs/Date/DateRangePicker/{index.tsx → Generic.tsx} +43 -11
  80. package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +1 -1
  81. package/src/components/inputs/Date/DateRangePicker/style.ts +19 -5
  82. package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +1 -1
  83. package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +1 -1
  84. package/src/components/inputs/DurationField/Generic.tsx +149 -152
  85. package/src/components/inputs/FileField/FileField.stories.tsx +6 -6
  86. package/src/components/inputs/FileField/Generic.tsx +101 -99
  87. package/src/components/inputs/InputProps.ts +0 -2
  88. package/src/components/inputs/RadioGroup/Controlled.tsx +1 -2
  89. package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +6 -4
  90. package/src/components/inputs/RadioGroup/RadioItem.tsx +54 -53
  91. package/src/components/inputs/Slider/Generic.tsx +1 -1
  92. package/src/components/inputs/Slider/Slider.stories.tsx +1 -1
  93. package/src/components/inputs/Slider/handle.tsx +1 -0
  94. package/src/components/inputs/Switch/Controlled.tsx +1 -2
  95. package/src/components/inputs/Switch/Generic.tsx +18 -45
  96. package/src/components/inputs/Switch/Switch.stories.tsx +2 -4
  97. package/src/components/inputs/Switch/style.ts +44 -38
  98. package/src/components/inputs/TagField/Generic.tsx +109 -109
  99. package/src/components/inputs/TextAreaField/Generic.tsx +41 -39
  100. package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +2 -3
  101. package/src/components/inputs/TextField/Generic.tsx +81 -79
  102. package/src/components/inputs/TextField/TextField.stories.tsx +3 -4
  103. package/src/components/inputs/index.ts +3 -2
  104. package/src/components/inputs/layout/Description.tsx +1 -2
  105. package/src/components/inputs/layout/InputWrapper.ts +2 -2
  106. package/src/components/inputs/selects/SelectField/Controlled.tsx +1 -2
  107. package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +4 -1
  108. package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +9 -10
  109. package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +200 -197
  110. package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +1 -1
  111. package/src/components/inputs/selects/SubComponents/Option.tsx +3 -3
  112. package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +1 -1
  113. package/src/components/inputs/selects/SubComponents/style.ts +18 -4
  114. package/src/components/inputs/selects/index.tsx +5 -2
  115. package/src/components/inputs/selects/sharedStyle.ts +1 -0
  116. package/src/components/navigation/HorizontalNav/index.tsx +5 -32
  117. package/src/components/navigation/HorizontalNav/style.ts +11 -26
  118. package/src/components/navigation/IconNav/index.tsx +1 -1
  119. package/src/components/navigation/Steppers/SlimStepper/index.tsx +1 -1
  120. package/src/components/navigation/Steppers/SlimStepper/style.ts +1 -2
  121. package/src/components/navigation/Steppers/Stepper/index.tsx +1 -1
  122. package/src/components/navigation/Steppers/context.tsx +2 -2
  123. package/src/components/navigation/Tabs/Content.tsx +4 -1
  124. package/src/components/navigation/Tabs/Trigger.tsx +24 -23
  125. package/src/components/navigation/index.ts +1 -1
  126. package/src/components/other/ActionMenu/ActionMenu.stories.tsx +1 -2
  127. package/src/components/other/ActionMenu/index.tsx +30 -29
  128. package/src/components/other/Collapsible/CollapsibleTrigger.tsx +8 -4
  129. package/src/components/other/Company/index.tsx +25 -26
  130. package/src/components/other/Empty/Empty.stories.tsx +1 -1
  131. package/src/components/other/Empty/index.tsx +1 -3
  132. package/src/components/other/PermissionsGuard/index.tsx +2 -2
  133. package/src/components/visual/Card/index.tsx +4 -1
  134. package/src/errors/base.ts +4 -1
  135. package/src/errors/errors.ts +19 -2
  136. package/src/helpers/getSnackbarProvider.tsx +3 -3
  137. package/src/helpers/regexprs.ts +1 -0
  138. package/src/hooks/useFocus.tsx +3 -1
  139. package/src/hooks/useOnScreen.ts +1 -1
  140. package/src/hooks/useTableActions.ts +10 -5
  141. package/src/styled/GlobalStyle.ts +2 -1
  142. package/src/styled/zIndex.ts +1 -1
  143. package/src/test/testUtils.tsx +3 -0
  144. 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
- ({ variant, title, text, dismiss = false, elevation = 4, action }, ref) => {
31
- const [visible, setVisible] = useState(true);
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
- const hasTitle = title ? true : false;
35
+ const hasTitle = title ? true : false;
34
36
 
35
- const handleExecute = (e: MouseEvent<HTMLButtonElement>) => {
36
- e.preventDefault();
37
- e.stopPropagation();
38
- action?.execute();
39
- };
37
+ const handleExecute = (e: MouseEvent<HTMLButtonElement>) => {
38
+ e.preventDefault();
39
+ e.stopPropagation();
40
+ action?.execute();
41
+ };
40
42
 
41
- const handleDismiss = (e: MouseEvent<HTMLButtonElement>) => {
42
- e.preventDefault();
43
- e.stopPropagation();
44
- setVisible(false);
45
- };
43
+ const handleDismiss = (e: MouseEvent<HTMLButtonElement>) => {
44
+ e.preventDefault();
45
+ e.stopPropagation();
46
+ setVisible(false);
47
+ };
46
48
 
47
- function getIcon() {
48
- switch (variant) {
49
- case 'success':
50
- return <Success size={24} />;
51
- case 'error':
52
- return <Error size={24} />;
53
- case 'warning':
54
- return <Warning size={24} />;
55
- case 'info':
56
- return <Info size={24} />;
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
- return (
60
- <AnimatePresence>
61
- {visible && (
62
- <Container
63
- animate={{ opacity: 1 }}
64
- exit={{ opacity: 0 }}
65
- $hasTitle={hasTitle}
66
- initial={{ opacity: 0 }}
67
- $variant={variant}
68
- $elevation={elevation}
69
- transition={{ duration: 0.2 }}
70
- ref={ref}
71
- role="status"
72
- >
73
- <Grid hasTitle={hasTitle}>
74
- <IconContainer variant={variant}>{getIcon()}</IconContainer>
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
- {/* If title is declared set title, otherwise put everything on single line */}
77
- {title && (
78
- <>
79
- <h2>{title}</h2>
80
- <div />
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
- {typeof text === 'string' ? (
84
- <p>{text}</p>
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
- {hasTitle ? <div /> : null}
95
- <ButtonContainer hasTitle={hasTitle} show={dismiss || action ? true : false} variant={variant}>
96
- {action && (
97
- <Button size="small" variant="outline" onClick={handleExecute} text={action.text} color={variant} />
98
- )}
99
- {dismiss && (
100
- <Button size="small" color="white" variant="outline" onClick={handleDismiss} text="Dismiss" />
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
  });
@@ -74,6 +74,6 @@ export const NotificationBanner: FC<NotificationBannerProps> = ({ title, descrip
74
74
  </Container>
75
75
  )}
76
76
  </AnimatePresence>,
77
- document.querySelector('#notification-banner') as Element
77
+ document.querySelector('#notification-banner') as Element,
78
78
  );
79
79
  };
@@ -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>>(({ style, ...props }, propRef) => {
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
- ({ children, asChild = false, ...props }, propRef) => {
12
- const context = usePopoverContext();
13
- const childrenRef = (children as any).ref;
14
- const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
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
- // `asChild` allows the user to pass any element as the anchor
17
- if (asChild && isValidElement(children)) {
18
- return cloneElement(
19
- children,
20
- context.getReferenceProps({
21
- ref,
22
- ...props,
23
- ...children.props,
24
- 'data-state': context.open ? 'open' : 'closed',
25
- onFocus: props.onFocus,
26
- onBlur: props.onBlur,
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
+ });
@@ -82,6 +82,6 @@ export function usePopover({
82
82
  setDescriptionId,
83
83
  arrowRef,
84
84
  }),
85
- [open, setOpen, interactions, data, modal, labelId, descriptionId]
85
+ [open, setOpen, interactions, data, modal, labelId, descriptionId],
86
86
  );
87
87
  }
@@ -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>>(({ style, ...props }, propRef) => {
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
  );
@@ -74,6 +74,6 @@ export function useTooltip({
74
74
  ...interactions,
75
75
  ...data,
76
76
  }),
77
- [open, setOpen, interactions, data]
77
+ [open, setOpen, interactions, data],
78
78
  );
79
79
  }
@@ -20,7 +20,10 @@ type FormInputs = {
20
20
  analytical: boolean;
21
21
  };
22
22
 
23
- export const CookieConsentSnack = forwardRef<HTMLDivElement, CustomContentProps>(({ id }, ref) => {
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
- ({ id, message, title, button1, button2, type = 'info', icon }, ref) => {
27
- const { closeSnackbar } = useSnackbar();
28
- const theme = useTheme();
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
- const getIcon = () => {
31
- switch (type) {
32
- case 'info':
33
- return <InfoIcon fill={theme.colors.info} size={15} />;
34
- case 'success':
35
- return <CheckMarkIcon fill={theme.colors.success} size={15} />;
36
- case 'warning':
37
- return <WarningIcon fill={theme.colors.warning} size={15} />;
38
- case 'error':
39
- return <ErrorIcon fill={theme.colors.warning} size={15} />;
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
- const handleDismiss = useCallback(() => {
44
- closeSnackbar(id);
45
- }, [id, closeSnackbar]);
45
+ const handleDismiss = useCallback(() => {
46
+ closeSnackbar(id);
47
+ }, [id, closeSnackbar]);
46
48
 
47
- return (
48
- <Wrapper ref={ref}>
49
- <ContentContainer>
50
- <IconContainer variant={type}>
51
- {icon ? cloneElement(icon, { size: 15, fill: theme.colors[type] }) : getIcon()}
52
- </IconContainer>
53
- <TextContainer>
54
- {title && <h3>{title}</h3>}
55
- <h5>{message}</h5>
56
- {button1 && (
57
- <ButtonContainer>
58
- <>
59
- {button1}
60
- {button2 && button2}
61
- </>
62
- </ButtonContainer>
63
- )}
64
- </TextContainer>
65
- <div style={{ width: '25px' }}>
66
- <Tooltip>
67
- <Tooltip.Trigger asChild>
68
- <IconButton icon={<CloseIcon />} ariaLabel="Dismiss snack popup" onClick={handleDismiss} />
69
- </Tooltip.Trigger>
70
- <Tooltip.Content>Dismiss</Tooltip.Content>
71
- </Tooltip>
72
- </div>
73
- </ContentContainer>
74
- </Wrapper>
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
- ({ id, message, children }, ref) => {
50
- const { closeSnackbar } = useSnackbar();
51
- const [expanded, setExpanded] = useState<boolean>(false);
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
- const handleClose = () => {
54
- closeSnackbar(id);
55
- };
55
+ const handleClose = () => {
56
+ closeSnackbar(id);
57
+ };
56
58
 
57
- return (
58
- <Wrapper ref={ref} data-testid={id}>
59
- <Container expanded={expanded}>
60
- <h4>{message}</h4>
61
- <div>
62
- <ArrowDownIcon onClick={() => setExpanded(!expanded)} size={16} />
63
- <CloseIcon onClick={handleClose} size={16} />
64
- </div>
65
- </Container>
66
- <Content expanded={expanded}>{children}</Content>
67
- </Wrapper>
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>(({ id, message }, ref) => {
36
- const { closeSnackbar } = useSnackbar();
35
+ export const NetworkDetectorOfflineSnack = forwardRef<HTMLDivElement, CustomContentProps>(
36
+ function NetworkDetectorOfflineSnack({ id, message }, ref) {
37
+ const { closeSnackbar } = useSnackbar();
37
38
 
38
- const handleClose = () => {
39
- closeSnackbar(id);
40
- };
39
+ const handleClose = () => {
40
+ closeSnackbar(id);
41
+ };
41
42
 
42
- return (
43
- <Container ref={ref}>
44
- <WifiOffIcon size={18} style={{ stroke: 'black' }} />
45
- <p>{message}</p>
46
- <CloseIconContainer>
47
- <CloseIcon onClick={handleClose} size={18} style={{ cursor: 'pointer' }} />
48
- </CloseIconContainer>
49
- </Container>
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>(({ id, message }, ref) => {
54
- const theme = useTheme();
55
- const { closeSnackbar } = useSnackbar();
55
+ export const NetworkDetectorOnlineSnack = forwardRef<HTMLDivElement, CustomContentProps>(
56
+ function NetworkDetectorOnlineSnack({ id, message }, ref) {
57
+ const theme = useTheme();
58
+ const { closeSnackbar } = useSnackbar();
56
59
 
57
- const handleClose = () => {
58
- closeSnackbar(id);
59
- };
60
+ const handleClose = () => {
61
+ closeSnackbar(id);
62
+ };
60
63
 
61
- return (
62
- <Container ref={ref}>
63
- <WifiIcon size={20} style={{ stroke: theme.colors.success }} />
64
- <p>{message}</p>
65
- <CloseIconContainer>
66
- <CloseIcon onClick={handleClose} size={18} style={{ cursor: 'pointer' }} />
67
- </CloseIconContainer>
68
- </Container>
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, CheckboxContainer } from './style';
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
- <CheckboxContainer className="placeholder" readOnly={readOnly} hasError={!!error} disabled={disabled} />
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 /> */}