qbs-react-grid 2.1.0 → 2.2.1
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/css/qbs-react-grid.css +1 -1
- package/dist/css/qbs-react-grid.min.css +1 -1
- package/dist/css/qbs-react-grid.min.css.map +1 -1
- package/es/Cell.js +2 -1
- package/es/Pagination.d.ts +3 -0
- package/es/Pagination.js +8 -3
- package/es/index.d.ts +1 -1
- package/es/less/qbs-table.less +148 -4
- package/es/qbsTable/QbsTable.js +56 -34
- package/es/qbsTable/TableCardList.js +47 -31
- package/es/qbsTable/Toolbar.js +15 -11
- package/es/qbsTable/commontypes.d.ts +5 -1
- package/es/qbsTable/labels.d.ts +48 -0
- package/es/qbsTable/labels.js +34 -0
- package/es/qbsTable/utilities/CardComponent.d.ts +2 -0
- package/es/qbsTable/utilities/CardComponent.js +7 -3
- package/es/qbsTable/utilities/CardMenuDropdown.d.ts +2 -0
- package/es/qbsTable/utilities/CardMenuDropdown.js +5 -2
- package/es/qbsTable/utilities/ColumShowHide.d.ts +2 -0
- package/es/qbsTable/utilities/ColumShowHide.js +9 -6
- package/es/qbsTable/utilities/SearchInput.d.ts +1 -0
- package/es/qbsTable/utilities/SearchInput.js +3 -1
- package/es/qbsTable/utilities/tablecalc.d.ts +1 -1
- package/es/qbsTable/utilities/tablecalc.js +7 -2
- package/lib/Cell.js +2 -1
- package/lib/Pagination.d.ts +3 -0
- package/lib/Pagination.js +8 -3
- package/lib/index.d.ts +1 -1
- package/lib/less/qbs-table.less +148 -4
- package/lib/qbsTable/QbsTable.js +56 -34
- package/lib/qbsTable/TableCardList.js +47 -31
- package/lib/qbsTable/Toolbar.js +15 -11
- package/lib/qbsTable/commontypes.d.ts +5 -1
- package/lib/qbsTable/labels.d.ts +48 -0
- package/lib/qbsTable/labels.js +42 -0
- package/lib/qbsTable/utilities/CardComponent.d.ts +2 -0
- package/lib/qbsTable/utilities/CardComponent.js +7 -3
- package/lib/qbsTable/utilities/CardMenuDropdown.d.ts +2 -0
- package/lib/qbsTable/utilities/CardMenuDropdown.js +5 -2
- package/lib/qbsTable/utilities/ColumShowHide.d.ts +2 -0
- package/lib/qbsTable/utilities/ColumShowHide.js +9 -6
- package/lib/qbsTable/utilities/SearchInput.d.ts +1 -0
- package/lib/qbsTable/utilities/SearchInput.js +3 -1
- package/lib/qbsTable/utilities/tablecalc.d.ts +1 -1
- package/lib/qbsTable/utilities/tablecalc.js +7 -2
- package/package.json +1 -1
- package/src/Cell.tsx +3 -1
- package/src/Pagination.tsx +10 -3
- package/src/index.ts +1 -1
- package/src/less/qbs-table.less +148 -4
- package/src/qbsTable/QbsTable.tsx +42 -9
- package/src/qbsTable/TableCardList.tsx +31 -7
- package/src/qbsTable/Toolbar.tsx +17 -10
- package/src/qbsTable/commontypes.ts +7 -0
- package/src/qbsTable/labels.ts +58 -0
- package/src/qbsTable/utilities/CardComponent.tsx +7 -2
- package/src/qbsTable/utilities/CardMenuDropdown.tsx +10 -2
- package/src/qbsTable/utilities/ColumShowHide.tsx +10 -6
- package/src/qbsTable/utilities/SearchInput.tsx +3 -1
- package/src/qbsTable/utilities/tablecalc.ts +8 -2
package/src/qbsTable/Toolbar.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { QbsTableToolbarProps } from './commontypes';
|
|
|
5
5
|
import debounce from './utilities/debounce';
|
|
6
6
|
import { CardView, ContentView, DefaultView, ExpandIcon, TableView } from './utilities/icons';
|
|
7
7
|
import SearchInput from './utilities/SearchInput';
|
|
8
|
+
import { formatSelectedItems, mergeLabels } from './labels';
|
|
8
9
|
import { getRowDisplayRange } from './utilities/tablecalc';
|
|
9
10
|
import TooltipComponent from './utilities/ToolTip';
|
|
10
11
|
|
|
@@ -33,8 +34,10 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
33
34
|
fullWidthView = false,
|
|
34
35
|
setTableFullView,
|
|
35
36
|
setRowViewToggle,
|
|
36
|
-
isFullScreen = false
|
|
37
|
+
isFullScreen = false,
|
|
38
|
+
labels: labelsProp
|
|
37
39
|
}) => {
|
|
40
|
+
const labels = mergeLabels(labelsProp);
|
|
38
41
|
const debouncedOnSearch = useCallback(debounce(onSearch ?? (() => {}), 1000), [onSearch]);
|
|
39
42
|
const [searchParam, setSearchParam] = useState<string | undefined>(searchValue);
|
|
40
43
|
const toolbarRef = useRef<HTMLDivElement>(null);
|
|
@@ -79,7 +82,8 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
79
82
|
<div className="qbs-table-primary-filter">
|
|
80
83
|
{search && (
|
|
81
84
|
<SearchInput
|
|
82
|
-
placeholder={searchPlaceholder ??
|
|
85
|
+
placeholder={searchPlaceholder ?? labels.search}
|
|
86
|
+
searchAriaLabel={labels.searchAriaLabel}
|
|
83
87
|
handleChange={handleChange}
|
|
84
88
|
handleSearch={handleSearch}
|
|
85
89
|
searchValue={searchParam}
|
|
@@ -114,12 +118,12 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
114
118
|
<div className="flex gap-2 qbs-row-switch-cntainer">
|
|
115
119
|
{rowViewToggle && (
|
|
116
120
|
<div className="flex gap-2 table_cell_style">
|
|
117
|
-
<TooltipComponent tableBodyRef={toolbarRef} title={
|
|
121
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToDefaultView}>
|
|
118
122
|
<div onClick={() => setRowViewToggle?.(true)}>
|
|
119
123
|
<DefaultView className={`${defaultRowView ? 'active' : ''}`} />
|
|
120
124
|
</div>
|
|
121
125
|
</TooltipComponent>
|
|
122
|
-
<TooltipComponent tableBodyRef={toolbarRef} title={
|
|
126
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToRelaxedView}>
|
|
123
127
|
<div onClick={() => setRowViewToggle?.(false)}>
|
|
124
128
|
<ContentView className={`${!defaultRowView ? 'active' : ''}`} />
|
|
125
129
|
</div>
|
|
@@ -128,7 +132,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
128
132
|
)}
|
|
129
133
|
{isFullScreen && (
|
|
130
134
|
<div className=" table_full_width">
|
|
131
|
-
<TooltipComponent tableBodyRef={toolbarRef} title={
|
|
135
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToFullScreen}>
|
|
132
136
|
<div onClick={() => setTableFullView?.(!fullWidthView)}>
|
|
133
137
|
<ExpandIcon className={`${fullWidthView ? 'active' : ''}`} />
|
|
134
138
|
</div>
|
|
@@ -140,7 +144,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
140
144
|
|
|
141
145
|
{enableTableToggle && !isMobile && (
|
|
142
146
|
<div className="qbs-table-top-icons flex gap-2">
|
|
143
|
-
<TooltipComponent tableBodyRef={toolbarRef} title={
|
|
147
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToTableView}>
|
|
144
148
|
<div onClick={() => setTableViewToggle?.(true)}>
|
|
145
149
|
<TableView className={`${tableViewToggle ? 'active' : ''}`} />
|
|
146
150
|
</div>
|
|
@@ -149,7 +153,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
149
153
|
<div className="border-r h-4 w-1"></div>
|
|
150
154
|
|
|
151
155
|
<div onClick={() => setTableViewToggle?.(false)}>
|
|
152
|
-
<TooltipComponent tableBodyRef={toolbarRef} title={
|
|
156
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToCardView}>
|
|
153
157
|
<CardView className={`${!tableViewToggle ? 'active' : ''}`} />
|
|
154
158
|
</TooltipComponent>
|
|
155
159
|
</div>
|
|
@@ -175,10 +179,12 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
175
179
|
>
|
|
176
180
|
{checkedKeys && checkedKeys?.length > 0 ? (
|
|
177
181
|
<div className="qbs-table-toolbar-sub-container-start">
|
|
178
|
-
<div className="selected-row">
|
|
182
|
+
<div className="selected-row">
|
|
183
|
+
{formatSelectedItems(labels.selectedItems, checkedKeys?.length ?? 0)}
|
|
184
|
+
</div>
|
|
179
185
|
<div className="selected-row-action">
|
|
180
186
|
<button className="btn" onClick={() => onSelect?.([])}>
|
|
181
|
-
|
|
187
|
+
{labels.clear}
|
|
182
188
|
</button>
|
|
183
189
|
{selectedRowActions?.map((actions, index: number) => (
|
|
184
190
|
<>
|
|
@@ -204,7 +210,8 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
204
210
|
{getRowDisplayRange(
|
|
205
211
|
paginationProps.total ?? 0,
|
|
206
212
|
paginationProps.rowsPerPage ?? 0,
|
|
207
|
-
paginationProps.currentPage ?? 0
|
|
213
|
+
paginationProps.currentPage ?? 0,
|
|
214
|
+
labels.showingRange
|
|
208
215
|
)}
|
|
209
216
|
</div>
|
|
210
217
|
)}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
+
import type { QbsTableLabels } from './labels';
|
|
4
|
+
|
|
5
|
+
export type { QbsTableLabels };
|
|
6
|
+
|
|
3
7
|
interface Content {
|
|
4
8
|
cell: ReactNode | string;
|
|
5
9
|
toolTip?: string;
|
|
@@ -74,6 +78,7 @@ export interface QbsTableProps {
|
|
|
74
78
|
searchValue?: string;
|
|
75
79
|
handleSearchValue?: (value?: string) => void;
|
|
76
80
|
theme?: string;
|
|
81
|
+
rtl?: boolean;
|
|
77
82
|
onRowClick?: (data: any) => void;
|
|
78
83
|
cellBordered?: boolean;
|
|
79
84
|
bordered?: boolean;
|
|
@@ -94,6 +99,7 @@ export interface QbsTableProps {
|
|
|
94
99
|
advancefilter?: ReactElement | ReactNode;
|
|
95
100
|
tableHeaderActions?: ReactElement | ReactNode;
|
|
96
101
|
searchPlaceholder?: string;
|
|
102
|
+
labels?: QbsTableLabels;
|
|
97
103
|
selectedRowActions?: {
|
|
98
104
|
actionTitle?: string;
|
|
99
105
|
action: (checked: (number | string)[]) => void;
|
|
@@ -171,6 +177,7 @@ export interface QbsTableToolbarProps {
|
|
|
171
177
|
dataLength: number;
|
|
172
178
|
headerHeight?: number;
|
|
173
179
|
searchPlaceholder?: string;
|
|
180
|
+
labels?: QbsTableLabels;
|
|
174
181
|
tableView?: boolean;
|
|
175
182
|
enableTableToggle?: boolean;
|
|
176
183
|
tableViewToggle?: boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface QbsTableLabels {
|
|
2
|
+
search?: string;
|
|
3
|
+
searchAriaLabel?: string;
|
|
4
|
+
clear?: string;
|
|
5
|
+
selectedItems?: string;
|
|
6
|
+
switchToDefaultView?: string;
|
|
7
|
+
switchToRelaxedView?: string;
|
|
8
|
+
switchToFullScreen?: string;
|
|
9
|
+
switchToTableView?: string;
|
|
10
|
+
switchToCardView?: string;
|
|
11
|
+
noDataFound?: string;
|
|
12
|
+
showingRange?: (start: number, end: number, total: number) => string;
|
|
13
|
+
itemsPerPage?: string;
|
|
14
|
+
fixedColumns?: string;
|
|
15
|
+
visibleColumns?: string;
|
|
16
|
+
availableColumns?: string;
|
|
17
|
+
resetToDefault?: string;
|
|
18
|
+
save?: string;
|
|
19
|
+
viewMore?: string;
|
|
20
|
+
viewLess?: string;
|
|
21
|
+
actions?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const DEFAULT_QBS_TABLE_LABELS: Required<
|
|
25
|
+
Omit<QbsTableLabels, 'showingRange'>
|
|
26
|
+
> & {
|
|
27
|
+
showingRange: (start: number, end: number, total: number) => string;
|
|
28
|
+
} = {
|
|
29
|
+
search: 'Search',
|
|
30
|
+
searchAriaLabel: 'Search',
|
|
31
|
+
clear: 'Clear',
|
|
32
|
+
selectedItems: 'Selected Items',
|
|
33
|
+
switchToDefaultView: 'Switch to Default View',
|
|
34
|
+
switchToRelaxedView: 'Switch to Relaxed View',
|
|
35
|
+
switchToFullScreen: 'Switch to Full Screen',
|
|
36
|
+
switchToTableView: 'Switch to Table View',
|
|
37
|
+
switchToCardView: 'Switch to Card View',
|
|
38
|
+
noDataFound: 'No Data Found',
|
|
39
|
+
showingRange: (start, end, total) => `Showing ${start} to ${end} of ${total}`,
|
|
40
|
+
itemsPerPage: 'Items per page',
|
|
41
|
+
fixedColumns: 'FIXED COLUMNS',
|
|
42
|
+
visibleColumns: 'VISIBLE COLUMNS',
|
|
43
|
+
availableColumns: 'AVAILABLE COLUMNS',
|
|
44
|
+
resetToDefault: 'Reset to default',
|
|
45
|
+
save: 'Save',
|
|
46
|
+
viewMore: 'View More',
|
|
47
|
+
viewLess: 'View Less',
|
|
48
|
+
actions: 'Actions'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const mergeLabels = (labels?: QbsTableLabels) => ({
|
|
52
|
+
...DEFAULT_QBS_TABLE_LABELS,
|
|
53
|
+
...labels,
|
|
54
|
+
showingRange: labels?.showingRange ?? DEFAULT_QBS_TABLE_LABELS.showingRange
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const formatSelectedItems = (selectedItemsLabel: string, count: number) =>
|
|
58
|
+
`${selectedItemsLabel}(${count}) `;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { QbsColumnProps } from '../commontypes';
|
|
4
|
+
import { mergeLabels, type QbsTableLabels } from '../labels';
|
|
4
5
|
import CardMenuDropdown from './CardMenuDropdown';
|
|
5
6
|
import { handleCellFormat } from './handleFormatCell';
|
|
6
7
|
import { ArrowUpIcon } from './icons';
|
|
@@ -17,6 +18,7 @@ type Props = {
|
|
|
17
18
|
handleMenuActions?: () => void;
|
|
18
19
|
cardColumLimit?: number;
|
|
19
20
|
childDetailHeading?: string;
|
|
21
|
+
labels?: QbsTableLabels;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
const CardComponent: React.FC<Props> = ({
|
|
@@ -27,8 +29,10 @@ const CardComponent: React.FC<Props> = ({
|
|
|
27
29
|
index,
|
|
28
30
|
cardColumLimit = 5,
|
|
29
31
|
handleMenuActions,
|
|
30
|
-
childDetailHeading = ''
|
|
32
|
+
childDetailHeading = '',
|
|
33
|
+
labels: labelsProp
|
|
31
34
|
}) => {
|
|
35
|
+
const labels = mergeLabels(labelsProp);
|
|
32
36
|
const [viewMore, setViewMore] = useState(false);
|
|
33
37
|
const initialDisplayCount = cardColumLimit;
|
|
34
38
|
|
|
@@ -102,13 +106,14 @@ const CardComponent: React.FC<Props> = ({
|
|
|
102
106
|
iconName="more"
|
|
103
107
|
rowIndex={index}
|
|
104
108
|
handleMenuActions={handleMenuActions}
|
|
109
|
+
labels={labels}
|
|
105
110
|
/>
|
|
106
111
|
</div>
|
|
107
112
|
|
|
108
113
|
{columns.length > initialDisplayCount && (
|
|
109
114
|
<TooltipComponent
|
|
110
115
|
tableBodyRef={useCardRef}
|
|
111
|
-
title={viewMore ?
|
|
116
|
+
title={viewMore ? labels.viewLess : labels.viewMore}
|
|
112
117
|
enabled={false}
|
|
113
118
|
>
|
|
114
119
|
<button
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { ActionProps } from '../commontypes';
|
|
3
|
+
import { mergeLabels, type QbsTableLabels } from '../labels';
|
|
3
4
|
import { ThreeDotIcon } from './icons';
|
|
4
5
|
import TooltipComponent from './ToolTip';
|
|
5
6
|
|
|
@@ -11,9 +12,16 @@ type Props = {
|
|
|
11
12
|
dataTheme?: string;
|
|
12
13
|
tableBodyRef: React.RefObject<HTMLDivElement>;
|
|
13
14
|
rowIndex?: number;
|
|
15
|
+
labels?: QbsTableLabels;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
|
-
const CardMenuDropdown: React.FC<Props> = ({
|
|
18
|
+
const CardMenuDropdown: React.FC<Props> = ({
|
|
19
|
+
actionDropDown,
|
|
20
|
+
handleMenuActions,
|
|
21
|
+
rowData,
|
|
22
|
+
labels: labelsProp
|
|
23
|
+
}) => {
|
|
24
|
+
const labels = mergeLabels(labelsProp);
|
|
17
25
|
const [openMenu, setOpenMenu] = useState(false);
|
|
18
26
|
const [menuPositionStyles, setMenuPositionStyles] = useState<{
|
|
19
27
|
top?: string;
|
|
@@ -73,7 +81,7 @@ const CardMenuDropdown: React.FC<Props> = ({ actionDropDown, handleMenuActions,
|
|
|
73
81
|
return (
|
|
74
82
|
<div className="dropdown text-black dark:text-white dark:bg-[#424242] bg-white" ref={menuRef}>
|
|
75
83
|
<button className="dropdown-toggle" onClick={toggleMenu} ref={menuButtonRef}>
|
|
76
|
-
<TooltipComponent title=
|
|
84
|
+
<TooltipComponent title={labels.actions} enabled={false} ref={menuButtonRef}>
|
|
77
85
|
<ThreeDotIcon />
|
|
78
86
|
</TooltipComponent>
|
|
79
87
|
</button>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { QbsColumnProps } from '../commontypes';
|
|
4
|
+
import { mergeLabels, type QbsTableLabels } from '../labels';
|
|
4
5
|
import { SettingsIcon } from './icons';
|
|
5
6
|
|
|
6
7
|
interface ColumnToggleProps {
|
|
@@ -14,6 +15,7 @@ interface ColumnToggleProps {
|
|
|
14
15
|
tableHeight?: number;
|
|
15
16
|
viewMode?: string;
|
|
16
17
|
setViewMode?: (value: string) => void;
|
|
18
|
+
labels?: QbsTableLabels;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
const ColumnToggle: React.FC<ColumnToggleProps> = ({
|
|
@@ -24,8 +26,10 @@ const ColumnToggle: React.FC<ColumnToggleProps> = ({
|
|
|
24
26
|
setIsOpen,
|
|
25
27
|
handleResetColumns,
|
|
26
28
|
handleColumnToggle,
|
|
27
|
-
tableHeight = 450
|
|
29
|
+
tableHeight = 450,
|
|
30
|
+
labels: labelsProp
|
|
28
31
|
}) => {
|
|
32
|
+
const labels = mergeLabels(labelsProp);
|
|
29
33
|
const [draggedItem, setDraggedItem] = useState<number | null>(null);
|
|
30
34
|
const popupRef = useRef<HTMLDivElement | null>(null);
|
|
31
35
|
const [dragOverPosition, setDragOverPosition] = useState<number | null>();
|
|
@@ -185,7 +189,7 @@ const ColumnToggle: React.FC<ColumnToggleProps> = ({
|
|
|
185
189
|
>
|
|
186
190
|
<div className="qbs-table-popup-container">
|
|
187
191
|
<div className="qbs-table-popup-item">
|
|
188
|
-
<div className="qbs-table-popup-label">
|
|
192
|
+
<div className="qbs-table-popup-label">{labels.fixedColumns}</div>
|
|
189
193
|
<div className="qbs-table-columns-container">
|
|
190
194
|
<div className="qbs-table-column">
|
|
191
195
|
{columns.map((column, index) =>
|
|
@@ -196,7 +200,7 @@ const ColumnToggle: React.FC<ColumnToggleProps> = ({
|
|
|
196
200
|
</div>
|
|
197
201
|
<div className="qbs-table-divider"></div>
|
|
198
202
|
<div className="qbs-table-popup-item">
|
|
199
|
-
<div className="qbs-table-popup-label">
|
|
203
|
+
<div className="qbs-table-popup-label">{labels.visibleColumns}</div>
|
|
200
204
|
<div className="qbs-table-columns-container">
|
|
201
205
|
<div className="qbs-table-column">
|
|
202
206
|
{columns.map((column, index) =>
|
|
@@ -209,7 +213,7 @@ const ColumnToggle: React.FC<ColumnToggleProps> = ({
|
|
|
209
213
|
<>
|
|
210
214
|
<div className="qbs-table-divider"></div>
|
|
211
215
|
<div className="qbs-table-popup-item">
|
|
212
|
-
<div className="qbs-table-popup-label">
|
|
216
|
+
<div className="qbs-table-popup-label">{labels.availableColumns}</div>
|
|
213
217
|
<div className="qbs-table-columns-container">
|
|
214
218
|
<div className="qbs-table-column">
|
|
215
219
|
{columns.map((column, index) =>
|
|
@@ -233,10 +237,10 @@ const ColumnToggle: React.FC<ColumnToggleProps> = ({
|
|
|
233
237
|
href="#"
|
|
234
238
|
onClick={() => handleResetColumns?.()}
|
|
235
239
|
>
|
|
236
|
-
|
|
240
|
+
{labels.resetToDefault}
|
|
237
241
|
</a>
|
|
238
242
|
<a className="qbs-table-reset-link" href="#" onClick={() => handleColToggle()}>
|
|
239
|
-
|
|
243
|
+
{labels.save}
|
|
240
244
|
</a>
|
|
241
245
|
</div>
|
|
242
246
|
</>
|
|
@@ -2,12 +2,14 @@ import React, { memo, useCallback } from 'react';
|
|
|
2
2
|
|
|
3
3
|
export interface SearchProps {
|
|
4
4
|
placeholder: string;
|
|
5
|
+
searchAriaLabel?: string;
|
|
5
6
|
handleChange: (value: string) => void;
|
|
6
7
|
searchValue: string | undefined;
|
|
7
8
|
handleSearch: (value?: string) => void;
|
|
8
9
|
}
|
|
9
10
|
const SearchInput: React.FC<SearchProps> = ({
|
|
10
11
|
placeholder,
|
|
12
|
+
searchAriaLabel = 'Search',
|
|
11
13
|
handleChange,
|
|
12
14
|
searchValue,
|
|
13
15
|
handleSearch
|
|
@@ -37,7 +39,7 @@ const SearchInput: React.FC<SearchProps> = ({
|
|
|
37
39
|
placeholder={placeholder}
|
|
38
40
|
value={searchValue ?? ''}
|
|
39
41
|
onChange={handleInputChange}
|
|
40
|
-
aria-label=
|
|
42
|
+
aria-label={searchAriaLabel}
|
|
41
43
|
/>
|
|
42
44
|
<button
|
|
43
45
|
className="search-button absolute left-1 bottom-1.5 bg-white text-grey-dark"
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
export function getRowDisplayRange(
|
|
1
|
+
export function getRowDisplayRange(
|
|
2
|
+
totalRows: number,
|
|
3
|
+
rowsPerPage: number,
|
|
4
|
+
pageNumber: number,
|
|
5
|
+
formatRange: (start: number, end: number, total: number) => string = (start, end, total) =>
|
|
6
|
+
`Showing ${start} to ${end} of ${total}`
|
|
7
|
+
) {
|
|
2
8
|
const start = (pageNumber - 1) * rowsPerPage + 1;
|
|
3
9
|
const end = Math.min(pageNumber * rowsPerPage, totalRows);
|
|
4
10
|
|
|
5
|
-
return
|
|
11
|
+
return formatRange(start ?? 0, end ?? 0, totalRows ?? 0);
|
|
6
12
|
}
|