react-table-edit 1.4.24 → 1.4.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component/table/header.d.ts +2 -2
- package/dist/component/utils.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -13,8 +13,8 @@ type IFDataProps = {
|
|
|
13
13
|
changeOrder: (data: IFOrderTable[]) => void;
|
|
14
14
|
indexCol: number;
|
|
15
15
|
indexParent: number;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
objHeaderWidthFixLeft: any;
|
|
17
|
+
objHeaderWidthFixRight: any;
|
|
18
18
|
totalCount: number;
|
|
19
19
|
lastObjWidthFixLeft: number;
|
|
20
20
|
fisrtObjWidthFixRight: number;
|
|
@@ -45,6 +45,8 @@ export declare const calculateTableStructure: (columns: any[]) => {
|
|
|
45
45
|
objWidthFixRight: Record<number, number>;
|
|
46
46
|
lastObjWidthFixLeft: number;
|
|
47
47
|
fisrtObjWidthFixRight: number;
|
|
48
|
+
objHeaderWidthFixRight: Record<string, number>;
|
|
49
|
+
objHeaderWidthFixLeft: Record<string, number>;
|
|
48
50
|
firstEdit: any;
|
|
49
51
|
lastEdit: any;
|
|
50
52
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -516,6 +516,8 @@ declare const calculateTableStructure: (columns: any[]) => {
|
|
|
516
516
|
objWidthFixRight: Record<number, number>;
|
|
517
517
|
lastObjWidthFixLeft: number;
|
|
518
518
|
fisrtObjWidthFixRight: number;
|
|
519
|
+
objHeaderWidthFixRight: Record<string, number>;
|
|
520
|
+
objHeaderWidthFixLeft: Record<string, number>;
|
|
519
521
|
firstEdit: any;
|
|
520
522
|
lastEdit: any;
|
|
521
523
|
};
|
package/dist/index.js
CHANGED
|
@@ -19318,6 +19318,8 @@ const calculateTableStructure = (columns) => {
|
|
|
19318
19318
|
const flat = [];
|
|
19319
19319
|
const objWidthFixLeft = {};
|
|
19320
19320
|
const objWidthFixRight = {};
|
|
19321
|
+
const objHeaderWidthFixRight = {};
|
|
19322
|
+
const objHeaderWidthFixLeft = {};
|
|
19321
19323
|
let maxDepth = 0;
|
|
19322
19324
|
// Tính depth tối đa
|
|
19323
19325
|
const calculateDepth = (cols, depth = 1) => (Math.max(...cols.map(col => (col.columns?.length ? calculateDepth(col.columns, depth + 1) : depth))));
|
|
@@ -19326,7 +19328,7 @@ const calculateTableStructure = (columns) => {
|
|
|
19326
19328
|
let rightTotal = 0;
|
|
19327
19329
|
const traverse = (cols, level = 0) => {
|
|
19328
19330
|
levels[level] = levels[level] || [];
|
|
19329
|
-
return cols.reduce((colspanSum, col) => {
|
|
19331
|
+
return cols.reduce((colspanSum, col, indexCol) => {
|
|
19330
19332
|
const hasChildren = (col.columns?.length ?? 0) > 0;
|
|
19331
19333
|
const colspan = hasChildren ? traverse(col.columns, level + 1) : 1;
|
|
19332
19334
|
const cell = {
|
|
@@ -19336,17 +19338,23 @@ const calculateTableStructure = (columns) => {
|
|
|
19336
19338
|
rowspan: hasChildren ? 1 : maxDepth - level
|
|
19337
19339
|
};
|
|
19338
19340
|
levels[level].push(cell);
|
|
19341
|
+
const headerKey = `${level}-${indexCol}`;
|
|
19342
|
+
if (col.fixedType === 'right' && col.visible !== false) {
|
|
19343
|
+
objHeaderWidthFixRight[headerKey] = rightTotal;
|
|
19344
|
+
}
|
|
19345
|
+
if (col.fixedType === 'left' && col.visible !== false) {
|
|
19346
|
+
objHeaderWidthFixLeft[headerKey] = leftTotal;
|
|
19347
|
+
}
|
|
19339
19348
|
if (!hasChildren) {
|
|
19340
|
-
const visible = col.visible !== false;
|
|
19341
19349
|
const index = flat.length;
|
|
19342
19350
|
const width = col.width ?? 40;
|
|
19343
19351
|
cell.index = index;
|
|
19344
19352
|
flat.push(cell);
|
|
19345
|
-
if (col.fixedType === 'left' && visible) {
|
|
19353
|
+
if (col.fixedType === 'left' && col.visible !== false) {
|
|
19346
19354
|
objWidthFixLeft[index] = leftTotal;
|
|
19347
19355
|
leftTotal += width;
|
|
19348
19356
|
}
|
|
19349
|
-
if (col.fixedType === 'right' && visible) {
|
|
19357
|
+
if (col.fixedType === 'right' && col.visible !== false) {
|
|
19350
19358
|
objWidthFixRight[index] = rightTotal;
|
|
19351
19359
|
rightTotal += width;
|
|
19352
19360
|
}
|
|
@@ -19369,6 +19377,8 @@ const calculateTableStructure = (columns) => {
|
|
|
19369
19377
|
objWidthFixRight,
|
|
19370
19378
|
lastObjWidthFixLeft,
|
|
19371
19379
|
fisrtObjWidthFixRight,
|
|
19380
|
+
objHeaderWidthFixRight,
|
|
19381
|
+
objHeaderWidthFixLeft,
|
|
19372
19382
|
firstEdit,
|
|
19373
19383
|
lastEdit
|
|
19374
19384
|
};
|
|
@@ -41816,7 +41826,7 @@ var css_248z$1 = ".react-resizable {\n position: relative;\n}\n.react-resizable
|
|
|
41816
41826
|
styleInject(css_248z$1);
|
|
41817
41827
|
|
|
41818
41828
|
const HeaderTableCol$1 = (props) => {
|
|
41819
|
-
const { selectEnable, dataSource, setSelectedRows, col, indexCol, indexParent,
|
|
41829
|
+
const { selectEnable, dataSource, setSelectedRows, col, indexCol, indexParent, objHeaderWidthFixLeft, objHeaderWidthFixRight, totalCount, selectedRows, columns, setColumns, orderBy, changeFilter, filterBy, changeOrder, allowFilter, allowOrder, container, fisrtObjWidthFixRight, lastObjWidthFixLeft, formatSetting, optionsFilter, idTable, isMulti } = props;
|
|
41820
41830
|
const { t } = reactI18next.useTranslation();
|
|
41821
41831
|
const headerRef = React$5.useRef(null);
|
|
41822
41832
|
const order = orderBy.find((item) => item.key === col.field);
|
|
@@ -41842,10 +41852,11 @@ const HeaderTableCol$1 = (props) => {
|
|
|
41842
41852
|
const checkOverflow = () => {
|
|
41843
41853
|
return headerRef.current && headerRef.current.scrollHeight > headerRef.current.clientHeight;
|
|
41844
41854
|
};
|
|
41855
|
+
console.log(col);
|
|
41845
41856
|
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx(Resizable, { className: "r-resize", width: typeof col.width === 'number' ? col.width : Number((col.width ?? "").replaceAll(new RegExp(`[^0-9]`, "g"), '')), height: 0, onResize: handleResize, draggableOpts: { enableUserSelectHack: false }, children: jsxRuntime.jsx("th", { rowSpan: col.rowspan !== 1 ? col.rowspan : 1, colSpan: col.columns?.filter(x => x.visible !== false)?.length ?? 1, className: classNames$1(`r-headercell fix-${col.fixedType}`, { 'fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'cell-fixed': col.fixedType }), style: {
|
|
41846
41857
|
top: `${indexParent * 42}px`,
|
|
41847
|
-
left: col.fixedType === 'left' ?
|
|
41848
|
-
right: col.fixedType === 'right' ?
|
|
41858
|
+
left: col.fixedType === 'left' ? objHeaderWidthFixLeft[`${indexParent}-${indexCol ?? 0}`] : undefined,
|
|
41859
|
+
right: col.fixedType === 'right' ? objHeaderWidthFixRight[`${indexParent}-${indexCol ?? 0}`] : undefined
|
|
41849
41860
|
}, children: jsxRuntime.jsxs("div", { style: { justifyContent: 'space-between' }, onClick: () => {
|
|
41850
41861
|
if (order) {
|
|
41851
41862
|
if (order.direction === 'asc') {
|
|
@@ -41869,7 +41880,7 @@ const HeaderTableCol$1 = (props) => {
|
|
|
41869
41880
|
setSelectedRows([]);
|
|
41870
41881
|
}
|
|
41871
41882
|
}
|
|
41872
|
-
} })), col.field !== 'checkbox' && jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'header-content', style: { justifyContent: col.textAlign ?? 'left' }, children: [jsxRuntime.jsx("span", { id: `header-${idTable}-${indexParent}-${indexCol}`, ref: headerRef, className: 'text-content', children: t(col.headerText ?? '') }), checkOverflow() && jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `header-${idTable}-${indexParent}-${indexCol}`, children: t(col.headerText ?? '') })] }), col.field !== '#' && col.field !== 'command' && jsxRuntime.jsxs("div", { className: 'd-flex', children: [allowOrder && order?.direction === 'asc' && jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", className: 'ms-25', width: "10", height: "10", viewBox: "0 0 16 18", fill: "none", children: [jsxRuntime.jsx("g", { "clip-path": "url(#clip0_520_6)", children: jsxRuntime.jsx("path", { d: "M8.70711 0.292893C8.31658 -0.0976311 7.68342 -0.0976311 7.29289 0.292893L0.928932 6.65685C0.538408 7.04738 0.538408 7.68054 0.928932 8.07107C1.31946 8.46159 1.95262 8.46159 2.34315 8.07107L8 2.41421L13.6569 8.07107C14.0474 8.46159 14.6805 8.46159 15.0711 8.07107C15.4616 7.68054 15.4616 7.04738 15.0711 6.65685L8.70711 0.292893ZM8 18H9L9 1H8H7L7 18H8Z", fill: "black" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_520_6", children: jsxRuntime.jsx("rect", { width: "16", height: "18", fill: "white" }) }) })] }), allowOrder && order?.direction === 'desc' && jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", className: 'ms-25', width: "10", height: "10", viewBox: "0 0 16 18", fill: "none", children: [jsxRuntime.jsx("g", { "clip-path": "url(#clip0_520_2)", children: jsxRuntime.jsx("path", { d: "M7.29289 17.7071C7.68342 18.0976 8.31658 18.0976 8.70711 17.7071L15.0711 11.3431C15.4616 10.9526 15.4616 10.3195 15.0711 9.92893C14.6805 9.53841 14.0474 9.53841 13.6569 9.92893L8 15.5858L2.34315 9.92893C1.95262 9.53841 1.31946 9.53841 0.928932 9.92893C0.538408 10.3195 0.538408 10.9526 0.928932 11.3431L7.29289 17.7071ZM8 0L7 0L7 17H8H9L9 0L8 0Z", fill: "black" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_520_2", children: jsxRuntime.jsx("rect", { width: "16", height: "18", fill: "white" }) }) })] }), allowFilter && jsxRuntime.jsxs(Dropdown$1, { isOpen: openFilter, toggle: (e) => {
|
|
41883
|
+
} })), col.field !== 'checkbox' && jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'header-content', style: { justifyContent: col.textAlign ?? 'left' }, children: [jsxRuntime.jsx("span", { id: `header-${idTable}-${indexParent}-${indexCol}`, ref: headerRef, className: 'text-content', children: t(col.headerText ?? '') }), checkOverflow() && jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `header-${idTable}-${indexParent}-${indexCol}`, children: t(col.headerText ?? '') })] }), col.field !== '#' && col.field !== 'command' && jsxRuntime.jsxs("div", { className: 'd-flex', children: [allowOrder && order?.direction === 'asc' && jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", className: 'ms-25', width: "10", height: "10", viewBox: "0 0 16 18", fill: "none", children: [jsxRuntime.jsx("g", { "clip-path": "url(#clip0_520_6)", children: jsxRuntime.jsx("path", { d: "M8.70711 0.292893C8.31658 -0.0976311 7.68342 -0.0976311 7.29289 0.292893L0.928932 6.65685C0.538408 7.04738 0.538408 7.68054 0.928932 8.07107C1.31946 8.46159 1.95262 8.46159 2.34315 8.07107L8 2.41421L13.6569 8.07107C14.0474 8.46159 14.6805 8.46159 15.0711 8.07107C15.4616 7.68054 15.4616 7.04738 15.0711 6.65685L8.70711 0.292893ZM8 18H9L9 1H8H7L7 18H8Z", fill: "black" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_520_6", children: jsxRuntime.jsx("rect", { width: "16", height: "18", fill: "white" }) }) })] }), allowOrder && order?.direction === 'desc' && jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", className: 'ms-25', width: "10", height: "10", viewBox: "0 0 16 18", fill: "none", children: [jsxRuntime.jsx("g", { "clip-path": "url(#clip0_520_2)", children: jsxRuntime.jsx("path", { d: "M7.29289 17.7071C7.68342 18.0976 8.31658 18.0976 8.70711 17.7071L15.0711 11.3431C15.4616 10.9526 15.4616 10.3195 15.0711 9.92893C14.6805 9.53841 14.0474 9.53841 13.6569 9.92893L8 15.5858L2.34315 9.92893C1.95262 9.53841 1.31946 9.53841 0.928932 9.92893C0.538408 10.3195 0.538408 10.9526 0.928932 11.3431L7.29289 17.7071ZM8 0L7 0L7 17H8H9L9 0L8 0Z", fill: "black" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_520_2", children: jsxRuntime.jsx("rect", { width: "16", height: "18", fill: "white" }) }) })] }), allowFilter && (col.columns?.length ?? 0) === 0 && col.allowFilter !== false && jsxRuntime.jsxs(Dropdown$1, { isOpen: openFilter, toggle: (e) => {
|
|
41873
41884
|
setOpenFilter(!openFilter);
|
|
41874
41885
|
e.stopPropagation();
|
|
41875
41886
|
}, onClick: (e) => {
|
|
@@ -41946,7 +41957,7 @@ const RenderFilterElement$1 = ({ filter, optionsFilter, formatSetting, filterBy,
|
|
|
41946
41957
|
handleSave();
|
|
41947
41958
|
e.stopPropagation();
|
|
41948
41959
|
}
|
|
41949
|
-
}, children: [((!column.filterType && column.editType === 'numeric') || column.filterType === 'numeric') ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderNumberFilter(), " "] }) : (column.filterType === 'select' ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderSelectFilter(), " "] }) : RenderStringFilter()), jsxRuntime.jsxs("div", { className: 'd-flex justify-content-end', children: [jsxRuntime.jsx(Button$1, { color: 'primary', style: { borderRadius: 3 }, className: 'me-50 py-25 px-50 fw-bold', onClick: handleSave, children: t('Filter') }), jsxRuntime.jsx(Button$1, { className: 'py-25 px-50
|
|
41960
|
+
}, children: [((!column.filterType && column.editType === 'numeric') || column.filterType === 'numeric') ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderNumberFilter(), " "] }) : (column.filterType === 'select' ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [RenderSelectFilter(), " "] }) : RenderStringFilter()), jsxRuntime.jsxs("div", { className: 'd-flex justify-content-end', children: [jsxRuntime.jsx(Button$1, { color: 'primary', style: { borderRadius: 3 }, className: 'me-50 py-25 px-50 fw-bold', onClick: handleSave, children: t('Filter') }), jsxRuntime.jsx(Button$1, { className: 'py-25 px-50 fw-bold', color: 'white', style: { borderRadius: 3, borderWidth: 0 }, onClick: () => {
|
|
41950
41961
|
if (filterBy) {
|
|
41951
41962
|
changeFilter(filterBy.filter((x) => x.key !== column.field));
|
|
41952
41963
|
}
|
|
@@ -42757,7 +42768,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42757
42768
|
pagingSetting.setCurrentPage(1);
|
|
42758
42769
|
}
|
|
42759
42770
|
}, [dataSource]);
|
|
42760
|
-
const { levels: headerColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, firstEdit: columnFirstEdit, lastEdit: columnLastEdit } = React$5.useMemo(() => {
|
|
42771
|
+
const { levels: headerColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, firstEdit: columnFirstEdit, lastEdit: columnLastEdit } = React$5.useMemo(() => {
|
|
42761
42772
|
const obj = calculateTableStructure(columns);
|
|
42762
42773
|
setContentColumns(obj.flat);
|
|
42763
42774
|
return obj;
|
|
@@ -43586,7 +43597,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43586
43597
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
43587
43598
|
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsxs("div", { className: "react-table-edit", children: [jsxRuntime.jsxs("div", { className: 'r-grid', ref: gridRef, children: [toolbarSetting?.showTopToolbar && jsxRuntime.jsx(RenderToolbarTop, { toolbarTopOption: toolbarTopOption }), jsxRuntime.jsx("div", { ref: tableElement, className: "r-gridtable", style: { height: `${height ? `${height}px` : 'auto'}`, minHeight: `${minHeight ? `${minHeight}px` : ''}`, maxHeight: `${maxHeight ? `${maxHeight}px` : '400px'}` }, children: jsxRuntime.jsxs("table", { style: { width: '100%' }, children: [jsxRuntime.jsx(RenderColGroup, { contentColumns: flatVisble }), jsxRuntime.jsx("thead", { className: 'r-gridheader', children: headerColumns.map((element, indexParent) => {
|
|
43588
43599
|
return (jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
43589
|
-
return (jsxRuntime.jsx(HeaderTableCol$1, { col: col, idTable: idTable ?? '', dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false,
|
|
43600
|
+
return (jsxRuntime.jsx(HeaderTableCol$1, { col: col, idTable: idTable ?? '', dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false, objHeaderWidthFixLeft: objHeaderWidthFixLeft, objHeaderWidthFixRight: objHeaderWidthFixRight, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, container: tableElement, filterBy: filterBy, orderBy: orderBy, optionsFilter: optionsFilter, allowFilter: allowFilter, allowOrder: allowOrder, formatSetting: formatSetting, changeFilter: (val) => {
|
|
43590
43601
|
setFilterBy([...val]);
|
|
43591
43602
|
}, changeOrder: (val) => {
|
|
43592
43603
|
setOrderBy([...val]);
|