qbs-react-grid 1.3.16 → 2.0.2
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/es/ColumnGroup.js +1 -1
- package/es/ColumnResizeHandler.js +2 -2
- package/es/Scrollbar.js +1 -1
- package/es/Table.d.ts +1 -1
- package/es/qbsTable/CustomTableCell.js +4 -4
- package/es/qbsTable/QbsTable.js +120 -8
- package/es/qbsTable/TableCardList.js +1 -1
- package/es/utils/getTableColumns.js +10 -10
- package/es/utils/useAffix.d.ts +4 -4
- package/es/utils/useAffix.js +5 -5
- package/es/utils/useCellDescriptor.d.ts +2 -2
- package/es/utils/useCellDescriptor.js +1 -0
- package/es/utils/usePosition.d.ts +5 -5
- package/es/utils/usePosition.js +3 -3
- package/es/utils/useScrollListener.d.ts +4 -4
- package/es/utils/useScrollListener.js +15 -15
- package/es/utils/useTableDimension.d.ts +11 -11
- package/es/utils/useTableDimension.js +2 -2
- package/es/utils/useTableRows.d.ts +1 -1
- package/lib/ColumnGroup.js +1 -1
- package/lib/ColumnResizeHandler.js +2 -2
- package/lib/Scrollbar.js +1 -1
- package/lib/Table.d.ts +1 -1
- package/lib/qbsTable/CustomTableCell.js +4 -4
- package/lib/qbsTable/QbsTable.js +120 -8
- package/lib/qbsTable/TableCardList.js +1 -1
- package/lib/utils/getTableColumns.js +10 -10
- package/lib/utils/useAffix.d.ts +4 -4
- package/lib/utils/useAffix.js +5 -5
- package/lib/utils/useCellDescriptor.d.ts +2 -2
- package/lib/utils/useCellDescriptor.js +1 -0
- package/lib/utils/usePosition.d.ts +5 -5
- package/lib/utils/usePosition.js +3 -3
- package/lib/utils/useScrollListener.d.ts +4 -4
- package/lib/utils/useScrollListener.js +14 -14
- package/lib/utils/useTableDimension.d.ts +11 -11
- package/lib/utils/useTableDimension.js +2 -2
- package/lib/utils/useTableRows.d.ts +1 -1
- package/package.json +7 -7
- package/src/ColumnGroup.tsx +25 -11
- package/src/ColumnResizeHandler.tsx +2 -2
- package/src/Scrollbar.tsx +1 -1
- package/src/Table.tsx +4 -4
- package/src/qbsTable/CustomTableCell.tsx +46 -48
- package/src/qbsTable/QbsTable.tsx +220 -116
- package/src/qbsTable/TableCardList.tsx +2 -2
- package/src/utils/getTableColumns.ts +4 -4
- package/src/utils/useAffix.ts +11 -11
- package/src/utils/useCellDescriptor.ts +5 -5
- package/src/utils/usePosition.ts +9 -9
- package/src/utils/useScrollListener.ts +19 -19
- package/src/utils/useTableDimension.ts +4 -4
|
@@ -110,21 +110,21 @@ export const CustomTableCell: React.FC<any> = React.memo(
|
|
|
110
110
|
...props
|
|
111
111
|
}) => {
|
|
112
112
|
return (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
113
|
+
<Cell {...props} dataKey={dataKey}>
|
|
114
|
+
{link && !path && !hideLink?.(rowData) ? (
|
|
115
|
+
<a onClick={() => rowClick?.(rowData)} className="qbs-table-row-link">
|
|
116
|
+
{renderCell ? renderCell(rowData)?.cell : handleCellFormat(rowData[dataKey], type)}
|
|
117
|
+
</a>
|
|
118
|
+
) : path && !hideLink?.(rowData) ? (
|
|
119
|
+
<Link to={path?.(rowData) ?? ''} className="qbs-table-row-link">
|
|
120
|
+
{renderCell ? renderCell(rowData)?.cell : handleCellFormat(rowData[dataKey], type)}
|
|
121
|
+
</Link>
|
|
122
|
+
) : renderCell ? (
|
|
123
|
+
renderCell(rowData)?.cell
|
|
124
|
+
) : (
|
|
125
|
+
handleCellFormat(rowData[dataKey], type)
|
|
126
|
+
)}
|
|
127
|
+
</Cell>
|
|
128
128
|
);
|
|
129
129
|
}
|
|
130
130
|
);
|
|
@@ -149,41 +149,39 @@ export const CustomRowStatus: React.FC<any> = React.memo(
|
|
|
149
149
|
};
|
|
150
150
|
|
|
151
151
|
return (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
onClick={() => rowClick?.(rowData)}
|
|
165
|
-
>
|
|
166
|
-
{getIcon?.(rowData)}
|
|
167
|
-
</span>
|
|
168
|
-
) : (
|
|
169
|
-
<Link
|
|
170
|
-
style={{ height: 24, width: 24 }}
|
|
171
|
-
to={path?.(rowData) ?? ''}
|
|
172
|
-
className="qbs-table-row-link"
|
|
173
|
-
>
|
|
174
|
-
{getIcon?.(rowData)}
|
|
175
|
-
</Link>
|
|
176
|
-
)}
|
|
177
|
-
<div
|
|
178
|
-
ref={dropRef}
|
|
179
|
-
className={`row-status-tooltip ${dropdownPosition}`}
|
|
180
|
-
style={{ position: 'fixed' }}
|
|
152
|
+
<Cell
|
|
153
|
+
{...props}
|
|
154
|
+
dataKey={dataKey}
|
|
155
|
+
style={{ padding: 0, display: 'flex', justifyContent: 'center', alignItems: 'center' }}
|
|
156
|
+
onMouseEnter={() => adjustDropdownPosition()}
|
|
157
|
+
>
|
|
158
|
+
<div className="row-status">
|
|
159
|
+
{!path ? (
|
|
160
|
+
<span
|
|
161
|
+
ref={menuButtonRef}
|
|
162
|
+
style={{ height: 24, width: 24, display: 'flex' }}
|
|
163
|
+
onClick={() => rowClick?.(rowData)}
|
|
181
164
|
>
|
|
182
|
-
{
|
|
183
|
-
</
|
|
165
|
+
{getIcon?.(rowData)}
|
|
166
|
+
</span>
|
|
167
|
+
) : (
|
|
168
|
+
<Link
|
|
169
|
+
style={{ height: 24, width: 24 }}
|
|
170
|
+
to={path?.(rowData) ?? ''}
|
|
171
|
+
className="qbs-table-row-link"
|
|
172
|
+
>
|
|
173
|
+
{getIcon?.(rowData)}
|
|
174
|
+
</Link>
|
|
175
|
+
)}
|
|
176
|
+
<div
|
|
177
|
+
ref={dropRef}
|
|
178
|
+
className={`row-status-tooltip ${dropdownPosition}`}
|
|
179
|
+
style={{ position: 'fixed' }}
|
|
180
|
+
>
|
|
181
|
+
{getToolTip?.(rowData)}
|
|
184
182
|
</div>
|
|
185
|
-
</
|
|
186
|
-
|
|
183
|
+
</div>
|
|
184
|
+
</Cell>
|
|
187
185
|
);
|
|
188
186
|
}
|
|
189
187
|
);
|
|
@@ -98,7 +98,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
98
98
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
99
99
|
const dataTheme = useMemo(() => localStorage.getItem('theme') ?? theme, [theme]);
|
|
100
100
|
const [isOpen, setIsOpen] = useState(false);
|
|
101
|
-
const prevColumns = useRef<any | null>();
|
|
101
|
+
const prevColumns = useRef<any | null>(null);
|
|
102
102
|
const [tableViewToggle, setTableViewToggle] = useState(tableView);
|
|
103
103
|
const isMobile = useResponsiveStore();
|
|
104
104
|
const tableBodyRef = useRef<HTMLDivElement>(null);
|
|
@@ -338,125 +338,229 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
338
338
|
const findGrouped = () => {
|
|
339
339
|
return columns?.find(item => item.grouped) ? true : false;
|
|
340
340
|
};
|
|
341
|
+
// const columnsRendered: React.ReactElement[] = useMemo(
|
|
342
|
+
// () =>
|
|
343
|
+
// (columns ?? []).map(
|
|
344
|
+
// ({
|
|
345
|
+
// title,
|
|
346
|
+
// field,
|
|
347
|
+
// resizable,
|
|
348
|
+
// sortable,
|
|
349
|
+
// colWidth,
|
|
350
|
+
// align,
|
|
351
|
+
// grouped,
|
|
352
|
+
// groupHeader,
|
|
353
|
+
// fixed,
|
|
354
|
+
// children,
|
|
355
|
+
// customCell,
|
|
356
|
+
// renderCell,
|
|
357
|
+
// isVisible,
|
|
358
|
+
// link,
|
|
359
|
+
// getPath,
|
|
360
|
+
// rowClick,
|
|
361
|
+
// sortKey,
|
|
362
|
+
// type,
|
|
363
|
+
// hideLink
|
|
364
|
+
// }) =>
|
|
365
|
+
// isVisible &&
|
|
366
|
+
// (grouped ? (
|
|
367
|
+
// <ColumnGroup
|
|
368
|
+
// header={groupHeader}
|
|
369
|
+
// fixed={fixed}
|
|
370
|
+
// align={align}
|
|
371
|
+
// verticalAlign="middle"
|
|
372
|
+
// groupHeaderHeight={40}
|
|
373
|
+
// >
|
|
374
|
+
// {children?.map(child => (
|
|
375
|
+
// <Column
|
|
376
|
+
// key={child.title}
|
|
377
|
+
// sortable={child.sortable}
|
|
378
|
+
// width={child.colWidth ?? COLUMN_WIDTH}
|
|
379
|
+
// resizable={child.resizable}
|
|
380
|
+
// align={child.align}
|
|
381
|
+
// onResize={handleColumnWidth}
|
|
382
|
+
// fixed={child.fixed}
|
|
383
|
+
// >
|
|
384
|
+
// <HeaderCell
|
|
385
|
+
// dataTheme={dataTheme}
|
|
386
|
+
// verticalAlign={'middle'}
|
|
387
|
+
// className={` ${classes.headerClass}`}
|
|
388
|
+
// sortKey={child.sortKey}
|
|
389
|
+
// renderSortIcon={renderSortIcon}
|
|
390
|
+
// >
|
|
391
|
+
// {child.title}
|
|
392
|
+
// </HeaderCell>
|
|
393
|
+
// {child.customCell || child.link ? (
|
|
394
|
+
// <CustomTableCell
|
|
395
|
+
// renderCell={child.renderCell}
|
|
396
|
+
// dataKey={child.field}
|
|
397
|
+
// dataTheme={dataTheme}
|
|
398
|
+
// type={child.type}
|
|
399
|
+
// path={child.getPath}
|
|
400
|
+
// link={child.link}
|
|
401
|
+
// />
|
|
402
|
+
// ) : (
|
|
403
|
+
// <Cell
|
|
404
|
+
// className={` ${classes.cellClass}`}
|
|
405
|
+
// dataKey={child.field}
|
|
406
|
+
// dataTheme={dataTheme}
|
|
407
|
+
// />
|
|
408
|
+
// )}
|
|
409
|
+
// </Column>
|
|
410
|
+
// ))}
|
|
411
|
+
// </ColumnGroup>
|
|
412
|
+
// ) : (
|
|
413
|
+
// <Column
|
|
414
|
+
// key={title}
|
|
415
|
+
// sortable={sortable}
|
|
416
|
+
// width={colWidth ?? COLUMN_WIDTH}
|
|
417
|
+
// resizable={resizable}
|
|
418
|
+
// align={align}
|
|
419
|
+
// fixed={fixed}
|
|
420
|
+
// onResize={handleColumnWidth}
|
|
421
|
+
// >
|
|
422
|
+
// <HeaderCell
|
|
423
|
+
// dataTheme={dataTheme}
|
|
424
|
+
// verticalAlign={findGrouped() ? 'middle' : undefined}
|
|
425
|
+
// className={` ${classes.headerClass}`}
|
|
426
|
+
// sortKey={sortKey}
|
|
427
|
+
// renderSortIcon={renderSortIcon}
|
|
428
|
+
// >
|
|
429
|
+
// {title}
|
|
430
|
+
// </HeaderCell>
|
|
431
|
+
// {customCell || link ? (
|
|
432
|
+
// <CustomTableCell
|
|
433
|
+
// renderCell={renderCell}
|
|
434
|
+
// dataKey={field}
|
|
435
|
+
// rowClick={rowClick}
|
|
436
|
+
// type={type}
|
|
437
|
+
// hideLink={hideLink}
|
|
438
|
+
// path={getPath}
|
|
439
|
+
// dataTheme={dataTheme}
|
|
440
|
+
// link={link}
|
|
441
|
+
// />
|
|
442
|
+
// ) : (
|
|
443
|
+
// <Cell dataKey={field} dataTheme={dataTheme} className={` ${classes.cellClass}`} />
|
|
444
|
+
// )}
|
|
445
|
+
// </Column>
|
|
446
|
+
// ))
|
|
447
|
+
// ),
|
|
448
|
+
// [columns, dataTheme]
|
|
449
|
+
// );
|
|
341
450
|
const columnsRendered: React.ReactElement[] = useMemo(
|
|
342
451
|
() =>
|
|
343
|
-
(columns ?? [])
|
|
344
|
-
(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
{
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
onResize={handleColumnWidth}
|
|
385
|
-
fixed={child.fixed}
|
|
386
|
-
>
|
|
387
|
-
<HeaderCell
|
|
388
|
-
dataTheme={dataTheme}
|
|
389
|
-
verticalAlign={'middle'}
|
|
390
|
-
className={` ${classes.headerClass}`}
|
|
391
|
-
sortKey={child.sortKey}
|
|
392
|
-
renderSortIcon={renderSortIcon}
|
|
393
|
-
>
|
|
394
|
-
{child.title}
|
|
395
|
-
</HeaderCell>
|
|
396
|
-
{child.customCell || child.link ? (
|
|
397
|
-
<CustomTableCell
|
|
398
|
-
renderCell={child.renderCell}
|
|
399
|
-
dataKey={child.field}
|
|
400
|
-
dataTheme={dataTheme}
|
|
401
|
-
type={child.type}
|
|
402
|
-
path={child.getPath}
|
|
403
|
-
link={child.link}
|
|
404
|
-
/>
|
|
405
|
-
) : (
|
|
406
|
-
<Cell
|
|
407
|
-
className={` ${classes.cellClass}`}
|
|
408
|
-
dataKey={child.field}
|
|
409
|
-
dataTheme={dataTheme}
|
|
410
|
-
/>
|
|
411
|
-
)}
|
|
412
|
-
</Column>
|
|
413
|
-
))}
|
|
414
|
-
</>
|
|
415
|
-
</ColumnGroup>
|
|
416
|
-
) : (
|
|
417
|
-
<Column
|
|
418
|
-
key={title}
|
|
419
|
-
sortable={sortable}
|
|
420
|
-
width={colWidth ?? COLUMN_WIDTH}
|
|
421
|
-
resizable={resizable}
|
|
422
|
-
align={align}
|
|
423
|
-
fixed={fixed}
|
|
424
|
-
onResize={handleColumnWidth}
|
|
425
|
-
>
|
|
426
|
-
<HeaderCell
|
|
427
|
-
dataTheme={dataTheme}
|
|
428
|
-
verticalAlign={findGrouped() ? 'middle' : undefined}
|
|
429
|
-
className={` ${classes.headerClass}`}
|
|
430
|
-
sortKey={sortKey}
|
|
431
|
-
renderSortIcon={renderSortIcon}
|
|
452
|
+
(columns ?? [])
|
|
453
|
+
.map(
|
|
454
|
+
({
|
|
455
|
+
title,
|
|
456
|
+
field,
|
|
457
|
+
resizable,
|
|
458
|
+
sortable,
|
|
459
|
+
colWidth,
|
|
460
|
+
align,
|
|
461
|
+
grouped,
|
|
462
|
+
groupHeader,
|
|
463
|
+
fixed,
|
|
464
|
+
children,
|
|
465
|
+
customCell,
|
|
466
|
+
renderCell,
|
|
467
|
+
isVisible,
|
|
468
|
+
link,
|
|
469
|
+
getPath,
|
|
470
|
+
rowClick,
|
|
471
|
+
sortKey,
|
|
472
|
+
type,
|
|
473
|
+
hideLink
|
|
474
|
+
}) =>
|
|
475
|
+
isVisible ? (
|
|
476
|
+
grouped ? (
|
|
477
|
+
<ColumnGroup
|
|
478
|
+
header={groupHeader}
|
|
479
|
+
fixed={fixed}
|
|
480
|
+
align={align}
|
|
481
|
+
verticalAlign="middle"
|
|
482
|
+
groupHeaderHeight={40}
|
|
483
|
+
>
|
|
484
|
+
{children?.map(child => (
|
|
485
|
+
<Column
|
|
486
|
+
key={child.title}
|
|
487
|
+
sortable={child.sortable}
|
|
488
|
+
width={child.colWidth ?? COLUMN_WIDTH}
|
|
489
|
+
resizable={child.resizable}
|
|
490
|
+
align={child.align}
|
|
491
|
+
onResize={handleColumnWidth}
|
|
492
|
+
fixed={child.fixed}
|
|
432
493
|
>
|
|
433
|
-
|
|
434
|
-
</HeaderCell>
|
|
435
|
-
{customCell || link ? (
|
|
436
|
-
<CustomTableCell
|
|
437
|
-
renderCell={renderCell}
|
|
438
|
-
dataKey={field}
|
|
439
|
-
rowClick={rowClick}
|
|
440
|
-
type={type}
|
|
441
|
-
hideLink={hideLink}
|
|
442
|
-
path={getPath}
|
|
494
|
+
<HeaderCell
|
|
443
495
|
dataTheme={dataTheme}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
496
|
+
verticalAlign="middle"
|
|
497
|
+
className={` ${classes.headerClass}`}
|
|
498
|
+
sortKey={child.sortKey}
|
|
499
|
+
renderSortIcon={renderSortIcon}
|
|
500
|
+
>
|
|
501
|
+
{child.title}
|
|
502
|
+
</HeaderCell>
|
|
503
|
+
{child.customCell || child.link ? (
|
|
504
|
+
<CustomTableCell
|
|
505
|
+
renderCell={child.renderCell}
|
|
506
|
+
dataKey={child.field}
|
|
507
|
+
dataTheme={dataTheme}
|
|
508
|
+
type={child.type}
|
|
509
|
+
path={child.getPath}
|
|
510
|
+
link={child.link}
|
|
511
|
+
/>
|
|
512
|
+
) : (
|
|
513
|
+
<Cell
|
|
514
|
+
className={` ${classes.cellClass}`}
|
|
515
|
+
dataKey={child.field}
|
|
516
|
+
dataTheme={dataTheme}
|
|
517
|
+
/>
|
|
518
|
+
)}
|
|
519
|
+
</Column>
|
|
520
|
+
))}
|
|
521
|
+
</ColumnGroup>
|
|
522
|
+
) : (
|
|
523
|
+
<Column
|
|
524
|
+
key={title}
|
|
525
|
+
sortable={sortable}
|
|
526
|
+
width={colWidth ?? COLUMN_WIDTH}
|
|
527
|
+
resizable={resizable}
|
|
528
|
+
align={align}
|
|
529
|
+
fixed={fixed}
|
|
530
|
+
onResize={handleColumnWidth}
|
|
531
|
+
>
|
|
532
|
+
<HeaderCell
|
|
533
|
+
dataTheme={dataTheme}
|
|
534
|
+
verticalAlign={findGrouped() ? 'middle' : undefined}
|
|
535
|
+
className={` ${classes.headerClass}`}
|
|
536
|
+
sortKey={sortKey}
|
|
537
|
+
renderSortIcon={renderSortIcon}
|
|
538
|
+
>
|
|
539
|
+
{title}
|
|
540
|
+
</HeaderCell>
|
|
541
|
+
{customCell || link ? (
|
|
542
|
+
<CustomTableCell
|
|
543
|
+
renderCell={renderCell}
|
|
544
|
+
dataKey={field}
|
|
545
|
+
rowClick={rowClick}
|
|
546
|
+
type={type}
|
|
547
|
+
hideLink={hideLink}
|
|
548
|
+
path={getPath}
|
|
549
|
+
dataTheme={dataTheme}
|
|
550
|
+
link={link}
|
|
551
|
+
/>
|
|
552
|
+
) : (
|
|
553
|
+
<Cell
|
|
554
|
+
dataKey={field}
|
|
555
|
+
dataTheme={dataTheme}
|
|
556
|
+
className={` ${classes.cellClass}`}
|
|
557
|
+
/>
|
|
558
|
+
)}
|
|
559
|
+
</Column>
|
|
560
|
+
)
|
|
561
|
+
) : null // ✅ Fix: Return `null` instead of `false`
|
|
458
562
|
)
|
|
459
|
-
|
|
563
|
+
.filter(Boolean) as React.ReactElement[], // ✅ Fix: Type assertion to ReactElement[]
|
|
460
564
|
[columns, dataTheme]
|
|
461
565
|
);
|
|
462
566
|
|
|
@@ -470,7 +574,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
470
574
|
key={tableKey}
|
|
471
575
|
tableKey={tableKey}
|
|
472
576
|
data={data}
|
|
473
|
-
tableBodyRef={tableBodyRef}
|
|
577
|
+
tableBodyRef={tableBodyRef as React.RefObject<HTMLDivElement>}
|
|
474
578
|
dataTheme={dataTheme}
|
|
475
579
|
wordWrap={wordWrap}
|
|
476
580
|
autoHeight={autoHeight}
|
|
@@ -88,7 +88,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
88
88
|
const [checkedKeys, setCheckedKeys] = useState<(number | string)[]>([]);
|
|
89
89
|
const dataTheme = useMemo(() => localStorage.getItem('theme') ?? theme, [theme]);
|
|
90
90
|
const [isOpen, setIsOpen] = useState(false);
|
|
91
|
-
const prevColumns = useRef<any | null>();
|
|
91
|
+
const prevColumns = useRef<any | null>(null);
|
|
92
92
|
const tableBodyRef = useRef<HTMLDivElement>(null);
|
|
93
93
|
const handleSortColumn = useCallback(
|
|
94
94
|
(sortColumn: any, sortType: any) => {
|
|
@@ -445,7 +445,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
|
|
|
445
445
|
key={tableKey}
|
|
446
446
|
tableKey={tableKey}
|
|
447
447
|
data={data}
|
|
448
|
-
tableBodyRef={tableBodyRef}
|
|
448
|
+
tableBodyRef={tableBodyRef as React.RefObject<HTMLDivElement>}
|
|
449
449
|
dataTheme={dataTheme}
|
|
450
450
|
wordWrap={wordWrap}
|
|
451
451
|
autoHeight={autoHeight}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import flatten from 'lodash/flatten';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import * as ReactIs from 'react-is';
|
|
3
|
-
import flatten from 'lodash/flatten';
|
|
4
4
|
import ColumnGroup from '../ColumnGroup';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -11,7 +11,7 @@ import ColumnGroup from '../ColumnGroup';
|
|
|
11
11
|
function getTableColumns(children) {
|
|
12
12
|
const childrenArray = Array.isArray(children) ? children : [children];
|
|
13
13
|
|
|
14
|
-
const flattenColumns = flatten(childrenArray).map((column:
|
|
14
|
+
const flattenColumns = flatten(childrenArray).map((column: any) => {
|
|
15
15
|
// If the column is a group, we need to get the columns from the children.
|
|
16
16
|
if (column?.type === ColumnGroup) {
|
|
17
17
|
const {
|
|
@@ -21,7 +21,7 @@ function getTableColumns(children) {
|
|
|
21
21
|
fixed,
|
|
22
22
|
verticalAlign,
|
|
23
23
|
groupHeaderHeight
|
|
24
|
-
} = column?.props;
|
|
24
|
+
} = column?.props as any;
|
|
25
25
|
|
|
26
26
|
const childColumns = getTableColumns(groupChildren);
|
|
27
27
|
|
|
@@ -56,7 +56,7 @@ function getTableColumns(children) {
|
|
|
56
56
|
});
|
|
57
57
|
} else if (ReactIs.isFragment(column)) {
|
|
58
58
|
// If the column is a fragment, we need to get the columns from the children.
|
|
59
|
-
return getTableColumns(column.props?.children);
|
|
59
|
+
return getTableColumns(column.props?.children as any);
|
|
60
60
|
} else if (Array.isArray(column)) {
|
|
61
61
|
// If the column is an array, need check item in the array.
|
|
62
62
|
return getTableColumns(column);
|
package/src/utils/useAffix.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React, { useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import getHeight from 'dom-lib/getHeight';
|
|
3
1
|
import addStyle from 'dom-lib/addStyle';
|
|
4
|
-
import
|
|
2
|
+
import getHeight from 'dom-lib/getHeight';
|
|
5
3
|
import on from 'dom-lib/on';
|
|
6
|
-
import
|
|
4
|
+
import removeStyle from 'dom-lib/removeStyle';
|
|
5
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
6
|
+
import type { ElementOffset, ListenerCallback } from '../@types/common';
|
|
7
|
+
import type { ScrollbarInstance } from '../Scrollbar';
|
|
7
8
|
import isNumberOrTrue from './isNumberOrTrue';
|
|
9
|
+
import toggleClass from './toggleClass';
|
|
8
10
|
import useUpdateEffect from './useUpdateEffect';
|
|
9
|
-
import type { ListenerCallback, ElementOffset } from '../@types/common';
|
|
10
|
-
import type { ScrollbarInstance } from '../Scrollbar';
|
|
11
11
|
|
|
12
12
|
interface AffixProps {
|
|
13
13
|
getTableHeight: () => number;
|
|
14
14
|
contentHeight: React.MutableRefObject<number>;
|
|
15
15
|
affixHeader?: boolean | number;
|
|
16
16
|
affixHorizontalScrollbar?: boolean | number;
|
|
17
|
-
tableOffset: React.RefObject<ElementOffset>;
|
|
18
|
-
headerOffset: React.RefObject<ElementOffset>;
|
|
17
|
+
tableOffset: React.RefObject<ElementOffset | null>;
|
|
18
|
+
headerOffset: React.RefObject<ElementOffset | null>;
|
|
19
19
|
headerHeight: number;
|
|
20
|
-
scrollbarXRef: React.RefObject<ScrollbarInstance>;
|
|
21
|
-
affixHeaderWrapperRef: React.RefObject<HTMLDivElement>;
|
|
20
|
+
scrollbarXRef: React.RefObject<ScrollbarInstance | null>;
|
|
21
|
+
affixHeaderWrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const useAffix = (props: AffixProps) => {
|
|
@@ -34,7 +34,7 @@ const useAffix = (props: AffixProps) => {
|
|
|
34
34
|
affixHeaderWrapperRef
|
|
35
35
|
} = props;
|
|
36
36
|
|
|
37
|
-
const scrollListener = useRef<ListenerCallback>();
|
|
37
|
+
const scrollListener = useRef<ListenerCallback>(null);
|
|
38
38
|
const handleAffixHorizontalScrollbar = useCallback(() => {
|
|
39
39
|
const scrollY = window.scrollY || window.pageYOffset;
|
|
40
40
|
const windowHeight = getHeight(window);
|
|
@@ -32,8 +32,8 @@ interface CellDescriptorProps<Row> {
|
|
|
32
32
|
onSortColumn?: (dataKey: string, sortType?: SortType) => void;
|
|
33
33
|
onHeaderCellResize?: (width: number, dataKey: string) => void;
|
|
34
34
|
rowHeight?: number | ((rowData?: Row) => number);
|
|
35
|
-
mouseAreaRef: React.RefObject<HTMLDivElement>;
|
|
36
|
-
tableRef: React.RefObject<HTMLDivElement>;
|
|
35
|
+
mouseAreaRef: React.RefObject<HTMLDivElement | null>;
|
|
36
|
+
tableRef: React.RefObject<HTMLDivElement | null>;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
interface CellDescriptor {
|
|
@@ -68,7 +68,7 @@ const useCellDescriptor = <Row extends RowDataType>(
|
|
|
68
68
|
rowHeight,
|
|
69
69
|
onSortColumn,
|
|
70
70
|
onHeaderCellResize,
|
|
71
|
-
prefix
|
|
71
|
+
prefix
|
|
72
72
|
} = props;
|
|
73
73
|
|
|
74
74
|
const [sortType, setSortType] = useControlled(sortTypeProp, defaultSortType);
|
|
@@ -196,16 +196,16 @@ const useCellDescriptor = <Row extends RowDataType>(
|
|
|
196
196
|
const count = columns.length;
|
|
197
197
|
const { totalFlexGrow, totalWidth } = getTotalByColumns(columns);
|
|
198
198
|
|
|
199
|
-
React.Children.forEach(columns, (column: React.ReactElement<ColumnProps>, index) => {
|
|
199
|
+
React.Children.forEach(columns as any, (column: React.ReactElement<ColumnProps>, index) => {
|
|
200
200
|
if (React.isValidElement(column)) {
|
|
201
201
|
const columnChildren = column.props.children as React.ReactNode[];
|
|
202
202
|
const columnProps = getColumnProps(column);
|
|
203
203
|
|
|
204
204
|
const { width, resizable, flexGrow, minWidth, onResize, treeCol } = columnProps;
|
|
205
|
-
|
|
206
205
|
if (treeCol) {
|
|
207
206
|
hasCustomTreeCol = true;
|
|
208
207
|
}
|
|
208
|
+
console.log(columns);
|
|
209
209
|
|
|
210
210
|
if (columnChildren?.length !== 2) {
|
|
211
211
|
throw new Error(`Component <HeaderCell> and <Cell> is required, column index: ${index} `);
|
package/src/utils/usePosition.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import React, { useCallback, useRef } from 'react';
|
|
2
1
|
import addStyle, { CSSProperty } from 'dom-lib/addStyle';
|
|
2
|
+
import React, { useCallback, useRef } from 'react';
|
|
3
|
+
import type { RowDataType } from '../@types/common';
|
|
3
4
|
import { SCROLLBAR_WIDTH } from '../constants';
|
|
5
|
+
import defer from './defer';
|
|
6
|
+
import isSupportTouchEvent from './isSupportTouchEvent';
|
|
4
7
|
import toggleClass from './toggleClass';
|
|
5
8
|
import useUpdateEffect from './useUpdateEffect';
|
|
6
|
-
import type { RowDataType } from '../@types/common';
|
|
7
|
-
import isSupportTouchEvent from './isSupportTouchEvent';
|
|
8
|
-
import defer from './defer';
|
|
9
9
|
|
|
10
10
|
interface PositionProps {
|
|
11
11
|
data: readonly RowDataType[];
|
|
12
12
|
height: number;
|
|
13
13
|
tableWidth: React.MutableRefObject<number>;
|
|
14
|
-
tableRef: React.RefObject<HTMLDivElement>;
|
|
14
|
+
tableRef: React.RefObject<HTMLDivElement | null>;
|
|
15
15
|
prefix: (str: string) => string;
|
|
16
16
|
translateDOMPositionXY: React.MutableRefObject<any>;
|
|
17
|
-
wheelWrapperRef: React.RefObject<HTMLDivElement>;
|
|
18
|
-
headerWrapperRef: React.RefObject<HTMLDivElement>;
|
|
19
|
-
affixHeaderWrapperRef: React.RefObject<HTMLDivElement>;
|
|
20
|
-
tableHeaderRef: React.RefObject<HTMLDivElement>;
|
|
17
|
+
wheelWrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
18
|
+
headerWrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
19
|
+
affixHeaderWrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
20
|
+
tableHeaderRef: React.RefObject<HTMLDivElement | null>;
|
|
21
21
|
scrollX: React.MutableRefObject<number>;
|
|
22
22
|
scrollY: React.MutableRefObject<number>;
|
|
23
23
|
contentWidth: React.MutableRefObject<number>;
|