react-table-edit 1.4.27 → 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/modal-import-excel/index.d.ts +1 -1
- package/dist/component/modal-import-excel/tab-handle-error.d.ts +1 -1
- package/dist/component/modal-import-excel/tab-merge.d.ts +1 -1
- package/dist/component/modal-import-excel/tab-validate.d.ts +1 -1
- package/dist/component/modal-import-excel/type.d.ts +24 -0
- package/dist/component/table-view/content.d.ts +22 -0
- package/dist/component/table-view/group-col.d.ts +6 -0
- package/dist/component/table-view/header.d.ts +32 -0
- package/dist/component/table-view/index.d.ts +30 -0
- package/dist/component/table-view/loading-item.d.ts +4 -0
- package/dist/component/type/index.d.ts +14 -52
- package/dist/component/utils.d.ts +1 -1
- package/dist/index.d.ts +25 -59
- package/dist/index.js +180 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +180 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -19278,7 +19278,7 @@ const FindNodeByPath = (tree, path) => {
|
|
|
19278
19278
|
* @param columns Mảng cấu trúc cây đại diện cho các cột của bảng
|
|
19279
19279
|
* @returns {
|
|
19280
19280
|
* levels: IHeaderColumnTable[][] // Các hàng header theo cấp
|
|
19281
|
-
* flat:
|
|
19281
|
+
* flat: IColumnTable[] // Danh sách cột phẳng
|
|
19282
19282
|
* objWidthFixLeft: Record<number, number> // Offset trái cho cột fixed left
|
|
19283
19283
|
* objWidthFixRight: Record<number, number> // Offset phải cho cột fixed right
|
|
19284
19284
|
* lastObjWidthFixLeft: number // Chỉ số cột cuối cùng fixed left
|
|
@@ -23540,7 +23540,7 @@ const SidebarSetColumn = (props) => {
|
|
|
23540
23540
|
}) }) }), jsx("tbody", { className: 'r-gridcontent', children: dataSource?.map((row, indexRow) => {
|
|
23541
23541
|
return (jsx("tr", { className: classNames$1('r-row', { 'last-row': indexRow === dataSource.length - 1 }, { 'fisrt-row': indexRow === 0 }), children: columns.map((col, indexCol) => {
|
|
23542
23542
|
let value = row[col.field];
|
|
23543
|
-
if (col.
|
|
23543
|
+
if (col.type === 'numeric' || (col.typeCondition && col.typeCondition(row) === 'numeric')) {
|
|
23544
23544
|
value = formartNumberic(row[col.field], ',', '.', col.numericSettings?.fraction, true) ?? 0;
|
|
23545
23545
|
}
|
|
23546
23546
|
return (jsx(Fragment, { children: col.visible !== false && jsx("td", { className: classNames$1(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': indexFocus === indexRow }), style: {
|
|
@@ -41876,7 +41876,7 @@ const HeaderTableCol$1 = (props) => {
|
|
|
41876
41876
|
};
|
|
41877
41877
|
const RenderFilterElement$1 = ({ filter, optionsFilter, formatSetting, filterBy, setOpenFilter, changeFilter, column }) => {
|
|
41878
41878
|
const { t } = useTranslation();
|
|
41879
|
-
const [operator, setOperator] = useState(filter?.ope ?? ((!column.filterType && column.
|
|
41879
|
+
const [operator, setOperator] = useState(filter?.ope ?? ((!column.filterType && column.type === 'numeric') || column.filterType === 'select' ? 'equal' : 'contains'));
|
|
41880
41880
|
const [valueFilter, setValueFilter] = useState(filter?.value ?? '');
|
|
41881
41881
|
const RenderStringFilter = () => {
|
|
41882
41882
|
const options = [
|
|
@@ -41941,7 +41941,7 @@ const RenderFilterElement$1 = ({ filter, optionsFilter, formatSetting, filterBy,
|
|
|
41941
41941
|
handleSave();
|
|
41942
41942
|
e.stopPropagation();
|
|
41943
41943
|
}
|
|
41944
|
-
}, children: [((!column.filterType && column.
|
|
41944
|
+
}, 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', color: 'white', style: { borderRadius: 3, borderWidth: 0 }, onClick: () => {
|
|
41945
41945
|
if (filterBy) {
|
|
41946
41946
|
changeFilter(filterBy.filter((x) => x.key !== column.field));
|
|
41947
41947
|
}
|
|
@@ -42800,7 +42800,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42800
42800
|
}
|
|
42801
42801
|
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42802
42802
|
/*eslint-disable */
|
|
42803
|
-
switch (col?.
|
|
42803
|
+
switch (col?.typeCondition ? col?.typeCondition(row) : col.type) {
|
|
42804
42804
|
case 'date':
|
|
42805
42805
|
return (jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$1('form-control border-0 rounded-0 input-numeric', { 'is-invalid': col.validate && col.validate(row[col.field], row) }), value: row[col.field], onChange: (date) => {
|
|
42806
42806
|
row[col.field] = date ? new Date(date.getTime() + 7 * 60 * 60 * 1000) : undefined;
|
|
@@ -43213,7 +43213,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43213
43213
|
}
|
|
43214
43214
|
}
|
|
43215
43215
|
else {
|
|
43216
|
-
if (column.
|
|
43216
|
+
if (column.type === 'date') {
|
|
43217
43217
|
const [day, month, year] = stringData.split('/');
|
|
43218
43218
|
const date = new Date(`${year}-${month}-${day}`);
|
|
43219
43219
|
if (!isNaN(date.getTime())) {
|
|
@@ -43231,7 +43231,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43231
43231
|
notificationError(t('PasteExcelIncorrectFormat', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43232
43232
|
}
|
|
43233
43233
|
}
|
|
43234
|
-
else if (column.
|
|
43234
|
+
else if (column.type === 'datetime') {
|
|
43235
43235
|
const [datePart, timePart] = stringData.split(' ');
|
|
43236
43236
|
const [day, month, year] = datePart.split('/');
|
|
43237
43237
|
const [hour, minute] = timePart.split(':');
|
|
@@ -43251,7 +43251,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43251
43251
|
notificationError(t('PasteExcelIncorrectFormat', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43252
43252
|
}
|
|
43253
43253
|
}
|
|
43254
|
-
else if (column.
|
|
43254
|
+
else if (column.type === 'numeric') {
|
|
43255
43255
|
const number = Number(stringData);
|
|
43256
43256
|
if (!isNaN(number)) {
|
|
43257
43257
|
if (column.onPaste) {
|
|
@@ -43268,7 +43268,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43268
43268
|
notificationError(t('PasteExcelIncorrectFormat', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43269
43269
|
}
|
|
43270
43270
|
}
|
|
43271
|
-
else if (column.
|
|
43271
|
+
else if (column.type === 'select') {
|
|
43272
43272
|
if (column.selectSettings?.allowCreate) {
|
|
43273
43273
|
if (column.onPaste) {
|
|
43274
43274
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43455,16 +43455,16 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43455
43455
|
}
|
|
43456
43456
|
else {
|
|
43457
43457
|
let value = row[col.field];
|
|
43458
|
-
if (col.
|
|
43458
|
+
if (col.type === 'numeric' || (col.typeCondition && col.typeCondition(row) === 'numeric')) {
|
|
43459
43459
|
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
43460
43460
|
}
|
|
43461
|
-
else if (col.
|
|
43461
|
+
else if (col.type === 'date') {
|
|
43462
43462
|
value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
|
|
43463
43463
|
}
|
|
43464
|
-
else if (col.
|
|
43464
|
+
else if (col.type === 'datetime') {
|
|
43465
43465
|
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
|
|
43466
43466
|
}
|
|
43467
|
-
const typeDis = !editDisable && (indexFocus === indexRow || col.
|
|
43467
|
+
const typeDis = !editDisable && (indexFocus === indexRow || col.type === 'checkbox') && (!col.disabledCondition || !col.disabledCondition(row)) ? (col.editEnable ? 1 : (col.template ? 2 : 3)) : (col.template ? 2 : 3);
|
|
43468
43468
|
const errorMessage = typeDis === 1 || col.field === '' || !col.validate ? '' : col.validate(row[col.field], row);
|
|
43469
43469
|
return (jsx(Fragment, { children: col.visible !== false && jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$1(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43470
43470
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
@@ -43506,21 +43506,21 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43506
43506
|
if (typeDis === 2) {
|
|
43507
43507
|
const value = col.template?.(row, indexRow) ?? '';
|
|
43508
43508
|
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
43509
|
-
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }), (!refreshRow && typeDis !== 2) && jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.
|
|
43509
|
+
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }), (!refreshRow && typeDis !== 2) && jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.type === 'numeric' && Number(row[col.field]) < 0 ? jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }));
|
|
43510
43510
|
}
|
|
43511
43511
|
else {
|
|
43512
43512
|
return value;
|
|
43513
43513
|
}
|
|
43514
43514
|
}
|
|
43515
|
-
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: (col.
|
|
43515
|
+
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: (col.type === 'numeric' && Number(row[col.field]) < 0 ? jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) }), (!(typeDis === 1 && !refreshRow) && typeDis !== 2) && jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.type === 'numeric' && Number(row[col.field]) < 0 ? jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }));
|
|
43516
43516
|
};
|
|
43517
43517
|
const renderFooterCol = (col, indexCol) => {
|
|
43518
|
-
const sumValue = (col.haveSum === true && col.
|
|
43518
|
+
const sumValue = (col.haveSum === true && col.type === "numeric") ? dataSource.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0) : 0;
|
|
43519
43519
|
return (jsx(Fragment, { children: (col.visible !== false) && jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
43520
43520
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
43521
43521
|
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
43522
43522
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
43523
|
-
}, children: jsxs("div", { className: "r-footer-div", children: [col.haveSum === true && col.
|
|
43523
|
+
}, children: jsxs("div", { className: "r-footer-div", children: [col.haveSum === true && col.type === "numeric" && (Number(sumValue) >= 0) && jsx(Fragment$1, { children: formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) }), col.haveSum === true && 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}`));
|
|
43524
43524
|
};
|
|
43525
43525
|
/**
|
|
43526
43526
|
* Kiểm tra row có thỏa mãn tất cả filter và chứa từ khóa tìm kiếm hay không
|
|
@@ -46260,7 +46260,7 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46260
46260
|
isPrimarykey: true
|
|
46261
46261
|
},
|
|
46262
46262
|
{
|
|
46263
|
-
|
|
46263
|
+
type: 'text',
|
|
46264
46264
|
field: "headerText",
|
|
46265
46265
|
headerText: 'Column name',
|
|
46266
46266
|
template: (value) => { return t(value.headerText); },
|
|
@@ -65349,7 +65349,7 @@ const TabMergeImportExcel = (props) => {
|
|
|
65349
65349
|
{
|
|
65350
65350
|
headerText: 'Required Information',
|
|
65351
65351
|
field: 'isRequired',
|
|
65352
|
-
|
|
65352
|
+
type: 'checkbox',
|
|
65353
65353
|
editEnable: true,
|
|
65354
65354
|
textAlign: 'center',
|
|
65355
65355
|
template: (data) => {
|
|
@@ -65372,7 +65372,7 @@ const TabMergeImportExcel = (props) => {
|
|
|
65372
65372
|
{
|
|
65373
65373
|
headerText: 'Columns on data files',
|
|
65374
65374
|
field: 'column',
|
|
65375
|
-
|
|
65375
|
+
type: 'select',
|
|
65376
65376
|
editEnable: true,
|
|
65377
65377
|
selectSettings: {
|
|
65378
65378
|
options: optionField
|
|
@@ -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: () => {
|
|
@@ -65623,13 +65625,13 @@ const RenderFilterElement = ({ filter, optionsFilter, formatSetting, filterBy, s
|
|
|
65623
65625
|
const RenderContentCol = (props) => {
|
|
65624
65626
|
const { col, indexCol, indexRow, isSelected, row, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, selectEnable, setSelectedRows, handleCommandClick, fieldKey, isMulti } = props;
|
|
65625
65627
|
const RenderElement = () => {
|
|
65626
|
-
if (col.type === 'command') {
|
|
65628
|
+
if (col.type === 'command' && !col.field) {
|
|
65627
65629
|
return jsx("div", { className: "r-rowcell-div command", children: jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row }) });
|
|
65628
65630
|
}
|
|
65629
|
-
else if (col.type === '#') {
|
|
65631
|
+
else if (col.type === '#' && !col.field) {
|
|
65630
65632
|
jsx("div", { className: "r-rowcell-div", children: indexRow + 1 });
|
|
65631
65633
|
}
|
|
65632
|
-
else if (col.type === 'checkbox') {
|
|
65634
|
+
else if (col.type === 'checkbox' && !col.field) {
|
|
65633
65635
|
return (jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: 'center' }, onClick: (e) => {
|
|
65634
65636
|
if (selectEnable) {
|
|
65635
65637
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
@@ -65703,26 +65705,120 @@ const RenderContentCol = (props) => {
|
|
|
65703
65705
|
}, children: RenderElement() }, `col-${indexRow}-${indexCol}`));
|
|
65704
65706
|
};
|
|
65705
65707
|
|
|
65706
|
-
const
|
|
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
|
|
65720
|
-
|
|
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(() => {
|
|
65722
|
+
if (!dataSource || dataSource.length === 0) {
|
|
65723
|
+
return [];
|
|
65724
|
+
}
|
|
65725
|
+
let datas = dataSource;
|
|
65726
|
+
if (searchTerm) {
|
|
65727
|
+
datas = datas.filter((row) => {
|
|
65728
|
+
return searchSetting?.keyField?.some((key) => {
|
|
65729
|
+
return row[key]?.toString().toLowerCase().includes(searchTerm.trim().toLowerCase());
|
|
65730
|
+
});
|
|
65731
|
+
});
|
|
65732
|
+
}
|
|
65733
|
+
if (filterBy && filterBy.length > 0) {
|
|
65734
|
+
datas = datas.filter((row) => {
|
|
65735
|
+
return filterBy.every((filter) => {
|
|
65736
|
+
const { key, value, ope } = filter;
|
|
65737
|
+
const rowValue = row[key];
|
|
65738
|
+
if (rowValue === undefined || rowValue === null || value === undefined || value === null) {
|
|
65739
|
+
return false;
|
|
65740
|
+
}
|
|
65741
|
+
const valStr = String(rowValue).toLowerCase();
|
|
65742
|
+
const filterStr = String(value).toLowerCase();
|
|
65743
|
+
/*eslint-disable*/
|
|
65744
|
+
switch (ope) {
|
|
65745
|
+
case 'startswith':
|
|
65746
|
+
return valStr.startsWith(filterStr);
|
|
65747
|
+
case 'endswith':
|
|
65748
|
+
return valStr.endsWith(filterStr);
|
|
65749
|
+
case 'contains':
|
|
65750
|
+
return valStr.includes(filterStr);
|
|
65751
|
+
case 'equal':
|
|
65752
|
+
return rowValue == value;
|
|
65753
|
+
case 'notequal':
|
|
65754
|
+
return rowValue != value;
|
|
65755
|
+
case 'greaterthan':
|
|
65756
|
+
return rowValue > value;
|
|
65757
|
+
case 'greaterthanorequal':
|
|
65758
|
+
return rowValue >= value;
|
|
65759
|
+
case 'lessthan':
|
|
65760
|
+
return rowValue < value;
|
|
65761
|
+
case 'lessthanorequal':
|
|
65762
|
+
return rowValue <= value;
|
|
65763
|
+
default:
|
|
65764
|
+
return false;
|
|
65765
|
+
}
|
|
65766
|
+
/*eslint-enable*/
|
|
65767
|
+
});
|
|
65768
|
+
});
|
|
65769
|
+
}
|
|
65770
|
+
if (orderBy && orderBy.length > 0) {
|
|
65771
|
+
datas = datas.sort((a, b) => {
|
|
65772
|
+
for (const order of orderBy) {
|
|
65773
|
+
const { key, direction } = order;
|
|
65774
|
+
const aValue = a[key];
|
|
65775
|
+
const bValue = b[key];
|
|
65776
|
+
if (aValue < bValue) {
|
|
65777
|
+
return direction === 'asc' ? -1 : 1;
|
|
65778
|
+
}
|
|
65779
|
+
if (aValue > bValue) {
|
|
65780
|
+
return direction === 'asc' ? 1 : -1;
|
|
65781
|
+
}
|
|
65782
|
+
}
|
|
65783
|
+
return 0;
|
|
65784
|
+
});
|
|
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;
|
|
65794
|
+
if (pagingSetting?.allowPaging && pagingSetting?.currentPage && pagingSetting?.pageSize && pagingSetting.pagingClient) {
|
|
65795
|
+
const start = (pagingSetting.currentPage - 1) * pagingSetting.pageSize;
|
|
65796
|
+
const end = start + pagingSetting.pageSize;
|
|
65797
|
+
datas = datas.slice(start, end);
|
|
65798
|
+
}
|
|
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]);
|
|
65721
65817
|
const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight } = useMemo(() => calculateTableStructure(columns), [columns]);
|
|
65722
65818
|
const scrollTimeoutRef = useRef(null);
|
|
65723
65819
|
const lastScrollTop = useRef(0);
|
|
65724
65820
|
const handleScroll = (e) => {
|
|
65725
|
-
if (!gridRef.current) {
|
|
65821
|
+
if (!gridRef.current || !isVirtualList) {
|
|
65726
65822
|
return;
|
|
65727
65823
|
}
|
|
65728
65824
|
// Nếu không có sự thay đổi về scrollTop => người dùng chỉ scroll ngang => không xử lý
|
|
@@ -65789,6 +65885,51 @@ const VirtualTable = ({ idTable, dataSource, rowHeight = 33, height = 400, colum
|
|
|
65789
65885
|
}
|
|
65790
65886
|
}
|
|
65791
65887
|
};
|
|
65888
|
+
useEffect(() => {
|
|
65889
|
+
if (setSelectedItem) {
|
|
65890
|
+
if (isMutil) {
|
|
65891
|
+
if (dataSource && selectedRows && selectedRows?.length !== selectedItem?.length) {
|
|
65892
|
+
setSelectedItem([...selectedRows]);
|
|
65893
|
+
if (handleSelect) {
|
|
65894
|
+
handleSelect([...selectedRows]);
|
|
65895
|
+
}
|
|
65896
|
+
}
|
|
65897
|
+
}
|
|
65898
|
+
else {
|
|
65899
|
+
if (dataSource && selectedRows?.length > 0) {
|
|
65900
|
+
if ((!selectedItem || (selectedItem[fieldKey] !== selectedRows[0][fieldKey]))) {
|
|
65901
|
+
setSelectedItem({ ...selectedRows[0] });
|
|
65902
|
+
if (handleSelect) {
|
|
65903
|
+
handleSelect({ ...selectedRows[0] });
|
|
65904
|
+
}
|
|
65905
|
+
}
|
|
65906
|
+
}
|
|
65907
|
+
else {
|
|
65908
|
+
setSelectedItem(undefined);
|
|
65909
|
+
if (handleSelect) {
|
|
65910
|
+
handleSelect(undefined);
|
|
65911
|
+
}
|
|
65912
|
+
}
|
|
65913
|
+
}
|
|
65914
|
+
}
|
|
65915
|
+
}, [selectedRows]);
|
|
65916
|
+
useEffect(() => {
|
|
65917
|
+
if (!isMutil) {
|
|
65918
|
+
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
65919
|
+
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
65920
|
+
setSelectedRows([selectedItem]);
|
|
65921
|
+
}
|
|
65922
|
+
}
|
|
65923
|
+
else {
|
|
65924
|
+
setSelectedRows([]);
|
|
65925
|
+
}
|
|
65926
|
+
}
|
|
65927
|
+
else {
|
|
65928
|
+
if (dataSource && selectedItem && selectedRows?.length !== selectedItem.length) {
|
|
65929
|
+
setSelectedRows(selectedItem ? [...selectedItem] : []);
|
|
65930
|
+
}
|
|
65931
|
+
}
|
|
65932
|
+
}, [selectedItem]);
|
|
65792
65933
|
return (jsxs("div", { className: "react-table-edit r-virtualized-table", children: [jsxs("div", { className: 'r-grid', children: [toolbarSetting?.showTopToolbar && jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), jsxs("div", { ref: gridRef, className: "r-gridtable", onScroll: handleScroll, style: { height: `${height ? `${height}px` : 'auto'}` }, children: [jsxs("table", { role: "presentation", style: { width: '100%' }, children: [jsx(RenderColGroup, { contentColumns: flatVisble }), jsx("thead", { className: 'r-gridheader', role: "rowgroup", children: headerColumns.map((rowColumn, indexParent) => (jsx("tr", { className: "r-row", role: "row", children: rowColumn.map((column, indexColumn) => (jsx(HeaderTableCol, { idTable: idTable, col: column, dataSource: dataSource, indexCol: indexColumn, indexParent: indexParent, isMulti: isMutil ?? false, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, columns: contentColumns, setColumns: setColumns, objWidthFixLeft: objWidthFixLeft, objWidthFixRight: objWidthFixRight, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, orderBy: orderBy, allowFilter: allowFilter, allowOrder: allowOrder, filterBy: filterBy, optionsFilter: optionsFilter, changeFilter: (val) => {
|
|
65793
65934
|
setFilterBy([...val]);
|
|
65794
65935
|
if (changeFilter) {
|
|
@@ -65802,20 +65943,20 @@ const VirtualTable = ({ idTable, dataSource, rowHeight = 33, height = 400, colum
|
|
|
65802
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) => {
|
|
65803
65944
|
const indexRow = index + startIndex;
|
|
65804
65945
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
65805
|
-
return (jsx("tr", { "aria-rowindex": indexRow + 1, role: "row", className: 'r-row', children: contentColumns.map((column, indexCol) => (jsx(RenderContentCol, { idTable: idTable, col: column, fieldKey:
|
|
65806
|
-
}),
|
|
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) => {
|
|
65807
65948
|
const item = columnsAggregate?.find((x) => x.field === col.field);
|
|
65808
65949
|
let sumValue = item?.value;
|
|
65809
65950
|
if (!item && col.haveSum === true && col.type === "numeric") {
|
|
65810
|
-
sumValue =
|
|
65951
|
+
sumValue = viewData.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0);
|
|
65811
65952
|
}
|
|
65812
65953
|
return col.visible !== false && jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
65813
65954
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
65814
65955
|
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
65815
65956
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
65816
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}`);
|
|
65817
|
-
}) }) : 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, {})] }));
|
|
65818
65959
|
};
|
|
65819
65960
|
|
|
65820
|
-
export { ExportExcelComponent, FindNodeByPath, ImportExcelComponent, InputStyleComponent, SelectTable, SelectTableTree,
|
|
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 };
|
|
65821
65962
|
//# sourceMappingURL=index.mjs.map
|