@indico-data/design-system 2.47.3 → 2.48.0
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/lib/components/index.d.ts +1 -0
- package/lib/components/pagination/Pagination.d.ts +2 -0
- package/lib/components/pagination/Pagination.stories.d.ts +6 -0
- package/lib/components/pagination/__tests__/Pagination.test.d.ts +1 -0
- package/lib/components/pagination/index.d.ts +1 -0
- package/lib/components/pagination/types.d.ts +6 -0
- package/lib/components/table/__tests__/Table.test.d.ts +1 -0
- package/lib/components/table/components/TablePagination.d.ts +9 -0
- package/lib/components/table/components/__tests__/TablePagination.test.d.ts +1 -0
- package/lib/components/table/sampleData.d.ts +2 -0
- package/lib/components/table/types.d.ts +5 -4
- package/lib/index.css +50 -8
- package/lib/index.d.ts +5 -5
- package/lib/index.esm.css +50 -8
- package/lib/index.esm.js +69 -14
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +68 -13
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/pagination/Pagination.mdx +31 -0
- package/src/components/pagination/Pagination.stories.tsx +80 -0
- package/src/components/pagination/Pagination.tsx +117 -0
- package/src/components/pagination/__tests__/Pagination.test.tsx +91 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pagination/styles/Pagination.scss +22 -0
- package/src/components/pagination/types.ts +6 -0
- package/src/components/table/Table.mdx +2 -0
- package/src/components/table/Table.stories.tsx +20 -28
- package/src/components/table/Table.tsx +9 -1
- package/src/components/table/__tests__/Table.test.tsx +10 -0
- package/src/components/table/components/TablePagination.tsx +44 -0
- package/src/components/table/components/__tests__/TablePagination.test.tsx +17 -0
- package/src/components/table/sampleData.ts +110 -0
- package/src/components/table/styles/Table.scss +40 -9
- package/src/components/table/styles/_variables.scss +1 -0
- package/src/components/table/types.ts +6 -6
- package/src/setup/setupIcons.ts +4 -0
- package/src/styles/index.scss +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Pagination } from './Pagination';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface TablePaginationProps {
|
|
2
|
+
rowsPerPage: number;
|
|
3
|
+
rowCount: number;
|
|
4
|
+
onChangePage: (page: number, perPage: number) => void;
|
|
5
|
+
currentPage: number;
|
|
6
|
+
totalEntriesText?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const TablePagination: ({ rowsPerPage, rowCount, onChangePage, currentPage, totalEntriesText, }: TablePaginationProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TableColumn } from './types';
|
|
1
2
|
export interface SampleDataRow {
|
|
2
3
|
name: string;
|
|
3
4
|
class: string;
|
|
@@ -7,3 +8,4 @@ export interface SampleDataRow {
|
|
|
7
8
|
favoriteMeal: string;
|
|
8
9
|
}
|
|
9
10
|
export declare const sampleData: SampleDataRow[];
|
|
11
|
+
export declare const columns: TableColumn<SampleDataRow>[];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Direction as RDTDirection, Alignment as RDTAlignment, TableColumn as RDTTableColumn, IDataTableProps } from 'react-data-table-component';
|
|
2
2
|
export type Direction = `${RDTDirection}`;
|
|
3
3
|
export type Alignment = `${RDTAlignment}`;
|
|
4
4
|
export type TableColumn<T> = RDTTableColumn<T>;
|
|
5
|
-
export
|
|
5
|
+
export interface TableProps<T> extends Omit<IDataTableProps<T>, 'paginationComponent' | 'direction' | 'subHeaderAlign'> {
|
|
6
6
|
isDisabled?: boolean;
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
direction?: Direction;
|
|
9
|
-
subHeaderAlign?:
|
|
9
|
+
subHeaderAlign?: 'left' | 'right' | 'center';
|
|
10
10
|
isFullHeight?: boolean;
|
|
11
|
-
|
|
11
|
+
totalEntriesText?: string;
|
|
12
|
+
}
|
package/lib/index.css
CHANGED
|
@@ -803,6 +803,7 @@ a:hover,
|
|
|
803
803
|
--pf-table-highlighted-color: var(--pf-primary-color);
|
|
804
804
|
--pf-table-highlighted-box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), 0 8px 16px rgba(0, 0, 0, 0.3);
|
|
805
805
|
--pf-table-font-size: var(--pf-font-size-body2);
|
|
806
|
+
--pf-table-pagination-background-color: var(--pf-primary-color-700);
|
|
806
807
|
}
|
|
807
808
|
|
|
808
809
|
.table-loading {
|
|
@@ -817,7 +818,7 @@ a:hover,
|
|
|
817
818
|
|
|
818
819
|
.table {
|
|
819
820
|
border-radius: var(--pf-rounded);
|
|
820
|
-
|
|
821
|
+
background-color: var(--pf-table-background-color);
|
|
821
822
|
/* Striped: alternating background */
|
|
822
823
|
/* Checked: Precedence over striped */
|
|
823
824
|
/* Highlighted: Precedence over checked */
|
|
@@ -833,16 +834,33 @@ a:hover,
|
|
|
833
834
|
color: var(--pf-table-font-color);
|
|
834
835
|
border-radius: var(--pf-rounded) !important;
|
|
835
836
|
border: var(--pf-border-sm) solid var(--pf-table-border-color);
|
|
837
|
+
height: 100%;
|
|
838
|
+
scrollbar-width: thin;
|
|
839
|
+
scrollbar-color: var(--pf-table-border-color) var(--pf-table-background-color);
|
|
840
|
+
}
|
|
841
|
+
.table-body::-webkit-scrollbar {
|
|
842
|
+
width: var(--pf-size-2);
|
|
843
|
+
height: var(--pf-size-2);
|
|
844
|
+
cursor: pointer;
|
|
845
|
+
}
|
|
846
|
+
.table-body::-webkit-scrollbar-track {
|
|
847
|
+
background: var(--pf-table-background-color);
|
|
848
|
+
border-radius: var(--pf-rounded);
|
|
849
|
+
cursor: pointer;
|
|
850
|
+
}
|
|
851
|
+
.table-body::-webkit-scrollbar-thumb {
|
|
852
|
+
background: var(--pf-table-border-color);
|
|
853
|
+
border-radius: var(--pf-rounded);
|
|
854
|
+
cursor: pointer;
|
|
855
|
+
}
|
|
856
|
+
.table-body::-webkit-scrollbar-thumb:hover {
|
|
857
|
+
background: var(--pf-primary-color);
|
|
836
858
|
}
|
|
837
859
|
.table > *:nth-child(3) {
|
|
838
860
|
margin-top: auto;
|
|
839
861
|
background-color: transparent;
|
|
840
862
|
border: none;
|
|
841
863
|
}
|
|
842
|
-
.table > *:nth-child(3) .rdt_Pagination {
|
|
843
|
-
background-color: transparent;
|
|
844
|
-
border: none;
|
|
845
|
-
}
|
|
846
864
|
.table .rdt_Table,
|
|
847
865
|
.table .rdt_TableRow,
|
|
848
866
|
.table .rdt_TableCol,
|
|
@@ -853,8 +871,7 @@ a:hover,
|
|
|
853
871
|
.table .rdt_TableHead,
|
|
854
872
|
.table .rdt_TableHeadRow,
|
|
855
873
|
.table .rdt_TableBody,
|
|
856
|
-
.table .rdt_ExpanderRow
|
|
857
|
-
.table .rdt_Pagination {
|
|
874
|
+
.table .rdt_ExpanderRow {
|
|
858
875
|
background-color: var(--pf-table-background-color);
|
|
859
876
|
color: var(--pf-table-font-color);
|
|
860
877
|
}
|
|
@@ -866,7 +883,8 @@ a:hover,
|
|
|
866
883
|
}
|
|
867
884
|
.table .rdt_TableHeader {
|
|
868
885
|
border-radius: var(--pf-rounded) 0;
|
|
869
|
-
border
|
|
886
|
+
border: var(--pf-border-sm) solid var(--pf-table-border-color);
|
|
887
|
+
border-bottom: none;
|
|
870
888
|
}
|
|
871
889
|
.table .rdt_TableHeadRow > :first-child,
|
|
872
890
|
.table .rdt_TableRow > :first-child {
|
|
@@ -908,6 +926,13 @@ a:hover,
|
|
|
908
926
|
background-color: var(--pf-table-highlighted-color) !important;
|
|
909
927
|
}
|
|
910
928
|
|
|
929
|
+
.table__pagination {
|
|
930
|
+
padding-bottom: var(--pf-padding-4);
|
|
931
|
+
padding-top: var(--pf-padding-4);
|
|
932
|
+
background-color: var(--pf-table-pagination-background-color);
|
|
933
|
+
padding-left: var(--pf-padding-4);
|
|
934
|
+
}
|
|
935
|
+
|
|
911
936
|
.input {
|
|
912
937
|
padding: 10px;
|
|
913
938
|
}
|
|
@@ -1901,6 +1926,23 @@ form {
|
|
|
1901
1926
|
text-align: right;
|
|
1902
1927
|
}
|
|
1903
1928
|
|
|
1929
|
+
.pagination .form-control {
|
|
1930
|
+
margin-bottom: 0;
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
.pagination__current-page {
|
|
1934
|
+
max-width: 50px;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
.pagination__current-page-input {
|
|
1938
|
+
text-align: center;
|
|
1939
|
+
font-weight: var(--pf-font-weight-heavy);
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
.pagination .pagination__current-page-input.has-error {
|
|
1943
|
+
border-color: var(--pf-error-color);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1904
1946
|
:root [data-theme=light] {
|
|
1905
1947
|
--pf-pill-primary-background-color: var(--pf-primary-color);
|
|
1906
1948
|
--pf-pill-primary-font-color: var(--pf-white-color);
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from '@floating-ui/react-dom';
|
|
|
4
4
|
import React$1, { CSSProperties, MouseEventHandler, ReactElement } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { ContainerProps, RowProps, ColProps } from 'react-grid-system';
|
|
7
|
-
import {
|
|
7
|
+
import { IDataTableProps, Direction as Direction$1 } from 'react-data-table-component';
|
|
8
8
|
import { Props as Props$7 } from 'react-select';
|
|
9
9
|
import { DateRange, OnSelectHandler, Mode, CustomComponents, Matcher, Formatters, MonthChangeEventHandler, DayEventHandler } from 'react-day-picker';
|
|
10
10
|
|
|
@@ -184,14 +184,14 @@ type SelectOption = {
|
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
type Direction = `${Direction$1}`;
|
|
187
|
-
|
|
188
|
-
type TableProps<T> = Omit<TableProps$1<T>, 'disabled' | 'progressPending' | 'direction' | 'subHeaderAlign'> & {
|
|
187
|
+
interface TableProps<T> extends Omit<IDataTableProps<T>, 'paginationComponent' | 'direction' | 'subHeaderAlign'> {
|
|
189
188
|
isDisabled?: boolean;
|
|
190
189
|
isLoading?: boolean;
|
|
191
190
|
direction?: Direction;
|
|
192
|
-
subHeaderAlign?:
|
|
191
|
+
subHeaderAlign?: 'left' | 'right' | 'center';
|
|
193
192
|
isFullHeight?: boolean;
|
|
194
|
-
|
|
193
|
+
totalEntriesText?: string;
|
|
194
|
+
}
|
|
195
195
|
|
|
196
196
|
type PillSize = 'sm' | 'md' | 'lg';
|
|
197
197
|
type PillColor = SemanticColor | 'neutral';
|
package/lib/index.esm.css
CHANGED
|
@@ -803,6 +803,7 @@ a:hover,
|
|
|
803
803
|
--pf-table-highlighted-color: var(--pf-primary-color);
|
|
804
804
|
--pf-table-highlighted-box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), 0 8px 16px rgba(0, 0, 0, 0.3);
|
|
805
805
|
--pf-table-font-size: var(--pf-font-size-body2);
|
|
806
|
+
--pf-table-pagination-background-color: var(--pf-primary-color-700);
|
|
806
807
|
}
|
|
807
808
|
|
|
808
809
|
.table-loading {
|
|
@@ -817,7 +818,7 @@ a:hover,
|
|
|
817
818
|
|
|
818
819
|
.table {
|
|
819
820
|
border-radius: var(--pf-rounded);
|
|
820
|
-
|
|
821
|
+
background-color: var(--pf-table-background-color);
|
|
821
822
|
/* Striped: alternating background */
|
|
822
823
|
/* Checked: Precedence over striped */
|
|
823
824
|
/* Highlighted: Precedence over checked */
|
|
@@ -833,16 +834,33 @@ a:hover,
|
|
|
833
834
|
color: var(--pf-table-font-color);
|
|
834
835
|
border-radius: var(--pf-rounded) !important;
|
|
835
836
|
border: var(--pf-border-sm) solid var(--pf-table-border-color);
|
|
837
|
+
height: 100%;
|
|
838
|
+
scrollbar-width: thin;
|
|
839
|
+
scrollbar-color: var(--pf-table-border-color) var(--pf-table-background-color);
|
|
840
|
+
}
|
|
841
|
+
.table-body::-webkit-scrollbar {
|
|
842
|
+
width: var(--pf-size-2);
|
|
843
|
+
height: var(--pf-size-2);
|
|
844
|
+
cursor: pointer;
|
|
845
|
+
}
|
|
846
|
+
.table-body::-webkit-scrollbar-track {
|
|
847
|
+
background: var(--pf-table-background-color);
|
|
848
|
+
border-radius: var(--pf-rounded);
|
|
849
|
+
cursor: pointer;
|
|
850
|
+
}
|
|
851
|
+
.table-body::-webkit-scrollbar-thumb {
|
|
852
|
+
background: var(--pf-table-border-color);
|
|
853
|
+
border-radius: var(--pf-rounded);
|
|
854
|
+
cursor: pointer;
|
|
855
|
+
}
|
|
856
|
+
.table-body::-webkit-scrollbar-thumb:hover {
|
|
857
|
+
background: var(--pf-primary-color);
|
|
836
858
|
}
|
|
837
859
|
.table > *:nth-child(3) {
|
|
838
860
|
margin-top: auto;
|
|
839
861
|
background-color: transparent;
|
|
840
862
|
border: none;
|
|
841
863
|
}
|
|
842
|
-
.table > *:nth-child(3) .rdt_Pagination {
|
|
843
|
-
background-color: transparent;
|
|
844
|
-
border: none;
|
|
845
|
-
}
|
|
846
864
|
.table .rdt_Table,
|
|
847
865
|
.table .rdt_TableRow,
|
|
848
866
|
.table .rdt_TableCol,
|
|
@@ -853,8 +871,7 @@ a:hover,
|
|
|
853
871
|
.table .rdt_TableHead,
|
|
854
872
|
.table .rdt_TableHeadRow,
|
|
855
873
|
.table .rdt_TableBody,
|
|
856
|
-
.table .rdt_ExpanderRow
|
|
857
|
-
.table .rdt_Pagination {
|
|
874
|
+
.table .rdt_ExpanderRow {
|
|
858
875
|
background-color: var(--pf-table-background-color);
|
|
859
876
|
color: var(--pf-table-font-color);
|
|
860
877
|
}
|
|
@@ -866,7 +883,8 @@ a:hover,
|
|
|
866
883
|
}
|
|
867
884
|
.table .rdt_TableHeader {
|
|
868
885
|
border-radius: var(--pf-rounded) 0;
|
|
869
|
-
border
|
|
886
|
+
border: var(--pf-border-sm) solid var(--pf-table-border-color);
|
|
887
|
+
border-bottom: none;
|
|
870
888
|
}
|
|
871
889
|
.table .rdt_TableHeadRow > :first-child,
|
|
872
890
|
.table .rdt_TableRow > :first-child {
|
|
@@ -908,6 +926,13 @@ a:hover,
|
|
|
908
926
|
background-color: var(--pf-table-highlighted-color) !important;
|
|
909
927
|
}
|
|
910
928
|
|
|
929
|
+
.table__pagination {
|
|
930
|
+
padding-bottom: var(--pf-padding-4);
|
|
931
|
+
padding-top: var(--pf-padding-4);
|
|
932
|
+
background-color: var(--pf-table-pagination-background-color);
|
|
933
|
+
padding-left: var(--pf-padding-4);
|
|
934
|
+
}
|
|
935
|
+
|
|
911
936
|
.input {
|
|
912
937
|
padding: 10px;
|
|
913
938
|
}
|
|
@@ -1901,6 +1926,23 @@ form {
|
|
|
1901
1926
|
text-align: right;
|
|
1902
1927
|
}
|
|
1903
1928
|
|
|
1929
|
+
.pagination .form-control {
|
|
1930
|
+
margin-bottom: 0;
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
.pagination__current-page {
|
|
1934
|
+
max-width: 50px;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
.pagination__current-page-input {
|
|
1938
|
+
text-align: center;
|
|
1939
|
+
font-weight: var(--pf-font-weight-heavy);
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
.pagination .pagination__current-page-input.has-error {
|
|
1943
|
+
border-color: var(--pf-error-color);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1904
1946
|
:root [data-theme=light] {
|
|
1905
1947
|
--pf-pill-primary-background-color: var(--pf-primary-color);
|
|
1906
1948
|
--pf-pill-primary-font-color: var(--pf-white-color);
|
package/lib/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { library, findIconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
2
|
-
import { faArrowDown, faArrowRight, faArrowLeft, faCalculator, faCheck, faCircleNotch, faMountainSun, faRocket, faWind, faEyeSlash, faEye, faCaretUp, faCaretDown, faTag, faPencilAlt, faSearch, faCog, faFileDownload, faQuestionCircle, faCopy, faXmark } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { faArrowDown, faArrowRight, faArrowLeft, faCalculator, faCheck, faCircleNotch, faMountainSun, faRocket, faWind, faEyeSlash, faEye, faCaretUp, faCaretDown, faTag, faPencilAlt, faSearch, faCog, faFileDownload, faQuestionCircle, faCopy, faXmark, faChevronLeft, faChevronRight } from '@fortawesome/free-solid-svg-icons';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { useLayoutEffect, useEffect, createContext, useState, useRef, useContext, useCallback, useImperativeHandle, forwardRef, useMemo, isValidElement, useId as useId$1 } from 'react';
|
|
@@ -205,7 +205,7 @@ const registerFontAwesomeIcons = (...icons) => {
|
|
|
205
205
|
library.add(...icons);
|
|
206
206
|
};
|
|
207
207
|
// Register the icons used directly in design system components
|
|
208
|
-
registerFontAwesomeIcons(faArrowDown, faArrowRight, faArrowLeft, faCalculator, faCheck, faCircleNotch, faMountainSun, faRocket, faWind, faEyeSlash, faEye, faCaretUp, faCaretDown, faTag, faPencilAlt, faSearch, faCog, faFileDownload, faQuestionCircle, faCopy, faXmark,
|
|
208
|
+
registerFontAwesomeIcons(faArrowDown, faArrowRight, faArrowLeft, faCalculator, faCheck, faCircleNotch, faMountainSun, faRocket, faWind, faEyeSlash, faEye, faCaretUp, faCaretDown, faTag, faPencilAlt, faSearch, faCog, faFileDownload, faQuestionCircle, faCopy, faXmark, faChevronLeft, faChevronRight,
|
|
209
209
|
// backwards compat, don't require registration of custom indicons
|
|
210
210
|
// might want to consider doing so in the future
|
|
211
211
|
...indiconDefinitions);
|
|
@@ -7168,18 +7168,6 @@ const LoadingComponent = () => {
|
|
|
7168
7168
|
return jsx("div", { className: "table-loading", children: "Loading..." });
|
|
7169
7169
|
};
|
|
7170
7170
|
|
|
7171
|
-
const Table = (props) => {
|
|
7172
|
-
const { responsive = true, direction = 'auto', keyField = 'id', striped = false, noDataComponent = 'built-in', isDisabled, isLoading, isFullHeight = false, subHeaderAlign = 'left', className } = props, rest = __rest(props, ["responsive", "direction", "keyField", "striped", "noDataComponent", "isDisabled", "isLoading", "isFullHeight", "subHeaderAlign", "className"]);
|
|
7173
|
-
const combinedClassName = classNames(className, {
|
|
7174
|
-
'table--striped': striped,
|
|
7175
|
-
'table-body': true,
|
|
7176
|
-
});
|
|
7177
|
-
const tableWrapperClassName = classNames('table', {
|
|
7178
|
-
'table--full-height': isFullHeight,
|
|
7179
|
-
});
|
|
7180
|
-
return (jsx("div", { className: tableWrapperClassName, children: jsx(Xe, Object.assign({ responsive: responsive, direction: direction, subHeaderAlign: subHeaderAlign, keyField: keyField, striped: striped, className: combinedClassName, disabled: isDisabled, noDataComponent: noDataComponent, progressPending: isLoading, progressComponent: jsx(LoadingComponent, {}) }, rest)) }));
|
|
7181
|
-
};
|
|
7182
|
-
|
|
7183
7171
|
const Label = ({ label, name, isRequired }) => {
|
|
7184
7172
|
return (jsx("div", { "data-testid": `${name}-testId`, className: `form-label`, children: jsxs("label", { htmlFor: `${name}`, children: [label, isRequired ? jsx("span", { className: "text-error", children: " *" }) : ''] }) }));
|
|
7185
7173
|
};
|
|
@@ -7213,6 +7201,73 @@ const Input = React__default.forwardRef((_a, ref) => {
|
|
|
7213
7201
|
});
|
|
7214
7202
|
const LabeledInput = withLabel(Input);
|
|
7215
7203
|
|
|
7204
|
+
const Pagination = (_a) => {
|
|
7205
|
+
var { totalPages, currentPage = 1, onChange, className } = _a, rest = __rest(_a, ["totalPages", "currentPage", "onChange", "className"]);
|
|
7206
|
+
const [inputValue, setInputValue] = useState(currentPage.toString());
|
|
7207
|
+
const totalPagesText = `of ${totalPages}`;
|
|
7208
|
+
const classes = classNames('pagination', className);
|
|
7209
|
+
useEffect(() => {
|
|
7210
|
+
setInputValue(currentPage.toString());
|
|
7211
|
+
}, [currentPage]);
|
|
7212
|
+
const handleNextPage = () => {
|
|
7213
|
+
if (currentPage < totalPages) {
|
|
7214
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(currentPage + 1);
|
|
7215
|
+
}
|
|
7216
|
+
};
|
|
7217
|
+
const handlePreviousPage = () => {
|
|
7218
|
+
if (currentPage > 1) {
|
|
7219
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(currentPage - 1);
|
|
7220
|
+
}
|
|
7221
|
+
};
|
|
7222
|
+
const validateAndUpdatePage = (value) => {
|
|
7223
|
+
// If empty or invalid, reset to current page
|
|
7224
|
+
if (!value) {
|
|
7225
|
+
setInputValue(currentPage.toString());
|
|
7226
|
+
return;
|
|
7227
|
+
}
|
|
7228
|
+
const page = Number(value);
|
|
7229
|
+
if (!isNaN(page) && page > 0 && page <= totalPages) {
|
|
7230
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(page);
|
|
7231
|
+
}
|
|
7232
|
+
else {
|
|
7233
|
+
setInputValue(currentPage.toString());
|
|
7234
|
+
}
|
|
7235
|
+
};
|
|
7236
|
+
const isNextButtonDisabled = currentPage === totalPages;
|
|
7237
|
+
const isPreviousButtonDisabled = currentPage === 1;
|
|
7238
|
+
const hasError = Number(inputValue) > totalPages || Number(inputValue) < 1;
|
|
7239
|
+
return (jsx("div", Object.assign({ className: classes }, rest, { children: jsx(Container, { children: jsxs(Row, { gutterWidth: 12, align: "center", children: [jsx(Col, { xs: "content", children: jsx("div", { className: "pagination__previous", children: jsx(Button$1, { "data-testid": "pagination-previous-button", ariaLabel: "Previous Page", variant: "link", onClick: handlePreviousPage, iconLeft: "chevron-left", isDisabled: isPreviousButtonDisabled }) }) }), jsx(Col, { xs: "content", children: jsx("div", { className: "pagination__current-page", children: jsx(LabeledInput, { "data-testid": "pagination-current-page-input", className: classNames('pagination__current-page-input', {
|
|
7240
|
+
'has-error': hasError,
|
|
7241
|
+
}), value: inputValue, name: "currentPage", label: "Current Page", hasHiddenLabel: true, onKeyDown: (e) => {
|
|
7242
|
+
if (e.key === 'Enter') {
|
|
7243
|
+
validateAndUpdatePage(e.currentTarget.value);
|
|
7244
|
+
}
|
|
7245
|
+
}, onChange: (e) => {
|
|
7246
|
+
const value = e.currentTarget.value;
|
|
7247
|
+
// Allow empty value or numbers
|
|
7248
|
+
if (value === '' || /^\d*$/.test(value)) {
|
|
7249
|
+
setInputValue(value);
|
|
7250
|
+
}
|
|
7251
|
+
}, onBlur: (e) => validateAndUpdatePage(e.currentTarget.value) }) }) }), jsx(Col, { xs: "content", children: jsx("p", { className: "pagination__page-total", children: totalPagesText }) }), jsx(Col, { xs: "content", children: jsx("div", { className: "pagination__next", children: jsx(Button$1, { "data-testid": "pagination-next-button", ariaLabel: "Next Page", variant: "link", onClick: handleNextPage, iconLeft: "chevron-right", isDisabled: isNextButtonDisabled }) }) })] }) }) })));
|
|
7252
|
+
};
|
|
7253
|
+
|
|
7254
|
+
const TablePagination = ({ rowsPerPage, rowCount, onChangePage, currentPage, totalEntriesText, }) => {
|
|
7255
|
+
const totalPages = Math.ceil(rowCount / rowsPerPage);
|
|
7256
|
+
return (jsx("div", { className: "table__pagination", children: jsxs(Row, { align: "center", justify: "between", children: [jsx(Col, { xs: "content", children: totalEntriesText && (jsx("span", { "data-testid": "table-pagination-total-entries", className: "table__pagination-total-entries", children: totalEntriesText })) }), jsx(Col, { xs: "content", children: jsx(Pagination, { "data-testid": "table-pagination-component", totalPages: totalPages, currentPage: currentPage, onChange: (page) => onChangePage(page, rowsPerPage) }) })] }) }));
|
|
7257
|
+
};
|
|
7258
|
+
|
|
7259
|
+
const Table = (props) => {
|
|
7260
|
+
const { responsive = true, direction = 'auto', keyField = 'id', striped = false, noDataComponent = 'built-in', isDisabled, isLoading, isFullHeight = false, subHeaderAlign = 'left', className, paginationTotalRows, totalEntriesText } = props, rest = __rest(props, ["responsive", "direction", "keyField", "striped", "noDataComponent", "isDisabled", "isLoading", "isFullHeight", "subHeaderAlign", "className", "paginationTotalRows", "totalEntriesText"]);
|
|
7261
|
+
const combinedClassName = classNames(className, {
|
|
7262
|
+
'table--striped': striped,
|
|
7263
|
+
'table-body': true,
|
|
7264
|
+
});
|
|
7265
|
+
const tableWrapperClassName = classNames('table', {
|
|
7266
|
+
'table--full-height': isFullHeight,
|
|
7267
|
+
});
|
|
7268
|
+
return (jsx("div", { className: tableWrapperClassName, "data-testid": "table", children: jsx(Xe, Object.assign({ responsive: responsive, direction: direction, subHeaderAlign: subHeaderAlign, keyField: keyField, striped: striped, className: combinedClassName, disabled: isDisabled, noDataComponent: noDataComponent, progressPending: isLoading, progressComponent: jsx(LoadingComponent, {}), pagination: true, paginationComponent: (props) => (jsx(TablePagination, Object.assign({}, props, { totalEntriesText: totalEntriesText }))), paginationTotalRows: paginationTotalRows }, rest)) }));
|
|
7269
|
+
};
|
|
7270
|
+
|
|
7216
7271
|
const Radio = React__default.forwardRef((_a, ref) => {
|
|
7217
7272
|
var { id, label, name, value, onChange, isDisabled } = _a, rest = __rest(_a, ["id", "label", "name", "value", "onChange", "isDisabled"]);
|
|
7218
7273
|
return (jsx("div", { className: "form-control", children: jsxs("div", { className: "radio-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-radio-input-${name}`, className: "radio-input", type: "radio", id: id, name: name, value: value, disabled: isDisabled, ref: ref, onChange: onChange, tabIndex: 0, "aria-describedby": id, "aria-label": label }, rest)), jsx("label", { htmlFor: id, className: "radio-input-label", "data-testid": `label-radio-input-${name}`, children: label })] }) }));
|