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.mjs
CHANGED
|
@@ -68708,21 +68708,32 @@ const UnExpandAllIcon = ({ className, color = '#7F7F7F', size = 24, onClick, sty
|
|
|
68708
68708
|
};
|
|
68709
68709
|
|
|
68710
68710
|
const RenderContentCol = (props) => {
|
|
68711
|
-
const { col, indexCol, indexRow, isSelected, row, zeroVisiable, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, setSelectedRows, handleCloseContext, handleDoubleClick, fieldKey, isMulti
|
|
68711
|
+
const { col, indexCol, indexRow, isSelected, row, zeroVisiable, formatSetting, idTable, fisrtObjWidthFixRight, lastObjWidthFixLeft, objWidthFixLeft, objWidthFixRight, selectedRows, setSelectedRows, handleCloseContext, handleDoubleClick, fieldKey, isMulti } = props;
|
|
68712
68712
|
const cellId = `content-${idTable}-row${indexRow}col-${indexCol}`;
|
|
68713
68713
|
const checkOverflow = () => {
|
|
68714
68714
|
const element = document.getElementById(cellId);
|
|
68715
68715
|
return element && element.scrollWidth > element.clientWidth;
|
|
68716
68716
|
};
|
|
68717
|
+
const toggleSelect = () => {
|
|
68718
|
+
const idx = selectedRows?.findIndex((x) => x?.[fieldKey] === row?.[fieldKey]);
|
|
68719
|
+
if (idx > -1) {
|
|
68720
|
+
if (isMulti) {
|
|
68721
|
+
return selectedRows?.filter((_, i) => i !== idx);
|
|
68722
|
+
}
|
|
68723
|
+
return [];
|
|
68724
|
+
}
|
|
68725
|
+
if (isMulti) {
|
|
68726
|
+
return [...selectedRows, row];
|
|
68727
|
+
}
|
|
68728
|
+
return [row];
|
|
68729
|
+
};
|
|
68717
68730
|
const RenderElement = () => {
|
|
68718
68731
|
if (col.field === '#' || col.type === '#') {
|
|
68719
68732
|
return (jsx("div", { className: classNames$1('r-rowcell-div cursor-pointer text-center', {
|
|
68720
|
-
'r-active-cell': isSelected
|
|
68733
|
+
'r-active-cell': isSelected
|
|
68721
68734
|
}), style: {
|
|
68722
|
-
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType
|
|
68723
|
-
|
|
68724
|
-
: 400,
|
|
68725
|
-
fontStyle: row.haveItalicType ? 'italic' : 'normal',
|
|
68735
|
+
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType ? 600 : 400,
|
|
68736
|
+
fontStyle: row.haveItalicType ? 'italic' : 'normal'
|
|
68726
68737
|
}, onDoubleClick: (e) => {
|
|
68727
68738
|
e.preventDefault();
|
|
68728
68739
|
handleCloseContext();
|
|
@@ -68731,34 +68742,13 @@ const RenderContentCol = (props) => {
|
|
|
68731
68742
|
}
|
|
68732
68743
|
else if (col.type === 'checkbox' || col.field === 'checkbox') {
|
|
68733
68744
|
return (jsx("div", { className: classNames$1('r-rowcell-div cursor-pointer', {
|
|
68734
|
-
'r-active-cell': isSelected
|
|
68745
|
+
'r-active-cell': isSelected
|
|
68735
68746
|
}), style: {
|
|
68736
68747
|
display: 'flex',
|
|
68737
|
-
justifyContent: col.textAlign === 'center'
|
|
68738
|
-
|
|
68739
|
-
: col.textAlign === 'right'
|
|
68740
|
-
? 'flex-end'
|
|
68741
|
-
: 'flex-start',
|
|
68742
|
-
alignItems: 'center',
|
|
68748
|
+
justifyContent: col.textAlign === 'center' ? 'center' : col.textAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
68749
|
+
alignItems: 'center'
|
|
68743
68750
|
}, onClick: (e) => {
|
|
68744
|
-
|
|
68745
|
-
if (index > -1) {
|
|
68746
|
-
if (isMulti) {
|
|
68747
|
-
selectedRows?.splice(index, 1);
|
|
68748
|
-
setSelectedRows([...selectedRows]);
|
|
68749
|
-
}
|
|
68750
|
-
else {
|
|
68751
|
-
setSelectedRows([]);
|
|
68752
|
-
}
|
|
68753
|
-
}
|
|
68754
|
-
else {
|
|
68755
|
-
if (isMulti) {
|
|
68756
|
-
setSelectedRows([...selectedRows, row]);
|
|
68757
|
-
}
|
|
68758
|
-
else {
|
|
68759
|
-
setSelectedRows([row]);
|
|
68760
|
-
}
|
|
68761
|
-
}
|
|
68751
|
+
setSelectedRows(toggleSelect());
|
|
68762
68752
|
e.stopPropagation();
|
|
68763
68753
|
}, children: jsx(Input$1, { defaultChecked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? 'center' } }) }));
|
|
68764
68754
|
}
|
|
@@ -68766,11 +68756,8 @@ const RenderContentCol = (props) => {
|
|
|
68766
68756
|
let value = row[col.field];
|
|
68767
68757
|
// ✅ Format dữ liệu theo loại cột
|
|
68768
68758
|
if (col.type === 'numeric') {
|
|
68769
|
-
value =
|
|
68770
|
-
|
|
68771
|
-
if (!zeroVisiable &&
|
|
68772
|
-
!(row?.sortOrder < 0 || row?.sortOrder > 100000) &&
|
|
68773
|
-
(value === '0' || value === 0)) {
|
|
68759
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
68760
|
+
if (!zeroVisiable && !(row?.sortOrder < 0 || row?.sortOrder > 100000) && (value === '0' || value === 0)) {
|
|
68774
68761
|
value = '';
|
|
68775
68762
|
}
|
|
68776
68763
|
}
|
|
@@ -68778,88 +68765,75 @@ const RenderContentCol = (props) => {
|
|
|
68778
68765
|
value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
|
|
68779
68766
|
}
|
|
68780
68767
|
else if (col.type === 'datetime') {
|
|
68781
|
-
value = value
|
|
68782
|
-
? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm')
|
|
68783
|
-
: '';
|
|
68768
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
|
|
68784
68769
|
}
|
|
68785
68770
|
if (col.template) {
|
|
68786
68771
|
value = col.template(row, indexRow) ?? '';
|
|
68787
68772
|
}
|
|
68788
68773
|
const isNegative = col.type === 'numeric' && Number(row[col.field]) < 0;
|
|
68789
|
-
const textColor = isNegative
|
|
68790
|
-
|
|
68791
|
-
|
|
68792
|
-
const
|
|
68793
|
-
const suffix = isNegative ? (formatSetting?.suffixNegative ?? '') : '';
|
|
68794
|
-
const displayText = isNegative
|
|
68795
|
-
? `${prefix}${value}${suffix}`
|
|
68796
|
-
: (value ?? '');
|
|
68774
|
+
const textColor = isNegative ? formatSetting?.colorNegative ?? 'red' : undefined;
|
|
68775
|
+
const prefix = isNegative ? formatSetting?.prefixNegative ?? '-' : '';
|
|
68776
|
+
const suffix = isNegative ? formatSetting?.suffixNegative ?? '' : '';
|
|
68777
|
+
const displayText = isNegative ? `${prefix}${value}${suffix}` : value ?? '';
|
|
68797
68778
|
return (jsxs("div", { className: classNames$1('r-rowcell-div cursor-pointer', {
|
|
68798
|
-
'r-active-cell': isSelected
|
|
68779
|
+
'r-active-cell': isSelected
|
|
68799
68780
|
}), style: {
|
|
68800
|
-
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType
|
|
68801
|
-
|
|
68802
|
-
: 400,
|
|
68803
|
-
fontStyle: row.haveItalicType ? 'italic' : 'normal',
|
|
68804
|
-
}, onDoubleClick: (e) => {
|
|
68805
|
-
e.preventDefault();
|
|
68806
|
-
handleCloseContext();
|
|
68807
|
-
handleDoubleClick?.(row, col);
|
|
68781
|
+
fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType ? 600 : 400,
|
|
68782
|
+
fontStyle: row.haveItalicType ? 'italic' : 'normal'
|
|
68808
68783
|
}, children: [jsx("div", { className: "r-cell-text", style: {
|
|
68809
68784
|
display: 'flex',
|
|
68810
|
-
justifyContent: col.textAlign === 'center'
|
|
68811
|
-
|
|
68812
|
-
: col.textAlign === 'right'
|
|
68813
|
-
? 'flex-end'
|
|
68814
|
-
: 'flex-start',
|
|
68815
|
-
alignItems: 'center',
|
|
68785
|
+
justifyContent: col.textAlign === 'center' ? 'center' : col.textAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
68786
|
+
alignItems: 'center'
|
|
68816
68787
|
}, children: jsx("div", { id: cellId, style: {
|
|
68817
68788
|
color: textColor,
|
|
68818
68789
|
overflow: 'hidden',
|
|
68819
68790
|
textOverflow: 'ellipsis',
|
|
68820
68791
|
whiteSpace: 'pre',
|
|
68821
|
-
maxWidth: '100%'
|
|
68792
|
+
maxWidth: '100%'
|
|
68822
68793
|
}, children: displayText }) }), checkOverflow() && (jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: cellId, placement: "top", children: jsx("div", { style: { color: textColor }, onClick: (e) => {
|
|
68823
68794
|
e.stopPropagation();
|
|
68824
68795
|
e.preventDefault();
|
|
68825
68796
|
}, children: displayText }) }))] }));
|
|
68826
68797
|
}
|
|
68827
68798
|
};
|
|
68799
|
+
const clickTimerRef = useRef(null);
|
|
68828
68800
|
return (jsx(Fragment$1, { children: col.visible !== false && col.isGroup !== true && (jsx("td", { className: classNames$1(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, {
|
|
68829
|
-
'fixed-last': (col.fixedType === 'left' &&
|
|
68830
|
-
indexCol === lastObjWidthFixLeft) ||
|
|
68831
|
-
(col.fixedType === 'right' &&
|
|
68832
|
-
indexCol === fisrtObjWidthFixRight),
|
|
68801
|
+
'fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight)
|
|
68833
68802
|
}, { 'r-active': isSelected }), style: {
|
|
68834
68803
|
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
68835
|
-
right: col.fixedType === 'right'
|
|
68836
|
-
? objWidthFixRight[indexCol]
|
|
68837
|
-
: undefined,
|
|
68804
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined
|
|
68838
68805
|
}, onClick: (e) => {
|
|
68839
|
-
|
|
68840
|
-
|
|
68841
|
-
|
|
68842
|
-
|
|
68843
|
-
|
|
68844
|
-
|
|
68845
|
-
|
|
68846
|
-
|
|
68847
|
-
|
|
68848
|
-
|
|
68849
|
-
|
|
68850
|
-
|
|
68851
|
-
|
|
68852
|
-
|
|
68853
|
-
|
|
68854
|
-
|
|
68855
|
-
setSelectedRows([row]);
|
|
68856
|
-
}
|
|
68857
|
-
}
|
|
68806
|
+
const tag = e.target?.nodeName;
|
|
68807
|
+
if (tag !== 'DIV' && tag !== 'TD') {
|
|
68808
|
+
return;
|
|
68809
|
+
}
|
|
68810
|
+
if (clickTimerRef.current) {
|
|
68811
|
+
window.clearTimeout(clickTimerRef.current);
|
|
68812
|
+
}
|
|
68813
|
+
if (handleDoubleClick) {
|
|
68814
|
+
clickTimerRef.current = window.setTimeout(() => {
|
|
68815
|
+
setSelectedRows(toggleSelect());
|
|
68816
|
+
clickTimerRef.current = null;
|
|
68817
|
+
}, 200);
|
|
68818
|
+
}
|
|
68819
|
+
else {
|
|
68820
|
+
setSelectedRows(toggleSelect());
|
|
68821
|
+
clickTimerRef.current = null;
|
|
68858
68822
|
}
|
|
68823
|
+
}, onDoubleClick: (e) => {
|
|
68824
|
+
// hủy single click pending để không đổi style trước
|
|
68825
|
+
if (clickTimerRef.current) {
|
|
68826
|
+
window.clearTimeout(clickTimerRef.current);
|
|
68827
|
+
}
|
|
68828
|
+
clickTimerRef.current = null;
|
|
68829
|
+
handleCloseContext();
|
|
68830
|
+
handleDoubleClick?.(row, col);
|
|
68831
|
+
e.preventDefault();
|
|
68832
|
+
e.stopPropagation();
|
|
68859
68833
|
}, children: RenderElement() }, `col-${indexRow}-${indexCol}`)) }));
|
|
68860
68834
|
};
|
|
68861
68835
|
|
|
68862
|
-
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
|
|
68836
|
+
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 }) => {
|
|
68863
68837
|
const { t } = useTranslation();
|
|
68864
68838
|
const gridRef = useRef(null);
|
|
68865
68839
|
const [openPopupSetupColumn, setOpenPopupSetupColumn] = useState(false);
|
|
@@ -68867,8 +68841,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68867
68841
|
const [orderBy, setOrderBy] = useState([]);
|
|
68868
68842
|
const [filterBy, setFilterBy] = useState([]);
|
|
68869
68843
|
const [searchTerm, setSearchTerm] = useState('');
|
|
68870
|
-
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ??
|
|
68871
|
-
'id';
|
|
68844
|
+
const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? 'id';
|
|
68872
68845
|
const [contentColumns, setContentColumns] = useState([]);
|
|
68873
68846
|
const [groupColumns, setGroupColumns] = useState([]);
|
|
68874
68847
|
const [expandsAll, setExpandsAll] = useState(true);
|
|
@@ -68887,7 +68860,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68887
68860
|
}
|
|
68888
68861
|
setExpandsAll(true);
|
|
68889
68862
|
}, [groupSetting?.groupColumns]);
|
|
68890
|
-
const { levels: headerColumns, objHeaderWidthFixLeft, objHeaderWidthFixRight, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight
|
|
68863
|
+
const { levels: headerColumns, objHeaderWidthFixLeft, objHeaderWidthFixRight, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight } = useMemo(() => {
|
|
68891
68864
|
const rs = calculateTableStructure(columns, settingColumns?.value, groupSetting?.groupColumns);
|
|
68892
68865
|
setContentColumns(rs.flat);
|
|
68893
68866
|
return rs;
|
|
@@ -68916,10 +68889,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68916
68889
|
if (searchTerm) {
|
|
68917
68890
|
datas = datas.filter((row) => {
|
|
68918
68891
|
return searchSetting?.keyField?.some((key) => {
|
|
68919
|
-
return row[key]
|
|
68920
|
-
?.toString()
|
|
68921
|
-
.toLowerCase()
|
|
68922
|
-
.includes(searchTerm.trim().toLowerCase());
|
|
68892
|
+
return row[key]?.toString().toLowerCase().includes(searchTerm.trim().toLowerCase());
|
|
68923
68893
|
});
|
|
68924
68894
|
});
|
|
68925
68895
|
}
|
|
@@ -68928,10 +68898,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68928
68898
|
return filterBy.every((filter) => {
|
|
68929
68899
|
const { key, value, ope } = filter;
|
|
68930
68900
|
const rowValue = row[key];
|
|
68931
|
-
if (rowValue === undefined ||
|
|
68932
|
-
rowValue === null ||
|
|
68933
|
-
value === undefined ||
|
|
68934
|
-
value === null) {
|
|
68901
|
+
if (rowValue === undefined || rowValue === null || value === undefined || value === null) {
|
|
68935
68902
|
return false;
|
|
68936
68903
|
}
|
|
68937
68904
|
const valStr = String(rowValue).toLowerCase();
|
|
@@ -68994,17 +68961,12 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
68994
68961
|
}
|
|
68995
68962
|
};
|
|
68996
68963
|
const searchTemplate = () => {
|
|
68997
|
-
return (jsx("div", { className: "me-50 r-search", children: jsx(ReactInput, { style: { width: '230px' }, value: searchSetting?.searchTerm !== undefined
|
|
68998
|
-
? searchSetting?.searchTerm
|
|
68999
|
-
: searchTerm, setSearchTerm: searchSetting?.setSearchTerm
|
|
69000
|
-
? searchSetting?.setSearchTerm
|
|
69001
|
-
: setSearchTerm, placeholder: t('Search'), onKeyPress: handleKeyPress }) }));
|
|
68964
|
+
return (jsx("div", { className: "me-50 r-search", children: jsx(ReactInput, { style: { width: '230px' }, value: searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm, setSearchTerm: searchSetting?.setSearchTerm ? searchSetting?.setSearchTerm : setSearchTerm, placeholder: t('Search'), onKeyPress: handleKeyPress }) }));
|
|
69002
68965
|
};
|
|
69003
68966
|
const groupbtnTemplate = () => {
|
|
69004
68967
|
return (jsxs(UncontrolledDropdown, { children: [jsx(DropdownToggle$1, { tag: "div", id: "group-dropdown-toggle", style: { position: 'relative' }, onClick: (e) => e.preventDefault(), children: jsx(GroupIcon, { color: "#7F7F7F", size: 24 }) }), jsxs(DropdownMenu$1, { className: "formula-dropdown icon-dropdown p-1", children: [jsx("div", { className: "mb-1", style: { fontSize: 16, fontWeight: 500 }, children: "Nh\u00F3m d\u1EEF li\u1EC7u theo c\u1ED9t" }), jsxs("div", { className: 'form-group', children: [jsx(Label$1, { id: `label-group-1`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 1" }), jsx("div", { className: "form-input", children: jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[0]
|
|
69005
68968
|
? {
|
|
69006
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[0])?.headerText ??
|
|
69007
|
-
contentColumns.find((x) => x.field === groupColumns[0])?.headerText),
|
|
68969
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[0])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[0])?.headerText)
|
|
69008
68970
|
}
|
|
69009
68971
|
: undefined, onChange: (val) => {
|
|
69010
68972
|
if (val) {
|
|
@@ -69016,8 +68978,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69016
68978
|
setGroupColumns([...groupColumns]);
|
|
69017
68979
|
}, isClearable: groupColumns?.length === 1 }) })] }), jsxs("div", { className: 'form-group', children: [jsx(Label$1, { id: `label-group-2`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 2" }), jsx("div", { className: "form-input", children: jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[1]
|
|
69018
68980
|
? {
|
|
69019
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[1])?.headerText ??
|
|
69020
|
-
contentColumns.find((x) => x.field === groupColumns[1])?.headerText),
|
|
68981
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[1])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[1])?.headerText)
|
|
69021
68982
|
}
|
|
69022
68983
|
: undefined, onChange: (val) => {
|
|
69023
68984
|
if (val) {
|
|
@@ -69029,8 +68990,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69029
68990
|
setGroupColumns([...groupColumns]);
|
|
69030
68991
|
}, isClearable: groupColumns?.length === 2 }) })] }), jsxs("div", { className: 'form-group', children: [jsx(Label$1, { id: `label-group-3`, style: { fontWeight: 500, fontSize: 13 }, children: "M\u1EE9c 3" }), jsx("div", { className: "form-input", children: jsx(SelectTable, { options: contentColumns, fieldLabel: 'headerText', fieldValue: 'field', value: groupColumns[2]
|
|
69031
68992
|
? {
|
|
69032
|
-
headerText: t(contentColumns.find((x) => x.field === groupColumns[2])?.headerText ??
|
|
69033
|
-
contentColumns.find((x) => x.field === groupColumns[2])?.headerText),
|
|
68993
|
+
headerText: t(contentColumns.find((x) => x.field === groupColumns[2])?.headerText ?? contentColumns.find((x) => x.field === groupColumns[2])?.headerText)
|
|
69034
68994
|
}
|
|
69035
68995
|
: undefined, onChange: (val) => {
|
|
69036
68996
|
if (groupSetting) {
|
|
@@ -69044,7 +69004,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69044
69004
|
}
|
|
69045
69005
|
}, isClearable: groupColumns?.length === 3 }) })] }), jsxs("div", { className: "border-top d-flex justify-content-end mt-1", children: [jsx(Button$1$1, { color: "primary", className: "mt-1 me-50 rounded", size: "sm", onClick: () => {
|
|
69046
69006
|
groupSetting?.onGroup({
|
|
69047
|
-
columnGrouped: groupColumns.filter((x) => x)
|
|
69007
|
+
columnGrouped: groupColumns.filter((x) => x)
|
|
69048
69008
|
});
|
|
69049
69009
|
document.getElementById('group-dropdown-toggle')?.click();
|
|
69050
69010
|
}, children: `${t('Apply')}` }), jsx(Button$1$1, { color: "secondary", outline: true, className: "mt-1 rounded", size: "sm", onClick: () => {
|
|
@@ -69053,16 +69013,14 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69053
69013
|
}, children: `${t('Delete')}` })] })] })] }));
|
|
69054
69014
|
};
|
|
69055
69015
|
const chooseColumnsTemplate = () => {
|
|
69056
|
-
return
|
|
69016
|
+
return jsx(SvgSettings, { className: "r-toolbar-icon", fontSize: 20, color: "#7F7F7F", onClick: () => setOpenPopupSetupColumn(true) });
|
|
69057
69017
|
};
|
|
69058
69018
|
const expandTemplate = () => {
|
|
69059
69019
|
return (jsxs(Fragment$1, { children: [!expandsAll && (jsx(ExpandAllIcon, { onClick: () => {
|
|
69060
69020
|
setExpandsAll(true);
|
|
69061
|
-
}, color: "#7F7F7F", size: 24 })), expandsAll &&
|
|
69021
|
+
}, color: "#7F7F7F", size: 24 })), expandsAll && jsx(UnExpandAllIcon, { onClick: () => setExpandsAll(false), color: "#7F7F7F", size: 24 })] }));
|
|
69062
69022
|
};
|
|
69063
|
-
const defaultToolbarOption = searchSetting?.searchEnable
|
|
69064
|
-
? [{ template: searchTemplate, align: 'left' }]
|
|
69065
|
-
: [];
|
|
69023
|
+
const defaultToolbarOption = searchSetting?.searchEnable ? [{ template: searchTemplate, align: 'left' }] : [];
|
|
69066
69024
|
if (groupSetting) {
|
|
69067
69025
|
defaultToolbarOption.push({ template: groupbtnTemplate, align: 'left' });
|
|
69068
69026
|
}
|
|
@@ -69071,10 +69029,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69071
69029
|
}
|
|
69072
69030
|
let toolbarTopOption = [];
|
|
69073
69031
|
if (toolbarSetting?.toolbarOptions) {
|
|
69074
|
-
toolbarTopOption = [
|
|
69075
|
-
...defaultToolbarOption,
|
|
69076
|
-
...toolbarSetting?.toolbarOptions,
|
|
69077
|
-
];
|
|
69032
|
+
toolbarTopOption = [...defaultToolbarOption, ...toolbarSetting?.toolbarOptions];
|
|
69078
69033
|
}
|
|
69079
69034
|
else {
|
|
69080
69035
|
toolbarTopOption = [...defaultToolbarOption];
|
|
@@ -69105,9 +69060,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69105
69060
|
useEffect(() => {
|
|
69106
69061
|
if (setSelectedItem) {
|
|
69107
69062
|
if (isMulti) {
|
|
69108
|
-
if (dataSource &&
|
|
69109
|
-
selectedRows &&
|
|
69110
|
-
selectedRows?.length !== selectedItem?.length) {
|
|
69063
|
+
if (dataSource && selectedRows && selectedRows?.length !== selectedItem?.length) {
|
|
69111
69064
|
setSelectedItem([...selectedRows]);
|
|
69112
69065
|
if (handleSelect) {
|
|
69113
69066
|
handleSelect([...selectedRows]);
|
|
@@ -69116,8 +69069,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69116
69069
|
}
|
|
69117
69070
|
else {
|
|
69118
69071
|
if (dataSource && selectedRows?.length > 0) {
|
|
69119
|
-
if (!selectedItem ||
|
|
69120
|
-
selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69072
|
+
if (!selectedItem || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69121
69073
|
setSelectedItem({ ...selectedRows[0] });
|
|
69122
69074
|
if (handleSelect) {
|
|
69123
69075
|
handleSelect({ ...selectedRows[0] });
|
|
@@ -69136,8 +69088,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69136
69088
|
useEffect(() => {
|
|
69137
69089
|
if (!isMulti) {
|
|
69138
69090
|
if (dataSource && selectedItem && selectedItem[fieldKey]) {
|
|
69139
|
-
if (selectedRows?.length === 0 ||
|
|
69140
|
-
selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69091
|
+
if (selectedRows?.length === 0 || selectedItem[fieldKey] !== selectedRows[0][fieldKey]) {
|
|
69141
69092
|
setSelectedRows([selectedItem]);
|
|
69142
69093
|
}
|
|
69143
69094
|
}
|
|
@@ -69146,9 +69097,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69146
69097
|
}
|
|
69147
69098
|
}
|
|
69148
69099
|
else {
|
|
69149
|
-
if (dataSource &&
|
|
69150
|
-
selectedItem &&
|
|
69151
|
-
selectedRows?.length !== selectedItem.length) {
|
|
69100
|
+
if (dataSource && selectedItem && selectedRows?.length !== selectedItem.length) {
|
|
69152
69101
|
setSelectedRows(selectedItem ? [...selectedItem] : []);
|
|
69153
69102
|
}
|
|
69154
69103
|
}
|
|
@@ -69166,67 +69115,52 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69166
69115
|
const col = contentColumns.find((x) => x.field === row.field);
|
|
69167
69116
|
let value = row[col.field];
|
|
69168
69117
|
if (col.type === 'numeric') {
|
|
69169
|
-
value =
|
|
69170
|
-
formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
69118
|
+
value = formartNumberic(row[col.field], formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) ?? 0;
|
|
69171
69119
|
}
|
|
69172
69120
|
else if (col.type === 'date') {
|
|
69173
|
-
value = value
|
|
69174
|
-
? formatDateTime(value, formatSetting?.dateFormat)
|
|
69175
|
-
: '';
|
|
69121
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat) : '';
|
|
69176
69122
|
}
|
|
69177
69123
|
else if (col.type === 'datetime') {
|
|
69178
|
-
value = value
|
|
69179
|
-
? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm')
|
|
69180
|
-
: '';
|
|
69124
|
+
value = value ? formatDateTime(value, formatSetting?.dateFormat ?? 'DD/MM/yyyy HH:mm') : '';
|
|
69181
69125
|
}
|
|
69182
69126
|
if (col.template) {
|
|
69183
69127
|
value = col.template(row, indexRow) ?? '';
|
|
69184
69128
|
}
|
|
69185
69129
|
return (jsxs(Fragment$1, { children: [jsxs("tr", { "aria-rowindex": indexRow + 1, role: "row", className: "r-row", children: [jsx("td", { className: "r-rowcell r-cell-group", colSpan: 3, children: jsxs("div", { className: "r-rowcell-div", children: [jsx(SvgChevronRight, { style: {
|
|
69186
69130
|
marginLeft: level * 20,
|
|
69187
|
-
transform: expand ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
69131
|
+
transform: expand ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
69188
69132
|
}, fontSize: 15, onClick: () => {
|
|
69189
69133
|
setExpand(!expand);
|
|
69190
69134
|
setExpandsAll(undefined);
|
|
69191
69135
|
row.expand = !expand;
|
|
69192
69136
|
} }), t(col.headerDisplay ?? col.headerText), ": ", value, " (", row.children.length, ")"] }) }), contentColumns.map((colSum, indexCol) => {
|
|
69193
|
-
if (indexCol <= firstColSpan ||
|
|
69194
|
-
colSum.visible === false ||
|
|
69195
|
-
colSum.isGroup === true) {
|
|
69137
|
+
if (indexCol <= firstColSpan || colSum.visible === false || colSum.isGroup === true) {
|
|
69196
69138
|
return;
|
|
69197
69139
|
}
|
|
69198
69140
|
let sumValue = row[colSum.field];
|
|
69199
|
-
const haveSum = row[colSum.field] !== undefined &&
|
|
69200
|
-
|
|
69201
|
-
if (!haveSum &&
|
|
69202
|
-
colSum.haveSum === true &&
|
|
69203
|
-
colSum.type === 'numeric') {
|
|
69141
|
+
const haveSum = row[colSum.field] !== undefined && row[colSum.field] !== null;
|
|
69142
|
+
if (!haveSum && colSum.haveSum === true && colSum.type === 'numeric') {
|
|
69204
69143
|
sumValue = row.children.reduce(function (accumulator, currentValue) {
|
|
69205
|
-
return
|
|
69206
|
-
Number(currentValue[colSum.field] ?? 0));
|
|
69144
|
+
return Number(accumulator ?? 0) + Number(currentValue[colSum.field] ?? 0);
|
|
69207
69145
|
}, 0);
|
|
69208
69146
|
}
|
|
69209
69147
|
if (colSum.type === 'numeric') {
|
|
69210
69148
|
sumValue = formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', colSum.numericSettings?.fraction, true, false);
|
|
69211
|
-
if (!zeroVisiable &&
|
|
69212
|
-
(sumValue === '0' || sumValue === 0)) {
|
|
69149
|
+
if (!zeroVisiable && (sumValue === '0' || sumValue === 0)) {
|
|
69213
69150
|
sumValue = '';
|
|
69214
69151
|
}
|
|
69215
69152
|
}
|
|
69216
69153
|
return (jsx("td", { className: "r-rowcell r-cell-sum-group", children: jsx("div", { className: "r-rowcell-div", style: {
|
|
69217
|
-
justifyContent: colSum.textAlign
|
|
69218
|
-
|
|
69219
|
-
: '
|
|
69220
|
-
}, children: (haveSum || colSum.haveSum === true) &&
|
|
69221
|
-
Number(row[colSum.field] ?? '0') < 0 ? (jsxs("div", { style: {
|
|
69222
|
-
color: formatSetting?.colorNegative ?? 'red',
|
|
69154
|
+
justifyContent: colSum.textAlign ? colSum.textAlign : 'left'
|
|
69155
|
+
}, children: (haveSum || colSum.haveSum === true) && Number(row[colSum.field] ?? '0') < 0 ? (jsxs("div", { style: {
|
|
69156
|
+
color: formatSetting?.colorNegative ?? 'red'
|
|
69223
69157
|
}, children: [' ', `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] })) : (sumValue) }) }, `group-sum-cell-${level}-${indexRow}-${indexCol}`));
|
|
69224
|
-
})] }), expand &&
|
|
69158
|
+
})] }), expand && jsx(RenderContent, { datas: row.children, level: level + 1 })] }, `row-${level}-${indexRow}`));
|
|
69225
69159
|
}
|
|
69226
69160
|
else {
|
|
69227
69161
|
const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
|
|
69228
69162
|
return (jsx("tr", { id: `row-content-${indexRow}`, "aria-rowindex": indexRow + 1, role: "row", className: classNames$1('r-row', {
|
|
69229
|
-
'r-last-row': level === 0 && indexRow === viewData.length - 1
|
|
69163
|
+
'r-last-row': level === 0 && indexRow === viewData.length - 1
|
|
69230
69164
|
}), onContextMenu: (e) => {
|
|
69231
69165
|
e.preventDefault();
|
|
69232
69166
|
handleContextMenu(e, row);
|
|
@@ -69242,7 +69176,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69242
69176
|
x: e.clientX,
|
|
69243
69177
|
y: e.clientY,
|
|
69244
69178
|
row,
|
|
69245
|
-
show: true
|
|
69179
|
+
show: true
|
|
69246
69180
|
});
|
|
69247
69181
|
}, 100);
|
|
69248
69182
|
};
|
|
@@ -69257,9 +69191,9 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69257
69191
|
virtualDivRef.current.style.height = '0px';
|
|
69258
69192
|
}
|
|
69259
69193
|
}, [context]);
|
|
69260
|
-
return (jsxs("div", { className: "r-table-edit r-virtualized-table", children: [jsxs("div", { className: "r-grid", children: [toolbarSetting?.showTopToolbar &&
|
|
69194
|
+
return (jsxs("div", { className: "r-table-edit r-virtualized-table", children: [jsxs("div", { className: "r-grid", children: [toolbarSetting?.showTopToolbar && jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), headerComponent && headerComponent(), jsxs("div", { ref: gridRef, className: "r-gridtable", style: {
|
|
69261
69195
|
height: `${height ? `${height}px` : 'auto'}`,
|
|
69262
|
-
position: 'relative'
|
|
69196
|
+
position: 'relative'
|
|
69263
69197
|
}, children: [jsxs("table", { role: "presentation", style: { width: '100%' }, children: [jsx(RenderColGroup, { contentColumns: contentColumns }), jsx("thead", { className: "r-gridheader", role: "rowgroup", children: headerColumns.map((rowColumn, indexParent) => {
|
|
69264
69198
|
return (jsx("tr", { className: "r-row", role: "row", children: rowColumn.map((col, index) => (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) => {
|
|
69265
69199
|
setFilterBy([...val]);
|
|
@@ -69278,32 +69212,22 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69278
69212
|
}
|
|
69279
69213
|
const item = columnsAggregate?.find((x) => x.field === col.field);
|
|
69280
69214
|
let sumValue = item?.value;
|
|
69281
|
-
if (!item &&
|
|
69282
|
-
col.haveSum === true &&
|
|
69283
|
-
col.type === 'numeric') {
|
|
69215
|
+
if (!item && col.haveSum === true && col.type === 'numeric') {
|
|
69284
69216
|
sumValue = viewData.reduce(function (accumulator, currentValue) {
|
|
69285
|
-
return
|
|
69286
|
-
Number(currentValue[col.field] ?? 0));
|
|
69217
|
+
return Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0);
|
|
69287
69218
|
}, 0);
|
|
69288
69219
|
}
|
|
69289
69220
|
if (col.type === 'numeric') {
|
|
69290
69221
|
sumValue = formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false);
|
|
69291
69222
|
}
|
|
69292
69223
|
return (jsx("td", { className: classNames$1(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
69293
|
-
left: col.fixedType === 'left'
|
|
69294
|
-
|
|
69295
|
-
|
|
69296
|
-
|
|
69297
|
-
|
|
69298
|
-
: undefined,
|
|
69299
|
-
textAlign: col.textAlign ? col.textAlign : 'left',
|
|
69300
|
-
}, children: jsx("div", { className: "r-footer-div", children: (item || col.haveSum === true) &&
|
|
69301
|
-
Number(item?.value ?? '0') < 0 ? (jsxs("div", { style: {
|
|
69302
|
-
color: formatSetting?.colorNegative ?? 'red',
|
|
69224
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
69225
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
69226
|
+
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
69227
|
+
}, children: jsx("div", { className: "r-footer-div", children: (item || col.haveSum === true) && Number(item?.value ?? '0') < 0 ? (jsxs("div", { style: {
|
|
69228
|
+
color: formatSetting?.colorNegative ?? 'red'
|
|
69303
69229
|
}, children: [' ', `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] })) : (sumValue) }) }, `summarycell-${indexCol}`));
|
|
69304
|
-
}) })) })] }), jsx("div", { ref: virtualDivRef }), context &&
|
|
69305
|
-
(contextMenuItems?.length ?? 0) > 0 &&
|
|
69306
|
-
handleContextMenuClick && (jsx(Popover$1, { className: "r-context-popover", placement: "right-start", isOpen: context.show, target: virtualDivRef.current, toggle: handleCloseContext, fade: false, children: jsx(PopoverBody$1, { children: contextMenuItems?.map((item, index) => {
|
|
69230
|
+
}) })) })] }), jsx("div", { ref: virtualDivRef }), context && (contextMenuItems?.length ?? 0) > 0 && handleContextMenuClick && (jsx(Popover$1, { className: "r-context-popover", placement: "right-start", isOpen: context.show, target: virtualDivRef.current, toggle: handleCloseContext, fade: false, children: jsx(PopoverBody$1, { children: contextMenuItems?.map((item, index) => {
|
|
69307
69231
|
return (jsxs("div", { className: "r-context-item", onClick: () => {
|
|
69308
69232
|
handleCloseContext();
|
|
69309
69233
|
handleContextMenuClick?.(item, context.row);
|
|
@@ -69318,7 +69242,7 @@ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoad
|
|
|
69318
69242
|
visible: x.visible,
|
|
69319
69243
|
fixedType: x.fixedType,
|
|
69320
69244
|
width: x.width,
|
|
69321
|
-
sortOrder: index + 1
|
|
69245
|
+
sortOrder: index + 1
|
|
69322
69246
|
})));
|
|
69323
69247
|
}
|
|
69324
69248
|
} })] }));
|