react-table-edit 1.5.1 → 1.5.2
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 -0
- package/dist/index.js +23 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -23906,7 +23906,7 @@ const SelectTableBox$1 = (props) => {
|
|
|
23906
23906
|
|
|
23907
23907
|
const defaultWidth = 200;
|
|
23908
23908
|
const EditForm = forwardRef((props, ref) => {
|
|
23909
|
-
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;
|
|
23909
|
+
const { id, field, displayValue, menuHeight, menuWidth, rowData, invalid, onChange, onChangeField, onKeyDown, defaultValues, placeholder, textAlign, schema, onFormOpen, onFormSubmit, footerTemplate, template, minWidth, onPaste, openOnFocus, isClearable, indexRow, component, labelSize = 'label-small' } = props;
|
|
23910
23910
|
const { innerWidth } = window;
|
|
23911
23911
|
const inputRef = useRef(null);
|
|
23912
23912
|
const editFormRef = useRef(null);
|
|
@@ -24088,12 +24088,13 @@ const EditForm = forwardRef((props, ref) => {
|
|
|
24088
24088
|
padding: template ? 0 : 'auto',
|
|
24089
24089
|
backgroundColor: '$white',
|
|
24090
24090
|
textAlign: textAlign ?? 'left'
|
|
24091
|
-
}, 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: {
|
|
24091
|
+
}, 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', container: component, style: {
|
|
24092
|
+
position: 'fixed',
|
|
24092
24093
|
minWidth: minWidth ? minWidth : defaultWidth,
|
|
24093
24094
|
width: menuWidth ? menuWidth : 'min-content',
|
|
24094
24095
|
maxWidth: innerWidth > 1280 ? 1280 : innerWidth,
|
|
24095
24096
|
borderRadius: 8,
|
|
24096
|
-
zIndex:
|
|
24097
|
+
zIndex: 9999
|
|
24097
24098
|
}, children: jsxs(DropdownItem$1, { className: 'p-0', style: { borderRadius: '6px' }, tag: 'div', header: true, children: [jsx("div", { onKeyDown: (e) => formKeyDown(e, handleSubmit(handleOnSubmit)), className: 'p-1', style: {
|
|
24098
24099
|
maxHeight: menuHeight ? menuHeight : 300,
|
|
24099
24100
|
overflow: "auto"
|
|
@@ -41174,7 +41175,7 @@ const RenderEditCellComponent = (props) => {
|
|
|
41174
41175
|
}
|
|
41175
41176
|
} }, `col-${indexRow}-${indexCol}`) }));
|
|
41176
41177
|
case "form":
|
|
41177
|
-
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) => {
|
|
41178
|
+
return (jsx(EditForm, { id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`, ...col.formSettings, component: gridRef, field: col.field, displayValue: col.formSettings?.displayValue ? col.formSettings?.displayValue(row) : "", placeholder: col.placeholder ? t(col.placeholder) : "", rowData: row, indexRow: indexRow, onChange: (val) => {
|
|
41178
41179
|
Object.assign(row, val);
|
|
41179
41180
|
handleDataChange(row, col, indexRow);
|
|
41180
41181
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -41462,38 +41463,46 @@ const CellComponent = React__default.memo((props) => {
|
|
|
41462
41463
|
const isActiveCell = col.field !== '#' && selectedCell && indexRow >= selectedCell.minRow && indexRow <= selectedCell.maxRow && indexCol >= selectedCell.minCol && indexCol <= selectedCell.maxCol;
|
|
41463
41464
|
const isActiveRow = col.field === '#' && selectedCell && indexRow >= selectedCell.minRow && indexRow <= selectedCell.maxRow;
|
|
41464
41465
|
useEffect(() => {
|
|
41465
|
-
if (!containerRef?.current)
|
|
41466
|
+
if (!containerRef?.current) {
|
|
41466
41467
|
return;
|
|
41468
|
+
}
|
|
41467
41469
|
const rafId = { current: 0 }; // hoặc useRef<number | null>(null)
|
|
41468
41470
|
const handleMouseMove = (e) => {
|
|
41469
|
-
if (!typeDragging.current)
|
|
41471
|
+
if (!typeDragging.current) {
|
|
41470
41472
|
return;
|
|
41473
|
+
}
|
|
41471
41474
|
const container = containerRef.current;
|
|
41472
41475
|
const rect = container.getBoundingClientRect();
|
|
41473
41476
|
const scrollStepVert = 50;
|
|
41474
41477
|
const scrollStepHor = 100;
|
|
41475
41478
|
let newTop = container.scrollTop;
|
|
41476
41479
|
let newLeft = container.scrollLeft;
|
|
41477
|
-
if (e.clientY < rect.top + 30)
|
|
41480
|
+
if (e.clientY < rect.top + 30) {
|
|
41478
41481
|
newTop -= scrollStepVert;
|
|
41479
|
-
|
|
41482
|
+
}
|
|
41483
|
+
else if (e.clientY > rect.bottom - 30) {
|
|
41480
41484
|
newTop += scrollStepVert;
|
|
41481
|
-
|
|
41485
|
+
}
|
|
41486
|
+
if (e.clientX < rect.left + 30) {
|
|
41482
41487
|
newLeft -= scrollStepHor;
|
|
41483
|
-
|
|
41488
|
+
}
|
|
41489
|
+
else if (e.clientX > rect.right - 30) {
|
|
41484
41490
|
newLeft += scrollStepHor;
|
|
41491
|
+
}
|
|
41485
41492
|
// Scroll smooth, chỉ khi cần
|
|
41486
41493
|
if (newTop !== container.scrollTop || newLeft !== container.scrollLeft) {
|
|
41487
|
-
if (rafId.current)
|
|
41494
|
+
if (rafId.current) {
|
|
41488
41495
|
cancelAnimationFrame(rafId.current);
|
|
41496
|
+
}
|
|
41489
41497
|
rafId.current = requestAnimationFrame(() => {
|
|
41490
41498
|
container.scrollTo({ top: newTop, left: newLeft, behavior: "smooth" });
|
|
41491
41499
|
});
|
|
41492
41500
|
}
|
|
41493
41501
|
};
|
|
41494
41502
|
const handleMouseUp = () => {
|
|
41495
|
-
if (!typeDragging.current)
|
|
41503
|
+
if (!typeDragging.current) {
|
|
41496
41504
|
return;
|
|
41505
|
+
}
|
|
41497
41506
|
document.body.style.userSelect = "";
|
|
41498
41507
|
typeDragging.current = 0;
|
|
41499
41508
|
isCopying.current = false;
|
|
@@ -41503,8 +41512,9 @@ const CellComponent = React__default.memo((props) => {
|
|
|
41503
41512
|
return () => {
|
|
41504
41513
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
41505
41514
|
window.removeEventListener("mouseup", handleMouseUp);
|
|
41506
|
-
if (rafId.current)
|
|
41515
|
+
if (rafId.current) {
|
|
41507
41516
|
cancelAnimationFrame(rafId.current);
|
|
41517
|
+
}
|
|
41508
41518
|
};
|
|
41509
41519
|
}, [containerRef]);
|
|
41510
41520
|
if (col.visible === false) {
|