dtable-ui-component 0.1.94-test8 → 0.1.94-uitest1
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/CheckboxEditor/index.css +31 -0
- package/lib/CheckboxEditor/index.js +17 -44
- package/lib/TextEditor/index.js +18 -18
- package/lib/TextEditor/index2.js +103 -0
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.dtable-ui-checkbox-editor {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 24px;
|
|
4
|
+
height: 24px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.dtable-ui-checkbox-editor .raw-checkbox {
|
|
8
|
+
position: absolute;
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
opacity: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.dtable-ui-checkbox-editor .shown-checkbox {
|
|
15
|
+
height: 100%;
|
|
16
|
+
border: 2px solid #e0e0e0;
|
|
17
|
+
border-radius: 3px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.dtable-ui-checkbox-editor .raw-checkbox:focus + .shown-checkbox {
|
|
21
|
+
border-color: #3b88fd;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.dtable-ui-checkbox-editor .shown-checkbox .dtable-icon-check-mark {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
color: #20c933;
|
|
30
|
+
font-weight: 500;
|
|
31
|
+
}
|
|
@@ -3,6 +3,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
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
|
+
import './index.css';
|
|
6
7
|
|
|
7
8
|
var CheckboxEditor = /*#__PURE__*/function (_React$Component) {
|
|
8
9
|
_inherits(CheckboxEditor, _React$Component);
|
|
@@ -16,15 +17,10 @@ var CheckboxEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
16
17
|
|
|
17
18
|
_this = _super.call(this, props);
|
|
18
19
|
|
|
19
|
-
_this.
|
|
20
|
+
_this.onCommit = function () {
|
|
20
21
|
var updated = {};
|
|
21
22
|
var column = _this.props.column;
|
|
22
23
|
updated[column.name] = _this.state.value;
|
|
23
|
-
return updated;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
_this.onCommit = function () {
|
|
27
|
-
var updated = _this.getValue();
|
|
28
24
|
|
|
29
25
|
_this.props.onCommit(updated);
|
|
30
26
|
};
|
|
@@ -34,37 +30,13 @@ var CheckboxEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
34
30
|
return;
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
var value = event.target.checked;
|
|
38
|
-
|
|
39
|
-
if (value === _this.state.value) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
33
|
_this.setState({
|
|
44
|
-
value: value
|
|
34
|
+
value: !_this.state.value
|
|
45
35
|
}, function () {
|
|
46
36
|
_this.onCommit();
|
|
47
37
|
});
|
|
48
38
|
};
|
|
49
39
|
|
|
50
|
-
_this.onKeyDown = function (event) {
|
|
51
|
-
event.stopPropagation();
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
_this.onBlur = function () {// this.onCommit();
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
_this.setInputRef = function (input) {
|
|
58
|
-
_this.input = input;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
_this.getStyle = function () {
|
|
62
|
-
return {
|
|
63
|
-
marginLeft: 0,
|
|
64
|
-
transform: 'scale(1.1)'
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
40
|
_this.state = {
|
|
69
41
|
value: props.value ? props.value : false
|
|
70
42
|
};
|
|
@@ -74,22 +46,23 @@ var CheckboxEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
74
46
|
_createClass(CheckboxEditor, [{
|
|
75
47
|
key: "render",
|
|
76
48
|
value: function render() {
|
|
77
|
-
var
|
|
49
|
+
var value = this.state.value;
|
|
50
|
+
var isReadOnly = this.props.isReadOnly;
|
|
51
|
+
var style = {
|
|
52
|
+
cursor: isReadOnly ? 'default' : 'pointer'
|
|
53
|
+
};
|
|
78
54
|
return /*#__PURE__*/React.createElement("div", {
|
|
79
|
-
className: "
|
|
80
|
-
|
|
81
|
-
className: "checkbox-editor-container"
|
|
55
|
+
className: "dtable-ui-checkbox-editor",
|
|
56
|
+
style: style
|
|
82
57
|
}, /*#__PURE__*/React.createElement("input", {
|
|
83
|
-
ref: this.setInputRef,
|
|
84
58
|
type: "checkbox",
|
|
85
|
-
className: "checkbox",
|
|
86
|
-
checked:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
readOnly: this.props.isReadOnly
|
|
59
|
+
className: "raw-checkbox",
|
|
60
|
+
checked: value,
|
|
61
|
+
onChange: this.onChange
|
|
62
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
className: "shown-checkbox"
|
|
64
|
+
}, value && /*#__PURE__*/React.createElement("span", {
|
|
65
|
+
className: "dtable-font dtable-icon-check-mark"
|
|
93
66
|
})));
|
|
94
67
|
}
|
|
95
68
|
}]);
|
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;
|