react-table-edit 1.4.9 → 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/edit-form-inline/index.d.ts +36 -0
- package/dist/component/edit-form-inline/select-table/index.d.ts +32 -0
- package/dist/component/table/button-handle.d.ts +3 -3
- package/dist/component/type/index.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +247 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +247 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -22988,7 +22988,7 @@ const SelectTable = forwardRef((props, ref) => {
|
|
|
22988
22988
|
}, children: jsxs("div", { className: 'r-select-grid', children: [jsx("div", { className: classnames('r-select-gridtable', { 'no-header': noHeader || (columns?.length ?? 0) === 0 }), ref: selectMenuTableRef, style: { width: menuWidth, minWidth: selectTableRef?.current?.clientWidth, maxHeight: maxHeight ?? defaultMaxHeight$1 }, children: jsx(RenderTable, {}) }), jsxs("div", { className: classnames('r-select-footer', { 'd-none': !(showFooter === true || handleAdd) }), children: [jsxs(Button$1, { outline: true, color: "primary", onClick: () => handleAdd?.(), className: classnames('r-btn d-flex align-items-center', { 'd-none': !handleAdd }), children: [jsx(SvgPlus, { className: "me-50", fontSize: 16 }), t('AddNew'), " (F9)"] }), footerComponent ? footerComponent() : null] })] }) }) }) })] }) }) }));
|
|
22989
22989
|
});
|
|
22990
22990
|
|
|
22991
|
-
const SelectTableBox = (props) => {
|
|
22991
|
+
const SelectTableBox$1 = (props) => {
|
|
22992
22992
|
const { isMulti, isLabel, confirmHandle, id, fieldValue, fieldLabel, labelComponent, options, loadOptions, control, placeholder, disabled, name, label, labelSize, required, errors, inLine, callback, desciptionLabel, classLabel, isClearable, defaultValue, handleAddNew, columns, ...rest } = props;
|
|
22993
22993
|
const handChange = ({ onChange, val }) => {
|
|
22994
22994
|
onChange((!isNullOrUndefined$1(val) && isMulti) ? val.map((item) => item.value) : ((!isNullOrUndefined$1(val) && !isMulti) ? (fieldValue ? val[fieldValue] : val?.value) : undefined));
|
|
@@ -23033,12 +23033,13 @@ const SelectTableBox = (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();
|
|
@@ -23189,11 +23191,30 @@ const EditForm = forwardRef((props, ref) => {
|
|
|
23189
23191
|
return (jsx(Col$1, { xl: 12, onKeyDown: e => formItemKeyDown(e, index), children: jsx(TextInput, { id: `form-element-${field}-${index}`, control: control, name: item.name, label: item.label ? item.label : '', labelSize: `text-left ${labelSize}`, errors: errors[item.name], disabled: item.disabled, callback: () => { elementChange(item.name); } }, index) }, index));
|
|
23190
23192
|
}
|
|
23191
23193
|
else if (item.type === 'select') {
|
|
23192
|
-
return (jsx(Col$1, { xl: 12, onKeyDown: e => formItemKeyDown(e, index), children: jsx(SelectTableBox, { id: `form-element-${field}-${index}`, options: item.options ?? [], control: control, name: item.name, label: item.label ? item.label : '', labelSize: `text-left ${labelSize}`, errors: errors[item.name], disabled: item.disabled, callback: () => { elementChange(item.name); } }, index) }, index));
|
|
23194
|
+
return (jsx(Col$1, { xl: 12, onKeyDown: e => formItemKeyDown(e, index), children: jsx(SelectTableBox$1, { id: `form-element-${field}-${index}`, options: item.options ?? [], control: control, name: item.name, label: item.label ? item.label : '', labelSize: `text-left ${labelSize}`, errors: errors[item.name], disabled: item.disabled, callback: () => { elementChange(item.name); } }, index) }, index));
|
|
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}`) : '');
|
|
@@ -42319,6 +42346,131 @@ const handleCtrlD = (e, params) => {
|
|
|
42319
42346
|
}
|
|
42320
42347
|
};
|
|
42321
42348
|
|
|
42349
|
+
const SelectTableBox = (props) => {
|
|
42350
|
+
const { isMulti, isLabel, confirmHandle, id, fieldValue, fieldLabel, labelComponent, options, loadOptions, control, placeholder, disabled, name, label, labelSize, required, errors, inLine, callback, desciptionLabel, classLabel, isClearable, defaultValue, handleAddNew, columns, ...rest } = props;
|
|
42351
|
+
const handChange = ({ onChange, val }) => {
|
|
42352
|
+
onChange((!isNullOrUndefined$1(val) && isMulti) ? val.map((item) => item.value) : ((!isNullOrUndefined$1(val) && !isMulti) ? (fieldValue ? val[fieldValue] : val?.value) : undefined));
|
|
42353
|
+
if (callback) {
|
|
42354
|
+
callback(val);
|
|
42355
|
+
}
|
|
42356
|
+
};
|
|
42357
|
+
const renderLabel = (props) => {
|
|
42358
|
+
const { t } = useTranslation();
|
|
42359
|
+
const { isLabel, desciptionLabel, id, classLabel, name, label, required } = props;
|
|
42360
|
+
return (jsxs(Fragment, { children: [isLabel === false ? '' : jsxs(Label$1, { id: `label-${id}`, className: classLabel, for: name, children: [t(label ? label : ''), " ", required ? jsx("span", { className: "text-danger", children: "*" }) : ''] }), (!isNullOrUndefined$1(desciptionLabel) && desciptionLabel !== '') ?? jsx(Fragment$1, { children: jsx(UncontrolledTooltip, { target: `label-${id}`, children: t(desciptionLabel ?? '') }) })] }));
|
|
42361
|
+
};
|
|
42362
|
+
return (jsx(Fragment, { children: jsxs("div", { className: classnames(inLine === false ? 'form-group ' : 'form-row-inline d-flex', 'align', {
|
|
42363
|
+
[labelSize ? labelSize : '']: labelSize,
|
|
42364
|
+
'form-row-inline-error': errors
|
|
42365
|
+
}), children: [renderLabel({ isLabel, desciptionLabel, classLabel, name, label, required, id: id ?? '' }), jsxs("div", { className: classnames('form-input-content', { 'hidden-label': isLabel === false }), children: [jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
42366
|
+
return (jsx(SelectTable, { ...rest, id: id, value: (isMulti ? value?.length > 0 : value) ? (!isMulti ? (options.find((val) => val[fieldValue ?? 'value'] === value) ?? (defaultValue ?? '')) : value) : (isMulti ? [] : undefined),
|
|
42367
|
+
// Giá trị của SelectTable, nếu isMulti là true và value có độ dài lớn hơn 0, hoặc nếu isMulti là false và value có giá trị,
|
|
42368
|
+
// thì tìm giá trị tương ứng trong options hoặc sử dụng defaultValue. Nếu không, sử dụng giá trị mặc định tùy thuộc vào isMulti.
|
|
42369
|
+
onChange: (val) => {
|
|
42370
|
+
if (isMulti || (fieldValue && val ? val[fieldValue] : val?.value) !== value) { // Kiểm tra nếu giá trị mới khác với giá trị hiện tại
|
|
42371
|
+
if (confirmHandle) { // Nếu có hàm confirmHandle
|
|
42372
|
+
confirmHandle(handChange, onChange, val); // Gọi hàm confirmHandle với các tham số tương ứng
|
|
42373
|
+
}
|
|
42374
|
+
else {
|
|
42375
|
+
if (isMulti) {
|
|
42376
|
+
onChange(!isNullOrUndefined$1(val) ? val.map((item) => item[fieldValue ?? 'value']) : []);
|
|
42377
|
+
}
|
|
42378
|
+
else {
|
|
42379
|
+
onChange(!isNullOrUndefined$1(val) ? val[fieldValue ?? 'value'] : undefined);
|
|
42380
|
+
}
|
|
42381
|
+
// Nếu giá trị mới không null hoặc undefined và isMulti là true, thì lấy mảng các giá trị.
|
|
42382
|
+
// Nếu isMulti là false, lấy giá trị mới hoặc giá trị của fieldValue.
|
|
42383
|
+
if (callback) { // Nếu có hàm callback
|
|
42384
|
+
callback(val); // Gọi hàm callback với giá trị mới
|
|
42385
|
+
}
|
|
42386
|
+
}
|
|
42387
|
+
}
|
|
42388
|
+
}, handleAdd: handleAddNew, isClearable: isClearable, isMulti: isMulti, placeholder: placeholder, invalid: errors, loadOptions: loadOptions, options: options, isDisabled: disabled, columns: columns, fieldValue: fieldValue, fieldLabel: fieldLabel, formatOptionLabel: labelComponent ? labelComponent : undefined }));
|
|
42389
|
+
} }), errors && jsx(FormFeedback$1, { children: errors?.message })] })] }) }));
|
|
42390
|
+
};
|
|
42391
|
+
|
|
42392
|
+
const EditFormInline = forwardRef((props, ref) => {
|
|
42393
|
+
const { id, field, rowData, onChange, onChangeField, onKeyDown, defaultValues, schema, indexRow, template, displayValue, onFormOpen, labelSize = 'label-small' } = props;
|
|
42394
|
+
useRef(null);
|
|
42395
|
+
useRef(null);
|
|
42396
|
+
const [itemsField, setItemsField] = useState([]);
|
|
42397
|
+
const [onFocus, setOnFocus] = useState(false);
|
|
42398
|
+
useTranslation();
|
|
42399
|
+
const { control, handleSubmit, getValues, reset, setValue, formState: { errors } } = useForm({
|
|
42400
|
+
mode: 'onChange',
|
|
42401
|
+
defaultValues,
|
|
42402
|
+
resolver: o(schema)
|
|
42403
|
+
});
|
|
42404
|
+
const focusElement = (id, focus) => {
|
|
42405
|
+
const element = document.getElementById(id);
|
|
42406
|
+
if (element) {
|
|
42407
|
+
if (element.className.includes('react-select')) {
|
|
42408
|
+
element.getElementsByTagName('input')[0]?.focus();
|
|
42409
|
+
}
|
|
42410
|
+
else {
|
|
42411
|
+
element.focus();
|
|
42412
|
+
if (focus) {
|
|
42413
|
+
element.setSelectionRange(0, element.innerText.length - 1);
|
|
42414
|
+
}
|
|
42415
|
+
}
|
|
42416
|
+
}
|
|
42417
|
+
};
|
|
42418
|
+
const handleOnKeyDown = (e) => {
|
|
42419
|
+
};
|
|
42420
|
+
const formKeyDown = (e, handSubmit) => {
|
|
42421
|
+
if (e.code === 'Enter') {
|
|
42422
|
+
handSubmit();
|
|
42423
|
+
e.preventDefault();
|
|
42424
|
+
e.stopPropagation();
|
|
42425
|
+
}
|
|
42426
|
+
};
|
|
42427
|
+
const formItemKeyDown = (e, index) => {
|
|
42428
|
+
if (e.code === 'ArrowRight' && index < itemsField.length - 1) {
|
|
42429
|
+
focusElement(`form-element-${field}-${index + 1}`);
|
|
42430
|
+
e.preventDefault();
|
|
42431
|
+
e.stopPropagation();
|
|
42432
|
+
}
|
|
42433
|
+
else if (e.code === 'ArrowLeft' && index > 0) {
|
|
42434
|
+
focusElement(`form-element-${field}-${index - 1}`);
|
|
42435
|
+
e.preventDefault();
|
|
42436
|
+
e.stopPropagation();
|
|
42437
|
+
}
|
|
42438
|
+
};
|
|
42439
|
+
const elementChange = (field) => {
|
|
42440
|
+
if (onChangeField) {
|
|
42441
|
+
onChangeField(rowData, field, setValue, getValues);
|
|
42442
|
+
const rs = getValues();
|
|
42443
|
+
if (rs) {
|
|
42444
|
+
onChange(rs);
|
|
42445
|
+
}
|
|
42446
|
+
}
|
|
42447
|
+
};
|
|
42448
|
+
useEffect(() => {
|
|
42449
|
+
if (onFocus && itemsField.length > 0) {
|
|
42450
|
+
itemsField.forEach((ele) => {
|
|
42451
|
+
setValue(ele.name, (rowData[ele.name] ?? ""));
|
|
42452
|
+
});
|
|
42453
|
+
focusElement(`form-element-${field}-${0}`);
|
|
42454
|
+
}
|
|
42455
|
+
}, [onFocus, itemsField]);
|
|
42456
|
+
return (jsxs("div", { className: "form-edit-inline", ref: ref, id: id, children: [!onFocus && jsx("div", { className: "form__display", onClick: () => {
|
|
42457
|
+
if (onFormOpen && itemsField.length === 0) {
|
|
42458
|
+
onFormOpen(rowData, itemsField, setItemsField);
|
|
42459
|
+
}
|
|
42460
|
+
setOnFocus(true);
|
|
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) => {
|
|
42462
|
+
if (item.type === 'numeric') {
|
|
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));
|
|
42464
|
+
}
|
|
42465
|
+
else if (item.type === 'text') {
|
|
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));
|
|
42467
|
+
}
|
|
42468
|
+
else if (item.type === 'select') {
|
|
42469
|
+
return (jsx("div", { className: "form__element", onKeyDown: e => formItemKeyDown(e, index), children: jsx(SelectTableBox, { id: `form-element-${field}-${index}`, options: item.options ?? [], 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));
|
|
42470
|
+
}
|
|
42471
|
+
}) })] }));
|
|
42472
|
+
});
|
|
42473
|
+
|
|
42322
42474
|
const TableEdit = forwardRef((props, ref) => {
|
|
42323
42475
|
const { t } = useTranslation();
|
|
42324
42476
|
const { idTable, dataSource, columns, commandClick, dataSourceChange, rowChange, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, setSelectedItem, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, handleSelect, haveSum, isMulti, disableAutoKey, onDuplicate } = props;
|
|
@@ -42495,7 +42647,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42495
42647
|
else {
|
|
42496
42648
|
toolbarTopOption = [...defaultToolbarOption];
|
|
42497
42649
|
}
|
|
42498
|
-
const
|
|
42650
|
+
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42499
42651
|
/*eslint-disable */
|
|
42500
42652
|
switch (col?.editTypeCondition ? col?.editTypeCondition(row) : col.editType) {
|
|
42501
42653
|
case 'date':
|
|
@@ -42606,31 +42758,29 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42606
42758
|
else {
|
|
42607
42759
|
valueSelectTree = (!isNullOrUndefined$1(row[col.field]) && row[col.field] !== '') ? findItemInTree(optionsSelectTree, row[col.field]) : '';
|
|
42608
42760
|
}
|
|
42609
|
-
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) => {
|
|
42610
42777
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) ;
|
|
42611
|
-
},
|
|
42612
|
-
|
|
42613
|
-
|
|
42614
|
-
|
|
42615
|
-
|
|
42616
|
-
|
|
42617
|
-
}
|
|
42618
|
-
if (col.callback) {
|
|
42619
|
-
col.callback(val, indexRow, row);
|
|
42620
|
-
}
|
|
42621
|
-
handleDataChange(row, col, indexRow);
|
|
42622
|
-
}, 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: () => {
|
|
42623
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
42624
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42625
|
-
}
|
|
42626
|
-
}, 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) => {
|
|
42627
|
-
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) ;
|
|
42628
|
-
}, onPaste: (e) => {
|
|
42629
|
-
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42630
|
-
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42631
|
-
e.preventDefault();
|
|
42632
|
-
}
|
|
42633
|
-
} }) }));
|
|
42778
|
+
}, onPaste: (e) => {
|
|
42779
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42780
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42781
|
+
e.preventDefault();
|
|
42782
|
+
}
|
|
42783
|
+
} }));
|
|
42634
42784
|
case 'checkbox':
|
|
42635
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) => {
|
|
42636
42786
|
row[col.field] = val.currentTarget.checked;
|
|
@@ -42695,7 +42845,19 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42695
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) => {
|
|
42696
42846
|
Object.assign(row, val);
|
|
42697
42847
|
handleDataChange(row, col, indexRow);
|
|
42698
|
-
}, 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) => {
|
|
42849
|
+
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42850
|
+
}, onPaste: (e) => {
|
|
42851
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42852
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42853
|
+
e.preventDefault();
|
|
42854
|
+
}
|
|
42855
|
+
} }));
|
|
42856
|
+
case 'formInline':
|
|
42857
|
+
return (jsx(EditFormInline, { 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) => {
|
|
42858
|
+
Object.assign(row, val);
|
|
42859
|
+
handleDataChange(row, col, indexRow);
|
|
42860
|
+
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
42699
42861
|
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42700
42862
|
}, onPaste: (e) => {
|
|
42701
42863
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
@@ -42759,7 +42921,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42759
42921
|
};
|
|
42760
42922
|
//Thêm dòng mới
|
|
42761
42923
|
const moveIndexRowToNewPage = () => {
|
|
42762
|
-
changeDataSource(dataSource,
|
|
42924
|
+
changeDataSource(dataSource, 1);
|
|
42763
42925
|
if (pagingClient && pagingSetting?.setCurrentPage && (totalCount % (pagingSetting?.pageSize ?? 0)) === 0) {
|
|
42764
42926
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 0) + 1);
|
|
42765
42927
|
}
|
|
@@ -42826,13 +42988,13 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42826
42988
|
}, 50);
|
|
42827
42989
|
});
|
|
42828
42990
|
const getColumn = (col, index) => {
|
|
42829
|
-
const column = contentColumns
|
|
42991
|
+
const column = contentColumns[col + index];
|
|
42830
42992
|
if (column) {
|
|
42831
42993
|
return { ...column };
|
|
42832
42994
|
}
|
|
42833
42995
|
return undefined;
|
|
42834
42996
|
};
|
|
42835
|
-
const pasteDataFromExcel = async (currenRowIndex,
|
|
42997
|
+
const pasteDataFromExcel = async (currenRowIndex, indexCol, e) => {
|
|
42836
42998
|
const clipboard = (e.clipboardData || window.Clipboard).getData('text');
|
|
42837
42999
|
const rowsClipboard = clipboard.trimEnd().split('\n');
|
|
42838
43000
|
setIndexFocus(-1);
|
|
@@ -42848,7 +43010,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42848
43010
|
stringData.push(element.trimEnd().split('\t')[index].toString().trim());
|
|
42849
43011
|
}
|
|
42850
43012
|
});
|
|
42851
|
-
const column = getColumn(
|
|
43013
|
+
const column = getColumn(indexCol, index);
|
|
43014
|
+
console.log(column);
|
|
42852
43015
|
if (column) {
|
|
42853
43016
|
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
|
|
42854
43017
|
const rs = await column.onPasteValidate(stringData.join(','), currenRowIndex + 0, dataSource[currenRowIndex + 0]);
|
|
@@ -42925,8 +43088,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42925
43088
|
}
|
|
42926
43089
|
}
|
|
42927
43090
|
else if (column.editType === 'select') {
|
|
42928
|
-
|
|
42929
|
-
if (rs) {
|
|
43091
|
+
if (column.selectSettings?.allowCreate) {
|
|
42930
43092
|
if (column.onPaste) {
|
|
42931
43093
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
42932
43094
|
}
|
|
@@ -42934,11 +43096,25 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42934
43096
|
dataRow[column.field] = stringData;
|
|
42935
43097
|
}
|
|
42936
43098
|
if (column.callback) {
|
|
42937
|
-
column.callback(
|
|
43099
|
+
column.callback(stringData, currenRowIndex + indexRow);
|
|
42938
43100
|
}
|
|
42939
43101
|
}
|
|
42940
43102
|
else {
|
|
42941
|
-
|
|
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
|
+
}
|
|
42942
43118
|
}
|
|
42943
43119
|
}
|
|
42944
43120
|
else {
|
|
@@ -42963,7 +43139,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42963
43139
|
}
|
|
42964
43140
|
changeDataSource(dataSource);
|
|
42965
43141
|
};
|
|
42966
|
-
const changeDataSource = (data,
|
|
43142
|
+
const changeDataSource = (data, numberOfRows) => {
|
|
42967
43143
|
if (!editDisable && setDataSource) {
|
|
42968
43144
|
if ((searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm)) {
|
|
42969
43145
|
if (searchSetting?.setSearchTerm) {
|
|
@@ -42973,8 +43149,10 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
42973
43149
|
setSearchTerm('');
|
|
42974
43150
|
}
|
|
42975
43151
|
}
|
|
42976
|
-
if (
|
|
42977
|
-
|
|
43152
|
+
if (numberOfRows && !addDisable) {
|
|
43153
|
+
for (let index = 0; index < numberOfRows; index++) {
|
|
43154
|
+
data.push(defaultValue ? { ...defaultValue, [fieldKey]: disableAutoKey ? undefined : generateUUID() } : {});
|
|
43155
|
+
}
|
|
42978
43156
|
setDataSource([...data]);
|
|
42979
43157
|
}
|
|
42980
43158
|
else {
|
|
@@ -43077,9 +43255,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43077
43255
|
else if (col.field === 'checkbox') {
|
|
43078
43256
|
return (jsx("td", { className: classnames(`r-rowcell p-0 fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43079
43257
|
left: col.fixedType === 'left' ? objWidthFix[indexCol] : undefined,
|
|
43080
|
-
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43081
|
-
|
|
43082
|
-
}, 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) => {
|
|
43083
43260
|
if (selectEnable) {
|
|
43084
43261
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
43085
43262
|
if (index > -1) {
|
|
@@ -43101,7 +43278,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43101
43278
|
}
|
|
43102
43279
|
e.stopPropagation();
|
|
43103
43280
|
}
|
|
43104
|
-
}, 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}`));
|
|
43105
43282
|
}
|
|
43106
43283
|
else {
|
|
43107
43284
|
let value = row[col.field];
|
|
@@ -43118,9 +43295,7 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43118
43295
|
const errorMessage = typeDis === 1 || col.field === '' || !col.validate ? '' : col.validate(row[col.field], row);
|
|
43119
43296
|
return (jsx(Fragment, { children: col.visible !== false && jsx("td", { className: classnames(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43120
43297
|
left: col.fixedType === 'left' ? objWidthFix[indexCol] : undefined,
|
|
43121
|
-
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43122
|
-
padding: 0,
|
|
43123
|
-
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
43298
|
+
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43124
43299
|
}, onClick: (e) => {
|
|
43125
43300
|
if (e.target.nodeName === 'DIV' || e.target.nodeName === 'TD') {
|
|
43126
43301
|
if (!editDisable && indexRow != indexFocus) {
|
|
@@ -43150,9 +43325,21 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43150
43325
|
e.stopPropagation();
|
|
43151
43326
|
}
|
|
43152
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: {
|
|
43153
|
-
|
|
43154
|
-
}, children: [typeDis === 1 && !refreshRow
|
|
43328
|
+
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
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
|
+
}
|
|
43155
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) })] }));
|
|
43156
43343
|
};
|
|
43157
43344
|
const renderFooterCol = (col, indexCol) => {
|
|
43158
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;
|
|
@@ -43195,8 +43382,8 @@ const TableEdit = forwardRef((props, ref) => {
|
|
|
43195
43382
|
}) }, `header-${-indexParent}`));
|
|
43196
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) => {
|
|
43197
43384
|
return (renderFooterCol(col, index));
|
|
43198
|
-
}) }) : jsx(Fragment$1, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsx(ToolbarBottom, { handleAdd: () => {
|
|
43199
|
-
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);
|
|
43200
43387
|
}, handleDuplicate: () => {
|
|
43201
43388
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
43202
43389
|
}, handleInsertAfter: () => {
|
|
@@ -64942,7 +65129,7 @@ const TabSelectFileImportExcel = (props) => {
|
|
|
64942
65129
|
getSheetsExcel(e.target.files[0], setValue, setOptionSheetName);
|
|
64943
65130
|
}, hidden: true, accept: '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel' })] })] }) : jsxs(Fragment$1, { children: [jsx("div", { className: 'fs-4 bolder', children: t('Drag and drop files here') }), jsx("div", { className: 'my-50', children: t('or') }), jsxs(Button$1, { tag: Label$1, outline: true, className: 'me-75', size: 'md', color: 'primary', children: [jsx(SvgArrowLeftCircle, { fontSize: 18, className: 'me-50' }), t('Select file'), jsx(Input$1, { type: 'file', onChange: (e) => {
|
|
64944
65131
|
getSheetsExcel(e.target.files[0], setValue, setOptionSheetName);
|
|
64945
|
-
}, hidden: true, accept: '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel' })] }), jsx("div", { className: 'mt-1', children: t('Accepts .xls, .xlsx, .csv files') })] }) }), jsxs(Row$1, { className: `${getValues('file') ? '' : 'd-none'} m-0 gy-1`, children: [jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsx(SelectTableBox, { labelSize: "d-flex form-row-inline label-medium", control: control, name: "sheetId", label: t("Sheet name"), required: true, errors: errors.sheetId, placeholder: t("Select"), options: optionSheetName }) }), jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsx(NumberInput, { control: control, name: "headerRow", labelSize: "d-flex form-row-inline label-medium", label: t("Header row"), errors: errors.headerRow }) })] })] }));
|
|
65132
|
+
}, hidden: true, accept: '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel' })] }), jsx("div", { className: 'mt-1', children: t('Accepts .xls, .xlsx, .csv files') })] }) }), jsxs(Row$1, { className: `${getValues('file') ? '' : 'd-none'} m-0 gy-1`, children: [jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsx(SelectTableBox$1, { labelSize: "d-flex form-row-inline label-medium", control: control, name: "sheetId", label: t("Sheet name"), required: true, errors: errors.sheetId, placeholder: t("Select"), options: optionSheetName }) }), jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsx(NumberInput, { control: control, name: "headerRow", labelSize: "d-flex form-row-inline label-medium", label: t("Header row"), errors: errors.headerRow }) })] })] }));
|
|
64946
65133
|
};
|
|
64947
65134
|
|
|
64948
65135
|
const TabMergeImportExcel = (props) => {
|