@pdg/react-table 1.0.126 → 1.0.127
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/README.md +1 -1
- package/dist/Table/Table.types.d.ts +2 -1
- package/dist/TableBodyCell/TableBodyCell.d.ts +1 -1
- package/dist/TableCommonCell/TableCommonCell.d.ts +1 -1
- package/dist/TableContext/TableContext.types.d.ts +1 -0
- package/dist/index.esm.js +31 -15
- package/dist/index.js +31 -15
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ https://parkdigy.github.io/react-table/
|
|
|
8
8
|
|
|
9
9
|
## 설치
|
|
10
10
|
```shell
|
|
11
|
-
npm install -D @pdg/react-table @dnd-kit/core @dnd-kit/sortable @emotion/react @emotion/styled @mui/icons-material @mui/material @mui/x-date-pickers @pdg/react-component @pdg/react-hook @pdg/react-form @tinymce/tinymce-react @types/uuid classnames dayjs copy-to-clipboard react-number-format react-resize-detector simplebar-react uuid
|
|
11
|
+
npm install -D @pdg/react-table @dnd-kit/core @dnd-kit/sortable @emotion/react @emotion/styled @mui/icons-material @mui/material @mui/x-date-pickers @pdg/react-component @pdg/react-hook @pdg/react-form @tinymce/tinymce-react @types/uuid classnames dayjs copy-to-clipboard react-number-format react-resize-detector simplebar-react uuid react-intersection-observer
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
### simplebar-react css 추가
|
|
@@ -66,7 +66,7 @@ export interface TableColumn<T = TableItem> {
|
|
|
66
66
|
onGetSx?(item: T, index: number): TableCommonSxProps['sx'];
|
|
67
67
|
onHide?(item: T, index: number): boolean;
|
|
68
68
|
onGetTooltip?(item: T, index: number): ReactNode;
|
|
69
|
-
onRender?(item: T, index: number): ReactNode;
|
|
69
|
+
onRender?(item: T, index: number, inView: boolean): ReactNode;
|
|
70
70
|
onClick?(item: T, index: number): void;
|
|
71
71
|
onInitChecked?(item: T): boolean;
|
|
72
72
|
onCheckDisabled?(item: T): boolean;
|
|
@@ -94,6 +94,7 @@ export interface TableProps<T = TableItem> extends TableCommonSxProps {
|
|
|
94
94
|
showOddColor?: boolean;
|
|
95
95
|
showEvenColor?: boolean;
|
|
96
96
|
cellPadding?: string | number;
|
|
97
|
+
inViewRender?: boolean;
|
|
97
98
|
footer?: boolean;
|
|
98
99
|
noData?: ReactNode;
|
|
99
100
|
pagination?: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TableBodyCellProps as Props } from './TableBodyCell.types';
|
|
3
|
-
declare const TableBodyCell: React.
|
|
3
|
+
declare const TableBodyCell: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLTableCellElement>>;
|
|
4
4
|
export default TableBodyCell;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TableCommonCellProps } from './TableCommonCell.types';
|
|
3
|
-
declare const TableCommonCell: React.
|
|
3
|
+
declare const TableCommonCell: React.ForwardRefExoticComponent<TableCommonCellProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
4
4
|
export default TableCommonCell;
|
|
@@ -4,6 +4,7 @@ import { TableHeadCellCommands } from '../TableHeadCell';
|
|
|
4
4
|
export interface TableContextValue {
|
|
5
5
|
menuOpen: boolean;
|
|
6
6
|
openMenuId?: string;
|
|
7
|
+
inViewRender?: boolean;
|
|
7
8
|
setMenuOpen(menuOpen: boolean, openMenuId?: string): void;
|
|
8
9
|
setItemColumnChecked(item: TableItem, column: TableColumn, checked: boolean): void;
|
|
9
10
|
setItemColumnCheckDisabled(item: TableItem, column: TableColumn, checkDisabled: boolean): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React,{createContext,useContext,useMemo,useCallback,useState,useEffect,useRef,useLayoutEffect,useId}from'react';import classNames from'classnames';import {styled,TableRow,lighten,TableCell,Box,Tooltip,Checkbox,Stack,Pagination,useTheme,TableHead,TableBody,Icon,TableFooter,Paper,Table as Table$1,Grid,Popper,Grow,ClickAwayListener,IconButton}from'@mui/material';import {useResizeDetector}from'react-resize-detector';import {useSortable,sortableKeyboardCoordinates,arrayMove,SortableContext,verticalListSortingStrategy}from'@dnd-kit/sortable';import dayjs from'dayjs';import {personalNoAutoDash,companyNoAutoDash,telNoAutoDash,numberFormat,notEmpty,equal,empty}from'@pdg/util';import {useAutoUpdateLayoutState}from'@pdg/react-hook';import {useSensors,useSensor,MouseSensor,TouchSensor,KeyboardSensor,DndContext,closestCenter}from'@dnd-kit/core';import SimpleBar from'simplebar-react';import'simplebar-react/dist/simplebar.min.css';import {v4}from'uuid';import {Search,SearchGroup,FormHidden}from'@pdg/react-form';import {PdgButton,PdgIcon,PdgCopyToClipboard}from'@pdg/react-component';function styleInject(css, ref) {
|
|
1
|
+
import React,{createContext,useContext,useMemo,useCallback,useState,useEffect,useRef,useLayoutEffect,useId}from'react';import classNames from'classnames';import {styled,TableRow,lighten,TableCell,Box,Tooltip,Checkbox,Stack,Pagination,useTheme,TableHead,TableBody,Icon,TableFooter,Paper,Table as Table$1,Grid,Popper,Grow,ClickAwayListener,IconButton}from'@mui/material';import {useResizeDetector}from'react-resize-detector';import {useSortable,sortableKeyboardCoordinates,arrayMove,SortableContext,verticalListSortingStrategy}from'@dnd-kit/sortable';import dayjs from'dayjs';import {personalNoAutoDash,companyNoAutoDash,telNoAutoDash,numberFormat,notEmpty,equal,empty}from'@pdg/util';import {useInView}from'react-intersection-observer';import {useAutoUpdateLayoutState}from'@pdg/react-hook';import {useSensors,useSensor,MouseSensor,TouchSensor,KeyboardSensor,DndContext,closestCenter}from'@dnd-kit/core';import SimpleBar from'simplebar-react';import'simplebar-react/dist/simplebar.min.css';import {v4}from'uuid';import {Search,SearchGroup,FormHidden}from'@pdg/react-form';import {PdgButton,PdgIcon,PdgCopyToClipboard}from'@pdg/react-component';function styleInject(css, ref) {
|
|
2
2
|
if ( ref === void 0 ) ref = {};
|
|
3
3
|
var insertAt = ref.insertAt;
|
|
4
4
|
|
|
@@ -170,6 +170,7 @@ function typographyColorToSxColor(color) {
|
|
|
170
170
|
}var TableContextDefaultValue = {
|
|
171
171
|
menuOpen: false,
|
|
172
172
|
openMenuId: undefined,
|
|
173
|
+
inViewRender: false,
|
|
173
174
|
setMenuOpen: function () { },
|
|
174
175
|
setItemColumnChecked: function () { },
|
|
175
176
|
setItemColumnCheckDisabled: function () { },
|
|
@@ -183,7 +184,7 @@ function typographyColorToSxColor(color) {
|
|
|
183
184
|
}
|
|
184
185
|
return value;
|
|
185
186
|
}var StyledTableCell = styled(TableCell)(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n &.ellipsis {\n position: relative;\n max-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"], ["\n &.ellipsis {\n position: relative;\n max-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"])));
|
|
186
|
-
var TableCommonCell = function (_a) {
|
|
187
|
+
var TableCommonCell = React.forwardRef(function (_a, ref) {
|
|
187
188
|
/********************************************************************************************************************
|
|
188
189
|
* Use
|
|
189
190
|
* ******************************************************************************************************************/
|
|
@@ -337,20 +338,21 @@ var TableCommonCell = function (_a) {
|
|
|
337
338
|
/********************************************************************************************************************
|
|
338
339
|
* Render
|
|
339
340
|
* ******************************************************************************************************************/
|
|
340
|
-
return (React.createElement(StyledTableCell, { align: align, className: classNames(className, 'TableCommonCell', ellipsis && 'ellipsis', column.type ? "column-type-".concat(column.type) : false), style: style, sx: sx, onClick: type === 'body' ? handleClick : undefined }, children));
|
|
341
|
-
};
|
|
341
|
+
return (React.createElement(StyledTableCell, { ref: ref, align: align, className: classNames(className, 'TableCommonCell', ellipsis && 'ellipsis', column.type ? "column-type-".concat(column.type) : false), style: style, sx: sx, onClick: type === 'body' ? handleClick : undefined }, children));
|
|
342
|
+
});
|
|
342
343
|
var templateObject_1$3;var StyledButtonsBox = styled(Box)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"], ["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"])));
|
|
343
|
-
var TableBodyCell = function (_a) {
|
|
344
|
+
var TableBodyCell = React.forwardRef(function (_a, ref) {
|
|
344
345
|
/********************************************************************************************************************
|
|
345
346
|
* Use
|
|
346
347
|
* ******************************************************************************************************************/
|
|
347
348
|
var className = _a.className, style = _a.style, sx = _a.sx, item = _a.item, index = _a.index, column = _a.column, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, onClick = _a.onClick, onCheckChange = _a.onCheckChange;
|
|
348
|
-
var _b = useTableState(), menuOpen = _b.menuOpen, setItemColumnChecked = _b.setItemColumnChecked, setItemColumnCheckDisabled = _b.setItemColumnCheckDisabled, setItemColumnCommands = _b.setItemColumnCommands;
|
|
349
|
+
var _b = useTableState(), menuOpen = _b.menuOpen, inViewRender = _b.inViewRender, setItemColumnChecked = _b.setItemColumnChecked, setItemColumnCheckDisabled = _b.setItemColumnCheckDisabled, setItemColumnCommands = _b.setItemColumnCommands;
|
|
350
|
+
var _c = useInView({ threshold: 0 }), inViewRef = _c.ref, inView = _c.inView;
|
|
349
351
|
/********************************************************************************************************************
|
|
350
352
|
* State
|
|
351
353
|
* ******************************************************************************************************************/
|
|
352
|
-
var
|
|
353
|
-
var
|
|
354
|
+
var _d = useState(false), checked = _d[0], setChecked = _d[1];
|
|
355
|
+
var _e = useState(false), checkDisabled = _e[0], setCheckDisabled = _e[1];
|
|
354
356
|
/********************************************************************************************************************
|
|
355
357
|
* Effect
|
|
356
358
|
* ******************************************************************************************************************/
|
|
@@ -404,7 +406,7 @@ var TableBodyCell = function (_a) {
|
|
|
404
406
|
var data;
|
|
405
407
|
if (column.type !== 'check') {
|
|
406
408
|
if (column.onRender) {
|
|
407
|
-
data = column.onRender(item, index);
|
|
409
|
+
data = column.onRender(item, index, inView);
|
|
408
410
|
}
|
|
409
411
|
else if (column.name) {
|
|
410
412
|
data = item[column.name];
|
|
@@ -513,7 +515,7 @@ var TableBodyCell = function (_a) {
|
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
517
|
return data;
|
|
516
|
-
}, [column, item, index, menuOpen, checked, checkDisabled, buttonsBoxJustifyContent, onCheckChange]);
|
|
518
|
+
}, [column, item, index, inView, menuOpen, checked, checkDisabled, buttonsBoxJustifyContent, onCheckChange]);
|
|
517
519
|
/********************************************************************************************************************
|
|
518
520
|
* Event Handler
|
|
519
521
|
* ******************************************************************************************************************/
|
|
@@ -529,8 +531,20 @@ var TableBodyCell = function (_a) {
|
|
|
529
531
|
/********************************************************************************************************************
|
|
530
532
|
* Render
|
|
531
533
|
* ******************************************************************************************************************/
|
|
532
|
-
return (React.createElement(TableCommonCell, {
|
|
533
|
-
|
|
534
|
+
return (React.createElement(TableCommonCell, { ref: function (cellRef) {
|
|
535
|
+
if (inViewRender) {
|
|
536
|
+
inViewRef(cellRef);
|
|
537
|
+
}
|
|
538
|
+
if (ref) {
|
|
539
|
+
if (typeof ref === 'function') {
|
|
540
|
+
ref(cellRef);
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
ref.current = cellRef;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}, type: 'body', className: classNames('TableBodyCell', className), style: style, sx: sx, column: column, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, item: item, index: index, onClick: column.onClick || onClick ? handleClick : undefined }, !isHidden && data));
|
|
547
|
+
});
|
|
534
548
|
var templateObject_1$2;var StyledBodyRow = styled(TableRow)(function (_a) {
|
|
535
549
|
var theme = _a.theme;
|
|
536
550
|
return ({
|
|
@@ -556,8 +570,9 @@ var TableBodyRow = function (_a) {
|
|
|
556
570
|
/********************************************************************************************************************
|
|
557
571
|
* Render
|
|
558
572
|
* ******************************************************************************************************************/
|
|
559
|
-
return (React.createElement(
|
|
560
|
-
|
|
573
|
+
return (React.createElement(React.Fragment, null,
|
|
574
|
+
React.createElement(StyledBodyRow, __assign({ className: classNames('TableBodyRow', className), style: sortable
|
|
575
|
+
? __assign(__assign({}, style), { transform: CSS.Transform.toString(transform), transition: transition }) : style }, props, sortableProps), columns.map(function (column, columnIdx) { return (React.createElement(TableBodyCell, { className: onGetColumnClassName ? onGetColumnClassName(column, item, index) : undefined, sx: onGetColumnSx ? onGetColumnSx(column, item, index) : undefined, style: onGetColumnStyle ? onGetColumnStyle(column, item, index) : undefined, key: columnIdx, index: index, item: item, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, column: column, onClick: onClick, onCheckChange: onCheckChange })); }))));
|
|
561
576
|
};var TableFooterCell = function (_a) {
|
|
562
577
|
/********************************************************************************************************************
|
|
563
578
|
* Memo
|
|
@@ -784,7 +799,7 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
784
799
|
/********************************************************************************************************************
|
|
785
800
|
* Ref
|
|
786
801
|
* ******************************************************************************************************************/
|
|
787
|
-
var className = _a.className, initStyle = _a.style, sx = _a.sx, caption = _a.caption, topHeadRows = _a.topHeadRows, initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, _b = _a.pagingAlign, pagingAlign = _b === void 0 ? 'center' : _b, _c = _a.defaultAlign, defaultAlign = _c === void 0 ? 'left' : _c, defaultEllipsis = _a.defaultEllipsis, initStickyHeader = _a.stickyHeader, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight, fullHeight = _a.fullHeight, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, _d = _a.cellPadding, cellPadding = _d === void 0 ? 13 : _d, footer = _a.footer, noData = _a.noData, pagination = _a.pagination, sortable = _a.sortable, onClick = _a.onClick, onGetBodyRowClassName = _a.onGetBodyRowClassName, onGetBodyRowStyle = _a.onGetBodyRowStyle, onGetBodyRowSx = _a.onGetBodyRowSx, onGetBodyColumnClassName = _a.onGetBodyColumnClassName, onGetBodyColumnStyle = _a.onGetBodyColumnStyle, onGetBodyColumnSx = _a.onGetBodyColumnSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange;
|
|
802
|
+
var className = _a.className, initStyle = _a.style, sx = _a.sx, caption = _a.caption, topHeadRows = _a.topHeadRows, initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, _b = _a.pagingAlign, pagingAlign = _b === void 0 ? 'center' : _b, _c = _a.defaultAlign, defaultAlign = _c === void 0 ? 'left' : _c, defaultEllipsis = _a.defaultEllipsis, initStickyHeader = _a.stickyHeader, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight, fullHeight = _a.fullHeight, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, _d = _a.cellPadding, cellPadding = _d === void 0 ? 13 : _d, inViewRender = _a.inViewRender, footer = _a.footer, noData = _a.noData, pagination = _a.pagination, sortable = _a.sortable, onClick = _a.onClick, onGetBodyRowClassName = _a.onGetBodyRowClassName, onGetBodyRowStyle = _a.onGetBodyRowStyle, onGetBodyRowSx = _a.onGetBodyRowSx, onGetBodyColumnClassName = _a.onGetBodyColumnClassName, onGetBodyColumnStyle = _a.onGetBodyColumnStyle, onGetBodyColumnSx = _a.onGetBodyColumnSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange;
|
|
788
803
|
var localHeaderDataRef = useRef({});
|
|
789
804
|
var localBodyDataRef = useRef({});
|
|
790
805
|
var updateHeadCheckTimer = useRef(undefined);
|
|
@@ -1312,6 +1327,7 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
1312
1327
|
return finalColumns ? (React.createElement(TableContextProvider, { value: {
|
|
1313
1328
|
menuOpen: menuOpen,
|
|
1314
1329
|
openMenuId: openMenuId,
|
|
1330
|
+
inViewRender: inViewRender,
|
|
1315
1331
|
setMenuOpen: TableContextSetMenuOpen,
|
|
1316
1332
|
setItemColumnChecked: TableContextSetItemColumnChecked,
|
|
1317
1333
|
setItemColumnCheckDisabled: TableContextSetItemColumnCheckDisabled,
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var React=require('react'),classNames=require('classnames'),material=require('@mui/material'),reactResizeDetector=require('react-resize-detector'),sortable=require('@dnd-kit/sortable'),dayjs=require('dayjs'),util=require('@pdg/util'),reactHook=require('@pdg/react-hook'),core=require('@dnd-kit/core'),SimpleBar=require('simplebar-react');require('simplebar-react/dist/simplebar.min.css');var uuid=require('uuid'),reactForm=require('@pdg/react-form'),reactComponent=require('@pdg/react-component');function styleInject(css, ref) {
|
|
1
|
+
'use strict';var React=require('react'),classNames=require('classnames'),material=require('@mui/material'),reactResizeDetector=require('react-resize-detector'),sortable=require('@dnd-kit/sortable'),dayjs=require('dayjs'),util=require('@pdg/util'),reactIntersectionObserver=require('react-intersection-observer'),reactHook=require('@pdg/react-hook'),core=require('@dnd-kit/core'),SimpleBar=require('simplebar-react');require('simplebar-react/dist/simplebar.min.css');var uuid=require('uuid'),reactForm=require('@pdg/react-form'),reactComponent=require('@pdg/react-component');function styleInject(css, ref) {
|
|
2
2
|
if ( ref === void 0 ) ref = {};
|
|
3
3
|
var insertAt = ref.insertAt;
|
|
4
4
|
|
|
@@ -170,6 +170,7 @@ function typographyColorToSxColor(color) {
|
|
|
170
170
|
}var TableContextDefaultValue = {
|
|
171
171
|
menuOpen: false,
|
|
172
172
|
openMenuId: undefined,
|
|
173
|
+
inViewRender: false,
|
|
173
174
|
setMenuOpen: function () { },
|
|
174
175
|
setItemColumnChecked: function () { },
|
|
175
176
|
setItemColumnCheckDisabled: function () { },
|
|
@@ -183,7 +184,7 @@ function typographyColorToSxColor(color) {
|
|
|
183
184
|
}
|
|
184
185
|
return value;
|
|
185
186
|
}var StyledTableCell = material.styled(material.TableCell)(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n &.ellipsis {\n position: relative;\n max-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"], ["\n &.ellipsis {\n position: relative;\n max-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n"])));
|
|
186
|
-
var TableCommonCell = function (_a) {
|
|
187
|
+
var TableCommonCell = React.forwardRef(function (_a, ref) {
|
|
187
188
|
/********************************************************************************************************************
|
|
188
189
|
* Use
|
|
189
190
|
* ******************************************************************************************************************/
|
|
@@ -337,20 +338,21 @@ var TableCommonCell = function (_a) {
|
|
|
337
338
|
/********************************************************************************************************************
|
|
338
339
|
* Render
|
|
339
340
|
* ******************************************************************************************************************/
|
|
340
|
-
return (React.createElement(StyledTableCell, { align: align, className: classNames(className, 'TableCommonCell', ellipsis && 'ellipsis', column.type ? "column-type-".concat(column.type) : false), style: style, sx: sx, onClick: type === 'body' ? handleClick : undefined }, children));
|
|
341
|
-
};
|
|
341
|
+
return (React.createElement(StyledTableCell, { ref: ref, align: align, className: classNames(className, 'TableCommonCell', ellipsis && 'ellipsis', column.type ? "column-type-".concat(column.type) : false), style: style, sx: sx, onClick: type === 'body' ? handleClick : undefined }, children));
|
|
342
|
+
});
|
|
342
343
|
var templateObject_1$3;var StyledButtonsBox = material.styled(material.Box)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"], ["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"])));
|
|
343
|
-
var TableBodyCell = function (_a) {
|
|
344
|
+
var TableBodyCell = React.forwardRef(function (_a, ref) {
|
|
344
345
|
/********************************************************************************************************************
|
|
345
346
|
* Use
|
|
346
347
|
* ******************************************************************************************************************/
|
|
347
348
|
var className = _a.className, style = _a.style, sx = _a.sx, item = _a.item, index = _a.index, column = _a.column, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, onClick = _a.onClick, onCheckChange = _a.onCheckChange;
|
|
348
|
-
var _b = useTableState(), menuOpen = _b.menuOpen, setItemColumnChecked = _b.setItemColumnChecked, setItemColumnCheckDisabled = _b.setItemColumnCheckDisabled, setItemColumnCommands = _b.setItemColumnCommands;
|
|
349
|
+
var _b = useTableState(), menuOpen = _b.menuOpen, inViewRender = _b.inViewRender, setItemColumnChecked = _b.setItemColumnChecked, setItemColumnCheckDisabled = _b.setItemColumnCheckDisabled, setItemColumnCommands = _b.setItemColumnCommands;
|
|
350
|
+
var _c = reactIntersectionObserver.useInView({ threshold: 0 }), inViewRef = _c.ref, inView = _c.inView;
|
|
349
351
|
/********************************************************************************************************************
|
|
350
352
|
* State
|
|
351
353
|
* ******************************************************************************************************************/
|
|
352
|
-
var
|
|
353
|
-
var
|
|
354
|
+
var _d = React.useState(false), checked = _d[0], setChecked = _d[1];
|
|
355
|
+
var _e = React.useState(false), checkDisabled = _e[0], setCheckDisabled = _e[1];
|
|
354
356
|
/********************************************************************************************************************
|
|
355
357
|
* Effect
|
|
356
358
|
* ******************************************************************************************************************/
|
|
@@ -404,7 +406,7 @@ var TableBodyCell = function (_a) {
|
|
|
404
406
|
var data;
|
|
405
407
|
if (column.type !== 'check') {
|
|
406
408
|
if (column.onRender) {
|
|
407
|
-
data = column.onRender(item, index);
|
|
409
|
+
data = column.onRender(item, index, inView);
|
|
408
410
|
}
|
|
409
411
|
else if (column.name) {
|
|
410
412
|
data = item[column.name];
|
|
@@ -513,7 +515,7 @@ var TableBodyCell = function (_a) {
|
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
517
|
return data;
|
|
516
|
-
}, [column, item, index, menuOpen, checked, checkDisabled, buttonsBoxJustifyContent, onCheckChange]);
|
|
518
|
+
}, [column, item, index, inView, menuOpen, checked, checkDisabled, buttonsBoxJustifyContent, onCheckChange]);
|
|
517
519
|
/********************************************************************************************************************
|
|
518
520
|
* Event Handler
|
|
519
521
|
* ******************************************************************************************************************/
|
|
@@ -529,8 +531,20 @@ var TableBodyCell = function (_a) {
|
|
|
529
531
|
/********************************************************************************************************************
|
|
530
532
|
* Render
|
|
531
533
|
* ******************************************************************************************************************/
|
|
532
|
-
return (React.createElement(TableCommonCell, {
|
|
533
|
-
|
|
534
|
+
return (React.createElement(TableCommonCell, { ref: function (cellRef) {
|
|
535
|
+
if (inViewRender) {
|
|
536
|
+
inViewRef(cellRef);
|
|
537
|
+
}
|
|
538
|
+
if (ref) {
|
|
539
|
+
if (typeof ref === 'function') {
|
|
540
|
+
ref(cellRef);
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
ref.current = cellRef;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}, type: 'body', className: classNames('TableBodyCell', className), style: style, sx: sx, column: column, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, item: item, index: index, onClick: column.onClick || onClick ? handleClick : undefined }, !isHidden && data));
|
|
547
|
+
});
|
|
534
548
|
var templateObject_1$2;var StyledBodyRow = material.styled(material.TableRow)(function (_a) {
|
|
535
549
|
var theme = _a.theme;
|
|
536
550
|
return ({
|
|
@@ -556,8 +570,9 @@ var TableBodyRow = function (_a) {
|
|
|
556
570
|
/********************************************************************************************************************
|
|
557
571
|
* Render
|
|
558
572
|
* ******************************************************************************************************************/
|
|
559
|
-
return (React.createElement(
|
|
560
|
-
|
|
573
|
+
return (React.createElement(React.Fragment, null,
|
|
574
|
+
React.createElement(StyledBodyRow, __assign({ className: classNames('TableBodyRow', className), style: sortable$1
|
|
575
|
+
? __assign(__assign({}, style), { transform: CSS.Transform.toString(transform), transition: transition }) : style }, props, sortableProps), columns.map(function (column, columnIdx) { return (React.createElement(TableBodyCell, { className: onGetColumnClassName ? onGetColumnClassName(column, item, index) : undefined, sx: onGetColumnSx ? onGetColumnSx(column, item, index) : undefined, style: onGetColumnStyle ? onGetColumnStyle(column, item, index) : undefined, key: columnIdx, index: index, item: item, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, column: column, onClick: onClick, onCheckChange: onCheckChange })); }))));
|
|
561
576
|
};var TableFooterCell = function (_a) {
|
|
562
577
|
/********************************************************************************************************************
|
|
563
578
|
* Memo
|
|
@@ -784,7 +799,7 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
784
799
|
/********************************************************************************************************************
|
|
785
800
|
* Ref
|
|
786
801
|
* ******************************************************************************************************************/
|
|
787
|
-
var className = _a.className, initStyle = _a.style, sx = _a.sx, caption = _a.caption, topHeadRows = _a.topHeadRows, initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, _b = _a.pagingAlign, pagingAlign = _b === void 0 ? 'center' : _b, _c = _a.defaultAlign, defaultAlign = _c === void 0 ? 'left' : _c, defaultEllipsis = _a.defaultEllipsis, initStickyHeader = _a.stickyHeader, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight, fullHeight = _a.fullHeight, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, _d = _a.cellPadding, cellPadding = _d === void 0 ? 13 : _d, footer = _a.footer, noData = _a.noData, pagination = _a.pagination, sortable$1 = _a.sortable, onClick = _a.onClick, onGetBodyRowClassName = _a.onGetBodyRowClassName, onGetBodyRowStyle = _a.onGetBodyRowStyle, onGetBodyRowSx = _a.onGetBodyRowSx, onGetBodyColumnClassName = _a.onGetBodyColumnClassName, onGetBodyColumnStyle = _a.onGetBodyColumnStyle, onGetBodyColumnSx = _a.onGetBodyColumnSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange;
|
|
802
|
+
var className = _a.className, initStyle = _a.style, sx = _a.sx, caption = _a.caption, topHeadRows = _a.topHeadRows, initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, _b = _a.pagingAlign, pagingAlign = _b === void 0 ? 'center' : _b, _c = _a.defaultAlign, defaultAlign = _c === void 0 ? 'left' : _c, defaultEllipsis = _a.defaultEllipsis, initStickyHeader = _a.stickyHeader, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight, fullHeight = _a.fullHeight, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, _d = _a.cellPadding, cellPadding = _d === void 0 ? 13 : _d, inViewRender = _a.inViewRender, footer = _a.footer, noData = _a.noData, pagination = _a.pagination, sortable$1 = _a.sortable, onClick = _a.onClick, onGetBodyRowClassName = _a.onGetBodyRowClassName, onGetBodyRowStyle = _a.onGetBodyRowStyle, onGetBodyRowSx = _a.onGetBodyRowSx, onGetBodyColumnClassName = _a.onGetBodyColumnClassName, onGetBodyColumnStyle = _a.onGetBodyColumnStyle, onGetBodyColumnSx = _a.onGetBodyColumnSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange;
|
|
788
803
|
var localHeaderDataRef = React.useRef({});
|
|
789
804
|
var localBodyDataRef = React.useRef({});
|
|
790
805
|
var updateHeadCheckTimer = React.useRef(undefined);
|
|
@@ -1312,6 +1327,7 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
1312
1327
|
return finalColumns ? (React.createElement(TableContextProvider, { value: {
|
|
1313
1328
|
menuOpen: menuOpen,
|
|
1314
1329
|
openMenuId: openMenuId,
|
|
1330
|
+
inViewRender: inViewRender,
|
|
1315
1331
|
setMenuOpen: TableContextSetMenuOpen,
|
|
1316
1332
|
setItemColumnChecked: TableContextSetItemColumnChecked,
|
|
1317
1333
|
setItemColumnCheckDisabled: TableContextSetItemColumnCheckDisabled,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdg/react-table",
|
|
3
3
|
"title": "React Table",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.127",
|
|
5
5
|
"description": "React Table",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"dayjs": "^1.0.0",
|
|
59
59
|
"react": ">=17.0.0",
|
|
60
60
|
"react-dom": ">=17.0.0",
|
|
61
|
+
"react-intersection-observer": "^9.16.0",
|
|
61
62
|
"react-number-format": "^5.0.0",
|
|
62
63
|
"react-resize-detector": "^12.0.0",
|
|
63
64
|
"simplebar-react": "^3.0.0",
|