dtable-ui-component 5.3.1-beta6 → 5.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/lib/CheckboxEditor/index.css +20 -3
  2. package/lib/CheckboxEditor/index.js +35 -98
  3. package/lib/CheckboxFormatter/index.js +9 -6
  4. package/lib/CollaboratorEditor/index.css +35 -12
  5. package/lib/CollaboratorEditor/index.js +212 -18
  6. package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.js +29 -26
  7. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +97 -0
  8. package/lib/CollaboratorItem/index.css +1 -1
  9. package/lib/CollaboratorItem/index.js +2 -6
  10. package/lib/DTableFiltersPopover/utils/index.js +7 -1
  11. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  12. package/lib/DTableGroupSelect/select-option-group.css +17 -17
  13. package/lib/DTableGroupSelect/select-option-group.js +1 -1
  14. package/lib/DTableSelect/index.js +1 -3
  15. package/lib/DateEditor/index.js +51 -14
  16. package/lib/DateEditor/pc-date-editor-popover.js +12 -145
  17. package/lib/Department-editor/department-single-select.js +1 -1
  18. package/lib/Department-editor/index.js +4 -3
  19. package/lib/DepartmentSingleSelectFormatter/index.js +1 -2
  20. package/lib/FileEditor/index.js +11 -258
  21. package/lib/FileEditor/pc-files-addition/index.js +1 -0
  22. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +1 -0
  23. package/lib/FileEditor/pc-files-preview/index.js +1 -0
  24. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +1 -0
  25. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  26. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  27. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  28. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  29. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  30. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  31. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  32. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  33. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  34. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  35. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  36. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  37. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  38. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  39. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  40. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  41. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  42. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  43. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  44. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  45. package/lib/FileItemFormatter/index.js +20 -19
  46. package/lib/FileItemFormatter/utils.js +99 -0
  47. package/lib/FileUploader/index.js +14 -268
  48. package/lib/FormulaFormatter/index.js +1 -2
  49. package/lib/FormulaFormatter/utils.js +31 -0
  50. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  51. package/lib/MultipleSelectEditor/index.css +9 -0
  52. package/lib/MultipleSelectEditor/index.js +177 -16
  53. package/lib/NumberEditor/index.js +77 -64
  54. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.css +1 -1
  55. package/lib/{RowExpandFormatter/RowExpandEmailFormatter → RowExpandEmailFormatter}/index.js +1 -1
  56. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.css +6 -6
  57. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/index.js +1 -3
  58. package/lib/{RowExpandFormatter/RowExpandFileFormatter → RowExpandFileFormatter}/row-expand-file-item-formatter.js +11 -10
  59. package/lib/RowExpandFormatter/index.css +1 -27
  60. package/lib/RowExpandFormatter/index.js +100 -83
  61. package/lib/{RowExpandFormatter/RowExpandFormulaFormatter → RowExpandFormulaFormatter}/index.js +10 -11
  62. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.css +6 -6
  63. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/index.js +1 -1
  64. package/lib/{RowExpandFormatter/RowExpandImageFormatter → RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
  65. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  66. package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.js +6 -6
  67. package/lib/RowExpandLinkFormatter/utils.js +71 -0
  68. package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.css +1 -1
  69. package/lib/RowExpandUrlFormatter/index.css +1 -0
  70. package/lib/{RowExpandFormatter/RowExpandUrlFormatter → RowExpandUrlFormatter}/index.js +3 -4
  71. package/lib/SingleSelectEditor/index.css +14 -0
  72. package/lib/SingleSelectEditor/index.js +156 -16
  73. package/lib/TextEditor/index.js +42 -113
  74. package/lib/constants/index.js +2 -34
  75. package/lib/css/cell-editor.css +2 -18
  76. package/lib/index.js +46 -74
  77. package/lib/lang/index.js +16 -19
  78. package/lib/locals/de.js +103 -0
  79. package/lib/locals/en.js +104 -0
  80. package/lib/locals/es.js +103 -0
  81. package/lib/locals/fr.js +103 -0
  82. package/lib/locals/pt.js +103 -0
  83. package/lib/locals/ru.js +103 -0
  84. package/lib/locals/zh-CN.js +104 -0
  85. package/lib/select-editor/index.js +6 -6
  86. package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.js +3 -3
  87. package/lib/select-editor/pc-select-editor-popover/index.css +71 -0
  88. package/lib/select-editor/pc-select-editor-popover/index.js +122 -0
  89. package/lib/utils/editor-utils.js +6 -1
  90. package/lib/utils/url.js +8 -121
  91. package/lib/utils/utils.js +2 -145
  92. package/package.json +2 -3
  93. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +0 -257
  94. package/lib/Comment/body/comment.js +0 -190
  95. package/lib/Comment/body/index.css +0 -95
  96. package/lib/Comment/body/index.js +0 -32
  97. package/lib/Comment/footer/btns/index.css +0 -40
  98. package/lib/Comment/footer/btns/index.js +0 -113
  99. package/lib/Comment/footer/index.css +0 -157
  100. package/lib/Comment/footer/index.js +0 -170
  101. package/lib/Comment/footer/input/index.css +0 -52
  102. package/lib/Comment/footer/input/index.js +0 -448
  103. package/lib/Comment/footer/input/participant/index.css +0 -0
  104. package/lib/Comment/footer/input/participant/index.js +0 -53
  105. package/lib/Comment/footer/participants/index.css +0 -22
  106. package/lib/Comment/footer/participants/index.js +0 -68
  107. package/lib/Comment/footer/participants/participant/index.css +0 -5
  108. package/lib/Comment/footer/participants/participant/index.js +0 -32
  109. package/lib/Comment/footer/participants/participant-select/index.css +0 -104
  110. package/lib/Comment/footer/participants/participant-select/index.js +0 -182
  111. package/lib/Comment/index.css +0 -19
  112. package/lib/Comment/index.js +0 -305
  113. package/lib/Comment/model.js +0 -25
  114. package/lib/Comment/utils/common.js +0 -62
  115. package/lib/Comment/utils/index.js +0 -27
  116. package/lib/Comment/utils/utilities.js +0 -176
  117. package/lib/DeleteTip/index.js +0 -50
  118. package/lib/DigitalSignEditor/constants.js +0 -7
  119. package/lib/DigitalSignEditor/index.css +0 -69
  120. package/lib/DigitalSignEditor/index.js +0 -182
  121. package/lib/DigitalSignEditor/service.js +0 -38
  122. package/lib/DigitalSignEditor/signature-board/index.css +0 -35
  123. package/lib/DigitalSignEditor/signature-board/index.js +0 -135
  124. package/lib/DigitalSignEditor/signature-board/signature-tool.js +0 -396
  125. package/lib/DigitalSignEditor/utils.js +0 -29
  126. package/lib/DurationEditor/index.js +0 -111
  127. package/lib/EmailEditor/index.js +0 -59
  128. package/lib/FileEditor/addition-previewer/index.css +0 -1
  129. package/lib/FileEditor/addition-previewer/index.js +0 -52
  130. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +0 -1
  131. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +0 -252
  132. package/lib/FileEditor/constants.js +0 -7
  133. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +0 -74
  134. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +0 -5
  135. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +0 -77
  136. package/lib/FileEditor/files-previewer/file-previewer/index.css +0 -88
  137. package/lib/FileEditor/files-previewer/file-previewer/index.js +0 -167
  138. package/lib/FileEditor/files-previewer/index.css +0 -56
  139. package/lib/FileEditor/files-previewer/index.js +0 -277
  140. package/lib/FileEditor/index.css +0 -6
  141. package/lib/FileEditor/utils.js +0 -22
  142. package/lib/FileUploader/index.css +0 -9
  143. package/lib/GeolocationEditor/country-editor.js +0 -319
  144. package/lib/GeolocationEditor/index.css +0 -641
  145. package/lib/GeolocationEditor/index.js +0 -241
  146. package/lib/GeolocationEditor/location-editor.js +0 -368
  147. package/lib/GeolocationEditor/map-editor/index.js +0 -456
  148. package/lib/GeolocationEditor/map-editor/large-editor/index.css +0 -137
  149. package/lib/GeolocationEditor/map-editor/large-editor/index.js +0 -461
  150. package/lib/GeolocationEditor/map-editor-utils.js +0 -153
  151. package/lib/GeolocationEditor/map-selection-editor/index.js +0 -455
  152. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +0 -1
  153. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +0 -447
  154. package/lib/GeolocationEditor/parse-geolocation.js +0 -282
  155. package/lib/GeolocationEditor/province-city-editor.js +0 -292
  156. package/lib/GeolocationEditor/province-editor.js +0 -226
  157. package/lib/GeolocationEditor/selector-header-item.js +0 -28
  158. package/lib/GeolocationEditor/selector-list.js +0 -33
  159. package/lib/GeolocationEditor/with-ref.js +0 -27
  160. package/lib/ImageEditor/addition-previewer/image-link/index.css +0 -45
  161. package/lib/ImageEditor/addition-previewer/image-link/index.js +0 -73
  162. package/lib/ImageEditor/addition-previewer/index.css +0 -106
  163. package/lib/ImageEditor/addition-previewer/index.js +0 -63
  164. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +0 -125
  165. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +0 -254
  166. package/lib/ImageEditor/constants.js +0 -7
  167. package/lib/ImageEditor/images-previewer/image-preview/index.css +0 -59
  168. package/lib/ImageEditor/images-previewer/image-preview/index.js +0 -155
  169. package/lib/ImageEditor/images-previewer/index.css +0 -18
  170. package/lib/ImageEditor/images-previewer/index.js +0 -140
  171. package/lib/ImageEditor/index.css +0 -24
  172. package/lib/ImageEditor/index.js +0 -194
  173. package/lib/ImageThumbnail/index.css +0 -20
  174. package/lib/ImageThumbnail/index.js +0 -136
  175. package/lib/RowExpandDialog/body/index.css +0 -21
  176. package/lib/RowExpandDialog/body/index.js +0 -262
  177. package/lib/RowExpandDialog/column-content/index.css +0 -44
  178. package/lib/RowExpandDialog/column-content/index.js +0 -50
  179. package/lib/RowExpandDialog/header/index.css +0 -31
  180. package/lib/RowExpandDialog/header/index.js +0 -55
  181. package/lib/RowExpandDialog/index.css +0 -24
  182. package/lib/RowExpandDialog/index.js +0 -252
  183. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +0 -22
  184. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +0 -24
  185. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +0 -18
  186. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +0 -43
  187. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +0 -5
  188. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +0 -232
  189. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +0 -130
  190. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +0 -129
  191. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +0 -13
  192. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +0 -208
  193. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +0 -105
  194. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +0 -2
  195. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +0 -125
  196. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +0 -1
  197. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +0 -146
  198. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +0 -17
  199. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +0 -165
  200. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +0 -6
  201. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +0 -170
  202. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +0 -6
  203. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +0 -123
  204. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +0 -44
  205. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +0 -224
  206. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +0 -105
  207. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +0 -13
  208. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +0 -152
  209. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +0 -58
  210. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +0 -192
  211. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +0 -4
  212. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +0 -127
  213. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +0 -31
  214. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +0 -130
  215. package/lib/RowExpandEditor/constants.js +0 -44
  216. package/lib/RowExpandEditor/index.css +0 -0
  217. package/lib/RowExpandEditor/index.js +0 -32
  218. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +0 -27
  219. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +0 -1
  220. package/lib/RowExpandFormatter/constants.js +0 -60
  221. package/lib/UploadProgress/index.js +0 -38
  222. package/lib/UrlEditor/index.js +0 -62
  223. package/lib/common/editor-base.js +0 -53
  224. package/lib/constants/file.js +0 -96
  225. package/lib/constants/key-codes.js +0 -109
  226. package/lib/hooks/index.js +0 -16
  227. package/lib/locales/de.json +0 -167
  228. package/lib/locales/en.json +0 -167
  229. package/lib/locales/es.json +0 -167
  230. package/lib/locales/fr.json +0 -167
  231. package/lib/locales/pt.json +0 -167
  232. package/lib/locales/ru.json +0 -167
  233. package/lib/locales/zh-CN.json +0 -167
  234. package/lib/select-editor/pc-select-editor/index.css +0 -85
  235. package/lib/select-editor/pc-select-editor/index.js +0 -290
  236. package/lib/utils/cell-comparer.js +0 -35
  237. package/lib/utils/cell.js +0 -55
  238. package/lib/utils/column-utils.js +0 -25
  239. package/lib/utils/get-event-transfer.js +0 -75
  240. package/lib/utils/hotkey.js +0 -37
  241. package/lib/utils/object-utils.js +0 -61
  242. /package/lib/CollaboratorEditor/{mb-collaborator-editor → mb-collaborator-editor-popover}/index.css +0 -0
  243. /package/lib/CollaboratorEditor/{pc-collaborator-editor → pc-collaborator-editor-popover}/index.css +0 -0
  244. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/index.css +0 -0
  245. /package/lib/{RowExpandFormatter/RowExpandLinkFormatter → RowExpandLinkFormatter}/value-display-utils.js +0 -0
  246. /package/lib/{RowExpandFormatter/RowExpandRateFormatter → RowExpandRateFormatter}/index.js +0 -0
  247. /package/lib/select-editor/{mb-select-editor → mb-select-editor-popover}/index.css +0 -0
@@ -1,305 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _dtableUtils = require("dtable-utils");
10
- var _Loading = _interopRequireDefault(require("../Loading"));
11
- var _toaster = _interopRequireDefault(require("../toaster"));
12
- var _body = _interopRequireDefault(require("./body"));
13
- var _footer = _interopRequireDefault(require("./footer"));
14
- var _model = _interopRequireDefault(require("./model"));
15
- var _utils = require("../utils/utils");
16
- var _lang = require("../lang");
17
- require("./index.css");
18
- const ROW_COMMENT = 'row_comment';
19
- class Comment extends _react.default.Component {
20
- constructor(_props) {
21
- var _this;
22
- super(_props);
23
- _this = this;
24
- this.handleError = error => {
25
- let errMsg = (0, _utils.getErrorMsg)(error, true);
26
- if (!error.response || error.response.status !== 403) {
27
- _toaster.default.danger((0, _lang.getLocale)(errMsg));
28
- }
29
- };
30
- // comment and count
31
- this.updateCount = function (row) {
32
- let count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
33
- _this.setState({
34
- count
35
- }, () => {
36
- _this.props.updateCount && _this.props.updateCount(row, count);
37
- });
38
- };
39
- this.reCalculateComments = function (row) {
40
- let pageNum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
41
- let isGetCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
42
- _this.initComments(row, 1, pageNum);
43
- if (!isGetCount) return;
44
- const {
45
- api
46
- } = _this.props;
47
- api.getCount(row).then(res => {
48
- const count = res.data.count;
49
- _this.updateCount(row, count);
50
- }).catch(e => {
51
- _this.handleError(e);
52
- });
53
- };
54
- this.initComments = function (row) {
55
- let page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
56
- let perPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
57
- const {
58
- api
59
- } = _this.props;
60
- api.get(row, page, perPage).then(res => {
61
- console.log(res);
62
- let comments = res.data.comment_list || [];
63
- let newComments = [];
64
- comments.forEach(item => {
65
- const comment = new _model.default(item);
66
- newComments.push(comment);
67
- });
68
- _this.setState({
69
- comments: newComments,
70
- isLoading: false
71
- });
72
- }).catch(e => {
73
- _this.handleError(e);
74
- });
75
- };
76
- this.addComment = (newComment, _ref) => {
77
- let {
78
- successCallback,
79
- failCallback
80
- } = _ref;
81
- const {
82
- row,
83
- api
84
- } = this.props;
85
- api.add(row, newComment).then(res => api.getCount(row)).then(res => {
86
- const count = res.data.count;
87
- this.updateCount(row, count);
88
- this.reCalculateComments(row, count, false);
89
- successCallback();
90
- }).catch(error => {
91
- failCallback && failCallback(error);
92
- });
93
- this.setState({
94
- isFirstLoading: true
95
- });
96
- };
97
- this.resolveComment = (event, commentID) => {
98
- event.persist();
99
- const {
100
- row,
101
- api
102
- } = this.props;
103
- api.update(row, commentID, null, 1).then(() => {
104
- this.reCalculateComments(row);
105
- }).catch(error => {
106
- this.handleError(error);
107
- });
108
- };
109
- this.deleteComment = (event, commentID) => {
110
- const {
111
- api,
112
- row
113
- } = this.props;
114
- api.delete(row, commentID).then(() => {
115
- this.reCalculateComments(row);
116
- }).catch(e => {
117
- this.handleError(e);
118
- });
119
- };
120
- // notification
121
- this.onNewNotification = notification => {
122
- const {
123
- msg_type
124
- } = notification;
125
- if (msg_type !== ROW_COMMENT) return;
126
- this.setState({
127
- isFirstLoading: true
128
- });
129
- const {
130
- row,
131
- api
132
- } = this.props;
133
- api.getCount(row).then(res => {
134
- const count = res.data.count;
135
- this.updateCount(row, count);
136
- this.reCalculateComments(row, count, false);
137
- }).catch(e => {
138
- this.handleError(e);
139
- });
140
- };
141
- // collaborators
142
- this.initCollaborators = props => {
143
- const {
144
- columns,
145
- row,
146
- collaborators
147
- } = props;
148
- let collaboratorColumnKeyList = [];
149
- columns.forEach(column => {
150
- if (column.type === _dtableUtils.CellType.COLLABORATOR) {
151
- collaboratorColumnKeyList.push(column.key);
152
- }
153
- });
154
- if (collaboratorColumnKeyList.length === 0) {
155
- this.setState({
156
- collaborators
157
- });
158
- return;
159
- }
160
- let rowCollaborators = [];
161
- collaboratorColumnKeyList.forEach(collaboratorKey => {
162
- if (row[collaboratorKey] && row[collaboratorKey].length > 0) {
163
- rowCollaborators.push(...row[collaboratorKey]);
164
- }
165
- });
166
- rowCollaborators = Array.from(new Set(rowCollaborators));
167
- let newCollaborators = [];
168
- if (rowCollaborators.length > 0) {
169
- collaborators.forEach(collaborator => {
170
- let rowCollaborator = rowCollaborators.find(rowCollaboratorItem => {
171
- return rowCollaboratorItem === collaborator.email;
172
- });
173
- if (rowCollaborator) {
174
- newCollaborators.unshift(collaborator);
175
- } else {
176
- newCollaborators.push(collaborator);
177
- }
178
- });
179
- } else {
180
- newCollaborators = collaborators;
181
- }
182
- this.setState({
183
- collaborators: newCollaborators
184
- });
185
- };
186
- // scroll
187
- this.onScrollBottom = () => {
188
- const commentListPaddingHeight = 16;
189
- this.body.scrollTop = this.bodyContent.offsetHeight - this.body.offsetHeight + commentListPaddingHeight;
190
- this.setState({
191
- isFirstLoading: false
192
- });
193
- };
194
- this.onScroll = () => {
195
- if (this.body.offsetHeight + this.body.scrollTop + 1 < this.bodyContent.offsetHeight + 32) return; // 16 is padding height
196
- const {
197
- api,
198
- row
199
- } = this.props;
200
- const {
201
- comments,
202
- count
203
- } = this.state;
204
- let currentCommentsLength = comments.length;
205
- if (currentCommentsLength < count) {
206
- // Have pagination
207
- let page = currentCommentsLength % 10 === 0 ? Math.floor(currentCommentsLength / 10) + 1 : Math.ceil(currentCommentsLength / 10);
208
- if (page === 0) return;
209
- api.get(row, page, 10).then(res => {
210
- let newComments = comments.slice(0);
211
- const nextPageCommentList = res.data.comment_list || [];
212
- nextPageCommentList.forEach(item => {
213
- const comment = new Comment(item);
214
- const commentId = comment.id;
215
- const commentIndex = newComments.findIndex(item => item.id === commentId);
216
- if (commentIndex === -1) {
217
- newComments.push(comment);
218
- }
219
- });
220
- this.setState({
221
- comments: newComments,
222
- isFirstLoading: false
223
- });
224
- }).catch(e => {
225
- this.handleError(e);
226
- });
227
- }
228
- };
229
- this.state = {
230
- count: 0,
231
- collaborators: _props.collaborators || [],
232
- comments: [],
233
- isLoading: true,
234
- isFirstLoading: true
235
- };
236
- this.unsubscribeNotification = null;
237
- }
238
- componentDidMount() {
239
- var _this$props$eventBus;
240
- this.initComments(this.props.row);
241
- this.initCollaborators(this.props);
242
- this.unsubscribeNotification = (_this$props$eventBus = this.props.eventBus) === null || _this$props$eventBus === void 0 ? void 0 : _this$props$eventBus.subscribe('new-notification', this.onNewNotification);
243
- }
244
- UNSAFE_componentWillReceiveProps(nextProps) {
245
- if (this.props.row._id !== nextProps.row._id) {
246
- this.initComments(nextProps.row);
247
- this.initCollaborators(nextProps);
248
- this.setState({
249
- isFirstLoading: true,
250
- isLoading: true
251
- });
252
- }
253
- }
254
- componentWillUnmount() {
255
- this.body = null;
256
- this.bodyContent = null;
257
- this.unsubscribeNotification();
258
- }
259
- render() {
260
- const {
261
- collaborators,
262
- comments,
263
- isLoading,
264
- isFirstLoading
265
- } = this.state;
266
- const {
267
- autoFocusInput,
268
- row,
269
- columns,
270
- onInputFocus,
271
- onInputBlur,
272
- api,
273
- uploadFile
274
- } = this.props;
275
- return /*#__PURE__*/_react.default.createElement("div", {
276
- className: "dtable-ui-comments h-100 w-100"
277
- }, /*#__PURE__*/_react.default.createElement("div", {
278
- className: "dtable-ui-comments-body",
279
- onScroll: this.onScroll,
280
- ref: ref => this.body = ref
281
- }, /*#__PURE__*/_react.default.createElement("div", {
282
- ref: ref => this.bodyContent = ref
283
- }, isLoading ? /*#__PURE__*/_react.default.createElement("div", {
284
- className: "w-100 h-100 d-flex align-items-center justify-content-center"
285
- }, /*#__PURE__*/_react.default.createElement(_Loading.default, null)) : /*#__PURE__*/_react.default.createElement(_body.default, {
286
- isFirstLoading: isFirstLoading,
287
- comments: comments,
288
- collaborators: collaborators,
289
- onDelete: this.deleteComment,
290
- onResolve: this.resolveComment,
291
- onScrollBottom: this.onScrollBottom
292
- }))), /*#__PURE__*/_react.default.createElement(_footer.default, {
293
- autoFocusInput: autoFocusInput,
294
- collaborators: collaborators,
295
- row: row,
296
- columns: columns,
297
- addComment: this.addComment,
298
- onChangeParticipants: api.modifyParticipants,
299
- uploadFile: uploadFile,
300
- onInputFocus: onInputFocus,
301
- onInputBlur: onInputBlur
302
- }));
303
- }
304
- }
305
- var _default = exports.default = Comment;
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _dayjs = _interopRequireDefault(require("dayjs"));
9
- class Comment {
10
- constructor(object) {
11
- this.id = object.id || null;
12
- this.author = object.author || null;
13
- this.comment = object.comment || null;
14
- this.dtable_uuid = object.dtable_uuid || null;
15
- this.row_id = object.row_id || null;
16
- this.created_at = object.created_at || null;
17
- this.updated_at = object.updated_at || null;
18
- this.resolved = object.resolved || 0;
19
- if (this.created_at) {
20
- const time = new Date(this.created_at).getTime();
21
- this.created_at = (0, _dayjs.default)(time).format('YYYY-MM-DD HH:mm');
22
- }
23
- }
24
- }
25
- var _default = exports.default = Comment;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSelectionCoords = void 0;
7
- const getSelectionCoords = () => {
8
- let doc = window.document;
9
- let sel = doc.selection;
10
- let range;
11
- let rects;
12
- let rect;
13
- let x = 0;
14
- let y = 0;
15
- if (sel) {
16
- if (sel.type !== 'Control') {
17
- range = sel.createRange();
18
- range.collapse(true);
19
- x = range.boundingLeft;
20
- y = range.boundingTop;
21
- }
22
- } else if (window.getSelection) {
23
- sel = window.getSelection();
24
- if (sel.rangeCount) {
25
- range = sel.getRangeAt(0).cloneRange();
26
- if (range.getClientRects) {
27
- range.collapse(true);
28
- rects = range.getClientRects();
29
- if (rects.length > 0) {
30
- rect = rects[0];
31
- }
32
- // When the cursor is at the beginning of the line, rect is undefined
33
- if (rect) {
34
- x = rect.left;
35
- y = rect.top;
36
- }
37
- }
38
- // Fall back to inserting a temporary element
39
- if (x === 0 && y === 0 || rect === undefined) {
40
- let span = doc.createElement('span');
41
- if (span.getClientRects) {
42
- // Ensure span has dimensions and position by
43
- // adding a zero-width space character
44
- span.appendChild(doc.createTextNode('\u200b'));
45
- range.insertNode(span);
46
- rect = span.getClientRects()[0];
47
- x = rect.left;
48
- y = rect.top;
49
- let spanParent = span.parentNode;
50
- spanParent.removeChild(span);
51
- // Glue any broken text nodes back together
52
- spanParent.normalize();
53
- }
54
- }
55
- }
56
- }
57
- return {
58
- x: x,
59
- y: y
60
- };
61
- };
62
- exports.getSelectionCoords = getSelectionCoords;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _common = require("./common");
7
- Object.keys(_common).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _common[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _common[key];
14
- }
15
- });
16
- });
17
- var _utilities = require("./utilities");
18
- Object.keys(_utilities).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _utilities[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _utilities[key];
25
- }
26
- });
27
- });
@@ -1,176 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Utilities = void 0;
8
- var _getEventTransfer = _interopRequireDefault(require("../../utils/get-event-transfer"));
9
- class Utilities {
10
- constructor() {
11
- this.onInsertElement = _ref => {
12
- let {
13
- commentRef,
14
- selection,
15
- range,
16
- content,
17
- nodeType
18
- } = _ref;
19
- if (range) {
20
- selection.removeAllRanges();
21
- selection.addRange(range);
22
- }
23
- return this.createHtmlElement({
24
- commentRef,
25
- selection,
26
- range,
27
- content,
28
- nodeType
29
- });
30
- };
31
- this.getHtmlElement = (nodeType, content) => {
32
- switch (nodeType) {
33
- case 'image':
34
- {
35
- let parentElement = document.createElement('div');
36
- parentElement.className = 'image-container';
37
- parentElement.contentEditable = 'false';
38
- let imageContainer = document.createElement('img');
39
- imageContainer.src = content;
40
- imageContainer.height = 60;
41
- parentElement.appendChild(imageContainer);
42
- return parentElement.outerHTML;
43
- }
44
- default:
45
- {
46
- return '';
47
- }
48
- }
49
- };
50
- this.createHtmlElement = _ref2 => {
51
- let {
52
- commentRef,
53
- selection,
54
- range,
55
- content,
56
- nodeType
57
- } = _ref2;
58
- let spanNode1;
59
- let spanNode2;
60
- let imageContainer;
61
- if (nodeType === 'image') {
62
- spanNode1 = document.createElement('div');
63
- spanNode1.className = 'image-container';
64
- spanNode1.contentEditable = 'false';
65
- imageContainer = document.createElement('img');
66
- imageContainer.src = content;
67
- imageContainer.height = 60;
68
- spanNode1.appendChild(imageContainer);
69
- spanNode2 = document.createElement('span');
70
- spanNode2.innerHTML = ' ';
71
- }
72
- if (nodeType === 'collaborator') {
73
- spanNode1 = document.createElement('span');
74
- spanNode2 = document.createElement('span');
75
- spanNode1.className = 'at-text';
76
- spanNode1.contentEditable = 'true';
77
- spanNode1.innerHTML = "@".concat(content.name);
78
- spanNode2.innerHTML = ' ';
79
- }
80
- let frag = document.createDocumentFragment();
81
- let lastNode;
82
- frag.appendChild(spanNode1);
83
- lastNode = frag.appendChild(spanNode2.firstChild);
84
- if (range) {
85
- range.insertNode(frag);
86
- } else {
87
- commentRef.appendChild(frag);
88
- range = selection.getRangeAt(0);
89
- }
90
- if (lastNode) {
91
- range = range.cloneRange();
92
- range.setStartAfter(lastNode);
93
- range.collapse(true);
94
- selection.removeAllRanges();
95
- selection.addRange(range);
96
- }
97
- return range;
98
- };
99
- this.onSelectParticipant = _ref3 => {
100
- let {
101
- selection,
102
- range,
103
- participant,
104
- callBack,
105
- commentRef
106
- } = _ref3;
107
- if (range) {
108
- // delete '@xxx';
109
- selection.removeAllRanges();
110
- selection.addRange(range);
111
- const textNode = range.startContainer;
112
- const atIndex = this.getAtIndexWithAnchorPosition(range.startOffset, textNode.data);
113
- if (atIndex > -1) {
114
- range.setStart(textNode, atIndex);
115
- range.setEnd(textNode, range.endOffset);
116
- range.deleteContents();
117
- }
118
- }
119
- let newRange = this.createHtmlElement({
120
- selection,
121
- range,
122
- content: participant,
123
- nodeType: 'collaborator',
124
- commentRef
125
- });
126
- if (callBack) {
127
- callBack();
128
- }
129
- if (commentRef) {
130
- commentRef.focus();
131
- }
132
- return newRange;
133
- };
134
- /**
135
- * get the index of '@' from anchor position.
136
- * @param {*} anchorPosition '@text|anchor position|'
137
- * @param {*} text '@abc'
138
- * @returns index
139
- * e.g. '@abc|anchor position|' // 0
140
- * '@123 @|anchor position| @abc' // 5
141
- */
142
- this.getAtIndexWithAnchorPosition = (anchorPosition, text) => {
143
- let atIndex = -1;
144
- for (let i = anchorPosition - 1; i > -1; i--) {
145
- if (text[i] === '@') {
146
- atIndex = i;
147
- break;
148
- }
149
- }
150
- return atIndex;
151
- };
152
- this.onPaste = (event, callBack) => {
153
- event.stopPropagation();
154
- let cliperData = (0, _getEventTransfer.default)(event);
155
- if (cliperData.files) {
156
- let file = cliperData.files[0];
157
- let isImage = /image/i.test(file.type);
158
- if (isImage) {
159
- event.preventDefault();
160
- if (callBack) {
161
- callBack(cliperData.files);
162
- }
163
- }
164
- } else {
165
- event.preventDefault();
166
- let text = cliperData.text;
167
- if (document.queryCommandSupported('insertText')) {
168
- document.execCommand('insertText', false, text);
169
- } else {
170
- document.execCommand('paste', false, text);
171
- }
172
- }
173
- };
174
- }
175
- }
176
- exports.Utilities = Utilities;
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
10
- var _ModalPortal = _interopRequireDefault(require("../ModalPortal"));
11
- var _lang = require("../lang");
12
- class DeleteTip extends _react.default.Component {
13
- constructor() {
14
- super(...arguments);
15
- this.handleOutsideClick = e => {
16
- if (this.tipContainer && !this.tipContainer.contains(e.target)) {
17
- this.props.toggle();
18
- }
19
- };
20
- }
21
- render() {
22
- const {
23
- toggle,
24
- deleteImage,
25
- position,
26
- deleteTip
27
- } = this.props;
28
- return /*#__PURE__*/_react.default.createElement(_ModalPortal.default, null, /*#__PURE__*/_react.default.createElement(_ClickOutside.default, {
29
- onClickOutside: this.handleOutsideClick
30
- }, /*#__PURE__*/_react.default.createElement("div", {
31
- ref: node => this.tipContainer = node,
32
- className: "dtable-tip tip-container",
33
- style: {
34
- top: position.top,
35
- left: position.left
36
- }
37
- }, /*#__PURE__*/_react.default.createElement("b", {
38
- className: "mb-4"
39
- }, deleteTip), /*#__PURE__*/_react.default.createElement("div", {
40
- className: "d-flex justify-content-end"
41
- }, /*#__PURE__*/_react.default.createElement("button", {
42
- className: "btn btn-secondary mr-2",
43
- onClick: toggle
44
- }, (0, _lang.getLocale)('Cancel')), /*#__PURE__*/_react.default.createElement("button", {
45
- className: "btn btn-primary",
46
- onClick: deleteImage
47
- }, (0, _lang.getLocale)('Delete'))))));
48
- }
49
- }
50
- var _default = exports.default = DeleteTip;
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DIGITAL_SIGNS_FOLDER = void 0;
7
- const DIGITAL_SIGNS_FOLDER = exports.DIGITAL_SIGNS_FOLDER = 'digital-signs';