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
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
rowData: any;
|
|
15
15
|
indexRow: any;
|
|
16
16
|
defaultValues?: any;
|
|
17
|
+
component?: string | HTMLElement | React.RefObject<HTMLElement> | undefined;
|
|
17
18
|
schema?: InferType<any>;
|
|
18
19
|
onKeyDown?: (e: React.KeyboardEvent<any>) => void | any;
|
|
19
20
|
onFormOpen?: (rowData: any, itemsField: FromItemsField[], setItemsField: Dispatch<SetStateAction<FromItemsField[]>>) => void;
|
package/dist/index.js
CHANGED
|
@@ -23935,7 +23935,7 @@ const SelectTableBox$1 = (props) => {
|
|
|
23935
23935
|
|
|
23936
23936
|
const defaultWidth = 200;
|
|
23937
23937
|
const EditForm = React$5.forwardRef((props, ref) => {
|
|
23938
|
-
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;
|
|
23938
|
+
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;
|
|
23939
23939
|
const { innerWidth } = window;
|
|
23940
23940
|
const inputRef = React$5.useRef(null);
|
|
23941
23941
|
const editFormRef = React$5.useRef(null);
|
|
@@ -24117,12 +24117,13 @@ const EditForm = React$5.forwardRef((props, ref) => {
|
|
|
24117
24117
|
padding: template ? 0 : 'auto',
|
|
24118
24118
|
backgroundColor: '$white',
|
|
24119
24119
|
textAlign: textAlign ?? 'left'
|
|
24120
|
-
}, 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: {
|
|
24120
|
+
}, 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', container: component, style: {
|
|
24121
|
+
position: 'fixed',
|
|
24121
24122
|
minWidth: minWidth ? minWidth : defaultWidth,
|
|
24122
24123
|
width: menuWidth ? menuWidth : 'min-content',
|
|
24123
24124
|
maxWidth: innerWidth > 1280 ? 1280 : innerWidth,
|
|
24124
24125
|
borderRadius: 8,
|
|
24125
|
-
zIndex:
|
|
24126
|
+
zIndex: 9999
|
|
24126
24127
|
}, children: jsxRuntime.jsxs(DropdownItem$1, { className: 'p-0', style: { borderRadius: '6px' }, tag: 'div', header: true, children: [jsxRuntime.jsx("div", { onKeyDown: (e) => formKeyDown(e, handleSubmit(handleOnSubmit)), className: 'p-1', style: {
|
|
24127
24128
|
maxHeight: menuHeight ? menuHeight : 300,
|
|
24128
24129
|
overflow: "auto"
|
|
@@ -41203,7 +41204,7 @@ const RenderEditCellComponent = (props) => {
|
|
|
41203
41204
|
}
|
|
41204
41205
|
} }, `col-${indexRow}-${indexCol}`) }));
|
|
41205
41206
|
case "form":
|
|
41206
|
-
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) => {
|
|
41207
|
+
return (jsxRuntime.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) => {
|
|
41207
41208
|
Object.assign(row, val);
|
|
41208
41209
|
handleDataChange(row, col, indexRow);
|
|
41209
41210
|
}, invalid: col.validate && col.validate(row[col.field], row), textAlign: col.textAlign, template: col.template, onKeyDown: (e) => {
|
|
@@ -41491,38 +41492,46 @@ const CellComponent = React__default["default"].memo((props) => {
|
|
|
41491
41492
|
const isActiveCell = col.field !== '#' && selectedCell && indexRow >= selectedCell.minRow && indexRow <= selectedCell.maxRow && indexCol >= selectedCell.minCol && indexCol <= selectedCell.maxCol;
|
|
41492
41493
|
const isActiveRow = col.field === '#' && selectedCell && indexRow >= selectedCell.minRow && indexRow <= selectedCell.maxRow;
|
|
41493
41494
|
React$5.useEffect(() => {
|
|
41494
|
-
if (!containerRef?.current)
|
|
41495
|
+
if (!containerRef?.current) {
|
|
41495
41496
|
return;
|
|
41497
|
+
}
|
|
41496
41498
|
const rafId = { current: 0 }; // hoặc useRef<number | null>(null)
|
|
41497
41499
|
const handleMouseMove = (e) => {
|
|
41498
|
-
if (!typeDragging.current)
|
|
41500
|
+
if (!typeDragging.current) {
|
|
41499
41501
|
return;
|
|
41502
|
+
}
|
|
41500
41503
|
const container = containerRef.current;
|
|
41501
41504
|
const rect = container.getBoundingClientRect();
|
|
41502
41505
|
const scrollStepVert = 50;
|
|
41503
41506
|
const scrollStepHor = 100;
|
|
41504
41507
|
let newTop = container.scrollTop;
|
|
41505
41508
|
let newLeft = container.scrollLeft;
|
|
41506
|
-
if (e.clientY < rect.top + 30)
|
|
41509
|
+
if (e.clientY < rect.top + 30) {
|
|
41507
41510
|
newTop -= scrollStepVert;
|
|
41508
|
-
|
|
41511
|
+
}
|
|
41512
|
+
else if (e.clientY > rect.bottom - 30) {
|
|
41509
41513
|
newTop += scrollStepVert;
|
|
41510
|
-
|
|
41514
|
+
}
|
|
41515
|
+
if (e.clientX < rect.left + 30) {
|
|
41511
41516
|
newLeft -= scrollStepHor;
|
|
41512
|
-
|
|
41517
|
+
}
|
|
41518
|
+
else if (e.clientX > rect.right - 30) {
|
|
41513
41519
|
newLeft += scrollStepHor;
|
|
41520
|
+
}
|
|
41514
41521
|
// Scroll smooth, chỉ khi cần
|
|
41515
41522
|
if (newTop !== container.scrollTop || newLeft !== container.scrollLeft) {
|
|
41516
|
-
if (rafId.current)
|
|
41523
|
+
if (rafId.current) {
|
|
41517
41524
|
cancelAnimationFrame(rafId.current);
|
|
41525
|
+
}
|
|
41518
41526
|
rafId.current = requestAnimationFrame(() => {
|
|
41519
41527
|
container.scrollTo({ top: newTop, left: newLeft, behavior: "smooth" });
|
|
41520
41528
|
});
|
|
41521
41529
|
}
|
|
41522
41530
|
};
|
|
41523
41531
|
const handleMouseUp = () => {
|
|
41524
|
-
if (!typeDragging.current)
|
|
41532
|
+
if (!typeDragging.current) {
|
|
41525
41533
|
return;
|
|
41534
|
+
}
|
|
41526
41535
|
document.body.style.userSelect = "";
|
|
41527
41536
|
typeDragging.current = 0;
|
|
41528
41537
|
isCopying.current = false;
|
|
@@ -41532,8 +41541,9 @@ const CellComponent = React__default["default"].memo((props) => {
|
|
|
41532
41541
|
return () => {
|
|
41533
41542
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
41534
41543
|
window.removeEventListener("mouseup", handleMouseUp);
|
|
41535
|
-
if (rafId.current)
|
|
41544
|
+
if (rafId.current) {
|
|
41536
41545
|
cancelAnimationFrame(rafId.current);
|
|
41546
|
+
}
|
|
41537
41547
|
};
|
|
41538
41548
|
}, [containerRef]);
|
|
41539
41549
|
if (col.visible === false) {
|