dtable-ui-component 0.1.99 → 0.1.102
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/DurationFormatter/index.js +3 -1
- package/lib/LinkEditor/link-editor-option.js +2 -1
- package/lib/LinkEditor/mb-link-editor-popover/index.js +2 -1
- package/lib/LinkEditor/pc-link-editor-popover/index.js +2 -1
- package/lib/NumberEditor/index.js +13 -5
- package/lib/SelectItem/index.js +2 -1
- package/lib/SimpleLongTextFormatter/index.js +5 -0
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +1 -0
- package/lib/SingleSelectFormatter/index.js +1 -9
- package/lib/constants/index.js +8 -4
- package/lib/index.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +2 -1
- package/lib/select-editor/pc-select-editor-popover/index.js +2 -1
- package/lib/select-editor/select-editor-option.js +2 -1
- package/lib/utils/utils.js +19 -0
- package/lib/utils/value-format-utils.js +130 -91
- package/package.json +2 -2
|
@@ -28,7 +28,9 @@ var DurationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
28
28
|
var classname = cn('dtable-ui cell-formatter-container duration-formatter', containerClassName);
|
|
29
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
30
30
|
className: classname
|
|
31
|
-
}, getDurationDisplayString(value,
|
|
31
|
+
}, getDurationDisplayString(value, {
|
|
32
|
+
duration_format: format
|
|
33
|
+
}));
|
|
32
34
|
}
|
|
33
35
|
}]);
|
|
34
36
|
|
|
@@ -89,7 +89,8 @@ var LinkEditorOption = /*#__PURE__*/function (_React$Component) {
|
|
|
89
89
|
style: optionStyle
|
|
90
90
|
}, /*#__PURE__*/React.createElement("div", {
|
|
91
91
|
className: "option-name",
|
|
92
|
-
style: optionNameStyle
|
|
92
|
+
style: optionNameStyle,
|
|
93
|
+
title: option.name
|
|
93
94
|
}, option.name)), isShowRemoveIcon && /*#__PURE__*/React.createElement("div", {
|
|
94
95
|
className: "option-remove",
|
|
95
96
|
style: operationStyle,
|
|
@@ -91,7 +91,8 @@ var MBLinkEditorPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
91
91
|
}, /*#__PURE__*/React.createElement("span", {
|
|
92
92
|
className: "mb-option-info"
|
|
93
93
|
}, /*#__PURE__*/React.createElement("span", {
|
|
94
|
-
className: "option-name"
|
|
94
|
+
className: "option-name",
|
|
95
|
+
title: option.name
|
|
95
96
|
}, option.name)), isSelect && /*#__PURE__*/React.createElement("i", {
|
|
96
97
|
className: "mb-option-checked dtable-font dtable-icon-check-mark"
|
|
97
98
|
}));
|
|
@@ -93,7 +93,8 @@ var PCLinkEditorPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
93
93
|
}, /*#__PURE__*/React.createElement("div", {
|
|
94
94
|
className: "option-info"
|
|
95
95
|
}, /*#__PURE__*/React.createElement("div", {
|
|
96
|
-
className: "option-name"
|
|
96
|
+
className: "option-name",
|
|
97
|
+
title: option.name
|
|
97
98
|
}, option.name)), /*#__PURE__*/React.createElement("div", {
|
|
98
99
|
className: "option-checked"
|
|
99
100
|
}, isSelect && /*#__PURE__*/React.createElement("i", {
|
|
@@ -5,7 +5,8 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import isHotkey from 'is-hotkey';
|
|
7
7
|
import { NUMBER_TYPES } from '../constants';
|
|
8
|
-
import { getNumberDisplayString, formatStringToNumber,
|
|
8
|
+
import { getNumberDisplayString, formatStringToNumber, replaceNumberNotAllowInput } from '../utils/value-format-utils';
|
|
9
|
+
import { isMac } from '../utils/utils';
|
|
9
10
|
|
|
10
11
|
var NumberEditor = /*#__PURE__*/function (_React$Component) {
|
|
11
12
|
_inherits(NumberEditor, _React$Component);
|
|
@@ -51,12 +52,19 @@ var NumberEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
_this.onChange = function (event) {
|
|
55
|
+
var data = _this.props.column.data; // data maybe 'null'
|
|
56
|
+
|
|
54
57
|
var value = event.target.value.trim();
|
|
55
|
-
|
|
58
|
+
var currency_symbol = null;
|
|
56
59
|
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
+
if (data && data.format === 'custom_currency') {
|
|
61
|
+
currency_symbol = data['currency_symbol'];
|
|
62
|
+
} //Prevent the repetition of periods bug in the Chinese input method of the Windows system
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if (!isMac() && value.indexOf('.。') > -1) return;
|
|
66
|
+
value = replaceNumberNotAllowInput(value, _this.dataFormat, currency_symbol);
|
|
67
|
+
if (value === _this.state.inputValue) return;
|
|
60
68
|
|
|
61
69
|
_this.setState({
|
|
62
70
|
inputValue: value
|
package/lib/SelectItem/index.js
CHANGED
|
@@ -47,7 +47,8 @@ var SelectItem = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
47
47
|
var style = this.getStyle(option, fontSize);
|
|
48
48
|
return /*#__PURE__*/React.createElement("div", {
|
|
49
49
|
className: "dtable-ui select-item",
|
|
50
|
-
style: style
|
|
50
|
+
style: style,
|
|
51
|
+
title: option.name
|
|
51
52
|
}, option.name);
|
|
52
53
|
}
|
|
53
54
|
}]);
|
|
@@ -122,6 +122,11 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
_createClass(SimpleLongTextFormatter, [{
|
|
125
|
+
key: "componentWillUnmount",
|
|
126
|
+
value: function componentWillUnmount() {
|
|
127
|
+
this.clearTimer();
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
125
130
|
key: "render",
|
|
126
131
|
value: function render() {
|
|
127
132
|
var _this2 = this;
|
|
@@ -27,6 +27,7 @@ var DtableMarkdownViewer = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
27
27
|
var index = appVersionList.findIndex(function (version) {
|
|
28
28
|
return version.indexOf('Chrome') >= 0;
|
|
29
29
|
});
|
|
30
|
+
if (index === -1) return;
|
|
30
31
|
var chromeVersion = appVersionList[index];
|
|
31
32
|
chromeVersion = parseInt(chromeVersion.slice(chromeVersion.indexOf('/') + 1));
|
|
32
33
|
|
|
@@ -50,17 +50,9 @@ var SingleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
50
50
|
containerClassName = _this$props2.containerClassName,
|
|
51
51
|
value = _this$props2.value;
|
|
52
52
|
var classname = cn('dtable-ui cell-formatter-container single-select-formatter', containerClassName);
|
|
53
|
-
|
|
54
|
-
if (!value) {
|
|
55
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
56
|
-
className: classname
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var option = this.getOption();
|
|
61
53
|
return /*#__PURE__*/React.createElement("div", {
|
|
62
54
|
className: classname
|
|
63
|
-
},
|
|
55
|
+
}, value ? this.getOption() : '');
|
|
64
56
|
}
|
|
65
57
|
}]);
|
|
66
58
|
|
package/lib/constants/index.js
CHANGED
|
@@ -9,7 +9,8 @@ var NUMBER_TYPES = {
|
|
|
9
9
|
'PERCENT': 'percent',
|
|
10
10
|
'YUAN': 'yuan',
|
|
11
11
|
'EURO': 'euro',
|
|
12
|
-
'DOLLAR': 'dollar'
|
|
12
|
+
'DOLLAR': 'dollar',
|
|
13
|
+
'CUSTOM_CURRENCY': 'custom_currency'
|
|
13
14
|
};
|
|
14
15
|
var DATE_TYPES = {
|
|
15
16
|
'D/M/YYYY': 'D/M/YYYY',
|
|
@@ -35,7 +36,10 @@ var DEFAULT_NUMBER_FORMAT = 'number';
|
|
|
35
36
|
var DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
|
|
36
37
|
var DURATION_FORMATS_MAP = {
|
|
37
38
|
H_MM: 'h:mm',
|
|
38
|
-
H_MM_SS: 'h:mm:ss'
|
|
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'
|
|
39
43
|
};
|
|
40
44
|
var DURATION_FORMATS = [{
|
|
41
45
|
name: DURATION_FORMATS_MAP.H_MM,
|
|
@@ -44,6 +48,6 @@ var DURATION_FORMATS = [{
|
|
|
44
48
|
name: DURATION_FORMATS_MAP.H_MM_SS,
|
|
45
49
|
type: DURATION_FORMATS_MAP.H_MM_SS
|
|
46
50
|
}];
|
|
47
|
-
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'), _DURATION_ZERO_DISPLA);
|
|
48
|
-
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), _DURATION_DECIMAL_DIG);
|
|
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);
|
|
49
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 };
|
package/lib/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { default as toaster } from './toaster'; // Loading
|
|
|
4
4
|
export { default as Loading } from './Loading';
|
|
5
5
|
export { setLocale } from './lang'; // utils
|
|
6
6
|
|
|
7
|
-
export { getDateDisplayString, getNumberDisplayString, formatStringToNumber
|
|
7
|
+
export { getDateDisplayString, getNumberDisplayString, formatStringToNumber } from './utils/value-format-utils'; // formatter
|
|
8
8
|
|
|
9
9
|
export { default as CheckboxFormatter } from './CheckboxFormatter';
|
|
10
10
|
export { default as ImageFormatter } from './ImageFormatter';
|
|
@@ -110,7 +110,8 @@ var MBSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
110
110
|
className: "mb-select-item"
|
|
111
111
|
}, /*#__PURE__*/React.createElement("span", {
|
|
112
112
|
className: "item-name",
|
|
113
|
-
style: style
|
|
113
|
+
style: style,
|
|
114
|
+
title: option.name
|
|
114
115
|
}, option.name)), /*#__PURE__*/React.createElement("span", {
|
|
115
116
|
className: "mb-item-checked"
|
|
116
117
|
}, isSelect && /*#__PURE__*/React.createElement("i", {
|
|
@@ -116,7 +116,8 @@ var PCSelectEditorPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
116
116
|
className: "option-info"
|
|
117
117
|
}, /*#__PURE__*/React.createElement("div", {
|
|
118
118
|
className: "option-name",
|
|
119
|
-
style: optionStyle
|
|
119
|
+
style: optionStyle,
|
|
120
|
+
title: option.name
|
|
120
121
|
}, option.name)), /*#__PURE__*/React.createElement("div", {
|
|
121
122
|
className: "option-checked"
|
|
122
123
|
}, isSelect && /*#__PURE__*/React.createElement("i", {
|
|
@@ -82,7 +82,8 @@ var SelectEditorOption = /*#__PURE__*/function (_React$Component) {
|
|
|
82
82
|
className: "option-info",
|
|
83
83
|
style: optionStyle
|
|
84
84
|
}, /*#__PURE__*/React.createElement("div", {
|
|
85
|
-
className: "option-name"
|
|
85
|
+
className: "option-name",
|
|
86
|
+
title: option.name
|
|
86
87
|
}, option.name)), isShowRemoveIcon && /*#__PURE__*/React.createElement("div", {
|
|
87
88
|
className: "option-remove",
|
|
88
89
|
style: operationStyle,
|
package/lib/utils/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import NP from './number-precision';
|
|
1
2
|
export var debounce = function debounce(fn, wait) {
|
|
2
3
|
var timeout = null;
|
|
3
4
|
return function () {
|
|
@@ -22,4 +23,22 @@ export var throttle = function throttle(func, delay) {
|
|
|
22
23
|
timer = setTimeout(func, remaining);
|
|
23
24
|
}
|
|
24
25
|
};
|
|
26
|
+
};
|
|
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
|
+
export var isMac = function isMac() {
|
|
41
|
+
var platform = navigator.platform; // eslint-disable-next-line eqeqeq
|
|
42
|
+
|
|
43
|
+
return platform == 'Mac68K' || platform == 'MacPPC' || platform == 'Macintosh' || platform == 'MacIntel';
|
|
25
44
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import NP from './number-precision';
|
|
4
4
|
import { CellType, NUMBER_TYPES, DEFAULT_NUMBER_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS, FORMULA_RESULT_TYPE, COLLABORATOR_COLUMN_TYPES, ARRAY_FORMAL_COLUMNS_TYPES, DEFAULT_DATE_FORMAT } from '../constants';
|
|
5
|
+
import { getFloatNumber } from './utils';
|
|
5
6
|
NP.enableBoundaryChecking(false);
|
|
6
7
|
var _separatorMap = {
|
|
7
8
|
'comma': ',',
|
|
@@ -125,27 +126,27 @@ export var getNumberDisplayString = function getNumberDisplayString(value, forma
|
|
|
125
126
|
format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
|
|
126
127
|
|
|
127
128
|
switch (format) {
|
|
128
|
-
case
|
|
129
|
+
case NUMBER_TYPES.NUMBER:
|
|
129
130
|
{
|
|
130
131
|
return _toThousands(value, false, formatData);
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
case
|
|
134
|
+
case NUMBER_TYPES.PERCENT:
|
|
134
135
|
{
|
|
135
136
|
return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
case
|
|
139
|
+
case NUMBER_TYPES.YUAN:
|
|
139
140
|
{
|
|
140
141
|
return "\uFFE5".concat(_toThousands(value, true, formatData));
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
case
|
|
144
|
+
case NUMBER_TYPES.DOLLAR:
|
|
144
145
|
{
|
|
145
146
|
return "$".concat(_toThousands(value, true, formatData));
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
case
|
|
149
|
+
case NUMBER_TYPES.EURO:
|
|
149
150
|
{
|
|
150
151
|
return "\u20AC".concat(_toThousands(value, true, formatData));
|
|
151
152
|
}
|
|
@@ -155,7 +156,7 @@ export var getNumberDisplayString = function getNumberDisplayString(value, forma
|
|
|
155
156
|
return getDurationDisplayString(value, formatData);
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
case
|
|
159
|
+
case NUMBER_TYPES.CUSTOM_CURRENCY:
|
|
159
160
|
{
|
|
160
161
|
if (formatData.currency_symbol_position === 'after') {
|
|
161
162
|
return "".concat(_toThousands(value, true, formatData)).concat(formatData.currency_symbol || '');
|
|
@@ -168,53 +169,90 @@ export var getNumberDisplayString = function getNumberDisplayString(value, forma
|
|
|
168
169
|
return '' + value;
|
|
169
170
|
}
|
|
170
171
|
};
|
|
171
|
-
export var formatStringToNumber = function formatStringToNumber(
|
|
172
|
-
var
|
|
173
|
-
|
|
172
|
+
export var formatStringToNumber = function formatStringToNumber(numberString, formatData) {
|
|
173
|
+
var _ref3 = formatData || {},
|
|
174
|
+
format = _ref3.format,
|
|
175
|
+
decimal = _ref3.decimal,
|
|
176
|
+
thousands = _ref3.thousands,
|
|
177
|
+
enable_precision = _ref3.enable_precision,
|
|
178
|
+
precision = _ref3.precision;
|
|
179
|
+
|
|
180
|
+
var value = numberString;
|
|
181
|
+
|
|
182
|
+
if (decimal && thousands && decimal === 'comma') {
|
|
183
|
+
if (thousands === 'dot') {
|
|
184
|
+
value = value.replace(/,/, '@');
|
|
185
|
+
value = value.replace(/\./g, ',');
|
|
186
|
+
value = value.replace(/@/, '.');
|
|
187
|
+
} else {
|
|
188
|
+
value = value.replace(/\./g, '');
|
|
189
|
+
value = value.replace(/,/, '.');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
174
192
|
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
value = getFloatNumber(value, format);
|
|
194
|
+
|
|
195
|
+
if (enable_precision && value) {
|
|
196
|
+
if (format === 'percent') {
|
|
197
|
+
precision += 2;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
value = Number(parseFloat(value).toFixed(precision));
|
|
177
201
|
}
|
|
178
202
|
|
|
179
|
-
return
|
|
203
|
+
return value;
|
|
180
204
|
};
|
|
181
|
-
export var
|
|
182
|
-
var
|
|
205
|
+
export var replaceNumberNotAllowInput = function replaceNumberNotAllowInput(value) {
|
|
206
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_NUMBER_FORMAT;
|
|
207
|
+
var currency_symbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
208
|
+
|
|
209
|
+
if (!value) {
|
|
210
|
+
return '';
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
value = value.replace(/。/g, '.');
|
|
183
214
|
|
|
184
215
|
switch (format) {
|
|
185
216
|
case NUMBER_TYPES.NUMBER:
|
|
186
217
|
case NUMBER_TYPES.NUMBER_WITH_COMMAS:
|
|
187
|
-
|
|
188
|
-
|
|
218
|
+
{
|
|
219
|
+
return value.replace(/[^.-\d,]/g, '');
|
|
220
|
+
}
|
|
189
221
|
|
|
190
222
|
case NUMBER_TYPES.PERCENT:
|
|
191
|
-
|
|
192
|
-
|
|
223
|
+
{
|
|
224
|
+
return value.replace(/[^.-\d,%]/g, '');
|
|
225
|
+
}
|
|
193
226
|
|
|
194
227
|
case NUMBER_TYPES.YUAN:
|
|
195
|
-
|
|
196
|
-
|
|
228
|
+
{
|
|
229
|
+
return value.replace(/[^.-\d¥¥,]/g, '');
|
|
230
|
+
}
|
|
197
231
|
|
|
198
232
|
case NUMBER_TYPES.DOLLAR:
|
|
199
|
-
|
|
200
|
-
|
|
233
|
+
{
|
|
234
|
+
return value.replace(/[^.-\d$,]/g, '');
|
|
235
|
+
}
|
|
201
236
|
|
|
202
237
|
case NUMBER_TYPES.EURO:
|
|
203
|
-
|
|
204
|
-
|
|
238
|
+
{
|
|
239
|
+
return value.replace(/[^.-\d€,]/g, '');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
case NUMBER_TYPES.CUSTOM_CURRENCY:
|
|
243
|
+
{
|
|
244
|
+
// eslint-disable-next-line
|
|
245
|
+
var reg = new RegExp('[^.-\d' + currency_symbol + ',]', 'g');
|
|
246
|
+
return value.replace(reg, '');
|
|
247
|
+
}
|
|
205
248
|
|
|
206
249
|
default:
|
|
207
|
-
|
|
250
|
+
return value.replace(/[^.-\d,]/g, '');
|
|
208
251
|
}
|
|
209
|
-
|
|
210
|
-
return formattedValue;
|
|
211
252
|
};
|
|
212
253
|
export var getDateDisplayString = function getDateDisplayString(value, format) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (!value) {
|
|
216
|
-
// value === '', value === undefine, value === null
|
|
217
|
-
return formattedValue;
|
|
254
|
+
if (!value || typeof value !== 'string') {
|
|
255
|
+
return '';
|
|
218
256
|
}
|
|
219
257
|
|
|
220
258
|
var date = dayjs(value);
|
|
@@ -247,8 +285,46 @@ export var getDateDisplayString = function getDateDisplayString(value, format) {
|
|
|
247
285
|
return date.format('YYYY-MM-DD');
|
|
248
286
|
}
|
|
249
287
|
};
|
|
250
|
-
|
|
288
|
+
|
|
289
|
+
var _getMathRoundedDuration = function _getMathRoundedDuration(num, duration_format) {
|
|
290
|
+
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
291
|
+
|
|
292
|
+
if (decimalDigits < 1) {
|
|
293
|
+
return num;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
var ratio = Math.pow(10, decimalDigits);
|
|
297
|
+
return Math.round(num * ratio) / ratio;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
var _getDurationDecimalSuffix = function _getDurationDecimalSuffix(duration_format, decimal) {
|
|
301
|
+
if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
|
|
302
|
+
return decimal === 0 ? '.0' : '';
|
|
303
|
+
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
|
|
304
|
+
if (decimal === 0) {
|
|
305
|
+
return '.00';
|
|
306
|
+
} else if (decimal < 10) {
|
|
307
|
+
return '0';
|
|
308
|
+
}
|
|
309
|
+
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
|
|
310
|
+
if (decimal === 0) {
|
|
311
|
+
return '.000';
|
|
312
|
+
} else if (decimal < 10) {
|
|
313
|
+
return '00';
|
|
314
|
+
} else if (decimal < 100) {
|
|
315
|
+
return '0';
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return '';
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export var getDurationDisplayString = function getDurationDisplayString(value, data) {
|
|
251
323
|
if (!value && value !== 0) return '';
|
|
324
|
+
|
|
325
|
+
var _ref4 = data || {},
|
|
326
|
+
duration_format = _ref4.duration_format;
|
|
327
|
+
|
|
252
328
|
duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
|
|
253
329
|
|
|
254
330
|
if (DURATION_FORMATS.findIndex(function (format) {
|
|
@@ -268,7 +344,7 @@ export var getDurationDisplayString = function getDurationDisplayString(value, d
|
|
|
268
344
|
positiveValue = Math.round(positiveValue);
|
|
269
345
|
}
|
|
270
346
|
|
|
271
|
-
positiveValue =
|
|
347
|
+
positiveValue = _getMathRoundedDuration(positiveValue, duration_format);
|
|
272
348
|
var decimalParts = (positiveValue + '').split('.');
|
|
273
349
|
var decimalPartsLen = decimalParts.length;
|
|
274
350
|
var decimal = 0;
|
|
@@ -279,7 +355,9 @@ export var getDurationDisplayString = function getDurationDisplayString(value, d
|
|
|
279
355
|
}
|
|
280
356
|
|
|
281
357
|
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
282
|
-
|
|
358
|
+
|
|
359
|
+
var decimalSuffix = _getDurationDecimalSuffix(duration_format, decimal);
|
|
360
|
+
|
|
283
361
|
var displayString = value < 0 ? '-' : '';
|
|
284
362
|
var hours = parseInt(positiveValue / 3600);
|
|
285
363
|
var minutes = parseInt((positiveValue - hours * 3600) / 60);
|
|
@@ -290,50 +368,11 @@ export var getDurationDisplayString = function getDurationDisplayString(value, d
|
|
|
290
368
|
}
|
|
291
369
|
|
|
292
370
|
var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
|
|
293
|
-
|
|
294
|
-
if (hours > 0) {
|
|
295
|
-
displayString += "".concat(hours, ":");
|
|
296
|
-
minutes = minutes > 9 ? minutes : "0".concat(minutes);
|
|
297
|
-
}
|
|
298
|
-
|
|
371
|
+
minutes = minutes > 9 ? minutes : "0".concat(minutes);
|
|
299
372
|
seconds = seconds > 9 ? seconds : "0".concat(seconds);
|
|
300
|
-
displayString += "".concat(minutes, ":").concat(seconds).concat(decimalSuffix);
|
|
373
|
+
displayString += "".concat(hours, ":").concat(minutes, ":").concat(seconds).concat(decimalSuffix);
|
|
301
374
|
return displayString;
|
|
302
375
|
};
|
|
303
|
-
|
|
304
|
-
var getMathRoundedDuration = function getMathRoundedDuration(num, duration_format) {
|
|
305
|
-
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
306
|
-
|
|
307
|
-
if (decimalDigits < 1) {
|
|
308
|
-
return num;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
var ratio = Math.pow(10, decimalDigits);
|
|
312
|
-
return Math.round(num * ratio) / ratio;
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format, decimal) {
|
|
316
|
-
if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
|
|
317
|
-
return decimal === 0 ? '.0' : '';
|
|
318
|
-
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
|
|
319
|
-
if (decimal === 0) {
|
|
320
|
-
return '.00';
|
|
321
|
-
} else if (decimal < 10) {
|
|
322
|
-
return '0';
|
|
323
|
-
}
|
|
324
|
-
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
|
|
325
|
-
if (decimal === 0) {
|
|
326
|
-
return '.000';
|
|
327
|
-
} else if (decimal < 10) {
|
|
328
|
-
return '00';
|
|
329
|
-
} else if (decimal < 100) {
|
|
330
|
-
return '0';
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return '';
|
|
335
|
-
};
|
|
336
|
-
|
|
337
376
|
export var getOptionName = function getOptionName(options, targetOptionID) {
|
|
338
377
|
if (!targetOptionID || !options || !Array.isArray(options)) return null;
|
|
339
378
|
var option = options.find(function (option) {
|
|
@@ -352,8 +391,8 @@ export var getMultipleOptionName = function getMultipleOptionName(options, cellV
|
|
|
352
391
|
}).join(', ');
|
|
353
392
|
};
|
|
354
393
|
export var getLongtextDisplayString = function getLongtextDisplayString(value) {
|
|
355
|
-
var
|
|
356
|
-
text =
|
|
394
|
+
var _ref5 = value || {},
|
|
395
|
+
text = _ref5.text;
|
|
357
396
|
|
|
358
397
|
if (!text) {
|
|
359
398
|
return null;
|
|
@@ -384,13 +423,13 @@ export var getCollaboratorsName = function getCollaboratorsName(collaborators, c
|
|
|
384
423
|
return null;
|
|
385
424
|
};
|
|
386
425
|
export var getGeolocationDisplayString = function getGeolocationDisplayString(value, columnData) {
|
|
387
|
-
var
|
|
388
|
-
geo_format =
|
|
426
|
+
var _ref6 = columnData || {},
|
|
427
|
+
geo_format = _ref6.geo_format;
|
|
389
428
|
|
|
390
429
|
var cellValue = value || {};
|
|
391
430
|
|
|
392
431
|
if (!value) {
|
|
393
|
-
return
|
|
432
|
+
return '';
|
|
394
433
|
}
|
|
395
434
|
|
|
396
435
|
if (geo_format === 'lng_lat' && value.lng && value.lat) {
|
|
@@ -417,9 +456,9 @@ export var getGeolocationDisplayString = function getGeolocationDisplayString(va
|
|
|
417
456
|
return "".concat(province || '').concat(city || '').concat(district || '').concat(detail || '');
|
|
418
457
|
};
|
|
419
458
|
export var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData) {
|
|
420
|
-
var
|
|
421
|
-
|
|
422
|
-
collaborators =
|
|
459
|
+
var _ref7 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
460
|
+
_ref7$collaborators = _ref7.collaborators,
|
|
461
|
+
collaborators = _ref7$collaborators === void 0 ? [] : _ref7$collaborators;
|
|
423
462
|
|
|
424
463
|
if (!columnData) {
|
|
425
464
|
return null;
|
|
@@ -470,10 +509,10 @@ export var getFormulaDisplayString = function getFormulaDisplayString(cellValue,
|
|
|
470
509
|
return cellValue;
|
|
471
510
|
};
|
|
472
511
|
export function getCellValueDisplayString(cellValue, type) {
|
|
473
|
-
var
|
|
474
|
-
data =
|
|
475
|
-
|
|
476
|
-
collaborators =
|
|
512
|
+
var _ref8 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
513
|
+
data = _ref8.data,
|
|
514
|
+
_ref8$collaborators = _ref8.collaborators,
|
|
515
|
+
collaborators = _ref8$collaborators === void 0 ? [] : _ref8$collaborators;
|
|
477
516
|
|
|
478
517
|
var newData = data || {};
|
|
479
518
|
|
|
@@ -517,9 +556,9 @@ export function getCellValueDisplayString(cellValue, type) {
|
|
|
517
556
|
|
|
518
557
|
case CellType.DATE:
|
|
519
558
|
{
|
|
520
|
-
var
|
|
521
|
-
|
|
522
|
-
format =
|
|
559
|
+
var _ref9 = newData || {},
|
|
560
|
+
_ref9$format = _ref9.format,
|
|
561
|
+
format = _ref9$format === void 0 ? DEFAULT_DATE_FORMAT : _ref9$format;
|
|
523
562
|
|
|
524
563
|
return getDateDisplayString(cellValue, format);
|
|
525
564
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.102",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@seafile/react-image-lightbox": "0.0.9",
|
|
7
|
-
"@seafile/seafile-calendar": "
|
|
7
|
+
"@seafile/seafile-calendar": "0.0.24",
|
|
8
8
|
"@seafile/seafile-editor": "^0.3.107",
|
|
9
9
|
"antd-mobile": "^2.3.3",
|
|
10
10
|
"astro-classname": "^2.1.0",
|