dtable-ui-component 0.1.75-beta1 → 0.1.75-beta5

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.
Files changed (227) hide show
  1. package/lib/AutoNumberFormatter/index.css +1 -0
  2. package/{es/components/cell-formatter/auto-number-formatter.js → lib/AutoNumberFormatter/index.js} +1 -0
  3. package/lib/ButtonFormatter/index.css +13 -0
  4. package/{es/components/cell-formatter/button-formatter.js → lib/ButtonFormatter/index.js} +1 -0
  5. package/lib/CTimeFormatter/index.css +1 -0
  6. package/{es/components/cell-formatter/ctime-formatter.js → lib/CTimeFormatter/index.js} +1 -0
  7. package/lib/CheckboxFormatter/index.css +1 -0
  8. package/{es/components/cell-formatter/checkbox-formatter.js → lib/CheckboxFormatter/index.js} +1 -0
  9. package/lib/CollaboratorFormatter/index.css +1 -0
  10. package/{es/components/cell-formatter/collaborator-formatter.js → lib/CollaboratorFormatter/index.js} +3 -2
  11. package/lib/CollaboratorItem/index.css +49 -0
  12. package/{es/components/common/collaborator-item.js → lib/CollaboratorItem/index.js} +1 -0
  13. package/lib/CreatorFormatter/index.css +1 -0
  14. package/{es/components/cell-formatter/creator-formatter.js → lib/CreatorFormatter/index.js} +3 -2
  15. package/lib/DateFormatter/index.css +1 -0
  16. package/{es/components/cell-formatter/date-formatter.js → lib/DateFormatter/index.js} +2 -1
  17. package/lib/DurationFormatter/index.css +1 -0
  18. package/{es/components/cell-formatter/duration-formatter.js → lib/DurationFormatter/index.js} +2 -1
  19. package/lib/EmailFormatter/index.css +5 -0
  20. package/{es/components/cell-formatter/email-formatter.js → lib/EmailFormatter/index.js} +1 -0
  21. package/lib/FileFormatter/index.css +29 -0
  22. package/{es/components/cell-formatter/file-formatter.js → lib/FileFormatter/index.js} +2 -1
  23. package/{es/components/cell-formatter/widgets/file-item-formatter.js → lib/FileItemFormatter/index.js} +3 -2
  24. package/{es/components/file-uploader → lib/FileUploader}/index.js +0 -0
  25. package/lib/FormulaFormatter/index.css +19 -0
  26. package/{es/components/cell-formatter/formula-formatter.js → lib/FormulaFormatter/index.js} +8 -8
  27. package/lib/GeolocationFormatter/index.css +1 -0
  28. package/{es/components/cell-formatter/geolocation-formatter.js → lib/GeolocationFormatter/index.js} +2 -1
  29. package/{es/components/common → lib/ImageFormatter}/images-lazy-load.js +2 -2
  30. package/lib/ImageFormatter/index.css +34 -0
  31. package/{es/components/cell-formatter/image-formatter.js → lib/ImageFormatter/index.js} +4 -3
  32. package/{es/css/image-previewer-ligntbox.css → lib/ImagePreviewerLightbox/index.css} +0 -0
  33. package/{es/components/cell-formatter/widgets/image-previewer-lightbox.js → lib/ImagePreviewerLightbox/index.js} +3 -3
  34. package/lib/LastModifierFormatter/index.css +1 -0
  35. package/{es/components/cell-formatter/last-modifier-formatter.js → lib/LastModifierFormatter/index.js} +5 -4
  36. package/lib/LinkFormatter/index.css +27 -0
  37. package/{es/components/cell-formatter/link-formatter.js → lib/LinkFormatter/index.js} +2 -2
  38. package/{es/css/loading.css → lib/Loading/index.css} +0 -0
  39. package/{es/components/loading.js → lib/Loading/index.js} +1 -1
  40. package/{es/components/cell-formatter/widgets/long-text-formatter → lib/LongTextFormatter}/html-long-text-formatter.js +1 -1
  41. package/lib/LongTextFormatter/index.css +63 -0
  42. package/{es/components/cell-formatter/long-text-formatter.js → lib/LongTextFormatter/index.js} +3 -2
  43. package/{es/components/cell-formatter/widgets/long-text-formatter → lib/LongTextFormatter}/simple-long-text-formatter.js +1 -1
  44. package/lib/MTimeFormatter/index.css +1 -0
  45. package/{es/components/cell-formatter/mtime-formatter.js → lib/MTimeFormatter/index.js} +1 -0
  46. package/{es/components/common/modal-portal.js → lib/ModalPortal/index.js} +0 -0
  47. package/lib/MultipleSelectFormatter/index.css +1 -0
  48. package/{es/components/cell-formatter/multiple-select-formatter.js → lib/MultipleSelectFormatter/index.js} +2 -1
  49. package/lib/NumberFormatter/index.css +1 -0
  50. package/{es/components/cell-formatter/number-formatter.js → lib/NumberFormatter/index.js} +2 -1
  51. package/lib/RateFormatter/index.css +1 -0
  52. package/{es/components/cell-formatter/rate-formatter.js → lib/RateFormatter/index.js} +1 -0
  53. package/{es/components/common/select-item.js → lib/SelectItem/index.js} +0 -0
  54. package/lib/SingleSelectFormatter/index.css +1 -0
  55. package/{es/components/cell-formatter/single-select-formatter.js → lib/SingleSelectFormatter/index.js} +2 -1
  56. package/lib/TextFormatter/index.css +1 -0
  57. package/{es/components/cell-formatter/text-formatter.js → lib/TextFormatter/index.js} +1 -0
  58. package/lib/UrlFormatter/index.css +5 -0
  59. package/{es/components/cell-formatter/url-formatter.js → lib/UrlFormatter/index.js} +1 -0
  60. package/lib/app.js +75 -80
  61. package/{es/components/cell-factory/cell-formatter-factory.js → lib/cellFormatterFactory/index.js} +3 -3
  62. package/lib/components/cell-editor/checkbox-editor.js +59 -66
  63. package/lib/components/cell-editor/collaborator-editor.js +113 -126
  64. package/lib/components/cell-editor/date-editor.js +99 -119
  65. package/lib/components/cell-editor/index.js +9 -40
  66. package/lib/components/cell-editor/link-editor.js +122 -140
  67. package/lib/components/cell-editor/multiple-select-editor.js +114 -127
  68. package/lib/components/cell-editor/number-editor.js +78 -86
  69. package/lib/components/cell-editor/single-select-editor.js +106 -120
  70. package/lib/components/cell-editor/text-editor.js +65 -72
  71. package/lib/components/cell-editor-dialog/pc-file-editor-dialog.js +31 -51
  72. package/lib/components/cell-editor-dialog/pc-files-addition/index.js +0 -1
  73. package/lib/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -1
  74. package/lib/components/cell-editor-dialog/pc-files-preview/index.js +0 -1
  75. package/lib/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -1
  76. package/lib/components/cell-editor-popover/mb-collaborator-editor-popover.js +105 -111
  77. package/lib/components/cell-editor-popover/mb-date-editor-popover.js +140 -157
  78. package/lib/components/cell-editor-popover/mb-link-editor-popover.js +103 -109
  79. package/lib/components/cell-editor-popover/mb-select-editor-popover.js +142 -155
  80. package/lib/components/cell-editor-popover/pc-collaborator-editor-popover.js +74 -89
  81. package/lib/components/cell-editor-popover/pc-date-editor-popover.js +88 -102
  82. package/lib/components/cell-editor-popover/pc-link-editor-popover.js +77 -91
  83. package/lib/components/cell-editor-popover/pc-select-editor-popover.js +91 -105
  84. package/lib/components/common/collaborator-item.js +43 -59
  85. package/lib/components/common/edit-editor-button.js +28 -39
  86. package/lib/components/common/link-editor-option.js +63 -71
  87. package/lib/components/common/mobile/mb-editor-header.js +39 -52
  88. package/lib/components/common/select-editor-option.js +58 -74
  89. package/lib/constants/cell-types.js +25 -54
  90. package/lib/constants/index.js +5 -26
  91. package/lib/css/cell-formatter.css +0 -243
  92. package/lib/formatterConfig/index.js +31 -0
  93. package/lib/index.js +31 -64
  94. package/lib/lang/index.js +11 -27
  95. package/lib/locals/de.js +1 -6
  96. package/lib/locals/en.js +1 -6
  97. package/lib/locals/fr.js +1 -6
  98. package/lib/locals/zh-CN.js +1 -6
  99. package/{es/components/toast → lib/toaster}/alert.js +0 -0
  100. package/{es/components/toast → lib/toaster}/index.js +0 -0
  101. package/{es/components/toast → lib/toaster}/toast.js +0 -0
  102. package/{es/components/toast → lib/toaster}/toastManager.js +0 -0
  103. package/{es/components/toast → lib/toaster}/toaster.js +0 -0
  104. package/lib/utils/cell-value-validator.js +4 -14
  105. package/lib/utils/column-utils.js +5 -13
  106. package/lib/utils/editor-utils.js +3 -13
  107. package/lib/utils/markdown2html.js +1 -7
  108. package/lib/utils/normalize-long-text-value.js +1 -6
  109. package/lib/utils/number-precision.js +14 -31
  110. package/lib/utils/utils.js +8 -33
  111. package/lib/utils/value-format-utils.js +60 -108
  112. package/package.json +5 -5
  113. package/es/app.css +0 -20
  114. package/es/app.js +0 -91
  115. package/es/assets/images/avatar/default_avatar.png +0 -0
  116. package/es/assets/images/file/192/excel.png +0 -0
  117. package/es/assets/images/file/192/file.png +0 -0
  118. package/es/assets/images/file/192/music.png +0 -0
  119. package/es/assets/images/file/192/pdf.png +0 -0
  120. package/es/assets/images/file/192/pic.png +0 -0
  121. package/es/assets/images/file/192/ppt.png +0 -0
  122. package/es/assets/images/file/192/txt.png +0 -0
  123. package/es/assets/images/file/192/video.png +0 -0
  124. package/es/assets/images/file/192/word.png +0 -0
  125. package/es/assets/images/file/24/excel.png +0 -0
  126. package/es/assets/images/file/24/file.png +0 -0
  127. package/es/assets/images/file/24/music.png +0 -0
  128. package/es/assets/images/file/24/pdf.png +0 -0
  129. package/es/assets/images/file/24/pic.png +0 -0
  130. package/es/assets/images/file/24/ppt.png +0 -0
  131. package/es/assets/images/file/24/txt.png +0 -0
  132. package/es/assets/images/file/24/video.png +0 -0
  133. package/es/assets/images/file/24/word.png +0 -0
  134. package/es/assets/images/folder/folder-192.png +0 -0
  135. package/es/assets/images/folder/folder-24.png +0 -0
  136. package/es/components/cell-editor/checkbox-editor.js +0 -104
  137. package/es/components/cell-editor/collaborator-editor.js +0 -236
  138. package/es/components/cell-editor/date-editor.js +0 -151
  139. package/es/components/cell-editor/index.js +0 -9
  140. package/es/components/cell-editor/link-editor.js +0 -303
  141. package/es/components/cell-editor/multiple-select-editor.js +0 -237
  142. package/es/components/cell-editor/number-editor.js +0 -154
  143. package/es/components/cell-editor/single-select-editor.js +0 -202
  144. package/es/components/cell-editor/text-editor.js +0 -122
  145. package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
  146. package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
  147. package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
  148. package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
  149. package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
  150. package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
  151. package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
  152. package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
  153. package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
  154. package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
  155. package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
  156. package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
  157. package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
  158. package/es/components/cell-formatter/formatter-config.js +0 -31
  159. package/es/components/cell-formatter/index.js +0 -27
  160. package/es/components/common/edit-editor-button.js +0 -56
  161. package/es/components/common/link-editor-option.js +0 -113
  162. package/es/components/common/mobile/mb-editor-header.js +0 -48
  163. package/es/components/common/select-editor-option.js +0 -106
  164. package/es/constants/cell-types.js +0 -25
  165. package/es/constants/index.js +0 -48
  166. package/es/css/cell-editor.css +0 -614
  167. package/es/css/cell-formatter.css +0 -247
  168. package/es/css/custom-rc-calendar.css +0 -118
  169. package/es/index.js +0 -6
  170. package/es/lang/index.js +0 -50
  171. package/es/locals/de.js +0 -2
  172. package/es/locals/en.js +0 -17
  173. package/es/locals/fr.js +0 -2
  174. package/es/locals/zh-CN.js +0 -17
  175. package/es/utils/cell-value-validator.js +0 -32
  176. package/es/utils/column-utils.js +0 -7
  177. package/es/utils/editor-utils.js +0 -71
  178. package/es/utils/markdown2html.js +0 -62
  179. package/es/utils/normalize-long-text-value.js +0 -69
  180. package/es/utils/number-precision.js +0 -163
  181. package/es/utils/unified/index.js +0 -470
  182. package/es/utils/utils.js +0 -116
  183. package/es/utils/value-format-utils.js +0 -495
  184. package/es/utils/vfile/core.js +0 -172
  185. package/es/utils/vfile/index.js +0 -48
  186. package/lib/components/cell-factory/cell-formatter-factory.js +0 -28
  187. package/lib/components/cell-formatter/auto-number-formatter.js +0 -45
  188. package/lib/components/cell-formatter/button-formatter.js +0 -66
  189. package/lib/components/cell-formatter/checkbox-formatter.js +0 -56
  190. package/lib/components/cell-formatter/collaborator-formatter.js +0 -111
  191. package/lib/components/cell-formatter/creator-formatter.js +0 -105
  192. package/lib/components/cell-formatter/ctime-formatter.js +0 -70
  193. package/lib/components/cell-formatter/date-formatter.js +0 -73
  194. package/lib/components/cell-formatter/duration-formatter.js +0 -49
  195. package/lib/components/cell-formatter/email-formatter.js +0 -45
  196. package/lib/components/cell-formatter/file-formatter.js +0 -77
  197. package/lib/components/cell-formatter/formatter-config.js +0 -66
  198. package/lib/components/cell-formatter/formula-formatter.js +0 -189
  199. package/lib/components/cell-formatter/geolocation-formatter.js +0 -66
  200. package/lib/components/cell-formatter/image-formatter.js +0 -171
  201. package/lib/components/cell-formatter/index.js +0 -112
  202. package/lib/components/cell-formatter/last-modifier-formatter.js +0 -105
  203. package/lib/components/cell-formatter/link-formatter.js +0 -165
  204. package/lib/components/cell-formatter/long-text-formatter.js +0 -46
  205. package/lib/components/cell-formatter/mtime-formatter.js +0 -70
  206. package/lib/components/cell-formatter/multiple-select-formatter.js +0 -84
  207. package/lib/components/cell-formatter/number-formatter.js +0 -60
  208. package/lib/components/cell-formatter/rate-formatter.js +0 -93
  209. package/lib/components/cell-formatter/single-select-formatter.js +0 -84
  210. package/lib/components/cell-formatter/text-formatter.js +0 -67
  211. package/lib/components/cell-formatter/url-formatter.js +0 -45
  212. package/lib/components/cell-formatter/widgets/file-item-formatter.js +0 -63
  213. package/lib/components/cell-formatter/widgets/image-previewer-lightbox.js +0 -152
  214. package/lib/components/cell-formatter/widgets/long-text-formatter/html-long-text-formatter.js +0 -107
  215. package/lib/components/cell-formatter/widgets/long-text-formatter/simple-long-text-formatter.js +0 -110
  216. package/lib/components/common/images-lazy-load.js +0 -158
  217. package/lib/components/common/modal-portal.js +0 -51
  218. package/lib/components/common/select-item.js +0 -73
  219. package/lib/components/file-uploader/index.js +0 -63
  220. package/lib/components/loading.js +0 -16
  221. package/lib/components/toast/alert.js +0 -164
  222. package/lib/components/toast/index.js +0 -12
  223. package/lib/components/toast/toast.js +0 -223
  224. package/lib/components/toast/toastManager.js +0 -189
  225. package/lib/components/toast/toaster.js +0 -92
  226. package/lib/css/image-previewer-ligntbox.css +0 -87
  227. package/lib/css/loading.css +0 -54
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,495 +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, FORMULA_RESULT_TYPE, COLLABORATOR_COLUMN_TYPES, ARRAY_FORMAL_COLUMNS_TYPES, DEFAULT_DATE_FORMAT } from '../constants';
4
- import * as CellType from '../constants/cell-types';
5
- NP.enableBoundaryChecking(false);
6
- var _separatorMap = {
7
- 'comma': ',',
8
- 'dot': '.',
9
- 'no': '',
10
- 'space': ' '
11
- };
12
-
13
- var _toThousands = function _toThousands(num, isCurrency, formatData) {
14
- var _ref = formatData || {},
15
- _ref$decimal = _ref.decimal,
16
- decimal = _ref$decimal === void 0 ? 'dot' : _ref$decimal,
17
- _ref$thousands = _ref.thousands,
18
- thousands = _ref$thousands === void 0 ? 'no' : _ref$thousands,
19
- _ref$precision = _ref.precision,
20
- precision = _ref$precision === void 0 ? 2 : _ref$precision,
21
- _ref$enable_precision = _ref.enable_precision,
22
- enable_precision = _ref$enable_precision === void 0 ? false : _ref$enable_precision;
23
-
24
- var decimalString = _separatorMap[decimal];
25
- var thousandsString = _separatorMap[thousands];
26
- var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
27
- var value = parseFloat(num.toFixed(decimalDigits));
28
- var integer = Math.trunc(value);
29
- var decimalValue = String(Math.abs(NP.minus(value, integer)).toFixed(decimalDigits)).slice(1);
30
-
31
- if (isCurrency) {
32
- if (decimalValue.length === 2) {
33
- decimalValue = decimalValue.padEnd(3, '0');
34
- } else {
35
- decimalValue = (decimalValue.substring(0, 3) || '.').padEnd(3, '0');
36
- }
37
-
38
- if (enable_precision) {
39
- decimalValue = precision === 0 ? '' : decimalValue.slice(0, precision + 1);
40
- }
41
- }
42
-
43
- decimalValue = decimalValue.replace(/./, decimalString);
44
- var result = [],
45
- counter = 0;
46
- integer = Object.is(integer, -0) ? ['-', '0'] : integer.toString().split('');
47
-
48
- for (var i = integer.length - 1; i >= 0; i--) {
49
- counter++;
50
- result.unshift(integer[i]);
51
-
52
- if (!(counter % 3) && i !== 0) {
53
- result.unshift(thousandsString);
54
- }
55
- }
56
-
57
- return result.join('') + decimalValue;
58
- };
59
-
60
- var _getDecimalDigits = function _getDecimalDigits(num) {
61
- if (Number.isInteger(num)) {
62
- return 0;
63
- }
64
-
65
- var valueArr = (num + '').split('.');
66
- var digitsLength = valueArr[1] ? valueArr[1].length : 8;
67
- return digitsLength > 8 ? 8 : digitsLength;
68
- };
69
-
70
- export var getNumberDisplayString = function getNumberDisplayString(value, formatData) {
71
- // formatData: old version maybe 'null'
72
- var type = Object.prototype.toString.call(value);
73
-
74
- if (type !== '[object Number]') {
75
- if (type === '[object String]' && value.startsWith('#')) {
76
- return value;
77
- }
78
-
79
- return null;
80
- }
81
-
82
- if (isNaN(value) || value === Infinity || value === -Infinity || (value + '').indexOf('e') > -1) return value + '';
83
-
84
- var _ref2 = formatData || {},
85
- _ref2$format = _ref2.format,
86
- format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
87
-
88
- switch (format) {
89
- case 'number':
90
- return _toThousands(value, false, formatData);
91
-
92
- case 'percent':
93
- {
94
- return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
95
- }
96
-
97
- case 'yuan':
98
- return "\uFFE5".concat(_toThousands(value, true, formatData));
99
-
100
- case 'dollar':
101
- return "$".concat(_toThousands(value, true, formatData));
102
-
103
- case 'euro':
104
- return "\u20AC".concat(_toThousands(value, true, formatData));
105
-
106
- case 'duration':
107
- {
108
- return getDurationDisplayString(value, formatData.duration_format);
109
- }
110
-
111
- default:
112
- return '' + value;
113
- }
114
- };
115
- export var formatStringToNumber = function formatStringToNumber(value) {
116
- var isIncludePercent = value.indexOf('%') > -1;
117
- var newData = parseFloat(value.replace(/[^.-\d]/g, ''));
118
-
119
- if (isIncludePercent && !isNaN(newData)) {
120
- return newData / 100;
121
- }
122
-
123
- return isNaN(newData) ? '' : newData;
124
- };
125
- export var formatNumberString = function formatNumberString(value, format) {
126
- var formattedValue = '';
127
-
128
- switch (format) {
129
- case NUMBER_TYPES.NUMBER:
130
- case NUMBER_TYPES.NUMBER_WITH_COMMAS:
131
- formattedValue = value.replace(/[^.-\d,]/g, '');
132
- break;
133
-
134
- case NUMBER_TYPES.PERCENT:
135
- formattedValue = value.replace(/[^.-\d,%]/g, '');
136
- break;
137
-
138
- case NUMBER_TYPES.YUAN:
139
- formattedValue = value.replace(/[^.-\d¥,]/g, '');
140
- break;
141
-
142
- case NUMBER_TYPES.DOLLAR:
143
- formattedValue = value.replace(/[^.-\d$,]/g, '');
144
- break;
145
-
146
- case NUMBER_TYPES.EURO:
147
- formattedValue = value.replace(/[^.-\d€,]/g, '');
148
- break;
149
-
150
- default:
151
- formattedValue = value.replace(/[^.-\d,]/g, '');
152
- }
153
-
154
- return formattedValue;
155
- };
156
- export var getDateDisplayString = function getDateDisplayString(value, format) {
157
- var formattedValue = '';
158
-
159
- if (!value) {
160
- // value === '', value === undefine, value === null
161
- return formattedValue;
162
- }
163
-
164
- var date = moment(value);
165
- if (!date.isValid()) return value;
166
-
167
- switch (format) {
168
- case 'D/M/YYYY':
169
- case 'DD/MM/YYYY':
170
- var formatValue = date.format('YYYY-MM-DD');
171
- var formatValueList = formatValue.split('-');
172
- return "".concat(formatValueList[2], "/").concat(formatValueList[1], "/").concat(formatValueList[0]);
173
-
174
- case 'D/M/YYYY HH:mm':
175
- case 'DD/MM/YYYY HH:mm':
176
- var formatValues = date.format('YYYY-MM-DD HH:mm');
177
- var formatValuesList = formatValues.split(' ');
178
- var formatDateList = formatValuesList[0].split('-');
179
- return "".concat(formatDateList[2], "/").concat(formatDateList[1], "/").concat(formatDateList[0], " ").concat(formatValuesList[1]);
180
-
181
- case 'M/D/YYYY':
182
- return date.format('M/D/YYYY');
183
-
184
- case 'M/D/YYYY HH:mm':
185
- return date.format('M/D/YYYY HH:mm');
186
-
187
- case 'YYYY-MM-DD':
188
- return date.format('YYYY-MM-DD');
189
-
190
- case 'YYYY-MM-DD HH:mm':
191
- return date.format('YYYY-MM-DD HH:mm');
192
-
193
- default:
194
- return value;
195
- }
196
- };
197
- export var getDurationDisplayString = function getDurationDisplayString(value, duration_format) {
198
- if (!value && value !== 0) return '';
199
- duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
200
-
201
- if (DURATION_FORMATS.findIndex(function (format) {
202
- return format.type === duration_format;
203
- }) < 0) {
204
- return '';
205
- }
206
-
207
- if (value === 0) {
208
- return DURATION_ZERO_DISPLAY[duration_format];
209
- }
210
-
211
- var includeDecimal = duration_format.indexOf('.') > -1;
212
- var positiveValue = Math.abs(value);
213
-
214
- if (!includeDecimal) {
215
- positiveValue = Math.round(positiveValue);
216
- }
217
-
218
- positiveValue = getMathRoundedDuration(positiveValue, duration_format);
219
- var decimalParts = (positiveValue + '').split('.');
220
- var decimalPartsLen = decimalParts.length;
221
- var decimal = 0;
222
-
223
- if (decimalPartsLen > 1) {
224
- decimal = decimalParts[decimalPartsLen - 1];
225
- decimal = decimal ? decimal - 0 : 0;
226
- }
227
-
228
- var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
229
- var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
230
- var displayString = value < 0 ? '-' : '';
231
- var hours = parseInt(positiveValue / 3600);
232
- var minutes = parseInt((positiveValue - hours * 3600) / 60);
233
-
234
- if (duration_format === DURATION_FORMATS_MAP.H_MM) {
235
- displayString += "".concat(hours, ":").concat(minutes > 9 ? minutes : '0' + minutes);
236
- return displayString;
237
- }
238
-
239
- var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
240
-
241
- if (hours > 0) {
242
- displayString += "".concat(hours, ":");
243
- minutes = minutes > 9 ? minutes : "0".concat(minutes);
244
- }
245
-
246
- seconds = seconds > 9 ? seconds : "0".concat(seconds);
247
- displayString += "".concat(minutes, ":").concat(seconds).concat(decimalSuffix);
248
- return displayString;
249
- };
250
-
251
- var getMathRoundedDuration = function getMathRoundedDuration(num, duration_format) {
252
- var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
253
-
254
- if (decimalDigits < 1) {
255
- return num;
256
- }
257
-
258
- var ratio = Math.pow(10, decimalDigits);
259
- return Math.round(num * ratio) / ratio;
260
- };
261
-
262
- var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format, decimal) {
263
- if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
264
- return decimal === 0 ? '.0' : '';
265
- } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
266
- if (decimal === 0) {
267
- return '.00';
268
- } else if (decimal < 10) {
269
- return '0';
270
- }
271
- } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
272
- if (decimal === 0) {
273
- return '.000';
274
- } else if (decimal < 10) {
275
- return '00';
276
- } else if (decimal < 100) {
277
- return '0';
278
- }
279
- }
280
-
281
- return '';
282
- };
283
-
284
- export var getOptionName = function getOptionName(options, targetOptionID) {
285
- if (!targetOptionID || !options || !Array.isArray(options)) return null;
286
- var option = options.find(function (option) {
287
- return option.id === targetOptionID;
288
- });
289
- return option ? option.name : null;
290
- };
291
- export var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
292
- if (!cellVal || !options || !Array.isArray(options)) return null;
293
- var selectedOptions = options.filter(function (option) {
294
- return cellVal.includes(option.id);
295
- });
296
- if (selectedOptions.length === 0) return null;
297
- return selectedOptions.map(function (option) {
298
- return option.name;
299
- }).join(', ');
300
- };
301
- export var getLongtextDisplayString = function getLongtextDisplayString(value) {
302
- var _ref3 = value || {},
303
- text = _ref3.text;
304
-
305
- if (!text) {
306
- return null;
307
- }
308
-
309
- return text;
310
- };
311
- export var getCollaboratorsName = function getCollaboratorsName(collaborators, cellVal) {
312
- if (cellVal) {
313
- var collaboratorsName = [];
314
- cellVal.forEach(function (v) {
315
- var collaborator = collaborators.find(function (c) {
316
- return c.email === v;
317
- });
318
-
319
- if (collaborator) {
320
- collaboratorsName.push(collaborator.name);
321
- }
322
- });
323
-
324
- if (collaboratorsName.length === 0) {
325
- return null;
326
- }
327
-
328
- return collaboratorsName.join(', ');
329
- }
330
-
331
- return null;
332
- };
333
- export var getGeolocationDisplayString = function getGeolocationDisplayString(value, columnData) {
334
- var _ref4 = columnData || {},
335
- geo_format = _ref4.geo_format;
336
-
337
- var cellValue = value || {};
338
-
339
- if (!value) {
340
- return null;
341
- }
342
-
343
- if (geo_format === 'lng_lat' && value.lng && value.lat) {
344
- return "".concat(cellValue.lng, ", ").concat(cellValue.lat);
345
- }
346
-
347
- if (geo_format === 'country_region' && cellValue.country_region) {
348
- return value.country_region || '';
349
- }
350
-
351
- var province = cellValue.province,
352
- city = cellValue.city,
353
- district = cellValue.district,
354
- detail = cellValue.detail;
355
-
356
- if (geo_format === 'province') {
357
- return "".concat(province || '');
358
- }
359
-
360
- if (geo_format === 'province_city') {
361
- return "".concat(province || '').concat(city || '');
362
- }
363
-
364
- return "".concat(province || '').concat(city || '').concat(district || '').concat(detail || '');
365
- };
366
- export var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData) {
367
- var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
368
- _ref5$collaborators = _ref5.collaborators,
369
- collaborators = _ref5$collaborators === void 0 ? [] : _ref5$collaborators;
370
-
371
- if (!columnData) {
372
- return null;
373
- }
374
-
375
- var result_type = columnData.result_type;
376
-
377
- if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
378
- return getNumberDisplayString(cellValue, columnData);
379
- }
380
-
381
- if (result_type === FORMULA_RESULT_TYPE.DATE) {
382
- var format = columnData.format;
383
- return getDateDisplayString(cellValue, format);
384
- }
385
-
386
- if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
387
- var array_type = columnData.array_type,
388
- array_data = columnData.array_data;
389
-
390
- if (!array_type) {
391
- return null;
392
- }
393
-
394
- if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
395
- return cellValue;
396
- }
397
-
398
- if (ARRAY_FORMAL_COLUMNS_TYPES.indexOf(array_type) < 0 && Array.isArray(cellValue)) {
399
- return cellValue.map(function (val) {
400
- return getCellValueDisplayString(val, array_type, {
401
- data: array_data,
402
- collaborators: collaborators
403
- });
404
- }).join(', ');
405
- }
406
-
407
- return getCellValueDisplayString(cellValue, array_type, {
408
- data: array_data,
409
- collaborators: collaborators
410
- });
411
- }
412
-
413
- if (Object.prototype.toString.call(cellValue) === '[object Boolean]') {
414
- return cellValue + '';
415
- }
416
-
417
- return cellValue;
418
- };
419
- export function getCellValueDisplayString(cellValue, type) {
420
- var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
421
- data = _ref6.data,
422
- _ref6$collaborators = _ref6.collaborators,
423
- collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators;
424
-
425
- var newData = data || {};
426
-
427
- switch (type) {
428
- case CellType.GEOLOCATION:
429
- {
430
- return getGeolocationDisplayString(cellValue, data);
431
- }
432
-
433
- case CellType.SINGLE_SELECT:
434
- {
435
- if (!data) return '';
436
- var options = newData.options;
437
- return getOptionName(options, cellValue);
438
- }
439
-
440
- case CellType.MULTIPLE_SELECT:
441
- {
442
- if (!data) return '';
443
- var _options = newData.options;
444
- return getMultipleOptionName(_options, cellValue);
445
- }
446
-
447
- case CellType.FORMULA:
448
- case CellType.LINK_FORMULA:
449
- {
450
- return getFormulaDisplayString(cellValue, newData, {
451
- collaborators: collaborators
452
- });
453
- }
454
-
455
- case CellType.LONG_TEXT:
456
- {
457
- return getLongtextDisplayString(cellValue);
458
- }
459
-
460
- case CellType.NUMBER:
461
- {
462
- return getNumberDisplayString(cellValue, newData);
463
- }
464
-
465
- case CellType.DATE:
466
- {
467
- var _ref7 = newData || {},
468
- _ref7$format = _ref7.format,
469
- format = _ref7$format === void 0 ? DEFAULT_DATE_FORMAT : _ref7$format;
470
-
471
- return getDateDisplayString(cellValue, format);
472
- }
473
-
474
- case CellType.CREATOR:
475
- case CellType.LAST_MODIFIER:
476
- {
477
- return cellValue === 'anonymous' ? cellValue : getCollaboratorsName(collaborators, [cellValue]);
478
- }
479
-
480
- case CellType.COLLABORATOR:
481
- {
482
- return getCollaboratorsName(collaborators, cellValue);
483
- }
484
-
485
- case CellType.DURATION:
486
- {
487
- return getDurationDisplayString(cellValue, data);
488
- }
489
-
490
- default:
491
- {
492
- return cellValue ? cellValue + '' : '';
493
- }
494
- }
495
- }