dtable-ui-component 0.1.75-beta3 → 0.1.75-beta4

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 (223) hide show
  1. package/lib/AutoNumberFormatter/index.js +27 -38
  2. package/lib/ButtonFormatter/index.js +47 -59
  3. package/lib/CTimeFormatter/index.js +39 -53
  4. package/lib/CheckboxFormatter/index.js +35 -48
  5. package/lib/CollaboratorFormatter/index.js +42 -64
  6. package/lib/CollaboratorItem/index.js +44 -61
  7. package/lib/CreatorFormatter/index.js +42 -62
  8. package/lib/DateFormatter/index.js +40 -55
  9. package/lib/DurationFormatter/index.js +29 -42
  10. package/lib/EmailFormatter/index.js +27 -38
  11. package/lib/FileFormatter/index.js +50 -65
  12. package/lib/FileItemFormatter/index.js +32 -44
  13. package/lib/FileUploader/index.js +34 -44
  14. package/lib/FormulaFormatter/index.js +81 -102
  15. package/lib/GeolocationFormatter/index.js +35 -50
  16. package/lib/ImageFormatter/images-lazy-load.js +73 -81
  17. package/lib/ImageFormatter/index.js +90 -109
  18. package/lib/ImagePreviewerLightbox/index.js +27 -60
  19. package/lib/LastModifierFormatter/index.js +42 -62
  20. package/lib/LinkFormatter/index.js +59 -80
  21. package/lib/Loading/index.js +4 -13
  22. package/lib/LongTextFormatter/html-long-text-formatter.js +49 -60
  23. package/lib/LongTextFormatter/index.js +9 -28
  24. package/lib/LongTextFormatter/simple-long-text-formatter.js +52 -58
  25. package/lib/MTimeFormatter/index.js +39 -53
  26. package/lib/ModalPortal/index.js +30 -37
  27. package/lib/MultipleSelectFormatter/index.js +39 -55
  28. package/lib/NumberFormatter/index.js +35 -50
  29. package/lib/RateFormatter/index.js +37 -52
  30. package/lib/SelectItem/index.js +31 -46
  31. package/lib/SingleSelectFormatter/index.js +38 -54
  32. package/lib/TextFormatter/index.js +31 -44
  33. package/lib/UrlFormatter/index.js +27 -38
  34. package/lib/app.js +75 -80
  35. package/lib/cellFormatterFactory/index.js +17 -20
  36. package/lib/components/cell-editor/checkbox-editor.js +59 -66
  37. package/lib/components/cell-editor/collaborator-editor.js +113 -126
  38. package/lib/components/cell-editor/date-editor.js +99 -119
  39. package/lib/components/cell-editor/index.js +9 -40
  40. package/lib/components/cell-editor/link-editor.js +122 -140
  41. package/lib/components/cell-editor/multiple-select-editor.js +114 -127
  42. package/lib/components/cell-editor/number-editor.js +78 -86
  43. package/lib/components/cell-editor/single-select-editor.js +106 -120
  44. package/lib/components/cell-editor/text-editor.js +65 -72
  45. package/lib/components/cell-editor-dialog/pc-file-editor-dialog.js +31 -51
  46. package/lib/components/cell-editor-dialog/pc-files-addition/index.js +0 -1
  47. package/lib/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -1
  48. package/lib/components/cell-editor-dialog/pc-files-preview/index.js +0 -1
  49. package/lib/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -1
  50. package/lib/components/cell-editor-popover/mb-collaborator-editor-popover.js +105 -111
  51. package/lib/components/cell-editor-popover/mb-date-editor-popover.js +140 -157
  52. package/lib/components/cell-editor-popover/mb-link-editor-popover.js +103 -109
  53. package/lib/components/cell-editor-popover/mb-select-editor-popover.js +142 -155
  54. package/lib/components/cell-editor-popover/pc-collaborator-editor-popover.js +74 -89
  55. package/lib/components/cell-editor-popover/pc-date-editor-popover.js +88 -102
  56. package/lib/components/cell-editor-popover/pc-link-editor-popover.js +77 -91
  57. package/lib/components/cell-editor-popover/pc-select-editor-popover.js +91 -105
  58. package/lib/components/common/collaborator-item.js +43 -59
  59. package/lib/components/common/edit-editor-button.js +28 -39
  60. package/lib/components/common/link-editor-option.js +63 -71
  61. package/lib/components/common/mobile/mb-editor-header.js +39 -52
  62. package/lib/components/common/select-editor-option.js +58 -74
  63. package/lib/constants/cell-types.js +25 -54
  64. package/lib/constants/index.js +5 -28
  65. package/lib/formatterConfig/index.js +28 -59
  66. package/lib/index.js +31 -139
  67. package/lib/lang/index.js +11 -27
  68. package/lib/locals/de.js +1 -6
  69. package/lib/locals/en.js +1 -6
  70. package/lib/locals/fr.js +1 -6
  71. package/lib/locals/zh-CN.js +1 -6
  72. package/lib/toaster/alert.js +92 -106
  73. package/lib/toaster/index.js +3 -12
  74. package/lib/toaster/toast.js +103 -147
  75. package/lib/toaster/toastManager.js +78 -97
  76. package/lib/toaster/toaster.js +36 -52
  77. package/lib/utils/cell-value-validator.js +5 -9
  78. package/lib/utils/column-utils.js +5 -13
  79. package/lib/utils/editor-utils.js +3 -13
  80. package/lib/utils/markdown2html.js +1 -7
  81. package/lib/utils/normalize-long-text-value.js +1 -6
  82. package/lib/utils/number-precision.js +13 -31
  83. package/lib/utils/utils.js +8 -33
  84. package/lib/utils/value-format-utils.js +58 -108
  85. package/package.json +5 -5
  86. package/es/AutoNumberFormatter/index.css +0 -1
  87. package/es/AutoNumberFormatter/index.js +0 -36
  88. package/es/ButtonFormatter/index.css +0 -13
  89. package/es/ButtonFormatter/index.js +0 -56
  90. package/es/CTimeFormatter/index.css +0 -1
  91. package/es/CTimeFormatter/index.js +0 -58
  92. package/es/CheckboxFormatter/index.css +0 -1
  93. package/es/CheckboxFormatter/index.js +0 -45
  94. package/es/CollaboratorFormatter/index.css +0 -1
  95. package/es/CollaboratorFormatter/index.js +0 -91
  96. package/es/CollaboratorItem/index.css +0 -49
  97. package/es/CollaboratorItem/index.js +0 -64
  98. package/es/CreatorFormatter/index.css +0 -1
  99. package/es/CreatorFormatter/index.js +0 -87
  100. package/es/DateFormatter/index.css +0 -1
  101. package/es/DateFormatter/index.js +0 -60
  102. package/es/DurationFormatter/index.css +0 -1
  103. package/es/DurationFormatter/index.js +0 -38
  104. package/es/EmailFormatter/index.css +0 -5
  105. package/es/EmailFormatter/index.js +0 -36
  106. package/es/FileFormatter/index.css +0 -29
  107. package/es/FileFormatter/index.js +0 -64
  108. package/es/FileItemFormatter/index.js +0 -50
  109. package/es/FileUploader/index.js +0 -53
  110. package/es/FormulaFormatter/index.css +0 -19
  111. package/es/FormulaFormatter/index.js +0 -164
  112. package/es/GeolocationFormatter/index.css +0 -1
  113. package/es/GeolocationFormatter/index.js +0 -53
  114. package/es/ImageFormatter/images-lazy-load.js +0 -150
  115. package/es/ImageFormatter/index.css +0 -34
  116. package/es/ImageFormatter/index.js +0 -154
  117. package/es/ImagePreviewerLightbox/index.css +0 -87
  118. package/es/ImagePreviewerLightbox/index.js +0 -119
  119. package/es/LastModifierFormatter/index.css +0 -1
  120. package/es/LastModifierFormatter/index.js +0 -87
  121. package/es/LinkFormatter/index.css +0 -27
  122. package/es/LinkFormatter/index.js +0 -144
  123. package/es/Loading/index.css +0 -54
  124. package/es/Loading/index.js +0 -7
  125. package/es/LongTextFormatter/html-long-text-formatter.js +0 -96
  126. package/es/LongTextFormatter/index.css +0 -63
  127. package/es/LongTextFormatter/index.js +0 -29
  128. package/es/LongTextFormatter/simple-long-text-formatter.js +0 -104
  129. package/es/MTimeFormatter/index.css +0 -1
  130. package/es/MTimeFormatter/index.js +0 -58
  131. package/es/ModalPortal/index.js +0 -44
  132. package/es/MultipleSelectFormatter/index.css +0 -1
  133. package/es/MultipleSelectFormatter/index.js +0 -70
  134. package/es/NumberFormatter/index.css +0 -1
  135. package/es/NumberFormatter/index.js +0 -47
  136. package/es/RateFormatter/index.css +0 -1
  137. package/es/RateFormatter/index.js +0 -80
  138. package/es/SelectItem/index.js +0 -58
  139. package/es/SingleSelectFormatter/index.css +0 -1
  140. package/es/SingleSelectFormatter/index.js +0 -70
  141. package/es/TextFormatter/index.css +0 -1
  142. package/es/TextFormatter/index.js +0 -56
  143. package/es/UrlFormatter/index.css +0 -5
  144. package/es/UrlFormatter/index.js +0 -36
  145. package/es/app.css +0 -20
  146. package/es/app.js +0 -91
  147. package/es/assets/images/avatar/default_avatar.png +0 -0
  148. package/es/assets/images/file/192/excel.png +0 -0
  149. package/es/assets/images/file/192/file.png +0 -0
  150. package/es/assets/images/file/192/music.png +0 -0
  151. package/es/assets/images/file/192/pdf.png +0 -0
  152. package/es/assets/images/file/192/pic.png +0 -0
  153. package/es/assets/images/file/192/ppt.png +0 -0
  154. package/es/assets/images/file/192/txt.png +0 -0
  155. package/es/assets/images/file/192/video.png +0 -0
  156. package/es/assets/images/file/192/word.png +0 -0
  157. package/es/assets/images/file/24/excel.png +0 -0
  158. package/es/assets/images/file/24/file.png +0 -0
  159. package/es/assets/images/file/24/music.png +0 -0
  160. package/es/assets/images/file/24/pdf.png +0 -0
  161. package/es/assets/images/file/24/pic.png +0 -0
  162. package/es/assets/images/file/24/ppt.png +0 -0
  163. package/es/assets/images/file/24/txt.png +0 -0
  164. package/es/assets/images/file/24/video.png +0 -0
  165. package/es/assets/images/file/24/word.png +0 -0
  166. package/es/assets/images/folder/folder-192.png +0 -0
  167. package/es/assets/images/folder/folder-24.png +0 -0
  168. package/es/cellFormatterFactory/index.js +0 -25
  169. package/es/components/cell-editor/checkbox-editor.js +0 -104
  170. package/es/components/cell-editor/collaborator-editor.js +0 -236
  171. package/es/components/cell-editor/date-editor.js +0 -151
  172. package/es/components/cell-editor/index.js +0 -9
  173. package/es/components/cell-editor/link-editor.js +0 -303
  174. package/es/components/cell-editor/multiple-select-editor.js +0 -237
  175. package/es/components/cell-editor/number-editor.js +0 -154
  176. package/es/components/cell-editor/single-select-editor.js +0 -202
  177. package/es/components/cell-editor/text-editor.js +0 -122
  178. package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
  179. package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
  180. package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
  181. package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
  182. package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
  183. package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
  184. package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
  185. package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
  186. package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
  187. package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
  188. package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
  189. package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
  190. package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
  191. package/es/components/common/collaborator-item.js +0 -63
  192. package/es/components/common/edit-editor-button.js +0 -56
  193. package/es/components/common/link-editor-option.js +0 -113
  194. package/es/components/common/mobile/mb-editor-header.js +0 -48
  195. package/es/components/common/select-editor-option.js +0 -106
  196. package/es/constants/cell-types.js +0 -25
  197. package/es/constants/index.js +0 -49
  198. package/es/css/cell-editor.css +0 -614
  199. package/es/css/cell-formatter.css +0 -4
  200. package/es/css/custom-rc-calendar.css +0 -118
  201. package/es/formatterConfig/index.js +0 -31
  202. package/es/index.js +0 -31
  203. package/es/lang/index.js +0 -50
  204. package/es/locals/de.js +0 -2
  205. package/es/locals/en.js +0 -17
  206. package/es/locals/fr.js +0 -2
  207. package/es/locals/zh-CN.js +0 -17
  208. package/es/toaster/alert.js +0 -150
  209. package/es/toaster/index.js +0 -3
  210. package/es/toaster/toast.js +0 -179
  211. package/es/toaster/toastManager.js +0 -170
  212. package/es/toaster/toaster.js +0 -76
  213. package/es/utils/cell-value-validator.js +0 -31
  214. package/es/utils/column-utils.js +0 -7
  215. package/es/utils/editor-utils.js +0 -71
  216. package/es/utils/markdown2html.js +0 -62
  217. package/es/utils/normalize-long-text-value.js +0 -69
  218. package/es/utils/number-precision.js +0 -164
  219. package/es/utils/unified/index.js +0 -470
  220. package/es/utils/utils.js +0 -116
  221. package/es/utils/value-format-utils.js +0 -497
  222. package/es/utils/vfile/core.js +0 -172
  223. package/es/utils/vfile/index.js +0 -48
@@ -1,27 +1,9 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.formatStringToNumber = exports.formatNumberString = void 0;
7
- exports.getCellValueDisplayString = getCellValueDisplayString;
8
- exports.getOptionName = exports.getNumberDisplayString = exports.getMultipleOptionName = exports.getLongtextDisplayString = exports.getGeolocationDisplayString = exports.getFormulaDisplayString = exports.getDurationDisplayString = exports.getDateDisplayString = exports.getCollaboratorsName = void 0;
9
-
10
- var _moment = _interopRequireDefault(require("moment"));
11
-
12
- var _numberPrecision = _interopRequireDefault(require("./number-precision"));
13
-
14
- var _constants = require("../constants");
15
-
16
- var CellType = _interopRequireWildcard(require("../constants/cell-types"));
17
-
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
1
  /* eslint-disable no-case-declarations */
23
- _numberPrecision.default.enableBoundaryChecking(false);
24
-
2
+ import moment from 'moment';
3
+ import NP from './number-precision';
4
+ 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';
5
+ import * as CellType from '../constants/cell-types';
6
+ NP.enableBoundaryChecking(false);
25
7
  var _separatorMap = {
26
8
  'comma': ',',
27
9
  'dot': '.',
@@ -45,7 +27,7 @@ var _toThousands = function _toThousands(num, isCurrency, formatData) {
45
27
  var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
46
28
  var value = parseFloat(num.toFixed(decimalDigits));
47
29
  var integer = Math.trunc(value);
48
- var decimalValue = String(Math.abs(_numberPrecision.default.minus(value, integer)).toFixed(decimalDigits)).slice(1);
30
+ var decimalValue = String(Math.abs(NP.minus(value, integer)).toFixed(decimalDigits)).slice(1);
49
31
 
50
32
  if (isCurrency) {
51
33
  if (decimalValue.length === 2) {
@@ -86,7 +68,7 @@ var _getDecimalDigits = function _getDecimalDigits(num) {
86
68
  return digitsLength > 8 ? 8 : digitsLength;
87
69
  };
88
70
 
89
- var getNumberDisplayString = function getNumberDisplayString(value, formatData) {
71
+ export var getNumberDisplayString = function getNumberDisplayString(value, formatData) {
90
72
  // formatData: old version maybe 'null'
91
73
  var type = Object.prototype.toString.call(value);
92
74
 
@@ -102,7 +84,7 @@ var getNumberDisplayString = function getNumberDisplayString(value, formatData)
102
84
 
103
85
  var _ref2 = formatData || {},
104
86
  _ref2$format = _ref2.format,
105
- format = _ref2$format === void 0 ? _constants.DEFAULT_NUMBER_FORMAT : _ref2$format;
87
+ format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
106
88
 
107
89
  switch (format) {
108
90
  case 'number':
@@ -110,17 +92,17 @@ var getNumberDisplayString = function getNumberDisplayString(value, formatData)
110
92
 
111
93
  case 'percent':
112
94
  {
113
- return _toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData) + "%";
95
+ return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
114
96
  }
115
97
 
116
98
  case 'yuan':
117
- return "\uFFE5" + _toThousands(value, true, formatData);
99
+ return "\uFFE5".concat(_toThousands(value, true, formatData));
118
100
 
119
101
  case 'dollar':
120
- return "$" + _toThousands(value, true, formatData);
102
+ return "$".concat(_toThousands(value, true, formatData));
121
103
 
122
104
  case 'euro':
123
- return "\u20AC" + _toThousands(value, true, formatData);
105
+ return "\u20AC".concat(_toThousands(value, true, formatData));
124
106
 
125
107
  case 'duration':
126
108
  {
@@ -131,10 +113,7 @@ var getNumberDisplayString = function getNumberDisplayString(value, formatData)
131
113
  return '' + value;
132
114
  }
133
115
  };
134
-
135
- exports.getNumberDisplayString = getNumberDisplayString;
136
-
137
- var formatStringToNumber = function formatStringToNumber(value) {
116
+ export var formatStringToNumber = function formatStringToNumber(value) {
138
117
  var isIncludePercent = value.indexOf('%') > -1;
139
118
  var newData = parseFloat(value.replace(/[^.-\d]/g, ''));
140
119
 
@@ -144,31 +123,28 @@ var formatStringToNumber = function formatStringToNumber(value) {
144
123
 
145
124
  return isNaN(newData) ? '' : newData;
146
125
  };
147
-
148
- exports.formatStringToNumber = formatStringToNumber;
149
-
150
- var formatNumberString = function formatNumberString(value, format) {
126
+ export var formatNumberString = function formatNumberString(value, format) {
151
127
  var formattedValue = '';
152
128
 
153
129
  switch (format) {
154
- case _constants.NUMBER_TYPES.NUMBER:
155
- case _constants.NUMBER_TYPES.NUMBER_WITH_COMMAS:
130
+ case NUMBER_TYPES.NUMBER:
131
+ case NUMBER_TYPES.NUMBER_WITH_COMMAS:
156
132
  formattedValue = value.replace(/[^.-\d,]/g, '');
157
133
  break;
158
134
 
159
- case _constants.NUMBER_TYPES.PERCENT:
135
+ case NUMBER_TYPES.PERCENT:
160
136
  formattedValue = value.replace(/[^.-\d,%]/g, '');
161
137
  break;
162
138
 
163
- case _constants.NUMBER_TYPES.YUAN:
139
+ case NUMBER_TYPES.YUAN:
164
140
  formattedValue = value.replace(/[^.-\d¥,]/g, '');
165
141
  break;
166
142
 
167
- case _constants.NUMBER_TYPES.DOLLAR:
143
+ case NUMBER_TYPES.DOLLAR:
168
144
  formattedValue = value.replace(/[^.-\d$,]/g, '');
169
145
  break;
170
146
 
171
- case _constants.NUMBER_TYPES.EURO:
147
+ case NUMBER_TYPES.EURO:
172
148
  formattedValue = value.replace(/[^.-\d€,]/g, '');
173
149
  break;
174
150
 
@@ -178,10 +154,7 @@ var formatNumberString = function formatNumberString(value, format) {
178
154
 
179
155
  return formattedValue;
180
156
  };
181
-
182
- exports.formatNumberString = formatNumberString;
183
-
184
- var getDateDisplayString = function getDateDisplayString(value, format) {
157
+ export var getDateDisplayString = function getDateDisplayString(value, format) {
185
158
  var formattedValue = '';
186
159
 
187
160
  if (!value) {
@@ -189,7 +162,7 @@ var getDateDisplayString = function getDateDisplayString(value, format) {
189
162
  return formattedValue;
190
163
  }
191
164
 
192
- var date = (0, _moment.default)(value);
165
+ var date = moment(value);
193
166
  if (!date.isValid()) return value;
194
167
 
195
168
  switch (format) {
@@ -198,14 +171,14 @@ var getDateDisplayString = function getDateDisplayString(value, format) {
198
171
  // no-case-declarations
199
172
  var formatValue = date.format('YYYY-MM-DD');
200
173
  var formatValueList = formatValue.split('-');
201
- return formatValueList[2] + "/" + formatValueList[1] + "/" + formatValueList[0];
174
+ return "".concat(formatValueList[2], "/").concat(formatValueList[1], "/").concat(formatValueList[0]);
202
175
 
203
176
  case 'D/M/YYYY HH:mm':
204
177
  case 'DD/MM/YYYY HH:mm':
205
178
  var formatValues = date.format('YYYY-MM-DD HH:mm');
206
179
  var formatValuesList = formatValues.split(' ');
207
180
  var formatDateList = formatValuesList[0].split('-');
208
- return formatDateList[2] + "/" + formatDateList[1] + "/" + formatDateList[0] + " " + formatValuesList[1];
181
+ return "".concat(formatDateList[2], "/").concat(formatDateList[1], "/").concat(formatDateList[0], " ").concat(formatValuesList[1]);
209
182
 
210
183
  case 'M/D/YYYY':
211
184
  return date.format('M/D/YYYY');
@@ -223,21 +196,18 @@ var getDateDisplayString = function getDateDisplayString(value, format) {
223
196
  return value;
224
197
  }
225
198
  };
226
-
227
- exports.getDateDisplayString = getDateDisplayString;
228
-
229
- var getDurationDisplayString = function getDurationDisplayString(value, duration_format) {
199
+ export var getDurationDisplayString = function getDurationDisplayString(value, duration_format) {
230
200
  if (!value && value !== 0) return '';
231
- duration_format = duration_format || _constants.DURATION_FORMATS_MAP.H_MM;
201
+ duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
232
202
 
233
- if (_constants.DURATION_FORMATS.findIndex(function (format) {
203
+ if (DURATION_FORMATS.findIndex(function (format) {
234
204
  return format.type === duration_format;
235
205
  }) < 0) {
236
206
  return '';
237
207
  }
238
208
 
239
209
  if (value === 0) {
240
- return _constants.DURATION_ZERO_DISPLAY[duration_format];
210
+ return DURATION_ZERO_DISPLAY[duration_format];
241
211
  }
242
212
 
243
213
  var includeDecimal = duration_format.indexOf('.') > -1;
@@ -257,33 +227,31 @@ var getDurationDisplayString = function getDurationDisplayString(value, duration
257
227
  decimal = decimal ? decimal - 0 : 0;
258
228
  }
259
229
 
260
- var decimalDigits = _constants.DURATION_DECIMAL_DIGITS[duration_format];
230
+ var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
261
231
  var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
262
232
  var displayString = value < 0 ? '-' : '';
263
233
  var hours = parseInt(positiveValue / 3600);
264
234
  var minutes = parseInt((positiveValue - hours * 3600) / 60);
265
235
 
266
- if (duration_format === _constants.DURATION_FORMATS_MAP.H_MM) {
267
- displayString += hours + ":" + (minutes > 9 ? minutes : '0' + minutes);
236
+ if (duration_format === DURATION_FORMATS_MAP.H_MM) {
237
+ displayString += "".concat(hours, ":").concat(minutes > 9 ? minutes : '0' + minutes);
268
238
  return displayString;
269
239
  }
270
240
 
271
241
  var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
272
242
 
273
243
  if (hours > 0) {
274
- displayString += hours + ":";
275
- minutes = minutes > 9 ? minutes : "0" + minutes;
244
+ displayString += "".concat(hours, ":");
245
+ minutes = minutes > 9 ? minutes : "0".concat(minutes);
276
246
  }
277
247
 
278
- seconds = seconds > 9 ? seconds : "0" + seconds;
279
- displayString += minutes + ":" + seconds + decimalSuffix;
248
+ seconds = seconds > 9 ? seconds : "0".concat(seconds);
249
+ displayString += "".concat(minutes, ":").concat(seconds).concat(decimalSuffix);
280
250
  return displayString;
281
251
  };
282
252
 
283
- exports.getDurationDisplayString = getDurationDisplayString;
284
-
285
253
  var getMathRoundedDuration = function getMathRoundedDuration(num, duration_format) {
286
- var decimalDigits = _constants.DURATION_DECIMAL_DIGITS[duration_format];
254
+ var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
287
255
 
288
256
  if (decimalDigits < 1) {
289
257
  return num;
@@ -294,15 +262,15 @@ var getMathRoundedDuration = function getMathRoundedDuration(num, duration_forma
294
262
  };
295
263
 
296
264
  var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format, decimal) {
297
- if (duration_format === _constants.DURATION_FORMATS_MAP.H_MM_SS_S) {
265
+ if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
298
266
  return decimal === 0 ? '.0' : '';
299
- } else if (duration_format === _constants.DURATION_FORMATS_MAP.H_MM_SS_SS) {
267
+ } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
300
268
  if (decimal === 0) {
301
269
  return '.00';
302
270
  } else if (decimal < 10) {
303
271
  return '0';
304
272
  }
305
- } else if (duration_format === _constants.DURATION_FORMATS_MAP.H_MM_SS_SSS) {
273
+ } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
306
274
  if (decimal === 0) {
307
275
  return '.000';
308
276
  } else if (decimal < 10) {
@@ -315,17 +283,14 @@ var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format
315
283
  return '';
316
284
  };
317
285
 
318
- var getOptionName = function getOptionName(options, targetOptionID) {
286
+ export var getOptionName = function getOptionName(options, targetOptionID) {
319
287
  if (!targetOptionID || !options || !Array.isArray(options)) return null;
320
288
  var option = options.find(function (option) {
321
289
  return option.id === targetOptionID;
322
290
  });
323
291
  return option ? option.name : null;
324
292
  };
325
-
326
- exports.getOptionName = getOptionName;
327
-
328
- var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
293
+ export var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
329
294
  if (!cellVal || !options || !Array.isArray(options)) return null;
330
295
  var selectedOptions = options.filter(function (option) {
331
296
  return cellVal.includes(option.id);
@@ -335,10 +300,7 @@ var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
335
300
  return option.name;
336
301
  }).join(', ');
337
302
  };
338
-
339
- exports.getMultipleOptionName = getMultipleOptionName;
340
-
341
- var getLongtextDisplayString = function getLongtextDisplayString(value) {
303
+ export var getLongtextDisplayString = function getLongtextDisplayString(value) {
342
304
  var _ref3 = value || {},
343
305
  text = _ref3.text;
344
306
 
@@ -348,10 +310,7 @@ var getLongtextDisplayString = function getLongtextDisplayString(value) {
348
310
 
349
311
  return text;
350
312
  };
351
-
352
- exports.getLongtextDisplayString = getLongtextDisplayString;
353
-
354
- var getCollaboratorsName = function getCollaboratorsName(collaborators, cellVal) {
313
+ export var getCollaboratorsName = function getCollaboratorsName(collaborators, cellVal) {
355
314
  if (cellVal) {
356
315
  var collaboratorsName = [];
357
316
  cellVal.forEach(function (v) {
@@ -373,10 +332,7 @@ var getCollaboratorsName = function getCollaboratorsName(collaborators, cellVal)
373
332
 
374
333
  return null;
375
334
  };
376
-
377
- exports.getCollaboratorsName = getCollaboratorsName;
378
-
379
- var getGeolocationDisplayString = function getGeolocationDisplayString(value, columnData) {
335
+ export var getGeolocationDisplayString = function getGeolocationDisplayString(value, columnData) {
380
336
  var _ref4 = columnData || {},
381
337
  geo_format = _ref4.geo_format;
382
338
 
@@ -387,7 +343,7 @@ var getGeolocationDisplayString = function getGeolocationDisplayString(value, co
387
343
  }
388
344
 
389
345
  if (geo_format === 'lng_lat' && value.lng && value.lat) {
390
- return cellValue.lng + ", " + cellValue.lat;
346
+ return "".concat(cellValue.lng, ", ").concat(cellValue.lat);
391
347
  }
392
348
 
393
349
  if (geo_format === 'country_region' && cellValue.country_region) {
@@ -400,20 +356,17 @@ var getGeolocationDisplayString = function getGeolocationDisplayString(value, co
400
356
  detail = cellValue.detail;
401
357
 
402
358
  if (geo_format === 'province') {
403
- return "" + (province || '');
359
+ return "".concat(province || '');
404
360
  }
405
361
 
406
362
  if (geo_format === 'province_city') {
407
- return "" + (province || '') + (city || '');
363
+ return "".concat(province || '').concat(city || '');
408
364
  }
409
365
 
410
- return "" + (province || '') + (city || '') + (district || '') + (detail || '');
366
+ return "".concat(province || '').concat(city || '').concat(district || '').concat(detail || '');
411
367
  };
412
-
413
- exports.getGeolocationDisplayString = getGeolocationDisplayString;
414
-
415
- var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData, _temp) {
416
- var _ref5 = _temp === void 0 ? {} : _temp,
368
+ export var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData) {
369
+ var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
417
370
  _ref5$collaborators = _ref5.collaborators,
418
371
  collaborators = _ref5$collaborators === void 0 ? [] : _ref5$collaborators;
419
372
 
@@ -423,16 +376,16 @@ var getFormulaDisplayString = function getFormulaDisplayString(cellValue, column
423
376
 
424
377
  var result_type = columnData.result_type;
425
378
 
426
- if (result_type === _constants.FORMULA_RESULT_TYPE.NUMBER) {
379
+ if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
427
380
  return getNumberDisplayString(cellValue, columnData);
428
381
  }
429
382
 
430
- if (result_type === _constants.FORMULA_RESULT_TYPE.DATE) {
383
+ if (result_type === FORMULA_RESULT_TYPE.DATE) {
431
384
  var format = columnData.format;
432
385
  return getDateDisplayString(cellValue, format);
433
386
  }
434
387
 
435
- if (result_type === _constants.FORMULA_RESULT_TYPE.ARRAY) {
388
+ if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
436
389
  var array_type = columnData.array_type,
437
390
  array_data = columnData.array_data;
438
391
 
@@ -440,11 +393,11 @@ var getFormulaDisplayString = function getFormulaDisplayString(cellValue, column
440
393
  return null;
441
394
  }
442
395
 
443
- if (_constants.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
396
+ if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
444
397
  return cellValue;
445
398
  }
446
399
 
447
- if (_constants.ARRAY_FORMAL_COLUMNS_TYPES.indexOf(array_type) < 0 && Array.isArray(cellValue)) {
400
+ if (ARRAY_FORMAL_COLUMNS_TYPES.indexOf(array_type) < 0 && Array.isArray(cellValue)) {
448
401
  return cellValue.map(function (val) {
449
402
  return getCellValueDisplayString(val, array_type, {
450
403
  data: array_data,
@@ -465,11 +418,8 @@ var getFormulaDisplayString = function getFormulaDisplayString(cellValue, column
465
418
 
466
419
  return cellValue;
467
420
  };
468
-
469
- exports.getFormulaDisplayString = getFormulaDisplayString;
470
-
471
- function getCellValueDisplayString(cellValue, type, _temp2) {
472
- var _ref6 = _temp2 === void 0 ? {} : _temp2,
421
+ export function getCellValueDisplayString(cellValue, type) {
422
+ var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
473
423
  data = _ref6.data,
474
424
  _ref6$collaborators = _ref6.collaborators,
475
425
  collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators;
@@ -518,7 +468,7 @@ function getCellValueDisplayString(cellValue, type, _temp2) {
518
468
  {
519
469
  var _ref7 = newData || {},
520
470
  _ref7$format = _ref7.format,
521
- format = _ref7$format === void 0 ? _constants.DEFAULT_DATE_FORMAT : _ref7$format;
471
+ format = _ref7$format === void 0 ? DEFAULT_DATE_FORMAT : _ref7$format;
522
472
 
523
473
  return getDateDisplayString(cellValue, format);
524
474
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "0.1.75beta3",
3
+ "version": "0.1.75beta4",
4
4
  "main": "./es/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "0.0.9",
@@ -45,11 +45,11 @@
45
45
  "eslint": "eslint --ext .jsx,.js src --max-warnings=0",
46
46
  "storybook": "start-storybook -p 6006",
47
47
  "build-storybook": "build-storybook -c .storybook -o docs",
48
- "pub:esm": "npm run clean:esm && export BABEL_ENV=production && ./node_modules/.bin/babel src --out-dir es --copy-files",
49
- "pub:lib": "npm run clean:lib && export BABEL_ENV=node && ./node_modules/.bin/babel src --out-dir lib --copy-files",
48
+ "pub:esm": "npm run clean:esm && export BABEL_ENV=node && ./node_modules/.bin/babel src --out-dir es --copy-files",
49
+ "pub:lib": "npm run clean:lib && export BABEL_ENV=production && ./node_modules/.bin/babel src --out-dir lib --copy-files",
50
50
  "pub:umd": "npm run build",
51
- "pub:optimized": "rm es/index.local.js && rm lib/index.local.js",
52
- "prepublishOnly": "npm run pub:esm && npm run pub:lib && npm run pub:umd && npm run pub:optimized"
51
+ "pub:optimized": "rm lib/index.local.js",
52
+ "prepublishOnly": "npm run pub:lib && npm run pub:umd && npm run pub:optimized"
53
53
  },
54
54
  "files": [
55
55
  "assets",
@@ -1 +0,0 @@
1
- @import url('../css/cell-formatter.css');
@@ -1,36 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import cn from 'astro-classname';
7
- import './index.css';
8
-
9
- var AutoNumberFormatter = /*#__PURE__*/function (_React$Component) {
10
- _inherits(AutoNumberFormatter, _React$Component);
11
-
12
- var _super = _createSuper(AutoNumberFormatter);
13
-
14
- function AutoNumberFormatter() {
15
- _classCallCheck(this, AutoNumberFormatter);
16
-
17
- return _super.apply(this, arguments);
18
- }
19
-
20
- _createClass(AutoNumberFormatter, [{
21
- key: "render",
22
- value: function render() {
23
- var _this$props = this.props,
24
- containerClassName = _this$props.containerClassName,
25
- value = _this$props.value;
26
- var classname = cn('dtable-ui cell-formatter-container auto-number-formatter', containerClassName);
27
- return /*#__PURE__*/React.createElement("div", {
28
- className: classname
29
- }, value);
30
- }
31
- }]);
32
-
33
- return AutoNumberFormatter;
34
- }(React.Component);
35
-
36
- export default AutoNumberFormatter;
@@ -1,13 +0,0 @@
1
- @import url('../css/cell-formatter.css');
2
-
3
- .dtable-ui.button-formatter {
4
- height: 26px;
5
- width: 80px;
6
- padding: 5px 8px;
7
- border-width: 1px;
8
- border-style: solid;
9
- border-radius: 3px;
10
- overflow: hidden;
11
- white-space: nowrap;
12
- text-overflow: ellipsis;
13
- }
@@ -1,56 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import cn from 'astro-classname';
7
- import './index.css';
8
-
9
- var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
10
- _inherits(ButtonFormatter, _React$Component);
11
-
12
- var _super = _createSuper(ButtonFormatter);
13
-
14
- function ButtonFormatter() {
15
- _classCallCheck(this, ButtonFormatter);
16
-
17
- return _super.apply(this, arguments);
18
- }
19
-
20
- _createClass(ButtonFormatter, [{
21
- key: "render",
22
- value: function render() {
23
- var _this$props = this.props,
24
- data = _this$props.data,
25
- containerClassName = _this$props.containerClassName,
26
- optionColors = _this$props.optionColors;
27
-
28
- var _ref = data || {},
29
- button_color = _ref.button_color,
30
- button_type = _ref.button_type,
31
- button_name = _ref.button_name;
32
-
33
- if (!button_type) return null;
34
- var colorOption = Array.isArray(optionColors) ? optionColors.find(function (item) {
35
- return item.COLOR === button_color;
36
- }) || optionColors[0] : {
37
- COLOR: '#FFFCB5',
38
- BORDER_COLOR: '#E8E79D',
39
- TEXT_COLOR: '#202428'
40
- };
41
- var btnStyle = {
42
- backgroundColor: colorOption.COLOR,
43
- borderColor: colorOption.BORDER_COLOR,
44
- color: colorOption.TEXT_COLOR
45
- };
46
- return /*#__PURE__*/React.createElement("div", {
47
- className: cn('dtable-ui cell-formatter-container button-formatter', containerClassName),
48
- style: btnStyle
49
- }, button_name);
50
- }
51
- }]);
52
-
53
- return ButtonFormatter;
54
- }(React.Component);
55
-
56
- export default ButtonFormatter;
@@ -1 +0,0 @@
1
- @import url('../css/cell-formatter.css');
@@ -1,58 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import cn from 'astro-classname';
7
- import moment from 'moment';
8
- import './index.css';
9
-
10
- var CTimeFormatter = /*#__PURE__*/function (_React$Component) {
11
- _inherits(CTimeFormatter, _React$Component);
12
-
13
- var _super = _createSuper(CTimeFormatter);
14
-
15
- function CTimeFormatter() {
16
- var _this;
17
-
18
- _classCallCheck(this, CTimeFormatter);
19
-
20
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
21
- args[_key] = arguments[_key];
22
- }
23
-
24
- _this = _super.call.apply(_super, [this].concat(args));
25
-
26
- _this.formatDate = function (date) {
27
- return moment(date).format('YYYY-MM-DD HH:mm:ss');
28
- };
29
-
30
- return _this;
31
- }
32
-
33
- _createClass(CTimeFormatter, [{
34
- key: "render",
35
- value: function render() {
36
- var _this$props = this.props,
37
- date = _this$props.value,
38
- containerClassName = _this$props.containerClassName;
39
- var classname = cn('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
40
-
41
- if (date !== '') {
42
- date = this.formatDate(date);
43
- }
44
-
45
- return /*#__PURE__*/React.createElement("div", {
46
- className: classname
47
- }, date);
48
- }
49
- }]);
50
-
51
- return CTimeFormatter;
52
- }(React.Component);
53
-
54
- CTimeFormatter.defaultProps = {
55
- value: '',
56
- containerClassName: ''
57
- };
58
- export default CTimeFormatter;
@@ -1 +0,0 @@
1
- @import url('../css/cell-formatter.css');
@@ -1,45 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import cn from 'astro-classname';
7
- import './index.css';
8
-
9
- var CheckboxFormatter = /*#__PURE__*/function (_React$PureComponent) {
10
- _inherits(CheckboxFormatter, _React$PureComponent);
11
-
12
- var _super = _createSuper(CheckboxFormatter);
13
-
14
- function CheckboxFormatter() {
15
- _classCallCheck(this, CheckboxFormatter);
16
-
17
- return _super.apply(this, arguments);
18
- }
19
-
20
- _createClass(CheckboxFormatter, [{
21
- key: "render",
22
- value: function render() {
23
- var _this$props = this.props,
24
- value = _this$props.value,
25
- containerClassName = _this$props.containerClassName;
26
- value = value === true ? true : false;
27
- var classname = cn('dtable-ui cell-formatter-container checkbox-formatter', containerClassName);
28
- return /*#__PURE__*/React.createElement("div", {
29
- className: classname
30
- }, /*#__PURE__*/React.createElement("input", {
31
- className: "checkbox",
32
- type: "checkbox",
33
- readOnly: true,
34
- checked: value
35
- }));
36
- }
37
- }]);
38
-
39
- return CheckboxFormatter;
40
- }(React.PureComponent);
41
-
42
- CheckboxFormatter.defaultProps = {
43
- value: false
44
- };
45
- export default CheckboxFormatter;
@@ -1 +0,0 @@
1
- @import url('../css/cell-formatter.css');