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