react-table-edit 1.5.37 → 1.5.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/index.js +107 -183
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -183
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -68737,21 +68737,32 @@ const UnExpandAllIcon = ({ className, color = '#7F7F7F', size = 24, onClick, sty
|
|
|
68737
68737
|
};
|
|
68738
68738
|
|
|
68739
68739
|
const RenderContentCol = (props) => {
|
|
68740
|
-
const { col, indexCol, indexRow, isSelected, row, zeroVisiable, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, setSelectedRows, handleCloseContext, handleDoubleClick, fieldKey, isMulti
|
|
68740
|
+
const { col, indexCol, indexRow, isSelected, row, zeroVisiable, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, setSelectedRows, handleCloseContext, handleDoubleClick, fieldKey, isMulti } = props;
|
|
68741
68741
|
const cellId = `content-${idTable}-row${indexRow}col-${indexCol}`;
|
|
68742
68742
|
const checkOverflow = () => {
|
|
68743
68743
|
const element = document.getElementById(cellId);
|
|
68744
68744
|
return element && element.scrollWidth > element.clientWidth;
|
|
68745
68745
|
};
|
|
68746
|
+
const toggleSelect = () => {
|
|
68747
|
+
const idx = selectedRows?.findIndex((x) => x?.[fieldKey] === row?.[fieldKey]);
|
|
68748
|
+
if (idx > -1) {
|
|
68749
|
+
if (isMulti) {
|
|
68750
|
+
return selectedRows?.filter((_, i) => i !== idx);
|
|
68751
|
+
}
|
|
68752
|
+
return [];
|
|
68753
|
+
}
|
|
68754
|
+
if (isMulti) {
|
|
68755
|
+
return [...selectedRows, row];
|
|
68756
|
+
}
|
|
68757
|
+
return [row];
|
|
68758
|
+
};
|
|
68746
68759
|
const RenderElement = () => {
|
|
68747
68760
|
if (col.field === '#' || col.type === '#') {
|
|
68748
68761
|
return (jsxRuntime.jsx("div", { className: classNames$1('r-rowcell-div cursor-pointer text-center', {
|
|
68749
|
-
'r-active-cell': isSelected
|
|
68762
|
+
'r-active-cell': isSelected
|
|
68750
68763
|
}), style: {
|
|
68751
|
-
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType
|
|
68752
|
-
|
|
68753
|
-
: 400,
|
|
68754
|
-
fontStyle: row.haveItalicType ? 'italic' : 'normal',
|
|
68764
|
+
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType ? 600 : 400,
|
|
68765
|
+
fontStyle: row.haveItalicType ? 'italic' : 'normal'
|
|
68755
68766
|
}, onDoubleClick: (e) => {
|
|
68756
68767
|
e.preventDefault();
|
|
68757
68768
|
handleCloseContext();
|
|
@@ -68760,34 +68771,13 @@ const RenderContentCol = (props) => {
|
|
|
68760
68771
|
}
|
|
68761
68772
|
else if (col.type === 'checkbox' || col.field === 'checkbox') {
|
|
68762
68773
|
return (jsxRuntime.jsx("div", { className: classNames$1('r-rowcell-div cursor-pointer', {
|
|
68763
|
-
'r-active-cell': isSelected
|
|
68774
|
+
'r-active-cell': isSelected
|
|
68764
68775
|
}), style: {
|
|
68765
68776
|
display: 'flex',
|
|
68766
|
-
justifyContent: col.textAlign === 'center'
|
|
68767
|
-
|
|
68768
|
-
: col.textAlign === 'right'
|
|
68769
|
-
? 'flex-end'
|
|
68770
|
-
: 'flex-start',
|
|
68771
|
-
alignItems: 'center',
|
|
68777
|
+
justifyContent: col.textAlign === 'center' ? 'center' : col.textAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
68778
|
+
alignItems: 'center'
|
|
68772
68779
|
}, onClick: (e) => {
|
|
68773
|
-
|
|
68774
|
-
if (index > -1) {
|
|
68775
|
-
if (isMulti) {
|
|
68776
|
-
selectedRows?.splice(index, 1);
|
|
68777
|
-
setSelectedRows([...selectedRows]);
|
|
68778
|
-
}
|
|
68779
|
-
else {
|
|
68780
|
-
setSelectedRows([]);
|
|
68781
|
-
}
|
|
68782
|
-
}
|
|
68783
|
-
else {
|
|
68784
|
-
if (isMulti) {
|
|
68785
|
-
setSelectedRows([...selectedRows, row]);
|
|
68786
|
-
}
|
|
68787
|
-
else {
|
|
68788
|
-
setSelectedRows([row]);
|
|
68789
|
-
}
|
|
68790
|
-
}
|
|
68780
|
+
setSelectedRows(toggleSelect());
|
|
68791
68781
|
e.stopPropagation();
|
|
68792
68782
|
}, children: jsxRuntime.jsx(Input$1, { defaultChecked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? 'center' } }) }));
|
|
68793
68783
|
}
|
|
@@ -68795,11 +68785,8 @@ const RenderContentCol = (props) => {
|
|
|
68795
68785
|
let value = row[col.field];
|
|
68796
68786
|
// ✅ Format dữ liệu theo loại cột
|
|
68797
68787
|
if (col.type === 'numeric') {
|
|
68798
|
-
value =
|
|
68799
|
-
|
|
68800
|
-
if (!zeroVisiable &&
|
|
68801
|
-
!(row?.sortOrder < 0 || row?.sortOrder > 100000) &&
|
|
68802
|
-
(value === '0' || value === 0)) {
|
|
68788
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
68789
|
+
if (!zeroVisiable && !(row?.sortOrder < 0 || row?.sortOrder > 100000) && (value === '0' || value === 0)) {
|
|
68803
68790
|
value = '';
|
|
68804
68791
|
}
|
|
68805
68792
|
}
|
|
@@ -68807,88 +68794,75 @@ const RenderContentCol = (props) => {
|
|
|
68807
68794
|
value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
|
|
68808
68795
|
}
|
|
68809
68796
|
else if (col.type === 'datetime') {
|
|
68810
|
-
value = value
|
|
68811
|
-
? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm')
|
|
68812
|
-
: '';
|
|
68797
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
|
|
68813
68798
|
}
|
|
68814
68799
|
if (col.template) {
|
|
68815
68800
|
value = col.template(row, indexRow) ?? '';
|
|
68816
68801
|
}
|
|
68817
68802
|
const isNegative = col.type === 'numeric' && Number(row[col.field]) < 0;
|
|
68818
|
-
const textColor = isNegative
|
|
68819
|
-
|
|
68820
|
-
|
|
68821
|
-
const
|
|
68822
|
-
const suffix = isNegative ? (formatSetting?.suffixNegative ?? '') : '';
|
|
68823
|
-
const displayText = isNegative
|
|
68824
|
-
? `${prefix}${value}${suffix}`
|
|
68825
|
-
: (value ?? '');
|
|
68803
|
+
const textColor = isNegative ? formatSetting?.colorNegative ?? 'red' : undefined;
|
|
68804
|
+
const prefix = isNegative ? formatSetting?.prefixNegative ?? '-' : '';
|
|
68805
|
+
const suffix = isNegative ? formatSetting?.suffixNegative ?? '' : '';
|
|
68806
|
+
const displayText = isNegative ? `${prefix}${value}${suffix}` : value ?? '';
|
|
68826
68807
|
return (jsxRuntime.jsxs("div", { className: classNames$1('r-rowcell-div cursor-pointer', {
|
|
68827
|
-
'r-active-cell': isSelected
|
|
68808
|
+
'r-active-cell': isSelected
|
|
68828
68809
|
}), style: {
|
|
68829
|
-
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType
|
|
68830
|
-
|
|
68831
|
-
: 400,
|
|
68832
|
-
fontStyle: row.haveItalicType ? 'italic' : 'normal',
|
|
68833
|
-
}, onDoubleClick: (e) => {
|
|
68834
|
-
e.preventDefault();
|
|
68835
|
-
handleCloseContext();
|
|
68836
|
-
handleDoubleClick?.(row, col);
|
|
68810
|
+
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType ? 600 : 400,
|
|
68811
|
+
fontStyle: row.haveItalicType ? 'italic' : 'normal'
|
|
68837
68812
|
}, children: [jsxRuntime.jsx("div", { className: "r-cell-text", style: {
|
|
68838
68813
|
display: 'flex',
|
|
68839
|
-
justifyContent: col.textAlign === 'center'
|
|
68840
|
-
|
|
68841
|
-
: col.textAlign === 'right'
|
|
68842
|
-
? 'flex-end'
|
|
68843
|
-
: 'flex-start',
|
|
68844
|
-
alignItems: 'center',
|
|
68814
|
+
justifyContent: col.textAlign === 'center' ? 'center' : col.textAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
68815
|
+
alignItems: 'center'
|
|
68845
68816
|
}, children: jsxRuntime.jsx("div", { id: cellId, style: {
|
|
68846
68817
|
color: textColor,
|
|
68847
68818
|
overflow: 'hidden',
|
|
68848
68819
|
textOverflow: 'ellipsis',
|
|
68849
68820
|
whiteSpace: 'pre',
|
|
68850
|
-
maxWidth: '100%'
|
|
68821
|
+
maxWidth: '100%'
|
|
68851
68822
|
}, children: displayText }) }), checkOverflow() && (jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: cellId, placement: "top", children: jsxRuntime.jsx("div", { style: { color: textColor }, onClick: (e) => {
|
|
68852
68823
|
e.stopPropagation();
|
|
68853
68824
|
e.preventDefault();
|
|
68854
68825
|
}, children: displayText }) }))] }));
|
|
68855
68826
|
}
|
|
68856
68827
|
};
|
|
68828
|
+
const clickTimerRef = React$5.useRef(null);
|
|
68857
68829
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: col.visible !== false && col.isGroup !== true && (jsxRuntime.jsx("td", { className: classNames$1(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, {
|
|
68858
|
-
'fixed-last': (col.fixedType === 'left' &&
|
|
68859
|
-
indexCol === lastObjWidthFixLeft) ||
|
|
68860
|
-
(col.fixedType === 'right' &&
|
|
68861
|
-
indexCol === fisrtObjWidthFixRight),
|
|
68830
|
+
'fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight)
|
|
68862
68831
|
}, { 'r-active': isSelected }), style: {
|
|
68863
68832
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
68864
|
-
right: col.fixedType === 'right'
|
|
68865
|
-
? objWidthFixRight[indexCol]
|
|
68866
|
-
: undefined,
|
|
68833
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined
|
|
68867
68834
|
}, onClick: (e) => {
|
|
68868
|
-
|
|
68869
|
-
|
|
68870
|
-
|
|
68871
|
-
|
|
68872
|
-
|
|
68873
|
-
|
|
68874
|
-
|
|
68875
|
-
|
|
68876
|
-
|
|
68877
|
-
|
|
68878
|
-
|
|
68879
|
-
|
|
68880
|
-
|
|
68881
|
-
|
|
68882
|
-
|
|
68883
|
-
|
|
68884
|
-
setSelectedRows([row]);
|
|
68885
|
-
}
|
|
68886
|
-
}
|
|
68835
|
+
const tag = e.target?.nodeName;
|
|
68836
|
+
if (tag !== 'DIV' && tag !== 'TD') {
|
|
68837
|
+
return;
|
|
68838
|
+
}
|
|
68839
|
+
if (clickTimerRef.current) {
|
|
68840
|
+
window.clearTimeout(clickTimerRef.current);
|
|
68841
|
+
}
|
|
68842
|
+
if (handleDoubleClick) {
|
|
68843
|
+
clickTimerRef.current = window.setTimeout(() => {
|
|
68844
|
+
setSelectedRows(toggleSelect());
|
|
68845
|
+
clickTimerRef.current = null;
|
|
68846
|
+
}, 200);
|
|
68847
|
+
}
|
|
68848
|
+
else {
|
|
68849
|
+
setSelectedRows(toggleSelect());
|
|
68850
|
+
clickTimerRef.current = null;
|
|
68887
68851
|
}
|
|
68852
|
+
}, onDoubleClick: (e) => {
|
|
68853
|
+
// hủy single click pending để không đổi style trước
|
|
68854
|
+
if (clickTimerRef.current) {
|
|
68855
|
+
window.clearTimeout(clickTimerRef.current);
|
|
68856
|
+
}
|
|
68857
|
+
clickTimerRef.current = null;
|
|
68858
|
+
handleCloseContext();
|
|
68859
|
+
handleDoubleClick?.(row, col);
|
|
68860
|
+
e.preventDefault();
|
|
68861
|
+
e.stopPropagation();
|
|
68888
68862
|
}, children: RenderElement() }, `col-${indexRow}-${indexCol}`)) }));
|
|
68889
68863
|
};
|
|
68890
68864
|
|
|
68891
|
-
const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoading, formatSetting, querySetting, pagingSetting, searchSetting, columnsAggregate, toolbarSetting, selectedItem, setSelectedItem, handleSelect, saveSettingColumn, resetDefaultColumns, settingColumns, headerComponent, groupSetting, zeroVisiable, isMulti, handleDoubleClick, contextMenuItems, handleContextMenuClick
|
|
68865
|
+
const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoading, formatSetting, querySetting, pagingSetting, searchSetting, columnsAggregate, toolbarSetting, selectedItem, setSelectedItem, handleSelect, saveSettingColumn, resetDefaultColumns, settingColumns, headerComponent, groupSetting, zeroVisiable, isMulti, handleDoubleClick, contextMenuItems, handleContextMenuClick }) => {
|
|
68892
68866
|
const { t } = reactI18next.useTranslation();
|
|
68893
68867
|
const gridRef = React$5.useRef(null);
|
|
68894
68868
|
const [openPopupSetupColumn, setOpenPopupSetupColumn] = React$5.useState(false);
|
|
@@ -68896,8 +68870,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68896
68870
|
const [orderBy, setOrderBy] = React$5.useState([]);
|
|
68897
68871
|
const [filterBy, setFilterBy] = React$5.useState([]);
|
|
68898
68872
|
const [searchTerm, setSearchTerm] = React$5.useState('');
|
|
68899
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ??
|
|
68900
|
-
'id';
|
|
68873
|
+
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? 'id';
|
|
68901
68874
|
const [contentColumns, setContentColumns] = React$5.useState([]);
|
|
68902
68875
|
const [groupColumns, setGroupColumns] = React$5.useState([]);
|
|
68903
68876
|
const [expandsAll, setExpandsAll] = React$5.useState(true);
|
|
@@ -68916,7 +68889,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68916
68889
|
}
|
|
68917
68890
|
setExpandsAll(true);
|
|
68918
68891
|
}, [groupSetting?.groupColumns]);
|
|
68919
|
-
const { levels: headerColumns, objHeaderWidthFixLeft, objHeaderWidthFixRight, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight
|
|
68892
|
+
const { levels: headerColumns, objHeaderWidthFixLeft, objHeaderWidthFixRight, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight } = React$5.useMemo(() => {
|
|
68920
68893
|
const rs = calculateTableStructure(columns, settingColumns?.value, groupSetting?.groupColumns);
|
|
68921
68894
|
setContentColumns(rs.flat);
|
|
68922
68895
|
return rs;
|
|
@@ -68945,10 +68918,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68945
68918
|
if (searchTerm) {
|
|
68946
68919
|
datas = datas.filter((row) => {
|
|
68947
68920
|
return searchSetting?.keyField?.some((key) => {
|
|
68948
|
-
return row[key]
|
|
68949
|
-
?.toString()
|
|
68950
|
-
.toLowerCase()
|
|
68951
|
-
.includes(searchTerm.trim().toLowerCase());
|
|
68921
|
+
return row[key]?.toString().toLowerCase().includes(searchTerm.trim().toLowerCase());
|
|
68952
68922
|
});
|
|
68953
68923
|
});
|
|
68954
68924
|
}
|
|
@@ -68957,10 +68927,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68957
68927
|
return filterBy.every((filter) => {
|
|
68958
68928
|
const { key, value, ope } = filter;
|
|
68959
68929
|
const rowValue = row[key];
|
|
68960
|
-
if (rowValue === undefined ||
|
|
68961
|
-
rowValue === null ||
|
|
68962
|
-
value === undefined ||
|
|
68963
|
-
value === null) {
|
|
68930
|
+
if (rowValue === undefined || rowValue === null || value === undefined || value === null) {
|
|
68964
68931
|
return false;
|
|
68965
68932
|
}
|
|
68966
68933
|
const valStr = String(rowValue).toLowerCase();
|
|
@@ -69023,17 +68990,12 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69023
68990
|
}
|
|
69024
68991
|
};
|
|
69025
68992
|
const searchTemplate = () => {
|
|
69026
|
-
return (jsxRuntime.jsx("div", { className: "me-50 r-search", children: jsxRuntime.jsx(ReactInput, { style: { width: '230px' }, value: searchSetting?.searchTerm !== undefined
|
|
69027
|
-
? searchSetting?.searchTerm
|
|
69028
|
-
: searchTerm, setSearchTerm: searchSetting?.setSearchTerm
|
|
69029
|
-
? searchSetting?.setSearchTerm
|
|
69030
|
-
: setSearchTerm, placeholder: t('Search'), onKeyPress: handleKeyPress }) }));
|
|
68993
|
+
return (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 }) }));
|
|
69031
68994
|
};
|
|
69032
68995
|
const groupbtnTemplate = () => {
|
|
69033
68996
|
return (jsxRuntime.jsxs(UncontrolledDropdown, { children: [jsxRuntime.jsx(DropdownToggle$1, { tag: "div", id: "group-dropdown-toggle", style: { position: 'relative' }, onClick: (e) => e.preventDefault(), children: jsxRuntime.jsx(GroupIcon, { color: "#7F7F7F", size: 24 }) }), jsxRuntime.jsxs(DropdownMenu$1, { className: "formula-dropdown icon-dropdown p-1", children: [jsxRuntime.jsx("div", { className: "mb-1", style: { fontSize: 16, fontWeight: 500 }, children: "Nh\u00F3m d\u1EEF li\u1EC7u theo c\u1ED9t" }), jsxRuntime.jsxs("div", { className: 'form-group', children: [jsxRuntime.jsx(Label$1, { id: `label-group-1`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 1" }), jsxRuntime.jsx("div", { className: "form-input", children: jsxRuntime.jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[0]
|
|
69034
68997
|
? {
|
|
69035
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[0])?.headerText ??
|
|
69036
|
-
contentColumns.find((x) => x.field === groupColumns[0])?.headerText),
|
|
68998
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[0])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[0])?.headerText)
|
|
69037
68999
|
}
|
|
69038
69000
|
: undefined, onChange: (val) => {
|
|
69039
69001
|
if (val) {
|
|
@@ -69045,8 +69007,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69045
69007
|
setGroupColumns([...groupColumns]);
|
|
69046
69008
|
}, isClearable: groupColumns?.length === 1 }) })] }), jsxRuntime.jsxs("div", { className: 'form-group', children: [jsxRuntime.jsx(Label$1, { id: `label-group-2`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 2" }), jsxRuntime.jsx("div", { className: "form-input", children: jsxRuntime.jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[1]
|
|
69047
69009
|
? {
|
|
69048
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[1])?.headerText ??
|
|
69049
|
-
contentColumns.find((x) => x.field === groupColumns[1])?.headerText),
|
|
69010
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[1])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[1])?.headerText)
|
|
69050
69011
|
}
|
|
69051
69012
|
: undefined, onChange: (val) => {
|
|
69052
69013
|
if (val) {
|
|
@@ -69058,8 +69019,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69058
69019
|
setGroupColumns([...groupColumns]);
|
|
69059
69020
|
}, isClearable: groupColumns?.length === 2 }) })] }), jsxRuntime.jsxs("div", { className: 'form-group', children: [jsxRuntime.jsx(Label$1, { id: `label-group-3`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 3" }), jsxRuntime.jsx("div", { className: "form-input", children: jsxRuntime.jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[2]
|
|
69060
69021
|
? {
|
|
69061
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[2])?.headerText ??
|
|
69062
|
-
contentColumns.find((x) => x.field === groupColumns[2])?.headerText),
|
|
69022
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[2])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[2])?.headerText)
|
|
69063
69023
|
}
|
|
69064
69024
|
: undefined, onChange: (val) => {
|
|
69065
69025
|
if (groupSetting) {
|
|
@@ -69073,7 +69033,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69073
69033
|
}
|
|
69074
69034
|
}, isClearable: groupColumns?.length === 3 }) })] }), jsxRuntime.jsxs("div", { className: "border-top d-flex justify-content-end mt-1", children: [jsxRuntime.jsx(Button$1$1, { color: "primary", className: "mt-1 me-50 rounded", size: "sm", onClick: () => {
|
|
69075
69035
|
groupSetting?.onGroup({
|
|
69076
|
-
columnGrouped: groupColumns.filter((x) => x)
|
|
69036
|
+
columnGrouped: groupColumns.filter((x) => x)
|
|
69077
69037
|
});
|
|
69078
69038
|
document.getElementById('group-dropdown-toggle')?.click();
|
|
69079
69039
|
}, children: `${t('Apply')}` }), jsxRuntime.jsx(Button$1$1, { color: "secondary", outline: true, className: "mt-1 rounded", size: "sm", onClick: () => {
|
|
@@ -69082,16 +69042,14 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69082
69042
|
}, children: `${t('Delete')}` })] })] })] }));
|
|
69083
69043
|
};
|
|
69084
69044
|
const chooseColumnsTemplate = () => {
|
|
69085
|
-
return
|
|
69045
|
+
return jsxRuntime.jsx(SvgSettings, { className: "r-toolbar-icon", fontSize: 20, color: "#7F7F7F", onClick: () => setOpenPopupSetupColumn(true) });
|
|
69086
69046
|
};
|
|
69087
69047
|
const expandTemplate = () => {
|
|
69088
69048
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!expandsAll && (jsxRuntime.jsx(ExpandAllIcon, { onClick: () => {
|
|
69089
69049
|
setExpandsAll(true);
|
|
69090
|
-
}, color: "#7F7F7F", size: 24 })), expandsAll &&
|
|
69050
|
+
}, color: "#7F7F7F", size: 24 })), expandsAll && jsxRuntime.jsx(UnExpandAllIcon, { onClick: () => setExpandsAll(false), color: "#7F7F7F", size: 24 })] }));
|
|
69091
69051
|
};
|
|
69092
|
-
const defaultToolbarOption = searchSetting?.searchEnable
|
|
69093
|
-
? [{ template: searchTemplate, align: 'left' }]
|
|
69094
|
-
: [];
|
|
69052
|
+
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align: 'left' }] : [];
|
|
69095
69053
|
if (groupSetting) {
|
|
69096
69054
|
defaultToolbarOption.push({ template: groupbtnTemplate, align: 'left' });
|
|
69097
69055
|
}
|
|
@@ -69100,10 +69058,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69100
69058
|
}
|
|
69101
69059
|
let toolbarTopOption = [];
|
|
69102
69060
|
if (toolbarSetting?.toolbarOptions) {
|
|
69103
|
-
toolbarTopOption = [
|
|
69104
|
-
...defaultToolbarOption,
|
|
69105
|
-
...toolbarSetting?.toolbarOptions,
|
|
69106
|
-
];
|
|
69061
|
+
toolbarTopOption = [...defaultToolbarOption, ...toolbarSetting?.toolbarOptions];
|
|
69107
69062
|
}
|
|
69108
69063
|
else {
|
|
69109
69064
|
toolbarTopOption = [...defaultToolbarOption];
|
|
@@ -69134,9 +69089,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69134
69089
|
React$5.useEffect(() => {
|
|
69135
69090
|
if (setSelectedItem) {
|
|
69136
69091
|
if (isMulti) {
|
|
69137
|
-
if (dataSource &&
|
|
69138
|
-
selectedRows &&
|
|
69139
|
-
selectedRows?.length !== selectedItem?.length) {
|
|
69092
|
+
if (dataSource && selectedRows && selectedRows?.length !== selectedItem?.length) {
|
|
69140
69093
|
setSelectedItem([...selectedRows]);
|
|
69141
69094
|
if (handleSelect) {
|
|
69142
69095
|
handleSelect([...selectedRows]);
|
|
@@ -69145,8 +69098,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69145
69098
|
}
|
|
69146
69099
|
else {
|
|
69147
69100
|
if (dataSource && selectedRows?.length > 0) {
|
|
69148
|
-
if (!selectedItem ||
|
|
69149
|
-
selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69101
|
+
if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69150
69102
|
setSelectedItem({ ...selectedRows[0] });
|
|
69151
69103
|
if (handleSelect) {
|
|
69152
69104
|
handleSelect({ ...selectedRows[0] });
|
|
@@ -69165,8 +69117,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69165
69117
|
React$5.useEffect(() => {
|
|
69166
69118
|
if (!isMulti) {
|
|
69167
69119
|
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
69168
|
-
if (selectedRows?.length === 0 ||
|
|
69169
|
-
selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69120
|
+
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69170
69121
|
setSelectedRows([selectedItem]);
|
|
69171
69122
|
}
|
|
69172
69123
|
}
|
|
@@ -69175,9 +69126,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69175
69126
|
}
|
|
69176
69127
|
}
|
|
69177
69128
|
else {
|
|
69178
|
-
if (dataSource &&
|
|
69179
|
-
selectedItem &&
|
|
69180
|
-
selectedRows?.length !== selectedItem.length) {
|
|
69129
|
+
if (dataSource && selectedItem && selectedRows?.length !== selectedItem.length) {
|
|
69181
69130
|
setSelectedRows(selectedItem ? [...selectedItem] : []);
|
|
69182
69131
|
}
|
|
69183
69132
|
}
|
|
@@ -69195,67 +69144,52 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69195
69144
|
const col = contentColumns.find((x) => x.field === row.field);
|
|
69196
69145
|
let value = row[col.field];
|
|
69197
69146
|
if (col.type === 'numeric') {
|
|
69198
|
-
value =
|
|
69199
|
-
formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
69147
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
69200
69148
|
}
|
|
69201
69149
|
else if (col.type === 'date') {
|
|
69202
|
-
value = value
|
|
69203
|
-
? formatDateTime(value, formatSetting?.dateFormat)
|
|
69204
|
-
: '';
|
|
69150
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
|
|
69205
69151
|
}
|
|
69206
69152
|
else if (col.type === 'datetime') {
|
|
69207
|
-
value = value
|
|
69208
|
-
? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm')
|
|
69209
|
-
: '';
|
|
69153
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
|
|
69210
69154
|
}
|
|
69211
69155
|
if (col.template) {
|
|
69212
69156
|
value = col.template(row, indexRow) ?? '';
|
|
69213
69157
|
}
|
|
69214
69158
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("tr", { "aria-rowindex": indexRow + 1, role: "row", className: "r-row", children: [jsxRuntime.jsx("td", { className: "r-rowcell r-cell-group", colSpan: 3, children: jsxRuntime.jsxs("div", { className: "r-rowcell-div", children: [jsxRuntime.jsx(SvgChevronRight, { style: {
|
|
69215
69159
|
marginLeft: level * 20,
|
|
69216
|
-
transform: expand ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
69160
|
+
transform: expand ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
69217
69161
|
}, fontSize: 15, onClick: () => {
|
|
69218
69162
|
setExpand(!expand);
|
|
69219
69163
|
setExpandsAll(undefined);
|
|
69220
69164
|
row.expand = !expand;
|
|
69221
69165
|
} }), t(col.headerDisplay ?? col.headerText), ": ", value, " (", row.children.length, ")"] }) }), contentColumns.map((colSum, indexCol) => {
|
|
69222
|
-
if (indexCol <= firstColSpan ||
|
|
69223
|
-
colSum.visible === false ||
|
|
69224
|
-
colSum.isGroup === true) {
|
|
69166
|
+
if (indexCol <= firstColSpan || colSum.visible === false || colSum.isGroup === true) {
|
|
69225
69167
|
return;
|
|
69226
69168
|
}
|
|
69227
69169
|
let sumValue = row[colSum.field];
|
|
69228
|
-
const haveSum = row[colSum.field] !== undefined &&
|
|
69229
|
-
|
|
69230
|
-
if (!haveSum &&
|
|
69231
|
-
colSum.haveSum === true &&
|
|
69232
|
-
colSum.type === 'numeric') {
|
|
69170
|
+
const haveSum = row[colSum.field] !== undefined && row[colSum.field] !== null;
|
|
69171
|
+
if (!haveSum && colSum.haveSum === true && colSum.type === 'numeric') {
|
|
69233
69172
|
sumValue = row.children.reduce(function (accumulator, currentValue) {
|
|
69234
|
-
return
|
|
69235
|
-
Number(currentValue[colSum.field] ?? 0));
|
|
69173
|
+
return Number(accumulator ?? 0) + Number(currentValue[colSum.field] ?? 0);
|
|
69236
69174
|
}, 0);
|
|
69237
69175
|
}
|
|
69238
69176
|
if (colSum.type === 'numeric') {
|
|
69239
69177
|
sumValue = formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', colSum.numericSettings?.fraction, true, false);
|
|
69240
|
-
if (!zeroVisiable &&
|
|
69241
|
-
(sumValue === '0' || sumValue === 0)) {
|
|
69178
|
+
if (!zeroVisiable && (sumValue === '0' || sumValue === 0)) {
|
|
69242
69179
|
sumValue = '';
|
|
69243
69180
|
}
|
|
69244
69181
|
}
|
|
69245
69182
|
return (jsxRuntime.jsx("td", { className: "r-rowcell r-cell-sum-group", children: jsxRuntime.jsx("div", { className: "r-rowcell-div", style: {
|
|
69246
|
-
justifyContent: colSum.textAlign
|
|
69247
|
-
|
|
69248
|
-
: '
|
|
69249
|
-
}, children: (haveSum || colSum.haveSum === true) &&
|
|
69250
|
-
Number(row[colSum.field] ?? '0') < 0 ? (jsxRuntime.jsxs("div", { style: {
|
|
69251
|
-
color: formatSetting?.colorNegative ?? 'red',
|
|
69183
|
+
justifyContent: colSum.textAlign ? colSum.textAlign : 'left'
|
|
69184
|
+
}, children: (haveSum || colSum.haveSum === true) && Number(row[colSum.field] ?? '0') < 0 ? (jsxRuntime.jsxs("div", { style: {
|
|
69185
|
+
color: formatSetting?.colorNegative ?? 'red'
|
|
69252
69186
|
}, children: [' ', `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] })) : (sumValue) }) }, `group-sum-cell-${level}-${indexRow}-${indexCol}`));
|
|
69253
|
-
})] }), expand &&
|
|
69187
|
+
})] }), expand && jsxRuntime.jsx(RenderContent, { datas: row.children, level: level + 1 })] }, `row-${level}-${indexRow}`));
|
|
69254
69188
|
}
|
|
69255
69189
|
else {
|
|
69256
69190
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
69257
69191
|
return (jsxRuntime.jsx("tr", { id: `row-content-${indexRow}`, "aria-rowindex": indexRow + 1, role: "row", className: classNames$1('r-row', {
|
|
69258
|
-
'r-last-row': level === 0 && indexRow === viewData.length - 1
|
|
69192
|
+
'r-last-row': level === 0 && indexRow === viewData.length - 1
|
|
69259
69193
|
}), onContextMenu: (e) => {
|
|
69260
69194
|
e.preventDefault();
|
|
69261
69195
|
handleContextMenu(e, row);
|
|
@@ -69271,7 +69205,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69271
69205
|
x: e.clientX,
|
|
69272
69206
|
y: e.clientY,
|
|
69273
69207
|
row,
|
|
69274
|
-
show: true
|
|
69208
|
+
show: true
|
|
69275
69209
|
});
|
|
69276
69210
|
}, 100);
|
|
69277
69211
|
};
|
|
@@ -69286,9 +69220,9 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69286
69220
|
virtualDivRef.current.style.height = '0px';
|
|
69287
69221
|
}
|
|
69288
69222
|
}, [context]);
|
|
69289
|
-
return (jsxRuntime.jsxs("div", { className: "r-table-edit r-virtualized-table", children: [jsxRuntime.jsxs("div", { className: "r-grid", children: [toolbarSetting?.showTopToolbar &&
|
|
69223
|
+
return (jsxRuntime.jsxs("div", { className: "r-table-edit r-virtualized-table", children: [jsxRuntime.jsxs("div", { className: "r-grid", children: [toolbarSetting?.showTopToolbar && jsxRuntime.jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), headerComponent && headerComponent(), jsxRuntime.jsxs("div", { ref: gridRef, className: "r-gridtable", style: {
|
|
69290
69224
|
height: `${height ? `${height}px` : 'auto'}`,
|
|
69291
|
-
position: 'relative'
|
|
69225
|
+
position: 'relative'
|
|
69292
69226
|
}, children: [jsxRuntime.jsxs("table", { role: "presentation", style: { width: '100%' }, children: [jsxRuntime.jsx(RenderColGroup, { contentColumns: contentColumns }), jsxRuntime.jsx("thead", { className: "r-gridheader", role: "rowgroup", children: headerColumns.map((rowColumn, indexParent) => {
|
|
69293
69227
|
return (jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: rowColumn.map((col, index) => (jsxRuntime.jsx(HeaderTableCol, { col: col, idTable: idTable ?? '', dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false, objHeaderWidthFixLeft: objHeaderWidthFixLeft, objHeaderWidthFixRight: objHeaderWidthFixRight, selectEnable: true, selectedRows: selectedRows, setSelectedRows: setSelectedRows, container: gridRef, filterBy: filterBy, orderBy: orderBy, optionsFilter: querySetting?.optionsFilter, allowFiltering: querySetting?.allowFiltering, allowSorting: querySetting?.allowSorting, formatSetting: formatSetting, changeFilter: (val) => {
|
|
69294
69228
|
setFilterBy([...val]);
|
|
@@ -69307,32 +69241,22 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69307
69241
|
}
|
|
69308
69242
|
const item = columnsAggregate?.find((x) => x.field === col.field);
|
|
69309
69243
|
let sumValue = item?.value;
|
|
69310
|
-
if (!item &&
|
|
69311
|
-
col.haveSum === true &&
|
|
69312
|
-
col.type === 'numeric') {
|
|
69244
|
+
if (!item && col.haveSum === true && col.type === 'numeric') {
|
|
69313
69245
|
sumValue = viewData.reduce(function (accumulator, currentValue) {
|
|
69314
|
-
return
|
|
69315
|
-
Number(currentValue[col.field] ?? 0));
|
|
69246
|
+
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
69316
69247
|
}, 0);
|
|
69317
69248
|
}
|
|
69318
69249
|
if (col.type === 'numeric') {
|
|
69319
69250
|
sumValue = formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false);
|
|
69320
69251
|
}
|
|
69321
69252
|
return (jsxRuntime.jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
69322
|
-
left: col.fixedType === 'left'
|
|
69323
|
-
|
|
69324
|
-
|
|
69325
|
-
|
|
69326
|
-
|
|
69327
|
-
: undefined,
|
|
69328
|
-
textAlign: col.textAlign ? col.textAlign : 'left',
|
|
69329
|
-
}, children: jsxRuntime.jsx("div", { className: "r-footer-div", children: (item || col.haveSum === true) &&
|
|
69330
|
-
Number(item?.value ?? '0') < 0 ? (jsxRuntime.jsxs("div", { style: {
|
|
69331
|
-
color: formatSetting?.colorNegative ?? 'red',
|
|
69253
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
69254
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
69255
|
+
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
69256
|
+
}, children: jsxRuntime.jsx("div", { className: "r-footer-div", children: (item || col.haveSum === true) && Number(item?.value ?? '0') < 0 ? (jsxRuntime.jsxs("div", { style: {
|
|
69257
|
+
color: formatSetting?.colorNegative ?? 'red'
|
|
69332
69258
|
}, children: [' ', `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] })) : (sumValue) }) }, `summarycell-${indexCol}`));
|
|
69333
|
-
}) })) })] }), jsxRuntime.jsx("div", { ref: virtualDivRef }), context &&
|
|
69334
|
-
(contextMenuItems?.length ?? 0) > 0 &&
|
|
69335
|
-
handleContextMenuClick && (jsxRuntime.jsx(Popover$1, { className: "r-context-popover", placement: "right-start", isOpen: context.show, target: virtualDivRef.current, toggle: handleCloseContext, fade: false, children: jsxRuntime.jsx(PopoverBody$1, { children: contextMenuItems?.map((item, index) => {
|
|
69259
|
+
}) })) })] }), jsxRuntime.jsx("div", { ref: virtualDivRef }), context && (contextMenuItems?.length ?? 0) > 0 && handleContextMenuClick && (jsxRuntime.jsx(Popover$1, { className: "r-context-popover", placement: "right-start", isOpen: context.show, target: virtualDivRef.current, toggle: handleCloseContext, fade: false, children: jsxRuntime.jsx(PopoverBody$1, { children: contextMenuItems?.map((item, index) => {
|
|
69336
69260
|
return (jsxRuntime.jsxs("div", { className: "r-context-item", onClick: () => {
|
|
69337
69261
|
handleCloseContext();
|
|
69338
69262
|
handleContextMenuClick?.(item, context.row);
|
|
@@ -69347,7 +69271,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69347
69271
|
visible: x.visible,
|
|
69348
69272
|
fixedType: x.fixedType,
|
|
69349
69273
|
width: x.width,
|
|
69350
|
-
sortOrder: index + 1
|
|
69274
|
+
sortOrder: index + 1
|
|
69351
69275
|
})));
|
|
69352
69276
|
}
|
|
69353
69277
|
} })] }));
|