react-table-edit 1.4.38 → 1.4.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component/sidebar-setting-column/index.d.ts +2 -0
- package/dist/component/table/index.d.ts +4 -15
- package/dist/component/type/index.d.ts +13 -0
- package/dist/index.d.ts +17 -15
- package/dist/index.js +100 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -70
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/styles/date-picker.css +0 -806
- package/dist/styles/date-picker.css.map +0 -1
- package/dist/styles/form-wizard.css +0 -165
- package/dist/styles/form-wizard.css.map +0 -1
- package/dist/styles/index.css +0 -1851
- package/dist/styles/index.css.map +0 -1
- package/dist/styles/select-table.css +0 -230
- package/dist/styles/select-table.css.map +0 -1
- package/dist/styles/sidebar.css +0 -118
- package/dist/styles/sidebar.css.map +0 -1
- package/dist/styles/tab-menu.css +0 -49
- package/dist/styles/tab-menu.css.map +0 -1
- package/dist/styles/variables.css +0 -3
- package/dist/styles/variables.css.map +0 -1
|
@@ -4,6 +4,8 @@ export interface IFPropsDetail {
|
|
|
4
4
|
setColumn: any;
|
|
5
5
|
openSidebar: boolean;
|
|
6
6
|
handleSidebar: any;
|
|
7
|
+
resetDefaultColumns?: () => void;
|
|
8
|
+
formatSetting?: any;
|
|
7
9
|
}
|
|
8
10
|
declare const SidebarSetColumn: (props: IFPropsDetail) => import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export default SidebarSetColumn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import { IColumnTable, IFTableEditButton, IFTableEditFormat, IFTableEditPaging, IFTableEditSearchSetting, IFTableEditToolbar } from "../type";
|
|
2
|
+
import { IColumnTable, IFSettingColumns, IFTableEditButton, IFTableEditFormat, IFTableEditPaging, IFTableEditSearchSetting, IFTableEditToolbar } from "../type";
|
|
3
3
|
export type IFTableEditProps = {
|
|
4
4
|
idTable?: string;
|
|
5
5
|
dataSource: any[];
|
|
@@ -24,26 +24,15 @@ export type IFTableEditProps = {
|
|
|
24
24
|
allowFilter?: boolean;
|
|
25
25
|
allowOrder?: boolean;
|
|
26
26
|
optionsFilter?: any;
|
|
27
|
-
settingColumns?:
|
|
28
|
-
field: string;
|
|
29
|
-
headerText?: string;
|
|
30
|
-
visible?: boolean;
|
|
31
|
-
fixedType?: "left" | "right";
|
|
32
|
-
width?: number | string;
|
|
33
|
-
}[];
|
|
27
|
+
settingColumns?: IFSettingColumns[];
|
|
34
28
|
setSelectedItem?: Dispatch<SetStateAction<any>>;
|
|
35
29
|
commandClick?: (data: any) => void;
|
|
36
30
|
handleSelect?: (data: any) => void;
|
|
37
31
|
dataSourceChange?: (data: any[]) => void;
|
|
38
32
|
rowChange?: (row: any, indexRow: number, field: string) => void;
|
|
39
33
|
onDuplicate?: (newData: any, index: number) => void;
|
|
40
|
-
saveSettingColumn?: (data:
|
|
41
|
-
|
|
42
|
-
headerText?: string;
|
|
43
|
-
visible?: boolean;
|
|
44
|
-
fixedType?: "left" | "right";
|
|
45
|
-
width?: number | string;
|
|
46
|
-
}[]) => void;
|
|
34
|
+
saveSettingColumn?: (data: IFSettingColumns[]) => void;
|
|
35
|
+
resetDefaultColumns?: () => void;
|
|
47
36
|
};
|
|
48
37
|
type IFRef = {
|
|
49
38
|
refeshFocusRow: any;
|
|
@@ -31,6 +31,19 @@ export type IFToolbarOptions = {
|
|
|
31
31
|
/** Template toolbar */
|
|
32
32
|
template: any;
|
|
33
33
|
};
|
|
34
|
+
/** Cấu hình thiết lập bảng */
|
|
35
|
+
export type IFSettingColumns = {
|
|
36
|
+
/** Tên thuộc tính */
|
|
37
|
+
field: string;
|
|
38
|
+
/** Tiêu đề hiển thị ở header */
|
|
39
|
+
headerText?: string;
|
|
40
|
+
/** Có hiển thị không */
|
|
41
|
+
visible?: boolean;
|
|
42
|
+
/** Cố định trái/phải */
|
|
43
|
+
fixedType?: "left" | "right";
|
|
44
|
+
/** Chiều rộng cột */
|
|
45
|
+
width?: number | string;
|
|
46
|
+
};
|
|
34
47
|
/** Cấu hình phần tử form khi dùng loại cột `form` */
|
|
35
48
|
export type ISettingFormElement = {
|
|
36
49
|
/** Schema định nghĩa cấu trúc form */
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,19 @@ type IFToolbarOptions = {
|
|
|
35
35
|
/** Template toolbar */
|
|
36
36
|
template: any;
|
|
37
37
|
};
|
|
38
|
+
/** Cấu hình thiết lập bảng */
|
|
39
|
+
type IFSettingColumns = {
|
|
40
|
+
/** Tên thuộc tính */
|
|
41
|
+
field: string;
|
|
42
|
+
/** Tiêu đề hiển thị ở header */
|
|
43
|
+
headerText?: string;
|
|
44
|
+
/** Có hiển thị không */
|
|
45
|
+
visible?: boolean;
|
|
46
|
+
/** Cố định trái/phải */
|
|
47
|
+
fixedType?: "left" | "right";
|
|
48
|
+
/** Chiều rộng cột */
|
|
49
|
+
width?: number | string;
|
|
50
|
+
};
|
|
38
51
|
/** Cấu hình phần tử form khi dùng loại cột `form` */
|
|
39
52
|
type ISettingFormElement = {
|
|
40
53
|
/** Schema định nghĩa cấu trúc form */
|
|
@@ -412,26 +425,15 @@ type IFTableEditProps = {
|
|
|
412
425
|
allowFilter?: boolean;
|
|
413
426
|
allowOrder?: boolean;
|
|
414
427
|
optionsFilter?: any;
|
|
415
|
-
settingColumns?:
|
|
416
|
-
field: string;
|
|
417
|
-
headerText?: string;
|
|
418
|
-
visible?: boolean;
|
|
419
|
-
fixedType?: "left" | "right";
|
|
420
|
-
width?: number | string;
|
|
421
|
-
}[];
|
|
428
|
+
settingColumns?: IFSettingColumns[];
|
|
422
429
|
setSelectedItem?: Dispatch<SetStateAction<any>>;
|
|
423
430
|
commandClick?: (data: any) => void;
|
|
424
431
|
handleSelect?: (data: any) => void;
|
|
425
432
|
dataSourceChange?: (data: any[]) => void;
|
|
426
433
|
rowChange?: (row: any, indexRow: number, field: string) => void;
|
|
427
434
|
onDuplicate?: (newData: any, index: number) => void;
|
|
428
|
-
saveSettingColumn?: (data:
|
|
429
|
-
|
|
430
|
-
headerText?: string;
|
|
431
|
-
visible?: boolean;
|
|
432
|
-
fixedType?: "left" | "right";
|
|
433
|
-
width?: number | string;
|
|
434
|
-
}[]) => void;
|
|
435
|
+
saveSettingColumn?: (data: IFSettingColumns[]) => void;
|
|
436
|
+
resetDefaultColumns?: () => void;
|
|
435
437
|
};
|
|
436
438
|
type IFRef = {
|
|
437
439
|
refeshFocusRow: any;
|
|
@@ -743,4 +745,4 @@ type TableViewProps = {
|
|
|
743
745
|
declare const TableView: React__default.FC<TableViewProps>;
|
|
744
746
|
|
|
745
747
|
export { ExportExcelComponent, FindNodeByPath, ImportExcelComponent, InputStyleComponent, SelectTable, SelectTableTree, TableView, TabsMenuComponent, Wizard, calculateTableStructure, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, formatDateTime, generateUUID, isNullOrUndefined, messageBoxConfirm, messageBoxConfirm2, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
|
|
746
|
-
export type { FromItemsField, IColumnTable, IColumnsAgg, ICommandItem, IFColumnSelectTable, IFColumnSelectTableTree, IFCurrentPage, IFCurrentPageConfig, IFFilterTable, IFOrderTable, IFPageSize, IFPropsDetail, IFTableEditButton, IFTableEditFormat, IFTableEditPaging, IFTableEditSearchSetting, IFTableEditToolbar, IFTableSelectFormat, IFTableTreeSelectFormat, IFToolbarOptions, IHeaderColumnTable, ISettingFormElement, ISettingNumericElement, ISettingSelectElement };
|
|
748
|
+
export type { FromItemsField, IColumnTable, IColumnsAgg, ICommandItem, IFColumnSelectTable, IFColumnSelectTableTree, IFCurrentPage, IFCurrentPageConfig, IFFilterTable, IFOrderTable, IFPageSize, IFPropsDetail, IFSettingColumns, IFTableEditButton, IFTableEditFormat, IFTableEditPaging, IFTableEditSearchSetting, IFTableEditToolbar, IFTableSelectFormat, IFTableTreeSelectFormat, IFToolbarOptions, IHeaderColumnTable, ISettingFormElement, ISettingNumericElement, ISettingSelectElement };
|
package/dist/index.js
CHANGED
|
@@ -17724,8 +17724,15 @@ const calculateTableStructure = (columns, settingColumns) => {
|
|
|
17724
17724
|
const column = settingColumns.find((y) => y.field === cell.field);
|
|
17725
17725
|
if (column) {
|
|
17726
17726
|
cell.visible = column.visible;
|
|
17727
|
-
|
|
17728
|
-
|
|
17727
|
+
if (column.fixedType !== undefined && column.fixedType !== null) {
|
|
17728
|
+
cell.fixedType = column.fixedType;
|
|
17729
|
+
}
|
|
17730
|
+
if (column.width !== undefined && column.width !== null) {
|
|
17731
|
+
cell.width = column.width;
|
|
17732
|
+
}
|
|
17733
|
+
if (column.headerText !== undefined && column.headerText !== null) {
|
|
17734
|
+
cell.headerText = column.headerText;
|
|
17735
|
+
}
|
|
17729
17736
|
}
|
|
17730
17737
|
else {
|
|
17731
17738
|
cell.visible = false;
|
|
@@ -17733,24 +17740,24 @@ const calculateTableStructure = (columns, settingColumns) => {
|
|
|
17733
17740
|
}
|
|
17734
17741
|
levels[level].push(cell);
|
|
17735
17742
|
const headerKey = `${level}-${indexCol}`;
|
|
17736
|
-
if (
|
|
17743
|
+
if (cell.fixedType === "left" && cell.visible !== false) {
|
|
17737
17744
|
objHeaderWidthFixLeft[headerKey] = leftTotal;
|
|
17738
17745
|
}
|
|
17739
17746
|
if (!hasChildren) {
|
|
17740
17747
|
const index = flat.length;
|
|
17741
|
-
const width =
|
|
17748
|
+
const width = cell.width ?? 40;
|
|
17742
17749
|
cell.index = index;
|
|
17743
17750
|
flat.push(cell);
|
|
17744
|
-
if (
|
|
17751
|
+
if (cell.fixedType === "left" && cell.visible !== false) {
|
|
17745
17752
|
objWidthFixLeft[index] = leftTotal;
|
|
17746
17753
|
leftTotal += width;
|
|
17747
17754
|
}
|
|
17748
|
-
if (
|
|
17755
|
+
if (cell.fixedType === "right" && cell.visible !== false) {
|
|
17749
17756
|
rightTotal -= width;
|
|
17750
17757
|
objWidthFixRight[index] = rightTotal;
|
|
17751
17758
|
}
|
|
17752
17759
|
}
|
|
17753
|
-
if (
|
|
17760
|
+
if (cell.fixedType === "right" && cell.visible !== false) {
|
|
17754
17761
|
objHeaderWidthFixRight[headerKey] = rightTotal;
|
|
17755
17762
|
}
|
|
17756
17763
|
return colspanSum + colspan;
|
|
@@ -40365,7 +40372,7 @@ const Sidebar = (props) => {
|
|
|
40365
40372
|
};
|
|
40366
40373
|
|
|
40367
40374
|
const SidebarSetColumn = (props) => {
|
|
40368
|
-
const { column, setColumn, openSidebar, handleSidebar } = props;
|
|
40375
|
+
const { column, setColumn, openSidebar, handleSidebar, resetDefaultColumns, formatSetting } = props;
|
|
40369
40376
|
const { t } = reactI18next.useTranslation();
|
|
40370
40377
|
const [dataSource, setDataSource] = React$5.useState([]);
|
|
40371
40378
|
const [indexFocus, setIndexFocus] = React$5.useState();
|
|
@@ -40396,46 +40403,83 @@ const SidebarSetColumn = (props) => {
|
|
|
40396
40403
|
window.removeEventListener("resize", handleWindowResize);
|
|
40397
40404
|
};
|
|
40398
40405
|
}, []);
|
|
40406
|
+
const handleResetColumns = () => {
|
|
40407
|
+
if (resetDefaultColumns) {
|
|
40408
|
+
resetDefaultColumns();
|
|
40409
|
+
}
|
|
40410
|
+
handleSidebar();
|
|
40411
|
+
setDataSource([]);
|
|
40412
|
+
};
|
|
40399
40413
|
const renderFooterButtons = () => {
|
|
40400
|
-
return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Button$1, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }), jsxRuntime.jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })] }));
|
|
40414
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [resetDefaultColumns && jsxRuntime.jsx(Button$1, { color: "primary", onClick: () => messageBoxConfirm(t, handleResetColumns, {}, 'Do you want to reset the default settings?'), className: "me-1", children: t("Reset") }), jsxRuntime.jsx(Button$1, { color: "primary", onClick: handleSubmit, className: "me-1", children: t("Confirm") }), jsxRuntime.jsx(Button$1, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })] }));
|
|
40401
40415
|
};
|
|
40402
40416
|
const visibleTemplate = (item, index) => {
|
|
40403
|
-
return (jsxRuntime.jsx(Input$1, { defaultChecked: item.visible ?? true,
|
|
40417
|
+
return (jsxRuntime.jsx("div", { className: "r-cell-text", children: jsxRuntime.jsx(Input$1, { defaultChecked: item.visible ?? true, type: "checkbox", style: { height: 18 }, className: " cursor-pointer", onChange: (e) => {
|
|
40418
|
+
if (dataSource) {
|
|
40419
|
+
dataSource[index].visible = e.target.checked;
|
|
40420
|
+
setDataSource(dataSource);
|
|
40421
|
+
}
|
|
40422
|
+
} }) }));
|
|
40423
|
+
};
|
|
40424
|
+
const headerTextTemplate = (item, index) => {
|
|
40425
|
+
let textValue = t(item.headerText);
|
|
40426
|
+
return (jsxRuntime.jsx(Input$1, { defaultValue: textValue, className: classNames$2("border-0 rounded-0 input-element"), onChange: (e) => {
|
|
40427
|
+
textValue = e.target?.value;
|
|
40428
|
+
}, onBlur: () => {
|
|
40404
40429
|
if (dataSource) {
|
|
40405
|
-
dataSource[index].
|
|
40430
|
+
dataSource[index].headerText = textValue;
|
|
40406
40431
|
setDataSource(dataSource);
|
|
40407
40432
|
}
|
|
40408
40433
|
} }));
|
|
40409
40434
|
};
|
|
40410
40435
|
const fixColumnTemplate = (item, index) => {
|
|
40411
|
-
|
|
40436
|
+
const optionsFix = [{ label: 'Trái', value: 'left' }, { label: 'Phải', value: 'right' }];
|
|
40437
|
+
return (jsxRuntime.jsx(SelectTable, { options: optionsFix, textAlign: "left", isClearable: true, onChange: (val) => {
|
|
40412
40438
|
if (dataSource) {
|
|
40413
|
-
|
|
40414
|
-
|
|
40415
|
-
|
|
40416
|
-
|
|
40417
|
-
|
|
40418
|
-
|
|
40419
|
-
|
|
40420
|
-
|
|
40421
|
-
|
|
40422
|
-
|
|
40439
|
+
dataSource[index].fixedType = val?.value;
|
|
40440
|
+
setDataSource([...dataSource]);
|
|
40441
|
+
}
|
|
40442
|
+
}, value: item.fixedType ? optionsFix.find(x => x.value === item.fixedType) : undefined }));
|
|
40443
|
+
};
|
|
40444
|
+
const widthColumnTemplate = (item, index) => {
|
|
40445
|
+
const numericFormatProps = {
|
|
40446
|
+
value: !isNullOrUndefined(item.width) ? item.width.toString() : "",
|
|
40447
|
+
thousandSeparator: checkThousandSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
40448
|
+
decimalSeparator: checkDecimalSeparator(formatSetting?.thousandSeparator, formatSetting?.decimalSeparator),
|
|
40449
|
+
allowNegative: false,
|
|
40450
|
+
decimalScale: 0
|
|
40451
|
+
};
|
|
40452
|
+
let floatValue = parseFloat(item.width ?? "0");
|
|
40453
|
+
return (jsxRuntime.jsx(NumericFormat, { style: { textAlign: 'right', height: 29 }, ...numericFormatProps, defaultValue: formartNumberic(item.width, formatSetting?.decimalSeparator ?? ",", formatSetting?.thousandSeparator ?? ".", 0), className: classNames$2("form-control border-0 rounded-0 input-numeric"), onValueChange: (values) => {
|
|
40454
|
+
floatValue = values?.floatValue;
|
|
40455
|
+
}, onFocus: (e) => {
|
|
40456
|
+
e.target.setSelectionRange(0, e.target.innerText.length - 1);
|
|
40457
|
+
}, onBlur: () => {
|
|
40458
|
+
if (floatValue !== item.width) {
|
|
40459
|
+
if (dataSource) {
|
|
40460
|
+
dataSource[index].width = !isNaN(floatValue) ? floatValue : 0;
|
|
40461
|
+
setDataSource(dataSource);
|
|
40423
40462
|
}
|
|
40424
|
-
setDataSource(dataSource);
|
|
40425
40463
|
}
|
|
40426
40464
|
} }));
|
|
40427
40465
|
};
|
|
40428
40466
|
const columns = [
|
|
40467
|
+
{
|
|
40468
|
+
field: "",
|
|
40469
|
+
headerText: "STT",
|
|
40470
|
+
template: (row, index) => {
|
|
40471
|
+
return index + 1;
|
|
40472
|
+
},
|
|
40473
|
+
textAlign: 'center',
|
|
40474
|
+
visible: true,
|
|
40475
|
+
width: 50
|
|
40476
|
+
},
|
|
40429
40477
|
{
|
|
40430
40478
|
field: "headerText",
|
|
40431
40479
|
headerText: "Column name",
|
|
40432
|
-
template:
|
|
40433
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: t(e.headerText) });
|
|
40434
|
-
},
|
|
40480
|
+
template: headerTextTemplate,
|
|
40435
40481
|
visible: true,
|
|
40436
|
-
width:
|
|
40437
|
-
maxWidth: 200,
|
|
40438
|
-
minWidth: 150
|
|
40482
|
+
width: 200
|
|
40439
40483
|
},
|
|
40440
40484
|
{
|
|
40441
40485
|
field: "",
|
|
@@ -40443,9 +40487,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40443
40487
|
headerText: "Display",
|
|
40444
40488
|
textAlign: "center",
|
|
40445
40489
|
visible: true,
|
|
40446
|
-
width:
|
|
40447
|
-
maxWidth: 120,
|
|
40448
|
-
minWidth: 80
|
|
40490
|
+
width: 80
|
|
40449
40491
|
},
|
|
40450
40492
|
{
|
|
40451
40493
|
field: "",
|
|
@@ -40453,18 +40495,15 @@ const SidebarSetColumn = (props) => {
|
|
|
40453
40495
|
headerText: "Fix the column",
|
|
40454
40496
|
textAlign: "center",
|
|
40455
40497
|
visible: true,
|
|
40456
|
-
width:
|
|
40457
|
-
maxWidth: 120,
|
|
40458
|
-
minWidth: 80
|
|
40498
|
+
width: 80
|
|
40459
40499
|
},
|
|
40460
40500
|
{
|
|
40461
40501
|
field: "width",
|
|
40462
40502
|
headerText: "Column width",
|
|
40463
40503
|
textAlign: "right",
|
|
40464
40504
|
visible: true,
|
|
40465
|
-
|
|
40466
|
-
|
|
40467
|
-
minWidth: 80
|
|
40505
|
+
template: widthColumnTemplate,
|
|
40506
|
+
width: 100
|
|
40468
40507
|
}
|
|
40469
40508
|
];
|
|
40470
40509
|
const renderHeaderCol = (col, indexCol) => {
|
|
@@ -40482,10 +40521,6 @@ const SidebarSetColumn = (props) => {
|
|
|
40482
40521
|
return renderHeaderCol(col, index);
|
|
40483
40522
|
}) }) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
|
|
40484
40523
|
return (jsxRuntime.jsx("tr", { className: classNames$2("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }), children: columns.map((col, indexCol) => {
|
|
40485
|
-
let value = row[col.field];
|
|
40486
|
-
if (col.type === "numeric" || (col.typeCondition && col.typeCondition(row) === "numeric")) {
|
|
40487
|
-
value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
|
|
40488
|
-
}
|
|
40489
40524
|
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && (jsxRuntime.jsx("td", { className: classNames$2(`r-rowcell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": indexFocus === indexRow }), style: {
|
|
40490
40525
|
padding: 0,
|
|
40491
40526
|
textAlign: col.textAlign ? col.textAlign : "left"
|
|
@@ -40503,7 +40538,7 @@ const SidebarSetColumn = (props) => {
|
|
|
40503
40538
|
}
|
|
40504
40539
|
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-div"), style: {
|
|
40505
40540
|
width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
|
|
40506
|
-
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-content"), children:
|
|
40541
|
+
}, children: jsxRuntime.jsx("div", { className: classNames$2("r-rowcell-content"), children: col.template && col.template(row, indexRow) }) }) }, `col-${indexRow}-${indexCol}`)) }, indexCol));
|
|
40507
40542
|
}) }, `row-${indexRow}`));
|
|
40508
40543
|
}) })] }) }) }) }), jsxRuntime.jsx("div", { className: "d-flex justify-content-end p-1 ", style: { boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }, children: renderFooterButtons() })] }));
|
|
40509
40544
|
};
|
|
@@ -42835,7 +42870,7 @@ const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleI
|
|
|
42835
42870
|
|
|
42836
42871
|
const TableEdit = React$5.forwardRef((props, ref) => {
|
|
42837
42872
|
const { t } = reactI18next.useTranslation();
|
|
42838
|
-
const { idTable, dataSource, columns, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, haveSum, isMulti, disableAutoKey, commandClick, dataSourceChange, rowChange, setSelectedItem, handleSelect, onDuplicate, saveSettingColumn, allowFilter = true, allowOrder, settingColumns, optionsFilter } = props;
|
|
42873
|
+
const { idTable, dataSource, columns, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, haveSum, isMulti, disableAutoKey, commandClick, dataSourceChange, rowChange, setSelectedItem, handleSelect, onDuplicate, saveSettingColumn, allowFilter = true, allowOrder, settingColumns, optionsFilter, resetDefaultColumns } = props;
|
|
42839
42874
|
React$5.useImperativeHandle(ref, () => {
|
|
42840
42875
|
return {
|
|
42841
42876
|
refeshFocusRow: handleRefeshRow
|
|
@@ -42848,7 +42883,6 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42848
42883
|
const [searchTerm, setSearchTerm] = React$5.useState("");
|
|
42849
42884
|
const [orderBy, setOrderBy] = React$5.useState([]);
|
|
42850
42885
|
const [filterBy, setFilterBy] = React$5.useState([]);
|
|
42851
|
-
const [refreshColumns, setRefreshColumns] = React$5.useState(false);
|
|
42852
42886
|
const tableElement = React$5.useRef(null);
|
|
42853
42887
|
const gridRef = React$5.useRef(null);
|
|
42854
42888
|
const totalCount = dataSource.length;
|
|
@@ -42863,7 +42897,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42863
42897
|
}, [dataSource]);
|
|
42864
42898
|
const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = React$5.useMemo(() => {
|
|
42865
42899
|
return calculateTableStructure(columns, settingColumns);
|
|
42866
|
-
}, [columns, settingColumns
|
|
42900
|
+
}, [columns, settingColumns]);
|
|
42867
42901
|
const handleRefeshRow = () => {
|
|
42868
42902
|
setRefreshRow(true);
|
|
42869
42903
|
setTimeout(() => {
|
|
@@ -43132,15 +43166,27 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43132
43166
|
}
|
|
43133
43167
|
} }));
|
|
43134
43168
|
default:
|
|
43135
|
-
|
|
43136
|
-
|
|
43137
|
-
|
|
43169
|
+
let textValue = row[col.field] ?? '';
|
|
43170
|
+
return (jsxRuntime.jsx(Input$1, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, style: { textAlign: col.textAlign, height: 29 }, defaultValue: textValue, className: classNames$2("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }), onChange: (val) => {
|
|
43171
|
+
textValue = val.target?.value;
|
|
43172
|
+
}, onBlur: () => {
|
|
43173
|
+
if (row[col.field] != textValue) {
|
|
43174
|
+
row[col.field] = textValue;
|
|
43138
43175
|
if (col.callback) {
|
|
43139
|
-
col.callback(
|
|
43176
|
+
col.callback(textValue, indexRow, row);
|
|
43140
43177
|
}
|
|
43141
43178
|
handleDataChange(row, col, indexRow);
|
|
43142
43179
|
}
|
|
43143
43180
|
}, onKeyDown: (e) => {
|
|
43181
|
+
if (e.key === "ArrowDown" || e.key === "NumpadEnter" || e.key === "ArrowUp" || e.key === "Enter" || e.key === "Tab") {
|
|
43182
|
+
if (row[col.field] != textValue) {
|
|
43183
|
+
row[col.field] = textValue;
|
|
43184
|
+
if (col.callback) {
|
|
43185
|
+
col.callback(textValue, indexRow, row);
|
|
43186
|
+
}
|
|
43187
|
+
handleDataChange(row, col, indexRow);
|
|
43188
|
+
}
|
|
43189
|
+
}
|
|
43144
43190
|
checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
43145
43191
|
}, onPaste: (e) => {
|
|
43146
43192
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
@@ -43702,15 +43748,9 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43702
43748
|
}, changeOrder: (val) => {
|
|
43703
43749
|
setOrderBy([...val]);
|
|
43704
43750
|
}, columns: contentColumns, setColumns: (newColumns) => {
|
|
43705
|
-
|
|
43706
|
-
|
|
43707
|
-
|
|
43708
|
-
column.visible = x.visible;
|
|
43709
|
-
column.fixedType = x.fixedType;
|
|
43710
|
-
column.width = x.width;
|
|
43711
|
-
}
|
|
43712
|
-
});
|
|
43713
|
-
setRefreshColumns(!refreshColumns);
|
|
43751
|
+
if (saveSettingColumn) {
|
|
43752
|
+
saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
|
|
43753
|
+
}
|
|
43714
43754
|
}, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
|
|
43715
43755
|
}) }, `header-${-indexParent}`));
|
|
43716
43756
|
}) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: dataSource.map((row, indexRow) => {
|
|
@@ -43735,20 +43775,10 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43735
43775
|
handleDeleteAll(t, messageBoxConfirmDelete, setIndexFocus, changeDataSource, editDisable, addDisable, toolbarSetting, buttonSetting);
|
|
43736
43776
|
}, setOpenPopupSetupColumn: setOpenPopupSetupColumn, indexFocus: indexFocus, editDisable: editDisable, addDisable: addDisable, buttonSetting: buttonSetting, toolbarSetting: toolbarSetting, headerColumns: headerColumns, t: t }))] }), pagingSetting?.allowPaging ? (jsxRuntime.jsx(PagingComponent, { onChangePage: onChangePage, pageSize: pagingSetting?.pageSize ?? 0, currentPage: pagingSetting?.currentPage ?? 0, pageOptions: pagingSetting?.pageOptions ?? [20, 30, 50, 100], totalItem: pagingClient ? totalCount : pagingSetting?.totalItem ?? 0, onChangePageSize: onChangePageSize })) : (jsxRuntime.jsx(jsxRuntime.Fragment, {}))] }), jsxRuntime.jsx(SidebarSetColumn, { handleSidebar: () => {
|
|
43737
43777
|
setOpenPopupSetupColumn(!openPopupSetupColumn);
|
|
43738
|
-
}, openSidebar: openPopupSetupColumn, column: [...contentColumns], setColumn: (newColumns) => {
|
|
43778
|
+
}, openSidebar: openPopupSetupColumn, column: [...contentColumns], resetDefaultColumns: resetDefaultColumns, setColumn: (newColumns) => {
|
|
43739
43779
|
if (saveSettingColumn) {
|
|
43740
|
-
console.log(newColumns);
|
|
43741
43780
|
saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
|
|
43742
43781
|
}
|
|
43743
|
-
newColumns.forEach((x) => {
|
|
43744
|
-
const column = columns.find((y) => y.field === x.field);
|
|
43745
|
-
if (column) {
|
|
43746
|
-
column.visible = x.visible;
|
|
43747
|
-
column.fixedType = x.fixedType;
|
|
43748
|
-
column.width = x.width;
|
|
43749
|
-
}
|
|
43750
|
-
});
|
|
43751
|
-
setRefreshColumns(!refreshColumns);
|
|
43752
43782
|
} })] }));
|
|
43753
43783
|
});
|
|
43754
43784
|
|