dtable-ui-component 4.3.6 → 4.3.8
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/AutoNumberFormatter/index.js +11 -24
- package/lib/ButtonFormatter/index.js +29 -45
- package/lib/CTimeFormatter/index.js +17 -32
- package/lib/CheckboxEditor/index.js +42 -49
- package/lib/CheckboxFormatter/index.js +17 -30
- package/lib/CollaboratorEditor/index.js +118 -135
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
- package/lib/CollaboratorFormatter/index.js +26 -42
- package/lib/CollaboratorItem/index.js +31 -44
- package/lib/CreatorFormatter/index.js +24 -40
- package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
- package/lib/DTableCustomizeSelect/index.css +22 -59
- package/lib/DTableCustomizeSelect/index.js +99 -95
- package/lib/DTablePopover/index.js +52 -71
- package/lib/DTablePopover/utils.js +1 -1
- package/lib/DTableRadio/index.js +9 -7
- package/lib/DTableSearchInput/index.js +89 -99
- package/lib/DTableSearchInput/utils.js +2 -2
- package/lib/DTableSelect/dtable-select-label.js +5 -3
- package/lib/DTableSelect/index.js +50 -64
- package/lib/DTableSelect/utils.js +36 -41
- package/lib/DTableSwitch/index.js +7 -5
- package/lib/DateEditor/index.js +88 -94
- package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
- package/lib/DateEditor/pc-date-editor-popover.js +70 -77
- package/lib/DateFormatter/index.js +15 -28
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
- package/lib/DigitalSignFormatter/index.js +55 -65
- package/lib/DigitalSignFormatter/utils.js +9 -8
- package/lib/DurationFormatter/index.js +14 -27
- package/lib/EditEditorButton/index.js +10 -22
- package/lib/EmailFormatter/index.js +11 -24
- package/lib/FieldDisplaySetting/field-item.js +18 -20
- package/lib/FieldDisplaySetting/index.js +41 -43
- package/lib/FileEditor/index.js +18 -29
- package/lib/FileFormatter/index.js +29 -43
- package/lib/FileItemFormatter/index.js +17 -32
- package/lib/FileItemFormatter/utils.js +5 -5
- package/lib/FileUploader/index.js +20 -33
- package/lib/FormulaFormatter/cell-value-validator.js +23 -8
- package/lib/FormulaFormatter/index.js +77 -83
- package/lib/FormulaFormatter/utils.js +27 -21
- package/lib/GeolocationFormatter/index.js +19 -32
- package/lib/HtmlLongTextFormatter/index.js +43 -52
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
- package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
- package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
- package/lib/ImageFormatter/images-lazy-load.js +71 -79
- package/lib/ImageFormatter/index.js +86 -97
- package/lib/ImageFormatter/utils.js +1 -1
- package/lib/ImagePreviewerLightbox/index.js +20 -18
- package/lib/ImagePreviewerLightbox/utils.js +3 -3
- package/lib/LastModifierFormatter/index.js +24 -40
- package/lib/LinkEditor/index.js +163 -167
- package/lib/LinkEditor/link-editor-option.js +41 -56
- package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
- package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
- package/lib/LinkFormatter/index.js +75 -77
- package/lib/LongTextFormatter/index.js +5 -3
- package/lib/MBEditorHeader/index.js +25 -38
- package/lib/MTimeFormatter/index.js +17 -32
- package/lib/ModalPortal/index.js +15 -32
- package/lib/MultipleSelectEditor/index.js +118 -136
- package/lib/MultipleSelectFormatter/index.js +24 -40
- package/lib/NotificationPopover/index.js +68 -95
- package/lib/NumberEditor/index.js +75 -82
- package/lib/NumberFormatter/index.js +15 -28
- package/lib/RateFormatter/index.js +29 -45
- package/lib/RoleStatusEditor/index.js +20 -22
- package/lib/RowExpandEmailFormatter/index.js +24 -37
- package/lib/RowExpandFileFormatter/index.js +28 -42
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
- package/lib/RowExpandFormatter/index.js +92 -96
- package/lib/RowExpandFormulaFormatter/index.js +85 -91
- package/lib/RowExpandImageFormatter/index.js +65 -82
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
- package/lib/RowExpandImageFormatter/utils.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
- package/lib/RowExpandLinkFormatter/index.js +131 -137
- package/lib/RowExpandLinkFormatter/utils.js +23 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
- package/lib/RowExpandRateFormatter/index.js +27 -42
- package/lib/RowExpandUrlFormatter/index.js +27 -40
- package/lib/SelectItem/index.js +17 -33
- package/lib/SelectOptionGroup/index.css +103 -0
- package/lib/SelectOptionGroup/index.js +157 -135
- package/lib/SelectOptionGroup/option.js +31 -38
- package/lib/SimpleLongTextFormatter/index.js +55 -67
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
- package/lib/SingleSelectEditor/index.js +108 -119
- package/lib/SingleSelectFormatter/index.js +21 -37
- package/lib/TextEditor/index.js +45 -51
- package/lib/TextFormatter/index.js +17 -32
- package/lib/UrlFormatter/index.js +11 -24
- package/lib/cellFormatterFactory/index.js +8 -17
- package/lib/common/ClickOutside.js +28 -0
- package/lib/common/delete-tip.js +40 -65
- package/lib/common/modal-portal.js +15 -33
- package/lib/constants/index.js +5 -5
- package/lib/data/dtable-value.js +4 -4
- package/lib/formatterConfig/base-formatter-config.js +24 -3
- package/lib/formatterConfig/index.js +5 -4
- package/lib/lang/index.js +6 -6
- package/lib/locals/de.js +1 -1
- package/lib/locals/en.js +1 -1
- package/lib/locals/fr.js +1 -1
- package/lib/locals/zh-CN.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
- package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
- package/lib/select-editor/select-editor-option.js +41 -56
- package/lib/toaster/alert.js +73 -88
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +75 -102
- package/lib/toaster/toastManager.js +55 -91
- package/lib/toaster/toaster.js +58 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- package/package.json +4 -4
|
@@ -1,79 +1,74 @@
|
|
|
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
1
|
import React, { Fragment } from 'react';
|
|
6
2
|
import MediaQuery from 'react-responsive';
|
|
7
3
|
import { getLocale } from '../lang';
|
|
8
4
|
import EditEditorButton from '../EditEditorButton';
|
|
9
5
|
import { SelectEditorOption, PCSelectEditorPopover, MBSelectEditorPopover } from '../select-editor';
|
|
10
6
|
import './index.css';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_this = _super.call(this, props);
|
|
18
|
-
_this.onDocumentToggle = function (e) {
|
|
19
|
-
if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
|
|
20
|
-
_this.onClosePopover();
|
|
7
|
+
class SingleSelectEditor extends React.Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.onDocumentToggle = e => {
|
|
11
|
+
if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
|
|
12
|
+
this.onClosePopover();
|
|
21
13
|
}
|
|
22
14
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
this.formatOption = () => {
|
|
16
|
+
let {
|
|
17
|
+
newValue
|
|
18
|
+
} = this.state;
|
|
19
|
+
let option = this.options.find(option => option.name === newValue);
|
|
28
20
|
return option;
|
|
29
21
|
};
|
|
30
|
-
|
|
22
|
+
this.onAddOptionToggle = event => {
|
|
31
23
|
event.nativeEvent.stopImmediatePropagation();
|
|
32
24
|
event.stopPropagation();
|
|
33
|
-
if (
|
|
25
|
+
if (this.props.isReadOnly) {
|
|
34
26
|
return;
|
|
35
27
|
}
|
|
36
|
-
|
|
28
|
+
let isPopoverShow = !this.state.isPopoverShow;
|
|
37
29
|
if (isPopoverShow) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
isPopoverShow
|
|
41
|
-
popoverPosition
|
|
30
|
+
let popoverPosition = this.caculatePopoverPosition();
|
|
31
|
+
this.setState({
|
|
32
|
+
isPopoverShow,
|
|
33
|
+
popoverPosition
|
|
42
34
|
});
|
|
43
35
|
} else {
|
|
44
|
-
|
|
45
|
-
isPopoverShow
|
|
36
|
+
this.setState({
|
|
37
|
+
isPopoverShow
|
|
46
38
|
});
|
|
47
39
|
}
|
|
48
40
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
this.onCommit = newValue => {
|
|
42
|
+
let updated = {};
|
|
43
|
+
let {
|
|
44
|
+
column
|
|
45
|
+
} = this.props;
|
|
52
46
|
updated[column.name] = newValue;
|
|
53
|
-
|
|
47
|
+
this.props.onCommit(updated);
|
|
54
48
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
newValue
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
this.onOptionItemToggle = option => {
|
|
50
|
+
let newValue = this.state.newValue === option.name ? '' : option.name;
|
|
51
|
+
this.setState({
|
|
52
|
+
newValue
|
|
53
|
+
}, () => {
|
|
54
|
+
this.onCommit(newValue);
|
|
55
|
+
this.onClosePopover();
|
|
62
56
|
});
|
|
63
57
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
top
|
|
69
|
-
height
|
|
70
|
-
|
|
71
|
-
|
|
58
|
+
this.caculatePopoverPosition = () => {
|
|
59
|
+
const POPOVER_MAX_HEIGHT = 200;
|
|
60
|
+
let innerHeight = window.innerHeight;
|
|
61
|
+
let {
|
|
62
|
+
top,
|
|
63
|
+
height
|
|
64
|
+
} = this.editor.getClientRects()[0];
|
|
65
|
+
let isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
|
|
66
|
+
let position = {
|
|
72
67
|
top: height + 1,
|
|
73
68
|
left: 0
|
|
74
69
|
};
|
|
75
70
|
if (!isBelow) {
|
|
76
|
-
|
|
71
|
+
let bottom = height + 1;
|
|
77
72
|
position = {
|
|
78
73
|
bottom: bottom,
|
|
79
74
|
left: 0
|
|
@@ -81,88 +76,82 @@ var SingleSelectEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
81
76
|
}
|
|
82
77
|
return position;
|
|
83
78
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
this.onAddNewOption = optionName => {
|
|
80
|
+
this.props.onAddNewOption(optionName);
|
|
81
|
+
this.onClosePopover();
|
|
87
82
|
};
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
this.onClosePopover = () => {
|
|
84
|
+
this.setState({
|
|
90
85
|
isPopoverShow: false
|
|
91
86
|
});
|
|
92
87
|
};
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
this.setEditorContainerRef = editorContainer => {
|
|
89
|
+
this.editorContainer = editorContainer;
|
|
95
90
|
};
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
this.setEditorRef = editor => {
|
|
92
|
+
this.editor = editor;
|
|
98
93
|
};
|
|
99
|
-
|
|
94
|
+
this.state = {
|
|
100
95
|
newValue: props.value,
|
|
101
96
|
isPopoverShow: false,
|
|
102
97
|
popoverPosition: {}
|
|
103
98
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
let {
|
|
100
|
+
column: _column
|
|
101
|
+
} = this.props;
|
|
102
|
+
this.options = _column.data && (_column.data.options || []);
|
|
103
|
+
}
|
|
104
|
+
componentDidMount() {
|
|
105
|
+
document.addEventListener('click', this.onDocumentToggle);
|
|
106
|
+
}
|
|
107
|
+
componentWillUnmount() {
|
|
108
|
+
document.removeEventListener('click', this.onDocumentToggle);
|
|
109
|
+
}
|
|
110
|
+
render() {
|
|
111
|
+
let {
|
|
112
|
+
isPopoverShow,
|
|
113
|
+
popoverPosition
|
|
114
|
+
} = this.state;
|
|
115
|
+
let option = this.formatOption();
|
|
116
|
+
let options = this.options;
|
|
117
|
+
let selectedOptions = option ? [option] : [];
|
|
118
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
119
|
+
ref: this.setEditorContainerRef,
|
|
120
|
+
className: "dtable-ui-single-select-editor"
|
|
121
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
ref: this.setEditorRef,
|
|
123
|
+
className: option ? '' : 'd-inline-block',
|
|
124
|
+
onClick: this.onAddOptionToggle
|
|
125
|
+
}, option ? /*#__PURE__*/React.createElement("div", {
|
|
126
|
+
className: "dtable-ui-single-select-option-container"
|
|
127
|
+
}, /*#__PURE__*/React.createElement(SelectEditorOption, {
|
|
128
|
+
option: option
|
|
129
|
+
})) : /*#__PURE__*/React.createElement(EditEditorButton, {
|
|
130
|
+
text: getLocale('Add_an_option')
|
|
131
|
+
})), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
|
|
132
|
+
query: "(min-width: 768px)"
|
|
133
|
+
}, /*#__PURE__*/React.createElement(PCSelectEditorPopover, {
|
|
134
|
+
popoverPosition: popoverPosition,
|
|
135
|
+
options: options,
|
|
136
|
+
selectedOptions: selectedOptions,
|
|
137
|
+
onOptionItemToggle: this.onOptionItemToggle,
|
|
138
|
+
isSupportNewOption: this.props.isSupportNewOption,
|
|
139
|
+
onAddNewOption: this.onAddNewOption
|
|
140
|
+
})), /*#__PURE__*/React.createElement(MediaQuery, {
|
|
141
|
+
query: "(max-width: 767.8px)"
|
|
142
|
+
}, /*#__PURE__*/React.createElement(MBSelectEditorPopover, {
|
|
143
|
+
isReadOnly: this.props.isReadOnly,
|
|
144
|
+
value: [this.state.newValue],
|
|
145
|
+
column: this.props.column,
|
|
146
|
+
options: options,
|
|
147
|
+
onOptionItemToggle: this.onOptionItemToggle,
|
|
148
|
+
isShowRemoveIcon: true,
|
|
149
|
+
isSupportNewOption: this.props.isSupportNewOption,
|
|
150
|
+
onAddNewOption: this.onAddNewOption,
|
|
151
|
+
onClosePopover: this.onClosePopover
|
|
152
|
+
}))));
|
|
107
153
|
}
|
|
108
|
-
|
|
109
|
-
key: "componentDidMount",
|
|
110
|
-
value: function componentDidMount() {
|
|
111
|
-
document.addEventListener('click', this.onDocumentToggle);
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "componentWillUnmount",
|
|
115
|
-
value: function componentWillUnmount() {
|
|
116
|
-
document.removeEventListener('click', this.onDocumentToggle);
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "render",
|
|
120
|
-
value: function render() {
|
|
121
|
-
var _this$state = this.state,
|
|
122
|
-
isPopoverShow = _this$state.isPopoverShow,
|
|
123
|
-
popoverPosition = _this$state.popoverPosition;
|
|
124
|
-
var option = this.formatOption();
|
|
125
|
-
var options = this.options;
|
|
126
|
-
var selectedOptions = option ? [option] : [];
|
|
127
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
128
|
-
ref: this.setEditorContainerRef,
|
|
129
|
-
className: "dtable-ui-single-select-editor"
|
|
130
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
131
|
-
ref: this.setEditorRef,
|
|
132
|
-
className: option ? '' : 'd-inline-block',
|
|
133
|
-
onClick: this.onAddOptionToggle
|
|
134
|
-
}, option ? /*#__PURE__*/React.createElement("div", {
|
|
135
|
-
className: "dtable-ui-single-select-option-container"
|
|
136
|
-
}, /*#__PURE__*/React.createElement(SelectEditorOption, {
|
|
137
|
-
option: option
|
|
138
|
-
})) : /*#__PURE__*/React.createElement(EditEditorButton, {
|
|
139
|
-
text: getLocale('Add_an_option')
|
|
140
|
-
})), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
|
|
141
|
-
query: "(min-width: 768px)"
|
|
142
|
-
}, /*#__PURE__*/React.createElement(PCSelectEditorPopover, {
|
|
143
|
-
popoverPosition: popoverPosition,
|
|
144
|
-
options: options,
|
|
145
|
-
selectedOptions: selectedOptions,
|
|
146
|
-
onOptionItemToggle: this.onOptionItemToggle,
|
|
147
|
-
isSupportNewOption: this.props.isSupportNewOption,
|
|
148
|
-
onAddNewOption: this.onAddNewOption
|
|
149
|
-
})), /*#__PURE__*/React.createElement(MediaQuery, {
|
|
150
|
-
query: "(max-width: 767.8px)"
|
|
151
|
-
}, /*#__PURE__*/React.createElement(MBSelectEditorPopover, {
|
|
152
|
-
isReadOnly: this.props.isReadOnly,
|
|
153
|
-
value: [this.state.newValue],
|
|
154
|
-
column: this.props.column,
|
|
155
|
-
options: options,
|
|
156
|
-
onOptionItemToggle: this.onOptionItemToggle,
|
|
157
|
-
isShowRemoveIcon: true,
|
|
158
|
-
isSupportNewOption: this.props.isSupportNewOption,
|
|
159
|
-
onAddNewOption: this.onAddNewOption,
|
|
160
|
-
onClosePopover: this.onClosePopover
|
|
161
|
-
}))));
|
|
162
|
-
}
|
|
163
|
-
}]);
|
|
164
|
-
return SingleSelectEditor;
|
|
165
|
-
}(React.Component);
|
|
154
|
+
}
|
|
166
155
|
SingleSelectEditor.defaultProps = {
|
|
167
156
|
isReadOnly: false,
|
|
168
157
|
value: ''
|
|
@@ -1,29 +1,17 @@
|
|
|
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
1
|
import React from 'react';
|
|
6
2
|
import classnames from 'classnames';
|
|
7
3
|
import SelectItem from '../SelectItem';
|
|
8
4
|
import './index.css';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_this.getOption = function () {
|
|
20
|
-
var _this$props = _this.props,
|
|
21
|
-
value = _this$props.value,
|
|
22
|
-
options = _this$props.options,
|
|
23
|
-
fontSize = _this$props.fontSize;
|
|
24
|
-
var option = options.find(function (item) {
|
|
25
|
-
return item.id === value || item.name === value;
|
|
26
|
-
});
|
|
5
|
+
class SingleSelectFormatter extends React.PureComponent {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.getOption = () => {
|
|
9
|
+
let {
|
|
10
|
+
value,
|
|
11
|
+
options,
|
|
12
|
+
fontSize
|
|
13
|
+
} = this.props;
|
|
14
|
+
let option = options.find(item => item.id === value || item.name === value);
|
|
27
15
|
if (option) {
|
|
28
16
|
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
29
17
|
option: option,
|
|
@@ -31,22 +19,18 @@ var SingleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
31
19
|
});
|
|
32
20
|
}
|
|
33
21
|
};
|
|
34
|
-
return _this;
|
|
35
22
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}]);
|
|
48
|
-
return SingleSelectFormatter;
|
|
49
|
-
}(React.PureComponent);
|
|
23
|
+
render() {
|
|
24
|
+
const {
|
|
25
|
+
containerClassName,
|
|
26
|
+
value
|
|
27
|
+
} = this.props;
|
|
28
|
+
let classname = classnames('dtable-ui cell-formatter-container single-select-formatter', containerClassName);
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: classname
|
|
31
|
+
}, value ? this.getOption() : '');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
50
34
|
SingleSelectFormatter.defaultProps = {
|
|
51
35
|
options: []
|
|
52
36
|
};
|
package/lib/TextEditor/index.js
CHANGED
|
@@ -1,38 +1,35 @@
|
|
|
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
1
|
import React from 'react';
|
|
6
2
|
import isHotkey from 'is-hotkey';
|
|
7
3
|
import { Input } from 'reactstrap';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
class TextEditor extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.onCommit = () => {
|
|
8
|
+
let updated = {};
|
|
9
|
+
let {
|
|
10
|
+
column
|
|
11
|
+
} = this.props;
|
|
12
|
+
let {
|
|
13
|
+
newValue
|
|
14
|
+
} = this.state;
|
|
19
15
|
updated[column.name] = newValue ? newValue.trim() : '';
|
|
20
|
-
|
|
16
|
+
this.props.onCommit(updated);
|
|
21
17
|
};
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
this.onBlur = () => {
|
|
19
|
+
this.onCommit();
|
|
24
20
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
this.onChange = event => {
|
|
22
|
+
let value = event.target.value;
|
|
23
|
+
this.setState({
|
|
28
24
|
newValue: value
|
|
29
25
|
});
|
|
30
26
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
selectionStart
|
|
34
|
-
selectionEnd
|
|
35
|
-
value
|
|
27
|
+
this.onKeyDown = event => {
|
|
28
|
+
let {
|
|
29
|
+
selectionStart,
|
|
30
|
+
selectionEnd,
|
|
31
|
+
value
|
|
32
|
+
} = event.currentTarget;
|
|
36
33
|
if (isHotkey('enter', event)) {
|
|
37
34
|
event.preventDefault();
|
|
38
35
|
event.target.blur();
|
|
@@ -40,39 +37,36 @@ var TextEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
40
37
|
event.stopPropagation();
|
|
41
38
|
}
|
|
42
39
|
};
|
|
43
|
-
|
|
40
|
+
this.onPaste = e => {
|
|
44
41
|
e.stopPropagation();
|
|
45
42
|
};
|
|
46
|
-
|
|
43
|
+
this.onCut = e => {
|
|
47
44
|
e.stopPropagation();
|
|
48
45
|
};
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
this.setInputRef = input => {
|
|
47
|
+
this.input = input;
|
|
51
48
|
};
|
|
52
|
-
|
|
49
|
+
this.state = {
|
|
53
50
|
newValue: props.value
|
|
54
51
|
};
|
|
55
|
-
return _this;
|
|
56
52
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return TextEditor;
|
|
75
|
-
}(React.Component);
|
|
53
|
+
render() {
|
|
54
|
+
const {
|
|
55
|
+
isReadOnly
|
|
56
|
+
} = this.props;
|
|
57
|
+
return /*#__PURE__*/React.createElement(Input, {
|
|
58
|
+
ref: this.setInputRef,
|
|
59
|
+
type: "text",
|
|
60
|
+
value: this.state.newValue,
|
|
61
|
+
readOnly: isReadOnly,
|
|
62
|
+
onChange: this.onChange,
|
|
63
|
+
onKeyDown: this.onKeyDown,
|
|
64
|
+
onBlur: this.onBlur,
|
|
65
|
+
onCut: this.onCut,
|
|
66
|
+
onPaste: this.onPaste
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
76
70
|
TextEditor.defaultProps = {
|
|
77
71
|
isReadOnly: false,
|
|
78
72
|
value: ''
|
|
@@ -1,21 +1,10 @@
|
|
|
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
1
|
import React from 'react';
|
|
6
2
|
import classnames from 'classnames';
|
|
7
3
|
import './index.css';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _this;
|
|
13
|
-
_classCallCheck(this, TextFormatter);
|
|
14
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
-
args[_key] = arguments[_key];
|
|
16
|
-
}
|
|
17
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
18
|
-
_this.getFormattedValue = function (val) {
|
|
4
|
+
class TextFormatter extends React.Component {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.getFormattedValue = val => {
|
|
19
8
|
if (typeof val === 'object') {
|
|
20
9
|
return null;
|
|
21
10
|
}
|
|
@@ -24,22 +13,18 @@ var TextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
24
13
|
}
|
|
25
14
|
return val;
|
|
26
15
|
};
|
|
27
|
-
return _this;
|
|
28
16
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}]);
|
|
43
|
-
return TextFormatter;
|
|
44
|
-
}(React.Component);
|
|
17
|
+
render() {
|
|
18
|
+
const {
|
|
19
|
+
containerClassName,
|
|
20
|
+
value
|
|
21
|
+
} = this.props;
|
|
22
|
+
const classname = classnames('dtable-ui cell-formatter-container text-formatter', containerClassName);
|
|
23
|
+
const formattedValue = this.getFormattedValue(value);
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: classname,
|
|
26
|
+
title: formattedValue
|
|
27
|
+
}, formattedValue);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
45
30
|
export default TextFormatter;
|
|
@@ -1,29 +1,16 @@
|
|
|
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
1
|
import React from 'react';
|
|
6
2
|
import classnames from 'classnames';
|
|
7
3
|
import './index.css';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
class UrlFormatter extends React.Component {
|
|
5
|
+
render() {
|
|
6
|
+
const {
|
|
7
|
+
containerClassName,
|
|
8
|
+
value
|
|
9
|
+
} = this.props;
|
|
10
|
+
let classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: classname
|
|
13
|
+
}, value);
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
key: "render",
|
|
17
|
-
value: function render() {
|
|
18
|
-
var _this$props = this.props,
|
|
19
|
-
containerClassName = _this$props.containerClassName,
|
|
20
|
-
value = _this$props.value;
|
|
21
|
-
var classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
|
|
22
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
-
className: classname
|
|
24
|
-
}, value);
|
|
25
|
-
}
|
|
26
|
-
}]);
|
|
27
|
-
return UrlFormatter;
|
|
28
|
-
}(React.Component);
|
|
15
|
+
}
|
|
29
16
|
export default UrlFormatter;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
1
|
import FormatterConfig from '../formatterConfig';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
_createClass(CellFormatterFactory, [{
|
|
9
|
-
key: "createFormatter",
|
|
10
|
-
value: function createFormatter(formatterType) {
|
|
11
|
-
if (FormatterConfig[formatterType]) {
|
|
12
|
-
return FormatterConfig[formatterType];
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
2
|
+
class CellFormatterFactory {
|
|
3
|
+
createFormatter(formatterType) {
|
|
4
|
+
if (FormatterConfig[formatterType]) {
|
|
5
|
+
return FormatterConfig[formatterType];
|
|
15
6
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const cellFormatterFactory = new CellFormatterFactory();
|
|
20
11
|
export default cellFormatterFactory;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export default class ClickOutside extends React.Component {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.isClickedInside = false;
|
|
6
|
+
this.handleDocumentClick = e => {
|
|
7
|
+
if (this.isClickedInside) {
|
|
8
|
+
this.isClickedInside = false;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
this.props.onClickOutside(e);
|
|
12
|
+
};
|
|
13
|
+
this.handleMouseDown = () => {
|
|
14
|
+
this.isClickedInside = true;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
componentDidMount() {
|
|
18
|
+
document.addEventListener('mousedown', this.handleDocumentClick);
|
|
19
|
+
}
|
|
20
|
+
componentWillUnmount() {
|
|
21
|
+
document.removeEventListener('mousedown', this.handleDocumentClick);
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return React.cloneElement(React.Children.only(this.props.children), {
|
|
25
|
+
onMouseDownCapture: this.handleMouseDown
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|