dtable-ui-component 0.3.5 → 0.3.6-beta.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/lib/DateEditor/index.js +1 -1
- package/lib/DateEditor/mb-date-editor-popover/index.js +3 -3
- package/lib/DateFormatter/index.js +3 -15
- package/lib/DurationFormatter/index.js +1 -1
- package/lib/FormulaFormatter/index.js +1 -2
- package/lib/GeolocationFormatter/index.js +9 -4
- package/lib/LinkEditor/index.js +1 -1
- package/lib/LinkFormatter/index.js +3 -4
- package/lib/NumberEditor/index.js +1 -1
- package/lib/NumberFormatter/index.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +2 -6
- package/lib/RowExpandLinkFormatter/value-display-utils.js +10 -398
- package/lib/constants/index.js +2 -33
- package/lib/data/dtable-value.js +1 -6
- package/lib/index.js +1 -3
- package/lib/utils/utils.js +0 -14
- package/package.json +3 -1
- package/lib/RowExpandLinkFormatter/column-data-constants.js +0 -20
- package/lib/RowExpandLinkFormatter/date-utils.js +0 -127
- package/lib/RowExpandLinkFormatter/formula-constants.js +0 -9
- package/lib/RowExpandLinkFormatter/number-precision.js +0 -116
- package/lib/constants/cell-types.js +0 -29
- package/lib/utils/number-precision.js +0 -164
- package/lib/utils/value-format-utils.js +0 -587
package/lib/constants/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
var _DURATION_ZERO_DISPLA, _DURATION_DECIMAL_DIG;
|
|
4
|
-
|
|
5
|
-
import * as CellType from './cell-types';
|
|
1
|
+
import { CellType, FORMULA_RESULT_TYPE } from '@seafile/dtable-utils';
|
|
6
2
|
var NUMBER_TYPES = {
|
|
7
3
|
'NUMBER': 'number',
|
|
8
4
|
'NUMBER_WITH_COMMAS': 'number-with-commas',
|
|
@@ -20,34 +16,7 @@ var DATE_TYPES = {
|
|
|
20
16
|
'YYYY-MM-DD': 'YYYY-MM-DD',
|
|
21
17
|
'YYYY-MM-DD HH:mm': 'YYYY-MM-DD HH:mm'
|
|
22
18
|
};
|
|
23
|
-
var FORMULA_RESULT_TYPE = {
|
|
24
|
-
NUMBER: 'number',
|
|
25
|
-
STRING: 'string',
|
|
26
|
-
DATE: 'date',
|
|
27
|
-
BOOL: 'bool',
|
|
28
|
-
ARRAY: 'array'
|
|
29
|
-
};
|
|
30
19
|
var SIMPLE_CELL_COLUMNS = [CellType.TEXT, CellType.NUMBER, CellType.DATE, CellType.CTIME, CellType.MTIME, CellType.GEOLOCATION, CellType.AUTO_NUMBER, CellType.URL, CellType.EMAIL, CellType.DURATION, CellType.CHECKBOX, CellType.RATE];
|
|
31
20
|
var ARRAY_FORMAL_COLUMNS = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
|
|
32
21
|
var SIMPLE_CELL_FORMULA_RESULTS = [FORMULA_RESULT_TYPE.NUMBER, FORMULA_RESULT_TYPE.STRING, FORMULA_RESULT_TYPE.DATE, FORMULA_RESULT_TYPE.BOOL];
|
|
33
|
-
|
|
34
|
-
var ARRAY_FORMAL_COLUMNS_TYPES = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
|
|
35
|
-
var DEFAULT_NUMBER_FORMAT = 'number';
|
|
36
|
-
var DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
|
|
37
|
-
var DURATION_FORMATS_MAP = {
|
|
38
|
-
H_MM: 'h:mm',
|
|
39
|
-
H_MM_SS: 'h:mm:ss',
|
|
40
|
-
H_MM_SS_S: 'h:mm:ss.s',
|
|
41
|
-
H_MM_SS_SS: 'h:mm:ss.ss',
|
|
42
|
-
H_MM_SS_SSS: 'h:mm:ss.sss'
|
|
43
|
-
};
|
|
44
|
-
var DURATION_FORMATS = [{
|
|
45
|
-
name: DURATION_FORMATS_MAP.H_MM,
|
|
46
|
-
type: DURATION_FORMATS_MAP.H_MM
|
|
47
|
-
}, {
|
|
48
|
-
name: DURATION_FORMATS_MAP.H_MM_SS,
|
|
49
|
-
type: DURATION_FORMATS_MAP.H_MM_SS
|
|
50
|
-
}];
|
|
51
|
-
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);
|
|
52
|
-
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);
|
|
53
|
-
export { CellType, NUMBER_TYPES, DATE_TYPES, FORMULA_RESULT_TYPE, SIMPLE_CELL_COLUMNS, ARRAY_FORMAL_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS, COLLABORATOR_COLUMN_TYPES, ARRAY_FORMAL_COLUMNS_TYPES, DEFAULT_NUMBER_FORMAT, DEFAULT_DATE_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS };
|
|
22
|
+
export { CellType, NUMBER_TYPES, DATE_TYPES, FORMULA_RESULT_TYPE, SIMPLE_CELL_COLUMNS, ARRAY_FORMAL_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS };
|
package/lib/data/dtable-value.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
3
|
-
var _COLUMNS_ICON_CONFIG;
|
|
4
|
-
|
|
5
1
|
import { CellType } from '../constants';
|
|
6
2
|
var DTABLE_VALUE = {
|
|
7
3
|
'tables': [{
|
|
@@ -2693,7 +2689,6 @@ var DTABLE_VALUE = {
|
|
|
2693
2689
|
'header_settings': {}
|
|
2694
2690
|
}]
|
|
2695
2691
|
};
|
|
2696
|
-
var COLUMNS_ICON_CONFIG = (_COLUMNS_ICON_CONFIG = {}, _defineProperty(_COLUMNS_ICON_CONFIG, CellType.DEFAULT, 'dtable-font dtable-icon-single-line-text'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.TEXT, 'dtable-font dtable-icon-single-line-text'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.NUMBER, 'dtable-font dtable-icon-number'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.CHECKBOX, 'dtable-font dtable-icon-check-square-solid'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.DATE, 'dtable-font dtable-icon-calendar-alt-solid'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.SINGLE_SELECT, 'dtable-font dtable-icon-single-election'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.LONG_TEXT, 'dtable-font dtable-icon-long-text'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.IMAGE, 'dtable-font dtable-icon-picture'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.FILE, 'dtable-font dtable-icon-file-alt-solid'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.MULTIPLE_SELECT, 'dtable-font dtable-icon-multiple-selection'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.COLLABORATOR, 'dtable-font dtable-icon-collaborator'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.LINK, 'dtable-font dtable-icon-link-other-record'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.FORMULA, 'dtable-font dtable-icon-formula'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.LINK_FORMULA, 'dtable-font dtable-icon-link-formulas'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.CREATOR, 'dtable-font dtable-icon-creator'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.CTIME, 'dtable-font dtable-icon-creation-time'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.LAST_MODIFIER, 'dtable-font dtable-icon-creator'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.MTIME, 'dtable-font dtable-icon-creation-time'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.GEOLOCATION, 'dtable-font dtable-icon-location'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.AUTO_NUMBER, 'dtable-font dtable-icon-autonumber'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.URL, 'dtable-font dtable-icon-url'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.EMAIL, 'dtable-font dtable-icon-email'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.DURATION, 'dtable-font dtable-icon-duration'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.BUTTON, 'dtable-font dtable-icon-button'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.RATE, 'dtable-font dtable-icon-star'), _defineProperty(_COLUMNS_ICON_CONFIG, CellType.DIGITAL_SIGN, 'dtable-font dtable-icon-handwritten-signature'), _COLUMNS_ICON_CONFIG);
|
|
2697
2692
|
var COLLABORATORS = [{
|
|
2698
2693
|
'avatar_url': 'https://dev.seatable.cn/image-view/avatars/0/0/916e1e9e7c6184061cb7d96a680292/resized/80/de58ef113a311d390934b06ceafd77cf.png',
|
|
2699
2694
|
'contact_email': '',
|
|
@@ -2728,4 +2723,4 @@ var SIGN_CONFIG = {
|
|
|
2728
2723
|
workspaceID: 3,
|
|
2729
2724
|
dtableUuid: '8327efbf-c9ff-4a14-9010-00e801a7e295'
|
|
2730
2725
|
};
|
|
2731
|
-
export { DTABLE_VALUE,
|
|
2726
|
+
export { DTABLE_VALUE, COLLABORATORS, SIGN_CONFIG };
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
export { default as toaster } from './toaster'; // Loading
|
|
3
3
|
|
|
4
4
|
export { default as Loading } from './Loading';
|
|
5
|
-
export { setLocale } from './lang'; //
|
|
6
|
-
|
|
7
|
-
export { getDateDisplayString, getNumberDisplayString, formatStringToNumber } from './utils/value-format-utils'; // formatter
|
|
5
|
+
export { setLocale } from './lang'; // formatter
|
|
8
6
|
|
|
9
7
|
export { default as CheckboxFormatter } from './CheckboxFormatter';
|
|
10
8
|
export { default as ImageFormatter } from './ImageFormatter';
|
package/lib/utils/utils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import NP from './number-precision';
|
|
2
1
|
export var debounce = function debounce(fn, wait) {
|
|
3
2
|
var timeout = null;
|
|
4
3
|
return function () {
|
|
@@ -24,19 +23,6 @@ export var throttle = function throttle(func, delay) {
|
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
|
-
export var getFloatNumber = function getFloatNumber(data, format) {
|
|
28
|
-
if (!data && data !== 0) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var newData = parseFloat(data.replace(/[^.-\d]/g, ''));
|
|
33
|
-
|
|
34
|
-
if (format === 'percent' && !isNaN(newData)) {
|
|
35
|
-
return NP.divide(newData, 100);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return isNaN(newData) ? null : newData;
|
|
39
|
-
};
|
|
40
26
|
export var isMac = function isMac() {
|
|
41
27
|
var platform = navigator.platform; // eslint-disable-next-line eqeqeq
|
|
42
28
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6-beta.2",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
|
+
"@seafile/dtable-utils": "0.0.5",
|
|
6
7
|
"@seafile/react-image-lightbox": "0.0.9",
|
|
7
8
|
"@seafile/seafile-calendar": "0.0.24",
|
|
8
9
|
"@seafile/seafile-editor": "0.3.121",
|
|
@@ -97,6 +98,7 @@
|
|
|
97
98
|
"babel-eslint": "10.0.3",
|
|
98
99
|
"babel-jest": "^24.9.0",
|
|
99
100
|
"babel-loader": "8.0.6",
|
|
101
|
+
"babel-plugin-import": "^1.13.6",
|
|
100
102
|
"babel-plugin-named-asset-import": "^0.3.6",
|
|
101
103
|
"babel-preset-react-app": "^9.1.1",
|
|
102
104
|
"camelcase": "^5.3.1",
|
|
@@ -1,20 +0,0 @@
|
|
|
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);
|
|
@@ -1,127 +0,0 @@
|
|
|
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;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
|
|
3
|
-
function strip(num) {
|
|
4
|
-
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
|
|
5
|
-
return +parseFloat(num.toPrecision(precision));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function digitLength(num) {
|
|
9
|
-
// Get digit length of e
|
|
10
|
-
var eSplit = num.toString().split(/[eE]/);
|
|
11
|
-
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
|
|
12
|
-
return len > 0 ? len : 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function float2Fixed(num) {
|
|
16
|
-
if (num.toString().indexOf('e') === -1) {
|
|
17
|
-
return Number(num.toString().replace('.', ''));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var dLen = digitLength(num);
|
|
21
|
-
return dLen > 0 ? strip(num * Math.pow(10, dLen)) : num;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function checkBoundary(num) {
|
|
25
|
-
if (_boundaryCheckingState) {
|
|
26
|
-
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.warn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function times(num1, num2) {
|
|
34
|
-
for (var _len = arguments.length, others = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
35
|
-
others[_key - 2] = arguments[_key];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (others.length > 0) {
|
|
39
|
-
return times.apply(void 0, [times(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var num1Changed = float2Fixed(num1);
|
|
43
|
-
var num2Changed = float2Fixed(num2);
|
|
44
|
-
var baseNum = digitLength(num1) + digitLength(num2);
|
|
45
|
-
var leftValue = num1Changed * num2Changed;
|
|
46
|
-
checkBoundary(leftValue);
|
|
47
|
-
return leftValue / Math.pow(10, baseNum);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function plus(num1, num2) {
|
|
51
|
-
for (var _len2 = arguments.length, others = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
52
|
-
others[_key2 - 2] = arguments[_key2];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (others.length > 0) {
|
|
56
|
-
return plus.apply(void 0, [plus(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
|
60
|
-
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function minus(num1, num2) {
|
|
64
|
-
for (var _len3 = arguments.length, others = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
65
|
-
others[_key3 - 2] = arguments[_key3];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (others.length > 0) {
|
|
69
|
-
return minus.apply(void 0, [minus(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
|
73
|
-
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function divide(num1, num2) {
|
|
77
|
-
for (var _len4 = arguments.length, others = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
|
78
|
-
others[_key4 - 2] = arguments[_key4];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (others.length > 0) {
|
|
82
|
-
return divide.apply(void 0, [divide(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
var num1Changed = float2Fixed(num1);
|
|
86
|
-
var num2Changed = float2Fixed(num2);
|
|
87
|
-
checkBoundary(num1Changed);
|
|
88
|
-
checkBoundary(num2Changed); // fix: Similar to 10 ** -4 is 0.00009999999999999999, strip correction
|
|
89
|
-
|
|
90
|
-
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function round(num, ratio) {
|
|
94
|
-
var base = Math.pow(10, ratio);
|
|
95
|
-
return divide(Math.round(times(num, base)), base);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
var _boundaryCheckingState = true;
|
|
99
|
-
|
|
100
|
-
function enableBoundaryChecking() {
|
|
101
|
-
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
102
|
-
_boundaryCheckingState = flag;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export { strip, plus, minus, times, divide, round, digitLength, float2Fixed, enableBoundaryChecking };
|
|
106
|
-
export default {
|
|
107
|
-
strip: strip,
|
|
108
|
-
plus: plus,
|
|
109
|
-
minus: minus,
|
|
110
|
-
times: times,
|
|
111
|
-
divide: divide,
|
|
112
|
-
round: round,
|
|
113
|
-
digitLength: digitLength,
|
|
114
|
-
float2Fixed: float2Fixed,
|
|
115
|
-
enableBoundaryChecking: enableBoundaryChecking
|
|
116
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export var DEFAULT = 'default';
|
|
2
|
-
export var NUMBER = 'number';
|
|
3
|
-
export var TEXT = 'text';
|
|
4
|
-
export var CHECKBOX = 'checkbox';
|
|
5
|
-
export var DATE = 'date';
|
|
6
|
-
export var SINGLE_SELECT = 'single-select';
|
|
7
|
-
export var LONG_TEXT = 'long-text';
|
|
8
|
-
export var IMAGE = 'image';
|
|
9
|
-
export var FILE = 'file';
|
|
10
|
-
export var MULTIPLE_SELECT = 'multiple-select';
|
|
11
|
-
export var COLLABORATOR = 'collaborator';
|
|
12
|
-
export var LINK = 'link';
|
|
13
|
-
export var FORMULA = 'formula';
|
|
14
|
-
export var LINK_FORMULA = 'link-formula';
|
|
15
|
-
export var CREATOR = 'creator';
|
|
16
|
-
export var CTIME = 'ctime';
|
|
17
|
-
export var LAST_MODIFIER = 'last-modifier';
|
|
18
|
-
export var MTIME = 'mtime';
|
|
19
|
-
export var GEOLOCATION = 'geolocation';
|
|
20
|
-
export var AUTO_NUMBER = 'auto-number';
|
|
21
|
-
export var URL = 'url';
|
|
22
|
-
export var EMAIL = 'email';
|
|
23
|
-
export var DURATION = 'duration';
|
|
24
|
-
export var RATE = 'rate';
|
|
25
|
-
export var BUTTON = 'button';
|
|
26
|
-
export var DIGITAL_SIGN = 'digital-sign'; // formula | link-formula column calculate result type
|
|
27
|
-
|
|
28
|
-
export var BOOL = 'bool';
|
|
29
|
-
export var STRING = 'string';
|
|
@@ -1,164 +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
|
-
// eslint-disable-next-line no-console
|
|
52
|
-
console.warn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Exact multiplication
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
function times(num1, num2) {
|
|
62
|
-
for (var _len = arguments.length, others = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
63
|
-
others[_key - 2] = arguments[_key];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (others.length > 0) {
|
|
67
|
-
return times.apply(void 0, [times(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var num1Changed = float2Fixed(num1);
|
|
71
|
-
var num2Changed = float2Fixed(num2);
|
|
72
|
-
var baseNum = digitLength(num1) + digitLength(num2);
|
|
73
|
-
var leftValue = num1Changed * num2Changed;
|
|
74
|
-
checkBoundary(leftValue);
|
|
75
|
-
return leftValue / Math.pow(10, baseNum);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Exact addition
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
function plus(num1, num2) {
|
|
83
|
-
for (var _len2 = arguments.length, others = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
84
|
-
others[_key2 - 2] = arguments[_key2];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (others.length > 0) {
|
|
88
|
-
return plus.apply(void 0, [plus(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
|
92
|
-
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Exact subtraction
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
function minus(num1, num2) {
|
|
100
|
-
for (var _len3 = arguments.length, others = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
101
|
-
others[_key3 - 2] = arguments[_key3];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (others.length > 0) {
|
|
105
|
-
return minus.apply(void 0, [minus(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
|
109
|
-
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Exact division
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
function divide(num1, num2) {
|
|
117
|
-
for (var _len4 = arguments.length, others = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
|
118
|
-
others[_key4 - 2] = arguments[_key4];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (others.length > 0) {
|
|
122
|
-
return divide.apply(void 0, [divide(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
var num1Changed = float2Fixed(num1);
|
|
126
|
-
var num2Changed = float2Fixed(num2);
|
|
127
|
-
checkBoundary(num1Changed);
|
|
128
|
-
checkBoundary(num2Changed); // fix: Similar to 10 ** -4 is 0.00009999999999999999, strip correction
|
|
129
|
-
|
|
130
|
-
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* rounding
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function round(num, ratio) {
|
|
138
|
-
var base = Math.pow(10, ratio);
|
|
139
|
-
return divide(Math.round(times(num, base)), base);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
var _boundaryCheckingState = true;
|
|
143
|
-
/**
|
|
144
|
-
* Whether to perform boundary check, default true
|
|
145
|
-
* @param flag Mark switch, true is on, false is off, default is true
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
function enableBoundaryChecking() {
|
|
149
|
-
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
150
|
-
_boundaryCheckingState = flag;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export { strip, plus, minus, times, divide, round, digitLength, float2Fixed, enableBoundaryChecking };
|
|
154
|
-
export default {
|
|
155
|
-
strip: strip,
|
|
156
|
-
plus: plus,
|
|
157
|
-
minus: minus,
|
|
158
|
-
times: times,
|
|
159
|
-
divide: divide,
|
|
160
|
-
round: round,
|
|
161
|
-
digitLength: digitLength,
|
|
162
|
-
float2Fixed: float2Fixed,
|
|
163
|
-
enableBoundaryChecking: enableBoundaryChecking
|
|
164
|
-
};
|