dtable-ui-component 0.2.7 → 0.2.8-beta
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/DTableRadio/index.css +14 -2
- package/lib/DTableRadio/index.js +7 -5
- package/package.json +1 -1
- package/es/app.css +0 -20
- package/es/app.js +0 -91
- 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 +0 -104
- package/es/components/cell-editor/collaborator-editor.js +0 -236
- package/es/components/cell-editor/date-editor.js +0 -151
- package/es/components/cell-editor/index.js +0 -9
- package/es/components/cell-editor/link-editor.js +0 -303
- package/es/components/cell-editor/multiple-select-editor.js +0 -237
- package/es/components/cell-editor/number-editor.js +0 -154
- package/es/components/cell-editor/single-select-editor.js +0 -202
- package/es/components/cell-editor/text-editor.js +0 -122
- package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
- 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 +0 -177
- package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
- package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
- package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
- package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
- package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
- package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
- package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
- package/es/components/cell-factory/cell-formatter-factory.js +0 -25
- package/es/components/cell-formatter/auto-number-formatter.js +0 -35
- package/es/components/cell-formatter/button-formatter.js +0 -55
- package/es/components/cell-formatter/checkbox-formatter.js +0 -44
- package/es/components/cell-formatter/collaborator-formatter.js +0 -91
- package/es/components/cell-formatter/creator-formatter.js +0 -87
- package/es/components/cell-formatter/ctime-formatter.js +0 -57
- package/es/components/cell-formatter/date-formatter.js +0 -59
- package/es/components/cell-formatter/duration-formatter.js +0 -37
- package/es/components/cell-formatter/email-formatter.js +0 -35
- package/es/components/cell-formatter/file-formatter.js +0 -63
- package/es/components/cell-formatter/formatter-config.js +0 -31
- package/es/components/cell-formatter/formula-formatter.js +0 -173
- package/es/components/cell-formatter/geolocation-formatter.js +0 -49
- package/es/components/cell-formatter/image-formatter.js +0 -153
- package/es/components/cell-formatter/index.js +0 -26
- package/es/components/cell-formatter/last-modifier-formatter.js +0 -87
- package/es/components/cell-formatter/link-formatter.js +0 -144
- package/es/components/cell-formatter/long-text-formatter.js +0 -106
- package/es/components/cell-formatter/mtime-formatter.js +0 -57
- package/es/components/cell-formatter/multiple-select-formatter.js +0 -70
- package/es/components/cell-formatter/number-formatter.js +0 -46
- package/es/components/cell-formatter/rate-formatter.js +0 -74
- package/es/components/cell-formatter/single-select-formatter.js +0 -69
- package/es/components/cell-formatter/text-formatter.js +0 -35
- package/es/components/cell-formatter/url-formatter.js +0 -35
- package/es/components/cell-formatter/widgets/file-item-formatter.js +0 -50
- package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +0 -119
- package/es/components/common/collaborator-item.js +0 -63
- package/es/components/common/edit-editor-button.js +0 -56
- package/es/components/common/images-lazy-load.js +0 -148
- package/es/components/common/link-editor-option.js +0 -113
- package/es/components/common/mobile/mb-editor-header.js +0 -48
- package/es/components/common/modal-portal.js +0 -44
- package/es/components/common/select-editor-option.js +0 -106
- package/es/components/common/select-item.js +0 -58
- package/es/components/file-uploader/index.js +0 -53
- package/es/components/loading.js +0 -7
- package/es/components/toast/alert.js +0 -150
- package/es/components/toast/index.js +0 -3
- package/es/components/toast/toast.js +0 -179
- package/es/components/toast/toastManager.js +0 -170
- package/es/components/toast/toaster.js +0 -76
- package/es/css/cell-editor.css +0 -614
- package/es/css/cell-formatter.css +0 -241
- package/es/css/custom-rc-calendar.css +0 -118
- package/es/css/image-previewer-ligntbox.css +0 -87
- package/es/css/loading.css +0 -54
- package/es/index.js +0 -5
- package/es/lang/index.js +0 -50
- package/es/locals/de.js +0 -2
- package/es/locals/en.js +0 -17
- package/es/locals/fr.js +0 -2
- package/es/locals/zh-CN.js +0 -17
- package/es/utils/cell-types.js +0 -25
- package/es/utils/constants.js +0 -41
- package/es/utils/editor-utils.js +0 -71
- package/es/utils/normalize-long-text-value.js +0 -68
- package/es/utils/number-precision.js +0 -163
- package/es/utils/utils.js +0 -116
- package/es/utils/value-format-utils.js +0 -281
package/es/utils/editor-utils.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
var zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
2
|
-
|
|
3
|
-
var zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
4
|
-
|
|
5
|
-
var enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
6
|
-
|
|
7
|
-
var frFR = require('@seafile/seafile-calendar/lib/locale/fr_FR');
|
|
8
|
-
|
|
9
|
-
var deDE = require('@seafile/seafile-calendar/lib/locale/de_DE');
|
|
10
|
-
|
|
11
|
-
var esES = require('@seafile/seafile-calendar/lib/locale/es_ES');
|
|
12
|
-
|
|
13
|
-
var plPL = require('@seafile/seafile-calendar/lib/locale/pl_PL');
|
|
14
|
-
|
|
15
|
-
var csCZ = require('@seafile/seafile-calendar/lib/locale/cs_CZ');
|
|
16
|
-
|
|
17
|
-
export var initDateEditorLanguage = function initDateEditorLanguage(lang) {
|
|
18
|
-
var language;
|
|
19
|
-
|
|
20
|
-
switch (lang) {
|
|
21
|
-
case 'zh-cn':
|
|
22
|
-
language = zhCN;
|
|
23
|
-
break;
|
|
24
|
-
|
|
25
|
-
case 'zh-tw':
|
|
26
|
-
language = zhTW;
|
|
27
|
-
break;
|
|
28
|
-
|
|
29
|
-
case 'en':
|
|
30
|
-
language = enUS;
|
|
31
|
-
break;
|
|
32
|
-
|
|
33
|
-
case 'fr':
|
|
34
|
-
language = frFR;
|
|
35
|
-
break;
|
|
36
|
-
|
|
37
|
-
case 'de':
|
|
38
|
-
language = deDE;
|
|
39
|
-
break;
|
|
40
|
-
|
|
41
|
-
case 'es':
|
|
42
|
-
language = esES;
|
|
43
|
-
break;
|
|
44
|
-
|
|
45
|
-
case 'es-ar':
|
|
46
|
-
language = esES;
|
|
47
|
-
break;
|
|
48
|
-
|
|
49
|
-
case 'es-mx':
|
|
50
|
-
language = esES;
|
|
51
|
-
break;
|
|
52
|
-
|
|
53
|
-
case 'pl':
|
|
54
|
-
language = plPL;
|
|
55
|
-
break;
|
|
56
|
-
|
|
57
|
-
case 'cs':
|
|
58
|
-
language = csCZ;
|
|
59
|
-
break;
|
|
60
|
-
|
|
61
|
-
default:
|
|
62
|
-
language = zhCN;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return language;
|
|
66
|
-
};
|
|
67
|
-
export var getSelectOptionItem = function getSelectOptionItem(options, optionId) {
|
|
68
|
-
return options.find(function (option) {
|
|
69
|
-
return option.id === optionId;
|
|
70
|
-
});
|
|
71
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var hrefReg = /\[.+\]\(\S+\)|<img src=(\S+).+\/>|!\[\]\(\S+\)|<\S+>/g,
|
|
2
|
-
imageReg1 = /^<img src="(\S+)" .+\/>/,
|
|
3
|
-
imageReg2 = /^!\[\]\((\S+)\)/,
|
|
4
|
-
linkReg1 = /^\[.+\]\(\S+\)/,
|
|
5
|
-
linkReg2 = /^<\S+>$/;
|
|
6
|
-
|
|
7
|
-
var getLinks = function getLinks(hrefList) {
|
|
8
|
-
var hrefObj = {
|
|
9
|
-
links: [],
|
|
10
|
-
images: []
|
|
11
|
-
};
|
|
12
|
-
hrefList.forEach(function (href) {
|
|
13
|
-
if (href.search(linkReg1) >= 0 || href.search(linkReg2) >= 0) {
|
|
14
|
-
hrefObj.links.push(href);
|
|
15
|
-
} else {
|
|
16
|
-
var imageSrcList = href.match(imageReg1);
|
|
17
|
-
var imageSrcList1 = href.match(imageReg2);
|
|
18
|
-
|
|
19
|
-
if (imageSrcList) {
|
|
20
|
-
hrefObj.images.push(imageSrcList[1]);
|
|
21
|
-
} else if (imageSrcList1) {
|
|
22
|
-
hrefObj.images.push(imageSrcList1[1]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return hrefObj;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var getPreviewContent = function getPreviewContent(markdownContent) {
|
|
30
|
-
var preview = '';
|
|
31
|
-
var newMarkdownContent = markdownContent.replace(hrefReg, '');
|
|
32
|
-
|
|
33
|
-
for (var index = 0; index < newMarkdownContent.length; index++) {
|
|
34
|
-
if (newMarkdownContent[index] === '#') {
|
|
35
|
-
continue;
|
|
36
|
-
} else if (newMarkdownContent[index] === '\n') {
|
|
37
|
-
preview += ' ';
|
|
38
|
-
} else {
|
|
39
|
-
preview += newMarkdownContent[index];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (preview.length === 30) {
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var hrefList = markdownContent.match(hrefReg);
|
|
48
|
-
|
|
49
|
-
if (hrefList) {
|
|
50
|
-
var _getLinks = getLinks(hrefList),
|
|
51
|
-
images = _getLinks.images,
|
|
52
|
-
links = _getLinks.links;
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
preview: preview,
|
|
56
|
-
images: images,
|
|
57
|
-
links: links
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
preview: preview,
|
|
63
|
-
images: [],
|
|
64
|
-
links: []
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default getPreviewContent;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @desc Solve the problem of floating calculation, avoid multiple digits after the decimal point and loss of calculation accuracy.
|
|
5
|
-
* example: 3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Correct wrong data
|
|
10
|
-
* strip(0.09999999999999998)=0.1
|
|
11
|
-
*/
|
|
12
|
-
function strip(num) {
|
|
13
|
-
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
|
|
14
|
-
return +parseFloat(num.toPrecision(precision));
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Return digits length of a number
|
|
18
|
-
* @param {*number} num Input number
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function digitLength(num) {
|
|
23
|
-
// Get digit length of e
|
|
24
|
-
var eSplit = num.toString().split(/[eE]/);
|
|
25
|
-
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
|
|
26
|
-
return len > 0 ? len : 0;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Convert decimals to integers and support scientific notation. If it is a decimal, it is enlarged to an integer
|
|
30
|
-
* @param {*number} num Number of inputs
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function float2Fixed(num) {
|
|
35
|
-
if (num.toString().indexOf('e') === -1) {
|
|
36
|
-
return Number(num.toString().replace('.', ''));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var dLen = digitLength(num);
|
|
40
|
-
return dLen > 0 ? strip(num * Math.pow(10, dLen)) : num;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Check whether the number is out of range, and give a prompt if it is out of range
|
|
44
|
-
* @param {*number} num Number of inputs
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function checkBoundary(num) {
|
|
49
|
-
if (_boundaryCheckingState) {
|
|
50
|
-
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
|
|
51
|
-
console.warn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Exact multiplication
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
function times(num1, num2) {
|
|
61
|
-
for (var _len = arguments.length, others = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
62
|
-
others[_key - 2] = arguments[_key];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (others.length > 0) {
|
|
66
|
-
return times.apply(void 0, [times(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var num1Changed = float2Fixed(num1);
|
|
70
|
-
var num2Changed = float2Fixed(num2);
|
|
71
|
-
var baseNum = digitLength(num1) + digitLength(num2);
|
|
72
|
-
var leftValue = num1Changed * num2Changed;
|
|
73
|
-
checkBoundary(leftValue);
|
|
74
|
-
return leftValue / Math.pow(10, baseNum);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Exact addition
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
function plus(num1, num2) {
|
|
82
|
-
for (var _len2 = arguments.length, others = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
83
|
-
others[_key2 - 2] = arguments[_key2];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (others.length > 0) {
|
|
87
|
-
return plus.apply(void 0, [plus(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
|
91
|
-
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Exact subtraction
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
function minus(num1, num2) {
|
|
99
|
-
for (var _len3 = arguments.length, others = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
100
|
-
others[_key3 - 2] = arguments[_key3];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (others.length > 0) {
|
|
104
|
-
return minus.apply(void 0, [minus(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
|
108
|
-
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Exact division
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
function divide(num1, num2) {
|
|
116
|
-
for (var _len4 = arguments.length, others = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
|
117
|
-
others[_key4 - 2] = arguments[_key4];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (others.length > 0) {
|
|
121
|
-
return divide.apply(void 0, [divide(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
var num1Changed = float2Fixed(num1);
|
|
125
|
-
var num2Changed = float2Fixed(num2);
|
|
126
|
-
checkBoundary(num1Changed);
|
|
127
|
-
checkBoundary(num2Changed); // fix: Similar to 10 ** -4 is 0.00009999999999999999, strip correction
|
|
128
|
-
|
|
129
|
-
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* rounding
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
function round(num, ratio) {
|
|
137
|
-
var base = Math.pow(10, ratio);
|
|
138
|
-
return divide(Math.round(times(num, base)), base);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
var _boundaryCheckingState = true;
|
|
142
|
-
/**
|
|
143
|
-
* Whether to perform boundary check, default true
|
|
144
|
-
* @param flag Mark switch, true is on, false is off, default is true
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
function enableBoundaryChecking() {
|
|
148
|
-
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
149
|
-
_boundaryCheckingState = flag;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export { strip, plus, minus, times, divide, round, digitLength, float2Fixed, enableBoundaryChecking };
|
|
153
|
-
export default {
|
|
154
|
-
strip: strip,
|
|
155
|
-
plus: plus,
|
|
156
|
-
minus: minus,
|
|
157
|
-
times: times,
|
|
158
|
-
divide: divide,
|
|
159
|
-
round: round,
|
|
160
|
-
digitLength: digitLength,
|
|
161
|
-
float2Fixed: float2Fixed,
|
|
162
|
-
enableBoundaryChecking: enableBoundaryChecking
|
|
163
|
-
};
|
package/es/utils/utils.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
var FILEEXT_ICON_MAP = {
|
|
2
|
-
// text file
|
|
3
|
-
md: "txt.png",
|
|
4
|
-
txt: "txt.png",
|
|
5
|
-
// pdf file
|
|
6
|
-
pdf: "pdf.png",
|
|
7
|
-
// document file
|
|
8
|
-
doc: "word.png",
|
|
9
|
-
docx: "word.png",
|
|
10
|
-
odt: "word.png",
|
|
11
|
-
fodt: "word.png",
|
|
12
|
-
ppt: "ppt.png",
|
|
13
|
-
pptx: "ppt.png",
|
|
14
|
-
odp: "ppt.png",
|
|
15
|
-
fodp: "ppt.png",
|
|
16
|
-
xls: "excel.png",
|
|
17
|
-
xlsx: "excel.png",
|
|
18
|
-
ods: "excel.png",
|
|
19
|
-
fods: "excel.png",
|
|
20
|
-
// video
|
|
21
|
-
mp4: "video.png",
|
|
22
|
-
ogv: "video.png",
|
|
23
|
-
webm: "video.png",
|
|
24
|
-
mov: "video.png",
|
|
25
|
-
flv: "video.png",
|
|
26
|
-
wmv: "video.png",
|
|
27
|
-
rmvb: "video.png",
|
|
28
|
-
// music file
|
|
29
|
-
mp3: "music.png",
|
|
30
|
-
oga: "music.png",
|
|
31
|
-
ogg: "music.png",
|
|
32
|
-
flac: "music.png",
|
|
33
|
-
aac: "music.png",
|
|
34
|
-
ac3: "music.png",
|
|
35
|
-
wma: "music.png",
|
|
36
|
-
// image file
|
|
37
|
-
jpg: "pic.png",
|
|
38
|
-
jpeg: "pic.png",
|
|
39
|
-
png: "pic.png",
|
|
40
|
-
svg: "pic.png",
|
|
41
|
-
gif: "pic.png",
|
|
42
|
-
bmp: "pic.png",
|
|
43
|
-
ico: "pic.png",
|
|
44
|
-
// folder dir
|
|
45
|
-
folder: "folder-192.png",
|
|
46
|
-
// default
|
|
47
|
-
default: "file.png"
|
|
48
|
-
};
|
|
49
|
-
export var getFileIconUrl = function getFileIconUrl(filename, direntType) {
|
|
50
|
-
if (direntType === "dir") {
|
|
51
|
-
var _iconUrl = "assets/images/folder/" + FILEEXT_ICON_MAP["folder"];
|
|
52
|
-
|
|
53
|
-
return _iconUrl;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var iconUrl = "";
|
|
57
|
-
|
|
58
|
-
if (filename.lastIndexOf(".") === -1) {
|
|
59
|
-
iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP["default"];
|
|
60
|
-
return iconUrl;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var file_ext = filename.substr(filename.lastIndexOf(".") + 1).toLowerCase();
|
|
64
|
-
|
|
65
|
-
if (FILEEXT_ICON_MAP[file_ext]) {
|
|
66
|
-
iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP[file_ext];
|
|
67
|
-
} else {
|
|
68
|
-
iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP["default"];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return iconUrl;
|
|
72
|
-
};
|
|
73
|
-
export var getImageThumbnailUrl = function getImageThumbnailUrl(url, server) {
|
|
74
|
-
if (server && url.indexOf(server) > -1) {
|
|
75
|
-
return url.replace("/workspace", "/thumbnail/workspace") + "?size=256";
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return url;
|
|
79
|
-
};
|
|
80
|
-
export var debounce = function debounce(fn, wait) {
|
|
81
|
-
var timeout = null;
|
|
82
|
-
return function () {
|
|
83
|
-
if (timeout !== null) clearTimeout(timeout);
|
|
84
|
-
timeout = setTimeout(fn, wait);
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
export var throttle = function throttle(func, delay) {
|
|
88
|
-
var timer = null;
|
|
89
|
-
var startTime = Date.now();
|
|
90
|
-
return function () {
|
|
91
|
-
var curTime = Date.now();
|
|
92
|
-
var remaining = delay - (curTime - startTime);
|
|
93
|
-
var context = this;
|
|
94
|
-
var args = arguments;
|
|
95
|
-
clearTimeout(timer);
|
|
96
|
-
|
|
97
|
-
if (remaining <= 0) {
|
|
98
|
-
func.apply(context, args);
|
|
99
|
-
startTime = Date.now();
|
|
100
|
-
} else {
|
|
101
|
-
timer = setTimeout(func, remaining);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
export var isFunction = function isFunction(functionToCheck) {
|
|
106
|
-
var getType = {};
|
|
107
|
-
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
108
|
-
};
|
|
109
|
-
export var isInternalImg = function isInternalImg(url) {
|
|
110
|
-
if (!url) return;
|
|
111
|
-
return url.indexOf(window.dtable.server) > -1;
|
|
112
|
-
};
|
|
113
|
-
export var checkSVGImage = function checkSVGImage(url) {
|
|
114
|
-
if (!url) return false;
|
|
115
|
-
return url.substr(-4).toLowerCase() === '.svg';
|
|
116
|
-
};
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
import NP from './number-precision';
|
|
3
|
-
import { NUMBER_TYPES, DEFAULT_NUMBER_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS } from './constants';
|
|
4
|
-
NP.enableBoundaryChecking(false);
|
|
5
|
-
var _separatorMap = {
|
|
6
|
-
'comma': ',',
|
|
7
|
-
'dot': '.',
|
|
8
|
-
'no': '',
|
|
9
|
-
'space': ' '
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
var _toThousands = function _toThousands(num, isCurrency, formatData) {
|
|
13
|
-
var _ref = formatData || {},
|
|
14
|
-
_ref$decimal = _ref.decimal,
|
|
15
|
-
decimal = _ref$decimal === void 0 ? 'dot' : _ref$decimal,
|
|
16
|
-
_ref$thousands = _ref.thousands,
|
|
17
|
-
thousands = _ref$thousands === void 0 ? 'no' : _ref$thousands,
|
|
18
|
-
_ref$precision = _ref.precision,
|
|
19
|
-
precision = _ref$precision === void 0 ? 2 : _ref$precision,
|
|
20
|
-
_ref$enable_precision = _ref.enable_precision,
|
|
21
|
-
enable_precision = _ref$enable_precision === void 0 ? false : _ref$enable_precision;
|
|
22
|
-
|
|
23
|
-
var decimalString = _separatorMap[decimal];
|
|
24
|
-
var thousandsString = _separatorMap[thousands];
|
|
25
|
-
var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
|
|
26
|
-
var value = parseFloat(num.toFixed(decimalDigits));
|
|
27
|
-
var integer = Math.trunc(value);
|
|
28
|
-
var decimalValue = String(Math.abs(NP.minus(value, integer)).toFixed(decimalDigits)).slice(1);
|
|
29
|
-
|
|
30
|
-
if (isCurrency) {
|
|
31
|
-
if (decimalValue.length === 2) {
|
|
32
|
-
decimalValue = decimalValue.padEnd(3, '0');
|
|
33
|
-
} else {
|
|
34
|
-
decimalValue = (decimalValue.substring(0, 3) || '.').padEnd(3, '0');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (enable_precision) {
|
|
38
|
-
decimalValue = precision === 0 ? '' : decimalValue.slice(0, precision + 1);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
decimalValue = decimalValue.replace(/./, decimalString);
|
|
43
|
-
var result = [],
|
|
44
|
-
counter = 0;
|
|
45
|
-
integer = Object.is(integer, -0) ? ['-', '0'] : integer.toString().split('');
|
|
46
|
-
|
|
47
|
-
for (var i = integer.length - 1; i >= 0; i--) {
|
|
48
|
-
counter++;
|
|
49
|
-
result.unshift(integer[i]);
|
|
50
|
-
|
|
51
|
-
if (!(counter % 3) && i !== 0) {
|
|
52
|
-
result.unshift(thousandsString);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return result.join('') + decimalValue;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
var _getDecimalDigits = function _getDecimalDigits(num) {
|
|
60
|
-
if (Number.isInteger(num)) {
|
|
61
|
-
return 0;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
var valueArr = (num + '').split('.');
|
|
65
|
-
var digitsLength = valueArr[1] ? valueArr[1].length : 8;
|
|
66
|
-
return digitsLength > 8 ? 8 : digitsLength;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export var formatNumberToString = function formatNumberToString(value, formatData) {
|
|
70
|
-
// formatData: old version maybe 'null'
|
|
71
|
-
var type = Object.prototype.toString.call(value);
|
|
72
|
-
|
|
73
|
-
if (type !== '[object Number]') {
|
|
74
|
-
if (type === '[object String]' && value.startsWith('#')) {
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (isNaN(value) || value === Infinity || value === -Infinity || (value + '').indexOf('e') > -1) return value + '';
|
|
82
|
-
|
|
83
|
-
var _ref2 = formatData || {},
|
|
84
|
-
_ref2$format = _ref2.format,
|
|
85
|
-
format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
|
|
86
|
-
|
|
87
|
-
switch (format) {
|
|
88
|
-
case 'number':
|
|
89
|
-
return _toThousands(value, false, formatData);
|
|
90
|
-
|
|
91
|
-
case 'percent':
|
|
92
|
-
{
|
|
93
|
-
return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
case 'yuan':
|
|
97
|
-
return "\uFFE5".concat(_toThousands(value, true, formatData));
|
|
98
|
-
|
|
99
|
-
case 'dollar':
|
|
100
|
-
return "$".concat(_toThousands(value, true, formatData));
|
|
101
|
-
|
|
102
|
-
case 'euro':
|
|
103
|
-
return "\u20AC".concat(_toThousands(value, true, formatData));
|
|
104
|
-
|
|
105
|
-
case 'duration':
|
|
106
|
-
{
|
|
107
|
-
return getDurationDisplayString(value, formatData.duration_format);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
default:
|
|
111
|
-
return '' + value;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
export var formatStringToNumber = function formatStringToNumber(value) {
|
|
115
|
-
var isIncludePercent = value.indexOf('%') > -1;
|
|
116
|
-
var newData = parseFloat(value.replace(/[^.-\d]/g, ''));
|
|
117
|
-
|
|
118
|
-
if (isIncludePercent && !isNaN(newData)) {
|
|
119
|
-
return newData / 100;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return isNaN(newData) ? '' : newData;
|
|
123
|
-
};
|
|
124
|
-
export var formatNumberString = function formatNumberString(value, format) {
|
|
125
|
-
var formatedValue = '';
|
|
126
|
-
|
|
127
|
-
switch (format) {
|
|
128
|
-
case NUMBER_TYPES.NUMBER:
|
|
129
|
-
case NUMBER_TYPES.NUMBER_WITH_COMMAS:
|
|
130
|
-
formatedValue = value.replace(/[^.-\d,]/g, '');
|
|
131
|
-
break;
|
|
132
|
-
|
|
133
|
-
case NUMBER_TYPES.PERCENT:
|
|
134
|
-
formatedValue = value.replace(/[^.-\d,%]/g, '');
|
|
135
|
-
break;
|
|
136
|
-
|
|
137
|
-
case NUMBER_TYPES.YUAN:
|
|
138
|
-
formatedValue = value.replace(/[^.-\d¥,]/g, '');
|
|
139
|
-
break;
|
|
140
|
-
|
|
141
|
-
case NUMBER_TYPES.DOLLAR:
|
|
142
|
-
formatedValue = value.replace(/[^.-\d$,]/g, '');
|
|
143
|
-
break;
|
|
144
|
-
|
|
145
|
-
case NUMBER_TYPES.EURO:
|
|
146
|
-
formatedValue = value.replace(/[^.-\d€,]/g, '');
|
|
147
|
-
break;
|
|
148
|
-
|
|
149
|
-
default:
|
|
150
|
-
formatedValue = value.replace(/[^.-\d,]/g, '');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return formatedValue;
|
|
154
|
-
};
|
|
155
|
-
export var formatDateToString = function formatDateToString(value, format) {
|
|
156
|
-
var formatedValue = '';
|
|
157
|
-
|
|
158
|
-
if (!value) {
|
|
159
|
-
// value === '', value === undefine, value === null
|
|
160
|
-
return formatedValue;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
var date = moment(value);
|
|
164
|
-
if (!date.isValid()) return value;
|
|
165
|
-
|
|
166
|
-
switch (format) {
|
|
167
|
-
case 'D/M/YYYY':
|
|
168
|
-
case 'DD/MM/YYYY':
|
|
169
|
-
var formatValue = date.format('YYYY-MM-DD');
|
|
170
|
-
var formatValueList = formatValue.split('-');
|
|
171
|
-
return "".concat(formatValueList[2], "/").concat(formatValueList[1], "/").concat(formatValueList[0]);
|
|
172
|
-
|
|
173
|
-
case 'D/M/YYYY HH:mm':
|
|
174
|
-
case 'DD/MM/YYYY HH:mm':
|
|
175
|
-
var formatValues = date.format('YYYY-MM-DD HH:mm');
|
|
176
|
-
var formatValuesList = formatValues.split(' ');
|
|
177
|
-
var formatDateList = formatValuesList[0].split('-');
|
|
178
|
-
return "".concat(formatDateList[2], "/").concat(formatDateList[1], "/").concat(formatDateList[0], " ").concat(formatValuesList[1]);
|
|
179
|
-
|
|
180
|
-
case 'M/D/YYYY':
|
|
181
|
-
return date.format('M/D/YYYY');
|
|
182
|
-
|
|
183
|
-
case 'M/D/YYYY HH:mm':
|
|
184
|
-
return date.format('M/D/YYYY HH:mm');
|
|
185
|
-
|
|
186
|
-
case 'YYYY-MM-DD':
|
|
187
|
-
return date.format('YYYY-MM-DD');
|
|
188
|
-
|
|
189
|
-
case 'YYYY-MM-DD HH:mm':
|
|
190
|
-
return date.format('YYYY-MM-DD HH:mm');
|
|
191
|
-
|
|
192
|
-
default:
|
|
193
|
-
return value;
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
export var getDurationDisplayString = function getDurationDisplayString(value, duration_format) {
|
|
197
|
-
if (!value && value !== 0) return '';
|
|
198
|
-
duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
|
|
199
|
-
|
|
200
|
-
if (DURATION_FORMATS.findIndex(function (format) {
|
|
201
|
-
return format.type === duration_format;
|
|
202
|
-
}) < 0) {
|
|
203
|
-
return '';
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (value === 0) {
|
|
207
|
-
return DURATION_ZERO_DISPLAY[duration_format];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
var includeDecimal = duration_format.indexOf('.') > -1;
|
|
211
|
-
var positiveValue = Math.abs(value);
|
|
212
|
-
|
|
213
|
-
if (!includeDecimal) {
|
|
214
|
-
positiveValue = Math.round(positiveValue);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
positiveValue = getMathRoundedDuration(positiveValue, duration_format);
|
|
218
|
-
var decimalParts = (positiveValue + '').split('.');
|
|
219
|
-
var decimalPartsLen = decimalParts.length;
|
|
220
|
-
var decimal = 0;
|
|
221
|
-
|
|
222
|
-
if (decimalPartsLen > 1) {
|
|
223
|
-
decimal = decimalParts[decimalPartsLen - 1];
|
|
224
|
-
decimal = decimal ? decimal - 0 : 0;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
228
|
-
var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
|
|
229
|
-
var displayString = value < 0 ? '-' : '';
|
|
230
|
-
var hours = parseInt(positiveValue / 3600);
|
|
231
|
-
var minutes = parseInt((positiveValue - hours * 3600) / 60);
|
|
232
|
-
|
|
233
|
-
if (duration_format === DURATION_FORMATS_MAP.H_MM) {
|
|
234
|
-
displayString += "".concat(hours, ":").concat(minutes > 9 ? minutes : '0' + minutes);
|
|
235
|
-
return displayString;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
|
|
239
|
-
|
|
240
|
-
if (hours > 0) {
|
|
241
|
-
displayString += "".concat(hours, ":");
|
|
242
|
-
minutes = minutes > 9 ? minutes : "0".concat(minutes);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
seconds = seconds > 9 ? seconds : "0".concat(seconds);
|
|
246
|
-
displayString += "".concat(minutes, ":").concat(seconds).concat(decimalSuffix);
|
|
247
|
-
return displayString;
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
var getMathRoundedDuration = function getMathRoundedDuration(num, duration_format) {
|
|
251
|
-
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
252
|
-
|
|
253
|
-
if (decimalDigits < 1) {
|
|
254
|
-
return num;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
var ratio = Math.pow(10, decimalDigits);
|
|
258
|
-
return Math.round(num * ratio) / ratio;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format, decimal) {
|
|
262
|
-
if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
|
|
263
|
-
return decimal === 0 ? '.0' : '';
|
|
264
|
-
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
|
|
265
|
-
if (decimal === 0) {
|
|
266
|
-
return '.00';
|
|
267
|
-
} else if (decimal < 10) {
|
|
268
|
-
return '0';
|
|
269
|
-
}
|
|
270
|
-
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
|
|
271
|
-
if (decimal === 0) {
|
|
272
|
-
return '.000';
|
|
273
|
-
} else if (decimal < 10) {
|
|
274
|
-
return '00';
|
|
275
|
-
} else if (decimal < 100) {
|
|
276
|
-
return '0';
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return '';
|
|
281
|
-
};
|