dtable-ui-component 0.3.2 → 0.3.4-alpha1
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/assets/dtable-font/dtable-font.eot +0 -0
- package/assets/dtable-font/dtable-font.svg +319 -11
- package/assets/dtable-font/dtable-font.ttf +0 -0
- package/assets/dtable-font/dtable-font.woff +0 -0
- package/assets/dtable-font/dtable-font.woff2 +0 -0
- package/assets/dtable-font.css +630 -14
- package/lib/AutoNumberFormatter/index.js +2 -2
- package/lib/ButtonFormatter/index.js +4 -8
- package/lib/CTimeFormatter/index.js +2 -2
- package/lib/CheckboxFormatter/index.js +2 -2
- package/lib/CollaboratorFormatter/index.js +2 -2
- package/lib/CreatorFormatter/index.js +2 -2
- package/lib/DTableCustomizeCollaboratorSelect/index.css +1 -1
- package/lib/DTableSearchInput/index.js +2 -2
- package/lib/DateFormatter/index.js +2 -2
- package/lib/DigitalSignFormatter/index.js +2 -2
- package/lib/DurationFormatter/index.js +2 -2
- package/lib/EmailFormatter/index.js +2 -2
- package/lib/FileFormatter/index.js +4 -3
- package/lib/FileItemFormatter/index.js +1 -1
- package/lib/FormulaFormatter/index.js +24 -5
- package/lib/FormulaFormatter/utils.js +91 -0
- package/lib/GeolocationFormatter/index.js +2 -2
- package/lib/HtmlLongTextFormatter/index.js +2 -2
- package/lib/ImageFormatter/images-lazy-load.js +12 -16
- package/lib/ImageFormatter/index.js +2 -2
- package/lib/ImagePreviewerLightbox/index.js +3 -3
- package/lib/LastModifierFormatter/index.js +2 -2
- package/lib/LinkFormatter/index.js +4 -4
- package/lib/MTimeFormatter/index.js +2 -2
- package/lib/MultipleSelectFormatter/index.js +2 -2
- package/lib/NumberFormatter/index.js +2 -2
- package/lib/RateFormatter/index.js +2 -2
- package/lib/RowExpandFileFormatter/index.css +72 -0
- package/lib/RowExpandFileFormatter/index.js +59 -0
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +125 -0
- package/lib/RowExpandFormatter/index.css +73 -0
- package/lib/RowExpandFormatter/index.js +441 -0
- package/lib/RowExpandImageFormatter/index.css +79 -0
- package/lib/RowExpandImageFormatter/index.js +127 -0
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +128 -0
- package/lib/RowExpandImageFormatter/utils.js +7 -0
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +164 -0
- package/lib/RowExpandLinkFormatter/column-data-constants.js +20 -0
- package/lib/RowExpandLinkFormatter/date-utils.js +127 -0
- package/lib/RowExpandLinkFormatter/formula-constants.js +9 -0
- package/lib/RowExpandLinkFormatter/index.css +25 -0
- package/lib/RowExpandLinkFormatter/index.js +170 -0
- package/lib/RowExpandLinkFormatter/number-precision.js +116 -0
- package/lib/RowExpandLinkFormatter/utils.js +58 -0
- package/lib/RowExpandLinkFormatter/value-display-utils.js +401 -0
- package/lib/SimpleLongTextFormatter/index.js +2 -2
- package/lib/SingleSelectFormatter/index.js +2 -2
- package/lib/TextFormatter/index.js +2 -2
- package/lib/UrlFormatter/index.js +2 -2
- package/lib/common/delete-tip.css +16 -0
- package/lib/common/delete-tip.js +84 -0
- package/lib/common/modal-portal.js +44 -0
- package/lib/constants/cell-types.js +5 -1
- package/lib/data/dtable-value.js +2731 -0
- package/lib/index.js +7 -1
- package/lib/lang/index.js +1 -1
- package/lib/locals/en.js +17 -13
- package/lib/locals/zh-CN.js +16 -12
- package/package.json +5 -4
|
@@ -0,0 +1,128 @@
|
|
|
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, { Component } from 'react';
|
|
6
|
+
import { Tooltip } from 'reactstrap';
|
|
7
|
+
import { getLocale } from '../lang';
|
|
8
|
+
import DeleteTip from '../common/delete-tip';
|
|
9
|
+
|
|
10
|
+
var RowExpandImageItemFormatter = /*#__PURE__*/function (_Component) {
|
|
11
|
+
_inherits(RowExpandImageItemFormatter, _Component);
|
|
12
|
+
|
|
13
|
+
var _super = _createSuper(RowExpandImageItemFormatter);
|
|
14
|
+
|
|
15
|
+
function RowExpandImageItemFormatter(props) {
|
|
16
|
+
var _this;
|
|
17
|
+
|
|
18
|
+
_classCallCheck(this, RowExpandImageItemFormatter);
|
|
19
|
+
|
|
20
|
+
_this = _super.call(this, props);
|
|
21
|
+
|
|
22
|
+
_this.toggleTooltip = function () {
|
|
23
|
+
_this.setState({
|
|
24
|
+
isTooltipOpen: !_this.state.isTooltipOpen
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
_this.closeDeleteTip = function () {
|
|
29
|
+
_this.setState({
|
|
30
|
+
isDeleteTipOpen: false
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
_this.onClickDelete = function (e) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
_this.position = {
|
|
38
|
+
top: e.clientY,
|
|
39
|
+
left: e.clientX
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
_this.setState({
|
|
43
|
+
isDeleteTipOpen: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
_this.onClickDownload = function (e) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
|
|
51
|
+
_this.props.downloadFile(_this.props.url, e);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
_this.onDelete = function (e) {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
|
|
57
|
+
_this.closeDeleteTip();
|
|
58
|
+
|
|
59
|
+
_this.props.deleteFile(_this.props.index);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
_this.onClickImage = function () {
|
|
63
|
+
_this.props.onImageClick(_this.props.index);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
_this.state = {
|
|
67
|
+
isTooltipOpen: false,
|
|
68
|
+
isDeleteTipOpen: false
|
|
69
|
+
};
|
|
70
|
+
return _this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_createClass(RowExpandImageItemFormatter, [{
|
|
74
|
+
key: "render",
|
|
75
|
+
value: function render() {
|
|
76
|
+
var _this$props = this.props,
|
|
77
|
+
url = _this$props.url,
|
|
78
|
+
column = _this$props.column,
|
|
79
|
+
index = _this$props.index,
|
|
80
|
+
readOnly = _this$props.readOnly,
|
|
81
|
+
downloadFile = _this$props.downloadFile,
|
|
82
|
+
deleteFile = _this$props.deleteFile;
|
|
83
|
+
var id = 'image-list-preview-item' + column.key + index;
|
|
84
|
+
var name = decodeURI(url.slice(url.lastIndexOf('/') + 1));
|
|
85
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
key: "image-".concat(index),
|
|
87
|
+
className: "row-expand-item-image",
|
|
88
|
+
id: id,
|
|
89
|
+
onClick: this.onClickImage
|
|
90
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
91
|
+
src: url,
|
|
92
|
+
id: "item-image-".concat(index),
|
|
93
|
+
alt: name
|
|
94
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
className: "dtable-image-icons-choice"
|
|
96
|
+
}, downloadFile && /*#__PURE__*/React.createElement("span", {
|
|
97
|
+
className: "image-icon",
|
|
98
|
+
onClick: this.onClickDownload
|
|
99
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
100
|
+
className: "dtable-font dtable-icon-download"
|
|
101
|
+
})), !readOnly && deleteFile && /*#__PURE__*/React.createElement("span", {
|
|
102
|
+
className: "image-icon",
|
|
103
|
+
onClick: this.onClickDelete
|
|
104
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
105
|
+
className: "dtable-font dtable-icon-fork-number"
|
|
106
|
+
})))), this.state.isDeleteTipOpen && /*#__PURE__*/React.createElement(DeleteTip, {
|
|
107
|
+
position: this.position,
|
|
108
|
+
toggle: this.closeDeleteTip,
|
|
109
|
+
onDelete: this.onDelete,
|
|
110
|
+
deleteTip: getLocale('Are_you_sure_you_want_to_delete_this_image')
|
|
111
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
112
|
+
placement: "bottom",
|
|
113
|
+
isOpen: this.state.isTooltipOpen,
|
|
114
|
+
toggle: this.toggleTooltip,
|
|
115
|
+
target: id,
|
|
116
|
+
delay: {
|
|
117
|
+
show: 0,
|
|
118
|
+
hide: 0
|
|
119
|
+
},
|
|
120
|
+
fade: false
|
|
121
|
+
}, name));
|
|
122
|
+
}
|
|
123
|
+
}]);
|
|
124
|
+
|
|
125
|
+
return RowExpandImageItemFormatter;
|
|
126
|
+
}(Component);
|
|
127
|
+
|
|
128
|
+
export { RowExpandImageItemFormatter as default };
|
|
@@ -0,0 +1,164 @@
|
|
|
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, { Component } from 'react';
|
|
6
|
+
import CollaboratorItem from '../CollaboratorItem';
|
|
7
|
+
|
|
8
|
+
var CollaboratorItemFormatter = /*#__PURE__*/function (_Component) {
|
|
9
|
+
_inherits(CollaboratorItemFormatter, _Component);
|
|
10
|
+
|
|
11
|
+
var _super = _createSuper(CollaboratorItemFormatter);
|
|
12
|
+
|
|
13
|
+
function CollaboratorItemFormatter(_props) {
|
|
14
|
+
var _this;
|
|
15
|
+
|
|
16
|
+
_classCallCheck(this, CollaboratorItemFormatter);
|
|
17
|
+
|
|
18
|
+
_this = _super.call(this, _props);
|
|
19
|
+
|
|
20
|
+
_this.isValidEmail = function (email) {
|
|
21
|
+
var reg = /^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,6}$/;
|
|
22
|
+
return reg.test(email);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
_this.calculateCollaboratorData = function (props) {
|
|
26
|
+
var _this$props = _this.props,
|
|
27
|
+
context = _this$props.context,
|
|
28
|
+
collaborators = _this$props.collaborators;
|
|
29
|
+
var cellValue = props.cellValue;
|
|
30
|
+
|
|
31
|
+
if (!cellValue) {
|
|
32
|
+
_this.setState({
|
|
33
|
+
isDataLoaded: true,
|
|
34
|
+
collaborator: null
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_this.setState({
|
|
41
|
+
isDataLoaded: false,
|
|
42
|
+
collaborator: null
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
var collaborator = collaborators && collaborators.find(function (c) {
|
|
46
|
+
return c.name === cellValue;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (collaborator) {
|
|
50
|
+
_this.setState({
|
|
51
|
+
isDataLoaded: true,
|
|
52
|
+
collaborator: collaborator
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!context) return;
|
|
59
|
+
var mediaUrl = context.getSetting('mediaUrl');
|
|
60
|
+
var defaultAvatarUrl = "".concat(mediaUrl, "/avatars/default.png");
|
|
61
|
+
|
|
62
|
+
if (cellValue === 'anonymous') {
|
|
63
|
+
collaborator = {
|
|
64
|
+
name: 'anonymous',
|
|
65
|
+
avatar_url: defaultAvatarUrl
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
_this.setState({
|
|
69
|
+
isDataLoaded: true,
|
|
70
|
+
collaborator: collaborator
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var collaboratorsCache = context.getSetting('collaboratorsCache');
|
|
77
|
+
collaborator = collaboratorsCache[cellValue];
|
|
78
|
+
|
|
79
|
+
if (collaborator) {
|
|
80
|
+
_this.setState({
|
|
81
|
+
isDataLoaded: true,
|
|
82
|
+
collaborator: collaborator
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!_this.isValidEmail(cellValue)) {
|
|
89
|
+
collaborator = {
|
|
90
|
+
name: cellValue,
|
|
91
|
+
avatar_url: defaultAvatarUrl
|
|
92
|
+
};
|
|
93
|
+
collaboratorsCache[cellValue] = collaborator;
|
|
94
|
+
|
|
95
|
+
_this.setState({
|
|
96
|
+
isDataLoaded: true,
|
|
97
|
+
collaborator: collaborator
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
_this.props.context.getUserCommonInfo(cellValue).then(function (res) {
|
|
104
|
+
collaborator = res.data;
|
|
105
|
+
collaboratorsCache[cellValue] = collaborator;
|
|
106
|
+
|
|
107
|
+
_this.setState({
|
|
108
|
+
isDataLoaded: true,
|
|
109
|
+
collaborator: collaborator
|
|
110
|
+
});
|
|
111
|
+
}).catch(function () {
|
|
112
|
+
collaborator = {
|
|
113
|
+
name: cellValue,
|
|
114
|
+
avatar_url: defaultAvatarUrl
|
|
115
|
+
};
|
|
116
|
+
collaboratorsCache[cellValue] = collaborator;
|
|
117
|
+
|
|
118
|
+
_this.setState({
|
|
119
|
+
isDataLoaded: true,
|
|
120
|
+
collaborator: collaborator
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
_this.state = {
|
|
126
|
+
isDataLoaded: false,
|
|
127
|
+
collaborator: null
|
|
128
|
+
};
|
|
129
|
+
return _this;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_createClass(CollaboratorItemFormatter, [{
|
|
133
|
+
key: "componentDidMount",
|
|
134
|
+
value: function componentDidMount() {
|
|
135
|
+
this.calculateCollaboratorData(this.props);
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
139
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
140
|
+
this.calculateCollaboratorData(nextProps);
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "render",
|
|
144
|
+
value: function render() {
|
|
145
|
+
var cellValue = this.props.cellValue;
|
|
146
|
+
var _this$state = this.state,
|
|
147
|
+
collaborator = _this$state.collaborator,
|
|
148
|
+
isDataLoaded = _this$state.isDataLoaded;
|
|
149
|
+
|
|
150
|
+
if (!isDataLoaded || !cellValue || !collaborator) {
|
|
151
|
+
return this.props.renderEmpty();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return /*#__PURE__*/React.createElement(CollaboratorItem, {
|
|
155
|
+
collaborator: collaborator,
|
|
156
|
+
enableDeleteCollaborator: false
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}]);
|
|
160
|
+
|
|
161
|
+
return CollaboratorItemFormatter;
|
|
162
|
+
}(Component);
|
|
163
|
+
|
|
164
|
+
export { CollaboratorItemFormatter as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
3
|
+
var _DURATION_ZERO_DISPLA, _DURATION_DECIMAL_DIG;
|
|
4
|
+
|
|
5
|
+
export var DURATION_FORMATS_MAP = {
|
|
6
|
+
H_MM: 'h:mm',
|
|
7
|
+
H_MM_SS: 'h:mm:ss',
|
|
8
|
+
H_MM_SS_S: 'h:mm:ss.s',
|
|
9
|
+
H_MM_SS_SS: 'h:mm:ss.ss',
|
|
10
|
+
H_MM_SS_SSS: 'h:mm:ss.sss'
|
|
11
|
+
};
|
|
12
|
+
export var DURATION_FORMATS = [{
|
|
13
|
+
name: DURATION_FORMATS_MAP.H_MM,
|
|
14
|
+
type: DURATION_FORMATS_MAP.H_MM
|
|
15
|
+
}, {
|
|
16
|
+
name: DURATION_FORMATS_MAP.H_MM_SS,
|
|
17
|
+
type: DURATION_FORMATS_MAP.H_MM_SS
|
|
18
|
+
}];
|
|
19
|
+
export var DURATION_ZERO_DISPLAY = (_DURATION_ZERO_DISPLA = {}, _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM, '0:00'), _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM_SS, '0:00'), _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM_SS_S, '0:00.0'), _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM_SS_SS, '0:00.00'), _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM_SS_SSS, '0:00.000'), _DURATION_ZERO_DISPLA);
|
|
20
|
+
export var DURATION_DECIMAL_DIGITS = (_DURATION_DECIMAL_DIG = {}, _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM, 0), _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM_SS, 0), _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM_SS_S, 1), _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM_SS_SS, 2), _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM_SS_SSS, 3), _DURATION_DECIMAL_DIG);
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
|
|
4
|
+
var DateUtils = /*#__PURE__*/function () {
|
|
5
|
+
function DateUtils() {
|
|
6
|
+
_classCallCheck(this, DateUtils);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_createClass(DateUtils, null, [{
|
|
10
|
+
key: "format",
|
|
11
|
+
value: function format(date, _format) {
|
|
12
|
+
var dateObject = this.getValidDate(date);
|
|
13
|
+
|
|
14
|
+
if (!dateObject) {
|
|
15
|
+
return date;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var upperCaseFormat = _format && _format.toUpperCase();
|
|
19
|
+
|
|
20
|
+
var year = dateObject.getFullYear();
|
|
21
|
+
var month = dateObject.getMonth() + 1;
|
|
22
|
+
var day = dateObject.getDate();
|
|
23
|
+
var displayMonth = month < 10 ? "0".concat(month) : month;
|
|
24
|
+
var displayDay = day < 10 ? "0".concat(day) : day;
|
|
25
|
+
|
|
26
|
+
switch (upperCaseFormat) {
|
|
27
|
+
case 'YYYY-MM-DD HH:MM:SS':
|
|
28
|
+
{
|
|
29
|
+
var hours = dateObject.getHours();
|
|
30
|
+
var minutes = dateObject.getMinutes();
|
|
31
|
+
var seconds = dateObject.getSeconds();
|
|
32
|
+
var displayHours = hours < 10 ? "0".concat(hours) : hours;
|
|
33
|
+
var displayMinutes = minutes < 10 ? "0".concat(minutes) : minutes;
|
|
34
|
+
var displaySeconds = seconds < 10 ? "0".concat(seconds) : seconds;
|
|
35
|
+
return "".concat(year, "-").concat(displayMonth, "-").concat(displayDay, " ").concat(displayHours, ":").concat(displayMinutes, ":").concat(displaySeconds);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
case 'YYYY-MM-DD HH:MM':
|
|
39
|
+
case 'YYYY-MM-DD HH:mm':
|
|
40
|
+
{
|
|
41
|
+
var _hours = dateObject.getHours();
|
|
42
|
+
|
|
43
|
+
var _minutes = dateObject.getMinutes();
|
|
44
|
+
|
|
45
|
+
var _displayHours = _hours < 10 ? "0".concat(_hours) : _hours;
|
|
46
|
+
|
|
47
|
+
var _displayMinutes = _minutes < 10 ? "0".concat(_minutes) : _minutes;
|
|
48
|
+
|
|
49
|
+
return "".concat(year, "-").concat(displayMonth, "-").concat(displayDay, " ").concat(_displayHours, ":").concat(_displayMinutes);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
case 'D/M/YYYY':
|
|
53
|
+
case 'DD/MM/YYYY':
|
|
54
|
+
{
|
|
55
|
+
return "".concat(displayDay, "/").concat(displayMonth, "/").concat(year);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
case 'D/M/YYYY HH:mm':
|
|
59
|
+
case 'DD/MM/YYYY HH:mm':
|
|
60
|
+
{
|
|
61
|
+
var _hours2 = dateObject.getHours();
|
|
62
|
+
|
|
63
|
+
var _minutes2 = dateObject.getMinutes();
|
|
64
|
+
|
|
65
|
+
var _displayHours2 = _hours2 < 10 ? "0".concat(_hours2) : _hours2;
|
|
66
|
+
|
|
67
|
+
var _displayMinutes2 = _minutes2 < 10 ? "0".concat(_minutes2) : _minutes2;
|
|
68
|
+
|
|
69
|
+
return "".concat(displayDay, "/").concat(displayMonth, "/").concat(year, " ").concat(_displayHours2, ":").concat(_displayMinutes2);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
case 'M/D/YYYY':
|
|
73
|
+
{
|
|
74
|
+
return "".concat(month, "/").concat(day, "/").concat(year);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
case 'M/D/YYYY HH:mm':
|
|
78
|
+
{
|
|
79
|
+
var _hours3 = dateObject.getHours();
|
|
80
|
+
|
|
81
|
+
var _minutes3 = dateObject.getMinutes();
|
|
82
|
+
|
|
83
|
+
var _displayHours3 = _hours3 < 10 ? "0".concat(_hours3) : _hours3;
|
|
84
|
+
|
|
85
|
+
var _displayMinutes3 = _minutes3 < 10 ? "0".concat(_minutes3) : _minutes3;
|
|
86
|
+
|
|
87
|
+
return "".concat(month, "/").concat(day, "/").concat(year, " ").concat(_displayHours3, ":").concat(_displayMinutes3);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
case 'YYYY-MM-DD':
|
|
91
|
+
{
|
|
92
|
+
return "".concat(year, "-").concat(displayMonth, "-").concat(displayDay);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
default:
|
|
96
|
+
{
|
|
97
|
+
return "".concat(year, "-").concat(displayMonth, "-").concat(displayDay);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "isValidDateObject",
|
|
103
|
+
value: function isValidDateObject(dateObject) {
|
|
104
|
+
return dateObject instanceof Date && !isNaN(dateObject.getTime());
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "getValidDate",
|
|
108
|
+
value: function getValidDate(date) {
|
|
109
|
+
if (!date) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var isDateTypeString = typeof date === 'string';
|
|
114
|
+
var dateObject = isDateTypeString ? new Date(date) : date;
|
|
115
|
+
if (this.isValidDateObject(dateObject)) return dateObject;
|
|
116
|
+
if (!isDateTypeString) return null; //ios phone and safari browser not support use '2021-09-10 12:30', support '2021/09/10 12:30'
|
|
117
|
+
|
|
118
|
+
dateObject = new Date(date.replace(/-/g, '/'));
|
|
119
|
+
if (this.isValidDateObject(dateObject)) return dateObject;
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}]);
|
|
123
|
+
|
|
124
|
+
return DateUtils;
|
|
125
|
+
}();
|
|
126
|
+
|
|
127
|
+
export default DateUtils;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.dtable-link-formatter {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
align-items: center;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: auto;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.dtable-link-formatter .row-expand-link-item {
|
|
11
|
+
flex-shrink: 0;
|
|
12
|
+
margin: 2px 4px 2px 0;
|
|
13
|
+
padding: 0 6px;
|
|
14
|
+
font-size: 13px;
|
|
15
|
+
max-width: 100%;
|
|
16
|
+
background: #eceff4;
|
|
17
|
+
border-radius: 3px;
|
|
18
|
+
align-items: center;
|
|
19
|
+
vertical-align: middle;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
text-overflow: ellipsis;
|
|
23
|
+
line-height: 20px;
|
|
24
|
+
width: fit-content;
|
|
25
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
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, { Component } from 'react';
|
|
7
|
+
import { CellType } from '../constants';
|
|
8
|
+
import { MultipleSelectFormatter, DateFormatter, CTimeFormatter, MTimeFormatter } from '../index';
|
|
9
|
+
import CollaboratorItemFormatter from './collaborator-item-formatter';
|
|
10
|
+
import { getFormulaArrayValue, isArrayFormalColumn } from './utils';
|
|
11
|
+
import { getCellDisplayValue } from './value-display-utils';
|
|
12
|
+
import './index.css';
|
|
13
|
+
|
|
14
|
+
var RowExpandLinkFormatter = /*#__PURE__*/function (_Component) {
|
|
15
|
+
_inherits(RowExpandLinkFormatter, _Component);
|
|
16
|
+
|
|
17
|
+
var _super = _createSuper(RowExpandLinkFormatter);
|
|
18
|
+
|
|
19
|
+
function RowExpandLinkFormatter() {
|
|
20
|
+
_classCallCheck(this, RowExpandLinkFormatter);
|
|
21
|
+
|
|
22
|
+
return _super.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_createClass(RowExpandLinkFormatter, [{
|
|
26
|
+
key: "render",
|
|
27
|
+
value: function render() {
|
|
28
|
+
var props = this.props;
|
|
29
|
+
var column = props.column,
|
|
30
|
+
value = props.value,
|
|
31
|
+
containerClassName = props.containerClassName,
|
|
32
|
+
collaborators = props.collaborators;
|
|
33
|
+
var data = column.data;
|
|
34
|
+
|
|
35
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
36
|
+
return props.renderEmpty();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var _ref = data || {},
|
|
40
|
+
displayColumn = _ref.display_column;
|
|
41
|
+
|
|
42
|
+
if (!displayColumn) {
|
|
43
|
+
return props.renderEmpty();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var displayColumnType = displayColumn.type,
|
|
47
|
+
displayColumnData = displayColumn.data;
|
|
48
|
+
var cellValue = getFormulaArrayValue(value, !isArrayFormalColumn(displayColumnType));
|
|
49
|
+
|
|
50
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0) {
|
|
51
|
+
return props.renderEmpty();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
switch (displayColumnType) {
|
|
55
|
+
case CellType.TEXT:
|
|
56
|
+
case CellType.AUTO_NUMBER:
|
|
57
|
+
case CellType.EMAIL:
|
|
58
|
+
case CellType.URL:
|
|
59
|
+
case CellType.DURATION:
|
|
60
|
+
case CellType.NUMBER:
|
|
61
|
+
{
|
|
62
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
className: containerClassName
|
|
64
|
+
}, cellValue.map(function (value, index) {
|
|
65
|
+
if (!value) return null;
|
|
66
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
68
|
+
className: "row-expand-link-item"
|
|
69
|
+
}, value);
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
case CellType.DATE:
|
|
74
|
+
{
|
|
75
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: containerClassName
|
|
77
|
+
}, cellValue.map(function (value, index) {
|
|
78
|
+
if (!value || typeof value !== 'string') return null;
|
|
79
|
+
|
|
80
|
+
var _ref2 = displayColumnData || {},
|
|
81
|
+
format = _ref2.format;
|
|
82
|
+
|
|
83
|
+
return /*#__PURE__*/React.createElement(DateFormatter, {
|
|
84
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
85
|
+
value: value.replace('T', ' ').replace('Z', ''),
|
|
86
|
+
format: format,
|
|
87
|
+
containerClassName: "row-expand-link-item"
|
|
88
|
+
});
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case CellType.CTIME:
|
|
93
|
+
{
|
|
94
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
className: containerClassName
|
|
96
|
+
}, cellValue.map(function (value, index) {
|
|
97
|
+
if (!value) return null;
|
|
98
|
+
return /*#__PURE__*/React.createElement(CTimeFormatter, {
|
|
99
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
100
|
+
value: value,
|
|
101
|
+
containerClassName: "row-expand-link-item"
|
|
102
|
+
});
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
case CellType.MTIME:
|
|
107
|
+
{
|
|
108
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: containerClassName
|
|
110
|
+
}, cellValue.map(function (value, index) {
|
|
111
|
+
if (!value) return null;
|
|
112
|
+
return /*#__PURE__*/React.createElement(MTimeFormatter, {
|
|
113
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
114
|
+
value: value,
|
|
115
|
+
containerClassName: "row-expand-link-item"
|
|
116
|
+
});
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
case CellType.CREATOR:
|
|
121
|
+
case CellType.LAST_MODIFIER:
|
|
122
|
+
{
|
|
123
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
124
|
+
className: "dtable-ui cell-formatter-container collaborator-formatter sql-query-collaborator-formatter"
|
|
125
|
+
}, cellValue.map(function (value, index) {
|
|
126
|
+
if (!value) return null;
|
|
127
|
+
return /*#__PURE__*/React.createElement(CollaboratorItemFormatter, {
|
|
128
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
129
|
+
cellValue: value,
|
|
130
|
+
collaborators: collaborators,
|
|
131
|
+
context: props.context,
|
|
132
|
+
renderEmpty: props.renderEmpty
|
|
133
|
+
});
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
case CellType.SINGLE_SELECT:
|
|
138
|
+
{
|
|
139
|
+
var options = displayColumnData && Array.isArray(displayColumnData.options) ? displayColumnData.options : [];
|
|
140
|
+
return /*#__PURE__*/React.createElement(MultipleSelectFormatter, {
|
|
141
|
+
value: cellValue,
|
|
142
|
+
options: options || []
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
case CellType.FORMULA:
|
|
147
|
+
{
|
|
148
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
className: containerClassName
|
|
150
|
+
}, cellValue.map(function (value, index) {
|
|
151
|
+
if (!value) return null;
|
|
152
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
153
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
154
|
+
className: "row-expand-link-item"
|
|
155
|
+
}, getCellDisplayValue(_defineProperty({}, displayColumn.key, value), displayColumn, collaborators));
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
default:
|
|
160
|
+
{
|
|
161
|
+
return props.renderEmpty();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}]);
|
|
166
|
+
|
|
167
|
+
return RowExpandLinkFormatter;
|
|
168
|
+
}(Component);
|
|
169
|
+
|
|
170
|
+
export { RowExpandLinkFormatter as default };
|