dtable-ui-component 0.1.75-beta → 0.1.75-beta1
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/app.css +20 -0
- package/lib/app.js +96 -0
- package/lib/assets/images/avatar/default_avatar.png +0 -0
- package/lib/assets/images/file/192/excel.png +0 -0
- package/lib/assets/images/file/192/file.png +0 -0
- package/lib/assets/images/file/192/music.png +0 -0
- package/lib/assets/images/file/192/pdf.png +0 -0
- package/lib/assets/images/file/192/pic.png +0 -0
- package/lib/assets/images/file/192/ppt.png +0 -0
- package/lib/assets/images/file/192/txt.png +0 -0
- package/lib/assets/images/file/192/video.png +0 -0
- package/lib/assets/images/file/192/word.png +0 -0
- package/lib/assets/images/file/24/excel.png +0 -0
- package/lib/assets/images/file/24/file.png +0 -0
- package/lib/assets/images/file/24/music.png +0 -0
- package/lib/assets/images/file/24/pdf.png +0 -0
- package/lib/assets/images/file/24/pic.png +0 -0
- package/lib/assets/images/file/24/ppt.png +0 -0
- package/lib/assets/images/file/24/txt.png +0 -0
- package/lib/assets/images/file/24/video.png +0 -0
- package/lib/assets/images/file/24/word.png +0 -0
- package/lib/assets/images/folder/folder-192.png +0 -0
- package/lib/assets/images/folder/folder-24.png +0 -0
- package/lib/components/cell-editor/checkbox-editor.js +111 -0
- package/lib/components/cell-editor/collaborator-editor.js +249 -0
- package/lib/components/cell-editor/date-editor.js +171 -0
- package/lib/components/cell-editor/index.js +40 -0
- package/lib/components/cell-editor/link-editor.js +321 -0
- package/lib/components/cell-editor/multiple-select-editor.js +250 -0
- package/lib/components/cell-editor/number-editor.js +162 -0
- package/lib/components/cell-editor/single-select-editor.js +216 -0
- package/lib/components/cell-editor/text-editor.js +129 -0
- package/lib/components/cell-editor-dialog/pc-file-editor-dialog.js +66 -0
- package/lib/components/cell-editor-dialog/pc-files-addition/index.js +1 -0
- package/lib/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +1 -0
- package/lib/components/cell-editor-dialog/pc-files-preview/index.js +1 -0
- package/lib/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +1 -0
- package/lib/components/cell-editor-popover/mb-collaborator-editor-popover.js +183 -0
- package/lib/components/cell-editor-popover/mb-date-editor-popover.js +262 -0
- package/lib/components/cell-editor-popover/mb-link-editor-popover.js +176 -0
- package/lib/components/cell-editor-popover/mb-select-editor-popover.js +243 -0
- package/lib/components/cell-editor-popover/pc-collaborator-editor-popover.js +124 -0
- package/lib/components/cell-editor-popover/pc-date-editor-popover.js +156 -0
- package/lib/components/cell-editor-popover/pc-link-editor-popover.js +128 -0
- package/lib/components/cell-editor-popover/pc-select-editor-popover.js +157 -0
- package/lib/components/cell-factory/cell-formatter-factory.js +28 -0
- package/lib/components/cell-formatter/auto-number-formatter.js +45 -0
- package/lib/components/cell-formatter/button-formatter.js +66 -0
- package/lib/components/cell-formatter/checkbox-formatter.js +56 -0
- package/lib/components/cell-formatter/collaborator-formatter.js +111 -0
- package/lib/components/cell-formatter/creator-formatter.js +105 -0
- package/lib/components/cell-formatter/ctime-formatter.js +70 -0
- package/lib/components/cell-formatter/date-formatter.js +73 -0
- package/lib/components/cell-formatter/duration-formatter.js +49 -0
- package/lib/components/cell-formatter/email-formatter.js +45 -0
- package/lib/components/cell-formatter/file-formatter.js +77 -0
- package/lib/components/cell-formatter/formatter-config.js +66 -0
- package/lib/components/cell-formatter/formula-formatter.js +189 -0
- package/lib/components/cell-formatter/geolocation-formatter.js +66 -0
- package/lib/components/cell-formatter/image-formatter.js +171 -0
- package/lib/components/cell-formatter/index.js +112 -0
- package/lib/components/cell-formatter/last-modifier-formatter.js +105 -0
- package/lib/components/cell-formatter/link-formatter.js +165 -0
- package/lib/components/cell-formatter/long-text-formatter.js +46 -0
- package/lib/components/cell-formatter/mtime-formatter.js +70 -0
- package/lib/components/cell-formatter/multiple-select-formatter.js +84 -0
- package/lib/components/cell-formatter/number-formatter.js +60 -0
- package/lib/components/cell-formatter/rate-formatter.js +93 -0
- package/lib/components/cell-formatter/single-select-formatter.js +84 -0
- package/lib/components/cell-formatter/text-formatter.js +67 -0
- package/lib/components/cell-formatter/url-formatter.js +45 -0
- package/lib/components/cell-formatter/widgets/file-item-formatter.js +63 -0
- package/lib/components/cell-formatter/widgets/image-previewer-lightbox.js +152 -0
- package/lib/components/cell-formatter/widgets/long-text-formatter/html-long-text-formatter.js +107 -0
- package/lib/components/cell-formatter/widgets/long-text-formatter/simple-long-text-formatter.js +110 -0
- package/lib/components/common/collaborator-item.js +79 -0
- package/lib/components/common/edit-editor-button.js +67 -0
- package/lib/components/common/images-lazy-load.js +158 -0
- package/lib/components/common/link-editor-option.js +121 -0
- package/lib/components/common/mobile/mb-editor-header.js +61 -0
- package/lib/components/common/modal-portal.js +51 -0
- package/lib/components/common/select-editor-option.js +122 -0
- package/lib/components/common/select-item.js +73 -0
- package/lib/components/file-uploader/index.js +63 -0
- package/lib/components/loading.js +16 -0
- package/lib/components/toast/alert.js +164 -0
- package/lib/components/toast/index.js +12 -0
- package/lib/components/toast/toast.js +223 -0
- package/lib/components/toast/toastManager.js +189 -0
- package/lib/components/toast/toaster.js +92 -0
- package/lib/constants/cell-types.js +54 -0
- package/lib/constants/index.js +70 -0
- package/lib/css/cell-editor.css +614 -0
- package/lib/css/cell-formatter.css +247 -0
- package/lib/css/custom-rc-calendar.css +118 -0
- package/lib/css/image-previewer-ligntbox.css +87 -0
- package/lib/css/loading.css +54 -0
- package/lib/index.js +64 -0
- package/lib/lang/index.js +66 -0
- package/lib/locals/de.js +7 -0
- package/lib/locals/en.js +22 -0
- package/lib/locals/fr.js +7 -0
- package/lib/locals/zh-CN.js +22 -0
- package/lib/utils/cell-value-validator.js +41 -0
- package/lib/utils/column-utils.js +15 -0
- package/lib/utils/editor-utils.js +81 -0
- package/lib/utils/markdown2html.js +68 -0
- package/lib/utils/normalize-long-text-value.js +74 -0
- package/lib/utils/number-precision.js +181 -0
- package/lib/utils/unified/index.js +470 -0
- package/lib/utils/utils.js +141 -0
- package/lib/utils/value-format-utils.js +545 -0
- package/lib/utils/vfile/core.js +172 -0
- package/lib/utils/vfile/index.js +48 -0
- package/package.json +3 -3
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
9
|
+
|
|
10
|
+
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
|
|
18
|
+
var _reactResponsive = _interopRequireDefault(require("react-responsive"));
|
|
19
|
+
|
|
20
|
+
var _lang = require("../../lang");
|
|
21
|
+
|
|
22
|
+
var _editEditorButton = _interopRequireDefault(require("../common/edit-editor-button"));
|
|
23
|
+
|
|
24
|
+
var _selectEditorOption = _interopRequireDefault(require("../common/select-editor-option"));
|
|
25
|
+
|
|
26
|
+
var _pcSelectEditorPopover = _interopRequireDefault(require("../cell-editor-popover/pc-select-editor-popover"));
|
|
27
|
+
|
|
28
|
+
var _mbSelectEditorPopover = _interopRequireDefault(require("../cell-editor-popover/mb-select-editor-popover"));
|
|
29
|
+
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
34
|
+
var propTypes = {
|
|
35
|
+
isReadOnly: _propTypes.default.bool,
|
|
36
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.array]),
|
|
37
|
+
column: _propTypes.default.object,
|
|
38
|
+
onCommit: _propTypes.default.func,
|
|
39
|
+
isSupportNewOption: _propTypes.default.bool,
|
|
40
|
+
onAddNewOption: _propTypes.default.func
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var MultipleSelectEditor = /*#__PURE__*/function (_React$Component) {
|
|
44
|
+
(0, _inheritsLoose2.default)(MultipleSelectEditor, _React$Component);
|
|
45
|
+
|
|
46
|
+
function MultipleSelectEditor(props) {
|
|
47
|
+
var _this;
|
|
48
|
+
|
|
49
|
+
_this = _React$Component.call(this, props) || this;
|
|
50
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDocumentToggle", function (e) {
|
|
51
|
+
if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
|
|
52
|
+
_this.onClosePopover();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getFormattedOptions", function () {
|
|
56
|
+
var newValue = _this.state.newValue;
|
|
57
|
+
|
|
58
|
+
if (Array.isArray(newValue) && newValue.length > 0) {
|
|
59
|
+
return newValue.map(function (option_id) {
|
|
60
|
+
return _this.options.find(function (option) {
|
|
61
|
+
return option.id === option_id;
|
|
62
|
+
});
|
|
63
|
+
}).filter(function (option) {
|
|
64
|
+
return !!option;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return [];
|
|
69
|
+
});
|
|
70
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onAddOptionToggle", function (event) {
|
|
71
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
72
|
+
event.stopPropagation();
|
|
73
|
+
|
|
74
|
+
if (_this.props.isReadOnly) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var isPopoverShow = !_this.state.isPopoverShow;
|
|
79
|
+
|
|
80
|
+
if (isPopoverShow) {
|
|
81
|
+
var popoverPosition = _this.caculatePopoverPosition();
|
|
82
|
+
|
|
83
|
+
_this.setState({
|
|
84
|
+
isPopoverShow: isPopoverShow,
|
|
85
|
+
popoverPosition: popoverPosition
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
_this.setState({
|
|
89
|
+
isPopoverShow: isPopoverShow
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCommit", function (newValue) {
|
|
94
|
+
var updated = {};
|
|
95
|
+
var column = _this.props.column;
|
|
96
|
+
updated[column.key] = newValue;
|
|
97
|
+
|
|
98
|
+
_this.props.onCommit(updated);
|
|
99
|
+
});
|
|
100
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onOptionItemToggle", function (option) {
|
|
101
|
+
var newValue = _this.state.newValue.slice();
|
|
102
|
+
|
|
103
|
+
var optionIndex = newValue.findIndex(function (option_id) {
|
|
104
|
+
return option_id === option.id;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (optionIndex !== -1) {
|
|
108
|
+
newValue.splice(optionIndex, 1);
|
|
109
|
+
} else {
|
|
110
|
+
newValue.push(option.id);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_this.setState({
|
|
114
|
+
newValue: newValue
|
|
115
|
+
}, function () {
|
|
116
|
+
_this.onCommit(newValue);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDeleteOption", function (option) {
|
|
120
|
+
var newValue = _this.state.newValue.slice();
|
|
121
|
+
|
|
122
|
+
var optionIndex = newValue.findIndex(function (option_id) {
|
|
123
|
+
return option_id === option.id;
|
|
124
|
+
});
|
|
125
|
+
newValue.splice(optionIndex, 1);
|
|
126
|
+
|
|
127
|
+
_this.setState({
|
|
128
|
+
newValue: newValue
|
|
129
|
+
}, function () {
|
|
130
|
+
_this.onCommit(newValue);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onAddNewOption", function (optionName) {
|
|
134
|
+
_this.props.onAddNewOption(optionName);
|
|
135
|
+
|
|
136
|
+
_this.onClosePopover();
|
|
137
|
+
});
|
|
138
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "caculatePopoverPosition", function () {
|
|
139
|
+
var POPOVER_MAX_HEIGHT = 200;
|
|
140
|
+
var innerHeight = window.innerHeight;
|
|
141
|
+
|
|
142
|
+
var _this$editor$getClien = _this.editor.getClientRects()[0],
|
|
143
|
+
top = _this$editor$getClien.top,
|
|
144
|
+
height = _this$editor$getClien.height;
|
|
145
|
+
|
|
146
|
+
var isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
|
|
147
|
+
var position = {
|
|
148
|
+
top: height + 1,
|
|
149
|
+
left: 0
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
if (!isBelow) {
|
|
153
|
+
var bottom = height + 1;
|
|
154
|
+
position = {
|
|
155
|
+
bottom: bottom,
|
|
156
|
+
left: 0
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return position;
|
|
161
|
+
});
|
|
162
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClosePopover", function () {
|
|
163
|
+
_this.setState({
|
|
164
|
+
isPopoverShow: false
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setEditorContainerRef", function (editorContainer) {
|
|
168
|
+
_this.editorContainer = editorContainer;
|
|
169
|
+
});
|
|
170
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setEditorRef", function (editor) {
|
|
171
|
+
_this.editor = editor;
|
|
172
|
+
});
|
|
173
|
+
_this.state = {
|
|
174
|
+
newValue: Array.isArray(props.value) ? props.value : [],
|
|
175
|
+
isPopoverShow: false,
|
|
176
|
+
popoverPosition: {}
|
|
177
|
+
};
|
|
178
|
+
var _column = _this.props.column;
|
|
179
|
+
_this.options = _column.data && (_column.data.options || []);
|
|
180
|
+
return _this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
var _proto = MultipleSelectEditor.prototype;
|
|
184
|
+
|
|
185
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
186
|
+
document.addEventListener('click', this.onDocumentToggle);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
190
|
+
document.removeEventListener('click', this.onDocumentToggle);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
_proto.render = function render() {
|
|
194
|
+
var _this2 = this;
|
|
195
|
+
|
|
196
|
+
var _this$state = this.state,
|
|
197
|
+
isPopoverShow = _this$state.isPopoverShow,
|
|
198
|
+
popoverPosition = _this$state.popoverPosition;
|
|
199
|
+
var options = this.options;
|
|
200
|
+
var selectedOptions = this.getFormattedOptions();
|
|
201
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
202
|
+
ref: this.setEditorContainerRef,
|
|
203
|
+
className: "cell-editor dtable-ui-multiple-select-editor"
|
|
204
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
205
|
+
ref: this.setEditorRef,
|
|
206
|
+
className: "dtable-ui-select-editor-container",
|
|
207
|
+
onClick: this.onAddOptionToggle
|
|
208
|
+
}, selectedOptions.length === 0 && /*#__PURE__*/_react.default.createElement(_editEditorButton.default, {
|
|
209
|
+
text: (0, _lang.getLocale)('Add_an_option')
|
|
210
|
+
}), selectedOptions.length !== 0 && selectedOptions.map(function (option) {
|
|
211
|
+
return /*#__PURE__*/_react.default.createElement(_selectEditorOption.default, {
|
|
212
|
+
key: option.id,
|
|
213
|
+
option: option,
|
|
214
|
+
isShowRemoveIcon: true,
|
|
215
|
+
onDeleteSelectOption: _this2.onDeleteOption
|
|
216
|
+
});
|
|
217
|
+
})), isPopoverShow && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactResponsive.default, {
|
|
218
|
+
query: "(min-width: 768px)"
|
|
219
|
+
}, /*#__PURE__*/_react.default.createElement(_pcSelectEditorPopover.default, {
|
|
220
|
+
popoverPosition: popoverPosition,
|
|
221
|
+
options: options,
|
|
222
|
+
selectedOptions: selectedOptions,
|
|
223
|
+
onOptionItemToggle: this.onOptionItemToggle,
|
|
224
|
+
isSupportNewOption: this.props.isSupportNewOption,
|
|
225
|
+
onAddNewOption: this.onAddNewOption
|
|
226
|
+
})), /*#__PURE__*/_react.default.createElement(_reactResponsive.default, {
|
|
227
|
+
query: "(max-width: 767.8px)"
|
|
228
|
+
}, /*#__PURE__*/_react.default.createElement(_mbSelectEditorPopover.default, {
|
|
229
|
+
isReadOnly: this.props.isReadOnly,
|
|
230
|
+
value: this.state.newValue,
|
|
231
|
+
column: this.props.column,
|
|
232
|
+
options: options,
|
|
233
|
+
onOptionItemToggle: this.onOptionItemToggle,
|
|
234
|
+
isShowRemoveIcon: true,
|
|
235
|
+
isSupportNewOption: this.props.isSupportNewOption,
|
|
236
|
+
onAddNewOption: this.onAddNewOption,
|
|
237
|
+
onClosePopover: this.onClosePopover
|
|
238
|
+
}))));
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
return MultipleSelectEditor;
|
|
242
|
+
}(_react.default.Component);
|
|
243
|
+
|
|
244
|
+
(0, _defineProperty2.default)(MultipleSelectEditor, "defaultProps", {
|
|
245
|
+
isReadOnly: false,
|
|
246
|
+
value: []
|
|
247
|
+
});
|
|
248
|
+
MultipleSelectEditor.propTypes = propTypes;
|
|
249
|
+
var _default = MultipleSelectEditor;
|
|
250
|
+
exports.default = _default;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
9
|
+
|
|
10
|
+
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
|
|
18
|
+
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
19
|
+
|
|
20
|
+
var _constants = require("../../constants");
|
|
21
|
+
|
|
22
|
+
var _valueFormatUtils = require("../../utils/value-format-utils");
|
|
23
|
+
|
|
24
|
+
var propTypes = {
|
|
25
|
+
isReadOnly: _propTypes.default.bool,
|
|
26
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
27
|
+
column: _propTypes.default.object,
|
|
28
|
+
onCommit: _propTypes.default.func
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
var NumberEditor = /*#__PURE__*/function (_React$Component) {
|
|
32
|
+
(0, _inheritsLoose2.default)(NumberEditor, _React$Component);
|
|
33
|
+
|
|
34
|
+
function NumberEditor(props) {
|
|
35
|
+
var _this;
|
|
36
|
+
|
|
37
|
+
_this = _React$Component.call(this, props) || this;
|
|
38
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onEditorHandle", function () {
|
|
39
|
+
if (_this.props.isReadOnly) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_this.setState({
|
|
44
|
+
isEditorShow: true,
|
|
45
|
+
inputValue: _this.state.textValue
|
|
46
|
+
}, function () {
|
|
47
|
+
_this.input.focus();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCommit", function () {
|
|
51
|
+
var updated = {};
|
|
52
|
+
var column = _this.props.column;
|
|
53
|
+
var inputValue = _this.state.inputValue ? _this.state.inputValue.toString() : '';
|
|
54
|
+
var value = inputValue ? (0, _valueFormatUtils.formatStringToNumber)(inputValue) : ''; // format the number to submit
|
|
55
|
+
|
|
56
|
+
updated[column.key] = value;
|
|
57
|
+
|
|
58
|
+
_this.props.onCommit(updated);
|
|
59
|
+
|
|
60
|
+
var newValue = (0, _valueFormatUtils.getNumberDisplayString)(value, column.data); // format the number to display
|
|
61
|
+
|
|
62
|
+
_this.setState({
|
|
63
|
+
isEditorShow: false,
|
|
64
|
+
textValue: newValue
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onChange", function (event) {
|
|
68
|
+
var value = event.target.value.trim();
|
|
69
|
+
value = (0, _valueFormatUtils.formatNumberString)(value, _this.dataFormat); // format the number in changing
|
|
70
|
+
|
|
71
|
+
if (value === _this.state.inputValue) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_this.setState({
|
|
76
|
+
inputValue: value
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBlur", function () {
|
|
80
|
+
_this.onCommit();
|
|
81
|
+
});
|
|
82
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onKeyDown", function (event) {
|
|
83
|
+
var _event$currentTarget = event.currentTarget,
|
|
84
|
+
selectionStart = _event$currentTarget.selectionStart,
|
|
85
|
+
selectionEnd = _event$currentTarget.selectionEnd,
|
|
86
|
+
value = _event$currentTarget.value;
|
|
87
|
+
|
|
88
|
+
if ((0, _isHotkey.default)('enter', event)) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
|
|
91
|
+
_this.onBlur();
|
|
92
|
+
} else if (event.keyCode === 37 && selectionStart === 0 || event.keyCode === 39 && selectionEnd === value.length) {
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPaste", function (e) {
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
});
|
|
99
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCut", function (e) {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
});
|
|
102
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getStyle", function () {
|
|
103
|
+
return {
|
|
104
|
+
width: '320px',
|
|
105
|
+
textAlign: 'left'
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setInputRef", function (input) {
|
|
109
|
+
_this.input = input;
|
|
110
|
+
return _this.input;
|
|
111
|
+
});
|
|
112
|
+
var _this$props = _this.props,
|
|
113
|
+
_value = _this$props.value,
|
|
114
|
+
_column = _this$props.column;
|
|
115
|
+
var dataFormat = _column.data && _column.data.format;
|
|
116
|
+
_this.dataFormat = dataFormat || _constants.NUMBER_TYPES.NUMBER;
|
|
117
|
+
var initValue = (0, _valueFormatUtils.getNumberDisplayString)(_value, _column.data); // format the number to display
|
|
118
|
+
|
|
119
|
+
_this.state = {
|
|
120
|
+
inputValue: initValue,
|
|
121
|
+
textValue: initValue,
|
|
122
|
+
isEditorShow: false
|
|
123
|
+
};
|
|
124
|
+
return _this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
var _proto = NumberEditor.prototype;
|
|
128
|
+
|
|
129
|
+
_proto.render = function render() {
|
|
130
|
+
var style = this.getStyle();
|
|
131
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
132
|
+
className: "cell-editor number-editor"
|
|
133
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
134
|
+
className: "number-editor-container"
|
|
135
|
+
}, !this.state.isEditorShow && /*#__PURE__*/_react.default.createElement("div", {
|
|
136
|
+
className: "form-control",
|
|
137
|
+
style: style,
|
|
138
|
+
onClick: this.onEditorHandle
|
|
139
|
+
}, this.state.textValue), this.state.isEditorShow && /*#__PURE__*/_react.default.createElement("input", {
|
|
140
|
+
ref: this.setInputRef,
|
|
141
|
+
type: "text",
|
|
142
|
+
className: "form-control",
|
|
143
|
+
style: style,
|
|
144
|
+
value: this.state.inputValue,
|
|
145
|
+
onChange: this.onChange,
|
|
146
|
+
onBlur: this.onBlur,
|
|
147
|
+
onCut: this.onCut,
|
|
148
|
+
onPaste: this.onPaste,
|
|
149
|
+
onKeyDown: this.onKeyDown
|
|
150
|
+
})));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return NumberEditor;
|
|
154
|
+
}(_react.default.Component);
|
|
155
|
+
|
|
156
|
+
(0, _defineProperty2.default)(NumberEditor, "defaultProps", {
|
|
157
|
+
isReadOnly: false,
|
|
158
|
+
value: ''
|
|
159
|
+
});
|
|
160
|
+
NumberEditor.propTypes = propTypes;
|
|
161
|
+
var _default = NumberEditor;
|
|
162
|
+
exports.default = _default;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
9
|
+
|
|
10
|
+
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
|
|
18
|
+
var _reactResponsive = _interopRequireDefault(require("react-responsive"));
|
|
19
|
+
|
|
20
|
+
var _lang = require("../../lang");
|
|
21
|
+
|
|
22
|
+
var _editEditorButton = _interopRequireDefault(require("../common/edit-editor-button"));
|
|
23
|
+
|
|
24
|
+
var _selectEditorOption = _interopRequireDefault(require("../common/select-editor-option"));
|
|
25
|
+
|
|
26
|
+
var _pcSelectEditorPopover = _interopRequireDefault(require("../cell-editor-popover/pc-select-editor-popover"));
|
|
27
|
+
|
|
28
|
+
var _mbSelectEditorPopover = _interopRequireDefault(require("../cell-editor-popover/mb-select-editor-popover"));
|
|
29
|
+
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
34
|
+
var propTypes = {
|
|
35
|
+
isReadOnly: _propTypes.default.bool,
|
|
36
|
+
value: _propTypes.default.string,
|
|
37
|
+
column: _propTypes.default.object,
|
|
38
|
+
onCommit: _propTypes.default.func,
|
|
39
|
+
isSupportNewOption: _propTypes.default.bool,
|
|
40
|
+
onAddNewOption: _propTypes.default.func
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var SingleSelectEditor = /*#__PURE__*/function (_React$Component) {
|
|
44
|
+
(0, _inheritsLoose2.default)(SingleSelectEditor, _React$Component);
|
|
45
|
+
|
|
46
|
+
function SingleSelectEditor(props) {
|
|
47
|
+
var _this;
|
|
48
|
+
|
|
49
|
+
_this = _React$Component.call(this, props) || this;
|
|
50
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDocumentToggle", function (e) {
|
|
51
|
+
if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
|
|
52
|
+
_this.onClosePopover();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "formatOption", function () {
|
|
56
|
+
var newValue = _this.state.newValue;
|
|
57
|
+
|
|
58
|
+
var option = _this.options.find(function (option) {
|
|
59
|
+
return option.id === newValue;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return option;
|
|
63
|
+
});
|
|
64
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onAddOptionToggle", function (event) {
|
|
65
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
66
|
+
event.stopPropagation();
|
|
67
|
+
|
|
68
|
+
if (_this.props.isReadOnly) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var isPopoverShow = !_this.state.isPopoverShow;
|
|
73
|
+
|
|
74
|
+
if (isPopoverShow) {
|
|
75
|
+
var popoverPosition = _this.caculatePopoverPosition();
|
|
76
|
+
|
|
77
|
+
_this.setState({
|
|
78
|
+
isPopoverShow: isPopoverShow,
|
|
79
|
+
popoverPosition: popoverPosition
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
_this.setState({
|
|
83
|
+
isPopoverShow: isPopoverShow
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCommit", function (newValue) {
|
|
88
|
+
var updated = {};
|
|
89
|
+
var column = _this.props.column;
|
|
90
|
+
updated[column.key] = newValue;
|
|
91
|
+
|
|
92
|
+
_this.props.onCommit(updated);
|
|
93
|
+
});
|
|
94
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onOptionItemToggle", function (option) {
|
|
95
|
+
var newValue = _this.state.newValue === option.id ? '' : option.id;
|
|
96
|
+
|
|
97
|
+
_this.setState({
|
|
98
|
+
newValue: newValue
|
|
99
|
+
}, function () {
|
|
100
|
+
_this.onCommit(newValue);
|
|
101
|
+
|
|
102
|
+
_this.onClosePopover();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "caculatePopoverPosition", function () {
|
|
106
|
+
var POPOVER_MAX_HEIGHT = 200;
|
|
107
|
+
var innerHeight = window.innerHeight;
|
|
108
|
+
|
|
109
|
+
var _this$editor$getClien = _this.editor.getClientRects()[0],
|
|
110
|
+
top = _this$editor$getClien.top,
|
|
111
|
+
height = _this$editor$getClien.height;
|
|
112
|
+
|
|
113
|
+
var isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
|
|
114
|
+
var position = {
|
|
115
|
+
top: height + 1,
|
|
116
|
+
left: 0
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if (!isBelow) {
|
|
120
|
+
var bottom = height + 1;
|
|
121
|
+
position = {
|
|
122
|
+
bottom: bottom,
|
|
123
|
+
left: 0
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return position;
|
|
128
|
+
});
|
|
129
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onAddNewOption", function (optionName) {
|
|
130
|
+
_this.props.onAddNewOption(optionName);
|
|
131
|
+
|
|
132
|
+
_this.onClosePopover();
|
|
133
|
+
});
|
|
134
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClosePopover", function () {
|
|
135
|
+
_this.setState({
|
|
136
|
+
isPopoverShow: false
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setEditorContainerRef", function (editorContainer) {
|
|
140
|
+
_this.editorContainer = editorContainer;
|
|
141
|
+
});
|
|
142
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setEditorRef", function (editor) {
|
|
143
|
+
_this.editor = editor;
|
|
144
|
+
});
|
|
145
|
+
_this.state = {
|
|
146
|
+
newValue: props.value,
|
|
147
|
+
isPopoverShow: false,
|
|
148
|
+
popoverPosition: {}
|
|
149
|
+
};
|
|
150
|
+
var _column = _this.props.column;
|
|
151
|
+
_this.options = _column.data && (_column.data.options || []);
|
|
152
|
+
return _this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
var _proto = SingleSelectEditor.prototype;
|
|
156
|
+
|
|
157
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
158
|
+
document.addEventListener('click', this.onDocumentToggle);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
162
|
+
document.removeEventListener('click', this.onDocumentToggle);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
_proto.render = function render() {
|
|
166
|
+
var _this$state = this.state,
|
|
167
|
+
isPopoverShow = _this$state.isPopoverShow,
|
|
168
|
+
popoverPosition = _this$state.popoverPosition;
|
|
169
|
+
var option = this.formatOption();
|
|
170
|
+
var options = this.options;
|
|
171
|
+
var selectedOptions = option ? [option] : [];
|
|
172
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
173
|
+
ref: this.setEditorContainerRef,
|
|
174
|
+
className: "cell-editor dtable-ui-single-select-editor"
|
|
175
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
176
|
+
ref: this.setEditorRef,
|
|
177
|
+
className: "dtable-ui-select-editor-container",
|
|
178
|
+
onClick: this.onAddOptionToggle
|
|
179
|
+
}, option ? /*#__PURE__*/_react.default.createElement(_selectEditorOption.default, {
|
|
180
|
+
option: option
|
|
181
|
+
}) : /*#__PURE__*/_react.default.createElement(_editEditorButton.default, {
|
|
182
|
+
text: (0, _lang.getLocale)('Add_an_option')
|
|
183
|
+
})), isPopoverShow && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactResponsive.default, {
|
|
184
|
+
query: "(min-width: 768px)"
|
|
185
|
+
}, /*#__PURE__*/_react.default.createElement(_pcSelectEditorPopover.default, {
|
|
186
|
+
popoverPosition: popoverPosition,
|
|
187
|
+
options: options,
|
|
188
|
+
selectedOptions: selectedOptions,
|
|
189
|
+
onOptionItemToggle: this.onOptionItemToggle,
|
|
190
|
+
isSupportNewOption: this.props.isSupportNewOption,
|
|
191
|
+
onAddNewOption: this.onAddNewOption
|
|
192
|
+
})), /*#__PURE__*/_react.default.createElement(_reactResponsive.default, {
|
|
193
|
+
query: "(max-width: 767.8px)"
|
|
194
|
+
}, /*#__PURE__*/_react.default.createElement(_mbSelectEditorPopover.default, {
|
|
195
|
+
isReadOnly: this.props.isReadOnly,
|
|
196
|
+
value: [this.state.newValue],
|
|
197
|
+
column: this.props.column,
|
|
198
|
+
options: options,
|
|
199
|
+
onOptionItemToggle: this.onOptionItemToggle,
|
|
200
|
+
isShowRemoveIcon: true,
|
|
201
|
+
isSupportNewOption: this.props.isSupportNewOption,
|
|
202
|
+
onAddNewOption: this.onAddNewOption,
|
|
203
|
+
onClosePopover: this.onClosePopover
|
|
204
|
+
}))));
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
return SingleSelectEditor;
|
|
208
|
+
}(_react.default.Component);
|
|
209
|
+
|
|
210
|
+
(0, _defineProperty2.default)(SingleSelectEditor, "defaultProps", {
|
|
211
|
+
isReadOnly: false,
|
|
212
|
+
value: ''
|
|
213
|
+
});
|
|
214
|
+
SingleSelectEditor.propTypes = propTypes;
|
|
215
|
+
var _default = SingleSelectEditor;
|
|
216
|
+
exports.default = _default;
|