@gobolt/genesis 0.3.21 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Button/components/Button/Button.d.ts +16 -0
- package/dist/components/Button/components/Button/Button.js +13 -0
- package/dist/components/Button/components/Button/styles.d.ts +1 -0
- package/dist/components/Button/components/Button/styles.js +118 -0
- package/dist/components/Button/constants/index.d.ts +163 -0
- package/dist/components/Button/constants/index.js +89 -0
- package/dist/components/Table/Table/Table.d.ts +51 -0
- package/dist/components/Table/Table/Table.js +14 -0
- package/dist/components/Table/Table/TableControls/CustomPagination.d.ts +13 -0
- package/dist/components/Table/Table/TableControls/CustomPagination.js +158 -0
- package/dist/components/Table/Table/TableControls/PaginationNumber.d.ts +7 -0
- package/dist/components/Table/Table/TableControls/PaginationNumber.js +30 -0
- package/dist/components/Table/Table/styles.d.ts +14 -0
- package/dist/components/Table/Table/styles.js +64 -0
- package/dist/components/Table/Table/useTable.d.ts +26 -0
- package/dist/components/Table/Table/useTable.js +141 -0
- package/dist/components/Table/Typography/Typography.d.ts +17 -0
- package/dist/components/Table/Typography/Typography.js +16 -0
- package/dist/components/Table/Typography/index.d.ts +2 -0
- package/dist/components/Table/Typography/index.js +1 -0
- package/dist/components/Table/Typography/styles.d.ts +3 -0
- package/dist/components/Table/Typography/styles.js +54 -0
- package/dist/components/TableWithControls/components/Badge/Badge.d.ts +16 -0
- package/dist/components/TableWithControls/components/Badge/Badge.js +28 -0
- package/dist/components/TableWithControls/components/Badge/index.d.ts +2 -0
- package/dist/components/TableWithControls/components/Badge/index.js +1 -0
- package/dist/components/TableWithControls/components/Badge/styles.d.ts +4 -0
- package/dist/components/TableWithControls/components/Badge/styles.js +46 -0
- package/dist/components/TableWithControls/components/Button/Button.d.ts +16 -0
- package/dist/components/TableWithControls/components/Button/Button.js +13 -0
- package/dist/components/TableWithControls/components/Button/IconButton.d.ts +8 -0
- package/dist/components/TableWithControls/components/Button/IconButton.js +9 -0
- package/dist/components/TableWithControls/components/Button/icon-button-styles.d.ts +1 -0
- package/dist/components/TableWithControls/components/Button/icon-button-styles.js +76 -0
- package/dist/components/TableWithControls/components/Button/index.d.ts +4 -0
- package/dist/components/TableWithControls/components/Button/index.js +2 -0
- package/dist/components/TableWithControls/components/Button/styles.d.ts +1 -0
- package/dist/components/TableWithControls/components/Button/styles.js +118 -0
- package/dist/components/TableWithControls/components/Input/Input.d.ts +13 -0
- package/dist/components/TableWithControls/components/Input/Input.js +34 -0
- package/dist/components/TableWithControls/components/Input/index.d.ts +2 -0
- package/dist/components/TableWithControls/components/Input/index.js +1 -0
- package/dist/components/TableWithControls/components/Input/styles.d.ts +1 -0
- package/dist/components/TableWithControls/components/Input/styles.js +180 -0
- package/dist/components/TableWithControls/components/Select/Select.d.ts +26 -0
- package/dist/components/TableWithControls/components/Select/Select.js +175 -0
- package/dist/components/TableWithControls/components/Select/SelectTrigger.d.ts +23 -0
- package/dist/components/TableWithControls/components/Select/SelectTrigger.js +103 -0
- package/dist/components/TableWithControls/components/Select/index.d.ts +2 -0
- package/dist/components/TableWithControls/components/Select/index.js +1 -0
- package/dist/components/TableWithControls/components/Table/Table.d.ts +51 -0
- package/dist/components/TableWithControls/components/Table/Table.js +14 -0
- package/dist/components/TableWithControls/components/Table/TableControls/CustomPagination.d.ts +13 -0
- package/dist/components/TableWithControls/components/Table/TableControls/CustomPagination.js +158 -0
- package/dist/components/TableWithControls/components/Table/TableControls/PaginationNumber.d.ts +7 -0
- package/dist/components/TableWithControls/components/Table/TableControls/PaginationNumber.js +30 -0
- package/dist/components/TableWithControls/components/Table/TableControls/PrimaryTableControlsRow.d.ts +18 -0
- package/dist/components/TableWithControls/components/Table/TableControls/PrimaryTableControlsRow.js +77 -0
- package/dist/components/TableWithControls/components/Table/TableControls/SecondaryTableControlsRow.d.ts +11 -0
- package/dist/components/TableWithControls/components/Table/TableControls/SecondaryTableControlsRow.js +43 -0
- package/dist/components/TableWithControls/components/Table/TableControls/TableControls.d.ts +14 -0
- package/dist/components/TableWithControls/components/Table/TableControls/TableControls.js +13 -0
- package/dist/components/TableWithControls/components/Table/TableControls/index.d.ts +2 -0
- package/dist/components/TableWithControls/components/Table/TableControls/index.js +1 -0
- package/dist/components/TableWithControls/components/Table/TablePagination.d.ts +13 -0
- package/dist/components/TableWithControls/components/Table/TablePagination.js +11 -0
- package/dist/components/TableWithControls/components/Table/__mocks__/table-mocks.d.ts +20 -0
- package/dist/components/TableWithControls/components/Table/__mocks__/table-mocks.js +301 -0
- package/dist/components/TableWithControls/components/Table/index.d.ts +6 -0
- package/dist/components/TableWithControls/components/Table/index.js +3 -0
- package/dist/components/TableWithControls/components/Table/styles.d.ts +14 -0
- package/dist/components/TableWithControls/components/Table/styles.js +64 -0
- package/dist/components/TableWithControls/components/Table/useTable.d.ts +26 -0
- package/dist/components/TableWithControls/components/Table/useTable.js +141 -0
- package/dist/components/TableWithControls/components/TableWithControls/TableWithControls.d.ts +12 -0
- package/dist/components/TableWithControls/components/TableWithControls/TableWithControls.js +20 -0
- package/dist/components/TableWithControls/components/TableWithControls/useTableWithControls.d.ts +29 -0
- package/dist/components/TableWithControls/components/TableWithControls/useTableWithControls.js +136 -0
- package/dist/components/TableWithControls/components/Tooltip/Tooltip.d.ts +7 -0
- package/dist/components/TableWithControls/components/Tooltip/Tooltip.js +8 -0
- package/dist/components/TableWithControls/components/Tooltip/index.d.ts +2 -0
- package/dist/components/TableWithControls/components/Tooltip/index.js +1 -0
- package/dist/components/TableWithControls/components/Tooltip/styles.d.ts +6 -0
- package/dist/components/TableWithControls/components/Tooltip/styles.js +26 -0
- package/dist/components/TableWithControls/components/Typography/Typography.d.ts +17 -0
- package/dist/components/TableWithControls/components/Typography/Typography.js +16 -0
- package/dist/components/TableWithControls/components/Typography/index.d.ts +2 -0
- package/dist/components/TableWithControls/components/Typography/index.js +1 -0
- package/dist/components/TableWithControls/components/Typography/styles.d.ts +3 -0
- package/dist/components/TableWithControls/components/Typography/styles.js +54 -0
- package/dist/components/TableWithControls/components/UtilityButton/UtilityButton.d.ts +5 -0
- package/dist/components/TableWithControls/components/UtilityButton/UtilityButton.js +9 -0
- package/dist/components/TableWithControls/components/UtilityButton/index.d.ts +2 -0
- package/dist/components/TableWithControls/components/UtilityButton/index.js +1 -0
- package/dist/components/TableWithControls/components/shared/DropdownChevron.d.ts +2 -0
- package/dist/components/TableWithControls/components/shared/DropdownChevron.js +7 -0
- package/dist/components/TableWithControls/constants/index.d.ts +163 -0
- package/dist/components/TableWithControls/constants/index.js +89 -0
- package/dist/components/TableWithControls/types/events.d.ts +22 -0
- package/dist/components/TableWithControls/types/events.js +1 -0
- package/dist/components/TableWithControls/utils/icon-util.d.ts +3 -0
- package/dist/components/TableWithControls/utils/icon-util.js +116 -0
- package/dist/components/UtilityButton/components/Button/Button.d.ts +16 -0
- package/dist/components/UtilityButton/components/Button/Button.js +13 -0
- package/dist/components/UtilityButton/components/Button/IconButton.d.ts +8 -0
- package/dist/components/UtilityButton/components/Button/IconButton.js +9 -0
- package/dist/components/UtilityButton/components/Button/icon-button-styles.d.ts +1 -0
- package/dist/components/UtilityButton/components/Button/icon-button-styles.js +76 -0
- package/dist/components/UtilityButton/components/Button/index.d.ts +4 -0
- package/dist/components/UtilityButton/components/Button/index.js +2 -0
- package/dist/components/UtilityButton/components/Button/styles.d.ts +1 -0
- package/dist/components/UtilityButton/components/Button/styles.js +118 -0
- package/dist/components/UtilityButton/components/UtilityButton/UtilityButton.d.ts +5 -0
- package/dist/components/UtilityButton/components/UtilityButton/UtilityButton.js +9 -0
- package/dist/components/UtilityButton/constants/index.d.ts +163 -0
- package/dist/components/UtilityButton/constants/index.js +89 -0
- package/dist/components/index.d.ts +6 -6
- package/dist/components/index.js +7 -0
- package/dist/components/index.ts +6 -6
- package/dist/constants/index.js +14 -14
- package/dist/index.d.ts +9 -9
- package/dist/index.js +10 -0
- package/dist/index.ts +9 -9
- package/package.json +1 -1
- package/dist/components/Button/Button.tsx +0 -59
- package/dist/components/Table/Table.tsx +0 -112
- package/dist/components/Table/useTable.ts +0 -194
- package/dist/components/TableWithControls/TableWithControls.tsx +0 -54
- package/dist/components/TableWithControls/useTableWithControls.tsx +0 -161
- package/dist/components/UtilityButton/UtilityButton.tsx +0 -36
- package/dist/constants/index.ts +0 -98
- package/dist/styles/theme/genesis-theme.types.ts +0 -297
- package/dist/utils/styled.ts +0 -52
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { MouseEvent } from "react";
|
|
2
|
+
import type { ButtonProps as AntButtonProperties } from "antd/es/button";
|
|
3
|
+
import { STATE } from "../../constants";
|
|
4
|
+
type ButtonThemeType = "primary" | "secondary" | "tertiary" | "destructive" | "utility" | "icon";
|
|
5
|
+
export interface ButtonProps extends Omit<AntButtonProperties, "type" | "size"> {
|
|
6
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
themeType?: ButtonThemeType;
|
|
9
|
+
state?: keyof typeof STATE;
|
|
10
|
+
isIconButton?: boolean;
|
|
11
|
+
size?: "small" | "normal" | "large";
|
|
12
|
+
isSelected?: boolean;
|
|
13
|
+
icon?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
declare const Button: React.FC<ButtonProps>;
|
|
16
|
+
export default Button;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as S from "./styles";
|
|
3
|
+
const getState = (state, isSelected) => {
|
|
4
|
+
if (isSelected) {
|
|
5
|
+
return "selected";
|
|
6
|
+
}
|
|
7
|
+
return state === "active" || state === "disabled" ? state : "active";
|
|
8
|
+
};
|
|
9
|
+
const Button = ({ children, onClick, themeType = "primary", state = "active", isIconButton = false, size = "normal", isSelected, ...rest }) => {
|
|
10
|
+
const buttonState = getState(state, isSelected);
|
|
11
|
+
return (_jsx(S.Button, { onClick: onClick, "$themeType": themeType, "$state": buttonState, disabled: state === "disabled" || rest.disabled, "$isIconButton": isIconButton, size: size, ...rest, children: children }));
|
|
12
|
+
};
|
|
13
|
+
export default Button;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Button: any;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import styled from "@gobolt/genesis/utils/styled";
|
|
2
|
+
import { Button as AntButton } from "antd";
|
|
3
|
+
const getPadding = (size, $themeType, sizing, $isIconButton) => {
|
|
4
|
+
if ($isIconButton && (size === "normal" || size === "large")) {
|
|
5
|
+
return `${sizing.Size2}px ${sizing.Size2}px`;
|
|
6
|
+
}
|
|
7
|
+
if ($isIconButton && size === "small") {
|
|
8
|
+
return `${sizing.Size1}px ${sizing.Size1}px`;
|
|
9
|
+
}
|
|
10
|
+
// utility button padding is different from the main button
|
|
11
|
+
if ($themeType === "utility" && size === "small") {
|
|
12
|
+
return `${sizing.Size1_5}px ${sizing.Size2}px`;
|
|
13
|
+
}
|
|
14
|
+
if ($themeType === "utility" && (size === "normal" || size === "large")) {
|
|
15
|
+
return `${sizing.Size2_5}px ${sizing.Size3}px`;
|
|
16
|
+
}
|
|
17
|
+
if (size === "small") {
|
|
18
|
+
return `${sizing.Size1_5}px ${sizing.Size4}px`;
|
|
19
|
+
}
|
|
20
|
+
if (size === "normal" || size === "large") {
|
|
21
|
+
return `${sizing.Size2_5}px ${sizing.Size6}px`;
|
|
22
|
+
}
|
|
23
|
+
return `${sizing.Size2}px ${sizing.Size2}px`;
|
|
24
|
+
};
|
|
25
|
+
const getHeight = (size) => {
|
|
26
|
+
if (size === "normal" || size === "large") {
|
|
27
|
+
return `40px`;
|
|
28
|
+
}
|
|
29
|
+
if (size === "small") {
|
|
30
|
+
return `32px`;
|
|
31
|
+
}
|
|
32
|
+
return `40px`;
|
|
33
|
+
};
|
|
34
|
+
const getWidth = (size, $isIconButton) => {
|
|
35
|
+
if (!$isIconButton) {
|
|
36
|
+
return `auto`;
|
|
37
|
+
}
|
|
38
|
+
if (size === "normal" || size === "large") {
|
|
39
|
+
return `40px`;
|
|
40
|
+
}
|
|
41
|
+
if (size === "small") {
|
|
42
|
+
return `32px`;
|
|
43
|
+
}
|
|
44
|
+
return `40px`;
|
|
45
|
+
};
|
|
46
|
+
const getVariant = ({ colors, sizing, borderRadius, components }, $themeType, $state, size, $isIconButton) => {
|
|
47
|
+
const backgroundColor = colors[$themeType][$state].backgroundColor;
|
|
48
|
+
return `
|
|
49
|
+
&.ant-btn {
|
|
50
|
+
|
|
51
|
+
color: ${colors[$themeType][$state].color};
|
|
52
|
+
font-size: ${sizing.Size4}px;
|
|
53
|
+
line-height: ${sizing.Size6}px;
|
|
54
|
+
letter-spacing: 0;
|
|
55
|
+
font-weight: 400;
|
|
56
|
+
border-width: 1px;
|
|
57
|
+
line-height: 1 !important;
|
|
58
|
+
|
|
59
|
+
width: ${getWidth(size, $isIconButton)}; !important;
|
|
60
|
+
height: ${getHeight(size)}; !important;
|
|
61
|
+
|
|
62
|
+
background-color: ${colors[$themeType][$state].backgroundColor};
|
|
63
|
+
padding: ${getPadding(size, $themeType, sizing, $isIconButton)};
|
|
64
|
+
|
|
65
|
+
box-shadow: ${$themeType === "utility" ? "0px 1px 2px 0px #00000026" : "none"};
|
|
66
|
+
|
|
67
|
+
border-radius: ${borderRadius.BorderRadiusMd}px;
|
|
68
|
+
gap: ${components.button.gap}px;
|
|
69
|
+
border-style: solid;
|
|
70
|
+
border-color: ${colors[$themeType][$state].borderColor};
|
|
71
|
+
|
|
72
|
+
transition: all 0.2s ease-in-out;
|
|
73
|
+
|
|
74
|
+
&:hover {
|
|
75
|
+
color: ${colors[$themeType].hover.color};
|
|
76
|
+
background-color: ${colors[$themeType].hover.backgroundColor};
|
|
77
|
+
border-color: ${colors[$themeType].hover.borderColor};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&:active {
|
|
81
|
+
color: ${colors[$themeType].pressed.color};
|
|
82
|
+
background-color: ${colors[$themeType].pressed.backgroundColor};
|
|
83
|
+
border-color: ${colors[$themeType].pressed.borderColor};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:focus-visible {
|
|
87
|
+
outline: none;
|
|
88
|
+
color: ${colors[$themeType].focussed.color};
|
|
89
|
+
background-color: ${colors[$themeType].focussed.backgroundColor};
|
|
90
|
+
box-shadow: 0 0 0 1px #fff, 0 0 0 4px ${colors[$themeType].focussed.ringColor};
|
|
91
|
+
border-radius: ${borderRadius.BorderRadiusMd}px;
|
|
92
|
+
border-color: ${colors[$themeType].focussed.borderColor};
|
|
93
|
+
transition: box-shadow 0.2s ease-in-out;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&:disabled {
|
|
97
|
+
color: ${colors[$themeType].disabled.color};
|
|
98
|
+
background-color: ${colors[$themeType].disabled.backgroundColor};
|
|
99
|
+
border-color: ${colors[$themeType].disabled.borderColor};
|
|
100
|
+
cursor: not-allowed;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
`;
|
|
106
|
+
};
|
|
107
|
+
const getGenesisButtonClass = (theme, $themeType, $state, $isIconButton, size) => `
|
|
108
|
+
&.ant-btn {
|
|
109
|
+
font-family: 'Inter', sans-serif;
|
|
110
|
+
|
|
111
|
+
${getVariant(theme, $themeType, $state, size, $isIconButton)}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
export const Button = styled(AntButton) `
|
|
115
|
+
${({ theme, $themeType, $state, children, $isIconButton, size }) => {
|
|
116
|
+
return getGenesisButtonClass(theme, $themeType, $state, $isIconButton, size);
|
|
117
|
+
}}
|
|
118
|
+
`;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export declare const TYPE: {
|
|
2
|
+
primary: string;
|
|
3
|
+
secondary: string;
|
|
4
|
+
tertiary: string;
|
|
5
|
+
destructive: string;
|
|
6
|
+
utility: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const BREAKPOINTS: {
|
|
10
|
+
wide: string;
|
|
11
|
+
medium: string;
|
|
12
|
+
narrow: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const STATE: {
|
|
15
|
+
active: string;
|
|
16
|
+
hover: string;
|
|
17
|
+
pressed: string;
|
|
18
|
+
focussed: string;
|
|
19
|
+
disabled: string;
|
|
20
|
+
error: string;
|
|
21
|
+
success: string;
|
|
22
|
+
warning: string;
|
|
23
|
+
progress: string;
|
|
24
|
+
info: string;
|
|
25
|
+
filled: string;
|
|
26
|
+
generic: string;
|
|
27
|
+
removed: string;
|
|
28
|
+
hollow: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const TYPOGRAPHY_VARIANT: {
|
|
31
|
+
display1: string;
|
|
32
|
+
display2: string;
|
|
33
|
+
display3: string;
|
|
34
|
+
heading1: string;
|
|
35
|
+
heading2: string;
|
|
36
|
+
heading3: string;
|
|
37
|
+
subHeading1: string;
|
|
38
|
+
subHeading2: string;
|
|
39
|
+
subHeading3: string;
|
|
40
|
+
body1: string;
|
|
41
|
+
body2: string;
|
|
42
|
+
body3: string;
|
|
43
|
+
body4: string;
|
|
44
|
+
body5: string;
|
|
45
|
+
message: string;
|
|
46
|
+
overline1: string;
|
|
47
|
+
overline2: string;
|
|
48
|
+
overline3: string;
|
|
49
|
+
label1: string;
|
|
50
|
+
label2: string;
|
|
51
|
+
label3: string;
|
|
52
|
+
link1: string;
|
|
53
|
+
link2: string;
|
|
54
|
+
link3: string;
|
|
55
|
+
digits1: string;
|
|
56
|
+
digits2: string;
|
|
57
|
+
digits3: string;
|
|
58
|
+
};
|
|
59
|
+
export declare const BUTTON_VARIANT: {
|
|
60
|
+
primary: string;
|
|
61
|
+
secondary: string;
|
|
62
|
+
tertiary: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const SIZE: {
|
|
65
|
+
small: string;
|
|
66
|
+
medium: string;
|
|
67
|
+
large: string;
|
|
68
|
+
standard: string;
|
|
69
|
+
};
|
|
70
|
+
export declare const BADGE: {
|
|
71
|
+
appointment: string;
|
|
72
|
+
asn: string;
|
|
73
|
+
inventory: string;
|
|
74
|
+
parcel: string;
|
|
75
|
+
product: string;
|
|
76
|
+
route: string;
|
|
77
|
+
shipment: string;
|
|
78
|
+
shoppingCart: string;
|
|
79
|
+
system: string;
|
|
80
|
+
};
|
|
81
|
+
declare const _default: {
|
|
82
|
+
TYPE: {
|
|
83
|
+
primary: string;
|
|
84
|
+
secondary: string;
|
|
85
|
+
tertiary: string;
|
|
86
|
+
destructive: string;
|
|
87
|
+
utility: string;
|
|
88
|
+
icon: string;
|
|
89
|
+
};
|
|
90
|
+
BREAKPOINTS: {
|
|
91
|
+
wide: string;
|
|
92
|
+
medium: string;
|
|
93
|
+
narrow: string;
|
|
94
|
+
};
|
|
95
|
+
STATE: {
|
|
96
|
+
active: string;
|
|
97
|
+
hover: string;
|
|
98
|
+
pressed: string;
|
|
99
|
+
focussed: string;
|
|
100
|
+
disabled: string;
|
|
101
|
+
error: string;
|
|
102
|
+
success: string;
|
|
103
|
+
warning: string;
|
|
104
|
+
progress: string;
|
|
105
|
+
info: string;
|
|
106
|
+
filled: string;
|
|
107
|
+
generic: string;
|
|
108
|
+
removed: string;
|
|
109
|
+
hollow: string;
|
|
110
|
+
};
|
|
111
|
+
TYPOGRAPHY_VARIANT: {
|
|
112
|
+
display1: string;
|
|
113
|
+
display2: string;
|
|
114
|
+
display3: string;
|
|
115
|
+
heading1: string;
|
|
116
|
+
heading2: string;
|
|
117
|
+
heading3: string;
|
|
118
|
+
subHeading1: string;
|
|
119
|
+
subHeading2: string;
|
|
120
|
+
subHeading3: string;
|
|
121
|
+
body1: string;
|
|
122
|
+
body2: string;
|
|
123
|
+
body3: string;
|
|
124
|
+
body4: string;
|
|
125
|
+
body5: string;
|
|
126
|
+
message: string;
|
|
127
|
+
overline1: string;
|
|
128
|
+
overline2: string;
|
|
129
|
+
overline3: string;
|
|
130
|
+
label1: string;
|
|
131
|
+
label2: string;
|
|
132
|
+
label3: string;
|
|
133
|
+
link1: string;
|
|
134
|
+
link2: string;
|
|
135
|
+
link3: string;
|
|
136
|
+
digits1: string;
|
|
137
|
+
digits2: string;
|
|
138
|
+
digits3: string;
|
|
139
|
+
};
|
|
140
|
+
BUTTON_VARIANT: {
|
|
141
|
+
primary: string;
|
|
142
|
+
secondary: string;
|
|
143
|
+
tertiary: string;
|
|
144
|
+
};
|
|
145
|
+
SIZE: {
|
|
146
|
+
small: string;
|
|
147
|
+
medium: string;
|
|
148
|
+
large: string;
|
|
149
|
+
standard: string;
|
|
150
|
+
};
|
|
151
|
+
BADGE: {
|
|
152
|
+
appointment: string;
|
|
153
|
+
asn: string;
|
|
154
|
+
inventory: string;
|
|
155
|
+
parcel: string;
|
|
156
|
+
product: string;
|
|
157
|
+
route: string;
|
|
158
|
+
shipment: string;
|
|
159
|
+
shoppingCart: string;
|
|
160
|
+
system: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export default _default;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export const TYPE = {
|
|
2
|
+
primary: "primary",
|
|
3
|
+
secondary: "secondary",
|
|
4
|
+
tertiary: "tertiary",
|
|
5
|
+
destructive: "destructive",
|
|
6
|
+
utility: "utility",
|
|
7
|
+
icon: "icon",
|
|
8
|
+
};
|
|
9
|
+
export const BREAKPOINTS = {
|
|
10
|
+
wide: "wide",
|
|
11
|
+
medium: "medium",
|
|
12
|
+
narrow: "narrow",
|
|
13
|
+
};
|
|
14
|
+
export const STATE = {
|
|
15
|
+
active: "active",
|
|
16
|
+
hover: "hover",
|
|
17
|
+
pressed: "pressed",
|
|
18
|
+
focussed: "focus",
|
|
19
|
+
disabled: "disabled",
|
|
20
|
+
error: "error",
|
|
21
|
+
success: "success",
|
|
22
|
+
warning: "warning",
|
|
23
|
+
progress: "progress",
|
|
24
|
+
info: "info",
|
|
25
|
+
filled: "filled",
|
|
26
|
+
generic: "generic",
|
|
27
|
+
removed: "removed",
|
|
28
|
+
hollow: "hollow",
|
|
29
|
+
};
|
|
30
|
+
export const TYPOGRAPHY_VARIANT = {
|
|
31
|
+
display1: "display1",
|
|
32
|
+
display2: "display2",
|
|
33
|
+
display3: "display3",
|
|
34
|
+
heading1: "heading1",
|
|
35
|
+
heading2: "heading2",
|
|
36
|
+
heading3: "heading3",
|
|
37
|
+
subHeading1: "subHeading1",
|
|
38
|
+
subHeading2: "subHeading2",
|
|
39
|
+
subHeading3: "subHeading3",
|
|
40
|
+
body1: "body1",
|
|
41
|
+
body2: "body2",
|
|
42
|
+
body3: "body3",
|
|
43
|
+
body4: "body4",
|
|
44
|
+
body5: "body5",
|
|
45
|
+
message: "message",
|
|
46
|
+
overline1: "overline1",
|
|
47
|
+
overline2: "overline2",
|
|
48
|
+
overline3: "overline3",
|
|
49
|
+
label1: "label1",
|
|
50
|
+
label2: "label2",
|
|
51
|
+
label3: "label3",
|
|
52
|
+
link1: "link1",
|
|
53
|
+
link2: "link2",
|
|
54
|
+
link3: "link3",
|
|
55
|
+
digits1: "digits1",
|
|
56
|
+
digits2: "digits2",
|
|
57
|
+
digits3: "digits3",
|
|
58
|
+
};
|
|
59
|
+
export const BUTTON_VARIANT = {
|
|
60
|
+
primary: "primary",
|
|
61
|
+
secondary: "secondary",
|
|
62
|
+
tertiary: "tertiary",
|
|
63
|
+
};
|
|
64
|
+
export const SIZE = {
|
|
65
|
+
small: "small",
|
|
66
|
+
medium: "medium",
|
|
67
|
+
large: "large",
|
|
68
|
+
standard: "standard",
|
|
69
|
+
};
|
|
70
|
+
export const BADGE = {
|
|
71
|
+
appointment: "appointment",
|
|
72
|
+
asn: "asn",
|
|
73
|
+
inventory: "inventory",
|
|
74
|
+
parcel: "parcel",
|
|
75
|
+
product: "product",
|
|
76
|
+
route: "route",
|
|
77
|
+
shipment: "shipment",
|
|
78
|
+
shoppingCart: "shopping cart",
|
|
79
|
+
system: "system",
|
|
80
|
+
};
|
|
81
|
+
export default {
|
|
82
|
+
TYPE,
|
|
83
|
+
BREAKPOINTS,
|
|
84
|
+
STATE,
|
|
85
|
+
TYPOGRAPHY_VARIANT,
|
|
86
|
+
BUTTON_VARIANT,
|
|
87
|
+
SIZE,
|
|
88
|
+
BADGE,
|
|
89
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ColumnType } from "antd/es/table";
|
|
3
|
+
import type { TablePaginationConfig } from "antd/es/table";
|
|
4
|
+
import { PaginationStyle } from "./TableControls/CustomPagination";
|
|
5
|
+
import type { ActionEvent } from "@/lib/types";
|
|
6
|
+
export type Change = (actionEvent: ActionEvent) => void;
|
|
7
|
+
export type SelectionType = "checkbox" | "radio";
|
|
8
|
+
export interface TableProps<T extends Record<string, any>> {
|
|
9
|
+
dataSource: T[];
|
|
10
|
+
columns: ColumnType<T>[];
|
|
11
|
+
rowKey?: keyof T | ((record: T) => React.Key);
|
|
12
|
+
size?: "small" | "middle" | "large";
|
|
13
|
+
rowSelection?: {
|
|
14
|
+
type?: SelectionType;
|
|
15
|
+
selectedRowKeys?: React.Key[];
|
|
16
|
+
onChange?: (selectedRowKeys: React.Key[], selectedRows: T[]) => void;
|
|
17
|
+
getCheckboxProps?: (record: T) => {
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
name?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
onChange?: (pagination: TablePaginationType, filters: Record<string, React.Key[]>, sorter: SorterResult<T> | SorterResult<T>[]) => void;
|
|
23
|
+
loading?: boolean;
|
|
24
|
+
pagination?: (TablePaginationConfig & {
|
|
25
|
+
paginationStyle?: PaginationStyle;
|
|
26
|
+
}) | false;
|
|
27
|
+
scroll?: {
|
|
28
|
+
x?: number | string;
|
|
29
|
+
y?: number | string;
|
|
30
|
+
};
|
|
31
|
+
bordered?: boolean;
|
|
32
|
+
locale?: {
|
|
33
|
+
emptyText?: React.ReactNode;
|
|
34
|
+
};
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
isMainContentCell?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export type TablePaginationType = {
|
|
39
|
+
pageSize?: number;
|
|
40
|
+
current?: number;
|
|
41
|
+
total?: number;
|
|
42
|
+
onChange?: (page: number, pageSize: number) => void;
|
|
43
|
+
};
|
|
44
|
+
export type SorterResult<T> = {
|
|
45
|
+
column?: ColumnType<T>;
|
|
46
|
+
order?: "ascend" | "descend" | null;
|
|
47
|
+
field?: keyof T | string | React.Key | readonly React.Key[];
|
|
48
|
+
columnKey?: React.Key;
|
|
49
|
+
};
|
|
50
|
+
declare function Table<T extends Record<string, any>>({ columns, dataSource, rowKey, size, onChange, rowSelection, pagination, isMainContentCell, ...rest }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export default Table;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as S from "./styles";
|
|
3
|
+
import CustomPagination, { PaginationStyle, } from "./TableControls/CustomPagination";
|
|
4
|
+
function Table({ columns, dataSource, rowKey = "id", size = "small", onChange, rowSelection, pagination, isMainContentCell = false, ...rest }) {
|
|
5
|
+
const paginationConfig = pagination === false
|
|
6
|
+
? false
|
|
7
|
+
: {
|
|
8
|
+
...pagination,
|
|
9
|
+
itemRender: undefined, // Clear any existing itemRender to avoid conflicts
|
|
10
|
+
render: (properties) => (_jsx(CustomPagination, { ...properties, paginationStyle: pagination?.paginationStyle || PaginationStyle.SIMPLE })),
|
|
11
|
+
};
|
|
12
|
+
return (_jsx(S.Table, { "data-testid": "Table", dataSource: dataSource, columns: columns, rowKey: rowKey, locale: { emptyText: "No Data" }, size: size, onChange: onChange, rowSelection: rowSelection, pagination: paginationConfig, "$isMainContentCell": isMainContentCell, ...rest }));
|
|
13
|
+
}
|
|
14
|
+
export default Table;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PaginationProps } from "antd";
|
|
3
|
+
export declare enum PaginationStyle {
|
|
4
|
+
SIMPLE = "simple",// Shows just 1-5
|
|
5
|
+
TRUNCATED = "truncated",// Shows 1-5...20
|
|
6
|
+
CENTERED = "centered",// Shows 1...4-5-6-7-8...20
|
|
7
|
+
END_FOCUSED = "endFocused"
|
|
8
|
+
}
|
|
9
|
+
interface CustomPaginationProperties extends Omit<PaginationProps, "itemRender"> {
|
|
10
|
+
paginationStyle?: PaginationStyle;
|
|
11
|
+
}
|
|
12
|
+
declare const CustomPagination: React.FC<CustomPaginationProperties>;
|
|
13
|
+
export default CustomPagination;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { PaginationNumber } from "./PaginationNumber";
|
|
4
|
+
export var PaginationStyle;
|
|
5
|
+
(function (PaginationStyle) {
|
|
6
|
+
PaginationStyle["SIMPLE"] = "simple";
|
|
7
|
+
PaginationStyle["TRUNCATED"] = "truncated";
|
|
8
|
+
PaginationStyle["CENTERED"] = "centered";
|
|
9
|
+
PaginationStyle["END_FOCUSED"] = "endFocused";
|
|
10
|
+
})(PaginationStyle || (PaginationStyle = {}));
|
|
11
|
+
const PaginationContainer = styled.div `
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: flex-start;
|
|
15
|
+
margin: 0;
|
|
16
|
+
gap: 0 0;
|
|
17
|
+
`;
|
|
18
|
+
const ChevronButton = styled.button `
|
|
19
|
+
background: transparent;
|
|
20
|
+
border: none;
|
|
21
|
+
color: ${({ theme, disabled }) => disabled ? theme.colors.onsurface["copy-light"] || "#B0B0B0" : "#222"};
|
|
22
|
+
font-size: 32px;
|
|
23
|
+
height: 40px;
|
|
24
|
+
border-radius: 10px;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
cursor: ${({ disabled }) => (disabled ? "not-allowed" : "pointer")};
|
|
29
|
+
margin-right: ${({ $right }) => ($right ? "0" : "8px")};
|
|
30
|
+
margin-left: ${({ $right }) => ($right ? "8px" : "0")};
|
|
31
|
+
transition: color 0.2s;
|
|
32
|
+
`;
|
|
33
|
+
const ChevronIcon = ({ left = false }) => (_jsx("svg", { width: "28", height: "28", viewBox: "0 0 28 28", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: left ? "M17.5 21L11.5 14L17.5 7" : "M10.5 7L16.5 14L10.5 21", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
34
|
+
const getSimplePages = (current, total) => {
|
|
35
|
+
// Always show 1-5, but don't exceed total
|
|
36
|
+
const pages = [];
|
|
37
|
+
for (let index = 1; index <= Math.min(5, total); index++) {
|
|
38
|
+
pages.push(index);
|
|
39
|
+
}
|
|
40
|
+
return pages;
|
|
41
|
+
};
|
|
42
|
+
const CustomPagination = ({ paginationStyle = PaginationStyle.SIMPLE, current = 1, total = 1, pageSize = 10, onChange, ...properties }) => {
|
|
43
|
+
const pageCount = Math.ceil(total / pageSize);
|
|
44
|
+
const handleChange = (page) => {
|
|
45
|
+
if (onChange)
|
|
46
|
+
onChange(page, pageSize);
|
|
47
|
+
};
|
|
48
|
+
if (paginationStyle === PaginationStyle.SIMPLE) {
|
|
49
|
+
const pages = getSimplePages(current, pageCount);
|
|
50
|
+
return (_jsxs(PaginationContainer, { children: [_jsx(ChevronButton, { onClick: () => handleChange(current - 1), disabled: current === 1, "aria-label": "Previous Page", children: _jsx(ChevronIcon, { left: true }) }), pages.map((number_) => (_jsx(PaginationNumber, { active: number_ === current, onClick: () => handleChange(number_), "aria-label": `Page ${number_}`, children: number_ }, number_))), _jsx(ChevronButton, { onClick: () => handleChange(current + 1), disabled: current === pageCount, "aria-label": "Next Page", "$right": true, children: _jsx(ChevronIcon, {}) })] }));
|
|
51
|
+
}
|
|
52
|
+
if (paginationStyle === PaginationStyle.TRUNCATED) {
|
|
53
|
+
// Show 1 2 3 4 5 ... last
|
|
54
|
+
const pages = [];
|
|
55
|
+
for (let index = 1; index <= Math.min(5, pageCount); index++) {
|
|
56
|
+
pages.push(index);
|
|
57
|
+
}
|
|
58
|
+
return (_jsxs(PaginationContainer, { children: [_jsx(ChevronButton, { onClick: () => handleChange(current - 1), disabled: current === 1, "aria-label": "Previous Page", children: _jsx(ChevronIcon, { left: true }) }), pages.map((number_) => (_jsx(PaginationNumber, { active: number_ === current, onClick: () => handleChange(number_), "aria-label": `Page ${number_}`, children: number_ }, number_))), pageCount > 5 && (_jsxs(_Fragment, { children: [_jsx("span", { style: {
|
|
59
|
+
color: "#7F7F7F",
|
|
60
|
+
fontWeight: 600,
|
|
61
|
+
fontSize: 16,
|
|
62
|
+
margin: "0 8px",
|
|
63
|
+
display: "flex",
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
justifyContent: "center",
|
|
66
|
+
paddingBottom: 10,
|
|
67
|
+
}, children: "..." }), _jsx(PaginationNumber, { active: current === pageCount, onClick: () => handleChange(pageCount), "aria-label": `Page ${pageCount}`, children: pageCount }, pageCount)] })), _jsx(ChevronButton, { onClick: () => handleChange(current + 1), disabled: current === pageCount, "aria-label": "Next Page", "$right": true, children: _jsx(ChevronIcon, {}) })] }));
|
|
68
|
+
}
|
|
69
|
+
if (paginationStyle === PaginationStyle.CENTERED) {
|
|
70
|
+
// Show 1 ... left mid mid mid mid ... last
|
|
71
|
+
// Always show 5 numbers, current centered if possible
|
|
72
|
+
const pages = [];
|
|
73
|
+
const visibleCount = 5;
|
|
74
|
+
const sideCount = 2; // numbers to show on each side of current
|
|
75
|
+
let start = Math.max(2, current - 2);
|
|
76
|
+
let end = Math.min(pageCount - 1, current + 2);
|
|
77
|
+
// Adjust if near the start
|
|
78
|
+
if (current <= 3) {
|
|
79
|
+
start = 2;
|
|
80
|
+
end = 6;
|
|
81
|
+
}
|
|
82
|
+
// Adjust if near the end
|
|
83
|
+
if (current >= pageCount - 2) {
|
|
84
|
+
start = pageCount - 4;
|
|
85
|
+
end = pageCount - 1;
|
|
86
|
+
}
|
|
87
|
+
start = Math.max(2, start);
|
|
88
|
+
end = Math.min(pageCount - 1, end);
|
|
89
|
+
// Always show first page
|
|
90
|
+
pages.push(1);
|
|
91
|
+
// Show left ellipsis if needed
|
|
92
|
+
if (start > 2) {
|
|
93
|
+
pages.push("left-ellipsis");
|
|
94
|
+
}
|
|
95
|
+
// Show middle pages
|
|
96
|
+
for (let index = start; index <= end; index++) {
|
|
97
|
+
pages.push(index);
|
|
98
|
+
}
|
|
99
|
+
// Show right ellipsis if needed
|
|
100
|
+
if (end < pageCount - 1) {
|
|
101
|
+
pages.push("right-ellipsis");
|
|
102
|
+
}
|
|
103
|
+
// Always show last page if more than 1
|
|
104
|
+
if (pageCount > 1) {
|
|
105
|
+
pages.push(pageCount);
|
|
106
|
+
}
|
|
107
|
+
return (_jsxs(PaginationContainer, { children: [_jsx(ChevronButton, { onClick: () => handleChange(current - 1), disabled: current === 1, "aria-label": "Previous Page", children: _jsx(ChevronIcon, { left: true }) }), pages.map((number_, index) => {
|
|
108
|
+
if (number_ === "left-ellipsis" || number_ === "right-ellipsis") {
|
|
109
|
+
return (_jsx("span", { style: {
|
|
110
|
+
color: "#7F7F7FB0",
|
|
111
|
+
fontWeight: 600,
|
|
112
|
+
fontSize: 16,
|
|
113
|
+
margin: "0 8px",
|
|
114
|
+
height: "40px",
|
|
115
|
+
display: "flex",
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
justifyContent: "center",
|
|
118
|
+
paddingBottom: 10,
|
|
119
|
+
}, children: "..." }, number_ + index));
|
|
120
|
+
}
|
|
121
|
+
return (_jsx(PaginationNumber, { active: number_ === current, onClick: () => typeof number_ === "number" && handleChange(number_), "aria-label": `Page ${number_}`, children: number_ }, number_));
|
|
122
|
+
}), _jsx(ChevronButton, { onClick: () => handleChange(current + 1), disabled: current === pageCount, "aria-label": "Next Page", "$right": true, children: _jsx(ChevronIcon, {}) })] }));
|
|
123
|
+
}
|
|
124
|
+
if (paginationStyle === PaginationStyle.END_FOCUSED) {
|
|
125
|
+
// Show 1 ... last 5 pages
|
|
126
|
+
const pages = [];
|
|
127
|
+
// Always show first page
|
|
128
|
+
pages.push(1);
|
|
129
|
+
// If more than 6 pages, show ellipsis
|
|
130
|
+
if (pageCount > 6) {
|
|
131
|
+
pages.push("left-ellipsis");
|
|
132
|
+
}
|
|
133
|
+
// Show last 5 pages
|
|
134
|
+
const start = Math.max(2, pageCount - 4);
|
|
135
|
+
for (let index = start; index <= pageCount; index++) {
|
|
136
|
+
pages.push(index);
|
|
137
|
+
}
|
|
138
|
+
return (_jsxs(PaginationContainer, { children: [_jsx(ChevronButton, { onClick: () => handleChange(current - 1), disabled: current === 1, "aria-label": "Previous Page", children: _jsx(ChevronIcon, { left: true }) }), pages.map((number_, index) => {
|
|
139
|
+
if (number_ === "left-ellipsis") {
|
|
140
|
+
return (_jsx("span", { style: {
|
|
141
|
+
color: "#7F7F7F",
|
|
142
|
+
fontWeight: 600,
|
|
143
|
+
fontSize: 18,
|
|
144
|
+
margin: "0 8px",
|
|
145
|
+
display: "flex",
|
|
146
|
+
alignItems: "center",
|
|
147
|
+
justifyContent: "center",
|
|
148
|
+
height: "40px",
|
|
149
|
+
paddingBottom: 10,
|
|
150
|
+
}, children: "..." }, number_ + index));
|
|
151
|
+
}
|
|
152
|
+
return (_jsx(PaginationNumber, { active: number_ === current, onClick: () => typeof number_ === "number" && handleChange(number_), "aria-label": `Page ${number_}`, children: number_ }, number_));
|
|
153
|
+
}), _jsx(ChevronButton, { onClick: () => handleChange(current + 1), disabled: current === pageCount, "aria-label": "Next Page", "$right": true, children: _jsx(ChevronIcon, {}) })] }));
|
|
154
|
+
}
|
|
155
|
+
// Fallback for other styles (not implemented yet)
|
|
156
|
+
return null;
|
|
157
|
+
};
|
|
158
|
+
export default CustomPagination;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import Typography from "../../Typography";
|
|
4
|
+
const NumberButton = styled.button `
|
|
5
|
+
background: ${({ $active, theme }) => $active ? theme.colors.primary.default.backgroundColor : "transparent"};
|
|
6
|
+
color: ${({ $active, theme }) => $active ? "#fff" : theme.colors.onsurface["copy-light"] || "#6C6C6C"};
|
|
7
|
+
border: none;
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
min-width: 24px;
|
|
10
|
+
height: 24px;
|
|
11
|
+
padding: 4px 7px;
|
|
12
|
+
font-size: 16px;
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
margin: 0 4px;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
transition: background 0.2s, color 0.2s;
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
font-family: inherit;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
background: ${({ $active, theme }) => $active
|
|
25
|
+
? theme.colors.primary.default.backgroundColor
|
|
26
|
+
: theme.colors.primary.default.backgroundColor + "22"};
|
|
27
|
+
color: #fff;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
export const PaginationNumber = ({ active, children, ...properties }) => (_jsx(NumberButton, { "$active": active, "aria-current": active ? "page" : undefined, ...properties, children: _jsx(Typography, { variant: "digits3", color: active ? "white" : "#6C6C6C", children: children }) }));
|