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.js
CHANGED
|
@@ -19306,7 +19306,7 @@ const FindNodeByPath = (tree, path) => {
|
|
|
19306
19306
|
* @param columns Mảng cấu trúc cây đại diện cho các cột của bảng
|
|
19307
19307
|
* @returns {
|
|
19308
19308
|
* levels: IHeaderColumnTable[][] // Các hàng header theo cấp
|
|
19309
|
-
* flat:
|
|
19309
|
+
* flat: IColumnTable[] // Danh sách cột phẳng
|
|
19310
19310
|
* objWidthFixLeft: Record<number, number> // Offset trái cho cột fixed left
|
|
19311
19311
|
* objWidthFixRight: Record<number, number> // Offset phải cho cột fixed right
|
|
19312
19312
|
* lastObjWidthFixLeft: number // Chỉ số cột cuối cùng fixed left
|
|
@@ -23568,7 +23568,7 @@ const SidebarSetColumn = (props) => {
|
|
|
23568
23568
|
}) }) }), jsxRuntime.jsx("tbody", { className: 'r-gridcontent', children: dataSource?.map((row, indexRow) => {
|
|
23569
23569
|
return (jsxRuntime.jsx("tr", { className: classNames$1('r-row', { 'last-row': indexRow === dataSource.length - 1 }, { 'fisrt-row': indexRow === 0 }), children: columns.map((col, indexCol) => {
|
|
23570
23570
|
let value = row[col.field];
|
|
23571
|
-
if (col.
|
|
23571
|
+
if (col.type === 'numeric' || (col.typeCondition && col.typeCondition(row) === 'numeric')) {
|
|
23572
23572
|
value = formartNumberic(row[col.field], ',', '.', col.numericSettings?.fraction, true) ?? 0;
|
|
23573
23573
|
}
|
|
23574
23574
|
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && jsxRuntime.jsx("td", { className: classNames$1(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': indexFocus === indexRow }), style: {
|
|
@@ -41904,7 +41904,7 @@ const HeaderTableCol$1 = (props) => {
|
|
|
41904
41904
|
};
|
|
41905
41905
|
const RenderFilterElement$1 = ({ filter, optionsFilter, formatSetting, filterBy, setOpenFilter, changeFilter, column }) => {
|
|
41906
41906
|
const { t } = reactI18next.useTranslation();
|
|
41907
|
-
const [operator, setOperator] = React$5.useState(filter?.ope ?? ((!column.filterType && column.
|
|
41907
|
+
const [operator, setOperator] = React$5.useState(filter?.ope ?? ((!column.filterType && column.type === 'numeric') || column.filterType === 'select' ? 'equal' : 'contains'));
|
|
41908
41908
|
const [valueFilter, setValueFilter] = React$5.useState(filter?.value ?? '');
|
|
41909
41909
|
const RenderStringFilter = () => {
|
|
41910
41910
|
const options = [
|
|
@@ -41969,7 +41969,7 @@ const RenderFilterElement$1 = ({ filter, optionsFilter, formatSetting, filterBy,
|
|
|
41969
41969
|
handleSave();
|
|
41970
41970
|
e.stopPropagation();
|
|
41971
41971
|
}
|
|
41972
|
-
}, children: [((!column.filterType && column.
|
|
41972
|
+
}, children: [((!column.filterType && column.type === 'numeric') || column.filterType === 'numeric') ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderNumberFilter(), " "] }) : (column.filterType === 'select' ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderSelectFilter(), " "] }) : RenderStringFilter()), jsxRuntime.jsxs("div", { className: 'd-flex justify-content-end', children: [jsxRuntime.jsx(Button$1, { color: 'primary', style: { borderRadius: 3 }, className: 'me-50 py-25 px-50 fw-bold', onClick: handleSave, children: t('Filter') }), jsxRuntime.jsx(Button$1, { className: 'py-25 px-50 fw-bold', color: 'white', style: { borderRadius: 3, borderWidth: 0 }, onClick: () => {
|
|
41973
41973
|
if (filterBy) {
|
|
41974
41974
|
changeFilter(filterBy.filter((x) => x.key !== column.field));
|
|
41975
41975
|
}
|
|
@@ -42828,7 +42828,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42828
42828
|
}
|
|
42829
42829
|
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42830
42830
|
/*eslint-disable */
|
|
42831
|
-
switch (col?.
|
|
42831
|
+
switch (col?.typeCondition ? col?.typeCondition(row) : col.type) {
|
|
42832
42832
|
case 'date':
|
|
42833
42833
|
return (jsxRuntime.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) => {
|
|
42834
42834
|
row[col.field] = date ? new Date(date.getTime() + 7 * 60 * 60 * 1000) : undefined;
|
|
@@ -43241,7 +43241,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43241
43241
|
}
|
|
43242
43242
|
}
|
|
43243
43243
|
else {
|
|
43244
|
-
if (column.
|
|
43244
|
+
if (column.type === 'date') {
|
|
43245
43245
|
const [day, month, year] = stringData.split('/');
|
|
43246
43246
|
const date = new Date(`${year}-${month}-${day}`);
|
|
43247
43247
|
if (!isNaN(date.getTime())) {
|
|
@@ -43259,7 +43259,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43259
43259
|
notificationError(t('PasteExcelIncorrectFormat', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43260
43260
|
}
|
|
43261
43261
|
}
|
|
43262
|
-
else if (column.
|
|
43262
|
+
else if (column.type === 'datetime') {
|
|
43263
43263
|
const [datePart, timePart] = stringData.split(' ');
|
|
43264
43264
|
const [day, month, year] = datePart.split('/');
|
|
43265
43265
|
const [hour, minute] = timePart.split(':');
|
|
@@ -43279,7 +43279,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43279
43279
|
notificationError(t('PasteExcelIncorrectFormat', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43280
43280
|
}
|
|
43281
43281
|
}
|
|
43282
|
-
else if (column.
|
|
43282
|
+
else if (column.type === 'numeric') {
|
|
43283
43283
|
const number = Number(stringData);
|
|
43284
43284
|
if (!isNaN(number)) {
|
|
43285
43285
|
if (column.onPaste) {
|
|
@@ -43296,7 +43296,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43296
43296
|
notificationError(t('PasteExcelIncorrectFormat', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43297
43297
|
}
|
|
43298
43298
|
}
|
|
43299
|
-
else if (column.
|
|
43299
|
+
else if (column.type === 'select') {
|
|
43300
43300
|
if (column.selectSettings?.allowCreate) {
|
|
43301
43301
|
if (column.onPaste) {
|
|
43302
43302
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43483,16 +43483,16 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43483
43483
|
}
|
|
43484
43484
|
else {
|
|
43485
43485
|
let value = row[col.field];
|
|
43486
|
-
if (col.
|
|
43486
|
+
if (col.type === 'numeric' || (col.typeCondition && col.typeCondition(row) === 'numeric')) {
|
|
43487
43487
|
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
43488
43488
|
}
|
|
43489
|
-
else if (col.
|
|
43489
|
+
else if (col.type === 'date') {
|
|
43490
43490
|
value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
|
|
43491
43491
|
}
|
|
43492
|
-
else if (col.
|
|
43492
|
+
else if (col.type === 'datetime') {
|
|
43493
43493
|
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
|
|
43494
43494
|
}
|
|
43495
|
-
const typeDis = !editDisable && (indexFocus === indexRow || col.
|
|
43495
|
+
const typeDis = !editDisable && (indexFocus === indexRow || col.type === 'checkbox') && (!col.disabledCondition || !col.disabledCondition(row)) ? (col.editEnable ? 1 : (col.template ? 2 : 3)) : (col.template ? 2 : 3);
|
|
43496
43496
|
const errorMessage = typeDis === 1 || col.field === '' || !col.validate ? '' : col.validate(row[col.field], row);
|
|
43497
43497
|
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && jsxRuntime.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: {
|
|
43498
43498
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
@@ -43534,21 +43534,21 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43534
43534
|
if (typeDis === 2) {
|
|
43535
43535
|
const value = col.template?.(row, indexRow) ?? '';
|
|
43536
43536
|
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
43537
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }), (!refreshRow && typeDis !== 2) && jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.
|
|
43537
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }), (!refreshRow && typeDis !== 2) && jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.type === 'numeric' && Number(row[col.field]) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }));
|
|
43538
43538
|
}
|
|
43539
43539
|
else {
|
|
43540
43540
|
return value;
|
|
43541
43541
|
}
|
|
43542
43542
|
}
|
|
43543
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: (col.
|
|
43543
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: (col.type === 'numeric' && Number(row[col.field]) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) }), (!(typeDis === 1 && !refreshRow) && typeDis !== 2) && jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.type === 'numeric' && Number(row[col.field]) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }));
|
|
43544
43544
|
};
|
|
43545
43545
|
const renderFooterCol = (col, indexCol) => {
|
|
43546
|
-
const sumValue = (col.haveSum === true && col.
|
|
43546
|
+
const sumValue = (col.haveSum === true && col.type === "numeric") ? dataSource.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0) : 0;
|
|
43547
43547
|
return (jsxRuntime.jsx(React$5.Fragment, { children: (col.visible !== false) && jsxRuntime.jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
43548
43548
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
43549
43549
|
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
43550
43550
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
43551
|
-
}, children: jsxRuntime.jsxs("div", { className: "r-footer-div", children: [col.haveSum === true && col.
|
|
43551
|
+
}, children: jsxRuntime.jsxs("div", { className: "r-footer-div", children: [col.haveSum === true && col.type === "numeric" && (Number(sumValue) >= 0) && jsxRuntime.jsx(jsxRuntime.Fragment, { children: formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) }), col.haveSum === true && col.type === "numeric" && (Number(sumValue) < 0) && jsxRuntime.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}`));
|
|
43552
43552
|
};
|
|
43553
43553
|
/**
|
|
43554
43554
|
* 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
|
|
@@ -46288,7 +46288,7 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46288
46288
|
isPrimarykey: true
|
|
46289
46289
|
},
|
|
46290
46290
|
{
|
|
46291
|
-
|
|
46291
|
+
type: 'text',
|
|
46292
46292
|
field: "headerText",
|
|
46293
46293
|
headerText: 'Column name',
|
|
46294
46294
|
template: (value) => { return t(value.headerText); },
|
|
@@ -65377,7 +65377,7 @@ const TabMergeImportExcel = (props) => {
|
|
|
65377
65377
|
{
|
|
65378
65378
|
headerText: 'Required Information',
|
|
65379
65379
|
field: 'isRequired',
|
|
65380
|
-
|
|
65380
|
+
type: 'checkbox',
|
|
65381
65381
|
editEnable: true,
|
|
65382
65382
|
textAlign: 'center',
|
|
65383
65383
|
template: (data) => {
|
|
@@ -65400,7 +65400,7 @@ const TabMergeImportExcel = (props) => {
|
|
|
65400
65400
|
{
|
|
65401
65401
|
headerText: 'Columns on data files',
|
|
65402
65402
|
field: 'column',
|
|
65403
|
-
|
|
65403
|
+
type: 'select',
|
|
65404
65404
|
editEnable: true,
|
|
65405
65405
|
selectSettings: {
|
|
65406
65406
|
options: optionField
|
|
@@ -65554,7 +65554,7 @@ const HeaderTableCol = (props) => {
|
|
|
65554
65554
|
orderBy.push({ direction: 'asc', key: col.field });
|
|
65555
65555
|
changeOrder(orderBy);
|
|
65556
65556
|
}
|
|
65557
|
-
}, className: classNames$1('r-headercell-div', { 'cursor-pointer': allowOrder }), children: [col.type === 'checkbox' && (jsxRuntime.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) => {
|
|
65557
|
+
}, className: classNames$1('r-headercell-div', { 'cursor-pointer': allowOrder }), children: [(col.type === 'checkbox' && !col.field) && (jsxRuntime.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) => {
|
|
65558
65558
|
if (selectEnable) {
|
|
65559
65559
|
if (e.target.checked) {
|
|
65560
65560
|
setSelectedRows(dataSource.map((item) => { return item; }));
|
|
@@ -65637,7 +65637,9 @@ const RenderFilterElement = ({ filter, optionsFilter, formatSetting, filterBy, s
|
|
|
65637
65637
|
};
|
|
65638
65638
|
return (jsxRuntime.jsxs("div", { className: 'r-filter-popup', onKeyDown: (e) => {
|
|
65639
65639
|
if (e.code === 'Enter' || e.code === 'NumpadEnter') {
|
|
65640
|
-
|
|
65640
|
+
setTimeout(() => {
|
|
65641
|
+
handleSave();
|
|
65642
|
+
}, 100);
|
|
65641
65643
|
e.stopPropagation();
|
|
65642
65644
|
}
|
|
65643
65645
|
}, children: [((!column.filterType && column.type === 'numeric') || column.filterType === 'numeric') ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderNumberFilter(), " "] }) : (column.filterType === 'select' ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderSelectFilter(), " "] }) : RenderStringFilter()), jsxRuntime.jsxs("div", { className: 'd-flex justify-content-end', children: [jsxRuntime.jsx(Button$1, { color: 'primary', style: { borderRadius: 3 }, className: 'me-50 py-25 px-50 fw-bold', onClick: handleSave, children: t('Filter') }), jsxRuntime.jsx(Button$1, { className: 'py-25 px-50 fw-bold', outline: true, style: { borderRadius: 3 }, onClick: () => {
|
|
@@ -65651,13 +65653,13 @@ const RenderFilterElement = ({ filter, optionsFilter, formatSetting, filterBy, s
|
|
|
65651
65653
|
const RenderContentCol = (props) => {
|
|
65652
65654
|
const { col, indexCol, indexRow, isSelected, row, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, selectEnable, setSelectedRows, handleCommandClick, fieldKey, isMulti } = props;
|
|
65653
65655
|
const RenderElement = () => {
|
|
65654
|
-
if (col.type === 'command') {
|
|
65656
|
+
if (col.type === 'command' && !col.field) {
|
|
65655
65657
|
return jsxRuntime.jsx("div", { className: "r-rowcell-div command", children: jsxRuntime.jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row }) });
|
|
65656
65658
|
}
|
|
65657
|
-
else if (col.type === '#') {
|
|
65659
|
+
else if (col.type === '#' && !col.field) {
|
|
65658
65660
|
jsxRuntime.jsx("div", { className: "r-rowcell-div", children: indexRow + 1 });
|
|
65659
65661
|
}
|
|
65660
|
-
else if (col.type === 'checkbox') {
|
|
65662
|
+
else if (col.type === 'checkbox' && !col.field) {
|
|
65661
65663
|
return (jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: 'center' }, onClick: (e) => {
|
|
65662
65664
|
if (selectEnable) {
|
|
65663
65665
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
@@ -65731,26 +65733,120 @@ const RenderContentCol = (props) => {
|
|
|
65731
65733
|
}, children: RenderElement() }, `col-${indexRow}-${indexCol}`));
|
|
65732
65734
|
};
|
|
65733
65735
|
|
|
65734
|
-
const
|
|
65736
|
+
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 }) => {
|
|
65737
|
+
const { t } = reactI18next.useTranslation();
|
|
65735
65738
|
const gridRef = React$5.useRef(null);
|
|
65736
|
-
const [startIndex, setStartIndex] = React$5.useState(0);
|
|
65737
65739
|
const [selectedRows, setSelectedRows] = React$5.useState([]);
|
|
65738
65740
|
const [orderBy, setOrderBy] = React$5.useState([]);
|
|
65739
65741
|
const [filterBy, setFilterBy] = React$5.useState([]);
|
|
65740
65742
|
const [searchTerm, setSearchTerm] = React$5.useState('');
|
|
65741
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? 'id';
|
|
65743
|
+
const fieldKey = (columns.find((item) => item.isPrimarykey === true)?.field) ?? 'id';
|
|
65744
|
+
const [startIndex, setStartIndex] = React$5.useState(0);
|
|
65742
65745
|
//trường liên quan đến virtul loading
|
|
65743
|
-
const visibleRowCount = Math.ceil(height / rowHeight) + 5;
|
|
65744
65746
|
const buffer = 10; // số dòng dự phòng phía trên và dưới
|
|
65745
|
-
const
|
|
65746
|
-
|
|
65747
|
-
const
|
|
65748
|
-
|
|
65747
|
+
const visibleRowCount = Math.ceil(height / rowHeight) + 5;
|
|
65748
|
+
// 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
|
|
65749
|
+
const viewData = React$5.useMemo(() => {
|
|
65750
|
+
if (!dataSource || dataSource.length === 0) {
|
|
65751
|
+
return [];
|
|
65752
|
+
}
|
|
65753
|
+
let datas = dataSource;
|
|
65754
|
+
if (searchTerm) {
|
|
65755
|
+
datas = datas.filter((row) => {
|
|
65756
|
+
return searchSetting?.keyField?.some((key) => {
|
|
65757
|
+
return row[key]?.toString().toLowerCase().includes(searchTerm.trim().toLowerCase());
|
|
65758
|
+
});
|
|
65759
|
+
});
|
|
65760
|
+
}
|
|
65761
|
+
if (filterBy && filterBy.length > 0) {
|
|
65762
|
+
datas = datas.filter((row) => {
|
|
65763
|
+
return filterBy.every((filter) => {
|
|
65764
|
+
const { key, value, ope } = filter;
|
|
65765
|
+
const rowValue = row[key];
|
|
65766
|
+
if (rowValue === undefined || rowValue === null || value === undefined || value === null) {
|
|
65767
|
+
return false;
|
|
65768
|
+
}
|
|
65769
|
+
const valStr = String(rowValue).toLowerCase();
|
|
65770
|
+
const filterStr = String(value).toLowerCase();
|
|
65771
|
+
/*eslint-disable*/
|
|
65772
|
+
switch (ope) {
|
|
65773
|
+
case 'startswith':
|
|
65774
|
+
return valStr.startsWith(filterStr);
|
|
65775
|
+
case 'endswith':
|
|
65776
|
+
return valStr.endsWith(filterStr);
|
|
65777
|
+
case 'contains':
|
|
65778
|
+
return valStr.includes(filterStr);
|
|
65779
|
+
case 'equal':
|
|
65780
|
+
return rowValue == value;
|
|
65781
|
+
case 'notequal':
|
|
65782
|
+
return rowValue != value;
|
|
65783
|
+
case 'greaterthan':
|
|
65784
|
+
return rowValue > value;
|
|
65785
|
+
case 'greaterthanorequal':
|
|
65786
|
+
return rowValue >= value;
|
|
65787
|
+
case 'lessthan':
|
|
65788
|
+
return rowValue < value;
|
|
65789
|
+
case 'lessthanorequal':
|
|
65790
|
+
return rowValue <= value;
|
|
65791
|
+
default:
|
|
65792
|
+
return false;
|
|
65793
|
+
}
|
|
65794
|
+
/*eslint-enable*/
|
|
65795
|
+
});
|
|
65796
|
+
});
|
|
65797
|
+
}
|
|
65798
|
+
if (orderBy && orderBy.length > 0) {
|
|
65799
|
+
datas = datas.sort((a, b) => {
|
|
65800
|
+
for (const order of orderBy) {
|
|
65801
|
+
const { key, direction } = order;
|
|
65802
|
+
const aValue = a[key];
|
|
65803
|
+
const bValue = b[key];
|
|
65804
|
+
if (aValue < bValue) {
|
|
65805
|
+
return direction === 'asc' ? -1 : 1;
|
|
65806
|
+
}
|
|
65807
|
+
if (aValue > bValue) {
|
|
65808
|
+
return direction === 'asc' ? 1 : -1;
|
|
65809
|
+
}
|
|
65810
|
+
}
|
|
65811
|
+
return 0;
|
|
65812
|
+
});
|
|
65813
|
+
}
|
|
65814
|
+
return datas;
|
|
65815
|
+
}, [searchTerm, filterBy, orderBy, dataSource]);
|
|
65816
|
+
// Lấy dữ liệu hiển thị với phân trang
|
|
65817
|
+
const pagingData = React$5.useMemo(() => {
|
|
65818
|
+
if (!viewData || viewData.length === 0) {
|
|
65819
|
+
return [];
|
|
65820
|
+
}
|
|
65821
|
+
let datas = viewData;
|
|
65822
|
+
if (pagingSetting?.allowPaging && pagingSetting?.currentPage && pagingSetting?.pageSize && pagingSetting.pagingClient) {
|
|
65823
|
+
const start = (pagingSetting.currentPage - 1) * pagingSetting.pageSize;
|
|
65824
|
+
const end = start + pagingSetting.pageSize;
|
|
65825
|
+
datas = datas.slice(start, end);
|
|
65826
|
+
}
|
|
65827
|
+
return datas;
|
|
65828
|
+
}, [viewData, pagingSetting?.pageSize, pagingSetting?.currentPage]);
|
|
65829
|
+
// Tính toán chỉ số bắt đầu và kết thúc của dữ liệu hiển thị
|
|
65830
|
+
const { adjustedStartIndex, adjustedEndIndex } = React$5.useMemo(() => {
|
|
65831
|
+
if (!pagingData || pagingData.length === 0 || !isVirtualList) {
|
|
65832
|
+
return { adjustedStartIndex: 0, adjustedEndIndex: 0 };
|
|
65833
|
+
}
|
|
65834
|
+
return {
|
|
65835
|
+
adjustedStartIndex: Math.max(startIndex - buffer, 0),
|
|
65836
|
+
adjustedEndIndex: Math.min(startIndex + visibleRowCount + buffer, dataSource.length)
|
|
65837
|
+
};
|
|
65838
|
+
}, [startIndex, pagingData]);
|
|
65839
|
+
const visibleData = React$5.useMemo(() => {
|
|
65840
|
+
if (!pagingData || pagingData.length === 0) {
|
|
65841
|
+
return [];
|
|
65842
|
+
}
|
|
65843
|
+
return isVirtualList ? pagingData.slice(adjustedStartIndex, adjustedEndIndex) : pagingData;
|
|
65844
|
+
}, [pagingData]);
|
|
65749
65845
|
const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight } = React$5.useMemo(() => calculateTableStructure(columns), [columns]);
|
|
65750
65846
|
const scrollTimeoutRef = React$5.useRef(null);
|
|
65751
65847
|
const lastScrollTop = React$5.useRef(0);
|
|
65752
65848
|
const handleScroll = (e) => {
|
|
65753
|
-
if (!gridRef.current) {
|
|
65849
|
+
if (!gridRef.current || !isVirtualList) {
|
|
65754
65850
|
return;
|
|
65755
65851
|
}
|
|
65756
65852
|
// Nếu không có sự thay đổi về scrollTop => người dùng chỉ scroll ngang => không xử lý
|
|
@@ -65817,6 +65913,51 @@ const VirtualTable = ({ idTable, dataSource, rowHeight = 33, height = 400, colum
|
|
|
65817
65913
|
}
|
|
65818
65914
|
}
|
|
65819
65915
|
};
|
|
65916
|
+
React$5.useEffect(() => {
|
|
65917
|
+
if (setSelectedItem) {
|
|
65918
|
+
if (isMutil) {
|
|
65919
|
+
if (dataSource && selectedRows && selectedRows?.length !== selectedItem?.length) {
|
|
65920
|
+
setSelectedItem([...selectedRows]);
|
|
65921
|
+
if (handleSelect) {
|
|
65922
|
+
handleSelect([...selectedRows]);
|
|
65923
|
+
}
|
|
65924
|
+
}
|
|
65925
|
+
}
|
|
65926
|
+
else {
|
|
65927
|
+
if (dataSource && selectedRows?.length > 0) {
|
|
65928
|
+
if ((!selectedItem || (selectedItem[fieldKey] !== selectedRows[0][fieldKey]))) {
|
|
65929
|
+
setSelectedItem({ ...selectedRows[0] });
|
|
65930
|
+
if (handleSelect) {
|
|
65931
|
+
handleSelect({ ...selectedRows[0] });
|
|
65932
|
+
}
|
|
65933
|
+
}
|
|
65934
|
+
}
|
|
65935
|
+
else {
|
|
65936
|
+
setSelectedItem(undefined);
|
|
65937
|
+
if (handleSelect) {
|
|
65938
|
+
handleSelect(undefined);
|
|
65939
|
+
}
|
|
65940
|
+
}
|
|
65941
|
+
}
|
|
65942
|
+
}
|
|
65943
|
+
}, [selectedRows]);
|
|
65944
|
+
React$5.useEffect(() => {
|
|
65945
|
+
if (!isMutil) {
|
|
65946
|
+
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
65947
|
+
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
65948
|
+
setSelectedRows([selectedItem]);
|
|
65949
|
+
}
|
|
65950
|
+
}
|
|
65951
|
+
else {
|
|
65952
|
+
setSelectedRows([]);
|
|
65953
|
+
}
|
|
65954
|
+
}
|
|
65955
|
+
else {
|
|
65956
|
+
if (dataSource && selectedItem && selectedRows?.length !== selectedItem.length) {
|
|
65957
|
+
setSelectedRows(selectedItem ? [...selectedItem] : []);
|
|
65958
|
+
}
|
|
65959
|
+
}
|
|
65960
|
+
}, [selectedItem]);
|
|
65820
65961
|
return (jsxRuntime.jsxs("div", { className: "react-table-edit r-virtualized-table", children: [jsxRuntime.jsxs("div", { className: 'r-grid', children: [toolbarSetting?.showTopToolbar && jsxRuntime.jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), jsxRuntime.jsxs("div", { ref: gridRef, className: "r-gridtable", onScroll: handleScroll, style: { height: `${height ? `${height}px` : 'auto'}` }, children: [jsxRuntime.jsxs("table", { role: "presentation", style: { width: '100%' }, children: [jsxRuntime.jsx(RenderColGroup, { contentColumns: flatVisble }), jsxRuntime.jsx("thead", { className: 'r-gridheader', role: "rowgroup", children: headerColumns.map((rowColumn, indexParent) => (jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: rowColumn.map((column, indexColumn) => (jsxRuntime.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) => {
|
|
65821
65962
|
setFilterBy([...val]);
|
|
65822
65963
|
if (changeFilter) {
|
|
@@ -65830,19 +65971,19 @@ const VirtualTable = ({ idTable, dataSource, rowHeight = 33, height = 400, colum
|
|
|
65830
65971
|
}, container: gridRef, totalCount: dataSource.length }, `header-${indexParent}-${indexColumn}`))) }, `header-${-indexParent}`))) }), jsxRuntime.jsxs("tbody", { className: 'r-gridcontent', role: "rowgroup", children: [adjustedStartIndex > 0 && (jsxRuntime.jsx("tr", { style: { height: adjustedStartIndex * rowHeight }, children: jsxRuntime.jsx("td", { style: { padding: 0 }, colSpan: flatVisble.length }) })), visibleData.map((row, index) => {
|
|
65831
65972
|
const indexRow = index + startIndex;
|
|
65832
65973
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
65833
|
-
return (jsxRuntime.jsx("tr", { "aria-rowindex": indexRow + 1, role: "row", className: 'r-row', children: contentColumns.map((column, indexCol) => (jsxRuntime.jsx(RenderContentCol, { idTable: idTable, col: column, fieldKey:
|
|
65834
|
-
}),
|
|
65974
|
+
return (jsxRuntime.jsx("tr", { "aria-rowindex": indexRow + 1, role: "row", className: 'r-row', children: contentColumns.map((column, indexCol) => (jsxRuntime.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}`));
|
|
65975
|
+
}), adjustedEndIndex > 0 && pagingData.length > adjustedEndIndex && (jsxRuntime.jsx("tr", { style: { height: (pagingData.length - adjustedEndIndex) * rowHeight }, children: jsxRuntime.jsx("td", { style: { padding: 0 }, colSpan: flatVisble.length }) }))] }), viewData.length > 0 && jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: (columnsAggregate?.length ?? 0) > 0 ? jsxRuntime.jsx("tr", { className: 'r-row', children: contentColumns.map((col, indexCol) => {
|
|
65835
65976
|
const item = columnsAggregate?.find((x) => x.field === col.field);
|
|
65836
65977
|
let sumValue = item?.value;
|
|
65837
65978
|
if (!item && col.haveSum === true && col.type === "numeric") {
|
|
65838
|
-
sumValue =
|
|
65979
|
+
sumValue = viewData.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0);
|
|
65839
65980
|
}
|
|
65840
65981
|
return col.visible !== false && jsxRuntime.jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
65841
65982
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
65842
65983
|
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
65843
65984
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
65844
65985
|
}, children: jsxRuntime.jsxs("div", { className: "r-footer-div", children: [(item || (col.haveSum === true && col.type === "numeric")) && col.type === "numeric" && (Number(sumValue) >= 0) && jsxRuntime.jsx(jsxRuntime.Fragment, { 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) && jsxRuntime.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}`);
|
|
65845
|
-
}) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }), (((
|
|
65986
|
+
}) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }), (((viewData.length ?? 0) === 0) && !isLoading) && jsxRuntime.jsxs("div", { className: "r-no-data", children: [jsxRuntime.jsx("svg", { width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsxs("g", { transform: "translate(0 1)", fill: "none", fillRule: "evenodd", children: [jsxRuntime.jsx("ellipse", { fill: "#f5f5f5", cx: "32", cy: "33", rx: "32", ry: "7" }), jsxRuntime.jsxs("g", { fillRule: "nonzero", stroke: "#d9d9d9", children: [jsxRuntime.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" }), jsxRuntime.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 && jsxRuntime.jsx("div", { className: "r-loading-overlay", children: jsxRuntime.jsxs("div", { className: "r-loading", children: [jsxRuntime.jsx(Spinner$1, { className: "me-1" }), t('Loading...')] }) })] })] }), pagingSetting?.allowPaging ? jsxRuntime.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 }) : jsxRuntime.jsx(jsxRuntime.Fragment, {})] }));
|
|
65846
65987
|
};
|
|
65847
65988
|
|
|
65848
65989
|
exports.ExportExcelComponent = ExportExcelComponent;
|
|
@@ -65851,8 +65992,8 @@ exports.ImportExcelComponent = ImportExcelComponent;
|
|
|
65851
65992
|
exports.InputStyleComponent = InputStyleComponent;
|
|
65852
65993
|
exports.SelectTable = SelectTable;
|
|
65853
65994
|
exports.SelectTableTree = SelectTableTree;
|
|
65995
|
+
exports.TableView = TableView;
|
|
65854
65996
|
exports.TabsMenuComponent = TabsMenuComponent;
|
|
65855
|
-
exports.VirtualTable = VirtualTable;
|
|
65856
65997
|
exports.Wizard = Wizard;
|
|
65857
65998
|
exports.calculateTableStructure = calculateTableStructure;
|
|
65858
65999
|
exports.checkDecimalSeparator = checkDecimalSeparator;
|