react-table-edit 1.4.10 → 1.4.12
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/edit-form/index.d.ts +1 -1
- package/dist/component/table/button-handle.d.ts +3 -3
- package/dist/component/table/header.d.ts +2 -1
- package/dist/index.js +134 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -22,13 +22,13 @@ type Props = {
|
|
|
22
22
|
menuWidth?: number;
|
|
23
23
|
rowData: any;
|
|
24
24
|
indexRow: any;
|
|
25
|
-
template?: any;
|
|
26
25
|
onKeyDown?: any;
|
|
27
26
|
defaultValues?: any;
|
|
28
27
|
schema?: InferType<any>;
|
|
29
28
|
onFormOpen?: (rowData: any, itemsField: FromItemsField[], setItemsField: Dispatch<SetStateAction<FromItemsField[]>>) => void;
|
|
30
29
|
onFormSubmit?: (rowData: any, setValue: UseFormSetValue<any>, getValues: UseFormGetValues<any>, reset: UseFormReset<any>) => void;
|
|
31
30
|
footerTemplate?: (rowData: any) => JSX.Element;
|
|
31
|
+
template?: (row: any, indexRow: number) => JSX.Element | string | number | undefined;
|
|
32
32
|
onChangeField?: (rowData: any, field: string, setValue: UseFormSetValue<any>, getValues: UseFormGetValues<any>) => void;
|
|
33
33
|
onChange: (rowData: any) => void;
|
|
34
34
|
onPaste?: (e: ClipboardEvent<HTMLInputElement>) => void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IFTableEditButton, IFTableEditPaging, IFTableEditToolbar } from "../type";
|
|
2
|
-
export declare const handleAdd: (dataSource: any[], tableElement: any, columnFistEdit: any, changeDataSource: (data: any[],
|
|
2
|
+
export declare const handleAdd: (dataSource: any[], tableElement: any, columnFistEdit: any, changeDataSource: (data: any[], numberOfRows?: number) => void, pagingSetting: {
|
|
3
3
|
setCurrentPage?: (page: number) => void;
|
|
4
4
|
pageSize?: number;
|
|
5
|
-
} | undefined, setIndexFocus: (item: number) => void, focusNewElement: (col: number, row: number, onLoad?: boolean) => void) => void;
|
|
5
|
+
} | undefined, setIndexFocus: (item: number) => void, focusNewElement: (col: number, row: number, onLoad?: boolean) => void, numberOfRows?: number) => void;
|
|
6
6
|
export declare const handleDuplicate: (dataSource: any[], indexFocus: number, fieldKey: string | undefined, defaultValue: any, fieldUniKey: string[], changeDataSource: (data: any[]) => void, tableElement: any, totalCount: number, toolbarSetting?: IFTableEditToolbar, buttonSetting?: IFTableEditButton, editDisable?: boolean, addDisable?: boolean, onDuplicate?: (newData: any, index: number) => void, // sự kiện khi duplicate
|
|
7
7
|
pagingClient?: boolean, pagingSetting?: IFTableEditPaging) => Promise<void>;
|
|
8
8
|
export declare const handleInsertAfter: (dataSource: any[], indexFocus: number, defaultValue: any, changeDataSource: (data: any[]) => void, tableElement: any, totalCount: number, pagingClient?: boolean, pagingSetting?: IFTableEditPaging, toolbarSetting?: IFTableEditToolbar, buttonSetting?: IFTableEditButton, editDisable?: boolean, addDisable?: boolean) => void;
|
|
9
9
|
export declare const handleInsertBefore: (dataSource: any[], indexFocus: number, defaultValue: any, changeDataSource: (data: any[]) => void, pagingClient?: boolean, pagingSetting?: IFTableEditPaging, toolbarSetting?: IFTableEditToolbar, buttonSetting?: IFTableEditButton, editDisable?: boolean, addDisable?: boolean) => void;
|
|
10
|
-
export declare const handleDeleteAll: (t: any, messageBoxConfirmDelete: (t: any, callback: () => void, message: string) => void, setIndexFocus: (item: number) => void, changeDataSource: (data: any[]
|
|
10
|
+
export declare const handleDeleteAll: (t: any, messageBoxConfirmDelete: (t: any, callback: () => void, message: string) => void, setIndexFocus: (item: number) => void, changeDataSource: (data: any[]) => void, editDisable?: boolean, addDisable?: boolean, toolbarSetting?: IFTableEditToolbar, buttonSetting?: IFTableEditButton) => void;
|
|
@@ -10,7 +10,8 @@ type IFDataProps = {
|
|
|
10
10
|
setColumn: Dispatch<SetStateAction<IHeaderColumnTable[]>>;
|
|
11
11
|
indexCol: number;
|
|
12
12
|
indexParent: number;
|
|
13
|
-
|
|
13
|
+
objWidthFixLeft: any;
|
|
14
|
+
objWidthFixRight: any;
|
|
14
15
|
totalCount: number;
|
|
15
16
|
selectedRows: any[];
|
|
16
17
|
isMulti: boolean;
|
package/dist/index.js
CHANGED
|
@@ -23061,12 +23061,13 @@ const SelectTableBox$1 = (props) => {
|
|
|
23061
23061
|
|
|
23062
23062
|
const defaultWidth = 200;
|
|
23063
23063
|
const EditForm = React$5.forwardRef((props, ref) => {
|
|
23064
|
-
const { id, field, displayValue, menuHeight, menuWidth, rowData, invalid, onChange, onChangeField, onKeyDown, defaultValues, placeholder, textAlign, schema, onFormOpen, onFormSubmit, footerTemplate, minWidth, onPaste, openOnFocus, isClearable, labelSize = 'label-small' } = props;
|
|
23064
|
+
const { id, field, displayValue, menuHeight, menuWidth, rowData, invalid, onChange, onChangeField, onKeyDown, defaultValues, placeholder, textAlign, schema, onFormOpen, onFormSubmit, footerTemplate, template, minWidth, onPaste, openOnFocus, isClearable, indexRow, labelSize = 'label-small' } = props;
|
|
23065
23065
|
const { innerWidth } = window;
|
|
23066
23066
|
const inputRef = React$5.useRef(null);
|
|
23067
23067
|
const editFormRef = React$5.useRef(null);
|
|
23068
23068
|
const buttonRef = React$5.useRef(null);
|
|
23069
23069
|
const [dropdownOpen, setDropdownOpen] = React$5.useState(false);
|
|
23070
|
+
const [isFocus, setIsFocus] = React$5.useState(false);
|
|
23070
23071
|
const [itemsField, setItemsField] = React$5.useState([]);
|
|
23071
23072
|
const { t } = reactI18next.useTranslation();
|
|
23072
23073
|
useOnClickOutside(editFormRef, () => {
|
|
@@ -23108,6 +23109,7 @@ const EditForm = React$5.forwardRef((props, ref) => {
|
|
|
23108
23109
|
else {
|
|
23109
23110
|
setDropdownOpen(true);
|
|
23110
23111
|
}
|
|
23112
|
+
inputRef?.current.focus();
|
|
23111
23113
|
};
|
|
23112
23114
|
const handleOnSubmit = (val) => {
|
|
23113
23115
|
closeMenu();
|
|
@@ -23221,7 +23223,26 @@ const EditForm = React$5.forwardRef((props, ref) => {
|
|
|
23221
23223
|
}
|
|
23222
23224
|
}) }));
|
|
23223
23225
|
};
|
|
23224
|
-
|
|
23226
|
+
React$5.useEffect(() => {
|
|
23227
|
+
if (inputRef) {
|
|
23228
|
+
inputRef.current.addEventListener('blur', function () {
|
|
23229
|
+
setIsFocus(false);
|
|
23230
|
+
});
|
|
23231
|
+
inputRef.current.addEventListener('focus', function () {
|
|
23232
|
+
if (!isFocus) {
|
|
23233
|
+
setIsFocus(true);
|
|
23234
|
+
}
|
|
23235
|
+
});
|
|
23236
|
+
}
|
|
23237
|
+
}, [inputRef]);
|
|
23238
|
+
return (jsxRuntime.jsx("div", { className: "form-edit", ref: ref, id: id, children: jsxRuntime.jsx("div", { ref: editFormRef, children: jsxRuntime.jsxs(Dropdown$1, { isOpen: dropdownOpen, toggle: () => { }, children: [jsxRuntime.jsx(DropdownToggle$1, { tag: 'div', children: jsxRuntime.jsxs("div", { className: classnames('display-value', { 'r-is-focus': isFocus || dropdownOpen }, { 'is-invalid': invalid }), onClick: handleOnClick, children: [template?.(rowData, indexRow) ?? displayValue, jsxRuntime.jsx(Input$1, { style: {
|
|
23239
|
+
width: template ? 0 : '100%',
|
|
23240
|
+
height: template ? 0 : 28,
|
|
23241
|
+
lineHeight: template ? 0 : 19,
|
|
23242
|
+
padding: template ? 0 : 'auto',
|
|
23243
|
+
backgroundColor: '#FFF',
|
|
23244
|
+
textAlign: textAlign ?? 'left'
|
|
23245
|
+
}, placeholder: placeholder, innerRef: inputRef, onKeyDown: (e) => handleOnKeyDown(e), onPaste: (e) => onPaste && onPaste(e), readOnly: true })] }) }), jsxRuntime.jsx(DropdownMenu$1, { className: 'formula-dropdown icon-dropdown p-0', style: {
|
|
23225
23246
|
minWidth: minWidth ? minWidth : defaultWidth,
|
|
23226
23247
|
width: menuWidth ? menuWidth : 'min-content',
|
|
23227
23248
|
maxWidth: innerWidth > 1280 ? 1280 : innerWidth,
|
|
@@ -41715,7 +41736,7 @@ var css_248z$1 = ".react-resizable {\n position: relative;\n}\n.react-resizable
|
|
|
41715
41736
|
styleInject(css_248z$1);
|
|
41716
41737
|
|
|
41717
41738
|
const HeaderTableCol = (props) => {
|
|
41718
|
-
const { selectEnable, dataSource, setSelectedRows, col, indexCol, indexParent,
|
|
41739
|
+
const { selectEnable, dataSource, setSelectedRows, col, indexCol, indexParent, objWidthFixLeft, objWidthFixRight, totalCount, selectedRows, column, setColumn, isMulti } = props;
|
|
41719
41740
|
const { t } = reactI18next.useTranslation();
|
|
41720
41741
|
const handleResize = (e, { size }) => {
|
|
41721
41742
|
// Update the column width here
|
|
@@ -41723,16 +41744,22 @@ const HeaderTableCol = (props) => {
|
|
|
41723
41744
|
if (size.width > 50) {
|
|
41724
41745
|
const newColumns = [...column];
|
|
41725
41746
|
newColumns[indexCol].width = size.width;
|
|
41747
|
+
if ((column[indexCol]?.maxWidth ?? 0) < size.width) {
|
|
41748
|
+
newColumns[indexCol].maxWidth = size.width;
|
|
41749
|
+
}
|
|
41750
|
+
if ((column[indexCol]?.minWidth ?? 0) > size.width) {
|
|
41751
|
+
newColumns[indexCol].minWidth = size.width;
|
|
41752
|
+
}
|
|
41726
41753
|
setColumn(newColumns);
|
|
41727
41754
|
}
|
|
41728
41755
|
};
|
|
41729
41756
|
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 : undefined, colSpan: col.columns?.filter(x => x.visible !== false)?.length ?? 1, className: classnames(`r-headercell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
41730
41757
|
top: `${indexParent * 42}px`,
|
|
41731
|
-
left: col.fixedType === 'left' ?
|
|
41732
|
-
right: col.fixedType === 'right' ?
|
|
41758
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[col.index ?? 0] : undefined,
|
|
41759
|
+
right: col.fixedType === 'right' ? objWidthFixRight[col.index ?? 0] : undefined,
|
|
41733
41760
|
width: col.width ? typeof col.width === 'number' ? col.width : col.width?.includes('px') || col.width?.includes('%') ? col.width : `${col.width}px` : 'auto',
|
|
41734
|
-
minWidth: col.width ? typeof col.
|
|
41735
|
-
maxWidth: col.width ? typeof col.
|
|
41761
|
+
minWidth: col.fixedType ? col.width : col.minWidth ? typeof col.minWidth === 'number' ? col.minWidth : col.minWidth?.includes('px') || col.minWidth?.includes('%') ? col.minWidth : `${col.minWidth}px` : 'auto',
|
|
41762
|
+
maxWidth: col.fixedType ? col.width : col.maxWidth ? typeof col.maxWidth === 'number' ? col.maxWidth : col.maxWidth?.includes('px') || col.maxWidth?.includes('%') ? col.maxWidth : `${col.maxWidth}px` : 'auto'
|
|
41736
41763
|
}, children: jsxRuntime.jsxs("div", { style: { justifyContent: col.textAlign ?? 'left' }, className: classnames('r-headercell-div'), children: [col.field === 'checkbox' && (jsxRuntime.jsx(Input$1, { checked: totalCount > 0 && selectedRows?.length >= totalCount, type: "checkbox", className: classnames('cursor-pointer', { 'd-none': !isMulti }), style: { textAlign: col.textAlign ?? 'left', marginTop: 6 }, onChange: (e) => {
|
|
41737
41764
|
if (selectEnable) {
|
|
41738
41765
|
if (e.target.checked) {
|
|
@@ -42136,11 +42163,11 @@ const RenderToolbarTop = ({ toolbarTopOption }) => {
|
|
|
42136
42163
|
|
|
42137
42164
|
const handleAdd = (dataSource, tableElement, columnFistEdit,
|
|
42138
42165
|
/*eslint-disable*/
|
|
42139
|
-
changeDataSource, pagingSetting, setIndexFocus, focusNewElement
|
|
42166
|
+
changeDataSource, pagingSetting, setIndexFocus, focusNewElement,
|
|
42140
42167
|
/*eslint-enable*/
|
|
42141
|
-
) => {
|
|
42168
|
+
numberOfRows) => {
|
|
42142
42169
|
const lengthData = dataSource.length;
|
|
42143
|
-
changeDataSource(dataSource,
|
|
42170
|
+
changeDataSource(dataSource, numberOfRows ?? 1);
|
|
42144
42171
|
if (pagingSetting?.setCurrentPage) {
|
|
42145
42172
|
pagingSetting?.setCurrentPage(Math.floor(lengthData / (pagingSetting?.pageSize ?? 0)) + 1);
|
|
42146
42173
|
}
|
|
@@ -42224,14 +42251,14 @@ editDisable, addDisable, toolbarSetting, buttonSetting) => {
|
|
|
42224
42251
|
messageBoxConfirmDelete(t, () => {
|
|
42225
42252
|
if (!editDisable && !addDisable) {
|
|
42226
42253
|
setIndexFocus(-1);
|
|
42227
|
-
changeDataSource([]
|
|
42254
|
+
changeDataSource([]);
|
|
42228
42255
|
}
|
|
42229
42256
|
}, '');
|
|
42230
42257
|
}
|
|
42231
42258
|
};
|
|
42232
42259
|
|
|
42233
42260
|
const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleInsertAfter, handleDeleteAll, setOpenPopupSetupColumn, indexFocus, editDisable, addDisable, buttonSetting, toolbarSetting, headerColumns, t }) => {
|
|
42234
|
-
return (jsxRuntime.jsx("div", { id: "table_custom_bottom_toolbar", className: "r-toolbar r-toolbar-bottom", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: jsxRuntime.jsxs("div", { className: "r-toolbar-items", children: [jsxRuntime.jsxs("div", { className: "r-toolbar-left", children: [jsxRuntime.
|
|
42261
|
+
return (jsxRuntime.jsx("div", { id: "table_custom_bottom_toolbar", className: "r-toolbar r-toolbar-bottom", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: jsxRuntime.jsxs("div", { className: "r-toolbar-items", children: [jsxRuntime.jsxs("div", { className: "r-toolbar-left", children: [jsxRuntime.jsxs("div", { className: classnames('r-toolbar-item d-flex', { 'd-none': editDisable || addDisable }), "aria-disabled": "false", children: [jsxRuntime.jsx(Button$1, { color: 'success', outline: true, onClick: () => handleAdd(1), className: 'd-flex', children: t('Add item') }), jsxRuntime.jsxs(UncontrolledDropdown, { className: 'nav-item', children: [jsxRuntime.jsx(DropdownToggle$1, { tag: 'div', className: 'me-0 d-flex', children: jsxRuntime.jsx(Button$1, { type: 'button', color: 'success', outline: true, style: { marginLeft: -1 }, className: 'px-25', children: jsxRuntime.jsx("svg", { fill: '#28c76f', height: "15", width: "20", viewBox: "0 0 20 20", children: jsxRuntime.jsx("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) }) }) }), jsxRuntime.jsxs(DropdownMenu$1, { className: 'formula-dropdown icon-dropdown p-0', style: { width: 60 }, children: [jsxRuntime.jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(10), children: " 10 " }), jsxRuntime.jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(20), children: " 20 " }), jsxRuntime.jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(30), children: " 30 " }), jsxRuntime.jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(40), children: " 40 " }), jsxRuntime.jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(50), children: " 50 " })] })] })] }), (indexFocus ?? -1) > -1 ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: classnames('r-toolbar-item', { 'd-none': editDisable || addDisable || buttonSetting?.duplicateDisable }), "aria-disabled": "false", children: jsxRuntime.jsx(Button$1, { color: 'success', outline: true, onClick: () => { handleDuplicate(); }, className: 'd-flex', children: t('Duplicate') }) }), jsxRuntime.jsx("div", { className: classnames('r-toolbar-item', { 'd-none': editDisable || addDisable || buttonSetting?.insertBeforeDisable }), "aria-disabled": "false", children: jsxRuntime.jsx(Button$1, { color: 'success', outline: true, onClick: handleInsertBefore, className: 'd-flex', children: t('Insert item before') }) }), jsxRuntime.jsx("div", { className: classnames('r-toolbar-item', { 'd-none': editDisable || addDisable || buttonSetting?.insertAfterDisable }), "aria-disabled": "false", children: jsxRuntime.jsx(Button$1, { color: 'success', outline: true, onClick: handleInsertAfter, className: 'd-flex', children: t('Insert item after') }) })] }) : jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }), jsxRuntime.jsx("div", { className: classnames('r-toolbar-item', { 'd-none': editDisable || buttonSetting?.deleteAllDisable }), "aria-disabled": "false", children: jsxRuntime.jsx(Button$1, { color: 'primary', outline: true, onClick: handleDeleteAll, className: 'd-flex', children: t('Delete all item') }) }), toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
42235
42262
|
return ((item.align === 'left') ? jsxRuntime.jsx("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : '');
|
|
42236
42263
|
})] }), jsxRuntime.jsx("div", { className: "r-toolbar-center", children: toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
42237
42264
|
return ((item.align === 'center') ? jsxRuntime.jsx("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-center-${index}`) : '');
|
|
@@ -42459,9 +42486,9 @@ const EditFormInline = React$5.forwardRef((props, ref) => {
|
|
|
42459
42486
|
onFormOpen(rowData, itemsField, setItemsField);
|
|
42460
42487
|
}
|
|
42461
42488
|
setOnFocus(true);
|
|
42462
|
-
}, onKeyDown: e => formKeyDown(e, handleSubmit), children: template ? template(rowData, indexRow) : displayValue }), jsxRuntime.jsx("div", { className: `form__edit ${onFocus ? 'active' : ''}`, onKeyDown: e => handleOnKeyDown(), children: itemsField.map((item, index) => {
|
|
42489
|
+
}, onKeyDown: e => formKeyDown(e, handleSubmit), children: template ? template(rowData, indexRow) : displayValue }), onFocus && jsxRuntime.jsx("div", { className: `form__edit ${onFocus ? 'active' : ''}`, style: { width: (itemsField?.length ?? 0) * 95 }, onKeyDown: e => handleOnKeyDown(), children: itemsField.map((item, index) => {
|
|
42463
42490
|
if (item.type === 'numeric') {
|
|
42464
|
-
return (jsxRuntime.jsx("div", { className: "form__element", onKeyDown: e => formItemKeyDown(e, index), children: jsxRuntime.jsx(NumberInput, { id: `form-element-${field}-${index}`, control: control, name: item.name, label: item.label ? item.label : '', labelSize: `${labelSize}`, errors: errors[item.name], disabled: item.disabled, min: item.min, max: item.max, inLine: false, fractionCurrency: item.fraction, callback: () => { elementChange(item.name); } }, index) }, index));
|
|
42491
|
+
return (jsxRuntime.jsx("div", { style: { minWidth: 90 }, className: "form__element", onKeyDown: e => formItemKeyDown(e, index), children: jsxRuntime.jsx(NumberInput, { id: `form-element-${field}-${index}`, control: control, name: item.name, label: item.label ? item.label : '', labelSize: `${labelSize}`, errors: errors[item.name], disabled: item.disabled, min: item.min, max: item.max, inLine: false, fractionCurrency: item.fraction, callback: () => { elementChange(item.name); } }, index) }, index));
|
|
42465
42492
|
}
|
|
42466
42493
|
else if (item.type === 'text') {
|
|
42467
42494
|
return (jsxRuntime.jsx("div", { className: "form__element", onKeyDown: e => formItemKeyDown(e, index), children: jsxRuntime.jsx(TextInput, { id: `form-element-${field}-${index}`, control: control, name: item.name, label: item.label ? item.label : '', labelSize: `${labelSize}`, inLine: false, errors: errors[item.name], disabled: item.disabled, callback: () => { elementChange(item.name); } }, index) }, index));
|
|
@@ -42488,7 +42515,10 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42488
42515
|
const [levelCol, setLevelCol] = React$5.useState(0);
|
|
42489
42516
|
const [columnFistEdit, setColumnFistEdit] = React$5.useState(0);
|
|
42490
42517
|
const [columnLastEdit, setColumnlastEdit] = React$5.useState(0);
|
|
42491
|
-
const [
|
|
42518
|
+
const [objWidthFixRight, setObjWidthFixRight] = React$5.useState({});
|
|
42519
|
+
const [objWidthFixLeft, setObjWidthFixLeft] = React$5.useState({});
|
|
42520
|
+
const [lastObjWidthFixLeft, setLastObjWidthFixLeft] = React$5.useState(0);
|
|
42521
|
+
const [fisrtObjWidthFixRight, setFisrtObjWidthFixRight] = React$5.useState(0);
|
|
42492
42522
|
const [openPopupSetupColumn, setOpenPopupSetupColumn] = React$5.useState(false);
|
|
42493
42523
|
const [searchTerm, setSearchTerm] = React$5.useState('');
|
|
42494
42524
|
const tableElement = React$5.useRef(null);
|
|
@@ -42515,12 +42545,14 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42515
42545
|
headerColumns[0][index].fixedType = item.fixedType;
|
|
42516
42546
|
}
|
|
42517
42547
|
if (item.fixedType === 'left' && item.visible !== false) {
|
|
42518
|
-
|
|
42548
|
+
setLastObjWidthFixLeft(index);
|
|
42549
|
+
objWidthFixLeft[index] = letfWidthFix;
|
|
42519
42550
|
letfWidthFix += Number(item.width ?? 40);
|
|
42520
42551
|
}
|
|
42521
42552
|
const lasColumn = contentColumns[contentColumns.length - 1 - index];
|
|
42522
42553
|
if (lasColumn.fixedType === 'right' && lasColumn.visible !== false) {
|
|
42523
|
-
|
|
42554
|
+
setFisrtObjWidthFixRight(contentColumns.length - 1 - index);
|
|
42555
|
+
objWidthFixRight[contentColumns.length - 1 - index] = rightWidthFix;
|
|
42524
42556
|
rightWidthFix += Number(lasColumn.width ?? 40);
|
|
42525
42557
|
}
|
|
42526
42558
|
if (item.editEnable && (item.visible !== false) && (!item.disabledCondition)) {
|
|
@@ -42533,7 +42565,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42533
42565
|
if (levelCol === 1) {
|
|
42534
42566
|
setHeaderColumns([...headerColumns]);
|
|
42535
42567
|
}
|
|
42536
|
-
|
|
42568
|
+
setObjWidthFixLeft(objWidthFixLeft);
|
|
42569
|
+
setObjWidthFixRight(objWidthFixRight);
|
|
42537
42570
|
setColumnFistEdit(indexFirst + 1);
|
|
42538
42571
|
setColumnlastEdit(indexlast + 1);
|
|
42539
42572
|
}, [contentColumns]);
|
|
@@ -42648,7 +42681,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42648
42681
|
else {
|
|
42649
42682
|
toolbarTopOption = [...defaultToolbarOption];
|
|
42650
42683
|
}
|
|
42651
|
-
const
|
|
42684
|
+
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42652
42685
|
/*eslint-disable */
|
|
42653
42686
|
switch (col?.editTypeCondition ? col?.editTypeCondition(row) : col.editType) {
|
|
42654
42687
|
case 'date':
|
|
@@ -42759,31 +42792,29 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42759
42792
|
else {
|
|
42760
42793
|
valueSelectTree = (!isNullOrUndefined$1(row[col.field]) && row[col.field] !== '') ? findItemInTree(optionsSelectTree, row[col.field]) : '';
|
|
42761
42794
|
}
|
|
42762
|
-
return (jsxRuntime.jsx(
|
|
42795
|
+
return (jsxRuntime.jsx(SelectTableTree, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelectTree, options: optionsSelectTree, onChange: (val) => {
|
|
42796
|
+
if (col.selectSettings?.isMulti) {
|
|
42797
|
+
row[col.field] = !isNullOrUndefined$1(val) ? val : [];
|
|
42798
|
+
}
|
|
42799
|
+
else {
|
|
42800
|
+
row[col.field] = !isNullOrUndefined$1(val) ? val[col.selectSettings?.fieldValue ?? 'value'] : undefined;
|
|
42801
|
+
}
|
|
42802
|
+
if (col.callback) {
|
|
42803
|
+
col.callback(val, indexRow, row);
|
|
42804
|
+
}
|
|
42805
|
+
handleDataChange(row, col, indexRow);
|
|
42806
|
+
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t('Select'), onOpenMenu: () => {
|
|
42807
|
+
if (col.selectSettings?.onOpenMenu) {
|
|
42808
|
+
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42809
|
+
}
|
|
42810
|
+
}, loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, fieldChildren: col.selectSettings?.fieldChild ?? 'children', selectChilds: col.selectSettings?.selectChilds, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, invalid: col.validate && col.validate(row[col.field], row), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? 'left', onKeyDown: (e) => {
|
|
42763
42811
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) ;
|
|
42764
|
-
},
|
|
42765
|
-
|
|
42766
|
-
|
|
42767
|
-
|
|
42768
|
-
|
|
42769
|
-
|
|
42770
|
-
}
|
|
42771
|
-
if (col.callback) {
|
|
42772
|
-
col.callback(val, indexRow, row);
|
|
42773
|
-
}
|
|
42774
|
-
handleDataChange(row, col, indexRow);
|
|
42775
|
-
}, fieldValue: col.selectSettings?.fieldValue, fieldLabel: col.selectSettings?.fieldLabel, component: gridRef, columns: col.selectSettings?.columns, isClearable: col.selectSettings?.isClearable ?? false, formatSetting: formatSetting, placeholder: t('Select'), onOpenMenu: () => {
|
|
42776
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
42777
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42778
|
-
}
|
|
42779
|
-
}, loadOptions: col.selectSettings?.loadOptions, handleAdd: col.selectSettings?.handAddNew ? (e) => col.selectSettings?.handAddNew(e, indexRow, row) : undefined, fieldChildren: col.selectSettings?.fieldChild ?? 'children', selectChilds: col.selectSettings?.selectChilds, showFooter: col.selectSettings?.showFooter, formatOptionLabel: col.selectSettings?.formatOptionLabel, footerComponent: col.selectSettings?.footerComponent, width: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, isMulti: col.selectSettings?.isMulti, noHeader: col.selectSettings?.noHeader, invalid: col.validate && col.validate(row[col.field], row), maxHeight: col.selectSettings?.heightPopup ? Number(col.selectSettings?.heightPopup) : undefined, menuWidth: col.selectSettings?.widthPopup ? Number(col.selectSettings?.widthPopup) : undefined, textAlign: col.textAlign ?? 'left', onKeyDown: (e) => {
|
|
42780
|
-
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) ;
|
|
42781
|
-
}, onPaste: (e) => {
|
|
42782
|
-
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42783
|
-
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42784
|
-
e.preventDefault();
|
|
42785
|
-
}
|
|
42786
|
-
} }) }));
|
|
42812
|
+
}, onPaste: (e) => {
|
|
42813
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42814
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42815
|
+
e.preventDefault();
|
|
42816
|
+
}
|
|
42817
|
+
} }));
|
|
42787
42818
|
case 'checkbox':
|
|
42788
42819
|
return (jsxRuntime.jsx(Input$1, { checked: row[col.field], id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, type: "checkbox", className: "input-checkbox cursor-pointer", style: { textAlign: col.textAlign ?? 'left', marginTop: 6 }, onChange: (val) => {
|
|
42789
42820
|
row[col.field] = val.currentTarget.checked;
|
|
@@ -42848,7 +42879,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42848
42879
|
return (jsxRuntime.jsx(EditForm, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) : '', placeholder: col.placeholder ? t(col.placeholder) : '', rowData: row, indexRow: indexRow, onChange: (val) => {
|
|
42849
42880
|
Object.assign(row, val);
|
|
42850
42881
|
handleDataChange(row, col, indexRow);
|
|
42851
|
-
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, onKeyDown: (e) => {
|
|
42882
|
+
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
42852
42883
|
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42853
42884
|
}, onPaste: (e) => {
|
|
42854
42885
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
@@ -42924,7 +42955,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42924
42955
|
};
|
|
42925
42956
|
//Thêm dòng mới
|
|
42926
42957
|
const moveIndexRowToNewPage = () => {
|
|
42927
|
-
changeDataSource(dataSource,
|
|
42958
|
+
changeDataSource(dataSource, 1);
|
|
42928
42959
|
if (pagingClient && pagingSetting?.setCurrentPage && (totalCount % (pagingSetting?.pageSize ?? 0)) === 0) {
|
|
42929
42960
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 0) + 1);
|
|
42930
42961
|
}
|
|
@@ -42991,13 +43022,13 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42991
43022
|
}, 50);
|
|
42992
43023
|
});
|
|
42993
43024
|
const getColumn = (col, index) => {
|
|
42994
|
-
const column = contentColumns
|
|
43025
|
+
const column = contentColumns[col + index];
|
|
42995
43026
|
if (column) {
|
|
42996
43027
|
return { ...column };
|
|
42997
43028
|
}
|
|
42998
43029
|
return undefined;
|
|
42999
43030
|
};
|
|
43000
|
-
const pasteDataFromExcel = async (currenRowIndex,
|
|
43031
|
+
const pasteDataFromExcel = async (currenRowIndex, indexCol, e) => {
|
|
43001
43032
|
const clipboard = (e.clipboardData || window.Clipboard).getData('text');
|
|
43002
43033
|
const rowsClipboard = clipboard.trimEnd().split('\n');
|
|
43003
43034
|
setIndexFocus(-1);
|
|
@@ -43013,7 +43044,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43013
43044
|
stringData.push(element.trimEnd().split('\t')[index].toString().trim());
|
|
43014
43045
|
}
|
|
43015
43046
|
});
|
|
43016
|
-
const column = getColumn(
|
|
43047
|
+
const column = getColumn(indexCol, index);
|
|
43048
|
+
console.log(column);
|
|
43017
43049
|
if (column) {
|
|
43018
43050
|
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
|
|
43019
43051
|
const rs = await column.onPasteValidate(stringData.join(','), currenRowIndex + 0, dataSource[currenRowIndex + 0]);
|
|
@@ -43090,8 +43122,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43090
43122
|
}
|
|
43091
43123
|
}
|
|
43092
43124
|
else if (column.editType === 'select') {
|
|
43093
|
-
|
|
43094
|
-
if (rs) {
|
|
43125
|
+
if (column.selectSettings?.allowCreate) {
|
|
43095
43126
|
if (column.onPaste) {
|
|
43096
43127
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
43097
43128
|
}
|
|
@@ -43099,11 +43130,25 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43099
43130
|
dataRow[column.field] = stringData;
|
|
43100
43131
|
}
|
|
43101
43132
|
if (column.callback) {
|
|
43102
|
-
column.callback(
|
|
43133
|
+
column.callback(stringData, currenRowIndex + indexRow);
|
|
43103
43134
|
}
|
|
43104
43135
|
}
|
|
43105
43136
|
else {
|
|
43106
|
-
|
|
43137
|
+
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ?? 'value'] === stringData);
|
|
43138
|
+
if (rs) {
|
|
43139
|
+
if (column.onPaste) {
|
|
43140
|
+
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
43141
|
+
}
|
|
43142
|
+
else {
|
|
43143
|
+
dataRow[column.field] = stringData;
|
|
43144
|
+
}
|
|
43145
|
+
if (column.callback) {
|
|
43146
|
+
column.callback(rs, currenRowIndex + indexRow);
|
|
43147
|
+
}
|
|
43148
|
+
}
|
|
43149
|
+
else {
|
|
43150
|
+
notificationError(t('PasteExcelNotExist', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43151
|
+
}
|
|
43107
43152
|
}
|
|
43108
43153
|
}
|
|
43109
43154
|
else {
|
|
@@ -43128,7 +43173,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43128
43173
|
}
|
|
43129
43174
|
changeDataSource(dataSource);
|
|
43130
43175
|
};
|
|
43131
|
-
const changeDataSource = (data,
|
|
43176
|
+
const changeDataSource = (data, numberOfRows) => {
|
|
43132
43177
|
if (!editDisable && setDataSource) {
|
|
43133
43178
|
if ((searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm)) {
|
|
43134
43179
|
if (searchSetting?.setSearchTerm) {
|
|
@@ -43138,8 +43183,10 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43138
43183
|
setSearchTerm('');
|
|
43139
43184
|
}
|
|
43140
43185
|
}
|
|
43141
|
-
if (
|
|
43142
|
-
|
|
43186
|
+
if (numberOfRows && !addDisable) {
|
|
43187
|
+
for (let index = 0; index < numberOfRows; index++) {
|
|
43188
|
+
data.push(defaultValue ? { ...defaultValue, [fieldKey]: disableAutoKey ? undefined : generateUUID() } : {});
|
|
43189
|
+
}
|
|
43143
43190
|
setDataSource([...data]);
|
|
43144
43191
|
}
|
|
43145
43192
|
else {
|
|
@@ -43195,16 +43242,16 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43195
43242
|
}, [selectedItem]);
|
|
43196
43243
|
const renderContentCol = (col, row, indexRow, indexCol, isSelected) => {
|
|
43197
43244
|
if (col.field === 'command') {
|
|
43198
|
-
return (col.visible !== false && jsxRuntime.jsx("td", { className: classnames(`r-rowcell p-0 fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43199
|
-
left: col.fixedType === 'left' ?
|
|
43200
|
-
right: col.fixedType === 'right' ?
|
|
43245
|
+
return (col.visible !== false && jsxRuntime.jsx("td", { className: classnames(`r-rowcell p-0 fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'cell-fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43246
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
43247
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
43201
43248
|
textAlign: col.textAlign ? col.textAlign : 'left',
|
|
43202
43249
|
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div command", children: jsxRuntime.jsx(CommandElement, { commandItems: col.commandItems ?? [], handleCommandClick: handleCommandClick, indexRow: indexRow, rowData: row, setIndexFocus: setIndexFocus, indexFocus: indexFocus }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43203
43250
|
}
|
|
43204
43251
|
else if (col.field === '#') {
|
|
43205
|
-
return (col.visible !== false && jsxRuntime.jsx("td", { className: classnames(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), tabIndex: Number(`${indexRow}${indexCol}`), style: {
|
|
43206
|
-
left: col.fixedType === 'left' ?
|
|
43207
|
-
right: col.fixedType === 'right' ?
|
|
43252
|
+
return (col.visible !== false && jsxRuntime.jsx("td", { className: classnames(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'cell-fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), tabIndex: Number(`${indexRow}${indexCol}`), style: {
|
|
43253
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
43254
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
43208
43255
|
textAlign: 'center',
|
|
43209
43256
|
}, onCopy: (e) => {
|
|
43210
43257
|
if (!editDisable && (e.target.nodeName === 'DIV' || e.target.nodeName === 'TD')) {
|
|
@@ -43240,11 +43287,10 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43240
43287
|
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div", children: indexRow + 1 }) }, `col-${indexRow}-${indexCol}`));
|
|
43241
43288
|
}
|
|
43242
43289
|
else if (col.field === 'checkbox') {
|
|
43243
|
-
return (jsxRuntime.jsx("td", { className: classnames(`r-rowcell p-0 fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43244
|
-
left: col.fixedType === 'left' ?
|
|
43245
|
-
right: col.fixedType === 'right' ?
|
|
43246
|
-
|
|
43247
|
-
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", onClick: (e) => {
|
|
43290
|
+
return (jsxRuntime.jsx("td", { className: classnames(`r-rowcell p-0 fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'cell-fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43291
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
43292
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
43293
|
+
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: 'center' }, onClick: (e) => {
|
|
43248
43294
|
if (selectEnable) {
|
|
43249
43295
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
43250
43296
|
if (index > -1) {
|
|
@@ -43266,7 +43312,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43266
43312
|
}
|
|
43267
43313
|
e.stopPropagation();
|
|
43268
43314
|
}
|
|
43269
|
-
}, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer",
|
|
43315
|
+
}, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? 'center' } }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43270
43316
|
}
|
|
43271
43317
|
else {
|
|
43272
43318
|
let value = row[col.field];
|
|
@@ -43281,9 +43327,9 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43281
43327
|
}
|
|
43282
43328
|
const typeDis = !editDisable && (indexFocus === indexRow || col.editType === 'checkbox') && (!col.disabledCondition || !col.disabledCondition(row)) ? (col.editEnable ? 1 : (col.template ? 2 : 3)) : (col.template ? 2 : 3);
|
|
43283
43329
|
const errorMessage = typeDis === 1 || col.field === '' || !col.validate ? '' : col.validate(row[col.field], row);
|
|
43284
|
-
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && jsxRuntime.jsx("td", { className: classnames(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43285
|
-
left: col.fixedType === 'left' ?
|
|
43286
|
-
right: col.fixedType === 'right' ?
|
|
43330
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: col.visible !== false && jsxRuntime.jsx("td", { className: classnames(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'cell-fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43331
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
43332
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
43287
43333
|
}, onClick: (e) => {
|
|
43288
43334
|
if (e.target.nodeName === 'DIV' || e.target.nodeName === 'TD') {
|
|
43289
43335
|
if (!editDisable && indexRow != indexFocus) {
|
|
@@ -43314,14 +43360,26 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43314
43360
|
}
|
|
43315
43361
|
}, children: jsxRuntime.jsx("div", { className: classnames('r-rowcell-div'), children: jsxRuntime.jsxs("div", { id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : '', className: classnames('r-rowcell-content', { 'r-is-invalid': errorMessage }), style: {
|
|
43316
43362
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
43317
|
-
}, children: [typeDis === 1 && !refreshRow
|
|
43363
|
+
}, children: [typeDis === 1 && !refreshRow && jsxRuntime.jsx(jsxRuntime.Fragment, { children: RenderEditCell(row, col, indexCol, indexRow) }), (typeDis !== 1 || refreshRow) && RenderContentCell(row, col, indexCol, indexRow, typeDis, value), jsxRuntime.jsx("span", { id: `error-${indexRow}-${indexCol}`, className: classnames('cursor-pointer text-primary icon-table', { 'd-none': !errorMessage }), children: jsxRuntime.jsx(SvgAlertCircle, { fontSize: 15.5 }) }), jsxRuntime.jsx(UncontrolledTooltip, { target: `error-${indexRow}-${indexCol}`, className: "r-tooltip tooltip-error", children: errorMessage?.toString() ?? '' })] }) }) }, `col-${indexRow}-${indexCol}`) }, indexCol));
|
|
43364
|
+
}
|
|
43365
|
+
};
|
|
43366
|
+
const RenderContentCell = (row, col, indexCol, indexRow, typeDis, value) => {
|
|
43367
|
+
if (typeDis === 2) {
|
|
43368
|
+
const value = col.template?.(row, indexRow) ?? '';
|
|
43369
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
43370
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }), (!refreshRow && typeDis !== 2) && jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.editType === 'numeric' && Number(row[col.field]) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }));
|
|
43371
|
+
}
|
|
43372
|
+
else {
|
|
43373
|
+
return value;
|
|
43374
|
+
}
|
|
43318
43375
|
}
|
|
43376
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: (col.editType === 'numeric' && Number(row[col.field]) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) }), (!(typeDis === 1 && !refreshRow) && typeDis !== 2) && jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.editType === 'numeric' && Number(row[col.field]) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }));
|
|
43319
43377
|
};
|
|
43320
43378
|
const renderFooterCol = (col, indexCol) => {
|
|
43321
43379
|
const sumValue = (col.haveSum === true && col.editType === "numeric") ? dataSource.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0) : 0;
|
|
43322
43380
|
return (jsxRuntime.jsx(React$5.Fragment, { children: (col.visible !== false) && jsxRuntime.jsx("td", { className: classnames(`p-0 px-50 r-footer fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }), style: {
|
|
43323
|
-
left: col.fixedType === 'left' ?
|
|
43324
|
-
right: col.fixedType === 'right' ?
|
|
43381
|
+
left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
|
|
43382
|
+
right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
|
|
43325
43383
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
43326
43384
|
}, children: jsxRuntime.jsxs("div", { className: "r-footer-div", children: [col.haveSum === true && col.editType === "numeric" && (Number(sumValue) >= 0) && jsxRuntime.jsx(jsxRuntime.Fragment, { children: formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false) }), col.haveSum === true && col.editType === "numeric" && (Number(sumValue) < 0) && jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${formartNumberic(sumValue, formatSetting?.decimalSeparator ?? ',', formatSetting?.thousandSeparator ?? '.', col.numericSettings?.fraction, true, false)}${formatSetting?.suffixNegative ?? ''}`] })] }) }) }, `summarycell-${indexCol}`));
|
|
43327
43385
|
};
|
|
@@ -43354,12 +43412,12 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43354
43412
|
}, [searchTerm, searchSetting?.searchTerm]);
|
|
43355
43413
|
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("thead", { className: 'r-gridheader', children: headerColumns.map((element, indexParent) => {
|
|
43356
43414
|
return (jsxRuntime.jsx("tr", { className: "r-row", role: "row", children: element?.map((col, index) => {
|
|
43357
|
-
return (jsxRuntime.jsx(HeaderTableCol, { col: col, dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false,
|
|
43415
|
+
return (jsxRuntime.jsx(HeaderTableCol, { col: col, dataSource: dataSource, indexCol: index, indexParent: indexParent, isMulti: isMulti ?? false, objWidthFixLeft: objWidthFixLeft, objWidthFixRight: objWidthFixRight, selectEnable: selectEnable ?? false, selectedRows: selectedRows, setSelectedRows: setSelectedRows, column: contentColumns, setColumn: setContentColumns, totalCount: totalCount }, `header-${indexParent}-${index}`));
|
|
43358
43416
|
}) }, `header-${-indexParent}`));
|
|
43359
43417
|
}) }), jsxRuntime.jsx("tbody", { className: 'r-gridcontent', children: renderData() }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? jsxRuntime.jsx("tr", { className: 'r-row', children: contentColumns.map((col, index) => {
|
|
43360
43418
|
return (renderFooterCol(col, index));
|
|
43361
|
-
}) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsxRuntime.jsx(ToolbarBottom, { handleAdd: () => {
|
|
43362
|
-
handleAdd(dataSource, tableElement.current, columnFistEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement);
|
|
43419
|
+
}) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsxRuntime.jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43420
|
+
handleAdd(dataSource, tableElement.current, columnFistEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement, numberOfRows);
|
|
43363
43421
|
}, handleDuplicate: () => {
|
|
43364
43422
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
43365
43423
|
}, handleInsertAfter: () => {
|