qbs-react-grid 2.2.6 → 2.2.11
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/index.d.ts +2 -0
- package/es/index.js +2 -1
- package/es/less/qbs-table.less +89 -6
- package/es/qbsTable/CustomTableCell.js +4 -2
- package/es/qbsTable/QbsTable.js +52 -6
- package/es/qbsTable/TableCardList.js +39 -5
- package/es/qbsTable/Toolbar.js +96 -21
- package/es/qbsTable/commontypes.d.ts +18 -0
- package/es/qbsTable/labels.d.ts +25 -0
- package/es/qbsTable/labels.js +32 -0
- package/es/qbsTable/utilities/ColumShowHide.d.ts +3 -0
- package/es/qbsTable/utilities/ColumShowHide.js +63 -35
- package/es/qbsTable/utilities/ToolTip.js +2 -1
- package/es/qbsTable/utilities/VerticalDropDownMenu.js +28 -7
- package/es/qbsTable/utilities/columnToggleCoordinator.d.ts +5 -0
- package/es/qbsTable/utilities/columnToggleCoordinator.js +9 -0
- package/es/qbsTable/utilities/icons.d.ts +3 -0
- package/es/qbsTable/utilities/icons.js +67 -3
- package/es/qbsTable/utilities/verticalMenuCoordinator.d.ts +5 -0
- package/es/qbsTable/utilities/verticalMenuCoordinator.js +9 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -2
- package/lib/less/qbs-table.less +89 -6
- package/lib/qbsTable/CustomTableCell.js +4 -2
- package/lib/qbsTable/QbsTable.js +52 -6
- package/lib/qbsTable/TableCardList.js +39 -5
- package/lib/qbsTable/Toolbar.js +94 -19
- package/lib/qbsTable/commontypes.d.ts +18 -0
- package/lib/qbsTable/labels.d.ts +25 -0
- package/lib/qbsTable/labels.js +40 -0
- package/lib/qbsTable/utilities/ColumShowHide.d.ts +3 -0
- package/lib/qbsTable/utilities/ColumShowHide.js +62 -34
- package/lib/qbsTable/utilities/ToolTip.js +2 -1
- package/lib/qbsTable/utilities/VerticalDropDownMenu.js +27 -6
- package/lib/qbsTable/utilities/columnToggleCoordinator.d.ts +5 -0
- package/lib/qbsTable/utilities/columnToggleCoordinator.js +15 -0
- package/lib/qbsTable/utilities/icons.d.ts +3 -0
- package/lib/qbsTable/utilities/icons.js +72 -5
- package/lib/qbsTable/utilities/verticalMenuCoordinator.d.ts +5 -0
- package/lib/qbsTable/utilities/verticalMenuCoordinator.js +15 -0
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/src/less/qbs-table.less +89 -6
- package/src/qbsTable/CustomTableCell.tsx +4 -2
- package/src/qbsTable/QbsTable.tsx +41 -4
- package/src/qbsTable/TableCardList.tsx +30 -3
- package/src/qbsTable/Toolbar.tsx +105 -26
- package/src/qbsTable/commontypes.ts +19 -0
- package/src/qbsTable/labels.ts +55 -0
- package/src/qbsTable/utilities/ColumShowHide.tsx +114 -77
- package/src/qbsTable/utilities/ToolTip.tsx +1 -1
- package/src/qbsTable/utilities/VerticalDropDownMenu.tsx +36 -5
- package/src/qbsTable/utilities/columnToggleCoordinator.ts +14 -0
- package/src/qbsTable/utilities/icons.tsx +76 -3
- package/src/qbsTable/utilities/verticalMenuCoordinator.ts +14 -0
|
@@ -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 { mergeQbsTableLabels } from './labels';
|
|
11
12
|
import {
|
|
12
13
|
ActionCell,
|
|
13
14
|
CheckCell,
|
|
@@ -92,8 +93,22 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
92
93
|
isCustomTableCardView = false,
|
|
93
94
|
handleTableCardView,
|
|
94
95
|
handleCustomCardLoader,
|
|
95
|
-
dropType
|
|
96
|
+
dropType,
|
|
97
|
+
labels: labelsProp,
|
|
98
|
+
rtl = false,
|
|
99
|
+
rowViewToggle = false,
|
|
100
|
+
defaultRowView = true,
|
|
101
|
+
fullWidthView = false,
|
|
102
|
+
setTableFullView,
|
|
103
|
+
setRowViewToggle,
|
|
104
|
+
isFullScreen = false,
|
|
105
|
+
rowHeight,
|
|
96
106
|
}) => {
|
|
107
|
+
const labels = useMemo(() => mergeQbsTableLabels(labelsProp), [labelsProp]);
|
|
108
|
+
const effectiveWordWrap = useMemo(() => {
|
|
109
|
+
if (!rowViewToggle) return wordWrap;
|
|
110
|
+
return defaultRowView ? wordWrap : 'break-word';
|
|
111
|
+
}, [rowViewToggle, defaultRowView, wordWrap]);
|
|
97
112
|
const [loading, setLoading] = useState(false);
|
|
98
113
|
const [columns, setColumns] = useState(propColumn);
|
|
99
114
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
@@ -103,6 +118,14 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
103
118
|
const [tableViewToggle, setTableViewToggle] = useState(tableView);
|
|
104
119
|
const isMobile = useResponsiveStore();
|
|
105
120
|
const tableBodyRef = useRef<HTMLDivElement>(null);
|
|
121
|
+
const [rowViewRefreshKey, setRowViewRefreshKey] = useState(0);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (rowViewToggle) {
|
|
125
|
+
setRowViewRefreshKey(key => key + 1);
|
|
126
|
+
}
|
|
127
|
+
}, [defaultRowView, rowViewToggle]);
|
|
128
|
+
|
|
106
129
|
const handleSortColumn = useCallback(
|
|
107
130
|
(sortColumn: any, sortType: any) => {
|
|
108
131
|
setLoading(true);
|
|
@@ -252,7 +275,15 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
252
275
|
searchPlaceholder: searchPlaceholder,
|
|
253
276
|
setTableViewToggle: setTableViewToggle,
|
|
254
277
|
tableViewToggle: tableViewToggle,
|
|
255
|
-
enableTableToggle: enableTableToggle
|
|
278
|
+
enableTableToggle: enableTableToggle,
|
|
279
|
+
rowViewToggle,
|
|
280
|
+
defaultRowView,
|
|
281
|
+
fullWidthView,
|
|
282
|
+
setTableFullView,
|
|
283
|
+
setRowViewToggle,
|
|
284
|
+
isFullScreen,
|
|
285
|
+
labels,
|
|
286
|
+
rtl,
|
|
256
287
|
};
|
|
257
288
|
const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
|
|
258
289
|
|
|
@@ -582,12 +613,13 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
582
613
|
{tableViewToggle ? (
|
|
583
614
|
<Table
|
|
584
615
|
height={autoHeight ? undefined : height}
|
|
585
|
-
key={tableKey}
|
|
616
|
+
key={`${tableKey}-${rowViewRefreshKey}`}
|
|
586
617
|
tableKey={tableKey}
|
|
618
|
+
rtl={rtl}
|
|
587
619
|
data={data}
|
|
588
620
|
tableBodyRef={tableBodyRef as React.RefObject<HTMLDivElement>}
|
|
589
621
|
dataTheme={dataTheme}
|
|
590
|
-
wordWrap={
|
|
622
|
+
wordWrap={effectiveWordWrap}
|
|
591
623
|
autoHeight={autoHeight}
|
|
592
624
|
sortColumn={sortColumn}
|
|
593
625
|
style={{ position: 'relative' }}
|
|
@@ -607,6 +639,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
607
639
|
columns={columns}
|
|
608
640
|
minHeight={minHeight}
|
|
609
641
|
headerHeight={headerHeight}
|
|
642
|
+
rowHeight={rowHeight}
|
|
610
643
|
rowExpandedHeight={rowExpandedHeight}
|
|
611
644
|
loading={isLoading ?? loading}
|
|
612
645
|
showHeader
|
|
@@ -722,6 +755,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
722
755
|
setIsOpen={setIsOpen}
|
|
723
756
|
handleResetColumns={handleResetColumns}
|
|
724
757
|
handleColumnToggle={handleColumnToggle}
|
|
758
|
+
labels={labels}
|
|
759
|
+
rtl={rtl}
|
|
725
760
|
/>
|
|
726
761
|
</HeaderCell>
|
|
727
762
|
<Cell />
|
|
@@ -747,6 +782,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
747
782
|
setIsOpen={setIsOpen}
|
|
748
783
|
handleResetColumns={handleResetColumns}
|
|
749
784
|
handleColumnToggle={handleColumnToggle}
|
|
785
|
+
labels={labels}
|
|
786
|
+
rtl={rtl}
|
|
750
787
|
/>
|
|
751
788
|
)}
|
|
752
789
|
</HeaderCell>
|
|
@@ -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 { mergeQbsTableLabels } from './labels';
|
|
10
11
|
import {
|
|
11
12
|
ActionCell,
|
|
12
13
|
CheckCell,
|
|
@@ -82,8 +83,21 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
82
83
|
autoHeight,
|
|
83
84
|
emptySubTitle,
|
|
84
85
|
emptyTitle,
|
|
85
|
-
dropType
|
|
86
|
+
dropType,
|
|
87
|
+
labels: labelsProp,
|
|
88
|
+
rtl = false,
|
|
89
|
+
rowViewToggle = false,
|
|
90
|
+
defaultRowView = true,
|
|
91
|
+
fullWidthView = false,
|
|
92
|
+
setTableFullView,
|
|
93
|
+
setRowViewToggle,
|
|
94
|
+
isFullScreen = false,
|
|
86
95
|
}) => {
|
|
96
|
+
const labels = useMemo(() => mergeQbsTableLabels(labelsProp), [labelsProp]);
|
|
97
|
+
const effectiveWordWrap = useMemo(() => {
|
|
98
|
+
if (!rowViewToggle) return wordWrap;
|
|
99
|
+
return defaultRowView ? wordWrap : 'break-word';
|
|
100
|
+
}, [rowViewToggle, defaultRowView, wordWrap]);
|
|
87
101
|
const [loading, setLoading] = useState(false);
|
|
88
102
|
const [columns, setColumns] = useState(propColumn);
|
|
89
103
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
@@ -237,7 +251,15 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
237
251
|
onSelect: handleClear,
|
|
238
252
|
handleColumnToggle: handleColumnToggle,
|
|
239
253
|
dataLength: data?.length,
|
|
240
|
-
searchPlaceholder: searchPlaceholder
|
|
254
|
+
searchPlaceholder: searchPlaceholder,
|
|
255
|
+
rowViewToggle,
|
|
256
|
+
defaultRowView,
|
|
257
|
+
fullWidthView,
|
|
258
|
+
setTableFullView,
|
|
259
|
+
setRowViewToggle,
|
|
260
|
+
isFullScreen,
|
|
261
|
+
labels,
|
|
262
|
+
rtl,
|
|
241
263
|
};
|
|
242
264
|
const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
|
|
243
265
|
|
|
@@ -455,10 +477,11 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
455
477
|
height={autoHeight ? undefined : height}
|
|
456
478
|
key={tableKey}
|
|
457
479
|
tableKey={tableKey}
|
|
480
|
+
rtl={rtl}
|
|
458
481
|
data={data}
|
|
459
482
|
tableBodyRef={tableBodyRef as React.RefObject<HTMLDivElement>}
|
|
460
483
|
dataTheme={dataTheme}
|
|
461
|
-
wordWrap={
|
|
484
|
+
wordWrap={effectiveWordWrap}
|
|
462
485
|
autoHeight={autoHeight}
|
|
463
486
|
sortColumn={sortColumn}
|
|
464
487
|
style={{ position: 'relative' }}
|
|
@@ -591,6 +614,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
591
614
|
setIsOpen={setIsOpen}
|
|
592
615
|
handleResetColumns={handleResetColumns}
|
|
593
616
|
handleColumnToggle={handleColumnToggle}
|
|
617
|
+
labels={labels}
|
|
618
|
+
rtl={rtl}
|
|
594
619
|
/>
|
|
595
620
|
</HeaderCell>
|
|
596
621
|
<Cell />
|
|
@@ -616,6 +641,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
616
641
|
setIsOpen={setIsOpen}
|
|
617
642
|
handleResetColumns={handleResetColumns}
|
|
618
643
|
handleColumnToggle={handleColumnToggle}
|
|
644
|
+
labels={labels}
|
|
645
|
+
rtl={rtl}
|
|
619
646
|
/>
|
|
620
647
|
)}
|
|
621
648
|
</HeaderCell>
|
package/src/qbsTable/Toolbar.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useCallback, useRef, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import useResponsiveStore from '../utils/useResponsiveStore';
|
|
4
4
|
import { QbsTableToolbarProps } from './commontypes';
|
|
5
|
+
import { formatSelectedItems, mergeQbsTableLabels } from './labels';
|
|
5
6
|
import debounce from './utilities/debounce';
|
|
6
|
-
import { CardView, TableView } from './utilities/icons';
|
|
7
|
+
import { CardView, ContentView, DefaultView, ExpandIcon, TableView } from './utilities/icons';
|
|
7
8
|
import SearchInput from './utilities/SearchInput';
|
|
8
9
|
import { getRowDisplayRange } from './utilities/tablecalc';
|
|
9
10
|
import TooltipComponent from './utilities/ToolTip';
|
|
@@ -27,8 +28,16 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
27
28
|
searchPlaceholder,
|
|
28
29
|
tableViewToggle,
|
|
29
30
|
setTableViewToggle,
|
|
30
|
-
enableTableToggle = false
|
|
31
|
+
enableTableToggle = false,
|
|
32
|
+
rowViewToggle = false,
|
|
33
|
+
defaultRowView = true,
|
|
34
|
+
fullWidthView = false,
|
|
35
|
+
setTableFullView,
|
|
36
|
+
setRowViewToggle,
|
|
37
|
+
isFullScreen = false,
|
|
38
|
+
labels: labelsProp,
|
|
31
39
|
}) => {
|
|
40
|
+
const labels = useMemo(() => mergeQbsTableLabels(labelsProp), [labelsProp]);
|
|
32
41
|
const debouncedOnSearch = useCallback(debounce(onSearch ?? (() => {}), 1000), [onSearch]);
|
|
33
42
|
const [searchParam, setSearchParam] = useState<string | undefined>(searchValue);
|
|
34
43
|
const toolbarRef = useRef<HTMLDivElement>(null);
|
|
@@ -39,7 +48,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
39
48
|
debouncedOnSearch(e);
|
|
40
49
|
}
|
|
41
50
|
},
|
|
42
|
-
[debouncedOnSearch]
|
|
51
|
+
[debouncedOnSearch],
|
|
43
52
|
);
|
|
44
53
|
|
|
45
54
|
const handleChange = useCallback(
|
|
@@ -51,29 +60,30 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
51
60
|
handleSearchValue?.(e);
|
|
52
61
|
}
|
|
53
62
|
},
|
|
54
|
-
[asyncSearch, handleSearch, handleSearchValue]
|
|
63
|
+
[asyncSearch, handleSearch, handleSearchValue],
|
|
55
64
|
);
|
|
56
|
-
const handleHide = (actions:
|
|
65
|
+
const handleHide = (actions: { hidden?: boolean; customHide?: string }) => {
|
|
57
66
|
if (actions.hidden) {
|
|
58
67
|
return false;
|
|
59
|
-
} else if (actions.customHide == '>2') {
|
|
60
|
-
return checkedKeys && checkedKeys?.length >= 2 ? true : false;
|
|
61
|
-
} else {
|
|
62
|
-
return true;
|
|
63
68
|
}
|
|
69
|
+
if (actions.customHide === '>2') {
|
|
70
|
+
return checkedKeys && checkedKeys?.length >= 2;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
64
73
|
};
|
|
65
74
|
const isMobile = useResponsiveStore();
|
|
66
75
|
const handleFilterClick = () => {
|
|
67
76
|
setIsOpen(!isOpen);
|
|
68
77
|
};
|
|
78
|
+
|
|
69
79
|
return (
|
|
70
80
|
<div className="qbs-table-toolbar-container" ref={toolbarRef}>
|
|
71
|
-
<div className={`qbs-table-toolbar ${className}`}>
|
|
81
|
+
<div className={`qbs-table-toolbar ${className ?? ''}`}>
|
|
72
82
|
<div className="start-container" style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
73
83
|
<div className="qbs-table-primary-filter">
|
|
74
84
|
{search && (
|
|
75
85
|
<SearchInput
|
|
76
|
-
placeholder={searchPlaceholder ?? 'Search'}
|
|
86
|
+
placeholder={searchPlaceholder ?? labels.search ?? 'Search'}
|
|
77
87
|
handleChange={handleChange}
|
|
78
88
|
handleSearch={handleSearch}
|
|
79
89
|
searchValue={searchParam}
|
|
@@ -103,22 +113,89 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
103
113
|
</span>
|
|
104
114
|
)}
|
|
105
115
|
{tableHeaderActions}
|
|
106
|
-
<div className="
|
|
116
|
+
<div className="pr-1 cursor-pointer relative table_custom_ctions">
|
|
117
|
+
{(rowViewToggle || isFullScreen) && (
|
|
118
|
+
<div className="flex gap-2 qbs-row-switch-cntainer">
|
|
119
|
+
{rowViewToggle && (
|
|
120
|
+
<div className="flex gap-2 table_cell_style qbs-table-top-icons">
|
|
121
|
+
<TooltipComponent
|
|
122
|
+
tableBodyRef={toolbarRef}
|
|
123
|
+
title={labels.switchToDefaultView ?? ''}
|
|
124
|
+
>
|
|
125
|
+
<div
|
|
126
|
+
role="button"
|
|
127
|
+
tabIndex={0}
|
|
128
|
+
title={labels.switchToDefaultView}
|
|
129
|
+
onClick={() => setRowViewToggle?.(true)}
|
|
130
|
+
onKeyDown={e => {
|
|
131
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
132
|
+
setRowViewToggle?.(true);
|
|
133
|
+
}
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
<DefaultView className={`${defaultRowView ? 'active' : ''}`} />
|
|
137
|
+
</div>
|
|
138
|
+
</TooltipComponent>
|
|
139
|
+
<TooltipComponent
|
|
140
|
+
tableBodyRef={toolbarRef}
|
|
141
|
+
title={labels.switchToRelaxedView ?? ''}
|
|
142
|
+
>
|
|
143
|
+
<div
|
|
144
|
+
role="button"
|
|
145
|
+
tabIndex={0}
|
|
146
|
+
title={labels.switchToRelaxedView}
|
|
147
|
+
onClick={() => setRowViewToggle?.(false)}
|
|
148
|
+
onKeyDown={e => {
|
|
149
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
150
|
+
setRowViewToggle?.(false);
|
|
151
|
+
}
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
<ContentView className={`${!defaultRowView ? 'active' : ''}`} />
|
|
155
|
+
</div>
|
|
156
|
+
</TooltipComponent>
|
|
157
|
+
</div>
|
|
158
|
+
)}
|
|
159
|
+
{isFullScreen && (
|
|
160
|
+
<div className="table_full_width qbs-table-top-icons">
|
|
161
|
+
<TooltipComponent
|
|
162
|
+
tableBodyRef={toolbarRef}
|
|
163
|
+
title={labels.switchToFullScreen ?? ''}
|
|
164
|
+
>
|
|
165
|
+
<div
|
|
166
|
+
role="button"
|
|
167
|
+
tabIndex={0}
|
|
168
|
+
title={labels.switchToFullScreen}
|
|
169
|
+
onClick={() => setTableFullView?.(!fullWidthView)}
|
|
170
|
+
onKeyDown={e => {
|
|
171
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
172
|
+
setTableFullView?.(!fullWidthView);
|
|
173
|
+
}
|
|
174
|
+
}}
|
|
175
|
+
>
|
|
176
|
+
<ExpandIcon className={`${fullWidthView ? 'active' : ''}`} />
|
|
177
|
+
</div>
|
|
178
|
+
</TooltipComponent>
|
|
179
|
+
</div>
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
|
|
107
184
|
{enableTableToggle && !isMobile && (
|
|
108
185
|
<div className="qbs-table-top-icons flex gap-2">
|
|
109
|
-
<TooltipComponent tableBodyRef={toolbarRef} title={
|
|
186
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToTableView ?? ''}>
|
|
110
187
|
<div onClick={() => setTableViewToggle?.(true)}>
|
|
111
188
|
<TableView className={`${tableViewToggle ? 'active' : ''}`} />
|
|
112
189
|
</div>
|
|
113
190
|
</TooltipComponent>
|
|
114
191
|
|
|
115
|
-
<div className="border-r h-4 w-1"
|
|
192
|
+
<div className="border-r h-4 w-1" />
|
|
116
193
|
|
|
117
|
-
<
|
|
118
|
-
<
|
|
194
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToCardView ?? ''}>
|
|
195
|
+
<div onClick={() => setTableViewToggle?.(false)}>
|
|
119
196
|
<CardView className={`${!tableViewToggle ? 'active' : ''}`} />
|
|
120
|
-
</
|
|
121
|
-
</
|
|
197
|
+
</div>
|
|
198
|
+
</TooltipComponent>
|
|
122
199
|
</div>
|
|
123
200
|
)}
|
|
124
201
|
</div>
|
|
@@ -141,16 +218,18 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
141
218
|
>
|
|
142
219
|
{checkedKeys && checkedKeys?.length > 0 ? (
|
|
143
220
|
<div className="qbs-table-toolbar-sub-container-start">
|
|
144
|
-
<div className="selected-row">
|
|
221
|
+
<div className="selected-row">
|
|
222
|
+
{formatSelectedItems(checkedKeys.length, labels)}
|
|
223
|
+
</div>
|
|
145
224
|
<div className="selected-row-action">
|
|
146
|
-
<button className="btn" onClick={() => onSelect?.([])}>
|
|
147
|
-
|
|
225
|
+
<button type="button" className="btn" onClick={() => onSelect?.([])}>
|
|
226
|
+
{labels.clear}
|
|
148
227
|
</button>
|
|
149
228
|
{selectedRowActions?.map((actions, index: number) => (
|
|
150
|
-
|
|
229
|
+
<React.Fragment key={index.toString()}>
|
|
151
230
|
{handleHide(actions) && (
|
|
152
231
|
<button
|
|
153
|
-
|
|
232
|
+
type="button"
|
|
154
233
|
className="btn"
|
|
155
234
|
disabled={actions.disabled}
|
|
156
235
|
onClick={() => actions?.action(checkedKeys)}
|
|
@@ -158,7 +237,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
158
237
|
{actions.actionTitle}
|
|
159
238
|
</button>
|
|
160
239
|
)}
|
|
161
|
-
|
|
240
|
+
</React.Fragment>
|
|
162
241
|
))}
|
|
163
242
|
</div>
|
|
164
243
|
</div>
|
|
@@ -169,7 +248,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
169
248
|
{getRowDisplayRange(
|
|
170
249
|
paginationProps.total ?? 0,
|
|
171
250
|
paginationProps.rowsPerPage ?? 0,
|
|
172
|
-
paginationProps.currentPage ?? 0
|
|
251
|
+
paginationProps.currentPage ?? 0,
|
|
173
252
|
)}
|
|
174
253
|
</div>
|
|
175
254
|
)}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
+
import type { QbsTableLabels } from './labels';
|
|
4
|
+
|
|
3
5
|
interface Content {
|
|
4
6
|
cell: ReactNode | string;
|
|
5
7
|
toolTip?: string;
|
|
@@ -88,6 +90,8 @@ export interface QbsTableProps {
|
|
|
88
90
|
setExpandedRowKeys?: (value: readonly number[]) => void;
|
|
89
91
|
handleMenuActions?: (actions: ActionProps, rowData: any) => void;
|
|
90
92
|
dropType?: 'vertical' | string;
|
|
93
|
+
labels?: QbsTableLabels;
|
|
94
|
+
rtl?: boolean;
|
|
91
95
|
handleRowExpanded?: (rowData: any) => React.ReactNode;
|
|
92
96
|
shouldUpdateScroll?: boolean;
|
|
93
97
|
rowExpand?: boolean;
|
|
@@ -131,6 +135,13 @@ export interface QbsTableProps {
|
|
|
131
135
|
handleTableCardView?: (data: any) => React.ReactNode;
|
|
132
136
|
isCustomTableCardView?: boolean;
|
|
133
137
|
handleCustomCardLoader?: () => React.ReactNode;
|
|
138
|
+
rowViewToggle?: boolean;
|
|
139
|
+
defaultRowView?: boolean;
|
|
140
|
+
fullWidthView?: boolean;
|
|
141
|
+
setTableFullView?: (value: boolean) => void;
|
|
142
|
+
setRowViewToggle?: (value: boolean) => void;
|
|
143
|
+
isFullScreen?: boolean;
|
|
144
|
+
rowHeight?: number;
|
|
134
145
|
}
|
|
135
146
|
|
|
136
147
|
export interface QbsTableToolbarProps {
|
|
@@ -160,6 +171,14 @@ export interface QbsTableToolbarProps {
|
|
|
160
171
|
enableTableToggle?: boolean;
|
|
161
172
|
tableViewToggle?: boolean;
|
|
162
173
|
setTableViewToggle?: (value: boolean) => void;
|
|
174
|
+
rowViewToggle?: boolean;
|
|
175
|
+
defaultRowView?: boolean;
|
|
176
|
+
fullWidthView?: boolean;
|
|
177
|
+
setTableFullView?: (value: boolean) => void;
|
|
178
|
+
setRowViewToggle?: (value: boolean) => void;
|
|
179
|
+
isFullScreen?: boolean;
|
|
180
|
+
labels?: QbsTableLabels;
|
|
181
|
+
rtl?: boolean;
|
|
163
182
|
selectedRowActions?: {
|
|
164
183
|
actionTitle?: string;
|
|
165
184
|
action: (checked: (number | string)[]) => void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type 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 defaultQbsTableLabels: QbsTableLabels = {
|
|
25
|
+
search: 'Search',
|
|
26
|
+
searchAriaLabel: 'Search',
|
|
27
|
+
clear: 'Clear',
|
|
28
|
+
selectedItems: 'Selected items',
|
|
29
|
+
switchToDefaultView: 'Switch to Default View',
|
|
30
|
+
switchToRelaxedView: 'Switch to Relaxed View',
|
|
31
|
+
switchToFullScreen: 'Switch to Full Screen',
|
|
32
|
+
switchToTableView: 'Switch to Table View',
|
|
33
|
+
switchToCardView: 'Switch to Card View',
|
|
34
|
+
noDataFound: 'No Data Found',
|
|
35
|
+
showingRange: (start, end, total) => `Showing ${start} to ${end} of ${total}`,
|
|
36
|
+
itemsPerPage: 'Items per page',
|
|
37
|
+
fixedColumns: 'FIXED COLUMNS',
|
|
38
|
+
visibleColumns: 'VISIBLE COLUMNS',
|
|
39
|
+
availableColumns: 'AVAILABLE COLUMNS',
|
|
40
|
+
resetToDefault: 'Reset to default',
|
|
41
|
+
save: 'Save',
|
|
42
|
+
viewMore: 'View More',
|
|
43
|
+
viewLess: 'View Less',
|
|
44
|
+
actions: 'Actions',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const mergeQbsTableLabels = (overrides?: QbsTableLabels): QbsTableLabels => ({
|
|
48
|
+
...defaultQbsTableLabels,
|
|
49
|
+
...overrides,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const formatSelectedItems = (count: number, labels?: QbsTableLabels): string => {
|
|
53
|
+
const merged = mergeQbsTableLabels(labels);
|
|
54
|
+
return `${merged.selectedItems} (${count})`;
|
|
55
|
+
};
|