@takaro/lib-components 0.0.1 → 0.0.5

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 +5 -6
  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
@@ -31,11 +31,11 @@ export const useStepper = () => {
31
31
  const decrementCurrentStep = useCallback(() => dispatch({ type: stepTypes.DECREMENT_CURRENT_STEP }), [dispatch]);
32
32
  const setSteps = useCallback(
33
33
  (steps: ReactNode[]) => dispatch({ type: stepTypes.SET_STEPS, payload: { steps } }),
34
- [dispatch]
34
+ [dispatch],
35
35
  );
36
36
  const setCurrentStep = useCallback(
37
37
  (amount: number) => dispatch({ type: stepTypes.SET_CURRENT_STEP, payload: { amount } }),
38
- [dispatch]
38
+ [dispatch],
39
39
  );
40
40
 
41
41
  return {
@@ -16,7 +16,10 @@ const variants = {
16
16
  hidden: { opacity: 0, x: '20px' },
17
17
  };
18
18
 
19
- export const Content = forwardRef<HTMLDivElement, PropsWithChildren<ContentProps>>(({ children, value }, ref) => {
19
+ export const Content = forwardRef<HTMLDivElement, PropsWithChildren<ContentProps>>(function TabsContent(
20
+ { children, value },
21
+ ref,
22
+ ) {
20
23
  const { value: selectedValue } = useTabsContext();
21
24
 
22
25
  const isHidden = value !== selectedValue;
@@ -37,29 +37,30 @@ interface TriggerProps {
37
37
  disabled?: boolean;
38
38
  }
39
39
 
40
- export const Trigger = forwardRef<HTMLButtonElement, PropsWithChildren<TriggerProps>>(
41
- ({ children, disabled, value }, ref) => {
42
- const { setValue, value: selectedValue } = useTabsContext();
40
+ export const Trigger = forwardRef<HTMLButtonElement, PropsWithChildren<TriggerProps>>(function TabsTrigger(
41
+ { children, disabled, value },
42
+ ref,
43
+ ) {
44
+ const { setValue, value: selectedValue } = useTabsContext();
43
45
 
44
- const handleClick = () => {
45
- if (disabled) return;
46
- setValue(value);
47
- };
46
+ const handleClick = () => {
47
+ if (disabled) return;
48
+ setValue(value);
49
+ };
48
50
 
49
- const isActive = value === selectedValue;
51
+ const isActive = value === selectedValue;
50
52
 
51
- return (
52
- <Container
53
- role="tab"
54
- ref={ref}
55
- onClick={handleClick}
56
- disabled={disabled}
57
- isActive={isActive}
58
- aria-selected={isActive}
59
- aria-controls={`tab-content-${value}`}
60
- >
61
- {children}
62
- </Container>
63
- );
64
- }
65
- );
53
+ return (
54
+ <Container
55
+ role="tab"
56
+ ref={ref}
57
+ onClick={handleClick}
58
+ disabled={disabled}
59
+ isActive={isActive}
60
+ aria-selected={isActive}
61
+ aria-controls={`tab-content-${value}`}
62
+ >
63
+ {children}
64
+ </Container>
65
+ );
66
+ });
@@ -10,7 +10,7 @@ export { IconNav } from './IconNav';
10
10
  export type { IconNavProps } from './IconNav';
11
11
 
12
12
  export { HorizontalNav } from './HorizontalNav';
13
- export type { HorizontalNavProps, HorizontalNavLink } from './HorizontalNav';
13
+ export type { HorizontalNavProps } from './HorizontalNav';
14
14
 
15
15
  export { Tabs } from './Tabs';
16
16
  export type { TabsProps } from './Tabs';
@@ -1,7 +1,6 @@
1
- import React, { useRef } from 'react';
1
+ import React, { useRef, useEffect, useState } from 'react';
2
2
  import { Meta, StoryFn } from '@storybook/react';
3
3
  import { Action, ActionMenu, ActionMenuProps } from '.';
4
- import { useEffect, useState } from 'react';
5
4
  import { styled } from '../../../styled';
6
5
  import { useOutsideAlerter } from '../../../hooks';
7
6
  import { useFloating } from '@floating-ui/react';
@@ -14,36 +14,37 @@ export interface ActionMenuProps {
14
14
  elevation?: Elevation;
15
15
  }
16
16
 
17
- export const ActionMenu = forwardRef<HTMLUListElement, ActionMenuProps>(
18
- ({ attributes, children, selectedState, elevation = 4 }, ref) => {
19
- const [selected, setSelected] = selectedState;
17
+ export const ActionMenu = forwardRef<HTMLUListElement, ActionMenuProps>(function ActionMenu(
18
+ { attributes, children, selectedState, elevation = 4 },
19
+ ref,
20
+ ) {
21
+ const [selected, setSelected] = selectedState;
20
22
 
21
- return (
22
- <Container
23
- elevation={elevation}
24
- style={{
25
- position: attributes.strategy,
26
- top: attributes.y ? attributes.y + 5 : 0,
27
- left: attributes.x ?? 0,
28
- }}
29
- ref={ref}
30
- >
31
- {Children.map(children, (child: ReactElement<ActionProps>, idx) => (
32
- <Item onClick={() => setSelected(idx)}>
33
- {child}
34
- {selected === idx ? (
35
- <div style={{ display: 'flex', alignItems: 'center' }}>
36
- <CheckMarkIcon size={15} />
37
- </div>
38
- ) : (
39
- <div className="checkmark-placeholder"></div>
40
- )}
41
- </Item>
42
- ))}
43
- </Container>
44
- );
45
- }
46
- );
23
+ return (
24
+ <Container
25
+ elevation={elevation}
26
+ style={{
27
+ position: attributes.strategy,
28
+ top: attributes.y ? attributes.y + 5 : 0,
29
+ left: attributes.x ?? 0,
30
+ }}
31
+ ref={ref}
32
+ >
33
+ {Children.map(children, (child: ReactElement<ActionProps>, idx) => (
34
+ <Item onClick={() => setSelected(idx)}>
35
+ {child}
36
+ {selected === idx ? (
37
+ <div style={{ display: 'flex', alignItems: 'center' }}>
38
+ <CheckMarkIcon size={15} />
39
+ </div>
40
+ ) : (
41
+ <div className="checkmark-placeholder"></div>
42
+ )}
43
+ </Item>
44
+ ))}
45
+ </Container>
46
+ );
47
+ });
47
48
 
48
49
  interface ActionProps {
49
50
  onClick: () => unknown;
@@ -29,7 +29,10 @@ const Container = styled.button<{ open: boolean }>`
29
29
  `;
30
30
 
31
31
  export type TriggerProps = HTMLProps<HTMLElement> & PropsWithChildren<{ asChild?: boolean }>;
32
- export const CollapsibleTrigger = forwardRef<HTMLElement, TriggerProps>(({ children, asChild }, ref) => {
32
+ export const CollapsibleTrigger = forwardRef<HTMLElement, TriggerProps>(function CollapsibleTrigger(
33
+ { children, asChild },
34
+ ref,
35
+ ) {
33
36
  const { setOpen, open } = useCollapsibleContext();
34
37
 
35
38
  const handleClick = () => {
@@ -37,9 +40,11 @@ export const CollapsibleTrigger = forwardRef<HTMLElement, TriggerProps>(({ child
37
40
  };
38
41
 
39
42
  if (asChild && isValidElement(children)) {
40
- const existingOnClick = children.props.onClick;
43
+ const hasOnClick = children.props.onClick;
41
44
  const mergedOnClick = () => {
42
- existingOnClick && existingOnClick();
45
+ if (hasOnClick) {
46
+ hasOnClick();
47
+ }
43
48
  handleClick();
44
49
  };
45
50
 
@@ -47,7 +52,6 @@ export const CollapsibleTrigger = forwardRef<HTMLElement, TriggerProps>(({ child
47
52
  onClick: mergedOnClick,
48
53
  role: 'button',
49
54
  });
50
- } else {
51
55
  }
52
56
 
53
57
  return (
@@ -12,34 +12,33 @@ export interface CompanyProps {
12
12
  to?: string;
13
13
  }
14
14
 
15
- export const Company = forwardRef<HTMLDivElement, CompanyProps>(
16
- ({ iconColor = 'primary', iconVisible = true, textVisible = true, to, size = 'medium' }, ref) => {
17
- if (to) {
18
- return (
19
- <Container size={size} textVisible={textVisible} ref={ref}>
20
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
21
- {/* @ts-ignore reusable link */}
22
- <Link to={to}>
23
- {iconVisible && (
24
- <Svg color={iconColor} size={size} viewBox="0 0 512 512">
25
- <path d="M512 165.4c0 127.9-70.05 235.3-175.3 270.1c-20.04 7.938-41.83 12.46-64.69 12.46c-64.9 0-125.2-36.51-155.7-94.47c-54.13 49.93-68.71 107-68.96 108.1C44.72 472.6 34.87 480 24.02 480c-1.844 0-3.727-.2187-5.602-.6562c-12.89-3.098-20.84-16.08-17.75-28.96c9.598-39.5 90.47-226.4 335.3-226.4C344.8 224 352 216.8 352 208S344.8 192 336 192C228.6 192 151 226.6 96.29 267.6c.1934-10.82 1.242-21.84 3.535-33.05c13.47-65.81 66.04-119 131.4-134.2c28.33-6.562 55.68-6.013 80.93-.0054c56 13.32 118.2-7.412 149.3-61.24c5.664-9.828 20.02-9.516 24.66 .8282C502.7 76.76 512 121.9 512 165.4z" />
26
- </Svg>
27
- )}
28
- {textVisible && <div>Takaro</div>}
29
- </Link>
30
- </Container>
31
- );
32
- }
33
-
15
+ export const Company = forwardRef<HTMLDivElement, CompanyProps>(function Company(
16
+ { iconColor = 'primary', iconVisible = true, textVisible = true, to, size = 'medium' },
17
+ ref,
18
+ ) {
19
+ if (to) {
34
20
  return (
35
21
  <Container size={size} textVisible={textVisible} ref={ref}>
36
- {iconVisible && (
37
- <Svg color={iconColor} size={size} viewBox="0 0 512 512">
38
- <path d="M512 165.4c0 127.9-70.05 235.3-175.3 270.1c-20.04 7.938-41.83 12.46-64.69 12.46c-64.9 0-125.2-36.51-155.7-94.47c-54.13 49.93-68.71 107-68.96 108.1C44.72 472.6 34.87 480 24.02 480c-1.844 0-3.727-.2187-5.602-.6562c-12.89-3.098-20.84-16.08-17.75-28.96c9.598-39.5 90.47-226.4 335.3-226.4C344.8 224 352 216.8 352 208S344.8 192 336 192C228.6 192 151 226.6 96.29 267.6c.1934-10.82 1.242-21.84 3.535-33.05c13.47-65.81 66.04-119 131.4-134.2c28.33-6.562 55.68-6.013 80.93-.0054c56 13.32 118.2-7.412 149.3-61.24c5.664-9.828 20.02-9.516 24.66 .8282C502.7 76.76 512 121.9 512 165.4z" />
39
- </Svg>
40
- )}
41
- {textVisible && <div>Takaro</div>}
22
+ <Link to={to}>
23
+ {iconVisible && (
24
+ <Svg color={iconColor} size={size} viewBox="0 0 512 512">
25
+ <path d="M512 165.4c0 127.9-70.05 235.3-175.3 270.1c-20.04 7.938-41.83 12.46-64.69 12.46c-64.9 0-125.2-36.51-155.7-94.47c-54.13 49.93-68.71 107-68.96 108.1C44.72 472.6 34.87 480 24.02 480c-1.844 0-3.727-.2187-5.602-.6562c-12.89-3.098-20.84-16.08-17.75-28.96c9.598-39.5 90.47-226.4 335.3-226.4C344.8 224 352 216.8 352 208S344.8 192 336 192C228.6 192 151 226.6 96.29 267.6c.1934-10.82 1.242-21.84 3.535-33.05c13.47-65.81 66.04-119 131.4-134.2c28.33-6.562 55.68-6.013 80.93-.0054c56 13.32 118.2-7.412 149.3-61.24c5.664-9.828 20.02-9.516 24.66 .8282C502.7 76.76 512 121.9 512 165.4z" />
26
+ </Svg>
27
+ )}
28
+ {textVisible && <div>Takaro</div>}
29
+ </Link>
42
30
  </Container>
43
31
  );
44
32
  }
45
- );
33
+
34
+ return (
35
+ <Container size={size} textVisible={textVisible} ref={ref}>
36
+ {iconVisible && (
37
+ <Svg color={iconColor} size={size} viewBox="0 0 512 512">
38
+ <path d="M512 165.4c0 127.9-70.05 235.3-175.3 270.1c-20.04 7.938-41.83 12.46-64.69 12.46c-64.9 0-125.2-36.51-155.7-94.47c-54.13 49.93-68.71 107-68.96 108.1C44.72 472.6 34.87 480 24.02 480c-1.844 0-3.727-.2187-5.602-.6562c-12.89-3.098-20.84-16.08-17.75-28.96c9.598-39.5 90.47-226.4 335.3-226.4C344.8 224 352 216.8 352 208S344.8 192 336 192C228.6 192 151 226.6 96.29 267.6c.1934-10.82 1.242-21.84 3.535-33.05c13.47-65.81 66.04-119 131.4-134.2c28.33-6.562 55.68-6.013 80.93-.0054c56 13.32 118.2-7.412 149.3-61.24c5.664-9.828 20.02-9.516 24.66 .8282C502.7 76.76 512 121.9 512 165.4z" />
39
+ </Svg>
40
+ )}
41
+ {textVisible && <div>Takaro</div>}
42
+ </Container>
43
+ );
44
+ });
@@ -10,7 +10,7 @@ export default {
10
10
  args: {
11
11
  header: 'Earn recurring revenue',
12
12
  description: 'Subscriptions allow you to grow recurring revenue by charging subscribers on a regular basis',
13
- actions: [<Button size="medium" icon={<AddIcon />} text="New project" />],
13
+ actions: [<Button key="new-project-button " size="medium" icon={<AddIcon />} text="New project" />],
14
14
  size: 'medium',
15
15
  },
16
16
  } as Meta<EmptyProps>;
@@ -1,6 +1,5 @@
1
1
  import { FC, ReactElement } from 'react';
2
2
  import { Size, styled } from '../../../styled';
3
- import { AiOutlineContainer as Icon } from 'react-icons/ai';
4
3
 
5
4
  const Container = styled.div<{ size: Size }>`
6
5
  display: flex;
@@ -56,7 +55,7 @@ const ActionContainer = styled.div`
56
55
  const Description = styled.p`
57
56
  max-width: 300px;
58
57
  margin: 0.5rem auto 1rem auto;
59
- color: ${({ theme }) => theme.colors.textAlt};
58
+ color: ${({ theme }) => theme.colors.text};
60
59
  text-align: center;
61
60
  `;
62
61
 
@@ -78,7 +77,6 @@ export interface EmptyProps {
78
77
  export const Empty: FC<EmptyProps> = ({ description = 'No Data', header, actions, size = 'medium' }) => {
79
78
  return (
80
79
  <Container size={size}>
81
- <Icon size={40} />
82
80
  <h2>{header}</h2>
83
81
  <Description>{description}</Description>
84
82
  <ActionContainer>{actions}</ActionContainer>
@@ -12,7 +12,7 @@ export interface PermissionsGuardProps {
12
12
 
13
13
  export const hasPermissionHelper = (
14
14
  userPermissions: PERMISSIONS[],
15
- requiredPermissions: RequiredPermissions
15
+ requiredPermissions: RequiredPermissions,
16
16
  ): boolean => {
17
17
  if (userPermissions.includes(PERMISSIONS.Root)) {
18
18
  return true;
@@ -20,7 +20,7 @@ export const hasPermissionHelper = (
20
20
  return requiredPermissions.some((permissionSet) =>
21
21
  Array.isArray(permissionSet)
22
22
  ? permissionSet.every((permission) => userPermissions.includes(permission))
23
- : userPermissions.includes(permissionSet as PERMISSIONS)
23
+ : userPermissions.includes(permissionSet as PERMISSIONS),
24
24
  );
25
25
  };
26
26
 
@@ -32,7 +32,10 @@ export interface CardProps extends HTMLProps<HTMLDivElement> {
32
32
  }
33
33
 
34
34
  // Forward ref and spread all props to the Container
35
- export const Card = forwardRef<HTMLDivElement, CardProps>(({ children, variant = 'default', ...props }, ref) => {
35
+ export const Card = forwardRef<HTMLDivElement, CardProps>(function Card(
36
+ { children, variant = 'default', ...props },
37
+ ref,
38
+ ) {
36
39
  const canClick = 'onClick' in props;
37
40
 
38
41
  // Extract the className prop, if present
@@ -3,7 +3,10 @@ interface IErrorOptions {
3
3
  }
4
4
 
5
5
  export class BaseError extends Error {
6
- constructor(public message: string, protected options?: Partial<IErrorOptions>) {
6
+ constructor(
7
+ public message: string,
8
+ protected options?: Partial<IErrorOptions>,
9
+ ) {
7
10
  super(message);
8
11
  // Ensure the name of this error is the same as the class name
9
12
  this.name = this.constructor.name;
@@ -11,7 +11,7 @@ export interface ErrorMessageMapping {
11
11
 
12
12
  export function getErrorUserMessage(
13
13
  apiError: AxiosError<any> | null,
14
- errorMessages: Partial<ErrorMessageMapping>
14
+ errorMessages: Partial<ErrorMessageMapping>,
15
15
  ): string | string[] | null {
16
16
  const defaultMesssage = 'An error occurred. Please try again later.';
17
17
 
@@ -33,6 +33,10 @@ export function getErrorUserMessage(
33
33
  if (err instanceof ResponseValidationError) {
34
34
  return err.parseValidationError();
35
35
  }
36
+ if (err instanceof BadRequestError) {
37
+ return err.message;
38
+ }
39
+
36
40
  if (err instanceof UniqueConstraintError) {
37
41
  if (err.message === 'Unique constraint violation') {
38
42
  const messageType = err.constructor.name as keyof ErrorMessageMapping;
@@ -58,13 +62,20 @@ export function transformError(apiError: AxiosError<any>) {
58
62
  return new UniqueConstraintError(error.message);
59
63
  }
60
64
 
65
+ if (error.code === 'BadRequestError') {
66
+ return new BadRequestError(error.message);
67
+ }
68
+
61
69
  if (error.code === 'ValidationError') {
62
70
  return new ResponseValidationError('Validation error', error.details);
63
71
  }
64
72
  }
65
73
 
66
74
  export class ResponseValidationError extends BaseError {
67
- constructor(message: string, public validationErrors: ValidationError[]) {
75
+ constructor(
76
+ message: string,
77
+ public validationErrors: ValidationError[],
78
+ ) {
68
79
  super(message, { meta: { validationErrors } });
69
80
  }
70
81
 
@@ -104,6 +115,12 @@ export class UniqueConstraintError extends BaseError {
104
115
  }
105
116
  }
106
117
 
118
+ export class BadRequestError extends BaseError {
119
+ constructor(message: string) {
120
+ super(message);
121
+ }
122
+ }
123
+
107
124
  export class ResponseClientError extends BaseError {}
108
125
  export class FailedLogOutError extends BaseError {}
109
126
  export class NotAuthorizedError extends BaseError {}
@@ -13,10 +13,10 @@ import { AlertVariants } from '../styled';
13
13
 
14
14
  const snackbarOptions: Partial<SnackbarProviderProps> = {
15
15
  anchorOrigin: {
16
- horizontal: 'center',
17
- vertical: 'top',
16
+ horizontal: 'right',
17
+ vertical: 'bottom',
18
18
  },
19
- autoHideDuration: 8000,
19
+ autoHideDuration: 4000,
20
20
  hideIconVariant: true,
21
21
  maxSnack: 3,
22
22
  preventDuplicate: true,
@@ -2,6 +2,7 @@ export const REGEXPR_STEAM_API_KEY = /\w{32}/;
2
2
  export const IPV4_REGEX = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/;
3
3
  export const IPV4_AND_PORT_REGEX =
4
4
  /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):([0-9]{1,5})\b/;
5
+ export const FQDN_REGEX = /(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$)/;
5
6
 
6
7
  export const IPV6_REGEX =
7
8
  /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/;
@@ -3,7 +3,9 @@ import { useRef } from 'react';
3
3
  export const useFocus = () => {
4
4
  const htmlElRef = useRef<HTMLElement>(null);
5
5
  const setFocus = () => {
6
- htmlElRef.current && htmlElRef.current.focus();
6
+ if (htmlElRef.current) {
7
+ htmlElRef.current.focus();
8
+ }
7
9
  };
8
10
 
9
11
  return [htmlElRef, setFocus];
@@ -10,7 +10,7 @@ export function useOnScreen(ref: React.RefObject<any>, rootMargin = '0px'): bool
10
10
  },
11
11
  {
12
12
  rootMargin,
13
- }
13
+ },
14
14
  );
15
15
  if (ref.current) {
16
16
  observer.observe(ref.current);
@@ -14,8 +14,8 @@ export interface PageOptions {
14
14
  }
15
15
 
16
16
  interface TableActionOptions {
17
- pageIndex: number;
18
- pageSize: number;
17
+ pageIndex?: number;
18
+ pageSize?: number;
19
19
  }
20
20
 
21
21
  export interface ColumnFilter {
@@ -23,10 +23,15 @@ export interface ColumnFilter {
23
23
  value: string[];
24
24
  }
25
25
 
26
- export function useTableActions<T>({ pageIndex, pageSize }: TableActionOptions = { pageIndex: 0, pageSize: 9 }) {
26
+ const DEFAULT_PAGE_SIZE = 10;
27
+ const DEFAULT_PAGE_INDEX = 0;
28
+
29
+ export function useTableActions<T>(
30
+ { pageIndex, pageSize }: TableActionOptions = { pageIndex: DEFAULT_PAGE_INDEX, pageSize: DEFAULT_PAGE_SIZE },
31
+ ) {
27
32
  const [paginationState, setPaginationState] = useState<PaginationState>({
28
- pageIndex,
29
- pageSize,
33
+ pageIndex: pageIndex ?? DEFAULT_PAGE_INDEX,
34
+ pageSize: pageSize ?? DEFAULT_PAGE_SIZE,
30
35
  });
31
36
  const [columnFiltersState, setColumnFiltersState] = useState<ColumnFilter[]>([]);
32
37
  const [columnSearchState, setColumnSearchState] = useState<ColumnFilter[]>([]);
@@ -49,7 +49,7 @@ export const GlobalStyle = createGlobalStyle<{ theme: ThemeType }>`
49
49
  overflow: hidden;
50
50
  }
51
51
 
52
- a, p, div, ul, li, h1, h2, h3, h4, h5, h6, header, footer, fieldset, legend, dl, dt{
52
+ a, p, div, ul, li, h1, h2, h3, h4, h5, h6, header, footer, fieldset, legend, dl, dt, dd{
53
53
  transition: background-color 0.2s linear;
54
54
  transition: box-shadow 0.125s linear;
55
55
  margin: 0;
@@ -94,6 +94,7 @@ export const GlobalStyle = createGlobalStyle<{ theme: ThemeType }>`
94
94
  }
95
95
 
96
96
  input, textarea {
97
+ appearance: none;
97
98
  box-sizing: border-box;
98
99
  margin: 0;
99
100
  outline: 0;
@@ -27,5 +27,5 @@ export const zIndex = types.reduce(
27
27
  acc[type] = baseValue + index;
28
28
  return acc;
29
29
  },
30
- {} as Record<ComponentType, number> // initialize obj with correct type
30
+ {} as Record<ComponentType, number>, // initialize obj with correct type
31
31
  );
@@ -18,6 +18,9 @@ const Providers: FC<PropsWithChildren<unknown>> = ({ children }) => {
18
18
  <ThemeProvider theme={lightTheme}>
19
19
  <SnackbarProvider>
20
20
  <GlobalStyle />
21
+ {/* I do not understand the following error but since this is a test file, doing a quick-fix :tm: */}
22
+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
23
+ {/* @ts-ignore - This is throwing a type error in the build but not in vscode... */}
21
24
  <RouterProvider router={router} />
22
25
  </SnackbarProvider>
23
26
  </ThemeProvider>
@@ -1,4 +0,0 @@
1
- export { Pagination } from './Pagination';
2
- export { Filter } from './Filter';
3
- export { ColumnHeader } from './ColumnHeader';
4
- export { ColumnVisibility } from './ColumnVisibility';