react-table-edit 1.4.10 → 1.4.11
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/index.js +107 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -23033,12 +23033,13 @@ const SelectTableBox$1 = (props) => {
|
|
|
23033
23033
|
|
|
23034
23034
|
const defaultWidth = 200;
|
|
23035
23035
|
const EditForm = forwardRef((props, ref) => {
|
|
23036
|
-
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;
|
|
23036
|
+
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;
|
|
23037
23037
|
const { innerWidth } = window;
|
|
23038
23038
|
const inputRef = useRef(null);
|
|
23039
23039
|
const editFormRef = useRef(null);
|
|
23040
23040
|
const buttonRef = useRef(null);
|
|
23041
23041
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
23042
|
+
const [isFocus, setIsFocus] = useState(false);
|
|
23042
23043
|
const [itemsField, setItemsField] = useState([]);
|
|
23043
23044
|
const { t } = useTranslation();
|
|
23044
23045
|
useOnClickOutside(editFormRef, () => {
|
|
@@ -23080,6 +23081,7 @@ const EditForm = forwardRef((props, ref) => {
|
|
|
23080
23081
|
else {
|
|
23081
23082
|
setDropdownOpen(true);
|
|
23082
23083
|
}
|
|
23084
|
+
inputRef?.current.focus();
|
|
23083
23085
|
};
|
|
23084
23086
|
const handleOnSubmit = (val) => {
|
|
23085
23087
|
closeMenu();
|
|
@@ -23193,7 +23195,26 @@ const EditForm = forwardRef((props, ref) => {
|
|
|
23193
23195
|
}
|
|
23194
23196
|
}) }));
|
|
23195
23197
|
};
|
|
23196
|
-
|
|
23198
|
+
useEffect(() => {
|
|
23199
|
+
if (inputRef) {
|
|
23200
|
+
inputRef.current.addEventListener('blur', function () {
|
|
23201
|
+
setIsFocus(false);
|
|
23202
|
+
});
|
|
23203
|
+
inputRef.current.addEventListener('focus', function () {
|
|
23204
|
+
if (!isFocus) {
|
|
23205
|
+
setIsFocus(true);
|
|
23206
|
+
}
|
|
23207
|
+
});
|
|
23208
|
+
}
|
|
23209
|
+
}, [inputRef]);
|
|
23210
|
+
return (jsx("div", { className: "form-edit", ref: ref, id: id, children: jsx("div", { ref: editFormRef, children: jsxs(Dropdown$1, { isOpen: dropdownOpen, toggle: () => { }, children: [jsx(DropdownToggle$1, { tag: 'div', children: jsxs("div", { className: classnames('display-value', { 'r-is-focus': isFocus || dropdownOpen }, { 'is-invalid': invalid }), onClick: handleOnClick, children: [template?.(rowData, indexRow) ?? displayValue, jsx(Input$1, { style: {
|
|
23211
|
+
width: template ? 0 : '100%',
|
|
23212
|
+
height: template ? 0 : 28,
|
|
23213
|
+
lineHeight: template ? 0 : 19,
|
|
23214
|
+
padding: template ? 0 : 'auto',
|
|
23215
|
+
backgroundColor: '#FFF',
|
|
23216
|
+
textAlign: textAlign ?? 'left'
|
|
23217
|
+
}, placeholder: placeholder, innerRef: inputRef, onKeyDown: (e) => handleOnKeyDown(e), onPaste: (e) => onPaste && onPaste(e), readOnly: true })] }) }), jsx(DropdownMenu$1, { className: 'formula-dropdown icon-dropdown p-0', style: {
|
|
23197
23218
|
minWidth: minWidth ? minWidth : defaultWidth,
|
|
23198
23219
|
width: menuWidth ? menuWidth : 'min-content',
|
|
23199
23220
|
maxWidth: innerWidth > 1280 ? 1280 : innerWidth,
|
|
@@ -41695,6 +41716,12 @@ const HeaderTableCol = (props) => {
|
|
|
41695
41716
|
if (size.width > 50) {
|
|
41696
41717
|
const newColumns = [...column];
|
|
41697
41718
|
newColumns[indexCol].width = size.width;
|
|
41719
|
+
if ((column[indexCol]?.maxWidth ?? 0) < size.width) {
|
|
41720
|
+
newColumns[indexCol].maxWidth = size.width;
|
|
41721
|
+
}
|
|
41722
|
+
if ((column[indexCol]?.minWidth ?? 0) > size.width) {
|
|
41723
|
+
newColumns[indexCol].minWidth = size.width;
|
|
41724
|
+
}
|
|
41698
41725
|
setColumn(newColumns);
|
|
41699
41726
|
}
|
|
41700
41727
|
};
|
|
@@ -41703,8 +41730,8 @@ const HeaderTableCol = (props) => {
|
|
|
41703
41730
|
left: col.fixedType === 'left' ? objWidthFix[col.index ?? 0] : undefined,
|
|
41704
41731
|
right: col.fixedType === 'right' ? objWidthFix[col.index ?? 0] : undefined,
|
|
41705
41732
|
width: col.width ? typeof col.width === 'number' ? col.width : col.width?.includes('px') || col.width?.includes('%') ? col.width : `${col.width}px` : 'auto',
|
|
41706
|
-
minWidth: col.width ? typeof col.
|
|
41707
|
-
maxWidth: col.width ? typeof col.
|
|
41733
|
+
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',
|
|
41734
|
+
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'
|
|
41708
41735
|
}, children: jsxs("div", { style: { justifyContent: col.textAlign ?? 'left' }, className: classnames('r-headercell-div'), children: [col.field === 'checkbox' && (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) => {
|
|
41709
41736
|
if (selectEnable) {
|
|
41710
41737
|
if (e.target.checked) {
|
|
@@ -42108,11 +42135,11 @@ const RenderToolbarTop = ({ toolbarTopOption }) => {
|
|
|
42108
42135
|
|
|
42109
42136
|
const handleAdd = (dataSource, tableElement, columnFistEdit,
|
|
42110
42137
|
/*eslint-disable*/
|
|
42111
|
-
changeDataSource, pagingSetting, setIndexFocus, focusNewElement
|
|
42138
|
+
changeDataSource, pagingSetting, setIndexFocus, focusNewElement,
|
|
42112
42139
|
/*eslint-enable*/
|
|
42113
|
-
) => {
|
|
42140
|
+
numberOfRows) => {
|
|
42114
42141
|
const lengthData = dataSource.length;
|
|
42115
|
-
changeDataSource(dataSource,
|
|
42142
|
+
changeDataSource(dataSource, numberOfRows ?? 1);
|
|
42116
42143
|
if (pagingSetting?.setCurrentPage) {
|
|
42117
42144
|
pagingSetting?.setCurrentPage(Math.floor(lengthData / (pagingSetting?.pageSize ?? 0)) + 1);
|
|
42118
42145
|
}
|
|
@@ -42196,14 +42223,14 @@ editDisable, addDisable, toolbarSetting, buttonSetting) => {
|
|
|
42196
42223
|
messageBoxConfirmDelete(t, () => {
|
|
42197
42224
|
if (!editDisable && !addDisable) {
|
|
42198
42225
|
setIndexFocus(-1);
|
|
42199
|
-
changeDataSource([]
|
|
42226
|
+
changeDataSource([]);
|
|
42200
42227
|
}
|
|
42201
42228
|
}, '');
|
|
42202
42229
|
}
|
|
42203
42230
|
};
|
|
42204
42231
|
|
|
42205
42232
|
const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleInsertAfter, handleDeleteAll, setOpenPopupSetupColumn, indexFocus, editDisable, addDisable, buttonSetting, toolbarSetting, headerColumns, t }) => {
|
|
42206
|
-
return (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: jsxs("div", { className: "r-toolbar-items", children: [jsxs("div", { className: "r-toolbar-left", children: [
|
|
42233
|
+
return (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: jsxs("div", { className: "r-toolbar-items", children: [jsxs("div", { className: "r-toolbar-left", children: [jsxs("div", { className: classnames('r-toolbar-item d-flex', { 'd-none': editDisable || addDisable }), "aria-disabled": "false", children: [jsx(Button$1, { color: 'success', outline: true, onClick: () => handleAdd(1), className: 'd-flex', children: t('Add item') }), jsxs(UncontrolledDropdown, { className: 'nav-item', children: [jsx(DropdownToggle$1, { tag: 'div', className: 'me-0 d-flex', children: jsx(Button$1, { type: 'button', color: 'success', outline: true, style: { marginLeft: -1 }, className: 'px-25', children: jsx("svg", { fill: '#28c76f', height: "15", width: "20", viewBox: "0 0 20 20", children: 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" }) }) }) }), jsxs(DropdownMenu$1, { className: 'formula-dropdown icon-dropdown p-0', style: { width: 60 }, children: [jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(10), children: " 10 " }), jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(20), children: " 20 " }), jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(30), children: " 30 " }), jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(40), children: " 40 " }), jsx(DropdownItem$1, { className: 'py-25', tag: 'div', onClick: () => handleAdd(50), children: " 50 " })] })] })] }), (indexFocus ?? -1) > -1 ? jsxs(Fragment$1, { children: [jsx("div", { className: classnames('r-toolbar-item', { 'd-none': editDisable || addDisable || buttonSetting?.duplicateDisable }), "aria-disabled": "false", children: jsx(Button$1, { color: 'success', outline: true, onClick: () => { handleDuplicate(); }, className: 'd-flex', children: t('Duplicate') }) }), jsx("div", { className: classnames('r-toolbar-item', { 'd-none': editDisable || addDisable || buttonSetting?.insertBeforeDisable }), "aria-disabled": "false", children: jsx(Button$1, { color: 'success', outline: true, onClick: handleInsertBefore, className: 'd-flex', children: t('Insert item before') }) }), jsx("div", { className: classnames('r-toolbar-item', { 'd-none': editDisable || addDisable || buttonSetting?.insertAfterDisable }), "aria-disabled": "false", children: jsx(Button$1, { color: 'success', outline: true, onClick: handleInsertAfter, className: 'd-flex', children: t('Insert item after') }) })] }) : jsx(Fragment$1, { children: " " }), jsx("div", { className: classnames('r-toolbar-item', { 'd-none': editDisable || buttonSetting?.deleteAllDisable }), "aria-disabled": "false", children: jsx(Button$1, { color: 'primary', outline: true, onClick: handleDeleteAll, className: 'd-flex', children: t('Delete all item') }) }), toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
42207
42234
|
return ((item.align === 'left') ? jsx("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : '');
|
|
42208
42235
|
})] }), jsx("div", { className: "r-toolbar-center", children: toolbarSetting?.toolbarBottomOptions?.map((item, index) => {
|
|
42209
42236
|
return ((item.align === 'center') ? jsx("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-center-${index}`) : '');
|
|
@@ -42431,9 +42458,9 @@ const EditFormInline = forwardRef((props, ref) => {
|
|
|
42431
42458
|
onFormOpen(rowData, itemsField, setItemsField);
|
|
42432
42459
|
}
|
|
42433
42460
|
setOnFocus(true);
|
|
42434
|
-
}, onKeyDown: e => formKeyDown(e, handleSubmit), children: template ? template(rowData, indexRow) : displayValue }), jsx("div", { className: `form__edit ${onFocus ? 'active' : ''}`, onKeyDown: e => handleOnKeyDown(), children: itemsField.map((item, index) => {
|
|
42461
|
+
}, onKeyDown: e => formKeyDown(e, handleSubmit), children: template ? template(rowData, indexRow) : displayValue }), onFocus && jsx("div", { className: `form__edit ${onFocus ? 'active' : ''}`, style: { width: (itemsField?.length ?? 0) * 95 }, onKeyDown: e => handleOnKeyDown(), children: itemsField.map((item, index) => {
|
|
42435
42462
|
if (item.type === 'numeric') {
|
|
42436
|
-
return (jsx("div", { className: "form__element", onKeyDown: e => formItemKeyDown(e, index), children: 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));
|
|
42463
|
+
return (jsx("div", { style: { minWidth: 90 }, className: "form__element", onKeyDown: e => formItemKeyDown(e, index), children: 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));
|
|
42437
42464
|
}
|
|
42438
42465
|
else if (item.type === 'text') {
|
|
42439
42466
|
return (jsx("div", { className: "form__element", onKeyDown: e => formItemKeyDown(e, index), children: 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));
|
|
@@ -42620,7 +42647,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42620
42647
|
else {
|
|
42621
42648
|
toolbarTopOption = [...defaultToolbarOption];
|
|
42622
42649
|
}
|
|
42623
|
-
const
|
|
42650
|
+
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42624
42651
|
/*eslint-disable */
|
|
42625
42652
|
switch (col?.editTypeCondition ? col?.editTypeCondition(row) : col.editType) {
|
|
42626
42653
|
case 'date':
|
|
@@ -42731,31 +42758,29 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42731
42758
|
else {
|
|
42732
42759
|
valueSelectTree = (!isNullOrUndefined$1(row[col.field]) && row[col.field] !== '') ? findItemInTree(optionsSelectTree, row[col.field]) : '';
|
|
42733
42760
|
}
|
|
42734
|
-
return (jsx(
|
|
42761
|
+
return (jsx(SelectTableTree, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelectTree, options: optionsSelectTree, onChange: (val) => {
|
|
42762
|
+
if (col.selectSettings?.isMulti) {
|
|
42763
|
+
row[col.field] = !isNullOrUndefined$1(val) ? val : [];
|
|
42764
|
+
}
|
|
42765
|
+
else {
|
|
42766
|
+
row[col.field] = !isNullOrUndefined$1(val) ? val[col.selectSettings?.fieldValue ?? 'value'] : undefined;
|
|
42767
|
+
}
|
|
42768
|
+
if (col.callback) {
|
|
42769
|
+
col.callback(val, indexRow, row);
|
|
42770
|
+
}
|
|
42771
|
+
handleDataChange(row, col, indexRow);
|
|
42772
|
+
}, 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: () => {
|
|
42773
|
+
if (col.selectSettings?.onOpenMenu) {
|
|
42774
|
+
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42775
|
+
}
|
|
42776
|
+
}, 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) => {
|
|
42735
42777
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) ;
|
|
42736
|
-
},
|
|
42737
|
-
|
|
42738
|
-
|
|
42739
|
-
|
|
42740
|
-
|
|
42741
|
-
|
|
42742
|
-
}
|
|
42743
|
-
if (col.callback) {
|
|
42744
|
-
col.callback(val, indexRow, row);
|
|
42745
|
-
}
|
|
42746
|
-
handleDataChange(row, col, indexRow);
|
|
42747
|
-
}, 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: () => {
|
|
42748
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
42749
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42750
|
-
}
|
|
42751
|
-
}, 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) => {
|
|
42752
|
-
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) ;
|
|
42753
|
-
}, onPaste: (e) => {
|
|
42754
|
-
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42755
|
-
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42756
|
-
e.preventDefault();
|
|
42757
|
-
}
|
|
42758
|
-
} }) }));
|
|
42778
|
+
}, onPaste: (e) => {
|
|
42779
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42780
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42781
|
+
e.preventDefault();
|
|
42782
|
+
}
|
|
42783
|
+
} }));
|
|
42759
42784
|
case 'checkbox':
|
|
42760
42785
|
return (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) => {
|
|
42761
42786
|
row[col.field] = val.currentTarget.checked;
|
|
@@ -42820,7 +42845,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42820
42845
|
return (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) => {
|
|
42821
42846
|
Object.assign(row, val);
|
|
42822
42847
|
handleDataChange(row, col, indexRow);
|
|
42823
|
-
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, onKeyDown: (e) => {
|
|
42848
|
+
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
42824
42849
|
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42825
42850
|
}, onPaste: (e) => {
|
|
42826
42851
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
@@ -42896,7 +42921,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42896
42921
|
};
|
|
42897
42922
|
//Thêm dòng mới
|
|
42898
42923
|
const moveIndexRowToNewPage = () => {
|
|
42899
|
-
changeDataSource(dataSource,
|
|
42924
|
+
changeDataSource(dataSource, 1);
|
|
42900
42925
|
if (pagingClient && pagingSetting?.setCurrentPage && (totalCount % (pagingSetting?.pageSize ?? 0)) === 0) {
|
|
42901
42926
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 0) + 1);
|
|
42902
42927
|
}
|
|
@@ -42963,13 +42988,13 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42963
42988
|
}, 50);
|
|
42964
42989
|
});
|
|
42965
42990
|
const getColumn = (col, index) => {
|
|
42966
|
-
const column = contentColumns
|
|
42991
|
+
const column = contentColumns[col + index];
|
|
42967
42992
|
if (column) {
|
|
42968
42993
|
return { ...column };
|
|
42969
42994
|
}
|
|
42970
42995
|
return undefined;
|
|
42971
42996
|
};
|
|
42972
|
-
const pasteDataFromExcel = async (currenRowIndex,
|
|
42997
|
+
const pasteDataFromExcel = async (currenRowIndex, indexCol, e) => {
|
|
42973
42998
|
const clipboard = (e.clipboardData || window.Clipboard).getData('text');
|
|
42974
42999
|
const rowsClipboard = clipboard.trimEnd().split('\n');
|
|
42975
43000
|
setIndexFocus(-1);
|
|
@@ -42985,7 +43010,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42985
43010
|
stringData.push(element.trimEnd().split('\t')[index].toString().trim());
|
|
42986
43011
|
}
|
|
42987
43012
|
});
|
|
42988
|
-
const column = getColumn(
|
|
43013
|
+
const column = getColumn(indexCol, index);
|
|
43014
|
+
console.log(column);
|
|
42989
43015
|
if (column) {
|
|
42990
43016
|
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
|
|
42991
43017
|
const rs = await column.onPasteValidate(stringData.join(','), currenRowIndex + 0, dataSource[currenRowIndex + 0]);
|
|
@@ -43062,8 +43088,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43062
43088
|
}
|
|
43063
43089
|
}
|
|
43064
43090
|
else if (column.editType === 'select') {
|
|
43065
|
-
|
|
43066
|
-
if (rs) {
|
|
43091
|
+
if (column.selectSettings?.allowCreate) {
|
|
43067
43092
|
if (column.onPaste) {
|
|
43068
43093
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
43069
43094
|
}
|
|
@@ -43071,11 +43096,25 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43071
43096
|
dataRow[column.field] = stringData;
|
|
43072
43097
|
}
|
|
43073
43098
|
if (column.callback) {
|
|
43074
|
-
column.callback(
|
|
43099
|
+
column.callback(stringData, currenRowIndex + indexRow);
|
|
43075
43100
|
}
|
|
43076
43101
|
}
|
|
43077
43102
|
else {
|
|
43078
|
-
|
|
43103
|
+
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ?? 'value'] === stringData);
|
|
43104
|
+
if (rs) {
|
|
43105
|
+
if (column.onPaste) {
|
|
43106
|
+
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
43107
|
+
}
|
|
43108
|
+
else {
|
|
43109
|
+
dataRow[column.field] = stringData;
|
|
43110
|
+
}
|
|
43111
|
+
if (column.callback) {
|
|
43112
|
+
column.callback(rs, currenRowIndex + indexRow);
|
|
43113
|
+
}
|
|
43114
|
+
}
|
|
43115
|
+
else {
|
|
43116
|
+
notificationError(t('PasteExcelNotExist', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43117
|
+
}
|
|
43079
43118
|
}
|
|
43080
43119
|
}
|
|
43081
43120
|
else {
|
|
@@ -43100,7 +43139,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43100
43139
|
}
|
|
43101
43140
|
changeDataSource(dataSource);
|
|
43102
43141
|
};
|
|
43103
|
-
const changeDataSource = (data,
|
|
43142
|
+
const changeDataSource = (data, numberOfRows) => {
|
|
43104
43143
|
if (!editDisable && setDataSource) {
|
|
43105
43144
|
if ((searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm)) {
|
|
43106
43145
|
if (searchSetting?.setSearchTerm) {
|
|
@@ -43110,8 +43149,10 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43110
43149
|
setSearchTerm('');
|
|
43111
43150
|
}
|
|
43112
43151
|
}
|
|
43113
|
-
if (
|
|
43114
|
-
|
|
43152
|
+
if (numberOfRows && !addDisable) {
|
|
43153
|
+
for (let index = 0; index < numberOfRows; index++) {
|
|
43154
|
+
data.push(defaultValue ? { ...defaultValue, [fieldKey]: disableAutoKey ? undefined : generateUUID() } : {});
|
|
43155
|
+
}
|
|
43115
43156
|
setDataSource([...data]);
|
|
43116
43157
|
}
|
|
43117
43158
|
else {
|
|
@@ -43214,9 +43255,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43214
43255
|
else if (col.field === 'checkbox') {
|
|
43215
43256
|
return (jsx("td", { className: classnames(`r-rowcell p-0 fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43216
43257
|
left: col.fixedType === 'left' ? objWidthFix[indexCol] : undefined,
|
|
43217
|
-
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43218
|
-
|
|
43219
|
-
}, children: jsx("div", { className: "r-rowcell-div cursor-pointer", onClick: (e) => {
|
|
43258
|
+
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43259
|
+
}, children: jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: 'center' }, onClick: (e) => {
|
|
43220
43260
|
if (selectEnable) {
|
|
43221
43261
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
43222
43262
|
if (index > -1) {
|
|
@@ -43238,7 +43278,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43238
43278
|
}
|
|
43239
43279
|
e.stopPropagation();
|
|
43240
43280
|
}
|
|
43241
|
-
}, children: jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer",
|
|
43281
|
+
}, children: jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? 'center' } }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43242
43282
|
}
|
|
43243
43283
|
else {
|
|
43244
43284
|
let value = row[col.field];
|
|
@@ -43286,8 +43326,20 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43286
43326
|
}
|
|
43287
43327
|
}, children: jsx("div", { className: classnames('r-rowcell-div'), children: jsxs("div", { id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : '', className: classnames('r-rowcell-content', { 'r-is-invalid': errorMessage }), style: {
|
|
43288
43328
|
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
43289
|
-
}, children: [typeDis === 1 && !refreshRow
|
|
43329
|
+
}, children: [typeDis === 1 && !refreshRow && jsx(Fragment$1, { children: RenderEditCell(row, col, indexCol, indexRow) }), (typeDis !== 1 || refreshRow) && RenderContentCell(row, col, indexCol, indexRow, typeDis, value), jsx("span", { id: `error-${indexRow}-${indexCol}`, className: classnames('cursor-pointer text-primary icon-table', { 'd-none': !errorMessage }), children: jsx(SvgAlertCircle, { fontSize: 15.5 }) }), jsx(UncontrolledTooltip, { target: `error-${indexRow}-${indexCol}`, className: "r-tooltip tooltip-error", children: errorMessage?.toString() ?? '' })] }) }) }, `col-${indexRow}-${indexCol}`) }, indexCol));
|
|
43330
|
+
}
|
|
43331
|
+
};
|
|
43332
|
+
const RenderContentCell = (row, col, indexCol, indexRow, typeDis, value) => {
|
|
43333
|
+
if (typeDis === 2) {
|
|
43334
|
+
const value = col.template?.(row, indexRow) ?? '';
|
|
43335
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
43336
|
+
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: value }), (!refreshRow && typeDis !== 2) && jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.editType === 'numeric' && Number(row[col.field]) < 0 ? jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }));
|
|
43337
|
+
}
|
|
43338
|
+
else {
|
|
43339
|
+
return value;
|
|
43340
|
+
}
|
|
43290
43341
|
}
|
|
43342
|
+
return (jsxs(Fragment$1, { children: [jsx("div", { id: `content-${idTable}-row${indexRow}col-${indexCol}`, className: "r-cell-text", children: (col.editType === 'numeric' && Number(row[col.field]) < 0 ? jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) }), (!(typeDis === 1 && !refreshRow) && typeDis !== 2) && jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: `content-${idTable}-row${indexRow}col-${indexCol}`, children: (col.editType === 'numeric' && Number(row[col.field]) < 0 ? jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${value}${formatSetting?.suffixNegative ?? ''}`] }) : value) })] }));
|
|
43291
43343
|
};
|
|
43292
43344
|
const renderFooterCol = (col, indexCol) => {
|
|
43293
43345
|
const sumValue = (col.haveSum === true && col.editType === "numeric") ? dataSource.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0) : 0;
|
|
@@ -43330,8 +43382,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43330
43382
|
}) }, `header-${-indexParent}`));
|
|
43331
43383
|
}) }), jsx("tbody", { className: 'r-gridcontent', children: renderData() }), jsx("tfoot", { className: "r-gridfoot", children: haveSum == true ? jsx("tr", { className: 'r-row', children: contentColumns.map((col, index) => {
|
|
43332
43384
|
return (renderFooterCol(col, index));
|
|
43333
|
-
}) }) : jsx(Fragment$1, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsx(ToolbarBottom, { handleAdd: () => {
|
|
43334
|
-
handleAdd(dataSource, tableElement.current, columnFistEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement);
|
|
43385
|
+
}) }) : jsx(Fragment$1, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43386
|
+
handleAdd(dataSource, tableElement.current, columnFistEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement, numberOfRows);
|
|
43335
43387
|
}, handleDuplicate: () => {
|
|
43336
43388
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
43337
43389
|
}, handleInsertAfter: () => {
|