@gobolt/genesis 0.3.21 → 0.3.22
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/Table/Table.d.ts +51 -0
- package/dist/Table/Table.js +14 -0
- package/dist/Table/TableControls/CustomPagination.d.ts +13 -0
- package/dist/Table/TableControls/CustomPagination.js +158 -0
- package/dist/Table/TableControls/PaginationNumber.d.ts +7 -0
- package/dist/Table/TableControls/PaginationNumber.js +30 -0
- package/dist/Table/styles.d.ts +14 -0
- package/dist/Table/styles.js +64 -0
- package/dist/Table/useTable.d.ts +26 -0
- package/dist/Table/useTable.js +141 -0
- package/dist/Typography/Typography.d.ts +17 -0
- package/dist/Typography/Typography.js +16 -0
- package/dist/Typography/index.d.ts +2 -0
- package/dist/Typography/index.js +1 -0
- package/dist/Typography/styles.d.ts +3 -0
- package/dist/Typography/styles.js +54 -0
- package/dist/components/Badge/Badge.js +9 -32
- package/dist/components/Badge/styles.d.ts +1 -10
- package/dist/components/Badge/styles.js +39 -14
- package/dist/components/Button/Button.js +4 -27
- package/dist/components/Button/IconButton.js +4 -27
- package/dist/components/Button/icon-button-styles.d.ts +1 -12
- package/dist/components/Button/icon-button-styles.js +69 -16
- package/dist/components/Button/styles.d.ts +1 -16
- package/dist/components/Button/styles.js +88 -30
- package/dist/components/Input/Input.js +6 -29
- package/dist/components/Input/styles.d.ts +1 -18
- package/dist/components/Input/styles.js +146 -42
- package/dist/components/Select/Select.js +101 -125
- package/dist/components/Select/SelectTrigger.js +71 -57
- package/dist/components/Table/Table.js +8 -27
- package/dist/components/Table/TableControls/CustomPagination.js +50 -66
- package/dist/components/Table/TableControls/PaginationNumber.js +27 -43
- package/dist/components/Table/TableControls/PrimaryTableControlsRow.js +16 -17
- package/dist/components/Table/TableControls/SecondaryTableControlsRow.js +14 -36
- package/dist/components/Table/TableControls/TableControls.js +3 -4
- package/dist/components/Table/TablePagination.js +4 -21
- package/dist/components/Table/__mocks__/table-mocks.js +15 -24
- package/dist/components/Table/styles.d.ts +1 -15
- package/dist/components/Table/styles.js +57 -13
- package/dist/components/Table/useTable.js +69 -166
- package/dist/components/TableWithControls/TableWithControls.js +6 -7
- package/dist/components/TableWithControls/useTableWithControls.js +82 -63
- package/dist/components/Tooltip/Tooltip.js +1 -2
- package/dist/components/Tooltip/styles.d.ts +1 -14
- package/dist/components/Tooltip/styles.js +23 -14
- package/dist/components/Typography/Typography.js +6 -29
- package/dist/components/Typography/styles.d.ts +3 -21
- package/dist/components/Typography/styles.js +41 -24
- package/dist/components/UtilityButton/UtilityButton.js +4 -27
- package/dist/components/shared/DropdownChevron.js +3 -14
- package/dist/constants/index.js +14 -14
- package/dist/genesis-theme.types.d.ts +263 -0
- package/dist/genesis-theme.types.js +6 -0
- package/dist/index.js +89 -0
- package/dist/styled.d.ts +1 -0
- package/dist/styled.js +44 -0
- package/dist/utils/icon-util.d.ts +2 -2
- package/dist/utils/icon-util.js +16 -19
- package/package.json +1 -1
|
@@ -1,68 +1,83 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
2
|
import React from "react";
|
|
7
3
|
import styled from "@gobolt/genesis/utils/styled";
|
|
8
4
|
import DropdownChevron from "../shared/DropdownChevron";
|
|
9
5
|
import { Typography } from "@gobolt/genesis/components";
|
|
10
|
-
|
|
6
|
+
const getBackgroundColor = (colors, disabled, $variant) => {
|
|
11
7
|
if ($variant === "simple")
|
|
12
8
|
return "#F4F4F4";
|
|
13
9
|
if (disabled)
|
|
14
10
|
return "#F4F4F4";
|
|
15
11
|
return "#fff";
|
|
16
12
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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(() => {
|
|
61
76
|
if (disabled)
|
|
62
77
|
return;
|
|
63
|
-
onClick
|
|
78
|
+
onClick?.();
|
|
64
79
|
}, [disabled, onClick]);
|
|
65
|
-
|
|
80
|
+
const displayValue = React.useMemo(() => {
|
|
66
81
|
if (!value)
|
|
67
82
|
return null;
|
|
68
83
|
if (renderValue)
|
|
@@ -70,20 +85,19 @@ var SelectTrigger = function (_a) {
|
|
|
70
85
|
if (Array.isArray(value)) {
|
|
71
86
|
if (value.length === 0)
|
|
72
87
|
return null;
|
|
73
|
-
|
|
88
|
+
const selectedLabels = value
|
|
74
89
|
.map(String)
|
|
75
|
-
.map(
|
|
90
|
+
.map((v) => options.find((opt) => opt.value === v)?.label)
|
|
76
91
|
.filter(Boolean);
|
|
77
92
|
return selectedLabels.length > 0
|
|
78
93
|
? selectedLabels.join(", ")
|
|
79
|
-
:
|
|
94
|
+
: `${value.length} selected`;
|
|
80
95
|
}
|
|
81
|
-
|
|
82
|
-
return
|
|
96
|
+
const selectedOption = options.find((opt) => opt.value === String(value));
|
|
97
|
+
return selectedOption?.label || value.toString();
|
|
83
98
|
}, [value, renderValue, options]);
|
|
84
99
|
return (_jsxs(TriggerWrapper, { "$themeType": type, "$state": state, onClick: handleClick, tabIndex: disabled ? -1 : 0, role: "button", "$disabled": disabled, "$variant": variant, style: {
|
|
85
100
|
backgroundColor: getBackgroundColor(theme, disabled, variant),
|
|
86
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, {}) })] }));
|
|
87
102
|
};
|
|
88
103
|
export default SelectTrigger;
|
|
89
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
2
|
import * as S from "./styles";
|
|
25
3
|
import CustomPagination, { PaginationStyle, } from "./TableControls/CustomPagination";
|
|
26
|
-
function Table(
|
|
27
|
-
|
|
28
|
-
var paginationConfig = pagination === false
|
|
4
|
+
function Table({ columns, dataSource, rowKey = "id", size = "small", onChange, rowSelection, pagination, isMainContentCell = false, ...rest }) {
|
|
5
|
+
const paginationConfig = pagination === false
|
|
29
6
|
? false
|
|
30
|
-
:
|
|
31
|
-
|
|
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 }));
|
|
32
13
|
}
|
|
33
14
|
export default Table;
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
6
|
-
var t = {};
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
10
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
11
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
12
|
-
t[p[i]] = s[p[i]];
|
|
13
|
-
}
|
|
14
|
-
return t;
|
|
15
|
-
};
|
|
16
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
2
|
import styled from "styled-components";
|
|
18
3
|
import { PaginationNumber } from "./PaginationNumber";
|
|
@@ -23,50 +8,54 @@ export var PaginationStyle;
|
|
|
23
8
|
PaginationStyle["CENTERED"] = "centered";
|
|
24
9
|
PaginationStyle["END_FOCUSED"] = "endFocused";
|
|
25
10
|
})(PaginationStyle || (PaginationStyle = {}));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
|
|
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) => {
|
|
45
35
|
// Always show 1-5, but don't exceed total
|
|
46
|
-
|
|
47
|
-
for (
|
|
36
|
+
const pages = [];
|
|
37
|
+
for (let index = 1; index <= Math.min(5, total); index++) {
|
|
48
38
|
pages.push(index);
|
|
49
39
|
}
|
|
50
40
|
return pages;
|
|
51
41
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var handleChange = function (page) {
|
|
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) => {
|
|
56
45
|
if (onChange)
|
|
57
46
|
onChange(page, pageSize);
|
|
58
47
|
};
|
|
59
48
|
if (paginationStyle === PaginationStyle.SIMPLE) {
|
|
60
|
-
|
|
61
|
-
return (_jsxs(PaginationContainer, { children: [_jsx(ChevronButton, { onClick:
|
|
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, {}) })] }));
|
|
62
51
|
}
|
|
63
52
|
if (paginationStyle === PaginationStyle.TRUNCATED) {
|
|
64
53
|
// Show 1 2 3 4 5 ... last
|
|
65
|
-
|
|
66
|
-
for (
|
|
54
|
+
const pages = [];
|
|
55
|
+
for (let index = 1; index <= Math.min(5, pageCount); index++) {
|
|
67
56
|
pages.push(index);
|
|
68
57
|
}
|
|
69
|
-
return (_jsxs(PaginationContainer, { children: [_jsx(ChevronButton, { onClick:
|
|
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: {
|
|
70
59
|
color: "#7F7F7F",
|
|
71
60
|
fontWeight: 600,
|
|
72
61
|
fontSize: 16,
|
|
@@ -75,16 +64,16 @@ var CustomPagination = function (_a) {
|
|
|
75
64
|
alignItems: "center",
|
|
76
65
|
justifyContent: "center",
|
|
77
66
|
paddingBottom: 10,
|
|
78
|
-
}, children: "..." }), _jsx(PaginationNumber, { active: current === pageCount, onClick:
|
|
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, {}) })] }));
|
|
79
68
|
}
|
|
80
69
|
if (paginationStyle === PaginationStyle.CENTERED) {
|
|
81
70
|
// Show 1 ... left mid mid mid mid ... last
|
|
82
71
|
// Always show 5 numbers, current centered if possible
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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);
|
|
88
77
|
// Adjust if near the start
|
|
89
78
|
if (current <= 3) {
|
|
90
79
|
start = 2;
|
|
@@ -104,7 +93,7 @@ var CustomPagination = function (_a) {
|
|
|
104
93
|
pages.push("left-ellipsis");
|
|
105
94
|
}
|
|
106
95
|
// Show middle pages
|
|
107
|
-
for (
|
|
96
|
+
for (let index = start; index <= end; index++) {
|
|
108
97
|
pages.push(index);
|
|
109
98
|
}
|
|
110
99
|
// Show right ellipsis if needed
|
|
@@ -115,7 +104,7 @@ var CustomPagination = function (_a) {
|
|
|
115
104
|
if (pageCount > 1) {
|
|
116
105
|
pages.push(pageCount);
|
|
117
106
|
}
|
|
118
|
-
return (_jsxs(PaginationContainer, { children: [_jsx(ChevronButton, { onClick:
|
|
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) => {
|
|
119
108
|
if (number_ === "left-ellipsis" || number_ === "right-ellipsis") {
|
|
120
109
|
return (_jsx("span", { style: {
|
|
121
110
|
color: "#7F7F7FB0",
|
|
@@ -129,14 +118,12 @@ var CustomPagination = function (_a) {
|
|
|
129
118
|
paddingBottom: 10,
|
|
130
119
|
}, children: "..." }, number_ + index));
|
|
131
120
|
}
|
|
132
|
-
return (_jsx(PaginationNumber, { active: number_ === current, onClick:
|
|
133
|
-
|
|
134
|
-
}, "aria-label": "Page ".concat(number_), children: number_ }, number_));
|
|
135
|
-
}), _jsx(ChevronButton, { onClick: function () { return handleChange(current + 1); }, disabled: current === pageCount, "aria-label": "Next Page", "$right": true, children: _jsx(ChevronIcon, {}) })] }));
|
|
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, {}) })] }));
|
|
136
123
|
}
|
|
137
124
|
if (paginationStyle === PaginationStyle.END_FOCUSED) {
|
|
138
125
|
// Show 1 ... last 5 pages
|
|
139
|
-
|
|
126
|
+
const pages = [];
|
|
140
127
|
// Always show first page
|
|
141
128
|
pages.push(1);
|
|
142
129
|
// If more than 6 pages, show ellipsis
|
|
@@ -144,11 +131,11 @@ var CustomPagination = function (_a) {
|
|
|
144
131
|
pages.push("left-ellipsis");
|
|
145
132
|
}
|
|
146
133
|
// Show last 5 pages
|
|
147
|
-
|
|
148
|
-
for (
|
|
134
|
+
const start = Math.max(2, pageCount - 4);
|
|
135
|
+
for (let index = start; index <= pageCount; index++) {
|
|
149
136
|
pages.push(index);
|
|
150
137
|
}
|
|
151
|
-
return (_jsxs(PaginationContainer, { children: [_jsx(ChevronButton, { onClick:
|
|
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) => {
|
|
152
139
|
if (number_ === "left-ellipsis") {
|
|
153
140
|
return (_jsx("span", { style: {
|
|
154
141
|
color: "#7F7F7F",
|
|
@@ -162,13 +149,10 @@ var CustomPagination = function (_a) {
|
|
|
162
149
|
paddingBottom: 10,
|
|
163
150
|
}, children: "..." }, number_ + index));
|
|
164
151
|
}
|
|
165
|
-
return (_jsx(PaginationNumber, { active: number_ === current, onClick:
|
|
166
|
-
|
|
167
|
-
}, "aria-label": "Page ".concat(number_), children: number_ }, number_));
|
|
168
|
-
}), _jsx(ChevronButton, { onClick: function () { return handleChange(current + 1); }, disabled: current === pageCount, "aria-label": "Next Page", "$right": true, children: _jsx(ChevronIcon, {}) })] }));
|
|
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, {}) })] }));
|
|
169
154
|
}
|
|
170
155
|
// Fallback for other styles (not implemented yet)
|
|
171
156
|
return null;
|
|
172
157
|
};
|
|
173
158
|
export default CustomPagination;
|
|
174
|
-
var templateObject_1, templateObject_2;
|
|
@@ -1,46 +1,30 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
-
var t = {};
|
|
18
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
-
t[p] = s[p];
|
|
20
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
-
t[p[i]] = s[p[i]];
|
|
24
|
-
}
|
|
25
|
-
return t;
|
|
26
|
-
};
|
|
27
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
2
|
import styled from "styled-components";
|
|
29
3
|
import Typography from "../../Typography";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 }) }));
|
|
@@ -8,43 +8,42 @@ import { HiMiniAdjustmentsVertical } from "react-icons/hi2";
|
|
|
8
8
|
import { HiSearch } from "react-icons/hi";
|
|
9
9
|
import { HiOutlineSortAscending, HiOutlineSortDescending, } from "react-icons/hi";
|
|
10
10
|
import { FiSettings } from "react-icons/fi";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
11
|
+
const PrimaryTableControlsRow = ({ sortOptions, searchByPlaceholder = "", searchField = "address", isSortedAscending = true, searchValue = "", selectedSortOption = "", onChange, }) => {
|
|
12
|
+
const onInputChange = (actionEvent) => {
|
|
13
|
+
onChange?.({
|
|
15
14
|
event: "inputChange",
|
|
16
15
|
payload: actionEvent.payload,
|
|
17
16
|
});
|
|
18
17
|
};
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const onSortChange = (value) => {
|
|
19
|
+
const sortActionEvent = {
|
|
21
20
|
event: "primarySortChange",
|
|
22
|
-
payload: { value
|
|
21
|
+
payload: { value },
|
|
23
22
|
};
|
|
24
|
-
onChange
|
|
23
|
+
onChange?.(sortActionEvent);
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const onFilterClick = () => {
|
|
26
|
+
const filterActionEvent = {
|
|
28
27
|
event: "filterClick",
|
|
29
28
|
payload: {},
|
|
30
29
|
};
|
|
31
|
-
onChange
|
|
30
|
+
onChange?.(filterActionEvent);
|
|
32
31
|
};
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const onSettingsClick = () => {
|
|
33
|
+
const settingsActionEvent = {
|
|
35
34
|
event: "settingsClick",
|
|
36
35
|
payload: {},
|
|
37
36
|
};
|
|
38
|
-
onChange
|
|
37
|
+
onChange?.(settingsActionEvent);
|
|
39
38
|
};
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const onOrderClick = () => {
|
|
40
|
+
const ascendingActionEvent = {
|
|
42
41
|
event: "orderClick",
|
|
43
42
|
payload: {
|
|
44
43
|
value: isSortedAscending ? "desc" : "asc",
|
|
45
44
|
},
|
|
46
45
|
};
|
|
47
|
-
onChange
|
|
46
|
+
onChange?.(ascendingActionEvent);
|
|
48
47
|
};
|
|
49
48
|
return (_jsxs("div", { style: {
|
|
50
49
|
display: "flex",
|
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
2
|
import Badge from "../../Badge";
|
|
19
3
|
import Typography from "../../Typography";
|
|
20
4
|
import Tooltip from "../../Tooltip";
|
|
21
5
|
import { getIcon } from "../../../utils/icon-util";
|
|
22
|
-
|
|
23
|
-
var title = _a.title, items = _a.items, onGroupItemClick = _a.onGroupItemClick;
|
|
6
|
+
const GroupItem = ({ title, items, onGroupItemClick }) => {
|
|
24
7
|
if (items.length === 0)
|
|
25
8
|
return null;
|
|
26
9
|
return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { tip: title, children: _jsx("div", { style: {
|
|
@@ -29,37 +12,32 @@ var GroupItem = function (_a) {
|
|
|
29
12
|
alignItems: "center",
|
|
30
13
|
width: 24,
|
|
31
14
|
height: 24,
|
|
32
|
-
}, children: getIcon(title) }) }), _jsx("div", { style: { display: "flex", gap: 4 }, children: items.map(
|
|
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()))) })] }));
|
|
33
16
|
};
|
|
34
|
-
|
|
35
|
-
var groups = _a.groups, onGroupItemClick = _a.onGroupItemClick;
|
|
17
|
+
const GroupsRow = ({ groups, onGroupItemClick }) => {
|
|
36
18
|
if (!groups)
|
|
37
19
|
return null;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
items: items,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
20
|
+
const groupArray = Object.entries(groups).map(([title, items]) => ({
|
|
21
|
+
title,
|
|
22
|
+
items,
|
|
23
|
+
}));
|
|
45
24
|
return (_jsx("div", { style: { display: "flex", gap: 4 }, children: groupArray.length > 0
|
|
46
|
-
? groupArray.map(
|
|
25
|
+
? groupArray.map((group) => (_jsx(GroupItem, { title: group.title, items: group.items, onGroupItemClick: onGroupItemClick }, group.title)))
|
|
47
26
|
: null }));
|
|
48
27
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var groupItemClickEvent = {
|
|
28
|
+
const SecondaryTableControlsRow = ({ groups, totalRecords, onChange, }) => {
|
|
29
|
+
const onGroupItemClick = (title, item) => {
|
|
30
|
+
const groupItemClickEvent = {
|
|
53
31
|
event: "groupItemClick",
|
|
54
|
-
payload: { title
|
|
32
|
+
payload: { title, item },
|
|
55
33
|
};
|
|
56
|
-
onChange
|
|
34
|
+
onChange?.(groupItemClickEvent);
|
|
57
35
|
};
|
|
58
36
|
return (_jsxs("div", { style: {
|
|
59
37
|
display: "flex",
|
|
60
38
|
justifyContent: "space-between",
|
|
61
39
|
alignItems: "flex-end",
|
|
62
40
|
marginTop: 8,
|
|
63
|
-
}, children: [_jsx(GroupsRow, { groups: groups, onGroupItemClick: onGroupItemClick }), totalRecords > 0 ? (_jsx(Typography, { variant: "body2", color: "#6C6C6C", children:
|
|
41
|
+
}, children: [_jsx(GroupsRow, { groups: groups, onGroupItemClick: onGroupItemClick }), totalRecords > 0 ? (_jsx(Typography, { variant: "body2", color: "#6C6C6C", children: `${totalRecords} results` })) : null] }));
|
|
64
42
|
};
|
|
65
43
|
export default SecondaryTableControlsRow;
|