dtable-ui-component 0.1.93 → 0.1.94-test3
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/lib/TextEditor/index.js +7 -26
- package/package.json +1 -1
package/lib/TextEditor/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import isHotkey from 'is-hotkey';
|
|
7
|
+
import { Input } from 'reactstrap';
|
|
7
8
|
|
|
8
9
|
var TextEditor = /*#__PURE__*/function (_React$Component) {
|
|
9
10
|
_inherits(TextEditor, _React$Component);
|
|
@@ -21,13 +22,9 @@ var TextEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
21
22
|
var updated = {};
|
|
22
23
|
var column = _this.props.column;
|
|
23
24
|
var newValue = _this.state.newValue;
|
|
24
|
-
updated[column.
|
|
25
|
+
updated[column.name] = newValue ? newValue.trim() : '';
|
|
25
26
|
|
|
26
27
|
_this.props.onCommit(updated);
|
|
27
|
-
|
|
28
|
-
_this.setState({
|
|
29
|
-
isEditorShow: false
|
|
30
|
-
});
|
|
31
28
|
};
|
|
32
29
|
|
|
33
30
|
_this.onBlur = function () {
|
|
@@ -42,18 +39,6 @@ var TextEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
42
39
|
});
|
|
43
40
|
};
|
|
44
41
|
|
|
45
|
-
_this.onEditorHandle = function () {
|
|
46
|
-
if (_this.props.isReadOnly) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
_this.setState({
|
|
51
|
-
isEditorShow: true
|
|
52
|
-
}, function () {
|
|
53
|
-
_this.input.focus();
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
42
|
_this.onKeyDown = function (event) {
|
|
58
43
|
var _event$currentTarget = event.currentTarget,
|
|
59
44
|
selectionStart = _event$currentTarget.selectionStart,
|
|
@@ -62,8 +47,7 @@ var TextEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
62
47
|
|
|
63
48
|
if (isHotkey('enter', event)) {
|
|
64
49
|
event.preventDefault();
|
|
65
|
-
|
|
66
|
-
_this.onBlur();
|
|
50
|
+
event.target.blur();
|
|
67
51
|
} else if (event.keyCode === 37 && selectionStart === 0 || event.keyCode === 39 && selectionEnd === value.length) {
|
|
68
52
|
event.stopPropagation();
|
|
69
53
|
}
|
|
@@ -82,8 +66,7 @@ var TextEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
82
66
|
};
|
|
83
67
|
|
|
84
68
|
_this.state = {
|
|
85
|
-
newValue: props.value
|
|
86
|
-
isEditorShow: false
|
|
69
|
+
newValue: props.value
|
|
87
70
|
};
|
|
88
71
|
return _this;
|
|
89
72
|
}
|
|
@@ -91,18 +74,16 @@ var TextEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
91
74
|
_createClass(TextEditor, [{
|
|
92
75
|
key: "render",
|
|
93
76
|
value: function render() {
|
|
77
|
+
var isReadOnly = this.props.isReadOnly;
|
|
94
78
|
return /*#__PURE__*/React.createElement("div", {
|
|
95
79
|
className: "cell-editor text-editor"
|
|
96
80
|
}, /*#__PURE__*/React.createElement("div", {
|
|
97
81
|
className: "text-editor-container"
|
|
98
|
-
},
|
|
99
|
-
className: "form-control",
|
|
100
|
-
onClick: this.onEditorHandle
|
|
101
|
-
}, this.state.newValue), this.state.isEditorShow && /*#__PURE__*/React.createElement("input", {
|
|
82
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
102
83
|
ref: this.setInputRef,
|
|
103
84
|
type: "text",
|
|
104
|
-
className: "form-control",
|
|
105
85
|
value: this.state.newValue,
|
|
86
|
+
readOnly: isReadOnly,
|
|
106
87
|
onChange: this.onChange,
|
|
107
88
|
onKeyDown: this.onKeyDown,
|
|
108
89
|
onBlur: this.onBlur,
|