react-table-edit 1.4.36 → 1.4.38
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/sidebar-setting-column/index.d.ts +1 -1
- package/dist/component/table/index.d.ts +14 -2
- package/dist/component/type/index.d.ts +12 -14
- package/dist/component/utils.d.ts +7 -1
- package/dist/index.d.ts +33 -17
- package/dist/index.js +341 -282
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +341 -282
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17505,11 +17505,11 @@ const useOnClickOutside = (ref, handler) => {
|
|
|
17505
17505
|
// ** Call passed function on click outside
|
|
17506
17506
|
handler(event);
|
|
17507
17507
|
};
|
|
17508
|
-
document.addEventListener(
|
|
17509
|
-
document.addEventListener(
|
|
17508
|
+
document.addEventListener("mousedown", listener);
|
|
17509
|
+
document.addEventListener("touchstart", listener);
|
|
17510
17510
|
return () => {
|
|
17511
|
-
document.removeEventListener(
|
|
17512
|
-
document.removeEventListener(
|
|
17511
|
+
document.removeEventListener("mousedown", listener);
|
|
17512
|
+
document.removeEventListener("touchstart", listener);
|
|
17513
17513
|
};
|
|
17514
17514
|
},
|
|
17515
17515
|
// ** Add ref and handler to effect dependencies
|
|
@@ -17524,7 +17524,7 @@ const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17524
17524
|
if (thousandSeparator) {
|
|
17525
17525
|
if (decimalSeparator) {
|
|
17526
17526
|
if (thousandSeparator === decimalSeparator) {
|
|
17527
|
-
return
|
|
17527
|
+
return ",";
|
|
17528
17528
|
}
|
|
17529
17529
|
else {
|
|
17530
17530
|
return thousandSeparator;
|
|
@@ -17535,14 +17535,14 @@ const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17535
17535
|
}
|
|
17536
17536
|
}
|
|
17537
17537
|
else {
|
|
17538
|
-
return
|
|
17538
|
+
return ",";
|
|
17539
17539
|
}
|
|
17540
17540
|
};
|
|
17541
17541
|
const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
|
|
17542
17542
|
if (decimalSeparator) {
|
|
17543
17543
|
if (thousandSeparator) {
|
|
17544
17544
|
if (thousandSeparator === decimalSeparator) {
|
|
17545
|
-
return
|
|
17545
|
+
return ".";
|
|
17546
17546
|
}
|
|
17547
17547
|
else {
|
|
17548
17548
|
return decimalSeparator;
|
|
@@ -17553,29 +17553,32 @@ const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
17553
17553
|
}
|
|
17554
17554
|
}
|
|
17555
17555
|
else {
|
|
17556
|
-
return
|
|
17556
|
+
return ".";
|
|
17557
17557
|
}
|
|
17558
17558
|
};
|
|
17559
17559
|
const isNullOrUndefined = (d) => {
|
|
17560
|
-
if (d === null || d === undefined || d ===
|
|
17560
|
+
if (d === null || d === undefined || d === "") {
|
|
17561
17561
|
return true;
|
|
17562
17562
|
}
|
|
17563
17563
|
return false;
|
|
17564
17564
|
};
|
|
17565
17565
|
const generateUUID = () => {
|
|
17566
|
+
// Public Domain/MIT
|
|
17566
17567
|
let d = new Date().getTime(); //Timestamp
|
|
17567
|
-
let d2 = (
|
|
17568
|
-
return
|
|
17568
|
+
let d2 = (typeof performance !== "undefined" && performance.now && performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
|
|
17569
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
17569
17570
|
let r = Math.random() * 16; //random number between 0 and 16
|
|
17570
|
-
if (d > 0) {
|
|
17571
|
+
if (d > 0) {
|
|
17572
|
+
//Use timestamp until depleted
|
|
17571
17573
|
r = (d + r) % 16 | 0;
|
|
17572
17574
|
d = Math.floor(d / 16);
|
|
17573
17575
|
}
|
|
17574
|
-
else {
|
|
17576
|
+
else {
|
|
17577
|
+
//Use microseconds since page-load if supported
|
|
17575
17578
|
r = (d2 + r) % 16 | 0;
|
|
17576
17579
|
d2 = Math.floor(d2 / 16);
|
|
17577
17580
|
}
|
|
17578
|
-
return (c ===
|
|
17581
|
+
return (c === "x" ? r : 0x3).toString(16);
|
|
17579
17582
|
});
|
|
17580
17583
|
};
|
|
17581
17584
|
/**
|
|
@@ -17592,17 +17595,17 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
|
|
|
17592
17595
|
str = roundNumber(Number(str), fraction);
|
|
17593
17596
|
}
|
|
17594
17597
|
// eslint-disable-next-line
|
|
17595
|
-
if (str || str ==
|
|
17598
|
+
if (str || str == "0") {
|
|
17596
17599
|
str = str.toString();
|
|
17597
|
-
const value = decimalSeparator !==
|
|
17598
|
-
const arr = value.toString().split(decimalSeparator ??
|
|
17599
|
-
let flag = value.toString().includes(decimalSeparator ??
|
|
17600
|
+
const value = decimalSeparator !== "." ? str.toString().replaceAll(".", decimalSeparator ?? "") : str;
|
|
17601
|
+
const arr = value.toString().split(decimalSeparator ?? "", 2);
|
|
17602
|
+
let flag = value.toString().includes(decimalSeparator ?? "");
|
|
17600
17603
|
if (arr[0].length < 3) {
|
|
17601
|
-
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ??
|
|
17604
|
+
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
|
|
17602
17605
|
}
|
|
17603
17606
|
else {
|
|
17604
17607
|
let flagNegative = false;
|
|
17605
|
-
if (arr[0][0] ===
|
|
17608
|
+
if (arr[0][0] === "-") {
|
|
17606
17609
|
flagNegative = true;
|
|
17607
17610
|
arr[0] = arr[0].substring(1, arr[0].length);
|
|
17608
17611
|
}
|
|
@@ -17613,20 +17616,20 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
|
|
|
17613
17616
|
count++;
|
|
17614
17617
|
}
|
|
17615
17618
|
}
|
|
17616
|
-
if (arr[0].lastIndexOf(thousandSeparator ??
|
|
17619
|
+
if (arr[0].lastIndexOf(thousandSeparator ?? "") === arr[0].length - 1) {
|
|
17617
17620
|
arr[0] = arr[0].slice(0, arr[0].length - 1);
|
|
17618
17621
|
}
|
|
17619
17622
|
if (isDone) {
|
|
17620
|
-
flag = (arr[1]?.substring(0, fraction) ??
|
|
17623
|
+
flag = (arr[1]?.substring(0, fraction) ?? "") !== "";
|
|
17621
17624
|
}
|
|
17622
17625
|
if (flagNegative && haveNegative) {
|
|
17623
|
-
arr[0] =
|
|
17626
|
+
arr[0] = "-".concat(arr[0]);
|
|
17624
17627
|
}
|
|
17625
|
-
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ??
|
|
17628
|
+
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
|
|
17626
17629
|
}
|
|
17627
17630
|
}
|
|
17628
17631
|
else {
|
|
17629
|
-
return
|
|
17632
|
+
return "";
|
|
17630
17633
|
}
|
|
17631
17634
|
};
|
|
17632
17635
|
const roundNumber = (num, fraction) => {
|
|
@@ -17634,23 +17637,23 @@ const roundNumber = (num, fraction) => {
|
|
|
17634
17637
|
const result = Math.round(num * base) / base;
|
|
17635
17638
|
return result;
|
|
17636
17639
|
};
|
|
17637
|
-
const formatDateTime = (data, format =
|
|
17640
|
+
const formatDateTime = (data, format = "dd/MM/yyyy") => {
|
|
17638
17641
|
if (!data) {
|
|
17639
|
-
return
|
|
17642
|
+
return "";
|
|
17640
17643
|
}
|
|
17641
17644
|
const date = new Date(data);
|
|
17642
17645
|
const map = {
|
|
17643
|
-
dd: String(date.getDate()).padStart(2,
|
|
17644
|
-
MM: String(date.getMonth() + 1).padStart(2,
|
|
17646
|
+
dd: String(date.getDate()).padStart(2, "0"),
|
|
17647
|
+
MM: String(date.getMonth() + 1).padStart(2, "0"),
|
|
17645
17648
|
yyyy: date.getFullYear(),
|
|
17646
|
-
HH: String(date.getHours()).padStart(2,
|
|
17647
|
-
mm: String(date.getMinutes()).padStart(2,
|
|
17649
|
+
HH: String(date.getHours()).padStart(2, "0"),
|
|
17650
|
+
mm: String(date.getMinutes()).padStart(2, "0")
|
|
17648
17651
|
};
|
|
17649
17652
|
return format.replace(/dd|MM|yyyy|HH|mm/g, (match) => map[match]);
|
|
17650
17653
|
};
|
|
17651
17654
|
// Hàm tìm vị trí theo chuỗi index
|
|
17652
17655
|
const FindNodeByPath = (tree, path) => {
|
|
17653
|
-
const levels = path.split(
|
|
17656
|
+
const levels = path.split("-").map((num) => parseInt(num, 10));
|
|
17654
17657
|
let current = tree;
|
|
17655
17658
|
let node = null;
|
|
17656
17659
|
for (let index = 0; index < levels.length - 1; index++) {
|
|
@@ -17679,7 +17682,7 @@ const FindNodeByPath = (tree, path) => {
|
|
|
17679
17682
|
* fisrtObjWidthFixRight: number // Chỉ số cột đầu tiên fixed right
|
|
17680
17683
|
* }
|
|
17681
17684
|
*/
|
|
17682
|
-
const calculateTableStructure = (columns) => {
|
|
17685
|
+
const calculateTableStructure = (columns, settingColumns) => {
|
|
17683
17686
|
const levels = [];
|
|
17684
17687
|
const flat = [];
|
|
17685
17688
|
const objWidthFixLeft = {};
|
|
@@ -17688,18 +17691,18 @@ const calculateTableStructure = (columns) => {
|
|
|
17688
17691
|
const objHeaderWidthFixLeft = {};
|
|
17689
17692
|
let maxDepth = 0;
|
|
17690
17693
|
// Tính depth tối đa
|
|
17691
|
-
const calculateDepth = (cols, depth = 1) =>
|
|
17694
|
+
const calculateDepth = (cols, depth = 1) => Math.max(...cols.map((col) => (col.columns?.length ? calculateDepth(col.columns, depth + 1) : depth)));
|
|
17692
17695
|
maxDepth = calculateDepth(columns);
|
|
17693
17696
|
let leftTotal = 0;
|
|
17694
17697
|
let rightTotal = 0;
|
|
17695
17698
|
// Tính tổng width của các cột cố định phải
|
|
17696
17699
|
const calcTotalRightWidth = (cols) => {
|
|
17697
|
-
cols.forEach(col => {
|
|
17700
|
+
cols.forEach((col) => {
|
|
17698
17701
|
if (col.columns?.length) {
|
|
17699
17702
|
calcTotalRightWidth(col.columns);
|
|
17700
17703
|
}
|
|
17701
17704
|
else {
|
|
17702
|
-
if (col.fixedType ===
|
|
17705
|
+
if (col.fixedType === "right" && col.visible !== false) {
|
|
17703
17706
|
rightTotal += col.width ?? 40;
|
|
17704
17707
|
}
|
|
17705
17708
|
}
|
|
@@ -17717,9 +17720,20 @@ const calculateTableStructure = (columns) => {
|
|
|
17717
17720
|
colspan,
|
|
17718
17721
|
rowspan: hasChildren ? 1 : maxDepth - level
|
|
17719
17722
|
};
|
|
17723
|
+
if (settingColumns && settingColumns.length > 0) {
|
|
17724
|
+
const column = settingColumns.find((y) => y.field === cell.field);
|
|
17725
|
+
if (column) {
|
|
17726
|
+
cell.visible = column.visible;
|
|
17727
|
+
cell.fixedType = column.fixedType;
|
|
17728
|
+
cell.width = column.width;
|
|
17729
|
+
}
|
|
17730
|
+
else {
|
|
17731
|
+
cell.visible = false;
|
|
17732
|
+
}
|
|
17733
|
+
}
|
|
17720
17734
|
levels[level].push(cell);
|
|
17721
17735
|
const headerKey = `${level}-${indexCol}`;
|
|
17722
|
-
if (col.fixedType ===
|
|
17736
|
+
if (col.fixedType === "left" && col.visible !== false) {
|
|
17723
17737
|
objHeaderWidthFixLeft[headerKey] = leftTotal;
|
|
17724
17738
|
}
|
|
17725
17739
|
if (!hasChildren) {
|
|
@@ -17727,16 +17741,16 @@ const calculateTableStructure = (columns) => {
|
|
|
17727
17741
|
const width = col.width ?? 40;
|
|
17728
17742
|
cell.index = index;
|
|
17729
17743
|
flat.push(cell);
|
|
17730
|
-
if (col.fixedType ===
|
|
17744
|
+
if (col.fixedType === "left" && col.visible !== false) {
|
|
17731
17745
|
objWidthFixLeft[index] = leftTotal;
|
|
17732
17746
|
leftTotal += width;
|
|
17733
17747
|
}
|
|
17734
|
-
if (col.fixedType ===
|
|
17748
|
+
if (col.fixedType === "right" && col.in !== false) {
|
|
17735
17749
|
rightTotal -= width;
|
|
17736
17750
|
objWidthFixRight[index] = rightTotal;
|
|
17737
17751
|
}
|
|
17738
17752
|
}
|
|
17739
|
-
if (col.fixedType ===
|
|
17753
|
+
if (col.fixedType === "right" && col.visible !== false) {
|
|
17740
17754
|
objHeaderWidthFixRight[headerKey] = rightTotal;
|
|
17741
17755
|
}
|
|
17742
17756
|
return colspanSum + colspan;
|
|
@@ -40383,7 +40397,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40383
40397
|
};
|
|
40384
40398
|
}, []);
|
|
40385
40399
|
const renderFooterButtons = () => {
|
|
40386
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }), jsxRuntime.jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, children: t(
|
|
40400
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }), jsxRuntime.jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })] }));
|
|
40387
40401
|
};
|
|
40388
40402
|
const visibleTemplate = (item, index) => {
|
|
40389
40403
|
return (jsxRuntime.jsx(Input$1, { defaultChecked: item.visible ?? true, disabled: item.invisibleDisable, type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
@@ -40394,14 +40408,14 @@ const SidebarSetColumn = (props) => {
|
|
|
40394
40408
|
} }));
|
|
40395
40409
|
};
|
|
40396
40410
|
const fixColumnTemplate = (item, index) => {
|
|
40397
|
-
return (jsxRuntime.jsx(Input$1, { defaultChecked: item.fixedType ===
|
|
40411
|
+
return (jsxRuntime.jsx(Input$1, { defaultChecked: item.fixedType === "left" || item.fixedType === "right", type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
40398
40412
|
if (dataSource) {
|
|
40399
40413
|
if (e.target.checked) {
|
|
40400
|
-
if (
|
|
40401
|
-
dataSource[index].fixedType =
|
|
40414
|
+
if (index * 2 <= dataSource.length) {
|
|
40415
|
+
dataSource[index].fixedType = "left";
|
|
40402
40416
|
}
|
|
40403
40417
|
else {
|
|
40404
|
-
dataSource[index].fixedType =
|
|
40418
|
+
dataSource[index].fixedType = "right";
|
|
40405
40419
|
}
|
|
40406
40420
|
}
|
|
40407
40421
|
else {
|
|
@@ -40413,7 +40427,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40413
40427
|
};
|
|
40414
40428
|
const columns = [
|
|
40415
40429
|
{
|
|
40416
|
-
field:
|
|
40430
|
+
field: "headerText",
|
|
40417
40431
|
headerText: "Column name",
|
|
40418
40432
|
template: (e) => {
|
|
40419
40433
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: t(e.headerText) });
|
|
@@ -40424,29 +40438,29 @@ const SidebarSetColumn = (props) => {
|
|
|
40424
40438
|
minWidth: 150
|
|
40425
40439
|
},
|
|
40426
40440
|
{
|
|
40427
|
-
field:
|
|
40441
|
+
field: "",
|
|
40428
40442
|
template: visibleTemplate,
|
|
40429
40443
|
headerText: "Display",
|
|
40430
|
-
textAlign:
|
|
40444
|
+
textAlign: "center",
|
|
40431
40445
|
visible: true,
|
|
40432
40446
|
width: 100,
|
|
40433
40447
|
maxWidth: 120,
|
|
40434
40448
|
minWidth: 80
|
|
40435
40449
|
},
|
|
40436
40450
|
{
|
|
40437
|
-
field:
|
|
40451
|
+
field: "",
|
|
40438
40452
|
template: fixColumnTemplate,
|
|
40439
40453
|
headerText: "Fix the column",
|
|
40440
|
-
textAlign:
|
|
40454
|
+
textAlign: "center",
|
|
40441
40455
|
visible: true,
|
|
40442
40456
|
width: 100,
|
|
40443
40457
|
maxWidth: 120,
|
|
40444
40458
|
minWidth: 80
|
|
40445
40459
|
},
|
|
40446
40460
|
{
|
|
40447
|
-
field:
|
|
40461
|
+
field: "width",
|
|
40448
40462
|
headerText: "Column width",
|
|
40449
|
-
textAlign:
|
|
40463
|
+
textAlign: "right",
|
|
40450
40464
|
visible: true,
|
|
40451
40465
|
width: 100,
|
|
40452
40466
|
maxWidth: 120,
|
|
@@ -40454,44 +40468,42 @@ const SidebarSetColumn = (props) => {
|
|
|
40454
40468
|
}
|
|
40455
40469
|
];
|
|
40456
40470
|
const renderHeaderCol = (col, indexCol) => {
|
|
40457
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && jsxRuntime.jsx("th", { className: classNames$2(`r-headercell fix-${col.fixedType}`, {
|
|
40458
|
-
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40459
|
-
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40471
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx("th", { className: classNames$2(`r-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }), style: {
|
|
40472
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
|
|
40473
|
+
minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
|
|
40460
40474
|
top: `${0 * 42}px`,
|
|
40461
40475
|
maxWidth: col.maxWidth
|
|
40462
|
-
}, children: jsxRuntime.jsx("div", { role: "textbox", title: t(col.headerText ??
|
|
40476
|
+
}, children: jsxRuntime.jsx("div", { role: "textbox", title: t(col.headerText ?? ""), style: {
|
|
40463
40477
|
height: `${1 * 42}px`,
|
|
40464
|
-
justifyContent: col.textAlign ??
|
|
40465
|
-
}, className: "r-headercell-div", children: t(col.headerText ??
|
|
40478
|
+
justifyContent: col.textAlign ?? "left"
|
|
40479
|
+
}, className: "r-headercell-div", children: t(col.headerText ?? "") }) })) }, `header-${indexCol}`));
|
|
40466
40480
|
};
|
|
40467
|
-
return (jsxRuntime.jsxs(Sidebar, { open: openSidebar, toggleSidebar: handleCancel, width: 700, children: [jsxRuntime.jsx(ModalHeader, { typeModal:
|
|
40468
|
-
return
|
|
40469
|
-
}) }) }), jsxRuntime.jsx("tbody", { className:
|
|
40470
|
-
return (jsxRuntime.jsx("tr", { className: classNames$2(
|
|
40481
|
+
return (jsxRuntime.jsxs(Sidebar, { open: openSidebar, toggleSidebar: handleCancel, width: 700, children: [jsxRuntime.jsx(ModalHeader, { typeModal: "Edit", handleModal: handleCancel, title: "Column setup" }), jsxRuntime.jsx("div", { className: "ms-2 r-table-edit", children: jsxRuntime.jsx("div", { className: "r-grid", children: jsxRuntime.jsx("div", { className: "r-gridtable", style: { height: windowSize.innerHeight - 120 }, children: jsxRuntime.jsxs("table", { style: { width: "100%" }, children: [jsxRuntime.jsx("thead", { className: "r-gridheader", children: jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: columns.map((col, index) => {
|
|
40482
|
+
return renderHeaderCol(col, index);
|
|
40483
|
+
}) }) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
|
|
40484
|
+
return (jsxRuntime.jsx("tr", { className: classNames$2("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }), children: columns.map((col, indexCol) => {
|
|
40471
40485
|
let value = row[col.field];
|
|
40472
|
-
if (col.type ===
|
|
40473
|
-
value = formartNumberic(row[col.field],
|
|
40486
|
+
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
40487
|
+
value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
|
|
40474
40488
|
}
|
|
40475
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && jsxRuntime.jsx("td", { className: classNames$2(`r-rowcell fix-${col.fixedType}`, {
|
|
40489
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx("td", { className: classNames$2(`r-rowcell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": indexFocus === indexRow }), style: {
|
|
40476
40490
|
padding: 0,
|
|
40477
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
40491
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
40478
40492
|
}, onFocus: (e) => {
|
|
40479
40493
|
if (indexRow !== indexFocus) {
|
|
40480
40494
|
setIndexFocus(indexRow);
|
|
40481
40495
|
}
|
|
40482
40496
|
e.stopPropagation();
|
|
40483
40497
|
}, onClick: (e) => {
|
|
40484
|
-
if (e.target.nodeName ===
|
|
40498
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
40485
40499
|
if (indexRow !== indexFocus) {
|
|
40486
40500
|
setIndexFocus(indexRow);
|
|
40487
40501
|
}
|
|
40488
40502
|
e.stopPropagation();
|
|
40489
40503
|
}
|
|
40490
|
-
}, children: jsxRuntime.jsx("div", { className: classNames$2(
|
|
40491
|
-
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth :
|
|
40492
|
-
}, children: jsxRuntime.jsx("div", { className: classNames$2(
|
|
40493
|
-
margin: '7px 9px'
|
|
40494
|
-
}, children: jsxRuntime.jsx("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value }) }) }) }, `col-${indexRow}-${indexCol}`) }, indexCol));
|
|
40504
|
+
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-div"), style: {
|
|
40505
|
+
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
|
|
40506
|
+
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-content"), children: jsxRuntime.jsx("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value }) }) }) }, `col-${indexRow}-${indexCol}`)) }, indexCol));
|
|
40495
40507
|
}) }, `row-${indexRow}`));
|
|
40496
40508
|
}) })] }) }) }) }), jsxRuntime.jsx("div", { className: "d-flex justify-content-end p-1 ", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: renderFooterButtons() })] }));
|
|
40497
40509
|
};
|
|
@@ -42823,7 +42835,7 @@ const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleI
|
|
|
42823
42835
|
|
|
42824
42836
|
const TableEdit = React$5.forwardRef((props, ref) => {
|
|
42825
42837
|
const { t } = reactI18next.useTranslation();
|
|
42826
|
-
const { idTable, dataSource, columns,
|
|
42838
|
+
const { idTable, dataSource, columns, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, haveSum, isMulti, disableAutoKey, commandClick, dataSourceChange, rowChange, setSelectedItem, handleSelect, onDuplicate, saveSettingColumn, allowFilter = true, allowOrder, settingColumns, optionsFilter } = props;
|
|
42827
42839
|
React$5.useImperativeHandle(ref, () => {
|
|
42828
42840
|
return {
|
|
42829
42841
|
refeshFocusRow: handleRefeshRow
|
|
@@ -42832,28 +42844,26 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42832
42844
|
const [refreshRow, setRefreshRow] = React$5.useState(false);
|
|
42833
42845
|
const [indexFocus, setIndexFocus] = React$5.useState(-1);
|
|
42834
42846
|
const [selectedRows, setSelectedRows] = React$5.useState([]);
|
|
42835
|
-
const [contentColumns, setContentColumns] = React$5.useState([]);
|
|
42836
42847
|
const [openPopupSetupColumn, setOpenPopupSetupColumn] = React$5.useState(false);
|
|
42837
|
-
const [searchTerm, setSearchTerm] = React$5.useState(
|
|
42848
|
+
const [searchTerm, setSearchTerm] = React$5.useState("");
|
|
42838
42849
|
const [orderBy, setOrderBy] = React$5.useState([]);
|
|
42839
42850
|
const [filterBy, setFilterBy] = React$5.useState([]);
|
|
42851
|
+
const [refreshColumns, setRefreshColumns] = React$5.useState(false);
|
|
42840
42852
|
const tableElement = React$5.useRef(null);
|
|
42841
42853
|
const gridRef = React$5.useRef(null);
|
|
42842
42854
|
const totalCount = dataSource.length;
|
|
42843
42855
|
const pagingClient = pagingSetting?.allowPaging && (pagingSetting?.pagingClient || !(editDisable || addDisable));
|
|
42844
42856
|
const searchClient = searchSetting?.searchEnable && (searchSetting?.searchClient || !(editDisable || addDisable));
|
|
42845
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ??
|
|
42857
|
+
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
|
|
42846
42858
|
const fieldUniKey = columns.filter((item) => item.isUnikey === true)?.map((item) => item.field);
|
|
42847
42859
|
React$5.useEffect(() => {
|
|
42848
42860
|
if (pagingClient && pagingSetting.setCurrentPage && Math.ceil(totalCount / (pagingSetting?.pageSize ?? 1)) < (pagingSetting.currentPage ?? 1)) {
|
|
42849
42861
|
pagingSetting.setCurrentPage(1);
|
|
42850
42862
|
}
|
|
42851
42863
|
}, [dataSource]);
|
|
42852
|
-
const { levels: headerColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = React$5.useMemo(() => {
|
|
42853
|
-
|
|
42854
|
-
|
|
42855
|
-
return obj;
|
|
42856
|
-
}, [columns]);
|
|
42864
|
+
const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = React$5.useMemo(() => {
|
|
42865
|
+
return calculateTableStructure(columns, settingColumns);
|
|
42866
|
+
}, [columns, settingColumns, refreshColumns]);
|
|
42857
42867
|
const handleRefeshRow = () => {
|
|
42858
42868
|
setRefreshRow(true);
|
|
42859
42869
|
setTimeout(() => {
|
|
@@ -42873,7 +42883,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42873
42883
|
}
|
|
42874
42884
|
};
|
|
42875
42885
|
const handleKeyPress = (e) => {
|
|
42876
|
-
if (
|
|
42886
|
+
if (e.code === "Enter" || e.code === "NumpadEnter") {
|
|
42877
42887
|
if (searchSetting?.setSearchTerm) {
|
|
42878
42888
|
searchSetting?.setSearchTerm(e.target.value);
|
|
42879
42889
|
}
|
|
@@ -42885,9 +42895,9 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42885
42895
|
}
|
|
42886
42896
|
};
|
|
42887
42897
|
const searchTemplate = () => {
|
|
42888
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsx("div", { className: "me-50 r-search", children: jsxRuntime.jsx(ReactInput, { style: { width:
|
|
42898
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsx("div", { className: "me-50 r-search", children: jsxRuntime.jsx(ReactInput, { style: { width: "230px" }, value: searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, setSearchTerm: searchSetting?.setSearchTerm ? searchSetting?.setSearchTerm : setSearchTerm, placeholder: t("Search"), onKeyPress: handleKeyPress }) }) }));
|
|
42889
42899
|
};
|
|
42890
|
-
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align:
|
|
42900
|
+
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align: "left" }] : [];
|
|
42891
42901
|
let toolbarTopOption = [];
|
|
42892
42902
|
if (toolbarSetting?.toolbarOptions) {
|
|
42893
42903
|
toolbarTopOption = [...defaultToolbarOption, ...toolbarSetting?.toolbarOptions];
|
|
@@ -42898,8 +42908,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42898
42908
|
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42899
42909
|
/*eslint-disable */
|
|
42900
42910
|
switch (col?.typeCondition ? col?.typeCondition(row) : col.type) {
|
|
42901
|
-
case
|
|
42902
|
-
return (jsxRuntime.jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2(
|
|
42911
|
+
case "date":
|
|
42912
|
+
return (jsxRuntime.jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2("form-control border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }), value: row[col.field], onChange: (date) => {
|
|
42903
42913
|
row[col.field] = date ? new Date(date.getTime() + 7 * 60 * 60 * 1000) : undefined;
|
|
42904
42914
|
if (col.callback) {
|
|
42905
42915
|
col.callback(row[col.field], indexRow, row);
|
|
@@ -42915,8 +42925,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42915
42925
|
e.preventDefault();
|
|
42916
42926
|
}
|
|
42917
42927
|
} }));
|
|
42918
|
-
case
|
|
42919
|
-
return (jsxRuntime.jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2(
|
|
42928
|
+
case "datetime":
|
|
42929
|
+
return (jsxRuntime.jsx(DateInput, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, className: classNames$2("form-control border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }), value: row[col.field], onChange: (date) => {
|
|
42920
42930
|
row[col.field] = date;
|
|
42921
42931
|
if (col.callback) {
|
|
42922
42932
|
col.callback(row[col.field], indexRow, row);
|
|
@@ -42930,41 +42940,49 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42930
42940
|
e.preventDefault();
|
|
42931
42941
|
}
|
|
42932
42942
|
} }));
|
|
42933
|
-
case
|
|
42943
|
+
case "select":
|
|
42934
42944
|
let valueSelect;
|
|
42935
42945
|
let optionsSelect = [];
|
|
42936
42946
|
if (col.selectSettings?.optionsField) {
|
|
42937
42947
|
optionsSelect = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
42938
42948
|
}
|
|
42939
42949
|
else {
|
|
42940
|
-
optionsSelect = col.selectSettings?.options
|
|
42950
|
+
optionsSelect = col.selectSettings?.options
|
|
42951
|
+
? col.selectSettings?.validateOption
|
|
42952
|
+
? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row))
|
|
42953
|
+
: col.selectSettings?.options
|
|
42954
|
+
: [];
|
|
42941
42955
|
}
|
|
42942
42956
|
if (col.selectSettings?.isMulti) {
|
|
42943
|
-
valueSelect = optionsSelect.filter((x) => row[col.field].some((y) => col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(x, row) : x[col.selectSettings?.fieldValue ??
|
|
42957
|
+
valueSelect = optionsSelect.filter((x) => row[col.field].some((y) => (col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(x, row) : x[col.selectSettings?.fieldValue ?? "value"] === y)));
|
|
42944
42958
|
}
|
|
42945
42959
|
else {
|
|
42946
|
-
valueSelect =
|
|
42960
|
+
valueSelect =
|
|
42961
|
+
!isNullOrUndefined(row[col.field]) && row[col.field] !== ""
|
|
42962
|
+
? optionsSelect?.find((val) => col.selectSettings?.compareFunction ? col.selectSettings.compareFunction(val, row) : val[col.selectSettings?.fieldValue ?? "value"] === row[col.field])
|
|
42963
|
+
: "";
|
|
42947
42964
|
if (!valueSelect && col.selectSettings?.defaultValue) {
|
|
42948
42965
|
valueSelect = col.selectSettings?.defaultValue(row);
|
|
42949
42966
|
}
|
|
42950
42967
|
}
|
|
42951
42968
|
return (jsxRuntime.jsx(SelectTable, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelect, options: optionsSelect, onChange: (val) => {
|
|
42952
42969
|
if (col.selectSettings?.isMulti) {
|
|
42953
|
-
row[col.field] = (val?.length ?? 0) > 0 ? val.map((item) => item[col.selectSettings?.fieldValue ??
|
|
42970
|
+
row[col.field] = (val?.length ?? 0) > 0 ? val.map((item) => item[col.selectSettings?.fieldValue ?? "value"]) : [];
|
|
42954
42971
|
}
|
|
42955
42972
|
else {
|
|
42956
|
-
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ??
|
|
42973
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : undefined;
|
|
42957
42974
|
}
|
|
42958
42975
|
if (val && col.selectSettings?.loadOptions && isMulti) {
|
|
42959
|
-
if (isMulti) {
|
|
42976
|
+
if (isMulti) {
|
|
42977
|
+
//push giá trị vào option khi loadoption
|
|
42960
42978
|
val.forEach((e) => {
|
|
42961
|
-
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ??
|
|
42979
|
+
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ?? "value"] === e[col.selectSettings?.fieldValue ?? "value"])) {
|
|
42962
42980
|
optionsSelect.unshift(e);
|
|
42963
42981
|
}
|
|
42964
42982
|
});
|
|
42965
42983
|
}
|
|
42966
42984
|
else if (!col.selectSettings?.defaultValue) {
|
|
42967
|
-
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ??
|
|
42985
|
+
if (!optionsSelect.some((a) => a[col.selectSettings?.fieldValue ?? "value"] === val[col.selectSettings?.fieldValue ?? "value"])) {
|
|
42968
42986
|
optionsSelect.unshift(val);
|
|
42969
42987
|
}
|
|
42970
42988
|
}
|
|
@@ -42973,27 +42991,21 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42973
42991
|
col.callback(val, indexRow, row);
|
|
42974
42992
|
}
|
|
42975
42993
|
handleDataChange(row, col, indexRow);
|
|
42976
|
-
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t(
|
|
42977
|
-
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42978
|
-
}, onOpenMenu: () => {
|
|
42979
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
42980
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42981
|
-
}
|
|
42982
|
-
}, onPaste: (e) => {
|
|
42994
|
+
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t("Select"), loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, invalid: col.validate && !isNullOrUndefined(col.validate(row[col.field], row)), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? "left", allowCreate: col.selectSettings?.allowCreate, compareFunction: col.selectSettings?.compareFunction ? (e) => col.selectSettings?.compareFunction?.(e, row) : undefined, onKeyDown: (e) => checkKeyDown(e, row, col, indexRow + 1, indexCol + 1), onOpenMenu: col.selectSettings?.onOpenMenu ? () => col.selectSettings?.onOpenMenu?.(row, col, indexRow) : undefined, onPaste: (e) => {
|
|
42983
42995
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42984
42996
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42985
42997
|
e.preventDefault();
|
|
42986
42998
|
}
|
|
42987
42999
|
} }));
|
|
42988
|
-
case
|
|
43000
|
+
case "selectTree":
|
|
42989
43001
|
const findItemInTree = (items, value) => {
|
|
42990
43002
|
for (let index = 0; index < items.length; index++) {
|
|
42991
43003
|
const item = items[index];
|
|
42992
|
-
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue :
|
|
43004
|
+
if (item[col.selectSettings?.fieldValue ? col.selectSettings?.fieldValue : "value"] === value) {
|
|
42993
43005
|
return { ...item };
|
|
42994
43006
|
}
|
|
42995
|
-
else if (item[col.selectSettings?.fieldChild ??
|
|
42996
|
-
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ??
|
|
43007
|
+
else if (item[col.selectSettings?.fieldChild ?? "children"]?.length > 0) {
|
|
43008
|
+
const itemFilter = findItemInTree(item[col.selectSettings?.fieldChild ?? "children"], value);
|
|
42997
43009
|
if (itemFilter) {
|
|
42998
43010
|
return itemFilter;
|
|
42999
43011
|
}
|
|
@@ -43006,39 +43018,37 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43006
43018
|
optionsSelectTree = row[col.selectSettings?.optionsField] ? row[col.selectSettings?.optionsField] : [];
|
|
43007
43019
|
}
|
|
43008
43020
|
else {
|
|
43009
|
-
optionsSelectTree = col.selectSettings?.options
|
|
43021
|
+
optionsSelectTree = col.selectSettings?.options
|
|
43022
|
+
? col.selectSettings?.validateOption
|
|
43023
|
+
? col.selectSettings?.options.filter((item) => col.selectSettings?.validateOption(item, row))
|
|
43024
|
+
: col.selectSettings?.options
|
|
43025
|
+
: [];
|
|
43010
43026
|
}
|
|
43011
43027
|
if (col.selectSettings?.isMulti) {
|
|
43012
43028
|
valueSelectTree = row[col.field];
|
|
43013
43029
|
}
|
|
43014
43030
|
else {
|
|
43015
|
-
valueSelectTree =
|
|
43031
|
+
valueSelectTree = !isNullOrUndefined(row[col.field]) && row[col.field] !== "" ? findItemInTree(optionsSelectTree, row[col.field]) : "";
|
|
43016
43032
|
}
|
|
43017
43033
|
return (jsxRuntime.jsx(SelectTableTree, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelectTree, options: optionsSelectTree, onChange: (val) => {
|
|
43018
43034
|
if (col.selectSettings?.isMulti) {
|
|
43019
43035
|
row[col.field] = !isNullOrUndefined(val) ? val : [];
|
|
43020
43036
|
}
|
|
43021
43037
|
else {
|
|
43022
|
-
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ??
|
|
43038
|
+
row[col.field] = !isNullOrUndefined(val) ? val[col.selectSettings?.fieldValue ?? "value"] : undefined;
|
|
43023
43039
|
}
|
|
43024
43040
|
if (col.callback) {
|
|
43025
43041
|
col.callback(val, indexRow, row);
|
|
43026
43042
|
}
|
|
43027
43043
|
handleDataChange(row, col, indexRow);
|
|
43028
|
-
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t(
|
|
43029
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
43030
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
43031
|
-
}
|
|
43032
|
-
}, loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, fieldChildren: col.selectSettings?.fieldChild ?? 'children', selectChilds: col.selectSettings?.selectChilds, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, invalid: col.validate && col.validate(row[col.field], row), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? 'left', onKeyDown: (e) => {
|
|
43033
|
-
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
43034
|
-
}, onPaste: (e) => {
|
|
43044
|
+
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t("Select"), loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, fieldChildren: col.selectSettings?.fieldChild ?? "children", selectChilds: col.selectSettings?.selectChilds, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, invalid: col.validate && col.validate(row[col.field], row), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? "left", onKeyDown: (e) => checkKeyDown(e, row, col, indexRow + 1, indexCol + 1), onOpenMenu: col.selectSettings?.onOpenMenu ? () => col.selectSettings?.onOpenMenu?.(row, col, indexRow) : undefined, onPaste: (e) => {
|
|
43035
43045
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
43036
43046
|
pasteDataFromExcel(indexRow, indexCol, e);
|
|
43037
43047
|
e.preventDefault();
|
|
43038
43048
|
}
|
|
43039
43049
|
} }));
|
|
43040
|
-
case
|
|
43041
|
-
return (jsxRuntime.jsx(Input$1, { checked: !!row[col.field], id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, type: "checkbox", className: "input-checkbox cursor-pointer", style: { textAlign: col.textAlign ??
|
|
43050
|
+
case "checkbox":
|
|
43051
|
+
return (jsxRuntime.jsx(Input$1, { checked: !!row[col.field], id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, type: "checkbox", className: "input-checkbox cursor-pointer", style: { textAlign: col.textAlign ?? "left", marginTop: 6 }, onChange: (val) => {
|
|
43042
43052
|
row[col.field] = val.currentTarget.checked;
|
|
43043
43053
|
if (col.callback) {
|
|
43044
43054
|
col.callback(val.target.value, indexRow, row);
|
|
@@ -43047,16 +43057,16 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43047
43057
|
}, onKeyDown: (e) => {
|
|
43048
43058
|
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
43049
43059
|
} }));
|
|
43050
|
-
case
|
|
43060
|
+
case "numeric":
|
|
43051
43061
|
const numericFormatProps = {
|
|
43052
|
-
value: !isNullOrUndefined(row[col.field]) ? row[col.field].toString() :
|
|
43062
|
+
value: !isNullOrUndefined(row[col.field]) ? row[col.field].toString() : "",
|
|
43053
43063
|
thousandSeparator: checkThousandSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
43054
43064
|
decimalSeparator: checkDecimalSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
43055
43065
|
allowNegative: col.numericSettings?.allowNegative ?? false,
|
|
43056
43066
|
decimalScale: col.numericSettings?.fraction ?? 0
|
|
43057
43067
|
};
|
|
43058
|
-
let floatValue = parseFloat(row[col.field] ??
|
|
43059
|
-
return (jsxRuntime.jsx(NumericFormat, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, ...numericFormatProps, defaultValue: formartNumberic(row[col.field], formatSetting?.decimalSeparator ??
|
|
43068
|
+
let floatValue = parseFloat(row[col.field] ?? "0");
|
|
43069
|
+
return (jsxRuntime.jsx(NumericFormat, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, ...numericFormatProps, defaultValue: formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction), className: classNames$2("form-control border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }), onValueChange: (values) => {
|
|
43060
43070
|
floatValue = values?.floatValue;
|
|
43061
43071
|
}, onFocus: (e) => {
|
|
43062
43072
|
e.target.setSelectionRange(0, e.target.innerText.length - 1);
|
|
@@ -43069,7 +43079,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43069
43079
|
handleDataChange(row, col, indexRow);
|
|
43070
43080
|
}
|
|
43071
43081
|
}, onKeyDown: (e) => {
|
|
43072
|
-
if (e.key ===
|
|
43082
|
+
if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
|
|
43073
43083
|
if (floatValue !== row[col.field]) {
|
|
43074
43084
|
row[col.field] = !isNaN(floatValue) ? floatValue : 0;
|
|
43075
43085
|
if (col.callback) {
|
|
@@ -43085,8 +43095,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43085
43095
|
e.preventDefault();
|
|
43086
43096
|
}
|
|
43087
43097
|
} }));
|
|
43088
|
-
case
|
|
43089
|
-
return (jsxRuntime.jsx("div", { style: { padding:
|
|
43098
|
+
case "color":
|
|
43099
|
+
return (jsxRuntime.jsx("div", { style: { padding: "4px 8px" }, children: jsxRuntime.jsx(Input$1, { type: "color", value: row[col.field], style: { textAlign: col.textAlign ?? "center", padding: 0, height: 23, border: "none" }, disabled: editDisable, onChange: (val) => {
|
|
43090
43100
|
if (row[col.field] != val.target?.value) {
|
|
43091
43101
|
row[col.field] = val.target?.value;
|
|
43092
43102
|
if (col.callback) {
|
|
@@ -43097,8 +43107,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43097
43107
|
}, onKeyDown: (val) => {
|
|
43098
43108
|
checkKeyDown(val, row, col, indexRow + 1, indexCol + 1);
|
|
43099
43109
|
} }, `col-${indexRow}-${indexCol}`) }));
|
|
43100
|
-
case
|
|
43101
|
-
return (jsxRuntime.jsx(EditForm, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) :
|
|
43110
|
+
case "form":
|
|
43111
|
+
return (jsxRuntime.jsx(EditForm, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) : "", placeholder: col.placeholder ? t(col.placeholder) : "", rowData: row, indexRow: indexRow, onChange: (val) => {
|
|
43102
43112
|
Object.assign(row, val);
|
|
43103
43113
|
handleDataChange(row, col, indexRow);
|
|
43104
43114
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -43109,8 +43119,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43109
43119
|
e.preventDefault();
|
|
43110
43120
|
}
|
|
43111
43121
|
} }));
|
|
43112
|
-
case
|
|
43113
|
-
return (jsxRuntime.jsx(EditFormInline, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) :
|
|
43122
|
+
case "formInline":
|
|
43123
|
+
return (jsxRuntime.jsx(EditFormInline, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) : "", placeholder: col.placeholder ? t(col.placeholder) : "", rowData: row, indexRow: indexRow, onChange: (val) => {
|
|
43114
43124
|
Object.assign(row, val);
|
|
43115
43125
|
handleDataChange(row, col, indexRow);
|
|
43116
43126
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -43122,7 +43132,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43122
43132
|
}
|
|
43123
43133
|
} }));
|
|
43124
43134
|
default:
|
|
43125
|
-
return (jsxRuntime.jsx(Input$1, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, value: isNullOrUndefined(row[col.field]) ?
|
|
43135
|
+
return (jsxRuntime.jsx(Input$1, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, value: isNullOrUndefined(row[col.field]) ? "" : row[col.field], className: classNames$2("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }), onChange: (val) => {
|
|
43126
43136
|
if (row[col.field] != val.target?.value) {
|
|
43127
43137
|
row[col.field] = val.target?.value;
|
|
43128
43138
|
if (col.callback) {
|
|
@@ -43150,8 +43160,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43150
43160
|
setTimeout(() => {
|
|
43151
43161
|
const element = document.getElementById(`${idTable}-col${col}-row${row}`);
|
|
43152
43162
|
if (element) {
|
|
43153
|
-
if (element.className.includes(
|
|
43154
|
-
element.getElementsByTagName(
|
|
43163
|
+
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
43164
|
+
element.getElementsByTagName("input")[0]?.focus();
|
|
43155
43165
|
}
|
|
43156
43166
|
else {
|
|
43157
43167
|
element.focus();
|
|
@@ -43160,16 +43170,17 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43160
43170
|
if (tableElement.current) {
|
|
43161
43171
|
const parentRect = tableElement.current.getBoundingClientRect();
|
|
43162
43172
|
const childRect = element.getBoundingClientRect();
|
|
43163
|
-
const offset = childRect.left - parentRect.left + tableElement.current.scrollLeft -
|
|
43164
|
-
tableElement.current.scrollTo({ left: offset, behavior:
|
|
43173
|
+
const offset = childRect.left - parentRect.left + tableElement.current.scrollLeft - parentRect.width / 2 + childRect.width / 2;
|
|
43174
|
+
tableElement.current.scrollTo({ left: offset, behavior: "smooth" });
|
|
43165
43175
|
}
|
|
43166
43176
|
}
|
|
43167
43177
|
if ((tableElement.current?.scrollHeight ?? 0) > 0) {
|
|
43168
43178
|
if ((tableElement.current?.scrollTop ?? 0) > ((row - 1) % (pagingSetting?.pageSize ?? 10000)) * 34) {
|
|
43169
|
-
tableElement.current?.scrollTo({ behavior:
|
|
43179
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: ((row - 1) % (pagingSetting?.pageSize ?? 10000)) * 34 });
|
|
43170
43180
|
}
|
|
43171
|
-
else if ((
|
|
43172
|
-
|
|
43181
|
+
else if ((tableElement.current?.clientHeight ?? 0) - (haveSum ? 30 : 0) - headerColumns.length * 42 <
|
|
43182
|
+
(row % (pagingSetting?.pageSize ?? 10000)) * 34 - (tableElement.current?.scrollTop ?? 0)) {
|
|
43183
|
+
tableElement.current?.scrollTo({ behavior: "smooth", top: (tableElement.current?.scrollTop ?? 0) + 34 });
|
|
43173
43184
|
}
|
|
43174
43185
|
}
|
|
43175
43186
|
}
|
|
@@ -43178,7 +43189,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43178
43189
|
//Thêm dòng mới
|
|
43179
43190
|
const moveIndexRowToNewPage = () => {
|
|
43180
43191
|
changeDataSource(dataSource, 1);
|
|
43181
|
-
if (pagingClient && pagingSetting?.setCurrentPage &&
|
|
43192
|
+
if (pagingClient && pagingSetting?.setCurrentPage && totalCount % (pagingSetting?.pageSize ?? 0) === 0) {
|
|
43182
43193
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 0) + 1);
|
|
43183
43194
|
}
|
|
43184
43195
|
if (tableElement) {
|
|
@@ -43253,25 +43264,25 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43253
43264
|
return undefined;
|
|
43254
43265
|
};
|
|
43255
43266
|
const pasteDataFromExcel = async (currenRowIndex, indexCol, e) => {
|
|
43256
|
-
const clipboard = (e.clipboardData || window.Clipboard).getData(
|
|
43257
|
-
const rowsClipboard = clipboard.trimEnd().split(
|
|
43267
|
+
const clipboard = (e.clipboardData || window.Clipboard).getData("text");
|
|
43268
|
+
const rowsClipboard = clipboard.trimEnd().split("\n");
|
|
43258
43269
|
setIndexFocus(-1);
|
|
43259
43270
|
if (rowsClipboard.length > 200) {
|
|
43260
|
-
messageBoxError(t,
|
|
43271
|
+
messageBoxError(t, "You can only paste up to 200 rows.");
|
|
43261
43272
|
}
|
|
43262
43273
|
if (rowsClipboard.length > 0) {
|
|
43263
43274
|
const columnsDataChange = [];
|
|
43264
|
-
for (let index = 0; index < rowsClipboard[0].trimEnd().split(
|
|
43275
|
+
for (let index = 0; index < rowsClipboard[0].trimEnd().split("\t").length; index++) {
|
|
43265
43276
|
const stringData = [];
|
|
43266
43277
|
rowsClipboard.forEach((element) => {
|
|
43267
|
-
if (element.trimEnd().split(
|
|
43268
|
-
stringData.push(element.trimEnd().split(
|
|
43278
|
+
if (element.trimEnd().split("\t")[index] && !stringData.includes(element.trimEnd().split("\t")[index].toString().trim())) {
|
|
43279
|
+
stringData.push(element.trimEnd().split("\t")[index].toString().trim());
|
|
43269
43280
|
}
|
|
43270
43281
|
});
|
|
43271
43282
|
const column = getColumn(indexCol, index);
|
|
43272
43283
|
if (column) {
|
|
43273
43284
|
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
|
|
43274
|
-
const rs = await column.onPasteValidate(stringData.join(
|
|
43285
|
+
const rs = await column.onPasteValidate(stringData.join(","), currenRowIndex + 0, dataSource[currenRowIndex + 0]);
|
|
43275
43286
|
if (rs) {
|
|
43276
43287
|
column.resultValidate = rs;
|
|
43277
43288
|
}
|
|
@@ -43281,7 +43292,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43281
43292
|
}
|
|
43282
43293
|
for (let indexRow = 0; indexRow < rowsClipboard.length; indexRow++) {
|
|
43283
43294
|
const item = rowsClipboard[indexRow];
|
|
43284
|
-
const colsClipboard = item.trimEnd().split(
|
|
43295
|
+
const colsClipboard = item.trimEnd().split("\t");
|
|
43285
43296
|
let dataRow = dataSource[currenRowIndex + indexRow];
|
|
43286
43297
|
if (!dataRow) {
|
|
43287
43298
|
dataRow = { ...defaultValue };
|
|
@@ -43293,7 +43304,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43293
43304
|
if (column) {
|
|
43294
43305
|
if (((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + indexRow])) && column.editEnable) || column.onPaste) {
|
|
43295
43306
|
if (column.onPasteValidate && column.resultValidate) {
|
|
43296
|
-
const rs = column.resultValidate.find((item) => item[column.selectSettings?.fieldValue ??
|
|
43307
|
+
const rs = column.resultValidate.find((item) => item[column.selectSettings?.fieldValue ?? "value"] === stringData);
|
|
43297
43308
|
if (rs) {
|
|
43298
43309
|
if (column.onPaste) {
|
|
43299
43310
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43306,12 +43317,12 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43306
43317
|
}
|
|
43307
43318
|
}
|
|
43308
43319
|
else {
|
|
43309
|
-
notificationError(t(
|
|
43320
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43310
43321
|
}
|
|
43311
43322
|
}
|
|
43312
43323
|
else {
|
|
43313
|
-
if (column.type ===
|
|
43314
|
-
const [day, month, year] = stringData.split(
|
|
43324
|
+
if (column.type === "date") {
|
|
43325
|
+
const [day, month, year] = stringData.split("/");
|
|
43315
43326
|
const date = new Date(`${year}-${month}-${day}`);
|
|
43316
43327
|
if (!isNaN(date.getTime())) {
|
|
43317
43328
|
if (column.onPaste) {
|
|
@@ -43325,13 +43336,13 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43325
43336
|
}
|
|
43326
43337
|
}
|
|
43327
43338
|
else {
|
|
43328
|
-
notificationError(t(
|
|
43339
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43329
43340
|
}
|
|
43330
43341
|
}
|
|
43331
|
-
else if (column.type ===
|
|
43332
|
-
const [datePart, timePart] = stringData.split(
|
|
43333
|
-
const [day, month, year] = datePart.split(
|
|
43334
|
-
const [hour, minute] = timePart.split(
|
|
43342
|
+
else if (column.type === "datetime") {
|
|
43343
|
+
const [datePart, timePart] = stringData.split(" ");
|
|
43344
|
+
const [day, month, year] = datePart.split("/");
|
|
43345
|
+
const [hour, minute] = timePart.split(":");
|
|
43335
43346
|
const date = new Date(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute));
|
|
43336
43347
|
if (!isNaN(date.getTime())) {
|
|
43337
43348
|
if (column.onPaste) {
|
|
@@ -43345,11 +43356,11 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43345
43356
|
}
|
|
43346
43357
|
}
|
|
43347
43358
|
else {
|
|
43348
|
-
notificationError(t(
|
|
43359
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43349
43360
|
}
|
|
43350
43361
|
}
|
|
43351
|
-
else if (column.type ===
|
|
43352
|
-
const number = Number(stringData.replaceAll(formatSetting?.thousandSeparator ??
|
|
43362
|
+
else if (column.type === "numeric") {
|
|
43363
|
+
const number = Number(stringData.replaceAll(formatSetting?.thousandSeparator ?? ".", "").replaceAll(formatSetting?.decimalSeparator ?? ",", "."));
|
|
43353
43364
|
if (!isNaN(number)) {
|
|
43354
43365
|
if (column.onPaste) {
|
|
43355
43366
|
dataRow[column.field] = column.onPaste(dataRow, number);
|
|
@@ -43362,10 +43373,10 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43362
43373
|
}
|
|
43363
43374
|
}
|
|
43364
43375
|
else {
|
|
43365
|
-
notificationError(t(
|
|
43376
|
+
notificationError(t("PasteExcelIncorrectFormat", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43366
43377
|
}
|
|
43367
43378
|
}
|
|
43368
|
-
else if (column.type ===
|
|
43379
|
+
else if (column.type === "select") {
|
|
43369
43380
|
if (column.selectSettings?.allowCreate) {
|
|
43370
43381
|
if (column.onPaste) {
|
|
43371
43382
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43378,7 +43389,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43378
43389
|
}
|
|
43379
43390
|
}
|
|
43380
43391
|
else {
|
|
43381
|
-
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ??
|
|
43392
|
+
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ?? "value"] === stringData);
|
|
43382
43393
|
if (rs) {
|
|
43383
43394
|
if (column.onPaste) {
|
|
43384
43395
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
@@ -43391,7 +43402,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43391
43402
|
}
|
|
43392
43403
|
}
|
|
43393
43404
|
else {
|
|
43394
|
-
notificationError(t(
|
|
43405
|
+
notificationError(t("PasteExcelNotExist", { index: currenRowIndex + indexRow + 1, field: t(column.headerText ?? ""), value: stringData }));
|
|
43395
43406
|
}
|
|
43396
43407
|
}
|
|
43397
43408
|
}
|
|
@@ -43411,7 +43422,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43411
43422
|
}
|
|
43412
43423
|
}
|
|
43413
43424
|
if (rowChange) {
|
|
43414
|
-
rowChange(dataRow, currenRowIndex + indexRow,
|
|
43425
|
+
rowChange(dataRow, currenRowIndex + indexRow, "");
|
|
43415
43426
|
}
|
|
43416
43427
|
}
|
|
43417
43428
|
}
|
|
@@ -43443,7 +43454,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43443
43454
|
}
|
|
43444
43455
|
else {
|
|
43445
43456
|
if (dataSource && selectedRows?.length > 0) {
|
|
43446
|
-
if (
|
|
43457
|
+
if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
43447
43458
|
setSelectedItem({ ...selectedRows[0] });
|
|
43448
43459
|
if (handleSelect) {
|
|
43449
43460
|
handleSelect({ ...selectedRows[0] });
|
|
@@ -43477,56 +43488,61 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43477
43488
|
}
|
|
43478
43489
|
}, [selectedItem]);
|
|
43479
43490
|
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
43480
|
-
if (col.field ===
|
|
43481
|
-
return (col.visible !== false && jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 fix-${col.fixedType}`, {
|
|
43482
|
-
left: col.fixedType ===
|
|
43483
|
-
right: col.fixedType ===
|
|
43484
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
43485
|
-
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div command", children: jsxRuntime.jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row, setIndexFocus: setIndexFocus, indexFocus: indexFocus }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43491
|
+
if (col.field === "command") {
|
|
43492
|
+
return (col.visible !== false && (jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 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: {
|
|
43493
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43494
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43495
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43496
|
+
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div command", children: jsxRuntime.jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row, setIndexFocus: setIndexFocus, indexFocus: indexFocus }) }) }, `col-${indexRow}-${indexCol}`)));
|
|
43486
43497
|
}
|
|
43487
|
-
else if (col.field ===
|
|
43488
|
-
return (col.visible !== false && jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, {
|
|
43489
|
-
left: col.fixedType ===
|
|
43490
|
-
right: col.fixedType ===
|
|
43491
|
-
textAlign:
|
|
43498
|
+
else if (col.field === "#") {
|
|
43499
|
+
return (col.visible !== false && (jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 cursor-pointer 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 }), tabIndex: Number(`${indexRow}${indexCol}`), style: {
|
|
43500
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43501
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43502
|
+
textAlign: "center"
|
|
43492
43503
|
}, onCopy: (e) => {
|
|
43493
|
-
if (!editDisable && (e.target.nodeName ===
|
|
43504
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43494
43505
|
navigator.clipboard.writeText(JSON.stringify(row));
|
|
43495
|
-
notificationSuccess(t(
|
|
43506
|
+
notificationSuccess(t("CopySuccessful"));
|
|
43496
43507
|
e.stopPropagation();
|
|
43497
43508
|
}
|
|
43498
43509
|
}, onPaste: (e) => {
|
|
43499
|
-
if (!editDisable && (e.target.nodeName ===
|
|
43500
|
-
navigator.clipboard
|
|
43510
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43511
|
+
navigator.clipboard
|
|
43512
|
+
.readText()
|
|
43513
|
+
.then((rs) => {
|
|
43501
43514
|
dataSource[indexRow] = JSON.parse(rs);
|
|
43502
43515
|
if (fieldKey) {
|
|
43503
43516
|
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
43504
43517
|
}
|
|
43505
43518
|
changeDataSource(dataSource);
|
|
43506
|
-
notificationSuccess(t(
|
|
43507
|
-
})
|
|
43519
|
+
notificationSuccess(t("PasteSuccessful"));
|
|
43520
|
+
})
|
|
43521
|
+
.catch((ex) => {
|
|
43522
|
+
alert(ex);
|
|
43523
|
+
});
|
|
43508
43524
|
e.stopPropagation();
|
|
43509
43525
|
}
|
|
43510
43526
|
}, onClick: (e) => {
|
|
43511
|
-
if (e.target.nodeName ===
|
|
43527
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
43512
43528
|
if (!editDisable && indexRow != indexFocus) {
|
|
43513
43529
|
setIndexFocus(indexRow);
|
|
43514
43530
|
}
|
|
43515
43531
|
e.stopPropagation();
|
|
43516
43532
|
}
|
|
43517
43533
|
}, onKeyDown: (e) => {
|
|
43518
|
-
if (e.code ===
|
|
43534
|
+
if (e.code === "KeyD" && e.ctrlKey == true && !editDisable && !addDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
43519
43535
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
43520
43536
|
e.preventDefault();
|
|
43521
43537
|
e.stopPropagation();
|
|
43522
43538
|
}
|
|
43523
|
-
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`));
|
|
43539
|
+
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`)));
|
|
43524
43540
|
}
|
|
43525
|
-
else if (col.field ===
|
|
43526
|
-
return (jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 fix-${col.fixedType}`, {
|
|
43527
|
-
left: col.fixedType ===
|
|
43528
|
-
right: col.fixedType ===
|
|
43529
|
-
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems:
|
|
43541
|
+
else if (col.field === "checkbox") {
|
|
43542
|
+
return (jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`r-rowcell p-0 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: {
|
|
43543
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43544
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined
|
|
43545
|
+
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: "center" }, onClick: (e) => {
|
|
43530
43546
|
if (selectEnable) {
|
|
43531
43547
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
43532
43548
|
if (index > -1) {
|
|
@@ -43548,26 +43564,34 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43548
43564
|
}
|
|
43549
43565
|
e.stopPropagation();
|
|
43550
43566
|
}
|
|
43551
|
-
}, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ??
|
|
43567
|
+
}, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? "center" } }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43552
43568
|
}
|
|
43553
43569
|
else {
|
|
43554
43570
|
let value = row[col.field];
|
|
43555
|
-
if (col.type ===
|
|
43556
|
-
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ??
|
|
43571
|
+
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
43572
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", col.numericSettings?.fraction, true, false) ?? 0;
|
|
43557
43573
|
}
|
|
43558
|
-
else if (col.type ===
|
|
43559
|
-
value = value ? formatDateTime(value, formatSetting?.dateFormat) :
|
|
43574
|
+
else if (col.type === "date") {
|
|
43575
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : "";
|
|
43560
43576
|
}
|
|
43561
|
-
else if (col.type ===
|
|
43562
|
-
value = value ? formatDateTime(value, formatSetting?.dateFormat ??
|
|
43577
|
+
else if (col.type === "datetime") {
|
|
43578
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? "DD/MM/yyyy HH:mm") : "";
|
|
43563
43579
|
}
|
|
43564
|
-
const typeDis = !editDisable && (indexFocus === indexRow || col.type ===
|
|
43565
|
-
|
|
43566
|
-
|
|
43567
|
-
|
|
43568
|
-
|
|
43580
|
+
const typeDis = !editDisable && (indexFocus === indexRow || col.type === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row))
|
|
43581
|
+
? col.editEnable
|
|
43582
|
+
? 1
|
|
43583
|
+
: col.template
|
|
43584
|
+
? 2
|
|
43585
|
+
: 3
|
|
43586
|
+
: col.template
|
|
43587
|
+
? 2
|
|
43588
|
+
: 3;
|
|
43589
|
+
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
43590
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx("td", { role: "gridcell", "aria-colindex": indexCol, className: classNames$2(`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: {
|
|
43591
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43592
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined
|
|
43569
43593
|
}, onClick: (e) => {
|
|
43570
|
-
if (e.target.nodeName ===
|
|
43594
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
43571
43595
|
if (!editDisable && indexRow != indexFocus) {
|
|
43572
43596
|
setIndexFocus(indexRow);
|
|
43573
43597
|
focusNewElement(indexCol + 1, indexRow + 1, true);
|
|
@@ -43594,30 +43618,34 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43594
43618
|
}
|
|
43595
43619
|
e.stopPropagation();
|
|
43596
43620
|
}
|
|
43597
|
-
}, children: jsxRuntime.jsx("div", { className: classNames$2(
|
|
43598
|
-
textAlign: col.textAlign ? col.textAlign :
|
|
43599
|
-
}, children: [typeDis === 1 && !refreshRow && jsxRuntime.jsx(jsxRuntime.Fragment, { children: RenderEditCell(row, col, indexCol, indexRow) }), (typeDis !== 1 || refreshRow) && RenderContentCell(row, col, indexCol, indexRow, typeDis, value), jsxRuntime.jsx("span", { id: `error-${indexRow}-${indexCol}`, className: classNames$2(
|
|
43621
|
+
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-div"), children: jsxRuntime.jsxs("div", { id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "", className: classNames$2("r-rowcell-content", { "r-is-invalid": errorMessage }), style: {
|
|
43622
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43623
|
+
}, children: [typeDis === 1 && !refreshRow && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: RenderEditCell(row, col, indexCol, indexRow) })), (typeDis !== 1 || refreshRow) && RenderContentCell(row, col, indexCol, indexRow, typeDis, value), jsxRuntime.jsx("span", { id: `error-${indexRow}-${indexCol}`, className: classNames$2("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: jsxRuntime.jsx(SvgAlertCircle, { fontSize: 15.5 }) }), jsxRuntime.jsx(UncontrolledTooltip, { target: `error-${indexRow}-${indexCol}`, className: "r-tooltip tooltip-error", children: errorMessage?.toString() ?? "" })] }) }) }, `col-${indexRow}-${indexCol}`)) }, indexCol));
|
|
43600
43624
|
}
|
|
43601
43625
|
};
|
|
43602
43626
|
const RenderContentCell = (row, col, indexCol, indexRow, typeDis, value) => {
|
|
43603
43627
|
if (typeDis === 2) {
|
|
43604
|
-
const value = col.template?.(row, indexRow) ??
|
|
43605
|
-
if (typeof value ===
|
|
43606
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }),
|
|
43628
|
+
const value = col.template?.(row, indexRow) ?? "";
|
|
43629
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
43630
|
+
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) }))] }));
|
|
43607
43631
|
}
|
|
43608
43632
|
else {
|
|
43609
43633
|
return value;
|
|
43610
43634
|
}
|
|
43611
43635
|
}
|
|
43612
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children:
|
|
43636
|
+
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) }))] }));
|
|
43613
43637
|
};
|
|
43614
43638
|
const renderFooterCol = (col, indexCol) => {
|
|
43615
|
-
const sumValue =
|
|
43616
|
-
|
|
43617
|
-
|
|
43618
|
-
|
|
43619
|
-
|
|
43620
|
-
|
|
43639
|
+
const sumValue = col.haveSum === true && col.type === "numeric"
|
|
43640
|
+
? dataSource.reduce(function (accumulator, currentValue) {
|
|
43641
|
+
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
43642
|
+
}, 0)
|
|
43643
|
+
: 0;
|
|
43644
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx("td", { className: classNames$2(`p-0 px-50 r-footer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }), style: {
|
|
43645
|
+
left: col.fixedType === "left" ? objWidthFixLeft[indexCol] : undefined,
|
|
43646
|
+
right: col.fixedType === "right" ? objWidthFixRight[indexCol] : undefined,
|
|
43647
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
43648
|
+
}, 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}`));
|
|
43621
43649
|
};
|
|
43622
43650
|
/**
|
|
43623
43651
|
* 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
|
|
@@ -43625,7 +43653,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43625
43653
|
function checkRowMatch(row, filters, keyword, searchKeys) {
|
|
43626
43654
|
if ((!filters || filters.length === 0) && (!keyword || !searchClient))
|
|
43627
43655
|
return true; // Không có filter thì mặc định là match
|
|
43628
|
-
const isFilterMatch = filters.every(filter => {
|
|
43656
|
+
const isFilterMatch = filters.every((filter) => {
|
|
43629
43657
|
const { key, value, ope } = filter;
|
|
43630
43658
|
const rowValue = row[key];
|
|
43631
43659
|
if (rowValue === undefined || rowValue === null || value === undefined || value === null)
|
|
@@ -43633,32 +43661,33 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43633
43661
|
const valStr = String(rowValue).toLowerCase();
|
|
43634
43662
|
const filterStr = String(value).toLowerCase();
|
|
43635
43663
|
switch (ope) {
|
|
43636
|
-
case
|
|
43664
|
+
case "startswith":
|
|
43637
43665
|
return valStr.startsWith(filterStr);
|
|
43638
|
-
case
|
|
43666
|
+
case "endswith":
|
|
43639
43667
|
return valStr.endsWith(filterStr);
|
|
43640
|
-
case
|
|
43668
|
+
case "contains":
|
|
43641
43669
|
return valStr.includes(filterStr);
|
|
43642
|
-
case
|
|
43670
|
+
case "equal":
|
|
43643
43671
|
return rowValue == value;
|
|
43644
|
-
case
|
|
43672
|
+
case "notequal":
|
|
43645
43673
|
return rowValue != value;
|
|
43646
|
-
case
|
|
43674
|
+
case "greaterthan":
|
|
43647
43675
|
return rowValue > value;
|
|
43648
|
-
case
|
|
43676
|
+
case "greaterthanorequal":
|
|
43649
43677
|
return rowValue >= value;
|
|
43650
|
-
case
|
|
43678
|
+
case "lessthan":
|
|
43651
43679
|
return rowValue < value;
|
|
43652
|
-
case
|
|
43680
|
+
case "lessthanorequal":
|
|
43653
43681
|
return rowValue <= value;
|
|
43654
43682
|
default:
|
|
43655
43683
|
return false;
|
|
43656
43684
|
}
|
|
43657
43685
|
});
|
|
43658
|
-
const isSearchMatch = !keyword ||
|
|
43659
|
-
|
|
43660
|
-
|
|
43661
|
-
|
|
43686
|
+
const isSearchMatch = !keyword ||
|
|
43687
|
+
searchKeys.some((key) => {
|
|
43688
|
+
const val = row[key];
|
|
43689
|
+
return val?.toString().toLowerCase().includes(keyword.trim().toLowerCase());
|
|
43690
|
+
});
|
|
43662
43691
|
return isFilterMatch && isSearchMatch;
|
|
43663
43692
|
}
|
|
43664
43693
|
React$5.useEffect(() => {
|
|
@@ -43666,24 +43695,35 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43666
43695
|
pagingSetting?.setCurrentPage(1);
|
|
43667
43696
|
}
|
|
43668
43697
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
43669
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsxs("div", { className: "r-table-edit", children: [jsxRuntime.jsxs("div", { className:
|
|
43698
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsxs("div", { className: "r-table-edit", children: [jsxRuntime.jsxs("div", { className: "r-grid", ref: gridRef, children: [toolbarSetting?.showTopToolbar && jsxRuntime.jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), jsxRuntime.jsx("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: jsxRuntime.jsxs("table", { style: { width: "100%" }, role: "presentation", children: [jsxRuntime.jsx(RenderColGroup, { contentColumns: flatVisble }), jsxRuntime.jsx("thead", { className: "r-gridheader", role: "rowgroup", children: headerColumns.map((element, indexParent) => {
|
|
43670
43699
|
return (jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
43671
|
-
return (jsxRuntime.jsx(HeaderTableCol$1, { col: col, idTable: idTable ??
|
|
43700
|
+
return (jsxRuntime.jsx(HeaderTableCol$1, { col: col, idTable: idTable ?? "", dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false, objHeaderWidthFixLeft: objHeaderWidthFixLeft, objHeaderWidthFixRight: objHeaderWidthFixRight, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, container: tableElement, filterBy: filterBy, orderBy: orderBy, optionsFilter: optionsFilter, allowFilter: allowFilter, allowOrder: allowOrder, formatSetting: formatSetting, changeFilter: (val) => {
|
|
43672
43701
|
setFilterBy([...val]);
|
|
43673
43702
|
}, changeOrder: (val) => {
|
|
43674
43703
|
setOrderBy([...val]);
|
|
43675
|
-
}, columns: contentColumns, setColumns:
|
|
43704
|
+
}, columns: contentColumns, setColumns: (newColumns) => {
|
|
43705
|
+
newColumns.forEach((x) => {
|
|
43706
|
+
const column = columns.find((y) => y.field === x.field);
|
|
43707
|
+
if (column) {
|
|
43708
|
+
column.visible = x.visible;
|
|
43709
|
+
column.fixedType = x.fixedType;
|
|
43710
|
+
column.width = x.width;
|
|
43711
|
+
}
|
|
43712
|
+
});
|
|
43713
|
+
setRefreshColumns(!refreshColumns);
|
|
43714
|
+
}, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
|
|
43676
43715
|
}) }, `header-${-indexParent}`));
|
|
43677
|
-
}) }), jsxRuntime.jsx("tbody", { className:
|
|
43716
|
+
}) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: dataSource.map((row, indexRow) => {
|
|
43678
43717
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
43679
43718
|
const flagSearch = checkRowMatch(row, filterBy, searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, searchSetting?.keyField ?? []);
|
|
43680
43719
|
if (flagSearch) {
|
|
43681
|
-
const flagDisplay = !pagingClient ||
|
|
43682
|
-
|
|
43720
|
+
const flagDisplay = !pagingClient ||
|
|
43721
|
+
(indexRow + 1 > (pagingSetting.pageSize ?? 0) * ((pagingSetting.currentPage ?? 0) - 1) && indexRow + 1 <= (pagingSetting.pageSize ?? 0) * (pagingSetting.currentPage ?? 0));
|
|
43722
|
+
return (flagDisplay && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("tr", { "aria-rowindex": indexRow + 1, role: "row", className: classNames$2("r-row"), children: contentColumns.map((col, indexCol) => renderContentCol(col, row, indexRow, indexCol, isSelected)) }, `row-${indexRow}`) })));
|
|
43683
43723
|
}
|
|
43684
|
-
}) }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? jsxRuntime.jsx("tr", { className:
|
|
43685
|
-
return
|
|
43686
|
-
}) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsxRuntime.jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43724
|
+
}) }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? (jsxRuntime.jsx("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
43725
|
+
return renderFooterCol(col, index);
|
|
43726
|
+
}) })) : (jsxRuntime.jsx(jsxRuntime.Fragment, {})) })] }) }), toolbarSetting?.showBottomToolbar && (jsxRuntime.jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43687
43727
|
handleAdd(dataSource, tableElement.current, indexFirstEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement, numberOfRows);
|
|
43688
43728
|
}, handleDuplicate: () => {
|
|
43689
43729
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
@@ -43693,7 +43733,23 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43693
43733
|
handleInsertBefore(dataSource, indexFocus, defaultValue, changeDataSource, pagingClient, pagingSetting, toolbarSetting, buttonSetting, editDisable, addDisable);
|
|
43694
43734
|
}, handleDeleteAll: () => {
|
|
43695
43735
|
handleDeleteAll(t, messageBoxConfirmDelete, setIndexFocus, changeDataSource, editDisable, addDisable, toolbarSetting, buttonSetting);
|
|
43696
|
-
}, setOpenPopupSetupColumn: setOpenPopupSetupColumn, indexFocus: indexFocus, editDisable: editDisable, addDisable: addDisable, buttonSetting: buttonSetting, toolbarSetting: toolbarSetting, headerColumns: headerColumns, t: t })] }), pagingSetting?.allowPaging ? jsxRuntime.jsx(PagingComponent, { onChangePage: onChangePage, pageSize: pagingSetting?.pageSize ?? 0, currentPage: pagingSetting?.currentPage ?? 0, pageOptions: pagingSetting?.pageOptions ?? [20, 30, 50, 100], totalItem: pagingClient ? totalCount :
|
|
43736
|
+
}, setOpenPopupSetupColumn: setOpenPopupSetupColumn, indexFocus: indexFocus, editDisable: editDisable, addDisable: addDisable, buttonSetting: buttonSetting, toolbarSetting: toolbarSetting, headerColumns: headerColumns, t: t }))] }), pagingSetting?.allowPaging ? (jsxRuntime.jsx(PagingComponent, { onChangePage: onChangePage, pageSize: pagingSetting?.pageSize ?? 0, currentPage: pagingSetting?.currentPage ?? 0, pageOptions: pagingSetting?.pageOptions ?? [20, 30, 50, 100], totalItem: pagingClient ? totalCount : pagingSetting?.totalItem ?? 0, onChangePageSize: onChangePageSize })) : (jsxRuntime.jsx(jsxRuntime.Fragment, {}))] }), jsxRuntime.jsx(SidebarSetColumn, { handleSidebar: () => {
|
|
43737
|
+
setOpenPopupSetupColumn(!openPopupSetupColumn);
|
|
43738
|
+
}, openSidebar: openPopupSetupColumn, column: [...contentColumns], setColumn: (newColumns) => {
|
|
43739
|
+
if (saveSettingColumn) {
|
|
43740
|
+
console.log(newColumns);
|
|
43741
|
+
saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
|
|
43742
|
+
}
|
|
43743
|
+
newColumns.forEach((x) => {
|
|
43744
|
+
const column = columns.find((y) => y.field === x.field);
|
|
43745
|
+
if (column) {
|
|
43746
|
+
column.visible = x.visible;
|
|
43747
|
+
column.fixedType = x.fixedType;
|
|
43748
|
+
column.width = x.width;
|
|
43749
|
+
}
|
|
43750
|
+
});
|
|
43751
|
+
setRefreshColumns(!refreshColumns);
|
|
43752
|
+
} })] }));
|
|
43697
43753
|
});
|
|
43698
43754
|
|
|
43699
43755
|
const TabsMenuComponent = ({ buttonWidth, tabParent, tabChild, resourceCodeParent, resources, resourceCode, windowSize, renderModal }) => {
|
|
@@ -46168,6 +46224,20 @@ const CheckboxInput = (props) => {
|
|
|
46168
46224
|
}), children: [renderLabel({ isLabel, name, label: label ?? '' }), jsxRuntime.jsxs("div", { className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: [renderInput(), renderText()] })] }) }));
|
|
46169
46225
|
};
|
|
46170
46226
|
|
|
46227
|
+
const StyleInput = (props) => {
|
|
46228
|
+
const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
|
|
46229
|
+
const renderInput = () => {
|
|
46230
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
46231
|
+
return (jsxRuntime.jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
|
|
46232
|
+
} }), errors && jsxRuntime.jsx(FormFeedback$1, { children: errors?.message })] }));
|
|
46233
|
+
};
|
|
46234
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsxs("div", { className: classNames$2(' align', {
|
|
46235
|
+
[labelSize ? labelSize : '']: labelSize,
|
|
46236
|
+
[classes ? classes : '']: classes,
|
|
46237
|
+
'form-row-inline-error': errors
|
|
46238
|
+
}, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel({ isLabel, name, label, required }), jsxRuntime.jsx("div", { style: { height: `${height}px` }, className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
|
|
46239
|
+
};
|
|
46240
|
+
|
|
46171
46241
|
const defaultStyleExportSetting = {
|
|
46172
46242
|
title: {
|
|
46173
46243
|
color: '$black',
|
|
@@ -46246,38 +46316,24 @@ const defaultStyleExportSetting = {
|
|
|
46246
46316
|
}
|
|
46247
46317
|
};
|
|
46248
46318
|
|
|
46249
|
-
const StyleInput = (props) => {
|
|
46250
|
-
const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
|
|
46251
|
-
const renderInput = () => {
|
|
46252
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
46253
|
-
return (jsxRuntime.jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
|
|
46254
|
-
} }), errors && jsxRuntime.jsx(FormFeedback$1, { children: errors?.message })] }));
|
|
46255
|
-
};
|
|
46256
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsxs("div", { className: classNames$2(' align', {
|
|
46257
|
-
[labelSize ? labelSize : '']: labelSize,
|
|
46258
|
-
[classes ? classes : '']: classes,
|
|
46259
|
-
'form-row-inline-error': errors
|
|
46260
|
-
}, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel({ isLabel, name, label, required }), jsxRuntime.jsx("div", { style: { height: `${height}px` }, className: classNames$2('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
|
|
46261
|
-
};
|
|
46262
|
-
|
|
46263
46319
|
const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, dataItem, columns, columnGroups }) => {
|
|
46264
46320
|
const { t } = reactI18next.useTranslation();
|
|
46265
46321
|
const [dataSelected, setDataSelected] = React$5.useState([]);
|
|
46266
46322
|
const [selectedGroups, setSelectedGroups] = React$5.useState([]);
|
|
46267
46323
|
const { control, reset, handleSubmit, clearErrors, getValues, setValue } = useForm({
|
|
46268
|
-
mode:
|
|
46324
|
+
mode: "onChange",
|
|
46269
46325
|
defaultValues: defaultStyleExportSetting
|
|
46270
46326
|
});
|
|
46271
46327
|
const handleCancel = () => {
|
|
46272
|
-
handleModal(
|
|
46328
|
+
handleModal("ExportExcelComponent");
|
|
46273
46329
|
clearErrors();
|
|
46274
46330
|
setDataSelected([]);
|
|
46275
46331
|
reset();
|
|
46276
46332
|
setSelectedGroups([]);
|
|
46277
46333
|
};
|
|
46278
46334
|
React$5.useEffect(() => {
|
|
46279
|
-
if (openModal && typeModal ===
|
|
46280
|
-
setValue(
|
|
46335
|
+
if (openModal && typeModal === "ExportExcel") {
|
|
46336
|
+
setValue("textTitle", dataItem.title);
|
|
46281
46337
|
}
|
|
46282
46338
|
}, [openModal]);
|
|
46283
46339
|
const handleToggleGroup = (groupName) => {
|
|
@@ -46302,9 +46358,10 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46302
46358
|
submit(data);
|
|
46303
46359
|
};
|
|
46304
46360
|
const submit = (data) => {
|
|
46305
|
-
dataItem
|
|
46361
|
+
dataItem
|
|
46362
|
+
.ExportExcelApi({
|
|
46306
46363
|
id: dataItem.id,
|
|
46307
|
-
columns: dataSelected.map(item => ({ ...item, headerText: t(item.headerText) })),
|
|
46364
|
+
columns: dataSelected.map((item) => ({ ...item, headerText: t(item.headerText) })),
|
|
46308
46365
|
countRowHeader: dataItem.countRowHeader,
|
|
46309
46366
|
groupby: dataItem.groupby,
|
|
46310
46367
|
fieldSums: dataItem.fieldSums,
|
|
@@ -46312,55 +46369,57 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46312
46369
|
order: dataItem.order,
|
|
46313
46370
|
organizationId: dataItem.organizationId,
|
|
46314
46371
|
style: data,
|
|
46315
|
-
title: getValues(
|
|
46316
|
-
subtitle: getValues(
|
|
46317
|
-
})
|
|
46372
|
+
title: getValues("textTitle"),
|
|
46373
|
+
subtitle: getValues("textSubtitle")
|
|
46374
|
+
})
|
|
46375
|
+
.unwrap()
|
|
46318
46376
|
.then((rs) => {
|
|
46319
46377
|
const url = window.URL.createObjectURL(new Blob([rs]));
|
|
46320
|
-
const link = document.createElement(
|
|
46378
|
+
const link = document.createElement("a");
|
|
46321
46379
|
link.href = url;
|
|
46322
|
-
link.setAttribute(
|
|
46380
|
+
link.setAttribute("download", `${dataItem.title}.xlsx`);
|
|
46323
46381
|
document.body.appendChild(link);
|
|
46324
46382
|
link.click();
|
|
46325
46383
|
handleModal();
|
|
46326
|
-
})
|
|
46384
|
+
})
|
|
46385
|
+
.catch(() => notificationError("Fail"));
|
|
46327
46386
|
};
|
|
46328
46387
|
const renderFooterButtons = () => {
|
|
46329
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", className: "me-1", onClick: handleSubmit(onSubmit), children: t(
|
|
46388
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", className: "me-1", onClick: handleSubmit(onSubmit), children: t("Export") }), jsxRuntime.jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, className: "me-1", children: t("Close") })] }));
|
|
46330
46389
|
};
|
|
46331
46390
|
const rightToolbarTemplate = () => {
|
|
46332
|
-
return (jsxRuntime.jsx("div", { className:
|
|
46391
|
+
return (jsxRuntime.jsx("div", { className: "d-flex", children: columnGroups?.map((ele, idx) => (jsxRuntime.jsx("div", { style: { width: ele.width ?? 150 }, children: jsxRuntime.jsx(CheckboxInput, { control: control, name: `group_${ele.label}`, label: t(ele.label), reverse: true, labelSize: "align-items-center", checked: selectedGroups.includes(ele.label), callback: () => handleToggleGroup(ele.label) }) }, idx))) }));
|
|
46333
46392
|
};
|
|
46334
46393
|
const toolbarTopOptions = [
|
|
46335
46394
|
{
|
|
46336
46395
|
template: rightToolbarTemplate,
|
|
46337
|
-
align:
|
|
46396
|
+
align: "left"
|
|
46338
46397
|
}
|
|
46339
46398
|
];
|
|
46340
|
-
return (jsxRuntime.jsxs(Sidebar, { open: openModal && typeModal ===
|
|
46399
|
+
return (jsxRuntime.jsxs(Sidebar, { open: openModal && typeModal === "ExportExcel", toggleSidebar: handleCancel, width: 900, children: [jsxRuntime.jsx(ModalHeader, { typeModal: typeModal, handleModal: () => handleCancel(), title: t("Export Excel Setting") }), jsxRuntime.jsx(lib.Scrollbars, { autoHeight: true, autoHeightMax: windowSize.innerHeight - 120, autoHeightMin: windowSize.innerHeight - 120, children: jsxRuntime.jsxs(ModalBody$1, { children: [jsxRuntime.jsxs("div", { className: "box form-box__border mb-2", children: [jsxRuntime.jsx("h5", { className: "m-0 form-box__border--title", children: t("Tùy chỉnh cột") }), jsxRuntime.jsx(Row$1, { className: "gy-1", children: jsxRuntime.jsx(Col$1, { lg: 12, md: 12, xs: 12, children: jsxRuntime.jsx(TableEdit, { dataSource: getCombinedColumns(), toolbarSetting: {
|
|
46341
46400
|
showTopToolbar: true,
|
|
46342
46401
|
showBottomToolbar: true,
|
|
46343
46402
|
toolbarBottomOptions: toolbarTopOptions
|
|
46344
46403
|
}, maxHeight: windowSize.innerHeight - 525, minHeight: 150, columns: [
|
|
46345
46404
|
{
|
|
46346
|
-
field:
|
|
46347
|
-
headerText:
|
|
46348
|
-
textAlign:
|
|
46349
|
-
invisibleDisable: true,
|
|
46405
|
+
field: "checkbox",
|
|
46406
|
+
headerText: "",
|
|
46407
|
+
textAlign: "center",
|
|
46350
46408
|
width: 20
|
|
46351
46409
|
},
|
|
46352
46410
|
{
|
|
46353
|
-
field:
|
|
46354
|
-
|
|
46355
|
-
headerText: '',
|
|
46411
|
+
field: "field",
|
|
46412
|
+
headerText: "",
|
|
46356
46413
|
visible: false,
|
|
46357
46414
|
isPrimarykey: true
|
|
46358
46415
|
},
|
|
46359
46416
|
{
|
|
46360
|
-
type:
|
|
46417
|
+
type: "text",
|
|
46361
46418
|
field: "headerText",
|
|
46362
|
-
headerText:
|
|
46363
|
-
template: (value) => {
|
|
46419
|
+
headerText: "Column name",
|
|
46420
|
+
template: (value) => {
|
|
46421
|
+
return t(value.headerText);
|
|
46422
|
+
},
|
|
46364
46423
|
width: 360,
|
|
46365
46424
|
minWidth: 320,
|
|
46366
46425
|
maxWidth: 400
|
|
@@ -46368,7 +46427,7 @@ const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, d
|
|
|
46368
46427
|
], isMulti: true, searchSetting: {
|
|
46369
46428
|
searchEnable: true,
|
|
46370
46429
|
searchClient: true
|
|
46371
|
-
}, selectedItem: dataSelected, setSelectedItem: setDataSelected, selectEnable: true, addDisable: true, editDisable: true },
|
|
46430
|
+
}, selectedItem: dataSelected, setSelectedItem: setDataSelected, selectEnable: true, addDisable: true, editDisable: true }, "TableFile") }) })] }), jsxRuntime.jsxs("div", { className: "box form-box__border", children: [jsxRuntime.jsx("h5", { className: "m-0 form-box__border--title", children: t("Title report") }), jsxRuntime.jsxs(Row$1, { className: "gy-1", children: [jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(TextInput, { control: control, name: "textTitle", label: t("Title report"), labelSize: "label-small", placeholder: t("Đặt tên cho tiêu đề báo cáo"), inLine: true }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(TextInput, { control: control, name: "textSubtitle", label: t("Subtitle"), labelSize: "label-small", placeholder: t("Đặt tên cho tiêu đề phụ"), inLine: true }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(StyleInput, { control: control, name: "title", disabledBackgroundColor: true, label: "Title report", labelSize: "label-small" }) }), jsxRuntime.jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsxRuntime.jsx(NumberInput, { control: control, name: "title.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(StyleInput, { control: control, name: "subtitle", disabledBackgroundColor: true, label: "Subtitle", labelSize: "label-small" }) }), jsxRuntime.jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsxRuntime.jsx(NumberInput, { control: control, name: "subtitle.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(StyleInput, { control: control, name: "header", label: "Title table", labelSize: "label-small" }) }), jsxRuntime.jsx(Col$1, { lg: 4, md: 6, xs: 6, children: jsxRuntime.jsx(NumberInput, { control: control, name: "header.row", label: "Row", labelSize: "label-small", min: 0 }) }), jsxRuntime.jsx(Col$1, { lg: 8, md: 12, xs: 12, children: jsxRuntime.jsx(StyleInput, { control: control, name: "content", label: "Content table", labelSize: "label-small" }) })] })] })] }) }), jsxRuntime.jsx("div", { className: "d-flex justify-content-end p-1", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: renderFooterButtons() })] }));
|
|
46372
46431
|
};
|
|
46373
46432
|
|
|
46374
46433
|
const TabValidateImportExcel = (props) => {
|