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.js
CHANGED
|
@@ -23016,7 +23016,7 @@ const SelectTable = React$5.forwardRef((props, ref) => {
|
|
|
23016
23016
|
}, children: jsxRuntime.jsxs("div", { className: 'r-select-grid', children: [jsxRuntime.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: jsxRuntime.jsx(RenderTable, {}) }), jsxRuntime.jsxs("div", { className: classnames('r-select-footer', { 'd-none': !(showFooter === true || handleAdd) }), children: [jsxRuntime.jsxs(Button$1, { outline: true, color: "primary", onClick: () => handleAdd?.(), className: classnames('r-btn d-flex align-items-center', { 'd-none': !handleAdd }), children: [jsxRuntime.jsx(SvgPlus, { className: "me-50", fontSize: 16 }), t('AddNew'), " (F9)"] }), footerComponent ? footerComponent() : null] })] }) }) }) })] }) }) }));
|
|
23017
23017
|
});
|
|
23018
23018
|
|
|
23019
|
-
const SelectTableBox = (props) => {
|
|
23019
|
+
const SelectTableBox$1 = (props) => {
|
|
23020
23020
|
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;
|
|
23021
23021
|
const handChange = ({ onChange, val }) => {
|
|
23022
23022
|
onChange((!isNullOrUndefined$1(val) && isMulti) ? val.map((item) => item.value) : ((!isNullOrUndefined$1(val) && !isMulti) ? (fieldValue ? val[fieldValue] : val?.value) : undefined));
|
|
@@ -23061,12 +23061,13 @@ const SelectTableBox = (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();
|
|
@@ -23217,11 +23219,30 @@ const EditForm = React$5.forwardRef((props, ref) => {
|
|
|
23217
23219
|
return (jsxRuntime.jsx(Col$1, { xl: 12, 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: `text-left ${labelSize}`, errors: errors[item.name], disabled: item.disabled, callback: () => { elementChange(item.name); } }, index) }, index));
|
|
23218
23220
|
}
|
|
23219
23221
|
else if (item.type === 'select') {
|
|
23220
|
-
return (jsxRuntime.jsx(Col$1, { xl: 12, onKeyDown: e => formItemKeyDown(e, index), children: jsxRuntime.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));
|
|
23222
|
+
return (jsxRuntime.jsx(Col$1, { xl: 12, onKeyDown: e => formItemKeyDown(e, index), children: jsxRuntime.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));
|
|
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,
|
|
@@ -41723,6 +41744,12 @@ 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
|
};
|
|
@@ -41731,8 +41758,8 @@ const HeaderTableCol = (props) => {
|
|
|
41731
41758
|
left: col.fixedType === 'left' ? objWidthFix[col.index ?? 0] : undefined,
|
|
41732
41759
|
right: col.fixedType === 'right' ? objWidthFix[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}`) : '');
|
|
@@ -42347,6 +42374,131 @@ const handleCtrlD = (e, params) => {
|
|
|
42347
42374
|
}
|
|
42348
42375
|
};
|
|
42349
42376
|
|
|
42377
|
+
const SelectTableBox = (props) => {
|
|
42378
|
+
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;
|
|
42379
|
+
const handChange = ({ onChange, val }) => {
|
|
42380
|
+
onChange((!isNullOrUndefined$1(val) && isMulti) ? val.map((item) => item.value) : ((!isNullOrUndefined$1(val) && !isMulti) ? (fieldValue ? val[fieldValue] : val?.value) : undefined));
|
|
42381
|
+
if (callback) {
|
|
42382
|
+
callback(val);
|
|
42383
|
+
}
|
|
42384
|
+
};
|
|
42385
|
+
const renderLabel = (props) => {
|
|
42386
|
+
const { t } = reactI18next.useTranslation();
|
|
42387
|
+
const { isLabel, desciptionLabel, id, classLabel, name, label, required } = props;
|
|
42388
|
+
return (jsxRuntime.jsxs(React$5.Fragment, { children: [isLabel === false ? '' : jsxRuntime.jsxs(Label$1, { id: `label-${id}`, className: classLabel, for: name, children: [t(label ? label : ''), " ", required ? jsxRuntime.jsx("span", { className: "text-danger", children: "*" }) : ''] }), (!isNullOrUndefined$1(desciptionLabel) && desciptionLabel !== '') ?? jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(UncontrolledTooltip, { target: `label-${id}`, children: t(desciptionLabel ?? '') }) })] }));
|
|
42389
|
+
};
|
|
42390
|
+
return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsxs("div", { className: classnames(inLine === false ? 'form-group ' : 'form-row-inline d-flex', 'align', {
|
|
42391
|
+
[labelSize ? labelSize : '']: labelSize,
|
|
42392
|
+
'form-row-inline-error': errors
|
|
42393
|
+
}), children: [renderLabel({ isLabel, desciptionLabel, classLabel, name, label, required, id: id ?? '' }), jsxRuntime.jsxs("div", { className: classnames('form-input-content', { 'hidden-label': isLabel === false }), children: [jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
|
|
42394
|
+
return (jsxRuntime.jsx(SelectTable, { ...rest, id: id, value: (isMulti ? value?.length > 0 : value) ? (!isMulti ? (options.find((val) => val[fieldValue ?? 'value'] === value) ?? (defaultValue ?? '')) : value) : (isMulti ? [] : undefined),
|
|
42395
|
+
// 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ị,
|
|
42396
|
+
// 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.
|
|
42397
|
+
onChange: (val) => {
|
|
42398
|
+
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
|
|
42399
|
+
if (confirmHandle) { // Nếu có hàm confirmHandle
|
|
42400
|
+
confirmHandle(handChange, onChange, val); // Gọi hàm confirmHandle với các tham số tương ứng
|
|
42401
|
+
}
|
|
42402
|
+
else {
|
|
42403
|
+
if (isMulti) {
|
|
42404
|
+
onChange(!isNullOrUndefined$1(val) ? val.map((item) => item[fieldValue ?? 'value']) : []);
|
|
42405
|
+
}
|
|
42406
|
+
else {
|
|
42407
|
+
onChange(!isNullOrUndefined$1(val) ? val[fieldValue ?? 'value'] : undefined);
|
|
42408
|
+
}
|
|
42409
|
+
// 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ị.
|
|
42410
|
+
// Nếu isMulti là false, lấy giá trị mới hoặc giá trị của fieldValue.
|
|
42411
|
+
if (callback) { // Nếu có hàm callback
|
|
42412
|
+
callback(val); // Gọi hàm callback với giá trị mới
|
|
42413
|
+
}
|
|
42414
|
+
}
|
|
42415
|
+
}
|
|
42416
|
+
}, 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 }));
|
|
42417
|
+
} }), errors && jsxRuntime.jsx(FormFeedback$1, { children: errors?.message })] })] }) }));
|
|
42418
|
+
};
|
|
42419
|
+
|
|
42420
|
+
const EditFormInline = React$5.forwardRef((props, ref) => {
|
|
42421
|
+
const { id, field, rowData, onChange, onChangeField, onKeyDown, defaultValues, schema, indexRow, template, displayValue, onFormOpen, labelSize = 'label-small' } = props;
|
|
42422
|
+
React$5.useRef(null);
|
|
42423
|
+
React$5.useRef(null);
|
|
42424
|
+
const [itemsField, setItemsField] = React$5.useState([]);
|
|
42425
|
+
const [onFocus, setOnFocus] = React$5.useState(false);
|
|
42426
|
+
reactI18next.useTranslation();
|
|
42427
|
+
const { control, handleSubmit, getValues, reset, setValue, formState: { errors } } = useForm({
|
|
42428
|
+
mode: 'onChange',
|
|
42429
|
+
defaultValues,
|
|
42430
|
+
resolver: o(schema)
|
|
42431
|
+
});
|
|
42432
|
+
const focusElement = (id, focus) => {
|
|
42433
|
+
const element = document.getElementById(id);
|
|
42434
|
+
if (element) {
|
|
42435
|
+
if (element.className.includes('react-select')) {
|
|
42436
|
+
element.getElementsByTagName('input')[0]?.focus();
|
|
42437
|
+
}
|
|
42438
|
+
else {
|
|
42439
|
+
element.focus();
|
|
42440
|
+
if (focus) {
|
|
42441
|
+
element.setSelectionRange(0, element.innerText.length - 1);
|
|
42442
|
+
}
|
|
42443
|
+
}
|
|
42444
|
+
}
|
|
42445
|
+
};
|
|
42446
|
+
const handleOnKeyDown = (e) => {
|
|
42447
|
+
};
|
|
42448
|
+
const formKeyDown = (e, handSubmit) => {
|
|
42449
|
+
if (e.code === 'Enter') {
|
|
42450
|
+
handSubmit();
|
|
42451
|
+
e.preventDefault();
|
|
42452
|
+
e.stopPropagation();
|
|
42453
|
+
}
|
|
42454
|
+
};
|
|
42455
|
+
const formItemKeyDown = (e, index) => {
|
|
42456
|
+
if (e.code === 'ArrowRight' && index < itemsField.length - 1) {
|
|
42457
|
+
focusElement(`form-element-${field}-${index + 1}`);
|
|
42458
|
+
e.preventDefault();
|
|
42459
|
+
e.stopPropagation();
|
|
42460
|
+
}
|
|
42461
|
+
else if (e.code === 'ArrowLeft' && index > 0) {
|
|
42462
|
+
focusElement(`form-element-${field}-${index - 1}`);
|
|
42463
|
+
e.preventDefault();
|
|
42464
|
+
e.stopPropagation();
|
|
42465
|
+
}
|
|
42466
|
+
};
|
|
42467
|
+
const elementChange = (field) => {
|
|
42468
|
+
if (onChangeField) {
|
|
42469
|
+
onChangeField(rowData, field, setValue, getValues);
|
|
42470
|
+
const rs = getValues();
|
|
42471
|
+
if (rs) {
|
|
42472
|
+
onChange(rs);
|
|
42473
|
+
}
|
|
42474
|
+
}
|
|
42475
|
+
};
|
|
42476
|
+
React$5.useEffect(() => {
|
|
42477
|
+
if (onFocus && itemsField.length > 0) {
|
|
42478
|
+
itemsField.forEach((ele) => {
|
|
42479
|
+
setValue(ele.name, (rowData[ele.name] ?? ""));
|
|
42480
|
+
});
|
|
42481
|
+
focusElement(`form-element-${field}-${0}`);
|
|
42482
|
+
}
|
|
42483
|
+
}, [onFocus, itemsField]);
|
|
42484
|
+
return (jsxRuntime.jsxs("div", { className: "form-edit-inline", ref: ref, id: id, children: [!onFocus && jsxRuntime.jsx("div", { className: "form__display", onClick: () => {
|
|
42485
|
+
if (onFormOpen && itemsField.length === 0) {
|
|
42486
|
+
onFormOpen(rowData, itemsField, setItemsField);
|
|
42487
|
+
}
|
|
42488
|
+
setOnFocus(true);
|
|
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) => {
|
|
42490
|
+
if (item.type === 'numeric') {
|
|
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));
|
|
42492
|
+
}
|
|
42493
|
+
else if (item.type === 'text') {
|
|
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));
|
|
42495
|
+
}
|
|
42496
|
+
else if (item.type === 'select') {
|
|
42497
|
+
return (jsxRuntime.jsx("div", { className: "form__element", onKeyDown: e => formItemKeyDown(e, index), children: jsxRuntime.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));
|
|
42498
|
+
}
|
|
42499
|
+
}) })] }));
|
|
42500
|
+
});
|
|
42501
|
+
|
|
42350
42502
|
const TableEdit = React$5.forwardRef((props, ref) => {
|
|
42351
42503
|
const { t } = reactI18next.useTranslation();
|
|
42352
42504
|
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;
|
|
@@ -42523,7 +42675,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42523
42675
|
else {
|
|
42524
42676
|
toolbarTopOption = [...defaultToolbarOption];
|
|
42525
42677
|
}
|
|
42526
|
-
const
|
|
42678
|
+
const RenderEditCell = (row, col, indexCol, indexRow) => {
|
|
42527
42679
|
/*eslint-disable */
|
|
42528
42680
|
switch (col?.editTypeCondition ? col?.editTypeCondition(row) : col.editType) {
|
|
42529
42681
|
case 'date':
|
|
@@ -42634,31 +42786,29 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42634
42786
|
else {
|
|
42635
42787
|
valueSelectTree = (!isNullOrUndefined$1(row[col.field]) && row[col.field] !== '') ? findItemInTree(optionsSelectTree, row[col.field]) : '';
|
|
42636
42788
|
}
|
|
42637
|
-
return (jsxRuntime.jsx(
|
|
42789
|
+
return (jsxRuntime.jsx(SelectTableTree, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, value: valueSelectTree, options: optionsSelectTree, onChange: (val) => {
|
|
42790
|
+
if (col.selectSettings?.isMulti) {
|
|
42791
|
+
row[col.field] = !isNullOrUndefined$1(val) ? val : [];
|
|
42792
|
+
}
|
|
42793
|
+
else {
|
|
42794
|
+
row[col.field] = !isNullOrUndefined$1(val) ? val[col.selectSettings?.fieldValue ?? 'value'] : undefined;
|
|
42795
|
+
}
|
|
42796
|
+
if (col.callback) {
|
|
42797
|
+
col.callback(val, indexRow, row);
|
|
42798
|
+
}
|
|
42799
|
+
handleDataChange(row, col, indexRow);
|
|
42800
|
+
}, 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: () => {
|
|
42801
|
+
if (col.selectSettings?.onOpenMenu) {
|
|
42802
|
+
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42803
|
+
}
|
|
42804
|
+
}, 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) => {
|
|
42638
42805
|
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) ;
|
|
42639
|
-
},
|
|
42640
|
-
|
|
42641
|
-
|
|
42642
|
-
|
|
42643
|
-
|
|
42644
|
-
|
|
42645
|
-
}
|
|
42646
|
-
if (col.callback) {
|
|
42647
|
-
col.callback(val, indexRow, row);
|
|
42648
|
-
}
|
|
42649
|
-
handleDataChange(row, col, indexRow);
|
|
42650
|
-
}, 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: () => {
|
|
42651
|
-
if (col.selectSettings?.onOpenMenu) {
|
|
42652
|
-
col.selectSettings?.onOpenMenu(row, col, indexRow);
|
|
42653
|
-
}
|
|
42654
|
-
}, 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) => {
|
|
42655
|
-
if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) ;
|
|
42656
|
-
}, onPaste: (e) => {
|
|
42657
|
-
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42658
|
-
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42659
|
-
e.preventDefault();
|
|
42660
|
-
}
|
|
42661
|
-
} }) }));
|
|
42806
|
+
}, onPaste: (e) => {
|
|
42807
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42808
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42809
|
+
e.preventDefault();
|
|
42810
|
+
}
|
|
42811
|
+
} }));
|
|
42662
42812
|
case 'checkbox':
|
|
42663
42813
|
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) => {
|
|
42664
42814
|
row[col.field] = val.currentTarget.checked;
|
|
@@ -42723,7 +42873,19 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42723
42873
|
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) => {
|
|
42724
42874
|
Object.assign(row, val);
|
|
42725
42875
|
handleDataChange(row, col, indexRow);
|
|
42726
|
-
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, onKeyDown: (e) => {
|
|
42876
|
+
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
42877
|
+
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42878
|
+
}, onPaste: (e) => {
|
|
42879
|
+
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
42880
|
+
pasteDataFromExcel(indexRow, indexCol, e);
|
|
42881
|
+
e.preventDefault();
|
|
42882
|
+
}
|
|
42883
|
+
} }));
|
|
42884
|
+
case 'formInline':
|
|
42885
|
+
return (jsxRuntime.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) => {
|
|
42886
|
+
Object.assign(row, val);
|
|
42887
|
+
handleDataChange(row, col, indexRow);
|
|
42888
|
+
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
42727
42889
|
return checkKeyDown(e, row, col, indexRow + 1, indexCol + 1);
|
|
42728
42890
|
}, onPaste: (e) => {
|
|
42729
42891
|
if (toolbarSetting?.showBottomToolbar && !editDisable && !addDisable && !col.disablePaste) {
|
|
@@ -42787,7 +42949,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42787
42949
|
};
|
|
42788
42950
|
//Thêm dòng mới
|
|
42789
42951
|
const moveIndexRowToNewPage = () => {
|
|
42790
|
-
changeDataSource(dataSource,
|
|
42952
|
+
changeDataSource(dataSource, 1);
|
|
42791
42953
|
if (pagingClient && pagingSetting?.setCurrentPage && (totalCount % (pagingSetting?.pageSize ?? 0)) === 0) {
|
|
42792
42954
|
pagingSetting?.setCurrentPage((pagingSetting?.currentPage ?? 0) + 1);
|
|
42793
42955
|
}
|
|
@@ -42854,13 +43016,13 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42854
43016
|
}, 50);
|
|
42855
43017
|
});
|
|
42856
43018
|
const getColumn = (col, index) => {
|
|
42857
|
-
const column = contentColumns
|
|
43019
|
+
const column = contentColumns[col + index];
|
|
42858
43020
|
if (column) {
|
|
42859
43021
|
return { ...column };
|
|
42860
43022
|
}
|
|
42861
43023
|
return undefined;
|
|
42862
43024
|
};
|
|
42863
|
-
const pasteDataFromExcel = async (currenRowIndex,
|
|
43025
|
+
const pasteDataFromExcel = async (currenRowIndex, indexCol, e) => {
|
|
42864
43026
|
const clipboard = (e.clipboardData || window.Clipboard).getData('text');
|
|
42865
43027
|
const rowsClipboard = clipboard.trimEnd().split('\n');
|
|
42866
43028
|
setIndexFocus(-1);
|
|
@@ -42876,7 +43038,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42876
43038
|
stringData.push(element.trimEnd().split('\t')[index].toString().trim());
|
|
42877
43039
|
}
|
|
42878
43040
|
});
|
|
42879
|
-
const column = getColumn(
|
|
43041
|
+
const column = getColumn(indexCol, index);
|
|
43042
|
+
console.log(column);
|
|
42880
43043
|
if (column) {
|
|
42881
43044
|
if ((!column.disabledCondition || !column.disabledCondition(dataSource[currenRowIndex + 0])) && column.editEnable && column.onPasteValidate) {
|
|
42882
43045
|
const rs = await column.onPasteValidate(stringData.join(','), currenRowIndex + 0, dataSource[currenRowIndex + 0]);
|
|
@@ -42953,8 +43116,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42953
43116
|
}
|
|
42954
43117
|
}
|
|
42955
43118
|
else if (column.editType === 'select') {
|
|
42956
|
-
|
|
42957
|
-
if (rs) {
|
|
43119
|
+
if (column.selectSettings?.allowCreate) {
|
|
42958
43120
|
if (column.onPaste) {
|
|
42959
43121
|
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
42960
43122
|
}
|
|
@@ -42962,11 +43124,25 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42962
43124
|
dataRow[column.field] = stringData;
|
|
42963
43125
|
}
|
|
42964
43126
|
if (column.callback) {
|
|
42965
|
-
column.callback(
|
|
43127
|
+
column.callback(stringData, currenRowIndex + indexRow);
|
|
42966
43128
|
}
|
|
42967
43129
|
}
|
|
42968
43130
|
else {
|
|
42969
|
-
|
|
43131
|
+
const rs = ((column.selectSettings?.optionsField ? item[column.selectSettings?.optionsField] : column.selectSettings?.options) ?? []).find((item) => item[column.selectSettings?.fieldValue ?? 'value'] === stringData);
|
|
43132
|
+
if (rs) {
|
|
43133
|
+
if (column.onPaste) {
|
|
43134
|
+
dataRow[column.field] = column.onPaste(dataRow, stringData);
|
|
43135
|
+
}
|
|
43136
|
+
else {
|
|
43137
|
+
dataRow[column.field] = stringData;
|
|
43138
|
+
}
|
|
43139
|
+
if (column.callback) {
|
|
43140
|
+
column.callback(rs, currenRowIndex + indexRow);
|
|
43141
|
+
}
|
|
43142
|
+
}
|
|
43143
|
+
else {
|
|
43144
|
+
notificationError(t('PasteExcelNotExist', { index: (currenRowIndex + indexRow + 1), field: t(column.headerText ?? ''), value: stringData }));
|
|
43145
|
+
}
|
|
42970
43146
|
}
|
|
42971
43147
|
}
|
|
42972
43148
|
else {
|
|
@@ -42991,7 +43167,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
42991
43167
|
}
|
|
42992
43168
|
changeDataSource(dataSource);
|
|
42993
43169
|
};
|
|
42994
|
-
const changeDataSource = (data,
|
|
43170
|
+
const changeDataSource = (data, numberOfRows) => {
|
|
42995
43171
|
if (!editDisable && setDataSource) {
|
|
42996
43172
|
if ((searchSetting?.searchTerm !== undefined ? searchSetting?.searchTerm : searchTerm)) {
|
|
42997
43173
|
if (searchSetting?.setSearchTerm) {
|
|
@@ -43001,8 +43177,10 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43001
43177
|
setSearchTerm('');
|
|
43002
43178
|
}
|
|
43003
43179
|
}
|
|
43004
|
-
if (
|
|
43005
|
-
|
|
43180
|
+
if (numberOfRows && !addDisable) {
|
|
43181
|
+
for (let index = 0; index < numberOfRows; index++) {
|
|
43182
|
+
data.push(defaultValue ? { ...defaultValue, [fieldKey]: disableAutoKey ? undefined : generateUUID() } : {});
|
|
43183
|
+
}
|
|
43006
43184
|
setDataSource([...data]);
|
|
43007
43185
|
}
|
|
43008
43186
|
else {
|
|
@@ -43105,9 +43283,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43105
43283
|
else if (col.field === 'checkbox') {
|
|
43106
43284
|
return (jsxRuntime.jsx("td", { className: classnames(`r-rowcell p-0 fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'r-active': (isSelected && editDisable) || indexFocus === indexRow }), style: {
|
|
43107
43285
|
left: col.fixedType === 'left' ? objWidthFix[indexCol] : undefined,
|
|
43108
|
-
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43109
|
-
|
|
43110
|
-
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", onClick: (e) => {
|
|
43286
|
+
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43287
|
+
}, children: jsxRuntime.jsx("div", { className: "r-rowcell-div cursor-pointer", style: { alignItems: 'center' }, onClick: (e) => {
|
|
43111
43288
|
if (selectEnable) {
|
|
43112
43289
|
const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
|
|
43113
43290
|
if (index > -1) {
|
|
@@ -43129,7 +43306,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43129
43306
|
}
|
|
43130
43307
|
e.stopPropagation();
|
|
43131
43308
|
}
|
|
43132
|
-
}, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer",
|
|
43309
|
+
}, children: jsxRuntime.jsx(Input$1, { checked: isSelected, type: "checkbox", className: "cursor-pointer", style: { textAlign: col.textAlign ?? 'center' } }) }) }, `col-${indexRow}-${indexCol}`));
|
|
43133
43310
|
}
|
|
43134
43311
|
else {
|
|
43135
43312
|
let value = row[col.field];
|
|
@@ -43146,9 +43323,7 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43146
43323
|
const errorMessage = typeDis === 1 || col.field === '' || !col.validate ? '' : col.validate(row[col.field], row);
|
|
43147
43324
|
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: {
|
|
43148
43325
|
left: col.fixedType === 'left' ? objWidthFix[indexCol] : undefined,
|
|
43149
|
-
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43150
|
-
padding: 0,
|
|
43151
|
-
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
43326
|
+
right: col.fixedType === 'right' ? objWidthFix[indexCol] : undefined
|
|
43152
43327
|
}, onClick: (e) => {
|
|
43153
43328
|
if (e.target.nodeName === 'DIV' || e.target.nodeName === 'TD') {
|
|
43154
43329
|
if (!editDisable && indexRow != indexFocus) {
|
|
@@ -43178,9 +43353,21 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43178
43353
|
e.stopPropagation();
|
|
43179
43354
|
}
|
|
43180
43355
|
}, 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: {
|
|
43181
|
-
|
|
43182
|
-
}, children: [typeDis === 1 && !refreshRow
|
|
43356
|
+
textAlign: col.textAlign ? col.textAlign : 'left'
|
|
43357
|
+
}, 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));
|
|
43358
|
+
}
|
|
43359
|
+
};
|
|
43360
|
+
const RenderContentCell = (row, col, indexCol, indexRow, typeDis, value) => {
|
|
43361
|
+
if (typeDis === 2) {
|
|
43362
|
+
const value = col.template?.(row, indexRow) ?? '';
|
|
43363
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
43364
|
+
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) })] }));
|
|
43365
|
+
}
|
|
43366
|
+
else {
|
|
43367
|
+
return value;
|
|
43368
|
+
}
|
|
43183
43369
|
}
|
|
43370
|
+
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) })] }));
|
|
43184
43371
|
};
|
|
43185
43372
|
const renderFooterCol = (col, indexCol) => {
|
|
43186
43373
|
const sumValue = (col.haveSum === true && col.editType === "numeric") ? dataSource.reduce(function (accumulator, currentValue) { return (Number(accumulator ?? 0) + Number(currentValue[col.field] ?? 0)); }, 0) : 0;
|
|
@@ -43223,8 +43410,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
43223
43410
|
}) }, `header-${-indexParent}`));
|
|
43224
43411
|
}) }), 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) => {
|
|
43225
43412
|
return (renderFooterCol(col, index));
|
|
43226
|
-
}) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsxRuntime.jsx(ToolbarBottom, { handleAdd: () => {
|
|
43227
|
-
handleAdd(dataSource, tableElement.current, columnFistEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement);
|
|
43413
|
+
}) }) : jsxRuntime.jsx(jsxRuntime.Fragment, {}) })] }) }), toolbarSetting?.showBottomToolbar && jsxRuntime.jsx(ToolbarBottom, { handleAdd: (numberOfRows) => {
|
|
43414
|
+
handleAdd(dataSource, tableElement.current, columnFistEdit, changeDataSource, pagingSetting, setIndexFocus, focusNewElement, numberOfRows);
|
|
43228
43415
|
}, handleDuplicate: () => {
|
|
43229
43416
|
handleDuplicate(dataSource, indexFocus, fieldKey, defaultValue, fieldUniKey, changeDataSource, tableElement, totalCount, toolbarSetting, buttonSetting, editDisable, addDisable, onDuplicate);
|
|
43230
43417
|
}, handleInsertAfter: () => {
|
|
@@ -64970,7 +65157,7 @@ const TabSelectFileImportExcel = (props) => {
|
|
|
64970
65157
|
getSheetsExcel(e.target.files[0], setValue, setOptionSheetName);
|
|
64971
65158
|
}, hidden: true, accept: '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel' })] })] }) : jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'fs-4 bolder', children: t('Drag and drop files here') }), jsxRuntime.jsx("div", { className: 'my-50', children: t('or') }), jsxRuntime.jsxs(Button$1, { tag: Label$1, outline: true, className: 'me-75', size: 'md', color: 'primary', children: [jsxRuntime.jsx(SvgArrowLeftCircle, { fontSize: 18, className: 'me-50' }), t('Select file'), jsxRuntime.jsx(Input$1, { type: 'file', onChange: (e) => {
|
|
64972
65159
|
getSheetsExcel(e.target.files[0], setValue, setOptionSheetName);
|
|
64973
|
-
}, hidden: true, accept: '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel' })] }), jsxRuntime.jsx("div", { className: 'mt-1', children: t('Accepts .xls, .xlsx, .csv files') })] }) }), jsxRuntime.jsxs(Row$1, { className: `${getValues('file') ? '' : 'd-none'} m-0 gy-1`, children: [jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.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 }) }), jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.jsx(NumberInput, { control: control, name: "headerRow", labelSize: "d-flex form-row-inline label-medium", label: t("Header row"), errors: errors.headerRow }) })] })] }));
|
|
65160
|
+
}, hidden: true, accept: '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel' })] }), jsxRuntime.jsx("div", { className: 'mt-1', children: t('Accepts .xls, .xlsx, .csv files') })] }) }), jsxRuntime.jsxs(Row$1, { className: `${getValues('file') ? '' : 'd-none'} m-0 gy-1`, children: [jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.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 }) }), jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.jsx(NumberInput, { control: control, name: "headerRow", labelSize: "d-flex form-row-inline label-medium", label: t("Header row"), errors: errors.headerRow }) })] })] }));
|
|
64974
65161
|
};
|
|
64975
65162
|
|
|
64976
65163
|
const TabMergeImportExcel = (props) => {
|