material-react-table 0.38.1 → 0.38.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.
|
@@ -1773,33 +1773,43 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1773
1773
|
})
|
|
1774
1774
|
: columnDef.muiTableBodyCellEditTextFieldProps;
|
|
1775
1775
|
const textFieldProps = Object.assign(Object.assign({}, mTableBodyCellEditTextFieldProps), mcTableBodyCellEditTextFieldProps);
|
|
1776
|
+
const saveRow = (newValue) => {
|
|
1777
|
+
if (editingRow) {
|
|
1778
|
+
setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: newValue }) }));
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1776
1781
|
const handleChange = (event) => {
|
|
1777
1782
|
var _a;
|
|
1778
1783
|
(_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1779
1784
|
setValue(event.target.value);
|
|
1780
|
-
if (
|
|
1781
|
-
|
|
1785
|
+
if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select) {
|
|
1786
|
+
saveRow(event.target.value);
|
|
1782
1787
|
}
|
|
1783
1788
|
};
|
|
1784
1789
|
const handleBlur = (event) => {
|
|
1785
1790
|
var _a;
|
|
1786
1791
|
(_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1787
|
-
|
|
1788
|
-
setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: value }) }));
|
|
1789
|
-
}
|
|
1792
|
+
saveRow(value);
|
|
1790
1793
|
setEditingCell(null);
|
|
1791
1794
|
};
|
|
1795
|
+
const handleEnterKeyDown = (event) => {
|
|
1796
|
+
var _a, _b;
|
|
1797
|
+
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1798
|
+
if (event.key === 'Enter') {
|
|
1799
|
+
(_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1792
1802
|
if (columnDef.Edit) {
|
|
1793
1803
|
return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }));
|
|
1794
1804
|
}
|
|
1795
|
-
return (React.createElement(TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true,
|
|
1805
|
+
return (React.createElement(TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true, inputRef: (inputRef) => {
|
|
1796
1806
|
if (inputRef) {
|
|
1797
1807
|
editInputRefs.current[column.id] = inputRef;
|
|
1798
1808
|
if (textFieldProps.inputRef) {
|
|
1799
1809
|
textFieldProps.inputRef = inputRef;
|
|
1800
1810
|
}
|
|
1801
1811
|
}
|
|
1802
|
-
}, onBlur: handleBlur, onChange: handleChange })));
|
|
1812
|
+
}, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { onBlur: handleBlur, onChange: handleChange, onKeyDown: handleEnterKeyDown })));
|
|
1803
1813
|
};
|
|
1804
1814
|
|
|
1805
1815
|
const MRT_CopyButton = ({ cell, children, table, }) => {
|