@gobolt/genesis 0.3.22 → 0.3.24
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/Badge/Badge.js +32 -9
- package/dist/components/Badge/styles.d.ts +10 -1
- package/dist/components/Badge/styles.js +14 -39
- package/dist/components/Button/Button.js +27 -4
- package/dist/components/Button/IconButton.js +27 -4
- 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/Button/icon-button-styles.d.ts +12 -1
- package/dist/components/Button/icon-button-styles.js +16 -69
- package/dist/components/Button/styles.d.ts +16 -1
- package/dist/components/Button/styles.js +30 -88
- package/dist/components/Input/Input.js +29 -6
- package/dist/components/Input/styles.d.ts +18 -1
- package/dist/components/Input/styles.js +42 -146
- package/dist/components/Select/Select.js +125 -101
- package/dist/components/Select/SelectTrigger.js +57 -71
- package/dist/components/Table/Table.js +27 -8
- package/dist/components/Table/TableControls/CustomPagination.js +66 -50
- package/dist/components/Table/TableControls/PaginationNumber.js +43 -27
- package/dist/components/Table/TableControls/PrimaryTableControlsRow.js +17 -16
- package/dist/components/Table/TableControls/SecondaryTableControlsRow.js +36 -14
- package/dist/components/Table/TableControls/TableControls.js +4 -3
- package/dist/components/Table/TablePagination.js +21 -4
- package/dist/components/Table/__mocks__/table-mocks.js +24 -15
- package/dist/components/Table/styles.d.ts +15 -1
- package/dist/components/Table/styles.js +13 -57
- package/dist/components/Table/useTable.js +166 -69
- package/dist/components/TableWithControls/TableWithControls.js +7 -6
- 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/useTableWithControls.js +63 -82
- package/dist/components/TableWithControls/utils/icon-util.d.ts +3 -0
- package/dist/components/TableWithControls/utils/icon-util.js +116 -0
- package/dist/components/Tooltip/Tooltip.js +2 -1
- package/dist/components/Tooltip/styles.d.ts +14 -1
- package/dist/components/Tooltip/styles.js +14 -23
- package/dist/components/Typography/Typography.js +29 -6
- package/dist/components/Typography/styles.d.ts +21 -3
- package/dist/components/Typography/styles.js +24 -41
- package/dist/components/UtilityButton/UtilityButton.js +27 -4
- 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.js +7 -0
- package/dist/components/shared/DropdownChevron.js +14 -3
- package/dist/index.js +10 -89
- package/dist/utils/icon-util.d.ts +2 -2
- package/dist/utils/icon-util.js +19 -16
- 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/components/index.ts +0 -7
- package/dist/constants/index.ts +0 -98
- package/dist/genesis-theme.types.d.ts +0 -263
- package/dist/genesis-theme.types.js +0 -6
- package/dist/index.ts +0 -10
- package/dist/styled.d.ts +0 -1
- package/dist/styled.js +0 -44
- package/dist/styles/theme/genesis-theme.types.ts +0 -297
- package/dist/utils/styled.ts +0 -52
- /package/dist/{Table → components/Table/Table}/Table.d.ts +0 -0
- /package/dist/{Table → components/Table/Table}/Table.js +0 -0
- /package/dist/{Table → components/Table/Table}/TableControls/CustomPagination.d.ts +0 -0
- /package/dist/{Table → components/Table/Table}/TableControls/CustomPagination.js +0 -0
- /package/dist/{Table → components/Table/Table}/TableControls/PaginationNumber.d.ts +0 -0
- /package/dist/{Table → components/Table/Table}/TableControls/PaginationNumber.js +0 -0
- /package/dist/{Table → components/Table/Table}/styles.d.ts +0 -0
- /package/dist/{Table → components/Table/Table}/styles.js +0 -0
- /package/dist/{Table → components/Table/Table}/useTable.d.ts +0 -0
- /package/dist/{Table → components/Table/Table}/useTable.js +0 -0
- /package/dist/{Typography → components/Table/Typography}/Typography.d.ts +0 -0
- /package/dist/{Typography → components/Table/Typography}/Typography.js +0 -0
- /package/dist/{Typography → components/Table/Typography}/index.d.ts +0 -0
- /package/dist/{Typography → components/Table/Typography}/index.js +0 -0
- /package/dist/{Typography → components/Table/Typography}/styles.d.ts +0 -0
- /package/dist/{Typography → components/Table/Typography}/styles.js +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styled from "@gobolt/genesis/utils/styled";
|
|
4
|
+
import DropdownChevron from "../shared/DropdownChevron";
|
|
5
|
+
import { Typography } from "@gobolt/genesis/components";
|
|
6
|
+
const getBackgroundColor = (colors, disabled, $variant) => {
|
|
7
|
+
if ($variant === "simple")
|
|
8
|
+
return "#F4F4F4";
|
|
9
|
+
if (disabled)
|
|
10
|
+
return "#F4F4F4";
|
|
11
|
+
return "#fff";
|
|
12
|
+
};
|
|
13
|
+
const TriggerWrapper = styled.div `
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
cursor: ${({ $disabled }) => ($disabled ? "not-allowed" : "pointer")};
|
|
18
|
+
opacity: ${({ $disabled }) => ($disabled ? 0.4 : 1)};
|
|
19
|
+
position: relative;
|
|
20
|
+
box-shadow: ${({ $variant }) => $variant === "simple" ? "none" : "0px 1px 2px 0px rgba(0, 0, 0, 0.12)"};
|
|
21
|
+
transition: all 0.2s ease-in-out;
|
|
22
|
+
min-height: ${({ $variant }) => ($variant === "simple" ? "32px" : "40px")};
|
|
23
|
+
|
|
24
|
+
&:focus-visible {
|
|
25
|
+
outline: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:focus {
|
|
29
|
+
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.12),
|
|
30
|
+
0 0 0 3px
|
|
31
|
+
${({ theme, $themeType = "primary" }) => theme.colors[$themeType].focussed.ringColor};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
${({ $variant, theme, $disabled }) => $variant === "simple"
|
|
35
|
+
? `
|
|
36
|
+
padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
|
|
37
|
+
background: ${$disabled ? theme.colors.inputs.surface.disabled : "rgba(0, 0, 0, 0.04)"};
|
|
38
|
+
border: none;
|
|
39
|
+
border-radius: ${theme.borderRadius.BorderRadiusSm}px;
|
|
40
|
+
min-height: ${({ $variant }) => ($variant === "simple" ? "32px" : "40px")};
|
|
41
|
+
|
|
42
|
+
&:hover {
|
|
43
|
+
border: none;
|
|
44
|
+
}
|
|
45
|
+
`
|
|
46
|
+
: `
|
|
47
|
+
padding: ${theme.sizing.Size1} ${theme.sizing.Size2};
|
|
48
|
+
background: ${$disabled
|
|
49
|
+
? theme.colors.inputs.surface.disabled
|
|
50
|
+
: theme.colors.surface.default?.backgroundColor};
|
|
51
|
+
border: 1px solid #9a9a9a;
|
|
52
|
+
border-radius: ${theme.borderRadius.BorderRadiusSm}px;
|
|
53
|
+
min-height: ${({ $variant }) => ($variant === "simple" ? "32px" : "40px")};
|
|
54
|
+
|
|
55
|
+
&:hover {
|
|
56
|
+
border-color: rgba(0, 0, 0, 0.2);
|
|
57
|
+
}
|
|
58
|
+
`}
|
|
59
|
+
`;
|
|
60
|
+
const ValueContainer = styled.div `
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: ${({ theme }) => theme.sizing.Size2}px;
|
|
64
|
+
flex: 1;
|
|
65
|
+
padding: 4px 8px;
|
|
66
|
+
`;
|
|
67
|
+
const ChevronContainer = styled.div `
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
margin-right: ${({ $variant }) => ($variant === "simple" ? "4px" : "4px")};
|
|
72
|
+
margin-left: ${({ $variant }) => ($variant === "simple" ? "4px" : "0")};
|
|
73
|
+
`;
|
|
74
|
+
const SelectTrigger = ({ type = "primary", theme, state, value, placeholder = "Select...", open, onClick, renderValue, options = [], disabled = false, variant = "none", }) => {
|
|
75
|
+
const handleClick = React.useCallback(() => {
|
|
76
|
+
if (disabled)
|
|
77
|
+
return;
|
|
78
|
+
onClick?.();
|
|
79
|
+
}, [disabled, onClick]);
|
|
80
|
+
const displayValue = React.useMemo(() => {
|
|
81
|
+
if (!value)
|
|
82
|
+
return null;
|
|
83
|
+
if (renderValue)
|
|
84
|
+
return renderValue(value);
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
if (value.length === 0)
|
|
87
|
+
return null;
|
|
88
|
+
const selectedLabels = value
|
|
89
|
+
.map(String)
|
|
90
|
+
.map((v) => options.find((opt) => opt.value === v)?.label)
|
|
91
|
+
.filter(Boolean);
|
|
92
|
+
return selectedLabels.length > 0
|
|
93
|
+
? selectedLabels.join(", ")
|
|
94
|
+
: `${value.length} selected`;
|
|
95
|
+
}
|
|
96
|
+
const selectedOption = options.find((opt) => opt.value === String(value));
|
|
97
|
+
return selectedOption?.label || value.toString();
|
|
98
|
+
}, [value, renderValue, options]);
|
|
99
|
+
return (_jsxs(TriggerWrapper, { "$themeType": type, "$state": state, onClick: handleClick, tabIndex: disabled ? -1 : 0, role: "button", "$disabled": disabled, "$variant": variant, style: {
|
|
100
|
+
backgroundColor: getBackgroundColor(theme, disabled, variant),
|
|
101
|
+
}, children: [_jsx(ValueContainer, { "$variant": variant, children: displayValue ? (_jsx(Typography, { variant: "body2", color: disabled ? "copy-light" : "copy", children: displayValue })) : (_jsx(Typography, { variant: "body2", color: disabled ? "copy-light" : "copy-light", children: placeholder })) }), _jsx(ChevronContainer, { "$variant": variant, children: _jsx(DropdownChevron, {}) })] }));
|
|
102
|
+
};
|
|
103
|
+
export default SelectTrigger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Select";
|
|
@@ -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;
|
package/dist/components/TableWithControls/components/Table/TableControls/CustomPagination.d.ts
ADDED
|
@@ -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 }) }));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ActionEvent, TableEventPayload } from "../../../types/events";
|
|
3
|
+
type SortOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
type SortOptions = SortOption[] | null;
|
|
8
|
+
export interface PrimaryTableControlsRowProps {
|
|
9
|
+
sortOptions: SortOptions;
|
|
10
|
+
searchByPlaceholder?: string;
|
|
11
|
+
searchField?: string;
|
|
12
|
+
isSortedAscending?: boolean;
|
|
13
|
+
onChange?: (event: ActionEvent<TableEventPayload>) => void;
|
|
14
|
+
searchValue?: string;
|
|
15
|
+
selectedSortOption?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const PrimaryTableControlsRow: ({ sortOptions, searchByPlaceholder, searchField, isSortedAscending, searchValue, selectedSortOption, onChange, }: PrimaryTableControlsRowProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default PrimaryTableControlsRow;
|
package/dist/components/TableWithControls/components/Table/TableControls/PrimaryTableControlsRow.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import UtilityButton from "../../UtilityButton";
|
|
3
|
+
import IconButton from "../../Button/IconButton";
|
|
4
|
+
import Select from "../../Select";
|
|
5
|
+
import Typography from "../../Typography";
|
|
6
|
+
import Input from "../../Input";
|
|
7
|
+
import { HiMiniAdjustmentsVertical } from "react-icons/hi2";
|
|
8
|
+
import { HiSearch } from "react-icons/hi";
|
|
9
|
+
import { HiOutlineSortAscending, HiOutlineSortDescending, } from "react-icons/hi";
|
|
10
|
+
import { FiSettings } from "react-icons/fi";
|
|
11
|
+
const PrimaryTableControlsRow = ({ sortOptions, searchByPlaceholder = "", searchField = "address", isSortedAscending = true, searchValue = "", selectedSortOption = "", onChange, }) => {
|
|
12
|
+
const onInputChange = (actionEvent) => {
|
|
13
|
+
onChange?.({
|
|
14
|
+
event: "inputChange",
|
|
15
|
+
payload: actionEvent.payload,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
const onSortChange = (value) => {
|
|
19
|
+
const sortActionEvent = {
|
|
20
|
+
event: "primarySortChange",
|
|
21
|
+
payload: { value },
|
|
22
|
+
};
|
|
23
|
+
onChange?.(sortActionEvent);
|
|
24
|
+
};
|
|
25
|
+
const onFilterClick = () => {
|
|
26
|
+
const filterActionEvent = {
|
|
27
|
+
event: "filterClick",
|
|
28
|
+
payload: {},
|
|
29
|
+
};
|
|
30
|
+
onChange?.(filterActionEvent);
|
|
31
|
+
};
|
|
32
|
+
const onSettingsClick = () => {
|
|
33
|
+
const settingsActionEvent = {
|
|
34
|
+
event: "settingsClick",
|
|
35
|
+
payload: {},
|
|
36
|
+
};
|
|
37
|
+
onChange?.(settingsActionEvent);
|
|
38
|
+
};
|
|
39
|
+
const onOrderClick = () => {
|
|
40
|
+
const ascendingActionEvent = {
|
|
41
|
+
event: "orderClick",
|
|
42
|
+
payload: {
|
|
43
|
+
value: isSortedAscending ? "desc" : "asc",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
onChange?.(ascendingActionEvent);
|
|
47
|
+
};
|
|
48
|
+
return (_jsxs("div", { style: {
|
|
49
|
+
display: "flex",
|
|
50
|
+
justifyContent: "space-between",
|
|
51
|
+
alignItems: "center",
|
|
52
|
+
width: "100%",
|
|
53
|
+
minWidth: 800,
|
|
54
|
+
marginBottom: 16,
|
|
55
|
+
}, children: [_jsxs("div", { style: { display: "flex" }, children: [_jsx(Input, { size: "normal", placeholder: searchByPlaceholder, prefix: _jsx(HiSearch, {}), style: {
|
|
56
|
+
padding: "5px 8px",
|
|
57
|
+
}, value: searchValue, onChange: onInputChange }), onFilterClick && (_jsx("div", { style: { marginLeft: 16 }, children: _jsx(UtilityButton, { isIconButton: true, icon: _jsx(HiMiniAdjustmentsVertical, { color: "#222222" }), onClick: onFilterClick }) })), onSettingsClick && (_jsx("div", { style: { marginLeft: 16 }, children: _jsx(UtilityButton, { isIconButton: true, icon: _jsx(FiSettings, { color: "#222222" }), onClick: onSettingsClick }) }))] }), _jsxs("div", { style: {
|
|
58
|
+
display: "flex",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
width: 300,
|
|
61
|
+
justifyContent: "flex-end",
|
|
62
|
+
marginLeft: "auto",
|
|
63
|
+
}, children: [_jsx(Typography, { variant: "body1", color: "#6C6C6C", style: {
|
|
64
|
+
width: 70,
|
|
65
|
+
flexShrink: 0,
|
|
66
|
+
textAlign: "right",
|
|
67
|
+
paddingRight: 4,
|
|
68
|
+
marginRight: 8,
|
|
69
|
+
}, children: "Sort by" }), sortOptions && onSortChange ? (_jsx(Select, { options: sortOptions, defaultValue: sortOptions[0].value, value: selectedSortOption, variant: "simple", onChange: onSortChange, style: {
|
|
70
|
+
width: 180,
|
|
71
|
+
flexShrink: 0,
|
|
72
|
+
} })) : null, _jsx("div", { style: {
|
|
73
|
+
marginLeft: 8,
|
|
74
|
+
flexShrink: 0,
|
|
75
|
+
}, children: _jsx(IconButton, { icon: isSortedAscending ? (_jsx(HiOutlineSortDescending, { size: 20 })) : (_jsx(HiOutlineSortAscending, { size: 20 })), onClick: onOrderClick }) })] })] }));
|
|
76
|
+
};
|
|
77
|
+
export default PrimaryTableControlsRow;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Change } from "../Table";
|
|
2
|
+
export type Groups = {
|
|
3
|
+
[key: string]: string[];
|
|
4
|
+
};
|
|
5
|
+
export interface SecondaryTableControlsRowProps {
|
|
6
|
+
groups: Groups | null;
|
|
7
|
+
totalRecords: number | null;
|
|
8
|
+
onChange?: Change;
|
|
9
|
+
}
|
|
10
|
+
declare const SecondaryTableControlsRow: ({ groups, totalRecords, onChange, }: SecondaryTableControlsRowProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default SecondaryTableControlsRow;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Badge from "../../Badge";
|
|
3
|
+
import Typography from "../../Typography";
|
|
4
|
+
import Tooltip from "../../Tooltip";
|
|
5
|
+
import { getIcon } from "../../../utils/icon-util";
|
|
6
|
+
const GroupItem = ({ title, items, onGroupItemClick }) => {
|
|
7
|
+
if (items.length === 0)
|
|
8
|
+
return null;
|
|
9
|
+
return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { tip: title, children: _jsx("div", { style: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
justifyContent: "center",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
width: 24,
|
|
14
|
+
height: 24,
|
|
15
|
+
}, children: getIcon(title) }) }), _jsx("div", { style: { display: "flex", gap: 4 }, children: items.map((item) => (_jsx(Badge, { label: item, hasClose: true, state: "generic", size: "small", onClick: () => onGroupItemClick(title, item) }, item.toString()))) })] }));
|
|
16
|
+
};
|
|
17
|
+
const GroupsRow = ({ groups, onGroupItemClick }) => {
|
|
18
|
+
if (!groups)
|
|
19
|
+
return null;
|
|
20
|
+
const groupArray = Object.entries(groups).map(([title, items]) => ({
|
|
21
|
+
title,
|
|
22
|
+
items,
|
|
23
|
+
}));
|
|
24
|
+
return (_jsx("div", { style: { display: "flex", gap: 4 }, children: groupArray.length > 0
|
|
25
|
+
? groupArray.map((group) => (_jsx(GroupItem, { title: group.title, items: group.items, onGroupItemClick: onGroupItemClick }, group.title)))
|
|
26
|
+
: null }));
|
|
27
|
+
};
|
|
28
|
+
const SecondaryTableControlsRow = ({ groups, totalRecords, onChange, }) => {
|
|
29
|
+
const onGroupItemClick = (title, item) => {
|
|
30
|
+
const groupItemClickEvent = {
|
|
31
|
+
event: "groupItemClick",
|
|
32
|
+
payload: { title, item },
|
|
33
|
+
};
|
|
34
|
+
onChange?.(groupItemClickEvent);
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs("div", { style: {
|
|
37
|
+
display: "flex",
|
|
38
|
+
justifyContent: "space-between",
|
|
39
|
+
alignItems: "flex-end",
|
|
40
|
+
marginTop: 8,
|
|
41
|
+
}, children: [_jsx(GroupsRow, { groups: groups, onGroupItemClick: onGroupItemClick }), totalRecords > 0 ? (_jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `${totalRecords} results` })) : null] }));
|
|
42
|
+
};
|
|
43
|
+
export default SecondaryTableControlsRow;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PrimaryTableControlsRowProps } from "./PrimaryTableControlsRow";
|
|
2
|
+
import type { SecondaryTableControlsRowProps } from "./SecondaryTableControlsRow";
|
|
3
|
+
import type { ActionEvent, TableEventPayload } from "../../../types/events";
|
|
4
|
+
export type TableControlsData = {
|
|
5
|
+
primaryTableRowData: PrimaryTableControlsRowProps;
|
|
6
|
+
secondaryTableRowData?: SecondaryTableControlsRowProps;
|
|
7
|
+
};
|
|
8
|
+
export interface TableControlsProps {
|
|
9
|
+
primaryTableRowData: PrimaryTableControlsRowProps;
|
|
10
|
+
secondaryTableRowData?: SecondaryTableControlsRowProps;
|
|
11
|
+
onChange: (event: ActionEvent<TableEventPayload>) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const TableControls: ({ primaryTableRowData, secondaryTableRowData, onChange, }: TableControlsProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default TableControls;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import PrimaryTableControlsRow from "./PrimaryTableControlsRow";
|
|
3
|
+
import SecondaryTableControlsRow from "./SecondaryTableControlsRow";
|
|
4
|
+
const TableControls = ({ primaryTableRowData, secondaryTableRowData, onChange, }) => {
|
|
5
|
+
const onPrimaryChange = (actionEvent) => {
|
|
6
|
+
onChange(actionEvent);
|
|
7
|
+
};
|
|
8
|
+
const onSecondaryChange = (actionEvent) => {
|
|
9
|
+
onChange(actionEvent);
|
|
10
|
+
};
|
|
11
|
+
return (_jsxs("div", { "data-testid": "TableControls", style: { margin: "16px 0px" }, children: [_jsx(PrimaryTableControlsRow, { sortOptions: primaryTableRowData.sortOptions, searchByPlaceholder: primaryTableRowData.searchByPlaceholder, isSortedAscending: primaryTableRowData.isSortedAscending, onChange: onPrimaryChange, searchValue: primaryTableRowData.searchValue, selectedSortOption: primaryTableRowData.selectedSortOption }), secondaryTableRowData ? (_jsx(SecondaryTableControlsRow, { groups: secondaryTableRowData.groups, totalRecords: secondaryTableRowData.totalRecords, onChange: onSecondaryChange })) : null] }));
|
|
12
|
+
};
|
|
13
|
+
export default TableControls;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./TableControls";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PaginationStyle } from "./TableControls/CustomPagination";
|
|
2
|
+
import type { ColumnType } from "antd/es/table";
|
|
3
|
+
export interface TablePaginationProps<T> {
|
|
4
|
+
columns: ColumnType<T>[];
|
|
5
|
+
dataSource: T[];
|
|
6
|
+
rowSelection?: any;
|
|
7
|
+
onChange?: (...arguments_: any[]) => void;
|
|
8
|
+
paginationStyle?: PaginationStyle;
|
|
9
|
+
pageSize?: number;
|
|
10
|
+
isMainContentCell?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const TablePagination: <T extends Record<string, any>>({ columns, dataSource, rowSelection, onChange, paginationStyle, pageSize, isMainContentCell, }: TablePaginationProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default TablePagination;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import Table from "./Table";
|
|
4
|
+
import CustomPagination, { PaginationStyle, } from "./TableControls/CustomPagination";
|
|
5
|
+
const TablePagination = ({ columns, dataSource, rowSelection, onChange, paginationStyle = PaginationStyle.SIMPLE, pageSize = 10, isMainContentCell, }) => {
|
|
6
|
+
const [current, setCurrent] = useState(1);
|
|
7
|
+
const total = dataSource.length;
|
|
8
|
+
const paginatedData = dataSource.slice((current - 1) * pageSize, current * pageSize);
|
|
9
|
+
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "0px" }, children: [_jsx(Table, { columns: columns, dataSource: paginatedData, rowSelection: rowSelection, onChange: onChange, pagination: false, isMainContentCell: isMainContentCell }), _jsx("div", { style: { display: "flex", justifyContent: "flex-end", marginTop: 16 }, children: _jsx(CustomPagination, { paginationStyle: paginationStyle, current: current, total: total, pageSize: pageSize, onChange: setCurrent }) })] }));
|
|
10
|
+
};
|
|
11
|
+
export default TablePagination;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ColumnsType } from "antd/es/table";
|
|
2
|
+
export interface AppointmentWithSimpleAddress {
|
|
3
|
+
id: string;
|
|
4
|
+
number: string;
|
|
5
|
+
timerange: string;
|
|
6
|
+
status: AppointmentStatus;
|
|
7
|
+
address: {
|
|
8
|
+
nickname: string;
|
|
9
|
+
address: string;
|
|
10
|
+
};
|
|
11
|
+
job_subtype: "delivery" | "pickup";
|
|
12
|
+
}
|
|
13
|
+
export interface MockDataSource {
|
|
14
|
+
appointments: AppointmentWithSimpleAddress[];
|
|
15
|
+
}
|
|
16
|
+
type AppointmentStatus = "scheduled" | "completed" | "cancelled" | "in_progress";
|
|
17
|
+
export declare const mockColumns: ColumnsType<AppointmentWithSimpleAddress>;
|
|
18
|
+
export declare const mockColumnsWithSortDisabled: ColumnsType<AppointmentWithSimpleAddress>;
|
|
19
|
+
export declare const mockDataSource: MockDataSource;
|
|
20
|
+
export {};
|