@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.
- package/package.json +5 -6
- 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
|
@@ -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>>((
|
|
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
|
-
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const handleClick = () => {
|
|
47
|
+
if (disabled) return;
|
|
48
|
+
setValue(value);
|
|
49
|
+
};
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
const isActive = value === selectedValue;
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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>((
|
|
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
|
|
43
|
+
const hasOnClick = children.props.onClick;
|
|
41
44
|
const mergedOnClick = () => {
|
|
42
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
{
|
|
37
|
-
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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.
|
|
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>((
|
|
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
|
package/src/errors/base.ts
CHANGED
|
@@ -3,7 +3,10 @@ interface IErrorOptions {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export class BaseError extends Error {
|
|
6
|
-
constructor(
|
|
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;
|
package/src/errors/errors.ts
CHANGED
|
@@ -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(
|
|
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: '
|
|
17
|
-
vertical: '
|
|
16
|
+
horizontal: 'right',
|
|
17
|
+
vertical: 'bottom',
|
|
18
18
|
},
|
|
19
|
-
autoHideDuration:
|
|
19
|
+
autoHideDuration: 4000,
|
|
20
20
|
hideIconVariant: true,
|
|
21
21
|
maxSnack: 3,
|
|
22
22
|
preventDuplicate: true,
|
package/src/helpers/regexprs.ts
CHANGED
|
@@ -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]))/;
|
package/src/hooks/useFocus.tsx
CHANGED
|
@@ -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
|
-
|
|
6
|
+
if (htmlElRef.current) {
|
|
7
|
+
htmlElRef.current.focus();
|
|
8
|
+
}
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
return [htmlElRef, setFocus];
|
package/src/hooks/useOnScreen.ts
CHANGED
|
@@ -14,8 +14,8 @@ export interface PageOptions {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
interface TableActionOptions {
|
|
17
|
-
pageIndex
|
|
18
|
-
pageSize
|
|
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
|
-
|
|
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;
|
package/src/styled/zIndex.ts
CHANGED
package/src/test/testUtils.tsx
CHANGED
|
@@ -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>
|