qbs-react-grid 2.0.16 → 2.2.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/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/Pagination.d.ts +3 -0
- package/es/Pagination.js +8 -3
- package/es/index.d.ts +1 -1
- package/es/less/qbs-table.less +95 -4
- package/es/qbsTable/QbsTable.js +53 -34
- package/es/qbsTable/TableCardList.js +47 -31
- package/es/qbsTable/Toolbar.js +19 -13
- package/es/qbsTable/commontypes.d.ts +9 -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/Pagination.d.ts +3 -0
- package/lib/Pagination.js +8 -3
- package/lib/index.d.ts +1 -1
- package/lib/less/qbs-table.less +95 -4
- package/lib/qbsTable/QbsTable.js +53 -34
- package/lib/qbsTable/TableCardList.js +47 -31
- package/lib/qbsTable/Toolbar.js +19 -13
- package/lib/qbsTable/commontypes.d.ts +9 -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/Pagination.tsx +10 -3
- package/src/index.ts +1 -1
- package/src/less/qbs-table.less +95 -4
- package/src/qbsTable/QbsTable.tsx +35 -9
- package/src/qbsTable/TableCardList.tsx +31 -7
- package/src/qbsTable/Toolbar.tsx +20 -12
- package/src/qbsTable/commontypes.ts +13 -2
- 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/Pagination.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { FC, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import CustomSelect from './customSelect';
|
|
4
|
+
import { mergeLabels, type QbsTableLabels } from './qbsTable/labels';
|
|
4
5
|
import { getRowDisplayRange } from './qbsTable/utilities/tablecalc';
|
|
5
6
|
|
|
6
7
|
// Import the custom select component
|
|
@@ -15,6 +16,8 @@ type PageProps = {
|
|
|
15
16
|
onRowsPerPage?: (row: number, page: number) => void;
|
|
16
17
|
onPagination?: (row: number, page: number) => void;
|
|
17
18
|
};
|
|
19
|
+
labels?: QbsTableLabels;
|
|
20
|
+
dataTheme?: string;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
const PageIndex = ({ currentPage, handleFirst, pageCount }) => {
|
|
@@ -52,7 +55,8 @@ const PageIndex = ({ currentPage, handleFirst, pageCount }) => {
|
|
|
52
55
|
return <>{renderPageNumbers()}</>;
|
|
53
56
|
};
|
|
54
57
|
|
|
55
|
-
const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
58
|
+
const Pagination: FC<PageProps> = ({ paginationProps, labels: labelsProp, dataTheme }) => {
|
|
59
|
+
const labels = mergeLabels(labelsProp);
|
|
56
60
|
const {
|
|
57
61
|
dropOptions = [10, 20, 50, 100, 200],
|
|
58
62
|
currentPage = 1,
|
|
@@ -96,9 +100,12 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
96
100
|
return (
|
|
97
101
|
<div
|
|
98
102
|
className="qbs-table-custom-pagination"
|
|
103
|
+
data-theme={dataTheme}
|
|
99
104
|
style={{ display: 'flex', justifyContent: 'space-between' }}
|
|
100
105
|
>
|
|
101
|
-
<div className="rows-count">
|
|
106
|
+
<div className="rows-count">
|
|
107
|
+
{getRowDisplayRange(total, rowsPerPageState, currentPage, labels.showingRange)}
|
|
108
|
+
</div>
|
|
102
109
|
<div className="qbs-table-pagination-right-block">
|
|
103
110
|
<button
|
|
104
111
|
className="qbs-table-icon-container"
|
|
@@ -194,7 +201,7 @@ const Pagination: FC<PageProps> = ({ paginationProps }) => {
|
|
|
194
201
|
</button>
|
|
195
202
|
</div>
|
|
196
203
|
<div className="qbs-table-pagination-flexBox">
|
|
197
|
-
<span className="qbs-table-pagination-text">
|
|
204
|
+
<span className="qbs-table-pagination-text">{labels.itemsPerPage}</span>
|
|
198
205
|
<CustomSelect
|
|
199
206
|
options={dropData}
|
|
200
207
|
selectedValue={rowsPerPageState}
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type { ColumnProps } from './Column';
|
|
|
11
11
|
export type { CellProps } from './Cell';
|
|
12
12
|
export type { HeaderCellProps } from './HeaderCell';
|
|
13
13
|
export type { ColumnGroupProps } from './ColumnGroup';
|
|
14
|
-
export type { QbsTableProps } from './qbsTable/commontypes';
|
|
14
|
+
export type { QbsTableProps, QbsTableLabels } from './qbsTable/commontypes';
|
|
15
15
|
export type {
|
|
16
16
|
StandardProps,
|
|
17
17
|
SortType,
|
package/src/less/qbs-table.less
CHANGED
|
@@ -104,12 +104,103 @@
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
.qbs-table[data-theme='dark'] {
|
|
107
|
-
background-color: #
|
|
108
|
-
color: #
|
|
107
|
+
background-color: #1f1f1f;
|
|
108
|
+
color: #f5f5f5;
|
|
109
|
+
|
|
110
|
+
.qbs-table-border-wrap {
|
|
111
|
+
border-color: #3d3d3d;
|
|
112
|
+
background: #262626;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.qbs-table-toolbar-container,
|
|
116
|
+
.qbs-table-toolbar,
|
|
117
|
+
.qbs-table-toolbar-sub-container,
|
|
118
|
+
.sub-qbs-table-toolbar {
|
|
119
|
+
color: #f5f5f5;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.qbs-table-search-container {
|
|
123
|
+
.input {
|
|
124
|
+
border-color: #4a4a4a;
|
|
125
|
+
background: #2d2d2d;
|
|
126
|
+
color: #f5f5f5;
|
|
127
|
+
|
|
128
|
+
&:hover,
|
|
129
|
+
&:focus {
|
|
130
|
+
border-color: #6b6b6b;
|
|
131
|
+
background: #2d2d2d;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.search-button,
|
|
136
|
+
.close-button {
|
|
137
|
+
color: #d1d1d1;
|
|
138
|
+
background-color: transparent;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.qbs-table-column-popup,
|
|
143
|
+
.qbs-table-popup-container {
|
|
144
|
+
background: #2d2d2d;
|
|
145
|
+
color: #f5f5f5;
|
|
146
|
+
border-color: #4a4a4a;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.qbs-table-popup-label,
|
|
150
|
+
.qbs-table-popup-value,
|
|
151
|
+
.qbs-table-reset-link {
|
|
152
|
+
color: #f5f5f5;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.qbs-table-custom-pagination,
|
|
156
|
+
.qbs-table-pagination-text,
|
|
157
|
+
.rows-count {
|
|
158
|
+
color: #f5f5f5;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.qbs-table-icon-container svg path {
|
|
162
|
+
stroke: #e5e5e5;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.custom-select-trigger,
|
|
166
|
+
.custom-select-options {
|
|
167
|
+
background: #2d2d2d;
|
|
168
|
+
color: #f5f5f5;
|
|
169
|
+
border-color: #4a4a4a;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.qbs-card-container {
|
|
173
|
+
border-color: #4a4a4a;
|
|
174
|
+
background: #262626;
|
|
175
|
+
color: #f5f5f5;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.nodata-title {
|
|
179
|
+
color: #f5f5f5;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.tooltiptext {
|
|
183
|
+
background-color: #3d3d3d;
|
|
184
|
+
color: #fff;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.qbs-table-custom-pagination[data-theme='dark'] {
|
|
189
|
+
color: #f5f5f5;
|
|
190
|
+
|
|
191
|
+
.rows-count,
|
|
192
|
+
.qbs-table-pagination-text {
|
|
193
|
+
color: #f5f5f5;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.qbs-table-icon-container svg path {
|
|
197
|
+
stroke: #e5e5e5;
|
|
198
|
+
}
|
|
109
199
|
}
|
|
200
|
+
|
|
110
201
|
.rs-table-cell-content[data-theme='dark'] {
|
|
111
|
-
background-color: #
|
|
112
|
-
color: #
|
|
202
|
+
background-color: #262626;
|
|
203
|
+
color: #f5f5f5;
|
|
113
204
|
}
|
|
114
205
|
/* Dropdown container */
|
|
115
206
|
.qbs-table-menu-dropdown {
|
|
@@ -8,6 +8,7 @@ import Pagination from '../Pagination';
|
|
|
8
8
|
import Table from '../Table';
|
|
9
9
|
import useResponsiveStore from '../utils/useResponsiveStore';
|
|
10
10
|
import { QbsColumnProps, QbsTableProps } from './commontypes';
|
|
11
|
+
import { mergeLabels } from './labels';
|
|
11
12
|
import {
|
|
12
13
|
ActionCell,
|
|
13
14
|
CheckCell,
|
|
@@ -105,12 +106,18 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
105
106
|
setRowViewToggle,
|
|
106
107
|
dropType = 'horizondal',
|
|
107
108
|
rowHeight,
|
|
108
|
-
isFullScreen
|
|
109
|
+
isFullScreen,
|
|
110
|
+
showHeader = true,
|
|
111
|
+
labels: labelsProp
|
|
109
112
|
}) => {
|
|
113
|
+
const labels = useMemo(() => mergeLabels(labelsProp), [labelsProp]);
|
|
110
114
|
const [loading, setLoading] = useState(false);
|
|
111
115
|
const [columns, setColumns] = useState(propColumn);
|
|
112
116
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
113
|
-
const dataTheme = useMemo(
|
|
117
|
+
const dataTheme = useMemo(
|
|
118
|
+
() => theme ?? (typeof localStorage !== 'undefined' ? localStorage.getItem('theme') : null) ?? 'light',
|
|
119
|
+
[theme]
|
|
120
|
+
);
|
|
114
121
|
const [isOpen, setIsOpen] = useState(false);
|
|
115
122
|
const prevColumns = useRef<any | null>(null);
|
|
116
123
|
const [tableViewToggle, setTableViewToggle] = useState(tableView);
|
|
@@ -272,11 +279,25 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
272
279
|
fullWidthView: fullWidthView,
|
|
273
280
|
setTableFullView: setTableFullView,
|
|
274
281
|
setRowViewToggle: setRowViewToggle,
|
|
275
|
-
isFullScreen: isFullScreen
|
|
282
|
+
isFullScreen: isFullScreen,
|
|
283
|
+
labels
|
|
276
284
|
};
|
|
277
|
-
const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
|
|
278
285
|
|
|
279
286
|
useEffect(() => {
|
|
287
|
+
if (!dataTheme || typeof document === 'undefined') return;
|
|
288
|
+
|
|
289
|
+
document.body.setAttribute('data-theme', dataTheme === 'dark' ? 'dark' : 'light');
|
|
290
|
+
document.documentElement.dataset.theme = dataTheme;
|
|
291
|
+
}, [dataTheme]);
|
|
292
|
+
|
|
293
|
+
const themeToggle = useMemo(
|
|
294
|
+
() => (typeof document !== 'undefined' ? document.getElementById('themeToggle') : null),
|
|
295
|
+
[]
|
|
296
|
+
) as HTMLInputElement | null;
|
|
297
|
+
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
if (theme || typeof document === 'undefined') return;
|
|
300
|
+
|
|
280
301
|
const handleThemeToggle = () => {
|
|
281
302
|
if (themeToggle?.checked) {
|
|
282
303
|
document.body.setAttribute('data-theme', 'dark');
|
|
@@ -301,7 +322,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
301
322
|
themeToggle?.removeEventListener('change', handleThemeToggle);
|
|
302
323
|
document.removeEventListener('DOMContentLoaded', handleDOMContentLoaded);
|
|
303
324
|
};
|
|
304
|
-
}, [themeToggle]);
|
|
325
|
+
}, [theme, themeToggle]);
|
|
305
326
|
|
|
306
327
|
const handleExpanded = useCallback(
|
|
307
328
|
(rowData: any) => {
|
|
@@ -637,7 +658,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
637
658
|
renderEmpty ? (
|
|
638
659
|
renderEmpty(info)
|
|
639
660
|
) : (
|
|
640
|
-
<NoData title={emptyTitle ??
|
|
661
|
+
<NoData title={emptyTitle ?? labels.noDataFound} subtitle={emptySubTitle} />
|
|
641
662
|
)
|
|
642
663
|
}
|
|
643
664
|
columns={columns}
|
|
@@ -645,7 +666,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
645
666
|
headerHeight={headerHeight}
|
|
646
667
|
rowExpandedHeight={rowExpandedHeight}
|
|
647
668
|
loading={isLoading ?? loading}
|
|
648
|
-
showHeader
|
|
669
|
+
showHeader={showHeader}
|
|
649
670
|
defaultChecked
|
|
650
671
|
expandedRowKeys={expandedRowKeys}
|
|
651
672
|
onExpandChange={onExpandChange}
|
|
@@ -759,6 +780,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
759
780
|
setIsOpen={setIsOpen}
|
|
760
781
|
handleResetColumns={handleResetColumns}
|
|
761
782
|
handleColumnToggle={handleColumnToggle}
|
|
783
|
+
labels={labels}
|
|
762
784
|
/>
|
|
763
785
|
</HeaderCell>
|
|
764
786
|
<Cell />
|
|
@@ -786,6 +808,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
786
808
|
setIsOpen={setIsOpen}
|
|
787
809
|
handleResetColumns={handleResetColumns}
|
|
788
810
|
handleColumnToggle={handleColumnToggle}
|
|
811
|
+
labels={labels}
|
|
789
812
|
/>
|
|
790
813
|
)}
|
|
791
814
|
</HeaderCell>
|
|
@@ -818,7 +841,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
818
841
|
>
|
|
819
842
|
{(data?.length === 0 || !data) && !isLoading && (
|
|
820
843
|
<div className="flex flex-col gap-2 p-2 mt-6 card-empty-container">
|
|
821
|
-
<NoData title={emptyTitle ??
|
|
844
|
+
<NoData title={emptyTitle ?? labels.noDataFound} subtitle={emptySubTitle} />
|
|
822
845
|
</div>
|
|
823
846
|
)}
|
|
824
847
|
{isLoading ? (
|
|
@@ -845,6 +868,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
845
868
|
columns={columns}
|
|
846
869
|
tableBodyRef={tableBodyRef}
|
|
847
870
|
actionProps={actionProps}
|
|
871
|
+
labels={labels}
|
|
848
872
|
/>
|
|
849
873
|
)}
|
|
850
874
|
</div>
|
|
@@ -853,7 +877,9 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
853
877
|
</div>
|
|
854
878
|
)}
|
|
855
879
|
<div>
|
|
856
|
-
{pagination && data?.length > 0 &&
|
|
880
|
+
{pagination && data?.length > 0 && (
|
|
881
|
+
<Pagination paginationProps={paginationProps} labels={labels} dataTheme={dataTheme} />
|
|
882
|
+
)}
|
|
857
883
|
</div>
|
|
858
884
|
</div>
|
|
859
885
|
</div>
|
|
@@ -7,6 +7,7 @@ import HeaderCell from '../HeaderCell';
|
|
|
7
7
|
import Pagination from '../Pagination';
|
|
8
8
|
import Table from '../Table';
|
|
9
9
|
import { QbsColumnProps, QbsTableProps } from './commontypes';
|
|
10
|
+
import { mergeLabels } from './labels';
|
|
10
11
|
import {
|
|
11
12
|
ActionCell,
|
|
12
13
|
CheckCell,
|
|
@@ -82,12 +83,17 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
82
83
|
autoHeight,
|
|
83
84
|
emptySubTitle,
|
|
84
85
|
emptyTitle,
|
|
85
|
-
dropType = 'horizontal'
|
|
86
|
+
dropType = 'horizontal',
|
|
87
|
+
labels: labelsProp
|
|
86
88
|
}) => {
|
|
89
|
+
const labels = useMemo(() => mergeLabels(labelsProp), [labelsProp]);
|
|
87
90
|
const [loading, setLoading] = useState(false);
|
|
88
91
|
const [columns, setColumns] = useState(propColumn);
|
|
89
92
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
90
|
-
const dataTheme = useMemo(
|
|
93
|
+
const dataTheme = useMemo(
|
|
94
|
+
() => theme ?? (typeof localStorage !== 'undefined' ? localStorage.getItem('theme') : null) ?? 'light',
|
|
95
|
+
[theme]
|
|
96
|
+
);
|
|
91
97
|
const [isOpen, setIsOpen] = useState(false);
|
|
92
98
|
const prevColumns = useRef<any | null>(null);
|
|
93
99
|
const tableBodyRef = useRef<HTMLDivElement>(null);
|
|
@@ -228,11 +234,25 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
228
234
|
onSelect: handleClear,
|
|
229
235
|
handleColumnToggle: handleColumnToggle,
|
|
230
236
|
dataLength: data?.length,
|
|
231
|
-
searchPlaceholder: searchPlaceholder
|
|
237
|
+
searchPlaceholder: searchPlaceholder,
|
|
238
|
+
labels
|
|
232
239
|
};
|
|
233
|
-
const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
|
|
234
240
|
|
|
235
241
|
useEffect(() => {
|
|
242
|
+
if (!dataTheme || typeof document === 'undefined') return;
|
|
243
|
+
|
|
244
|
+
document.body.setAttribute('data-theme', dataTheme === 'dark' ? 'dark' : 'light');
|
|
245
|
+
document.documentElement.dataset.theme = dataTheme;
|
|
246
|
+
}, [dataTheme]);
|
|
247
|
+
|
|
248
|
+
const themeToggle = useMemo(
|
|
249
|
+
() => (typeof document !== 'undefined' ? document.getElementById('themeToggle') : null),
|
|
250
|
+
[]
|
|
251
|
+
) as HTMLInputElement | null;
|
|
252
|
+
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
if (theme || typeof document === 'undefined') return;
|
|
255
|
+
|
|
236
256
|
const handleThemeToggle = () => {
|
|
237
257
|
if (themeToggle?.checked) {
|
|
238
258
|
document.body.setAttribute('data-theme', 'dark');
|
|
@@ -257,7 +277,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
257
277
|
themeToggle?.removeEventListener('change', handleThemeToggle);
|
|
258
278
|
document.removeEventListener('DOMContentLoaded', handleDOMContentLoaded);
|
|
259
279
|
};
|
|
260
|
-
}, [themeToggle]);
|
|
280
|
+
}, [theme, themeToggle]);
|
|
261
281
|
|
|
262
282
|
const handleExpanded = useCallback(
|
|
263
283
|
(rowData: any) => {
|
|
@@ -463,7 +483,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
463
483
|
renderEmpty ? (
|
|
464
484
|
renderEmpty(info)
|
|
465
485
|
) : (
|
|
466
|
-
<NoData title={emptyTitle ??
|
|
486
|
+
<NoData title={emptyTitle ?? labels.noDataFound} subtitle={emptySubTitle} />
|
|
467
487
|
)
|
|
468
488
|
}
|
|
469
489
|
columns={columns}
|
|
@@ -581,6 +601,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
581
601
|
setIsOpen={setIsOpen}
|
|
582
602
|
handleResetColumns={handleResetColumns}
|
|
583
603
|
handleColumnToggle={handleColumnToggle}
|
|
604
|
+
labels={labels}
|
|
584
605
|
/>
|
|
585
606
|
</HeaderCell>
|
|
586
607
|
<Cell />
|
|
@@ -606,6 +627,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
606
627
|
setIsOpen={setIsOpen}
|
|
607
628
|
handleResetColumns={handleResetColumns}
|
|
608
629
|
handleColumnToggle={handleColumnToggle}
|
|
630
|
+
labels={labels}
|
|
609
631
|
/>
|
|
610
632
|
)}
|
|
611
633
|
</HeaderCell>
|
|
@@ -622,7 +644,9 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
622
644
|
</Table>
|
|
623
645
|
|
|
624
646
|
<div>
|
|
625
|
-
{pagination && data?.length > 0 &&
|
|
647
|
+
{pagination && data?.length > 0 && (
|
|
648
|
+
<Pagination paginationProps={paginationProps} labels={labels} dataTheme={dataTheme} />
|
|
649
|
+
)}
|
|
626
650
|
</div>
|
|
627
651
|
</div>
|
|
628
652
|
</div>
|
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,21 +179,24 @@ 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
|
<>
|
|
185
191
|
{handleHide(actions) && (
|
|
186
192
|
<button
|
|
187
193
|
key={index.toString()}
|
|
188
|
-
className=
|
|
194
|
+
className={`btn ${actions?.buttonClassName}`}
|
|
189
195
|
disabled={actions.disabled}
|
|
190
196
|
onClick={() => actions?.action(checkedKeys)}
|
|
191
197
|
>
|
|
192
|
-
{actions
|
|
198
|
+
{actions?.icon && <span className="mr-2">{actions?.icon}</span>}
|
|
199
|
+
<span>{actions.actionTitle}</span>
|
|
193
200
|
</button>
|
|
194
201
|
)}
|
|
195
202
|
</>
|
|
@@ -203,7 +210,8 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
203
210
|
{getRowDisplayRange(
|
|
204
211
|
paginationProps.total ?? 0,
|
|
205
212
|
paginationProps.rowsPerPage ?? 0,
|
|
206
|
-
paginationProps.currentPage ?? 0
|
|
213
|
+
paginationProps.currentPage ?? 0,
|
|
214
|
+
labels.showingRange
|
|
207
215
|
)}
|
|
208
216
|
</div>
|
|
209
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;
|
|
@@ -94,12 +98,15 @@ export interface QbsTableProps {
|
|
|
94
98
|
advancefilter?: ReactElement | ReactNode;
|
|
95
99
|
tableHeaderActions?: ReactElement | ReactNode;
|
|
96
100
|
searchPlaceholder?: string;
|
|
101
|
+
labels?: QbsTableLabels;
|
|
97
102
|
selectedRowActions?: {
|
|
98
103
|
actionTitle?: string;
|
|
99
104
|
action: (checked: (number | string)[]) => void;
|
|
100
105
|
disabled?: boolean;
|
|
101
106
|
hidden?: boolean;
|
|
102
107
|
customHide?: string;
|
|
108
|
+
buttonClassName?: string;
|
|
109
|
+
icon?: ReactElement | ReactNode;
|
|
103
110
|
}[];
|
|
104
111
|
selectedRows?: (number | string)[];
|
|
105
112
|
classes?: { [key: string]: any };
|
|
@@ -142,7 +149,8 @@ export interface QbsTableProps {
|
|
|
142
149
|
setRowViewToggle?: (value: boolean) => void;
|
|
143
150
|
dropType?: 'horizondal' | 'vertical';
|
|
144
151
|
rowHeight?: number;
|
|
145
|
-
isFullScreen?: boolean
|
|
152
|
+
isFullScreen?: boolean;
|
|
153
|
+
showHeader?: boolean;
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
export interface QbsTableToolbarProps {
|
|
@@ -168,6 +176,7 @@ export interface QbsTableToolbarProps {
|
|
|
168
176
|
dataLength: number;
|
|
169
177
|
headerHeight?: number;
|
|
170
178
|
searchPlaceholder?: string;
|
|
179
|
+
labels?: QbsTableLabels;
|
|
171
180
|
tableView?: boolean;
|
|
172
181
|
enableTableToggle?: boolean;
|
|
173
182
|
tableViewToggle?: boolean;
|
|
@@ -178,11 +187,13 @@ export interface QbsTableToolbarProps {
|
|
|
178
187
|
disabled?: boolean;
|
|
179
188
|
hidden?: boolean;
|
|
180
189
|
customHide?: string;
|
|
190
|
+
buttonClassName?: string;
|
|
191
|
+
icon?: ReactElement | ReactNode;
|
|
181
192
|
}[];
|
|
182
193
|
rowViewToggle?: boolean;
|
|
183
194
|
defaultRowView?: boolean;
|
|
184
195
|
fullWidthView?: boolean;
|
|
185
196
|
setTableFullView?: (value: boolean) => void;
|
|
186
197
|
setRowViewToggle?: (value: boolean) => void;
|
|
187
|
-
isFullScreen?: boolean
|
|
198
|
+
isFullScreen?: boolean;
|
|
188
199
|
}
|
|
@@ -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
|