dtable-ui-component 0.2.0 → 0.2.2
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/es/app.css +20 -0
- package/es/app.js +91 -0
- package/es/assets/images/avatar/default_avatar.png +0 -0
- package/es/assets/images/file/192/excel.png +0 -0
- package/es/assets/images/file/192/file.png +0 -0
- package/es/assets/images/file/192/music.png +0 -0
- package/es/assets/images/file/192/pdf.png +0 -0
- package/es/assets/images/file/192/pic.png +0 -0
- package/es/assets/images/file/192/ppt.png +0 -0
- package/es/assets/images/file/192/txt.png +0 -0
- package/es/assets/images/file/192/video.png +0 -0
- package/es/assets/images/file/192/word.png +0 -0
- package/es/assets/images/file/24/excel.png +0 -0
- package/es/assets/images/file/24/file.png +0 -0
- package/es/assets/images/file/24/music.png +0 -0
- package/es/assets/images/file/24/pdf.png +0 -0
- package/es/assets/images/file/24/pic.png +0 -0
- package/es/assets/images/file/24/ppt.png +0 -0
- package/es/assets/images/file/24/txt.png +0 -0
- package/es/assets/images/file/24/video.png +0 -0
- package/es/assets/images/file/24/word.png +0 -0
- package/es/assets/images/folder/folder-192.png +0 -0
- package/es/assets/images/folder/folder-24.png +0 -0
- package/es/components/cell-editor/checkbox-editor.js +104 -0
- package/es/components/cell-editor/collaborator-editor.js +236 -0
- package/es/components/cell-editor/date-editor.js +151 -0
- package/es/components/cell-editor/index.js +9 -0
- package/es/components/cell-editor/link-editor.js +303 -0
- package/es/components/cell-editor/multiple-select-editor.js +237 -0
- package/es/components/cell-editor/number-editor.js +154 -0
- package/es/components/cell-editor/single-select-editor.js +202 -0
- package/es/components/cell-editor/text-editor.js +122 -0
- package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +46 -0
- package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
- package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +177 -0
- package/es/components/cell-editor-popover/mb-date-editor-popover.js +245 -0
- package/es/components/cell-editor-popover/mb-link-editor-popover.js +170 -0
- package/es/components/cell-editor-popover/mb-select-editor-popover.js +230 -0
- package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +109 -0
- package/es/components/cell-editor-popover/pc-date-editor-popover.js +142 -0
- package/es/components/cell-editor-popover/pc-link-editor-popover.js +114 -0
- package/es/components/cell-editor-popover/pc-select-editor-popover.js +143 -0
- package/es/components/cell-factory/cell-formatter-factory.js +25 -0
- package/es/components/cell-formatter/auto-number-formatter.js +35 -0
- package/es/components/cell-formatter/button-formatter.js +55 -0
- package/es/components/cell-formatter/checkbox-formatter.js +44 -0
- package/es/components/cell-formatter/collaborator-formatter.js +91 -0
- package/es/components/cell-formatter/creator-formatter.js +87 -0
- package/es/components/cell-formatter/ctime-formatter.js +57 -0
- package/es/components/cell-formatter/date-formatter.js +59 -0
- package/es/components/cell-formatter/duration-formatter.js +37 -0
- package/es/components/cell-formatter/email-formatter.js +35 -0
- package/es/components/cell-formatter/file-formatter.js +63 -0
- package/es/components/cell-formatter/formatter-config.js +31 -0
- package/es/components/cell-formatter/formula-formatter.js +173 -0
- package/es/components/cell-formatter/geolocation-formatter.js +49 -0
- package/es/components/cell-formatter/image-formatter.js +153 -0
- package/es/components/cell-formatter/index.js +26 -0
- package/es/components/cell-formatter/last-modifier-formatter.js +87 -0
- package/es/components/cell-formatter/link-formatter.js +144 -0
- package/es/components/cell-formatter/long-text-formatter.js +106 -0
- package/es/components/cell-formatter/mtime-formatter.js +57 -0
- package/es/components/cell-formatter/multiple-select-formatter.js +70 -0
- package/es/components/cell-formatter/number-formatter.js +46 -0
- package/es/components/cell-formatter/rate-formatter.js +74 -0
- package/es/components/cell-formatter/single-select-formatter.js +69 -0
- package/es/components/cell-formatter/text-formatter.js +35 -0
- package/es/components/cell-formatter/url-formatter.js +35 -0
- package/es/components/cell-formatter/widgets/file-item-formatter.js +50 -0
- package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +119 -0
- package/es/components/common/collaborator-item.js +63 -0
- package/es/components/common/edit-editor-button.js +56 -0
- package/es/components/common/images-lazy-load.js +148 -0
- package/es/components/common/link-editor-option.js +113 -0
- package/es/components/common/mobile/mb-editor-header.js +48 -0
- package/es/components/common/modal-portal.js +44 -0
- package/es/components/common/select-editor-option.js +106 -0
- package/es/components/common/select-item.js +58 -0
- package/es/components/file-uploader/index.js +53 -0
- package/es/components/loading.js +7 -0
- package/es/components/toast/alert.js +150 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +179 -0
- package/es/components/toast/toastManager.js +170 -0
- package/es/components/toast/toaster.js +76 -0
- package/es/css/cell-editor.css +614 -0
- package/es/css/cell-formatter.css +241 -0
- package/es/css/custom-rc-calendar.css +118 -0
- package/es/css/image-previewer-ligntbox.css +87 -0
- package/es/css/loading.css +54 -0
- package/es/index.js +5 -0
- package/es/lang/index.js +50 -0
- package/es/locals/de.js +2 -0
- package/es/locals/en.js +17 -0
- package/es/locals/fr.js +2 -0
- package/es/locals/zh-CN.js +17 -0
- package/es/utils/cell-types.js +25 -0
- package/es/utils/constants.js +41 -0
- package/es/utils/editor-utils.js +71 -0
- package/es/utils/normalize-long-text-value.js +68 -0
- package/es/utils/number-precision.js +163 -0
- package/es/utils/utils.js +116 -0
- package/es/utils/value-format-utils.js +281 -0
- package/lib/AutoNumberFormatter/index.js +3 -0
- package/lib/ButtonFormatter/index.js +1 -1
- package/lib/CollaboratorFormatter/index.js +3 -0
- package/lib/CreatorFormatter/index.js +3 -0
- package/lib/DTableCustomizeCollaboratorSelect/index.js +1 -1
- package/lib/DTableCustomizeSelect/index.js +1 -1
- package/lib/DTableSelect/index.js +1 -1
- package/lib/FormulaFormatter/index.js +2 -2
- package/lib/HtmlLongTextFormatter/vfile/index.js +0 -2
- package/lib/ImageFormatter/index.js +2 -1
- package/lib/ImagePreviewerLightbox/index.js +3 -2
- package/lib/ImagePreviewerLightbox/utils.js +3 -2
- package/lib/LastModifierFormatter/index.js +3 -0
- package/lib/LinkFormatter/index.js +4 -1
- package/lib/MultipleSelectFormatter/index.js +3 -0
- package/lib/SelectOptionGroup/KeyCodes.js +1 -1
- package/lib/SingleSelectFormatter/index.js +3 -0
- package/lib/cellFormatterFactory/index.js +3 -3
- package/lib/formatterConfig/base-formatter-config.js +28 -0
- package/lib/formatterConfig/index.js +6 -23
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import CollaboratorItem from '../common/collaborator-item';
|
|
8
|
+
import DefaultAvatar from '../../assets/images/avatar/default_avatar.png';
|
|
9
|
+
|
|
10
|
+
// there will be there conditions
|
|
11
|
+
// 1 value is not exist, typeof value is array, but it's length is 0
|
|
12
|
+
// 2 value is exist, but can't find in collaborators
|
|
13
|
+
// 3 value is exist, typeof value is a string
|
|
14
|
+
// 4 value is exist, typeof value is array
|
|
15
|
+
var CollaboratorFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
16
|
+
_inherits(CollaboratorFormatter, _React$PureComponent);
|
|
17
|
+
|
|
18
|
+
var _super = _createSuper(CollaboratorFormatter);
|
|
19
|
+
|
|
20
|
+
function CollaboratorFormatter() {
|
|
21
|
+
var _this;
|
|
22
|
+
|
|
23
|
+
_classCallCheck(this, CollaboratorFormatter);
|
|
24
|
+
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
30
|
+
|
|
31
|
+
_this.getCollaborators = function () {
|
|
32
|
+
var _this$props = _this.props,
|
|
33
|
+
value = _this$props.value,
|
|
34
|
+
collaborators = _this$props.collaborators,
|
|
35
|
+
enableDeleteCollaborator = _this$props.enableDeleteCollaborator,
|
|
36
|
+
onDeleteCollaborator = _this$props.onDeleteCollaborator;
|
|
37
|
+
|
|
38
|
+
if (!Array.isArray(value)) {
|
|
39
|
+
value = [value];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return value.map(function (item, index) {
|
|
43
|
+
var collaborator = collaborators.find(function (collaborator) {
|
|
44
|
+
return collaborator.email === item;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!collaborator) {
|
|
48
|
+
collaborator = {
|
|
49
|
+
name: item,
|
|
50
|
+
avatar_url: DefaultAvatar
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
;
|
|
55
|
+
return /*#__PURE__*/React.createElement(CollaboratorItem, {
|
|
56
|
+
key: index,
|
|
57
|
+
collaborator: collaborator,
|
|
58
|
+
enableDeleteCollaborator: enableDeleteCollaborator,
|
|
59
|
+
onDeleteCollaborator: onDeleteCollaborator
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return _this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_createClass(CollaboratorFormatter, [{
|
|
68
|
+
key: "render",
|
|
69
|
+
value: function render() {
|
|
70
|
+
var _this$props2 = this.props,
|
|
71
|
+
containerClassName = _this$props2.containerClassName,
|
|
72
|
+
value = _this$props2.value;
|
|
73
|
+
var classname = cn('dtable-ui cell-formatter-container collaborator-formatter', containerClassName);
|
|
74
|
+
|
|
75
|
+
if (!value || Array.isArray(value) && value.length === 0) {
|
|
76
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: classname
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var collaborators = this.getCollaborators();
|
|
82
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
className: classname
|
|
84
|
+
}, collaborators);
|
|
85
|
+
}
|
|
86
|
+
}]);
|
|
87
|
+
|
|
88
|
+
return CollaboratorFormatter;
|
|
89
|
+
}(React.PureComponent);
|
|
90
|
+
|
|
91
|
+
export default CollaboratorFormatter;
|
|
@@ -0,0 +1,87 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import ColloboratorItem from '../common/collaborator-item';
|
|
8
|
+
import DefaultAvatar from '../../assets/images/avatar/default_avatar.png';
|
|
9
|
+
|
|
10
|
+
// there will be there conditions
|
|
11
|
+
// 1 value is not exist, typeof value is array, but it's length is 0
|
|
12
|
+
// 2 value is exist, but can't find in collaborators
|
|
13
|
+
// 3 value is exist, typeof value is a string
|
|
14
|
+
// 4 vlaue is exist, typeof value is array
|
|
15
|
+
var CreatorFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
16
|
+
_inherits(CreatorFormatter, _React$PureComponent);
|
|
17
|
+
|
|
18
|
+
var _super = _createSuper(CreatorFormatter);
|
|
19
|
+
|
|
20
|
+
function CreatorFormatter() {
|
|
21
|
+
var _this;
|
|
22
|
+
|
|
23
|
+
_classCallCheck(this, CreatorFormatter);
|
|
24
|
+
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
30
|
+
|
|
31
|
+
_this.getCollaborators = function () {
|
|
32
|
+
var _this$props = _this.props,
|
|
33
|
+
value = _this$props.value,
|
|
34
|
+
collaborators = _this$props.collaborators;
|
|
35
|
+
|
|
36
|
+
if (!Array.isArray(value)) {
|
|
37
|
+
value = [value];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return value.map(function (item, index) {
|
|
41
|
+
var collaborator = collaborators.find(function (collaborator) {
|
|
42
|
+
return collaborator.email === item;
|
|
43
|
+
}); // the collaborator can be not exist, beacuse the row created by third app
|
|
44
|
+
|
|
45
|
+
if (!collaborator) {
|
|
46
|
+
collaborator = {
|
|
47
|
+
name: item,
|
|
48
|
+
avatar_url: DefaultAvatar
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
;
|
|
53
|
+
return /*#__PURE__*/React.createElement(ColloboratorItem, {
|
|
54
|
+
key: index,
|
|
55
|
+
collaborator: collaborator
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_createClass(CreatorFormatter, [{
|
|
64
|
+
key: "render",
|
|
65
|
+
value: function render() {
|
|
66
|
+
var _this$props2 = this.props,
|
|
67
|
+
containerClassName = _this$props2.containerClassName,
|
|
68
|
+
value = _this$props2.value;
|
|
69
|
+
var classname = cn('dtable-ui cell-formatter-container creator-formatter', containerClassName);
|
|
70
|
+
|
|
71
|
+
if (!value || Array.isArray(value) && value.length === 0) {
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: classname
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var collaborators = this.getCollaborators();
|
|
78
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: classname
|
|
80
|
+
}, collaborators);
|
|
81
|
+
}
|
|
82
|
+
}]);
|
|
83
|
+
|
|
84
|
+
return CreatorFormatter;
|
|
85
|
+
}(React.PureComponent);
|
|
86
|
+
|
|
87
|
+
export default CreatorFormatter;
|
|
@@ -0,0 +1,57 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import moment from 'moment';
|
|
8
|
+
|
|
9
|
+
var CTimeFormatter = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(CTimeFormatter, _React$Component);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(CTimeFormatter);
|
|
13
|
+
|
|
14
|
+
function CTimeFormatter() {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, CTimeFormatter);
|
|
18
|
+
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
|
+
|
|
25
|
+
_this.formatDate = function (date) {
|
|
26
|
+
return moment(date).format('YYYY-MM-DD HH:mm:ss');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_createClass(CTimeFormatter, [{
|
|
33
|
+
key: "render",
|
|
34
|
+
value: function render() {
|
|
35
|
+
var _this$props = this.props,
|
|
36
|
+
date = _this$props.value,
|
|
37
|
+
containerClassName = _this$props.containerClassName;
|
|
38
|
+
var classname = cn('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
|
|
39
|
+
|
|
40
|
+
if (date !== '') {
|
|
41
|
+
date = this.formatDate(date);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
className: classname
|
|
46
|
+
}, date);
|
|
47
|
+
}
|
|
48
|
+
}]);
|
|
49
|
+
|
|
50
|
+
return CTimeFormatter;
|
|
51
|
+
}(React.Component);
|
|
52
|
+
|
|
53
|
+
CTimeFormatter.defaultProps = {
|
|
54
|
+
value: '',
|
|
55
|
+
containerClassName: ''
|
|
56
|
+
};
|
|
57
|
+
export default CTimeFormatter;
|
|
@@ -0,0 +1,59 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import { formatDateToString } from '../../utils/value-format-utils';
|
|
8
|
+
|
|
9
|
+
var DateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(DateFormatter, _React$Component);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(DateFormatter);
|
|
13
|
+
|
|
14
|
+
function DateFormatter() {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, DateFormatter);
|
|
18
|
+
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
|
+
|
|
25
|
+
_this.formatDate = function (date, format) {
|
|
26
|
+
return formatDateToString(date, format);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_createClass(DateFormatter, [{
|
|
33
|
+
key: "render",
|
|
34
|
+
value: function render() {
|
|
35
|
+
var _this$props = this.props,
|
|
36
|
+
date = _this$props.value,
|
|
37
|
+
format = _this$props.format,
|
|
38
|
+
containerClassName = _this$props.containerClassName;
|
|
39
|
+
var classname = cn('dtable-ui cell-formatter-container date-formatter', containerClassName);
|
|
40
|
+
|
|
41
|
+
if (date !== '') {
|
|
42
|
+
date = this.formatDate(date, format);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: classname
|
|
47
|
+
}, date);
|
|
48
|
+
}
|
|
49
|
+
}]);
|
|
50
|
+
|
|
51
|
+
return DateFormatter;
|
|
52
|
+
}(React.Component);
|
|
53
|
+
|
|
54
|
+
DateFormatter.defaultProps = {
|
|
55
|
+
value: '',
|
|
56
|
+
format: 'YYYY-MM-DD',
|
|
57
|
+
containerClassName: ''
|
|
58
|
+
};
|
|
59
|
+
export default DateFormatter;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import { getDurationDisplayString } from '../../utils/value-format-utils';
|
|
8
|
+
|
|
9
|
+
var DurationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(DurationFormatter, _React$Component);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(DurationFormatter);
|
|
13
|
+
|
|
14
|
+
function DurationFormatter() {
|
|
15
|
+
_classCallCheck(this, DurationFormatter);
|
|
16
|
+
|
|
17
|
+
return _super.apply(this, arguments);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_createClass(DurationFormatter, [{
|
|
21
|
+
key: "render",
|
|
22
|
+
value: function render() {
|
|
23
|
+
var _this$props = this.props,
|
|
24
|
+
value = _this$props.value,
|
|
25
|
+
containerClassName = _this$props.containerClassName,
|
|
26
|
+
format = _this$props.format;
|
|
27
|
+
var classname = cn('dtable-ui cell-formatter-container duration-formatter', containerClassName);
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: classname
|
|
30
|
+
}, getDurationDisplayString(value, format));
|
|
31
|
+
}
|
|
32
|
+
}]);
|
|
33
|
+
|
|
34
|
+
return DurationFormatter;
|
|
35
|
+
}(React.Component);
|
|
36
|
+
|
|
37
|
+
export default DurationFormatter;
|
|
@@ -0,0 +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
|
+
import React from 'react';
|
|
6
|
+
import cn from 'astro-classname';
|
|
7
|
+
|
|
8
|
+
var EmailFormatter = /*#__PURE__*/function (_React$Component) {
|
|
9
|
+
_inherits(EmailFormatter, _React$Component);
|
|
10
|
+
|
|
11
|
+
var _super = _createSuper(EmailFormatter);
|
|
12
|
+
|
|
13
|
+
function EmailFormatter() {
|
|
14
|
+
_classCallCheck(this, EmailFormatter);
|
|
15
|
+
|
|
16
|
+
return _super.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createClass(EmailFormatter, [{
|
|
20
|
+
key: "render",
|
|
21
|
+
value: function render() {
|
|
22
|
+
var _this$props = this.props,
|
|
23
|
+
containerClassName = _this$props.containerClassName,
|
|
24
|
+
value = _this$props.value;
|
|
25
|
+
var classname = cn('dtable-ui cell-formatter-container email-formatter', containerClassName);
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
className: classname
|
|
28
|
+
}, value);
|
|
29
|
+
}
|
|
30
|
+
}]);
|
|
31
|
+
|
|
32
|
+
return EmailFormatter;
|
|
33
|
+
}(React.Component);
|
|
34
|
+
|
|
35
|
+
export default EmailFormatter;
|
|
@@ -0,0 +1,63 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import FileItemFormatter from './widgets/file-item-formatter';
|
|
8
|
+
|
|
9
|
+
var FileFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
10
|
+
_inherits(FileFormatter, _React$PureComponent);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(FileFormatter);
|
|
13
|
+
|
|
14
|
+
function FileFormatter() {
|
|
15
|
+
_classCallCheck(this, FileFormatter);
|
|
16
|
+
|
|
17
|
+
return _super.apply(this, arguments);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_createClass(FileFormatter, [{
|
|
21
|
+
key: "render",
|
|
22
|
+
value: function render() {
|
|
23
|
+
var _this$props = this.props,
|
|
24
|
+
isSample = _this$props.isSample,
|
|
25
|
+
value = _this$props.value,
|
|
26
|
+
containerClassName = _this$props.containerClassName;
|
|
27
|
+
var className = cn('dtable-ui cell-formatter-container file-formatter', containerClassName);
|
|
28
|
+
|
|
29
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (isSample) {
|
|
34
|
+
var item = value[0];
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: className
|
|
37
|
+
}, /*#__PURE__*/React.createElement(FileItemFormatter, {
|
|
38
|
+
file: item
|
|
39
|
+
}), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
|
|
40
|
+
className: "file-item-count"
|
|
41
|
+
}, "+".concat(value.length)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
className: className
|
|
46
|
+
}, value.map(function (item, index) {
|
|
47
|
+
return /*#__PURE__*/React.createElement(FileItemFormatter, {
|
|
48
|
+
file: item,
|
|
49
|
+
key: index
|
|
50
|
+
});
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
}]);
|
|
54
|
+
|
|
55
|
+
return FileFormatter;
|
|
56
|
+
}(React.PureComponent);
|
|
57
|
+
|
|
58
|
+
FileFormatter.defaultProps = {
|
|
59
|
+
isSample: false,
|
|
60
|
+
value: [],
|
|
61
|
+
containerClassName: ''
|
|
62
|
+
};
|
|
63
|
+
export default FileFormatter;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
3
|
+
var _FormatterConfig;
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import * as CellTypes from '../../utils/cell-types';
|
|
7
|
+
import CheckboxFormatter from './checkbox-formatter';
|
|
8
|
+
import ImageFormatter from './image-formatter';
|
|
9
|
+
import LongTextFormatter from './long-text-formatter';
|
|
10
|
+
import TextCellFormatter from './text-formatter';
|
|
11
|
+
import SingleSelectFormatter from './single-select-formatter';
|
|
12
|
+
import MultipleSelectFormatter from './multiple-select-formatter';
|
|
13
|
+
import FileFormatter from './file-formatter';
|
|
14
|
+
import LinkFormatter from './link-formatter';
|
|
15
|
+
import CollaboratorFormatter from './collaborator-formatter';
|
|
16
|
+
import NumberFormatter from './number-formatter';
|
|
17
|
+
import DateFormatter from './date-formatter';
|
|
18
|
+
import CreatorFormatter from './creator-formatter';
|
|
19
|
+
import CTimeFormatter from './ctime-formatter';
|
|
20
|
+
import LastModifierFormatter from './last-modifier-formatter';
|
|
21
|
+
import MTimeFormatter from './mtime-formatter';
|
|
22
|
+
import GeolocationFormatter from './geolocation-formatter';
|
|
23
|
+
import FormulaFormatter from './formula-formatter';
|
|
24
|
+
import AutoNumberFormatter from './auto-number-formatter';
|
|
25
|
+
import UrlFormatter from './url-formatter';
|
|
26
|
+
import EmailFormatter from './email-formatter';
|
|
27
|
+
import DurationFormatter from './duration-formatter';
|
|
28
|
+
import RateFormatter from './rate-formatter';
|
|
29
|
+
import ButtonFormatter from './button-formatter';
|
|
30
|
+
var FormatterConfig = (_FormatterConfig = {}, _defineProperty(_FormatterConfig, CellTypes.DEFAULT, /*#__PURE__*/React.createElement(TextCellFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.TEXT, /*#__PURE__*/React.createElement(TextCellFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CHECKBOX, /*#__PURE__*/React.createElement(CheckboxFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LONG_TEXT, /*#__PURE__*/React.createElement(LongTextFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.SINGLE_SELECT, /*#__PURE__*/React.createElement(SingleSelectFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.IMAGE, /*#__PURE__*/React.createElement(ImageFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.FILE, /*#__PURE__*/React.createElement(FileFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.MULTIPLE_SELECT, /*#__PURE__*/React.createElement(MultipleSelectFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.COLLABORATOR, /*#__PURE__*/React.createElement(CollaboratorFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.NUMBER, /*#__PURE__*/React.createElement(NumberFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.DATE, /*#__PURE__*/React.createElement(DateFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LINK, /*#__PURE__*/React.createElement(LinkFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CREATOR, /*#__PURE__*/React.createElement(CreatorFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CTIME, /*#__PURE__*/React.createElement(CTimeFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LAST_MODIFIER, /*#__PURE__*/React.createElement(LastModifierFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.MTIME, /*#__PURE__*/React.createElement(MTimeFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.GEOLOCATION, /*#__PURE__*/React.createElement(GeolocationFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.FORMULA, /*#__PURE__*/React.createElement(FormulaFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.AUTO_NUMBER, /*#__PURE__*/React.createElement(AutoNumberFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.URL, /*#__PURE__*/React.createElement(UrlFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.EMAIL, /*#__PURE__*/React.createElement(EmailFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.DURATION, /*#__PURE__*/React.createElement(DurationFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.RATE, /*#__PURE__*/React.createElement(RateFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.BUTTON, /*#__PURE__*/React.createElement(ButtonFormatter, null)), _FormatterConfig);
|
|
31
|
+
export default FormatterConfig;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import cn from 'astro-classname';
|
|
8
|
+
import { FORMULA_RESULT_TYPE } from '../../utils/constants';
|
|
9
|
+
import cellFormatterFactory from '../cell-factory/cell-formatter-factory';
|
|
10
|
+
import * as CellTypes from '../../utils/cell-types';
|
|
11
|
+
import { formatNumberToString, formatDateToString } from '../../utils/value-format-utils';
|
|
12
|
+
import { isFunction } from '../../utils/utils';
|
|
13
|
+
import TextFormatter from './text-formatter';
|
|
14
|
+
var SIMPLE_CELL_FORMATTER_COLUMNS = [CellTypes.TEXT, CellTypes.NUMBER, CellTypes.DATE, CellTypes.CTIME, CellTypes.MTIME, CellTypes.GEOLOCATION, CellTypes.AUTO_NUMBER, CellTypes.URL, CellTypes.EMAIL, CellTypes.DURATION];
|
|
15
|
+
var ARRAY_FORMAL_COLUMNS = [CellTypes.IMAGE, CellTypes.FILE, CellTypes.MULTIPLE_SELECT, CellTypes.COLLABORATOR];
|
|
16
|
+
|
|
17
|
+
var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
18
|
+
_inherits(FormulaFormatter, _React$Component);
|
|
19
|
+
|
|
20
|
+
var _super = _createSuper(FormulaFormatter);
|
|
21
|
+
|
|
22
|
+
function FormulaFormatter() {
|
|
23
|
+
var _this;
|
|
24
|
+
|
|
25
|
+
_classCallCheck(this, FormulaFormatter);
|
|
26
|
+
|
|
27
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
28
|
+
args[_key] = arguments[_key];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
32
|
+
|
|
33
|
+
_this.getOtherColumnFormatter = function (value, column) {
|
|
34
|
+
var collaborators = _this.props.collaborators;
|
|
35
|
+
var formatterProps = {
|
|
36
|
+
value: value
|
|
37
|
+
};
|
|
38
|
+
var columnType = column.type;
|
|
39
|
+
var Formatter = cellFormatterFactory.createFormatter(columnType);
|
|
40
|
+
|
|
41
|
+
switch (columnType) {
|
|
42
|
+
case CellTypes.NUMBER:
|
|
43
|
+
{
|
|
44
|
+
formatterProps.data = column.data;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case CellTypes.DATE:
|
|
49
|
+
{
|
|
50
|
+
formatterProps.format = column.format;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
case CellTypes.SINGLE_SELECT:
|
|
55
|
+
case CellTypes.MULTIPLE_SELECT:
|
|
56
|
+
{
|
|
57
|
+
formatterProps.options = column.data.options;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
case CellTypes.COLLABORATOR:
|
|
62
|
+
{
|
|
63
|
+
formatterProps.collaborators = collaborators;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
case CellTypes.FORMULA:
|
|
68
|
+
case CellTypes.LINK_FORMULA:
|
|
69
|
+
{
|
|
70
|
+
formatterProps.column = column;
|
|
71
|
+
Formatter = FormulaFormatter;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (React.isValidElement(Formatter)) {
|
|
76
|
+
return React.cloneElement(Formatter, _objectSpread({}, formatterProps));
|
|
77
|
+
} else if (isFunction(Formatter)) {
|
|
78
|
+
return /*#__PURE__*/React.createElement(Formatter, formatterProps);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return /*#__PURE__*/React.createElement(TextFormatter, formatterProps);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
_this.renderOtherColumnFormatter = function () {
|
|
85
|
+
var _this$props = _this.props,
|
|
86
|
+
value = _this$props.value,
|
|
87
|
+
column = _this$props.column,
|
|
88
|
+
tables = _this$props.tables;
|
|
89
|
+
var columnData = column.data;
|
|
90
|
+
|
|
91
|
+
var _ref = columnData || {},
|
|
92
|
+
display_column_key = _ref.display_column_key,
|
|
93
|
+
linked_table_id = _ref.linked_table_id;
|
|
94
|
+
|
|
95
|
+
var linkedTable = tables.find(function (table) {
|
|
96
|
+
return table._id === linked_table_id;
|
|
97
|
+
});
|
|
98
|
+
if (!linkedTable) return null;
|
|
99
|
+
var linkedColumn = linkedTable.columns.find(function (column) {
|
|
100
|
+
return column.key === display_column_key;
|
|
101
|
+
});
|
|
102
|
+
if (!linkedColumn) return null;
|
|
103
|
+
var linkedColumnType = linkedColumn.type;
|
|
104
|
+
|
|
105
|
+
if (!ARRAY_FORMAL_COLUMNS.includes(linkedColumnType) && Object.prototype.toString.call(value) === '[object Array]') {
|
|
106
|
+
var contentItemClassName = cn('formula-formatter-content-item', {
|
|
107
|
+
'simple-cell-formatter': SIMPLE_CELL_FORMATTER_COLUMNS.includes(linkedColumnType)
|
|
108
|
+
});
|
|
109
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: "dtable-ui formula-formatter multiple"
|
|
111
|
+
}, value.map(function (v, index) {
|
|
112
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
113
|
+
className: contentItemClassName,
|
|
114
|
+
key: "formula-formatter-content-item-".concat(index)
|
|
115
|
+
}, _this.getOtherColumnFormatter(v, linkedColumn));
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return _this.getOtherColumnFormatter(value, linkedColumn);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
_this.getFormattedValue = function (cellValue, columnData) {
|
|
123
|
+
if (!columnData) return '';
|
|
124
|
+
var result_type = columnData.result_type;
|
|
125
|
+
|
|
126
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
127
|
+
cellValue = parseFloat(cellValue);
|
|
128
|
+
return formatNumberToString(cellValue, columnData);
|
|
129
|
+
} else if (result_type === FORMULA_RESULT_TYPE.DATE) {
|
|
130
|
+
var format = columnData.format;
|
|
131
|
+
return formatDateToString(cellValue, format);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var formattedValue = Object.prototype.toString.call(cellValue) === '[object Boolean]' ? cellValue + '' : cellValue;
|
|
135
|
+
return formattedValue;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return _this;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
_createClass(FormulaFormatter, [{
|
|
142
|
+
key: "render",
|
|
143
|
+
value: function render() {
|
|
144
|
+
var _this$props2 = this.props,
|
|
145
|
+
value = _this$props2.value,
|
|
146
|
+
containerClassName = _this$props2.containerClassName,
|
|
147
|
+
column = _this$props2.column;
|
|
148
|
+
var columnData = column.data;
|
|
149
|
+
var resultType = columnData.result_type;
|
|
150
|
+
|
|
151
|
+
if (resultType === FORMULA_RESULT_TYPE.COLUMN) {
|
|
152
|
+
return this.renderOtherColumnFormatter();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (typeof value === 'object') {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
var isNumber = resultType === FORMULA_RESULT_TYPE.NUMBER;
|
|
160
|
+
var classname = cn('dtable-ui cell-formatter-container formula-formatter', containerClassName, {
|
|
161
|
+
"text-right": isNumber
|
|
162
|
+
});
|
|
163
|
+
var formattedValue = this.getFormattedValue(value, columnData);
|
|
164
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
165
|
+
className: classname
|
|
166
|
+
}, formattedValue);
|
|
167
|
+
}
|
|
168
|
+
}]);
|
|
169
|
+
|
|
170
|
+
return FormulaFormatter;
|
|
171
|
+
}(React.Component);
|
|
172
|
+
|
|
173
|
+
export default FormulaFormatter;
|