qbs-react-grid 2.2.5 → 2.2.9
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 +58 -4
- package/es/qbsTable/CustomTableCell.js +27 -10
- package/es/qbsTable/QbsTable.js +42 -7
- package/es/qbsTable/TableCardList.js +40 -7
- package/es/qbsTable/Toolbar.js +87 -23
- package/es/qbsTable/commontypes.d.ts +19 -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 +112 -33
- package/es/qbsTable/utilities/VerticalDropDownMenu.d.ts +11 -0
- package/es/qbsTable/utilities/VerticalDropDownMenu.js +182 -0
- 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 +58 -4
- package/lib/qbsTable/CustomTableCell.js +27 -10
- package/lib/qbsTable/QbsTable.js +42 -7
- package/lib/qbsTable/TableCardList.js +40 -7
- package/lib/qbsTable/Toolbar.js +85 -21
- package/lib/qbsTable/commontypes.d.ts +19 -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 +112 -32
- package/lib/qbsTable/utilities/VerticalDropDownMenu.d.ts +11 -0
- package/lib/qbsTable/utilities/VerticalDropDownMenu.js +190 -0
- 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 +9 -1
- package/src/index.ts +6 -0
- package/src/less/qbs-table.less +58 -4
- package/src/qbsTable/CustomTableCell.tsx +28 -8
- package/src/qbsTable/QbsTable.tsx +32 -4
- package/src/qbsTable/TableCardList.tsx +30 -4
- package/src/qbsTable/Toolbar.tsx +99 -29
- package/src/qbsTable/commontypes.ts +20 -0
- package/src/qbsTable/labels.ts +55 -0
- package/src/qbsTable/utilities/ColumShowHide.tsx +170 -84
- package/src/qbsTable/utilities/VerticalDropDownMenu.tsx +216 -0
- package/src/qbsTable/utilities/columnToggleCoordinator.ts +14 -0
- package/src/qbsTable/utilities/icons.tsx +76 -3
- package/src/qbsTable/utilities/verticalMenuCoordinator.ts +14 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.closeOtherVerticalMenus = exports.VERTICAL_MENU_CLOSE_OTHERS = void 0;
|
|
5
|
+
var VERTICAL_MENU_CLOSE_OTHERS = 'qbs-vertical-menu-close-others';
|
|
6
|
+
exports.VERTICAL_MENU_CLOSE_OTHERS = VERTICAL_MENU_CLOSE_OTHERS;
|
|
7
|
+
var closeOtherVerticalMenus = function closeOtherVerticalMenus(exceptId) {
|
|
8
|
+
if (typeof document === 'undefined') return;
|
|
9
|
+
document.dispatchEvent(new CustomEvent(VERTICAL_MENU_CLOSE_OTHERS, {
|
|
10
|
+
detail: {
|
|
11
|
+
exceptId: exceptId
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
exports.closeOtherVerticalMenus = closeOtherVerticalMenus;
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qbs-react-grid",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"description": "A React table component",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"module": "es/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./es/index.js",
|
|
11
|
+
"require": "./lib/index.js",
|
|
12
|
+
"default": "./es/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./dist/css/qbs-react-grid.css": "./dist/css/qbs-react-grid.css"
|
|
15
|
+
},
|
|
8
16
|
"scripts": {
|
|
9
17
|
"format": "prettier --write \"{src,test}/**/*.{tsx,ts,js}\"",
|
|
10
18
|
"format:check": "prettier --list-different \"{src,test}/**/*.{tsx,ts,js}\"",
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,12 @@ export type { CellProps } from './Cell';
|
|
|
12
12
|
export type { HeaderCellProps } from './HeaderCell';
|
|
13
13
|
export type { ColumnGroupProps } from './ColumnGroup';
|
|
14
14
|
export type { QbsTableProps } from './qbsTable/commontypes';
|
|
15
|
+
export type { QbsTableLabels } from './qbsTable/labels';
|
|
16
|
+
export {
|
|
17
|
+
mergeQbsTableLabels,
|
|
18
|
+
defaultQbsTableLabels,
|
|
19
|
+
formatSelectedItems,
|
|
20
|
+
} from './qbsTable/labels';
|
|
15
21
|
export type {
|
|
16
22
|
StandardProps,
|
|
17
23
|
SortType,
|
package/src/less/qbs-table.less
CHANGED
|
@@ -376,11 +376,17 @@
|
|
|
376
376
|
gap: 10px;
|
|
377
377
|
align-items: center;
|
|
378
378
|
}
|
|
379
|
+
.qbs-table-settings-wrapper {
|
|
380
|
+
position: relative;
|
|
381
|
+
display: inline-flex;
|
|
382
|
+
align-items: center;
|
|
383
|
+
justify-content: center;
|
|
384
|
+
}
|
|
385
|
+
|
|
379
386
|
.qbs-table-column-popup {
|
|
380
387
|
position: fixed;
|
|
381
388
|
padding: 8px;
|
|
382
|
-
z-index:
|
|
383
|
-
right: 10px;
|
|
389
|
+
z-index: 10060;
|
|
384
390
|
border-radius: 8px;
|
|
385
391
|
background: #fff;
|
|
386
392
|
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
|
|
@@ -389,7 +395,6 @@
|
|
|
389
395
|
display: flex;
|
|
390
396
|
flex-direction: column;
|
|
391
397
|
max-height: 500px;
|
|
392
|
-
// overflow-y: auto;
|
|
393
398
|
}
|
|
394
399
|
.qbs-table-popup-container {
|
|
395
400
|
max-width: 400px;
|
|
@@ -408,9 +413,37 @@
|
|
|
408
413
|
|
|
409
414
|
.qbs-table-columns-container {
|
|
410
415
|
display: flex;
|
|
416
|
+
flex-direction: row;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.qbs-table-column-popup--rtl .qbs-table-columns-container {
|
|
411
420
|
flex-direction: row-reverse;
|
|
412
421
|
}
|
|
413
422
|
|
|
423
|
+
.qbs-table-popup-footer {
|
|
424
|
+
display: flex;
|
|
425
|
+
flex-direction: row;
|
|
426
|
+
justify-content: space-between;
|
|
427
|
+
align-items: center;
|
|
428
|
+
gap: 8px;
|
|
429
|
+
padding: 4px 0 0;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.qbs-table-column-popup--rtl .qbs-table-popup-footer {
|
|
433
|
+
flex-direction: row-reverse;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.qbs-table-reset-link {
|
|
437
|
+
background: none;
|
|
438
|
+
border: none;
|
|
439
|
+
padding: 0;
|
|
440
|
+
cursor: pointer;
|
|
441
|
+
font-size: 13px;
|
|
442
|
+
font-weight: 500;
|
|
443
|
+
color: inherit;
|
|
444
|
+
text-decoration: none;
|
|
445
|
+
}
|
|
446
|
+
|
|
414
447
|
.qbs-table-columns-label {
|
|
415
448
|
display: flex;
|
|
416
449
|
gap: 10px;
|
|
@@ -746,11 +779,32 @@
|
|
|
746
779
|
|
|
747
780
|
.qbs-table-top-icons {
|
|
748
781
|
color: #999696;
|
|
782
|
+
display: inline-flex;
|
|
783
|
+
align-items: center;
|
|
784
|
+
gap: 8px;
|
|
749
785
|
|
|
750
|
-
.active{
|
|
786
|
+
.active {
|
|
751
787
|
color: #EC6A17;
|
|
752
788
|
}
|
|
753
789
|
}
|
|
790
|
+
|
|
791
|
+
.qbs-row-switch-container {
|
|
792
|
+
display: inline-flex;
|
|
793
|
+
align-items: center;
|
|
794
|
+
gap: 8px;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
.qbs-table-view-btn {
|
|
798
|
+
display: inline-flex;
|
|
799
|
+
align-items: center;
|
|
800
|
+
justify-content: center;
|
|
801
|
+
padding: 0;
|
|
802
|
+
margin: 0;
|
|
803
|
+
border: none;
|
|
804
|
+
background: transparent;
|
|
805
|
+
cursor: pointer;
|
|
806
|
+
color: inherit;
|
|
807
|
+
}
|
|
754
808
|
.qbs-card-empty-wrapper {
|
|
755
809
|
display: flex;
|
|
756
810
|
justify-content: center;
|
|
@@ -4,6 +4,7 @@ import { Link } from 'react-router-dom';
|
|
|
4
4
|
import Cell from '../Cell';
|
|
5
5
|
import { handleCellFormat } from './utilities/handleFormatCell';
|
|
6
6
|
import MenuDropDown from './utilities/menuDropDown';
|
|
7
|
+
import VerticalMenuDropdown from './utilities/VerticalDropDownMenu';
|
|
7
8
|
|
|
8
9
|
const CHECKBOX_LINE_HEIGHT = '36px';
|
|
9
10
|
export const CheckCell: React.FC<any> = React.memo(
|
|
@@ -37,9 +38,26 @@ export const CheckCell: React.FC<any> = React.memo(
|
|
|
37
38
|
)
|
|
38
39
|
);
|
|
39
40
|
export const ActionCell: React.FC<any> = React.memo(
|
|
40
|
-
({
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
({
|
|
42
|
+
rowData,
|
|
43
|
+
handleMenuActions,
|
|
44
|
+
dataTheme,
|
|
45
|
+
actionProps,
|
|
46
|
+
tableBodyRef,
|
|
47
|
+
rowIndex,
|
|
48
|
+
dropType,
|
|
49
|
+
...props
|
|
50
|
+
}) => (
|
|
51
|
+
<Cell {...props} dataTheme={dataTheme} style={{ padding: 0 }}>
|
|
52
|
+
{dropType === 'vertical' ? (
|
|
53
|
+
<VerticalMenuDropdown
|
|
54
|
+
tableBodyRef={tableBodyRef}
|
|
55
|
+
actionDropDown={actionProps}
|
|
56
|
+
rowData={rowData}
|
|
57
|
+
rowIndex={rowIndex}
|
|
58
|
+
handleMenuActions={handleMenuActions}
|
|
59
|
+
/>
|
|
60
|
+
) : (
|
|
43
61
|
<MenuDropDown
|
|
44
62
|
tableBodyRef={tableBodyRef}
|
|
45
63
|
actionDropDown={actionProps}
|
|
@@ -48,14 +66,16 @@ export const ActionCell: React.FC<any> = React.memo(
|
|
|
48
66
|
rowIndex={rowIndex}
|
|
49
67
|
handleMenuActions={handleMenuActions}
|
|
50
68
|
/>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
)}
|
|
70
|
+
</Cell>
|
|
71
|
+
)
|
|
54
72
|
);
|
|
55
73
|
export const ExpandCell: React.FC<any> = React.memo(
|
|
56
74
|
({ rowData, dataKey, expandedRowKeys, onChange, ...props }) => (
|
|
57
75
|
<Cell {...props}>
|
|
58
76
|
<button
|
|
77
|
+
type="button"
|
|
78
|
+
className="qbs-table-expand-btn"
|
|
59
79
|
onClick={() => {
|
|
60
80
|
onChange(rowData);
|
|
61
81
|
}}
|
|
@@ -72,7 +92,7 @@ export const ExpandCell: React.FC<any> = React.memo(
|
|
|
72
92
|
fillRule="evenodd"
|
|
73
93
|
clipRule="evenodd"
|
|
74
94
|
d="M0.792893 0.292893C1.18342 -0.097631 1.81658 -0.097631 2.20711 0.292893L5.5 3.58579L8.79289 0.292893C9.18342 -0.0976311 9.81658 -0.0976311 10.2071 0.292893C10.5976 0.683417 10.5976 1.31658 10.2071 1.70711L6.20711 5.70711C5.81658 6.09763 5.18342 6.09763 4.79289 5.70711L0.792893 1.70711C0.402369 1.31658 0.402369 0.683417 0.792893 0.292893Z"
|
|
75
|
-
fill="
|
|
95
|
+
fill="currentColor"
|
|
76
96
|
/>
|
|
77
97
|
</svg>
|
|
78
98
|
) : (
|
|
@@ -87,7 +107,7 @@ export const ExpandCell: React.FC<any> = React.memo(
|
|
|
87
107
|
fillRule="evenodd"
|
|
88
108
|
clipRule="evenodd"
|
|
89
109
|
d="M0.792894 9.70711C0.402369 9.31658 0.402369 8.68342 0.792894 8.29289L4.08579 5L0.792893 1.70711C0.402369 1.31658 0.402369 0.683418 0.792893 0.292894C1.18342 -0.0976312 1.81658 -0.0976312 2.20711 0.292894L6.20711 4.29289C6.59763 4.68342 6.59763 5.31658 6.20711 5.70711L2.20711 9.70711C1.81658 10.0976 1.18342 10.0976 0.792894 9.70711Z"
|
|
90
|
-
fill="
|
|
110
|
+
fill="currentColor"
|
|
91
111
|
/>
|
|
92
112
|
</svg>
|
|
93
113
|
)}
|
|
@@ -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,
|
|
@@ -91,8 +92,20 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
91
92
|
childDetailHeading = '',
|
|
92
93
|
isCustomTableCardView = false,
|
|
93
94
|
handleTableCardView,
|
|
94
|
-
handleCustomCardLoader
|
|
95
|
+
handleCustomCardLoader,
|
|
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,
|
|
95
106
|
}) => {
|
|
107
|
+
const labels = useMemo(() => mergeQbsTableLabels(labelsProp), [labelsProp]);
|
|
108
|
+
const pinSide = rtl ? 'left' : 'right';
|
|
96
109
|
const [loading, setLoading] = useState(false);
|
|
97
110
|
const [columns, setColumns] = useState(propColumn);
|
|
98
111
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
@@ -251,7 +264,15 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
251
264
|
searchPlaceholder: searchPlaceholder,
|
|
252
265
|
setTableViewToggle: setTableViewToggle,
|
|
253
266
|
tableViewToggle: tableViewToggle,
|
|
254
|
-
enableTableToggle: enableTableToggle
|
|
267
|
+
enableTableToggle: enableTableToggle,
|
|
268
|
+
rowViewToggle,
|
|
269
|
+
defaultRowView,
|
|
270
|
+
fullWidthView,
|
|
271
|
+
setTableFullView,
|
|
272
|
+
setRowViewToggle,
|
|
273
|
+
isFullScreen,
|
|
274
|
+
labels,
|
|
275
|
+
rtl,
|
|
255
276
|
};
|
|
256
277
|
const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
|
|
257
278
|
|
|
@@ -583,6 +604,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
583
604
|
height={autoHeight ? undefined : height}
|
|
584
605
|
key={tableKey}
|
|
585
606
|
tableKey={tableKey}
|
|
607
|
+
rtl={rtl}
|
|
586
608
|
data={data}
|
|
587
609
|
tableBodyRef={tableBodyRef as React.RefObject<HTMLDivElement>}
|
|
588
610
|
dataTheme={dataTheme}
|
|
@@ -606,6 +628,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
606
628
|
columns={columns}
|
|
607
629
|
minHeight={minHeight}
|
|
608
630
|
headerHeight={headerHeight}
|
|
631
|
+
rowHeight={rowHeight}
|
|
609
632
|
rowExpandedHeight={rowExpandedHeight}
|
|
610
633
|
loading={isLoading ?? loading}
|
|
611
634
|
showHeader
|
|
@@ -705,7 +728,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
705
728
|
{columnsRendered}
|
|
706
729
|
{!actionProps ||
|
|
707
730
|
(actionProps?.length === 0 && columnToggle && (
|
|
708
|
-
<Column width={40} fixed=
|
|
731
|
+
<Column width={40} fixed={pinSide}>
|
|
709
732
|
<HeaderCell
|
|
710
733
|
verticalAlign={findGrouped() ? 'middle' : undefined}
|
|
711
734
|
className={` ${classes.headerlClass}`}
|
|
@@ -721,13 +744,15 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
721
744
|
setIsOpen={setIsOpen}
|
|
722
745
|
handleResetColumns={handleResetColumns}
|
|
723
746
|
handleColumnToggle={handleColumnToggle}
|
|
747
|
+
labels={labels}
|
|
748
|
+
rtl={rtl}
|
|
724
749
|
/>
|
|
725
750
|
</HeaderCell>
|
|
726
751
|
<Cell />
|
|
727
752
|
</Column>
|
|
728
753
|
))}
|
|
729
754
|
{actionProps && actionProps?.length > 0 && (
|
|
730
|
-
<Column width={40} fixed=
|
|
755
|
+
<Column width={40} fixed={pinSide}>
|
|
731
756
|
<HeaderCell
|
|
732
757
|
verticalAlign={findGrouped() ? 'middle' : undefined}
|
|
733
758
|
className={` ${classes.headerlClass}`}
|
|
@@ -746,6 +771,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
746
771
|
setIsOpen={setIsOpen}
|
|
747
772
|
handleResetColumns={handleResetColumns}
|
|
748
773
|
handleColumnToggle={handleColumnToggle}
|
|
774
|
+
labels={labels}
|
|
775
|
+
rtl={rtl}
|
|
749
776
|
/>
|
|
750
777
|
)}
|
|
751
778
|
</HeaderCell>
|
|
@@ -755,6 +782,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
755
782
|
className={`${classes.cellClass} ${classes.actionCellClass}`}
|
|
756
783
|
handleMenuActions={handleMenuActions}
|
|
757
784
|
dataTheme={dataTheme}
|
|
785
|
+
dropType={dropType}
|
|
758
786
|
/>
|
|
759
787
|
</Column>
|
|
760
788
|
)}
|
|
@@ -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,
|
|
@@ -81,8 +82,19 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
81
82
|
renderEmpty,
|
|
82
83
|
autoHeight,
|
|
83
84
|
emptySubTitle,
|
|
84
|
-
emptyTitle
|
|
85
|
+
emptyTitle,
|
|
86
|
+
dropType,
|
|
87
|
+
labels: labelsProp,
|
|
88
|
+
rtl = false,
|
|
89
|
+
rowViewToggle = false,
|
|
90
|
+
defaultRowView = true,
|
|
91
|
+
fullWidthView = false,
|
|
92
|
+
setTableFullView,
|
|
93
|
+
setRowViewToggle,
|
|
94
|
+
isFullScreen = false,
|
|
85
95
|
}) => {
|
|
96
|
+
const labels = useMemo(() => mergeQbsTableLabels(labelsProp), [labelsProp]);
|
|
97
|
+
const pinSide = rtl ? 'left' : 'right';
|
|
86
98
|
const [loading, setLoading] = useState(false);
|
|
87
99
|
const [columns, setColumns] = useState(propColumn);
|
|
88
100
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
@@ -236,7 +248,15 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
236
248
|
onSelect: handleClear,
|
|
237
249
|
handleColumnToggle: handleColumnToggle,
|
|
238
250
|
dataLength: data?.length,
|
|
239
|
-
searchPlaceholder: searchPlaceholder
|
|
251
|
+
searchPlaceholder: searchPlaceholder,
|
|
252
|
+
rowViewToggle,
|
|
253
|
+
defaultRowView,
|
|
254
|
+
fullWidthView,
|
|
255
|
+
setTableFullView,
|
|
256
|
+
setRowViewToggle,
|
|
257
|
+
isFullScreen,
|
|
258
|
+
labels,
|
|
259
|
+
rtl,
|
|
240
260
|
};
|
|
241
261
|
const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
|
|
242
262
|
|
|
@@ -454,6 +474,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
454
474
|
height={autoHeight ? undefined : height}
|
|
455
475
|
key={tableKey}
|
|
456
476
|
tableKey={tableKey}
|
|
477
|
+
rtl={rtl}
|
|
457
478
|
data={data}
|
|
458
479
|
tableBodyRef={tableBodyRef as React.RefObject<HTMLDivElement>}
|
|
459
480
|
dataTheme={dataTheme}
|
|
@@ -574,7 +595,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
574
595
|
{columnsRendered}
|
|
575
596
|
{!actionProps ||
|
|
576
597
|
(actionProps?.length === 0 && columnToggle && (
|
|
577
|
-
<Column width={40} fixed=
|
|
598
|
+
<Column width={40} fixed={pinSide}>
|
|
578
599
|
<HeaderCell
|
|
579
600
|
verticalAlign={findGrouped() ? 'middle' : undefined}
|
|
580
601
|
className={` ${classes.headerlClass}`}
|
|
@@ -590,13 +611,15 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
590
611
|
setIsOpen={setIsOpen}
|
|
591
612
|
handleResetColumns={handleResetColumns}
|
|
592
613
|
handleColumnToggle={handleColumnToggle}
|
|
614
|
+
labels={labels}
|
|
615
|
+
rtl={rtl}
|
|
593
616
|
/>
|
|
594
617
|
</HeaderCell>
|
|
595
618
|
<Cell />
|
|
596
619
|
</Column>
|
|
597
620
|
))}
|
|
598
621
|
{actionProps && actionProps?.length > 0 && (
|
|
599
|
-
<Column width={40} fixed=
|
|
622
|
+
<Column width={40} fixed={pinSide}>
|
|
600
623
|
<HeaderCell
|
|
601
624
|
verticalAlign={findGrouped() ? 'middle' : undefined}
|
|
602
625
|
className={` ${classes.headerlClass}`}
|
|
@@ -615,6 +638,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
615
638
|
setIsOpen={setIsOpen}
|
|
616
639
|
handleResetColumns={handleResetColumns}
|
|
617
640
|
handleColumnToggle={handleColumnToggle}
|
|
641
|
+
labels={labels}
|
|
642
|
+
rtl={rtl}
|
|
618
643
|
/>
|
|
619
644
|
)}
|
|
620
645
|
</HeaderCell>
|
|
@@ -624,6 +649,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
624
649
|
className={`${classes.cellClass} ${classes.actionCellClass}`}
|
|
625
650
|
handleMenuActions={handleMenuActions}
|
|
626
651
|
dataTheme={dataTheme}
|
|
652
|
+
dropType={dropType}
|
|
627
653
|
/>
|
|
628
654
|
</Column>
|
|
629
655
|
)}
|
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,17 @@ 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,
|
|
39
|
+
rtl = false,
|
|
31
40
|
}) => {
|
|
41
|
+
const labels = useMemo(() => mergeQbsTableLabels(labelsProp), [labelsProp]);
|
|
32
42
|
const debouncedOnSearch = useCallback(debounce(onSearch ?? (() => {}), 1000), [onSearch]);
|
|
33
43
|
const [searchParam, setSearchParam] = useState<string | undefined>(searchValue);
|
|
34
44
|
const toolbarRef = useRef<HTMLDivElement>(null);
|
|
@@ -39,7 +49,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
39
49
|
debouncedOnSearch(e);
|
|
40
50
|
}
|
|
41
51
|
},
|
|
42
|
-
[debouncedOnSearch]
|
|
52
|
+
[debouncedOnSearch],
|
|
43
53
|
);
|
|
44
54
|
|
|
45
55
|
const handleChange = useCallback(
|
|
@@ -51,29 +61,30 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
51
61
|
handleSearchValue?.(e);
|
|
52
62
|
}
|
|
53
63
|
},
|
|
54
|
-
[asyncSearch, handleSearch, handleSearchValue]
|
|
64
|
+
[asyncSearch, handleSearch, handleSearchValue],
|
|
55
65
|
);
|
|
56
|
-
const handleHide = (actions:
|
|
66
|
+
const handleHide = (actions: { hidden?: boolean; customHide?: string }) => {
|
|
57
67
|
if (actions.hidden) {
|
|
58
68
|
return false;
|
|
59
|
-
} else if (actions.customHide == '>2') {
|
|
60
|
-
return checkedKeys && checkedKeys?.length >= 2 ? true : false;
|
|
61
|
-
} else {
|
|
62
|
-
return true;
|
|
63
69
|
}
|
|
70
|
+
if (actions.customHide === '>2') {
|
|
71
|
+
return checkedKeys && checkedKeys?.length >= 2;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
64
74
|
};
|
|
65
75
|
const isMobile = useResponsiveStore();
|
|
66
76
|
const handleFilterClick = () => {
|
|
67
77
|
setIsOpen(!isOpen);
|
|
68
78
|
};
|
|
79
|
+
|
|
69
80
|
return (
|
|
70
|
-
<div className="qbs-table-toolbar-container" ref={toolbarRef}>
|
|
71
|
-
<div className={`qbs-table-toolbar ${className}`}>
|
|
81
|
+
<div className="qbs-table-toolbar-container" ref={toolbarRef} dir={rtl ? 'rtl' : 'ltr'}>
|
|
82
|
+
<div className={`qbs-table-toolbar ${className ?? ''}`}>
|
|
72
83
|
<div className="start-container" style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
73
84
|
<div className="qbs-table-primary-filter">
|
|
74
85
|
{search && (
|
|
75
86
|
<SearchInput
|
|
76
|
-
placeholder={searchPlaceholder ?? 'Search'}
|
|
87
|
+
placeholder={searchPlaceholder ?? labels.search ?? 'Search'}
|
|
77
88
|
handleChange={handleChange}
|
|
78
89
|
handleSearch={handleSearch}
|
|
79
90
|
searchValue={searchParam}
|
|
@@ -103,22 +114,79 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
103
114
|
</span>
|
|
104
115
|
)}
|
|
105
116
|
{tableHeaderActions}
|
|
106
|
-
<div className="
|
|
117
|
+
<div className="pr-1 cursor-pointer relative table_custom_ctions">
|
|
118
|
+
{(rowViewToggle || isFullScreen) && (
|
|
119
|
+
<div className="flex gap-2 qbs-row-switch-container">
|
|
120
|
+
{rowViewToggle && (
|
|
121
|
+
<div className="flex gap-2 table_cell_style qbs-table-top-icons">
|
|
122
|
+
<TooltipComponent
|
|
123
|
+
tableBodyRef={toolbarRef}
|
|
124
|
+
title={labels.switchToDefaultView ?? ''}
|
|
125
|
+
>
|
|
126
|
+
<button
|
|
127
|
+
type="button"
|
|
128
|
+
className="qbs-table-view-btn"
|
|
129
|
+
onClick={() => setRowViewToggle?.(true)}
|
|
130
|
+
>
|
|
131
|
+
<DefaultView className={`${defaultRowView ? 'active' : ''}`} />
|
|
132
|
+
</button>
|
|
133
|
+
</TooltipComponent>
|
|
134
|
+
<TooltipComponent
|
|
135
|
+
tableBodyRef={toolbarRef}
|
|
136
|
+
title={labels.switchToRelaxedView ?? ''}
|
|
137
|
+
>
|
|
138
|
+
<button
|
|
139
|
+
type="button"
|
|
140
|
+
className="qbs-table-view-btn"
|
|
141
|
+
onClick={() => setRowViewToggle?.(false)}
|
|
142
|
+
>
|
|
143
|
+
<ContentView className={`${!defaultRowView ? 'active' : ''}`} />
|
|
144
|
+
</button>
|
|
145
|
+
</TooltipComponent>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
{isFullScreen && (
|
|
149
|
+
<div className="table_full_width qbs-table-top-icons">
|
|
150
|
+
<TooltipComponent
|
|
151
|
+
tableBodyRef={toolbarRef}
|
|
152
|
+
title={labels.switchToFullScreen ?? ''}
|
|
153
|
+
>
|
|
154
|
+
<button
|
|
155
|
+
type="button"
|
|
156
|
+
className="qbs-table-view-btn"
|
|
157
|
+
onClick={() => setTableFullView?.(!fullWidthView)}
|
|
158
|
+
>
|
|
159
|
+
<ExpandIcon className={`${fullWidthView ? 'active' : ''}`} />
|
|
160
|
+
</button>
|
|
161
|
+
</TooltipComponent>
|
|
162
|
+
</div>
|
|
163
|
+
)}
|
|
164
|
+
</div>
|
|
165
|
+
)}
|
|
166
|
+
|
|
107
167
|
{enableTableToggle && !isMobile && (
|
|
108
168
|
<div className="qbs-table-top-icons flex gap-2">
|
|
109
|
-
<TooltipComponent tableBodyRef={toolbarRef} title={
|
|
110
|
-
<
|
|
169
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToTableView ?? ''}>
|
|
170
|
+
<button
|
|
171
|
+
type="button"
|
|
172
|
+
className="qbs-table-view-btn"
|
|
173
|
+
onClick={() => setTableViewToggle?.(true)}
|
|
174
|
+
>
|
|
111
175
|
<TableView className={`${tableViewToggle ? 'active' : ''}`} />
|
|
112
|
-
</
|
|
176
|
+
</button>
|
|
113
177
|
</TooltipComponent>
|
|
114
178
|
|
|
115
|
-
<div className="border-r h-4 w-1"
|
|
179
|
+
<div className="border-r h-4 w-1" />
|
|
116
180
|
|
|
117
|
-
<
|
|
118
|
-
<
|
|
181
|
+
<TooltipComponent tableBodyRef={toolbarRef} title={labels.switchToCardView ?? ''}>
|
|
182
|
+
<button
|
|
183
|
+
type="button"
|
|
184
|
+
className="qbs-table-view-btn"
|
|
185
|
+
onClick={() => setTableViewToggle?.(false)}
|
|
186
|
+
>
|
|
119
187
|
<CardView className={`${!tableViewToggle ? 'active' : ''}`} />
|
|
120
|
-
</
|
|
121
|
-
</
|
|
188
|
+
</button>
|
|
189
|
+
</TooltipComponent>
|
|
122
190
|
</div>
|
|
123
191
|
)}
|
|
124
192
|
</div>
|
|
@@ -141,16 +209,18 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
141
209
|
>
|
|
142
210
|
{checkedKeys && checkedKeys?.length > 0 ? (
|
|
143
211
|
<div className="qbs-table-toolbar-sub-container-start">
|
|
144
|
-
<div className="selected-row">
|
|
212
|
+
<div className="selected-row">
|
|
213
|
+
{formatSelectedItems(checkedKeys.length, labels)}
|
|
214
|
+
</div>
|
|
145
215
|
<div className="selected-row-action">
|
|
146
|
-
<button className="btn" onClick={() => onSelect?.([])}>
|
|
147
|
-
|
|
216
|
+
<button type="button" className="btn" onClick={() => onSelect?.([])}>
|
|
217
|
+
{labels.clear}
|
|
148
218
|
</button>
|
|
149
219
|
{selectedRowActions?.map((actions, index: number) => (
|
|
150
|
-
|
|
220
|
+
<React.Fragment key={index.toString()}>
|
|
151
221
|
{handleHide(actions) && (
|
|
152
222
|
<button
|
|
153
|
-
|
|
223
|
+
type="button"
|
|
154
224
|
className="btn"
|
|
155
225
|
disabled={actions.disabled}
|
|
156
226
|
onClick={() => actions?.action(checkedKeys)}
|
|
@@ -158,7 +228,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
158
228
|
{actions.actionTitle}
|
|
159
229
|
</button>
|
|
160
230
|
)}
|
|
161
|
-
|
|
231
|
+
</React.Fragment>
|
|
162
232
|
))}
|
|
163
233
|
</div>
|
|
164
234
|
</div>
|
|
@@ -169,7 +239,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
|
|
|
169
239
|
{getRowDisplayRange(
|
|
170
240
|
paginationProps.total ?? 0,
|
|
171
241
|
paginationProps.rowsPerPage ?? 0,
|
|
172
|
-
paginationProps.currentPage ?? 0
|
|
242
|
+
paginationProps.currentPage ?? 0,
|
|
173
243
|
)}
|
|
174
244
|
</div>
|
|
175
245
|
)}
|
|
@@ -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;
|
|
@@ -87,6 +89,9 @@ export interface QbsTableProps {
|
|
|
87
89
|
expandedRowKeys?: readonly number[];
|
|
88
90
|
setExpandedRowKeys?: (value: readonly number[]) => void;
|
|
89
91
|
handleMenuActions?: (actions: ActionProps, rowData: any) => void;
|
|
92
|
+
dropType?: 'vertical' | string;
|
|
93
|
+
labels?: QbsTableLabels;
|
|
94
|
+
rtl?: boolean;
|
|
90
95
|
handleRowExpanded?: (rowData: any) => React.ReactNode;
|
|
91
96
|
shouldUpdateScroll?: boolean;
|
|
92
97
|
rowExpand?: boolean;
|
|
@@ -130,6 +135,13 @@ export interface QbsTableProps {
|
|
|
130
135
|
handleTableCardView?: (data: any) => React.ReactNode;
|
|
131
136
|
isCustomTableCardView?: boolean;
|
|
132
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;
|
|
133
145
|
}
|
|
134
146
|
|
|
135
147
|
export interface QbsTableToolbarProps {
|
|
@@ -159,6 +171,14 @@ export interface QbsTableToolbarProps {
|
|
|
159
171
|
enableTableToggle?: boolean;
|
|
160
172
|
tableViewToggle?: boolean;
|
|
161
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;
|
|
162
182
|
selectedRowActions?: {
|
|
163
183
|
actionTitle?: string;
|
|
164
184
|
action: (checked: (number | string)[]) => void;
|