react-table-edit 1.4.28 → 1.4.29
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/component/table-view/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +42 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -65526,7 +65526,7 @@ const HeaderTableCol = (props) => {
|
|
|
65526
65526
|
orderBy.push({ direction: 'asc', key: col.field });
|
|
65527
65527
|
changeOrder(orderBy);
|
|
65528
65528
|
}
|
|
65529
|
-
}, className: classNames$1('r-headercell-div', { 'cursor-pointer': allowOrder }), children: [col.type === 'checkbox' && (jsx(Input$1, { checked: !!(totalCount > 0 && selectedRows?.length >= totalCount), type: "checkbox", className: classNames$1('cursor-pointer', { 'd-none': !isMulti }), style: { textAlign: col.textAlign ?? 'left', marginTop: 6 }, onChange: (e) => {
|
|
65529
|
+
}, className: classNames$1('r-headercell-div', { 'cursor-pointer': allowOrder }), children: [(col.type === 'checkbox' && !col.field) && (jsx(Input$1, { checked: !!(totalCount > 0 && selectedRows?.length >= totalCount), type: "checkbox", className: classNames$1('cursor-pointer', { 'd-none': !isMulti }), style: { textAlign: col.textAlign ?? 'left', marginTop: 6 }, onChange: (e) => {
|
|
65530
65530
|
if (selectEnable) {
|
|
65531
65531
|
if (e.target.checked) {
|
|
65532
65532
|
setSelectedRows(dataSource.map((item) => { return item; }));
|
|
@@ -65609,7 +65609,9 @@ const RenderFilterElement = ({ filter, optionsFilter, formatSetting, filterBy, s
|
|
|
65609
65609
|
};
|
|
65610
65610
|
return (jsxs("div", { className: 'r-filter-popup', onKeyDown: (e) => {
|
|
65611
65611
|
if (e.code === 'Enter' || e.code === 'NumpadEnter') {
|
|
65612
|
-
|
|
65612
|
+
setTimeout(() => {
|
|
65613
|
+
handleSave();
|
|
65614
|
+
}, 100);
|
|
65613
65615
|
e.stopPropagation();
|
|
65614
65616
|
}
|
|
65615
65617
|
}, children: [((!column.filterType && column.type === 'numeric') || column.filterType === 'numeric') ? jsxs(Fragment$1, { children: [RenderNumberFilter(), " "] }) : (column.filterType === 'select' ? jsxs(Fragment$1, { children: [RenderSelectFilter(), " "] }) : RenderStringFilter()), jsxs("div", { className: 'd-flex justify-content-end', children: [jsx(Button$1, { color: 'primary', style: { borderRadius: 3 }, className: 'me-50 py-25 px-50 fw-bold', onClick: handleSave, children: t('Filter') }), jsx(Button$1, { className: 'py-25 px-50 fw-bold', outline: true, style: { borderRadius: 3 }, onClick: () => {
|
|
@@ -65703,20 +65705,20 @@ const RenderContentCol = (props) => {
|
|
|
65703
65705
|
}, children: RenderElement() }, `col-${indexRow}-${indexCol}`));
|
|
65704
65706
|
};
|
|
65705
65707
|
|
|
65706
|
-
const TableView = ({ idTable, dataSource, rowHeight = 33, height = 400, columns, isMutil = false, isLoading, selectEnable, formatSetting, commandClick, allowFilter, allowOrder, setColumns, pagingSetting, changeFilter, changeOrder, searchSetting, columnsAggregate, toolbarSetting, optionsFilter, selectedItem, setSelectedItem, handleSelect }) => {
|
|
65708
|
+
const TableView = ({ idTable, dataSource, rowHeight = 33, height = 400, columns, isMutil = false, isLoading, selectEnable, formatSetting, commandClick, allowFilter, allowOrder, setColumns, pagingSetting, changeFilter, changeOrder, searchSetting, columnsAggregate, toolbarSetting, optionsFilter, selectedItem, setSelectedItem, handleSelect, isVirtualList }) => {
|
|
65709
|
+
const { t } = useTranslation();
|
|
65707
65710
|
const gridRef = useRef(null);
|
|
65708
|
-
const [startIndex, setStartIndex] = useState(0);
|
|
65709
65711
|
const [selectedRows, setSelectedRows] = useState([]);
|
|
65710
65712
|
const [orderBy, setOrderBy] = useState([]);
|
|
65711
65713
|
const [filterBy, setFilterBy] = useState([]);
|
|
65712
65714
|
const [searchTerm, setSearchTerm] = useState('');
|
|
65713
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? 'id';
|
|
65715
|
+
const fieldKey = (columns.find((item) => item.isPrimarykey === true)?.field) ?? 'id';
|
|
65716
|
+
const [startIndex, setStartIndex] = useState(0);
|
|
65714
65717
|
//trường liên quan đến virtul loading
|
|
65715
|
-
const visibleRowCount = Math.ceil(height / rowHeight) + 5;
|
|
65716
65718
|
const buffer = 10; // số dòng dự phòng phía trên và dưới
|
|
65717
|
-
const
|
|
65718
|
-
|
|
65719
|
-
const
|
|
65719
|
+
const visibleRowCount = Math.ceil(height / rowHeight) + 5;
|
|
65720
|
+
// Tính toán dữ liệu hiển thị dựa trên các điều kiện lọc, tìm kiếm và sắp xếp
|
|
65721
|
+
const viewData = useMemo(() => {
|
|
65720
65722
|
if (!dataSource || dataSource.length === 0) {
|
|
65721
65723
|
return [];
|
|
65722
65724
|
}
|
|
@@ -65781,19 +65783,42 @@ const TableView = ({ idTable, dataSource, rowHeight = 33, height = 400, columns,
|
|
|
65781
65783
|
return 0;
|
|
65782
65784
|
});
|
|
65783
65785
|
}
|
|
65786
|
+
return datas;
|
|
65787
|
+
}, [searchTerm, filterBy, orderBy, dataSource]);
|
|
65788
|
+
// Lấy dữ liệu hiển thị với phân trang
|
|
65789
|
+
const pagingData = useMemo(() => {
|
|
65790
|
+
if (!viewData || viewData.length === 0) {
|
|
65791
|
+
return [];
|
|
65792
|
+
}
|
|
65793
|
+
let datas = viewData;
|
|
65784
65794
|
if (pagingSetting?.allowPaging && pagingSetting?.currentPage && pagingSetting?.pageSize && pagingSetting.pagingClient) {
|
|
65785
65795
|
const start = (pagingSetting.currentPage - 1) * pagingSetting.pageSize;
|
|
65786
65796
|
const end = start + pagingSetting.pageSize;
|
|
65787
65797
|
datas = datas.slice(start, end);
|
|
65788
65798
|
}
|
|
65789
|
-
return datas
|
|
65790
|
-
}, [
|
|
65791
|
-
|
|
65799
|
+
return datas;
|
|
65800
|
+
}, [viewData, pagingSetting?.pageSize, pagingSetting?.currentPage]);
|
|
65801
|
+
// Tính toán chỉ số bắt đầu và kết thúc của dữ liệu hiển thị
|
|
65802
|
+
const { adjustedStartIndex, adjustedEndIndex } = useMemo(() => {
|
|
65803
|
+
if (!pagingData || pagingData.length === 0 || !isVirtualList) {
|
|
65804
|
+
return { adjustedStartIndex: 0, adjustedEndIndex: 0 };
|
|
65805
|
+
}
|
|
65806
|
+
return {
|
|
65807
|
+
adjustedStartIndex: Math.max(startIndex - buffer, 0),
|
|
65808
|
+
adjustedEndIndex: Math.min(startIndex + visibleRowCount + buffer, dataSource.length)
|
|
65809
|
+
};
|
|
65810
|
+
}, [startIndex, pagingData]);
|
|
65811
|
+
const visibleData = useMemo(() => {
|
|
65812
|
+
if (!pagingData || pagingData.length === 0) {
|
|
65813
|
+
return [];
|
|
65814
|
+
}
|
|
65815
|
+
return isVirtualList ? pagingData.slice(adjustedStartIndex, adjustedEndIndex) : pagingData;
|
|
65816
|
+
}, [pagingData]);
|
|
65792
65817
|
const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight } = useMemo(() => calculateTableStructure(columns), [columns]);
|
|
65793
65818
|
const scrollTimeoutRef = useRef(null);
|
|
65794
65819
|
const lastScrollTop = useRef(0);
|
|
65795
65820
|
const handleScroll = (e) => {
|
|
65796
|
-
if (!gridRef.current) {
|
|
65821
|
+
if (!gridRef.current || !isVirtualList) {
|
|
65797
65822
|
return;
|
|
65798
65823
|
}
|
|
65799
65824
|
// Nếu không có sự thay đổi về scrollTop => người dùng chỉ scroll ngang => không xử lý
|
|
@@ -65918,19 +65943,19 @@ const TableView = ({ idTable, dataSource, rowHeight = 33, height = 400, columns,
|
|
|
65918
65943
|
}, container: gridRef, totalCount: dataSource.length }, `header-${indexParent}-${indexColumn}`))) }, `header-${-indexParent}`))) }), jsxs("tbody", { className: 'r-gridcontent', role: "rowgroup", children: [adjustedStartIndex > 0 && (jsx("tr", { style: { height: adjustedStartIndex * rowHeight }, children: jsx("td", { style: { padding: 0 }, colSpan: flatVisble.length }) })), visibleData.map((row, index) => {
|
|
65919
65944
|
const indexRow = index + startIndex;
|
|
65920
65945
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
65921
|
-
return (jsx("tr", { "aria-rowindex": indexRow + 1, role: "row", className: 'r-row', children: contentColumns.map((column, indexCol) => (jsx(RenderContentCol, { idTable: idTable, col: column, fieldKey:
|
|
65922
|
-
}),
|
|
65946
|
+
return (jsx("tr", { "aria-rowindex": indexRow + 1, role: "row", className: 'r-row', children: contentColumns.map((column, indexCol) => (jsx(RenderContentCol, { idTable: idTable, col: column, fieldKey: fieldKey, objWidthFixLeft: objWidthFixLeft, objWidthFixRight: objWidthFixRight, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, isMulti: isMutil ?? false, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, formatSetting: formatSetting, handleCommandClick: handleCommandClick, indexCol: indexCol, indexRow: indexRow, isSelected: isSelected, row: row }, indexCol))) }, `row-content-${indexRow}`));
|
|
65947
|
+
}), adjustedEndIndex > 0 && pagingData.length > adjustedEndIndex && (jsx("tr", { style: { height: (pagingData.length - adjustedEndIndex) * rowHeight }, children: jsx("td", { style: { padding: 0 }, colSpan: flatVisble.length }) }))] }), viewData.length > 0 && jsx("tfoot", { className: "r-gridfoot", children: (columnsAggregate?.length ?? 0) > 0 ? jsx("tr", { className: 'r-row', children: contentColumns.map((col, indexCol) => {
|
|
65923
65948
|
const item = columnsAggregate?.find((x) => x.field === col.field);
|
|
65924
65949
|
let sumValue = item?.value;
|
|
65925
65950
|
if (!item && col.haveSum === true && col.type === "numeric") {
|
|
65926
|
-
sumValue =
|
|
65951
|
+
sumValue = viewData.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0);
|
|
65927
65952
|
}
|
|
65928
65953
|
return col.visible !== false && jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
65929
65954
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
65930
65955
|
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
65931
65956
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
65932
65957
|
}, children: jsxs("div", { className: "r-footer-div", children: [(item || (col.haveSum === true && col.type === "numeric")) && col.type === "numeric" && (Number(sumValue) >= 0) && jsx(Fragment$1, { children: formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) }), (item || (col.haveSum === true && col.type === "numeric")) && col.type === "numeric" && (Number(sumValue) < 0) && jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false)}${formatSetting?.suffixNegative ?? ''}`] })] }) }, `summarycell-${indexCol}`);
|
|
65933
|
-
}) }) : jsx(Fragment$1, {}) })] }), (((
|
|
65958
|
+
}) }) : jsx(Fragment$1, {}) })] }), (((viewData.length ?? 0) === 0) && !isLoading) && jsxs("div", { className: "r-no-data", children: [jsx("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: jsxs("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [jsx("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }), jsxs("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [jsx("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }), jsx("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", fill: "#fafafa" })] })] }) }), t('No data available.')] }), isLoading && jsx("div", { className: "r-loading-overlay", children: jsxs("div", { className: "r-loading", children: [jsx(Spinner$1, { className: "me-1" }), t('Loading...')] }) })] })] }), pagingSetting?.allowPaging ? jsx(PagingComponent, { onChangePage: onChangePage, pageSize: pagingSetting?.pageSize ?? 0, currentPage: pagingSetting?.currentPage ?? 0, pageOptions: pagingSetting?.pageOptions ?? [20, 30, 50, 100], totalItem: (pagingSetting?.pagingClient ? viewData.length : pagingSetting?.totalItem ?? 0), onChangePageSize: onChangePageSize }) : jsx(Fragment$1, {})] }));
|
|
65934
65959
|
};
|
|
65935
65960
|
|
|
65936
65961
|
export { ExportExcelComponent, FindNodeByPath, ImportExcelComponent, InputStyleComponent, SelectTable, SelectTableTree, TableView, TabsMenuComponent, Wizard, calculateTableStructure, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, formatDateTime, generateUUID, isNullOrUndefined$1 as isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
|