react-table-edit 1.2.1 → 1.2.2
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/index.js +198 -193
- package/dist/index.mjs +198 -193
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3413,7 +3413,6 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3413
3413
|
const focusNewElement = (col, row, onLoad = false) => {
|
|
3414
3414
|
setTimeout(() => {
|
|
3415
3415
|
const element = document.getElementById(`${idTable}-col${col}-row${row}`);
|
|
3416
|
-
console.log(element);
|
|
3417
3416
|
if (element) {
|
|
3418
3417
|
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
3419
3418
|
element.getElementsByTagName("input")[0]?.focus();
|
|
@@ -3796,92 +3795,163 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3796
3795
|
}
|
|
3797
3796
|
}
|
|
3798
3797
|
}, [selectedItem]);
|
|
3799
|
-
const
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
`col-${indexRow}-${indexCol}`
|
|
3816
|
-
) }) : col.field === "#" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3817
|
-
"td",
|
|
3818
|
-
{
|
|
3819
|
-
className: (0, import_classnames14.default)(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
|
|
3820
|
-
tabIndex: Number(`${indexRow}${indexCol}`),
|
|
3821
|
-
style: {
|
|
3822
|
-
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3823
|
-
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3824
|
-
textAlign: "center"
|
|
3825
|
-
},
|
|
3826
|
-
onCopy: (e) => {
|
|
3827
|
-
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
3828
|
-
navigator.clipboard.writeText(JSON.stringify(row));
|
|
3829
|
-
notificationSuccess(t("CopySuccessful"));
|
|
3830
|
-
e.stopPropagation();
|
|
3831
|
-
}
|
|
3798
|
+
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
3799
|
+
if (col.field === "command") {
|
|
3800
|
+
return col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3801
|
+
"td",
|
|
3802
|
+
{
|
|
3803
|
+
className: (0, import_classnames14.default)(
|
|
3804
|
+
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
3805
|
+
{ "cell-fixed": col.fixedType },
|
|
3806
|
+
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
3807
|
+
),
|
|
3808
|
+
style: {
|
|
3809
|
+
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3810
|
+
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3811
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
3812
|
+
},
|
|
3813
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-rowcell-div command", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(command_default, { commandItems: col.commandItems ?? [], handleCommandClick, indexRow, rowData: row, setIndexFocus, indexFocus }) })
|
|
3832
3814
|
},
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3815
|
+
`col-${indexRow}-${indexCol}`
|
|
3816
|
+
);
|
|
3817
|
+
} else if (col.field === "#") {
|
|
3818
|
+
return col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3819
|
+
"td",
|
|
3820
|
+
{
|
|
3821
|
+
className: (0, import_classnames14.default)(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
|
|
3822
|
+
tabIndex: Number(`${indexRow}${indexCol}`),
|
|
3823
|
+
style: {
|
|
3824
|
+
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3825
|
+
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3826
|
+
textAlign: "center"
|
|
3827
|
+
},
|
|
3828
|
+
onCopy: (e) => {
|
|
3829
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
3830
|
+
navigator.clipboard.writeText(JSON.stringify(row));
|
|
3831
|
+
notificationSuccess(t("CopySuccessful"));
|
|
3832
|
+
e.stopPropagation();
|
|
3833
|
+
}
|
|
3834
|
+
},
|
|
3835
|
+
onPaste: (e) => {
|
|
3836
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
3837
|
+
navigator.clipboard.readText().then((rs) => {
|
|
3838
|
+
dataSource[indexRow] = JSON.parse(rs);
|
|
3839
|
+
if (fieldKey) {
|
|
3840
|
+
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
3841
|
+
}
|
|
3842
|
+
changeDataSource(dataSource);
|
|
3843
|
+
notificationSuccess(t("PasteSuccessful"));
|
|
3844
|
+
}).catch((ex) => {
|
|
3845
|
+
alert(ex);
|
|
3846
|
+
});
|
|
3847
|
+
e.stopPropagation();
|
|
3848
|
+
}
|
|
3849
|
+
},
|
|
3850
|
+
onClick: (e) => {
|
|
3851
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
3852
|
+
if (!editDisable && indexRow != indexFocus) {
|
|
3853
|
+
setIndexFocus(indexRow);
|
|
3839
3854
|
}
|
|
3840
|
-
|
|
3841
|
-
notificationSuccess(t("PasteSuccessful"));
|
|
3842
|
-
}).catch((ex) => {
|
|
3843
|
-
alert(ex);
|
|
3844
|
-
});
|
|
3845
|
-
e.stopPropagation();
|
|
3846
|
-
}
|
|
3847
|
-
},
|
|
3848
|
-
onClick: (e) => {
|
|
3849
|
-
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
3850
|
-
if (!editDisable && indexRow != indexFocus) {
|
|
3851
|
-
setIndexFocus(indexRow);
|
|
3855
|
+
e.stopPropagation();
|
|
3852
3856
|
}
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
}
|
|
3857
|
+
},
|
|
3858
|
+
onKeyDown: (e) => {
|
|
3859
|
+
if (e.code === "KeyD" && e.ctrlKey == true && (!editDisable && !addDisable) && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
3860
|
+
handleDuplicate(row, indexRow);
|
|
3861
|
+
e.preventDefault();
|
|
3862
|
+
e.stopPropagation();
|
|
3863
|
+
}
|
|
3864
|
+
},
|
|
3865
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-rowcell-div", children: indexRow + 1 })
|
|
3862
3866
|
},
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3867
|
+
`col-${indexRow}-${indexCol}`
|
|
3868
|
+
);
|
|
3869
|
+
} else if (col.field === "checkbox") {
|
|
3870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3871
|
+
"td",
|
|
3872
|
+
{
|
|
3873
|
+
className: (0, import_classnames14.default)(
|
|
3874
|
+
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
3875
|
+
{ "cell-fixed": col.fixedType },
|
|
3876
|
+
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
3877
|
+
),
|
|
3878
|
+
style: {
|
|
3879
|
+
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3880
|
+
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3881
|
+
textAlign: col.textAlign ? col.textAlign : "center"
|
|
3882
|
+
},
|
|
3883
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3884
|
+
"div",
|
|
3885
|
+
{
|
|
3886
|
+
className: "r-rowcell-div cursor-pointer",
|
|
3887
|
+
onClick: (e) => {
|
|
3888
|
+
if (selectEnable) {
|
|
3889
|
+
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
3890
|
+
if (index > -1) {
|
|
3891
|
+
if (isMulti) {
|
|
3892
|
+
selectedRows?.splice(index, 1);
|
|
3893
|
+
setSelectedRows([...selectedRows]);
|
|
3894
|
+
} else {
|
|
3895
|
+
setSelectedRows([]);
|
|
3896
|
+
}
|
|
3897
|
+
} else {
|
|
3898
|
+
if (isMulti) {
|
|
3899
|
+
setSelectedRows([...selectedRows, row]);
|
|
3900
|
+
} else {
|
|
3901
|
+
setSelectedRows([row]);
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
e.stopPropagation();
|
|
3905
|
+
}
|
|
3906
|
+
},
|
|
3907
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3908
|
+
import_reactstrap11.Input,
|
|
3909
|
+
{
|
|
3910
|
+
checked: isSelected,
|
|
3911
|
+
type: "checkbox",
|
|
3912
|
+
className: "cursor-pointer",
|
|
3913
|
+
onChange: () => {
|
|
3914
|
+
},
|
|
3915
|
+
style: { textAlign: col.textAlign ?? "center", marginTop: 6 }
|
|
3916
|
+
}
|
|
3917
|
+
)
|
|
3918
|
+
}
|
|
3919
|
+
)
|
|
3878
3920
|
},
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3921
|
+
`col-${indexRow}-${indexCol}`
|
|
3922
|
+
);
|
|
3923
|
+
} else {
|
|
3924
|
+
let value = row[col.field];
|
|
3925
|
+
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
3926
|
+
value = formartNumberic(row[col.field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) ?? 0;
|
|
3927
|
+
} else if (col.editType === "date") {
|
|
3928
|
+
value = value ? (0, import_moment3.default)(value).format("DD/MM/yyyy") : "";
|
|
3929
|
+
} else if (col.editType === "datetime") {
|
|
3930
|
+
value = value ? (0, import_moment3.default)(value).format("DD/MM/yyyy HH:mm") : "";
|
|
3931
|
+
}
|
|
3932
|
+
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
3933
|
+
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
3934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3935
|
+
"td",
|
|
3936
|
+
{
|
|
3937
|
+
className: (0, import_classnames14.default)(
|
|
3938
|
+
`r-rowcell fix-${col.fixedType}`,
|
|
3939
|
+
{ "cell-fixed": col.fixedType },
|
|
3940
|
+
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
3941
|
+
),
|
|
3942
|
+
style: {
|
|
3943
|
+
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3944
|
+
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3945
|
+
padding: 0,
|
|
3946
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
3947
|
+
},
|
|
3948
|
+
onClick: (e) => {
|
|
3949
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
3950
|
+
if (!editDisable && indexRow != indexFocus) {
|
|
3951
|
+
setIndexFocus(indexRow);
|
|
3952
|
+
focusNewElement(indexCol + 1, indexRow + 1, true);
|
|
3953
|
+
}
|
|
3954
|
+
if (selectEnable && editDisable) {
|
|
3885
3955
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
3886
3956
|
if (index > -1) {
|
|
3887
3957
|
if (isMulti) {
|
|
@@ -3897,116 +3967,51 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
3897
3967
|
setSelectedRows([row]);
|
|
3898
3968
|
}
|
|
3899
3969
|
}
|
|
3900
|
-
e.stopPropagation();
|
|
3901
3970
|
}
|
|
3902
|
-
|
|
3903
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3904
|
-
import_reactstrap11.Input,
|
|
3905
|
-
{
|
|
3906
|
-
checked: isSelected,
|
|
3907
|
-
type: "checkbox",
|
|
3908
|
-
className: "cursor-pointer",
|
|
3909
|
-
onChange: () => {
|
|
3910
|
-
},
|
|
3911
|
-
style: { textAlign: col.textAlign ?? "center", marginTop: 6 }
|
|
3912
|
-
}
|
|
3913
|
-
)
|
|
3914
|
-
}
|
|
3915
|
-
)
|
|
3916
|
-
},
|
|
3917
|
-
`col-${indexRow}-${indexCol}`
|
|
3918
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ContenComponent, { col, indexCol, indexRow, isSelected, row }) });
|
|
3919
|
-
};
|
|
3920
|
-
const ContenComponent = ({ col, indexCol, indexRow, isSelected, row }) => {
|
|
3921
|
-
let value = row[col.field];
|
|
3922
|
-
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
3923
|
-
value = formartNumberic(row[col.field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) ?? 0;
|
|
3924
|
-
} else if (col.editType === "date") {
|
|
3925
|
-
value = value ? (0, import_moment3.default)(value).format("DD/MM/yyyy") : "";
|
|
3926
|
-
} else if (col.editType === "datetime") {
|
|
3927
|
-
value = value ? (0, import_moment3.default)(value).format("DD/MM/yyyy HH:mm") : "";
|
|
3928
|
-
}
|
|
3929
|
-
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
3930
|
-
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
3931
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3932
|
-
"td",
|
|
3933
|
-
{
|
|
3934
|
-
className: (0, import_classnames14.default)(
|
|
3935
|
-
`r-rowcell fix-${col.fixedType}`,
|
|
3936
|
-
{ "cell-fixed": col.fixedType },
|
|
3937
|
-
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
3938
|
-
),
|
|
3939
|
-
style: {
|
|
3940
|
-
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3941
|
-
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3942
|
-
padding: 0,
|
|
3943
|
-
textAlign: col.textAlign ? col.textAlign : "left"
|
|
3944
|
-
},
|
|
3945
|
-
onClick: (e) => {
|
|
3946
|
-
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
3947
|
-
if (!editDisable && indexRow != indexFocus) {
|
|
3948
|
-
setIndexFocus(indexRow);
|
|
3949
|
-
focusNewElement(indexCol + 1, indexRow + 1, true);
|
|
3971
|
+
e.stopPropagation();
|
|
3950
3972
|
}
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3973
|
+
},
|
|
3974
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3975
|
+
"div",
|
|
3976
|
+
{
|
|
3977
|
+
className: (0, import_classnames14.default)("r-rowcell-div"),
|
|
3978
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3979
|
+
"div",
|
|
3980
|
+
{
|
|
3981
|
+
id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
|
|
3982
|
+
className: (0, import_classnames14.default)("r-rowcell-content", { "r-is-invalid": errorMessage }),
|
|
3983
|
+
style: {
|
|
3984
|
+
margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2,
|
|
3985
|
+
color: col.editType === "numeric" && Number(row[col.field]) < 0 ? "red" : ""
|
|
3986
|
+
},
|
|
3987
|
+
children: [
|
|
3988
|
+
typeDis === 1 && !refreshRow ? RenderEdit(row, col, indexCol, indexRow) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3989
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { id: `error-${indexRow}-${indexCol}`, className: (0, import_classnames14.default)("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_becoxy_icons7.AlertCircle, { fontSize: 15.5 }) }),
|
|
3990
|
+
!(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_reactstrap11.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3991
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3992
|
+
import_reactstrap11.UncontrolledTooltip,
|
|
3993
|
+
{
|
|
3994
|
+
target: `error-${indexRow}-${indexCol}`,
|
|
3995
|
+
className: "r-tooltip tooltip-error",
|
|
3996
|
+
children: errorMessage?.toString() ?? ""
|
|
3997
|
+
}
|
|
3998
|
+
)
|
|
3999
|
+
]
|
|
3965
4000
|
}
|
|
3966
|
-
|
|
4001
|
+
)
|
|
3967
4002
|
}
|
|
3968
|
-
|
|
4003
|
+
)
|
|
3969
4004
|
},
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
className: (0, import_classnames14.default)("r-rowcell-div"),
|
|
3974
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3975
|
-
"div",
|
|
3976
|
-
{
|
|
3977
|
-
id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
|
|
3978
|
-
className: (0, import_classnames14.default)("r-rowcell-content", { "r-is-invalid": errorMessage }),
|
|
3979
|
-
style: {
|
|
3980
|
-
margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2,
|
|
3981
|
-
color: col.editType === "numeric" && Number(row[col.field]) < 0 ? "red" : ""
|
|
3982
|
-
},
|
|
3983
|
-
children: [
|
|
3984
|
-
typeDis === 1 && !refreshRow ? RenderEdit(row, col, indexCol, indexRow) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3985
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { id: `error-${indexRow}-${indexCol}`, className: (0, import_classnames14.default)("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_becoxy_icons7.AlertCircle, { fontSize: 15.5 }) }),
|
|
3986
|
-
!(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_reactstrap11.UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3987
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3988
|
-
import_reactstrap11.UncontrolledTooltip,
|
|
3989
|
-
{
|
|
3990
|
-
target: `error-${indexRow}-${indexCol}`,
|
|
3991
|
-
className: "r-tooltip tooltip-error",
|
|
3992
|
-
children: errorMessage?.toString() ?? ""
|
|
3993
|
-
}
|
|
3994
|
-
)
|
|
3995
|
-
]
|
|
3996
|
-
}
|
|
3997
|
-
)
|
|
3998
|
-
}
|
|
3999
|
-
)
|
|
4000
|
-
},
|
|
4001
|
-
`col-${indexRow}-${indexCol}`
|
|
4002
|
-
) }, indexCol);
|
|
4005
|
+
`col-${indexRow}-${indexCol}`
|
|
4006
|
+
) }, indexCol);
|
|
4007
|
+
}
|
|
4003
4008
|
};
|
|
4004
4009
|
const checkOverflow = (indexRow, indexCol) => {
|
|
4005
4010
|
const element = document.getElementById(`content-${idTable}-row${indexRow}col-${indexCol}`);
|
|
4006
4011
|
return element && element.scrollWidth > element.clientWidth;
|
|
4007
4012
|
};
|
|
4008
|
-
const
|
|
4009
|
-
return col.visible !== false
|
|
4013
|
+
const renderFooterCol = (col, indexCol) => {
|
|
4014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4010
4015
|
"td",
|
|
4011
4016
|
{
|
|
4012
4017
|
className: (0, import_classnames14.default)(
|
|
@@ -4022,9 +4027,9 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
4022
4027
|
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
4023
4028
|
}, 0), decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) : "" })
|
|
4024
4029
|
}
|
|
4025
|
-
)
|
|
4030
|
+
) }, `summarycell-${indexCol}`);
|
|
4026
4031
|
};
|
|
4027
|
-
const
|
|
4032
|
+
const renderToolbarTop = () => {
|
|
4028
4033
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id: "table_custom_top_toolbar", className: "r-toolbar r-toolbar-top", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "r-toolbar-items", children: [
|
|
4029
4034
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-toolbar-left", children: toolbarTopOption?.map((item, index) => {
|
|
4030
4035
|
return item.align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-left-${index}`) : "";
|
|
@@ -4037,7 +4042,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
4037
4042
|
}) })
|
|
4038
4043
|
] }) });
|
|
4039
4044
|
};
|
|
4040
|
-
const
|
|
4045
|
+
const renderToolbarBottom = () => {
|
|
4041
4046
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id: "table_custom_bottom_toolbar", className: "r-toolbar r-toolbar-bottom", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "r-toolbar-items", children: [
|
|
4042
4047
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "r-toolbar-left", children: [
|
|
4043
4048
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: (0, import_classnames14.default)("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_reactstrap11.Button, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
|
|
@@ -4091,10 +4096,10 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
4091
4096
|
}
|
|
4092
4097
|
return false;
|
|
4093
4098
|
};
|
|
4094
|
-
const
|
|
4099
|
+
const renderData = () => {
|
|
4095
4100
|
totalCount = 0;
|
|
4096
4101
|
let countDisplay = -1;
|
|
4097
|
-
return
|
|
4102
|
+
return dataSource.map((row, indexRow) => {
|
|
4098
4103
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
4099
4104
|
const flagSearch = !searchClient || checkSearch(searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm, row, searchSetting?.keyField ?? []);
|
|
4100
4105
|
if (flagSearch) {
|
|
@@ -4107,14 +4112,14 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
4107
4112
|
{
|
|
4108
4113
|
className: (0, import_classnames14.default)("r-row", { "fisrt-row": countDisplay === 0 }),
|
|
4109
4114
|
children: contentColumns.map((col, indexCol) => {
|
|
4110
|
-
return
|
|
4115
|
+
return renderContentCol(col, row, indexRow, indexCol, isSelected);
|
|
4111
4116
|
})
|
|
4112
4117
|
},
|
|
4113
4118
|
`row-${indexRow}`
|
|
4114
4119
|
);
|
|
4115
4120
|
}
|
|
4116
4121
|
}
|
|
4117
|
-
})
|
|
4122
|
+
});
|
|
4118
4123
|
};
|
|
4119
4124
|
(0, import_react16.useEffect)(() => {
|
|
4120
4125
|
if (pagingClient && pagingSetting?.setCurrentPage && (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm)) {
|
|
@@ -4124,7 +4129,7 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
4124
4129
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react16.Fragment, { children: [
|
|
4125
4130
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "react-table-edit", children: [
|
|
4126
4131
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "r-grid", ref: gridRef, children: [
|
|
4127
|
-
toolbarSetting?.showTopToolbar ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4132
|
+
toolbarSetting?.showTopToolbar ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: renderToolbarTop() }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, {}),
|
|
4128
4133
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("table", { style: { width: "100%" }, children: [
|
|
4129
4134
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("thead", { className: "r-gridheader", children: headerColumns.map((element, indexParent) => {
|
|
4130
4135
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
@@ -4148,12 +4153,12 @@ var TableEdit = (0, import_react16.forwardRef)((props, ref) => {
|
|
|
4148
4153
|
);
|
|
4149
4154
|
}) }, `header-${-indexParent}`);
|
|
4150
4155
|
}) }),
|
|
4151
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tbody", { className: "r-gridcontent", children:
|
|
4156
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tbody", { className: "r-gridcontent", children: renderData() }),
|
|
4152
4157
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tfoot", { className: "r-gridfoot", children: haveSum == true ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
4153
|
-
return
|
|
4158
|
+
return renderFooterCol(col, index);
|
|
4154
4159
|
}) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, {}) })
|
|
4155
4160
|
] }) }),
|
|
4156
|
-
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4161
|
+
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: renderToolbarBottom() }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, {})
|
|
4157
4162
|
] }),
|
|
4158
4163
|
pagingSetting?.allowPaging ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4159
4164
|
PagingComponent,
|
package/dist/index.mjs
CHANGED
|
@@ -3382,7 +3382,6 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3382
3382
|
const focusNewElement = (col, row, onLoad = false) => {
|
|
3383
3383
|
setTimeout(() => {
|
|
3384
3384
|
const element = document.getElementById(`${idTable}-col${col}-row${row}`);
|
|
3385
|
-
console.log(element);
|
|
3386
3385
|
if (element) {
|
|
3387
3386
|
if (element.className.includes("react-select") || element.className.includes("form-edit")) {
|
|
3388
3387
|
element.getElementsByTagName("input")[0]?.focus();
|
|
@@ -3765,92 +3764,163 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3765
3764
|
}
|
|
3766
3765
|
}
|
|
3767
3766
|
}, [selectedItem]);
|
|
3768
|
-
const
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
`col-${indexRow}-${indexCol}`
|
|
3785
|
-
) }) : col.field === "#" ? /* @__PURE__ */ jsx16(
|
|
3786
|
-
"td",
|
|
3787
|
-
{
|
|
3788
|
-
className: classnames9(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
|
|
3789
|
-
tabIndex: Number(`${indexRow}${indexCol}`),
|
|
3790
|
-
style: {
|
|
3791
|
-
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3792
|
-
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3793
|
-
textAlign: "center"
|
|
3794
|
-
},
|
|
3795
|
-
onCopy: (e) => {
|
|
3796
|
-
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
3797
|
-
navigator.clipboard.writeText(JSON.stringify(row));
|
|
3798
|
-
notificationSuccess(t("CopySuccessful"));
|
|
3799
|
-
e.stopPropagation();
|
|
3800
|
-
}
|
|
3767
|
+
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
3768
|
+
if (col.field === "command") {
|
|
3769
|
+
return col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3770
|
+
"td",
|
|
3771
|
+
{
|
|
3772
|
+
className: classnames9(
|
|
3773
|
+
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
3774
|
+
{ "cell-fixed": col.fixedType },
|
|
3775
|
+
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
3776
|
+
),
|
|
3777
|
+
style: {
|
|
3778
|
+
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3779
|
+
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3780
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
3781
|
+
},
|
|
3782
|
+
children: /* @__PURE__ */ jsx16("div", { className: "r-rowcell-div command", children: /* @__PURE__ */ jsx16(command_default, { commandItems: col.commandItems ?? [], handleCommandClick, indexRow, rowData: row, setIndexFocus, indexFocus }) })
|
|
3801
3783
|
},
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3784
|
+
`col-${indexRow}-${indexCol}`
|
|
3785
|
+
);
|
|
3786
|
+
} else if (col.field === "#") {
|
|
3787
|
+
return col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3788
|
+
"td",
|
|
3789
|
+
{
|
|
3790
|
+
className: classnames9(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
|
|
3791
|
+
tabIndex: Number(`${indexRow}${indexCol}`),
|
|
3792
|
+
style: {
|
|
3793
|
+
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3794
|
+
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3795
|
+
textAlign: "center"
|
|
3796
|
+
},
|
|
3797
|
+
onCopy: (e) => {
|
|
3798
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
3799
|
+
navigator.clipboard.writeText(JSON.stringify(row));
|
|
3800
|
+
notificationSuccess(t("CopySuccessful"));
|
|
3801
|
+
e.stopPropagation();
|
|
3802
|
+
}
|
|
3803
|
+
},
|
|
3804
|
+
onPaste: (e) => {
|
|
3805
|
+
if (!editDisable && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
3806
|
+
navigator.clipboard.readText().then((rs) => {
|
|
3807
|
+
dataSource[indexRow] = JSON.parse(rs);
|
|
3808
|
+
if (fieldKey) {
|
|
3809
|
+
dataSource[indexRow][fieldKey] = defaultValue[fieldKey];
|
|
3810
|
+
}
|
|
3811
|
+
changeDataSource(dataSource);
|
|
3812
|
+
notificationSuccess(t("PasteSuccessful"));
|
|
3813
|
+
}).catch((ex) => {
|
|
3814
|
+
alert(ex);
|
|
3815
|
+
});
|
|
3816
|
+
e.stopPropagation();
|
|
3817
|
+
}
|
|
3818
|
+
},
|
|
3819
|
+
onClick: (e) => {
|
|
3820
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
3821
|
+
if (!editDisable && indexRow != indexFocus) {
|
|
3822
|
+
setIndexFocus(indexRow);
|
|
3808
3823
|
}
|
|
3809
|
-
|
|
3810
|
-
notificationSuccess(t("PasteSuccessful"));
|
|
3811
|
-
}).catch((ex) => {
|
|
3812
|
-
alert(ex);
|
|
3813
|
-
});
|
|
3814
|
-
e.stopPropagation();
|
|
3815
|
-
}
|
|
3816
|
-
},
|
|
3817
|
-
onClick: (e) => {
|
|
3818
|
-
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
3819
|
-
if (!editDisable && indexRow != indexFocus) {
|
|
3820
|
-
setIndexFocus(indexRow);
|
|
3824
|
+
e.stopPropagation();
|
|
3821
3825
|
}
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
}
|
|
3826
|
+
},
|
|
3827
|
+
onKeyDown: (e) => {
|
|
3828
|
+
if (e.code === "KeyD" && e.ctrlKey == true && (!editDisable && !addDisable) && (e.target.nodeName === "DIV" || e.target.nodeName === "TD")) {
|
|
3829
|
+
handleDuplicate(row, indexRow);
|
|
3830
|
+
e.preventDefault();
|
|
3831
|
+
e.stopPropagation();
|
|
3832
|
+
}
|
|
3833
|
+
},
|
|
3834
|
+
children: /* @__PURE__ */ jsx16("div", { className: "r-rowcell-div", children: indexRow + 1 })
|
|
3831
3835
|
},
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3836
|
+
`col-${indexRow}-${indexCol}`
|
|
3837
|
+
);
|
|
3838
|
+
} else if (col.field === "checkbox") {
|
|
3839
|
+
return /* @__PURE__ */ jsx16(
|
|
3840
|
+
"td",
|
|
3841
|
+
{
|
|
3842
|
+
className: classnames9(
|
|
3843
|
+
`r-rowcell p-0 fix-${col.fixedType}`,
|
|
3844
|
+
{ "cell-fixed": col.fixedType },
|
|
3845
|
+
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
3846
|
+
),
|
|
3847
|
+
style: {
|
|
3848
|
+
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3849
|
+
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3850
|
+
textAlign: col.textAlign ? col.textAlign : "center"
|
|
3851
|
+
},
|
|
3852
|
+
children: /* @__PURE__ */ jsx16(
|
|
3853
|
+
"div",
|
|
3854
|
+
{
|
|
3855
|
+
className: "r-rowcell-div cursor-pointer",
|
|
3856
|
+
onClick: (e) => {
|
|
3857
|
+
if (selectEnable) {
|
|
3858
|
+
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
3859
|
+
if (index > -1) {
|
|
3860
|
+
if (isMulti) {
|
|
3861
|
+
selectedRows?.splice(index, 1);
|
|
3862
|
+
setSelectedRows([...selectedRows]);
|
|
3863
|
+
} else {
|
|
3864
|
+
setSelectedRows([]);
|
|
3865
|
+
}
|
|
3866
|
+
} else {
|
|
3867
|
+
if (isMulti) {
|
|
3868
|
+
setSelectedRows([...selectedRows, row]);
|
|
3869
|
+
} else {
|
|
3870
|
+
setSelectedRows([row]);
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
e.stopPropagation();
|
|
3874
|
+
}
|
|
3875
|
+
},
|
|
3876
|
+
children: /* @__PURE__ */ jsx16(
|
|
3877
|
+
Input9,
|
|
3878
|
+
{
|
|
3879
|
+
checked: isSelected,
|
|
3880
|
+
type: "checkbox",
|
|
3881
|
+
className: "cursor-pointer",
|
|
3882
|
+
onChange: () => {
|
|
3883
|
+
},
|
|
3884
|
+
style: { textAlign: col.textAlign ?? "center", marginTop: 6 }
|
|
3885
|
+
}
|
|
3886
|
+
)
|
|
3887
|
+
}
|
|
3888
|
+
)
|
|
3847
3889
|
},
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3890
|
+
`col-${indexRow}-${indexCol}`
|
|
3891
|
+
);
|
|
3892
|
+
} else {
|
|
3893
|
+
let value = row[col.field];
|
|
3894
|
+
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
3895
|
+
value = formartNumberic(row[col.field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) ?? 0;
|
|
3896
|
+
} else if (col.editType === "date") {
|
|
3897
|
+
value = value ? moment3(value).format("DD/MM/yyyy") : "";
|
|
3898
|
+
} else if (col.editType === "datetime") {
|
|
3899
|
+
value = value ? moment3(value).format("DD/MM/yyyy HH:mm") : "";
|
|
3900
|
+
}
|
|
3901
|
+
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
3902
|
+
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
3903
|
+
return /* @__PURE__ */ jsx16(Fragment20, { children: col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3904
|
+
"td",
|
|
3905
|
+
{
|
|
3906
|
+
className: classnames9(
|
|
3907
|
+
`r-rowcell fix-${col.fixedType}`,
|
|
3908
|
+
{ "cell-fixed": col.fixedType },
|
|
3909
|
+
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
3910
|
+
),
|
|
3911
|
+
style: {
|
|
3912
|
+
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3913
|
+
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3914
|
+
padding: 0,
|
|
3915
|
+
textAlign: col.textAlign ? col.textAlign : "left"
|
|
3916
|
+
},
|
|
3917
|
+
onClick: (e) => {
|
|
3918
|
+
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
3919
|
+
if (!editDisable && indexRow != indexFocus) {
|
|
3920
|
+
setIndexFocus(indexRow);
|
|
3921
|
+
focusNewElement(indexCol + 1, indexRow + 1, true);
|
|
3922
|
+
}
|
|
3923
|
+
if (selectEnable && editDisable) {
|
|
3854
3924
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
3855
3925
|
if (index > -1) {
|
|
3856
3926
|
if (isMulti) {
|
|
@@ -3866,116 +3936,51 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3866
3936
|
setSelectedRows([row]);
|
|
3867
3937
|
}
|
|
3868
3938
|
}
|
|
3869
|
-
e.stopPropagation();
|
|
3870
3939
|
}
|
|
3871
|
-
|
|
3872
|
-
children: /* @__PURE__ */ jsx16(
|
|
3873
|
-
Input9,
|
|
3874
|
-
{
|
|
3875
|
-
checked: isSelected,
|
|
3876
|
-
type: "checkbox",
|
|
3877
|
-
className: "cursor-pointer",
|
|
3878
|
-
onChange: () => {
|
|
3879
|
-
},
|
|
3880
|
-
style: { textAlign: col.textAlign ?? "center", marginTop: 6 }
|
|
3881
|
-
}
|
|
3882
|
-
)
|
|
3883
|
-
}
|
|
3884
|
-
)
|
|
3885
|
-
},
|
|
3886
|
-
`col-${indexRow}-${indexCol}`
|
|
3887
|
-
) : /* @__PURE__ */ jsx16(ContenComponent, { col, indexCol, indexRow, isSelected, row }) });
|
|
3888
|
-
};
|
|
3889
|
-
const ContenComponent = ({ col, indexCol, indexRow, isSelected, row }) => {
|
|
3890
|
-
let value = row[col.field];
|
|
3891
|
-
if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
|
|
3892
|
-
value = formartNumberic(row[col.field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) ?? 0;
|
|
3893
|
-
} else if (col.editType === "date") {
|
|
3894
|
-
value = value ? moment3(value).format("DD/MM/yyyy") : "";
|
|
3895
|
-
} else if (col.editType === "datetime") {
|
|
3896
|
-
value = value ? moment3(value).format("DD/MM/yyyy HH:mm") : "";
|
|
3897
|
-
}
|
|
3898
|
-
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === "checkbox") && (!col.disabledCondition || !col.disabledCondition(row)) ? col.editEnable ? 1 : col.template ? 2 : 3 : col.template ? 2 : 3;
|
|
3899
|
-
const errorMessage = typeDis === 1 || col.field === "" || !col.validate ? "" : col.validate(row[col.field], row);
|
|
3900
|
-
return /* @__PURE__ */ jsx16(Fragment20, { children: col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3901
|
-
"td",
|
|
3902
|
-
{
|
|
3903
|
-
className: classnames9(
|
|
3904
|
-
`r-rowcell fix-${col.fixedType}`,
|
|
3905
|
-
{ "cell-fixed": col.fixedType },
|
|
3906
|
-
{ "r-active": isSelected && editDisable || indexFocus === indexRow }
|
|
3907
|
-
),
|
|
3908
|
-
style: {
|
|
3909
|
-
left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
|
|
3910
|
-
right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
|
|
3911
|
-
padding: 0,
|
|
3912
|
-
textAlign: col.textAlign ? col.textAlign : "left"
|
|
3913
|
-
},
|
|
3914
|
-
onClick: (e) => {
|
|
3915
|
-
if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
|
|
3916
|
-
if (!editDisable && indexRow != indexFocus) {
|
|
3917
|
-
setIndexFocus(indexRow);
|
|
3918
|
-
focusNewElement(indexCol + 1, indexRow + 1, true);
|
|
3940
|
+
e.stopPropagation();
|
|
3919
3941
|
}
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3942
|
+
},
|
|
3943
|
+
children: /* @__PURE__ */ jsx16(
|
|
3944
|
+
"div",
|
|
3945
|
+
{
|
|
3946
|
+
className: classnames9("r-rowcell-div"),
|
|
3947
|
+
children: /* @__PURE__ */ jsxs15(
|
|
3948
|
+
"div",
|
|
3949
|
+
{
|
|
3950
|
+
id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
|
|
3951
|
+
className: classnames9("r-rowcell-content", { "r-is-invalid": errorMessage }),
|
|
3952
|
+
style: {
|
|
3953
|
+
margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2,
|
|
3954
|
+
color: col.editType === "numeric" && Number(row[col.field]) < 0 ? "red" : ""
|
|
3955
|
+
},
|
|
3956
|
+
children: [
|
|
3957
|
+
typeDis === 1 && !refreshRow ? RenderEdit(row, col, indexCol, indexRow) : /* @__PURE__ */ jsx16("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3958
|
+
/* @__PURE__ */ jsx16("span", { id: `error-${indexRow}-${indexCol}`, className: classnames9("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ jsx16(AlertCircle, { fontSize: 15.5 }) }),
|
|
3959
|
+
!(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ jsx16(UncontrolledTooltip5, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3960
|
+
/* @__PURE__ */ jsx16(
|
|
3961
|
+
UncontrolledTooltip5,
|
|
3962
|
+
{
|
|
3963
|
+
target: `error-${indexRow}-${indexCol}`,
|
|
3964
|
+
className: "r-tooltip tooltip-error",
|
|
3965
|
+
children: errorMessage?.toString() ?? ""
|
|
3966
|
+
}
|
|
3967
|
+
)
|
|
3968
|
+
]
|
|
3934
3969
|
}
|
|
3935
|
-
|
|
3970
|
+
)
|
|
3936
3971
|
}
|
|
3937
|
-
|
|
3972
|
+
)
|
|
3938
3973
|
},
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
className: classnames9("r-rowcell-div"),
|
|
3943
|
-
children: /* @__PURE__ */ jsxs15(
|
|
3944
|
-
"div",
|
|
3945
|
-
{
|
|
3946
|
-
id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
|
|
3947
|
-
className: classnames9("r-rowcell-content", { "r-is-invalid": errorMessage }),
|
|
3948
|
-
style: {
|
|
3949
|
-
margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2,
|
|
3950
|
-
color: col.editType === "numeric" && Number(row[col.field]) < 0 ? "red" : ""
|
|
3951
|
-
},
|
|
3952
|
-
children: [
|
|
3953
|
-
typeDis === 1 && !refreshRow ? RenderEdit(row, col, indexCol, indexRow) : /* @__PURE__ */ jsx16("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3954
|
-
/* @__PURE__ */ jsx16("span", { id: `error-${indexRow}-${indexCol}`, className: classnames9("cursor-pointer text-primary icon-table", { "d-none": !errorMessage }), children: /* @__PURE__ */ jsx16(AlertCircle, { fontSize: 15.5 }) }),
|
|
3955
|
-
!(typeDis === 1 && !refreshRow) && checkOverflow(indexRow, indexCol) && /* @__PURE__ */ jsx16(UncontrolledTooltip5, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: typeDis === 2 ? col.template(row, indexRow) : value }),
|
|
3956
|
-
/* @__PURE__ */ jsx16(
|
|
3957
|
-
UncontrolledTooltip5,
|
|
3958
|
-
{
|
|
3959
|
-
target: `error-${indexRow}-${indexCol}`,
|
|
3960
|
-
className: "r-tooltip tooltip-error",
|
|
3961
|
-
children: errorMessage?.toString() ?? ""
|
|
3962
|
-
}
|
|
3963
|
-
)
|
|
3964
|
-
]
|
|
3965
|
-
}
|
|
3966
|
-
)
|
|
3967
|
-
}
|
|
3968
|
-
)
|
|
3969
|
-
},
|
|
3970
|
-
`col-${indexRow}-${indexCol}`
|
|
3971
|
-
) }, indexCol);
|
|
3974
|
+
`col-${indexRow}-${indexCol}`
|
|
3975
|
+
) }, indexCol);
|
|
3976
|
+
}
|
|
3972
3977
|
};
|
|
3973
3978
|
const checkOverflow = (indexRow, indexCol) => {
|
|
3974
3979
|
const element = document.getElementById(`content-${idTable}-row${indexRow}col-${indexCol}`);
|
|
3975
3980
|
return element && element.scrollWidth > element.clientWidth;
|
|
3976
3981
|
};
|
|
3977
|
-
const
|
|
3978
|
-
return col.visible !== false
|
|
3982
|
+
const renderFooterCol = (col, indexCol) => {
|
|
3983
|
+
return /* @__PURE__ */ jsx16(Fragment20, { children: col.visible !== false && /* @__PURE__ */ jsx16(
|
|
3979
3984
|
"td",
|
|
3980
3985
|
{
|
|
3981
3986
|
className: classnames9(
|
|
@@ -3991,9 +3996,9 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
3991
3996
|
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
3992
3997
|
}, 0), decimalSeparator, thousandSeparator, col.numericSettings?.fraction, true) : "" })
|
|
3993
3998
|
}
|
|
3994
|
-
)
|
|
3999
|
+
) }, `summarycell-${indexCol}`);
|
|
3995
4000
|
};
|
|
3996
|
-
const
|
|
4001
|
+
const renderToolbarTop = () => {
|
|
3997
4002
|
return /* @__PURE__ */ jsx16("div", { id: "table_custom_top_toolbar", className: "r-toolbar r-toolbar-top", "aria-orientation": "horizontal", children: /* @__PURE__ */ jsxs15("div", { className: "r-toolbar-items", children: [
|
|
3998
4003
|
/* @__PURE__ */ jsx16("div", { className: "r-toolbar-left", children: toolbarTopOption?.map((item, index) => {
|
|
3999
4004
|
return item.align === "left" ? /* @__PURE__ */ jsx16("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-top-left-${index}`) : "";
|
|
@@ -4006,7 +4011,7 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
4006
4011
|
}) })
|
|
4007
4012
|
] }) });
|
|
4008
4013
|
};
|
|
4009
|
-
const
|
|
4014
|
+
const renderToolbarBottom = () => {
|
|
4010
4015
|
return /* @__PURE__ */ jsx16("div", { id: "table_custom_bottom_toolbar", className: "r-toolbar r-toolbar-bottom", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: /* @__PURE__ */ jsxs15("div", { className: "r-toolbar-items", children: [
|
|
4011
4016
|
/* @__PURE__ */ jsxs15("div", { className: "r-toolbar-left", children: [
|
|
4012
4017
|
/* @__PURE__ */ jsx16("div", { className: classnames9("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx16(Button6, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
|
|
@@ -4060,10 +4065,10 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
4060
4065
|
}
|
|
4061
4066
|
return false;
|
|
4062
4067
|
};
|
|
4063
|
-
const
|
|
4068
|
+
const renderData = () => {
|
|
4064
4069
|
totalCount = 0;
|
|
4065
4070
|
let countDisplay = -1;
|
|
4066
|
-
return
|
|
4071
|
+
return dataSource.map((row, indexRow) => {
|
|
4067
4072
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
4068
4073
|
const flagSearch = !searchClient || checkSearch(searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm, row, searchSetting?.keyField ?? []);
|
|
4069
4074
|
if (flagSearch) {
|
|
@@ -4076,14 +4081,14 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
4076
4081
|
{
|
|
4077
4082
|
className: classnames9("r-row", { "fisrt-row": countDisplay === 0 }),
|
|
4078
4083
|
children: contentColumns.map((col, indexCol) => {
|
|
4079
|
-
return
|
|
4084
|
+
return renderContentCol(col, row, indexRow, indexCol, isSelected);
|
|
4080
4085
|
})
|
|
4081
4086
|
},
|
|
4082
4087
|
`row-${indexRow}`
|
|
4083
4088
|
);
|
|
4084
4089
|
}
|
|
4085
4090
|
}
|
|
4086
|
-
})
|
|
4091
|
+
});
|
|
4087
4092
|
};
|
|
4088
4093
|
useEffect9(() => {
|
|
4089
4094
|
if (pagingClient && pagingSetting?.setCurrentPage && (searchSetting?.searchTerm !== void 0 ? searchSetting?.searchTerm : searchTerm)) {
|
|
@@ -4093,7 +4098,7 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
4093
4098
|
return /* @__PURE__ */ jsxs15(Fragment20, { children: [
|
|
4094
4099
|
/* @__PURE__ */ jsxs15("div", { className: "react-table-edit", children: [
|
|
4095
4100
|
/* @__PURE__ */ jsxs15("div", { className: "r-grid", ref: gridRef, children: [
|
|
4096
|
-
toolbarSetting?.showTopToolbar ? /* @__PURE__ */ jsx16(
|
|
4101
|
+
toolbarSetting?.showTopToolbar ? /* @__PURE__ */ jsx16(Fragment21, { children: renderToolbarTop() }) : /* @__PURE__ */ jsx16(Fragment21, {}),
|
|
4097
4102
|
/* @__PURE__ */ jsx16("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ jsxs15("table", { style: { width: "100%" }, children: [
|
|
4098
4103
|
/* @__PURE__ */ jsx16("thead", { className: "r-gridheader", children: headerColumns.map((element, indexParent) => {
|
|
4099
4104
|
return /* @__PURE__ */ jsx16("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
@@ -4117,12 +4122,12 @@ var TableEdit = forwardRef4((props, ref) => {
|
|
|
4117
4122
|
);
|
|
4118
4123
|
}) }, `header-${-indexParent}`);
|
|
4119
4124
|
}) }),
|
|
4120
|
-
/* @__PURE__ */ jsx16("tbody", { className: "r-gridcontent", children:
|
|
4125
|
+
/* @__PURE__ */ jsx16("tbody", { className: "r-gridcontent", children: renderData() }),
|
|
4121
4126
|
/* @__PURE__ */ jsx16("tfoot", { className: "r-gridfoot", children: haveSum == true ? /* @__PURE__ */ jsx16("tr", { className: "r-row", children: contentColumns.map((col, index) => {
|
|
4122
|
-
return
|
|
4127
|
+
return renderFooterCol(col, index);
|
|
4123
4128
|
}) }) : /* @__PURE__ */ jsx16(Fragment21, {}) })
|
|
4124
4129
|
] }) }),
|
|
4125
|
-
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */ jsx16(
|
|
4130
|
+
toolbarSetting?.showBottomToolbar ? /* @__PURE__ */ jsx16(Fragment21, { children: renderToolbarBottom() }) : /* @__PURE__ */ jsx16(Fragment21, {})
|
|
4126
4131
|
] }),
|
|
4127
4132
|
pagingSetting?.allowPaging ? /* @__PURE__ */ jsx16(
|
|
4128
4133
|
PagingComponent,
|