dtable-ui-component 5.3.6 → 5.3.8-beta

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 (256) hide show
  1. package/lib/ButtonFormatter/index.js +8 -2
  2. package/lib/CheckboxEditor/index.css +8 -20
  3. package/lib/CheckboxEditor/index.js +98 -35
  4. package/lib/CheckboxFormatter/index.css +5 -0
  5. package/lib/CheckboxFormatter/index.js +9 -15
  6. package/lib/CollaboratorEditor/index.css +12 -35
  7. package/lib/CollaboratorEditor/index.js +18 -212
  8. package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +27 -30
  9. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
  10. package/lib/CollaboratorItem/index.css +7 -1
  11. package/lib/CollaboratorItem/index.js +6 -2
  12. package/lib/Comment/body/comment.js +190 -0
  13. package/lib/Comment/body/index.css +95 -0
  14. package/lib/Comment/body/index.js +32 -0
  15. package/lib/Comment/footer/btns/index.css +40 -0
  16. package/lib/Comment/footer/btns/index.js +113 -0
  17. package/lib/Comment/footer/index.css +157 -0
  18. package/lib/Comment/footer/index.js +169 -0
  19. package/lib/Comment/footer/input/index.css +52 -0
  20. package/lib/Comment/footer/input/index.js +448 -0
  21. package/lib/Comment/footer/input/participant/index.css +0 -0
  22. package/lib/Comment/footer/input/participant/index.js +53 -0
  23. package/lib/Comment/footer/participants/index.css +22 -0
  24. package/lib/Comment/footer/participants/index.js +68 -0
  25. package/lib/Comment/footer/participants/participant/index.css +5 -0
  26. package/lib/Comment/footer/participants/participant/index.js +32 -0
  27. package/lib/Comment/footer/participants/participant-select/index.css +104 -0
  28. package/lib/Comment/footer/participants/participant-select/index.js +182 -0
  29. package/lib/Comment/index.css +19 -0
  30. package/lib/Comment/index.js +304 -0
  31. package/lib/Comment/model.js +25 -0
  32. package/lib/Comment/utils/common.js +62 -0
  33. package/lib/Comment/utils/index.js +27 -0
  34. package/lib/Comment/utils/utilities.js +176 -0
  35. package/lib/DTableCustomizeSelect/index.js +2 -2
  36. package/lib/DTableFiltersPopover/utils/index.js +1 -7
  37. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  38. package/lib/DTableGroupSelect/index.js +3 -3
  39. package/lib/DTableSelect/index.js +3 -1
  40. package/lib/DateEditor/index.js +14 -51
  41. package/lib/DateEditor/pc-date-editor-popover.js +149 -12
  42. package/lib/{common/delete-tip.js → DeleteTip/index.js} +12 -16
  43. package/lib/Department-editor/department-single-select.js +1 -1
  44. package/lib/Department-editor/index.js +3 -4
  45. package/lib/DepartmentSingleSelectFormatter/index.js +3 -2
  46. package/lib/DigitalSignEditor/constants.js +7 -0
  47. package/lib/DigitalSignEditor/index.css +69 -0
  48. package/lib/DigitalSignEditor/index.js +182 -0
  49. package/lib/DigitalSignEditor/service.js +39 -0
  50. package/lib/DigitalSignEditor/signature-board/index.css +35 -0
  51. package/lib/DigitalSignEditor/signature-board/index.js +135 -0
  52. package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
  53. package/lib/DigitalSignEditor/utils.js +29 -0
  54. package/lib/DurationEditor/index.js +110 -0
  55. package/lib/EmailEditor/index.js +58 -0
  56. package/lib/FileEditor/addition-previewer/index.css +1 -0
  57. package/lib/FileEditor/addition-previewer/index.js +52 -0
  58. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
  59. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
  60. package/lib/FileEditor/constants.js +7 -0
  61. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
  62. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
  63. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
  64. package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
  65. package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
  66. package/lib/FileEditor/files-previewer/index.css +56 -0
  67. package/lib/FileEditor/files-previewer/index.js +277 -0
  68. package/lib/FileEditor/index.css +6 -0
  69. package/lib/FileEditor/index.js +258 -11
  70. package/lib/FileEditor/utils.js +22 -0
  71. package/lib/FileItemFormatter/index.js +19 -20
  72. package/lib/FileUploader/index.css +9 -0
  73. package/lib/FileUploader/index.js +268 -14
  74. package/lib/FormulaFormatter/cell-value-validator.js +17 -17
  75. package/lib/FormulaFormatter/index.js +2 -1
  76. package/lib/FormulaFormatter/utils.js +0 -31
  77. package/lib/GeolocationEditor/country-editor.js +319 -0
  78. package/lib/GeolocationEditor/index.css +641 -0
  79. package/lib/GeolocationEditor/index.js +240 -0
  80. package/lib/GeolocationEditor/location-editor.js +368 -0
  81. package/lib/GeolocationEditor/map-editor/index.js +456 -0
  82. package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
  83. package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
  84. package/lib/GeolocationEditor/map-editor-utils.js +153 -0
  85. package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
  86. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
  87. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
  88. package/lib/GeolocationEditor/parse-geolocation.js +282 -0
  89. package/lib/GeolocationEditor/province-city-editor.js +292 -0
  90. package/lib/GeolocationEditor/province-editor.js +226 -0
  91. package/lib/GeolocationEditor/selector-header-item.js +28 -0
  92. package/lib/GeolocationEditor/selector-list.js +33 -0
  93. package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
  94. package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
  95. package/lib/ImageEditor/addition-previewer/index.css +106 -0
  96. package/lib/ImageEditor/addition-previewer/index.js +63 -0
  97. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
  98. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
  99. package/lib/ImageEditor/constants.js +7 -0
  100. package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
  101. package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
  102. package/lib/ImageEditor/images-previewer/index.css +18 -0
  103. package/lib/ImageEditor/images-previewer/index.js +140 -0
  104. package/lib/ImageEditor/index.css +24 -0
  105. package/lib/ImageEditor/index.js +194 -0
  106. package/lib/ImageThumbnail/index.css +20 -0
  107. package/lib/ImageThumbnail/index.js +137 -0
  108. package/lib/LinkEditor/index.js +2 -3
  109. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  110. package/lib/MultipleSelectEditor/index.js +16 -177
  111. package/lib/NumberEditor/index.js +63 -77
  112. package/lib/RowExpandDialog/body/index.css +21 -0
  113. package/lib/RowExpandDialog/body/index.js +262 -0
  114. package/lib/RowExpandDialog/column-content/index.css +48 -0
  115. package/lib/RowExpandDialog/column-content/index.js +50 -0
  116. package/lib/RowExpandDialog/header/index.css +31 -0
  117. package/lib/RowExpandDialog/header/index.js +55 -0
  118. package/lib/RowExpandDialog/index.css +28 -0
  119. package/lib/RowExpandDialog/index.js +237 -0
  120. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
  121. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
  122. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
  123. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
  124. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
  125. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
  126. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
  127. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +106 -0
  128. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
  129. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
  130. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
  131. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
  132. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
  133. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
  134. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +148 -0
  135. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
  136. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
  137. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +11 -0
  138. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
  139. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
  140. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +123 -0
  141. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
  142. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +224 -0
  143. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
  144. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
  145. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
  146. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
  147. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +193 -0
  148. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
  149. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
  150. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
  151. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
  152. package/lib/RowExpandEditor/constants.js +44 -0
  153. package/lib/RowExpandEditor/index.css +0 -0
  154. package/lib/RowExpandEditor/index.js +32 -0
  155. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
  156. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
  157. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
  158. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
  159. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
  160. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +12 -13
  161. package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
  162. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
  163. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
  164. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +5 -5
  165. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  166. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +2 -2
  167. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +20 -20
  168. package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
  169. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
  170. package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
  171. package/lib/RowExpandFormatter/constants.js +61 -0
  172. package/lib/RowExpandFormatter/index.css +28 -3
  173. package/lib/RowExpandFormatter/index.js +113 -131
  174. package/lib/SingleSelectEditor/index.js +16 -156
  175. package/lib/SvgIcon/index.css +11 -0
  176. package/lib/SvgIcon/index.js +29 -0
  177. package/lib/TextEditor/index.js +112 -42
  178. package/lib/UploadProgress/index.js +38 -0
  179. package/lib/UrlEditor/index.js +61 -0
  180. package/lib/common/editor-base.js +52 -0
  181. package/lib/constants/file.js +96 -0
  182. package/lib/constants/index.js +27 -15
  183. package/lib/constants/key-codes.js +109 -0
  184. package/lib/css/cell-editor.css +18 -2
  185. package/lib/formatterConfig/base-formatter-config.js +23 -23
  186. package/lib/formatterConfig/index.js +3 -3
  187. package/lib/hooks/index.js +16 -0
  188. package/lib/index.js +81 -46
  189. package/lib/lang/index.js +19 -16
  190. package/lib/locales/de.json +167 -0
  191. package/lib/locales/en.json +167 -0
  192. package/lib/locales/es.json +167 -0
  193. package/lib/locales/fr.json +167 -0
  194. package/lib/locales/pt.json +167 -0
  195. package/lib/locales/ru.json +167 -0
  196. package/lib/locales/zh-CN.json +167 -0
  197. package/lib/select-editor/index.js +6 -6
  198. package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
  199. package/lib/select-editor/pc-select-editor/index.css +85 -0
  200. package/lib/select-editor/pc-select-editor/index.js +290 -0
  201. package/lib/utils/cell-comparer.js +35 -0
  202. package/lib/utils/cell.js +55 -0
  203. package/lib/utils/column-utils.js +25 -0
  204. package/lib/utils/editor-utils.js +1 -6
  205. package/lib/utils/get-event-transfer.js +75 -0
  206. package/lib/utils/hotkey.js +37 -0
  207. package/lib/utils/object-utils.js +61 -0
  208. package/lib/utils/url.js +126 -8
  209. package/lib/utils/utils.js +119 -2
  210. package/package.json +3 -2
  211. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
  212. package/lib/FileEditor/pc-files-addition/index.js +0 -1
  213. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
  214. package/lib/FileEditor/pc-files-preview/index.js +0 -1
  215. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
  216. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  217. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  218. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  219. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  220. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  221. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  222. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  223. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  224. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  225. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  226. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  227. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  228. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  229. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  230. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  231. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  232. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  233. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  234. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  235. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  236. package/lib/FileItemFormatter/utils.js +0 -99
  237. package/lib/MultipleSelectEditor/index.css +0 -9
  238. package/lib/RowExpandLinkFormatter/utils.js +0 -71
  239. package/lib/RowExpandUrlFormatter/index.css +0 -1
  240. package/lib/SingleSelectEditor/index.css +0 -14
  241. package/lib/common/modal-portal.js +0 -26
  242. package/lib/locals/de.js +0 -103
  243. package/lib/locals/en.js +0 -104
  244. package/lib/locals/es.js +0 -103
  245. package/lib/locals/fr.js +0 -103
  246. package/lib/locals/pt.js +0 -103
  247. package/lib/locals/ru.js +0 -103
  248. package/lib/locals/zh-CN.js +0 -104
  249. package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
  250. package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
  251. /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
  252. /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
  253. /package/lib/{common/delete-tip.css → DeleteTip/index.css} +0 -0
  254. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
  255. /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
  256. /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
@@ -0,0 +1,448 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _dtableUtils = require("dtable-utils");
12
+ var _ModalPortal = _interopRequireDefault(require("../../../ModalPortal"));
13
+ var _utils = require("../../utils");
14
+ var _ImagePreviewerLightbox = _interopRequireDefault(require("../../../ImagePreviewerLightbox"));
15
+ var _FileUploader = _interopRequireDefault(require("../../../FileUploader"));
16
+ var _constants = require("../../../constants");
17
+ var _hotkey = require("../../../utils/hotkey");
18
+ var _participant = _interopRequireDefault(require("./participant"));
19
+ var _lang = require("../../../lang");
20
+ require("./index.css");
21
+ const FONT_SIZE_WIDTH = 15;
22
+ const PADDING_WIDTH = 9;
23
+ const LINE_HEIGHT = 22;
24
+ const POPOVER_PADDING_HEIGHT = 10;
25
+ const DOWN = 'down';
26
+ const UP = 'up';
27
+ class Input extends _react.default.Component {
28
+ constructor(props) {
29
+ super(props);
30
+ this.hidePopover = event => {
31
+ if (this.commentPopoverRef && event && !this.commentPopoverRef.contains(event.target)) {
32
+ this.onHidePopover();
33
+ }
34
+ };
35
+ this.onHidePopover = () => {
36
+ if (this.state.filteredCollaborators.length > 0) {
37
+ this.setState({
38
+ filteredCollaborators: [],
39
+ activeCollaboratorIndex: 0
40
+ });
41
+ }
42
+ };
43
+ this.setPopoverPosition = () => {
44
+ const {
45
+ caretPosition
46
+ } = this.state;
47
+ let {
48
+ right,
49
+ left
50
+ } = this.commentRef.getBoundingClientRect();
51
+ this.commentPopoverRef.style.left = "".concat(caretPosition.x + FONT_SIZE_WIDTH, "px");
52
+ this.commentPopoverRef.style.top = "".concat(caretPosition.y - this.commentPopoverRef.offsetHeight, "px");
53
+ if (caretPosition.x + FONT_SIZE_WIDTH > right - PADDING_WIDTH) {
54
+ // is last code
55
+ this.commentPopoverRef.style.left = "".concat(left + PADDING_WIDTH + FONT_SIZE_WIDTH, "px");
56
+ this.commentPopoverRef.style.top = "".concat(caretPosition.y - this.commentPopoverRef.offsetHeight + LINE_HEIGHT, "px");
57
+ }
58
+ if (caretPosition.x + FONT_SIZE_WIDTH + this.commentPopoverRef.offsetWidth > document.body.clientWidth) {
59
+ this.commentPopoverRef.style.right = 0;
60
+ this.commentPopoverRef.style.left = '';
61
+ }
62
+ };
63
+ this.onKeyDown = event => {
64
+ if ((0, _hotkey.isModZ)(event)) {
65
+ this.onHidePopover();
66
+ event.preventDefault();
67
+ event.stopPropagation();
68
+ event.nativeEvent.stopImmediatePropagation();
69
+ this.commentRef.innerHTML = '';
70
+ return;
71
+ } else if ((0, _hotkey.isShiftEnter)(event)) {
72
+ return;
73
+ } else if ((0, _hotkey.isModP)(event)) {
74
+ this.commentRef.blur();
75
+ }
76
+ switch (event.keyCode) {
77
+ case _constants.KeyCodes.DownArrow:
78
+ case _constants.KeyCodes.UpArrow:
79
+ {
80
+ event.stopPropagation();
81
+ if (this.commentPopoverRef) {
82
+ event.preventDefault();
83
+ }
84
+ break;
85
+ }
86
+ case _constants.KeyCodes.Enter:
87
+ {
88
+ event.preventDefault();
89
+
90
+ // exec select collaborator operation.
91
+ if (this.state.filteredCollaborators.length > 0) {
92
+ break;
93
+ }
94
+ this.props.onSubmit();
95
+ break;
96
+ }
97
+ default:
98
+ {
99
+ break;
100
+ }
101
+ }
102
+ };
103
+ this.onFocus = () => {
104
+ this.props.onInputFocus && this.props.onInputFocus();
105
+ };
106
+ this.onBlur = () => {
107
+ this.props.onInputBlur && this.props.onInputBlur();
108
+ };
109
+ this.setScrollTop = (offsetTop, itemOffsetHeight, mouseDownType) => {
110
+ let {
111
+ offsetHeight,
112
+ scrollTop
113
+ } = this.commentPopoverRef;
114
+ if (mouseDownType === DOWN) {
115
+ if (offsetTop + itemOffsetHeight - scrollTop - offsetHeight + POPOVER_PADDING_HEIGHT > 0) {
116
+ let top = offsetTop + itemOffsetHeight - offsetHeight + POPOVER_PADDING_HEIGHT;
117
+ this.commentPopoverRef.scrollTop = top;
118
+ }
119
+ }
120
+ if (mouseDownType === UP) {
121
+ if (offsetTop < scrollTop) {
122
+ this.commentPopoverRef.scrollTop = offsetTop - POPOVER_PADDING_HEIGHT;
123
+ }
124
+ }
125
+ };
126
+ this.setCommentInputValue = () => {
127
+ this.commentRef.innerHTML = '';
128
+ };
129
+ this.getCommentInputValue = () => {
130
+ return this.commentRef.innerHTML;
131
+ };
132
+ this.onInsertElement = (content, nodeType) => {
133
+ const selection = window.getSelection();
134
+ let {
135
+ range
136
+ } = this.state;
137
+ let newRange = this.commentUtilities.onInsertElement({
138
+ selection,
139
+ range,
140
+ content,
141
+ nodeType,
142
+ commentRef: this.commentRef
143
+ });
144
+ this.setState({
145
+ range: newRange
146
+ });
147
+ };
148
+ this.createHtmlElement = (selection, range, content, nodeType) => {
149
+ let spanNode1;
150
+ let spanNode2;
151
+ let imageContainer;
152
+ if (nodeType === 'image') {
153
+ spanNode1 = document.createElement('div');
154
+ spanNode1.className = 'image-container';
155
+ spanNode1.contentEditable = 'false';
156
+ imageContainer = document.createElement('img');
157
+ imageContainer.src = content;
158
+ imageContainer.height = 60;
159
+ spanNode1.appendChild(imageContainer);
160
+ spanNode2 = document.createElement('span');
161
+ spanNode2.innerHTML = ' ';
162
+ }
163
+ if (nodeType === 'collaborator') {
164
+ spanNode1 = document.createElement('span');
165
+ spanNode2 = document.createElement('span');
166
+ spanNode1.className = 'at-text';
167
+ spanNode1.contentEditable = 'false';
168
+ spanNode1.innerHTML = "@".concat(content.name);
169
+ spanNode2.innerHTML = ' ';
170
+ }
171
+ let frag = document.createDocumentFragment();
172
+ let node;
173
+ let lastNode;
174
+ frag.appendChild(spanNode1);
175
+ while (node = spanNode2.firstChild) {
176
+ lastNode = frag.appendChild(node);
177
+ }
178
+ if (!range) {
179
+ this.commentRef.appendChild(frag);
180
+ range = selection.getRangeAt(0);
181
+ } else {
182
+ range.insertNode(frag);
183
+ }
184
+ if (lastNode) {
185
+ range = range.cloneRange();
186
+ range.setStartAfter(lastNode);
187
+ range.collapse(true);
188
+ selection.removeAllRanges();
189
+ selection.addRange(range);
190
+ }
191
+ this.setState({
192
+ range: selection.getRangeAt(0)
193
+ });
194
+ };
195
+ this.onSelectCollaborator = collaborator => {
196
+ const selection = window.getSelection();
197
+ let {
198
+ range
199
+ } = this.state;
200
+ let callBack = () => {
201
+ this.onHidePopover();
202
+ this.props.addParticipant(collaborator.email);
203
+ };
204
+ let newRange = this.commentUtilities.onSelectParticipant({
205
+ selection,
206
+ range,
207
+ participant: collaborator,
208
+ callBack,
209
+ commentRef: this.commentRef
210
+ });
211
+ this.setState({
212
+ range: newRange
213
+ });
214
+ };
215
+ this.onPaste = event => {
216
+ let _this = this;
217
+ let callBack = files => {
218
+ _this.uploaderFileRef.handleFilesChange(files);
219
+ };
220
+ this.commentUtilities.onPaste(event, callBack);
221
+ };
222
+ this.onFileUploadSuccess = uploadFileMessage => {
223
+ this.onInsertElement(uploadFileMessage.url, 'image');
224
+ };
225
+ this.handleImageZoom = event => {
226
+ event.persist();
227
+ if (event.target.tagName === 'IMG') {
228
+ let imageUrl = event.target.src;
229
+ let imageTagList = this.commentRef.getElementsByTagName('img');
230
+ let imageUrlList = [];
231
+ for (let i = 0; i < imageTagList.length; i++) {
232
+ imageUrlList.push(imageTagList[i].src);
233
+ }
234
+ this.setState({
235
+ imageUrlList: imageUrlList,
236
+ largeImageIndex: imageUrlList.findIndex(imageItemUrl => imageItemUrl === imageUrl)
237
+ });
238
+ }
239
+ };
240
+ this.moveNext = () => {
241
+ let images = this.state.imageUrlList;
242
+ this.setState(prevState => ({
243
+ largeImageIndex: (prevState.largeImageIndex + 1) % images.length
244
+ }));
245
+ };
246
+ this.movePrev = () => {
247
+ let images = this.state.imageUrlList;
248
+ this.setState(prevState => ({
249
+ largeImageIndex: (prevState.largeImageIndex + images.length - 1) % images.length
250
+ }));
251
+ };
252
+ this.hideLargeImage = () => {
253
+ this.setState({
254
+ largeImageIndex: -1,
255
+ imageUrlList: []
256
+ });
257
+ };
258
+ this.onKeyUp = event => {
259
+ const selection = window.getSelection();
260
+ this.setState({
261
+ range: selection.getRangeAt(0)
262
+ });
263
+ if (event.keyCode === _constants.KeyCodes.DownArrow) {
264
+ return this.handleSelectingCollaborator(event, DOWN);
265
+ }
266
+ if (event.keyCode === _constants.KeyCodes.UpArrow) {
267
+ return this.handleSelectingCollaborator(event, UP);
268
+ }
269
+ if (event.keyCode === _constants.KeyCodes.Enter) {
270
+ return this.handleSelectCollaborator();
271
+ }
272
+ this.handleMentions(event);
273
+ };
274
+ this.onMouseUp = () => {
275
+ const selection = window.getSelection();
276
+ this.setState({
277
+ range: selection.getRangeAt(0)
278
+ });
279
+ };
280
+ this.checkMentionOperation = event => {
281
+ const {
282
+ keyCode
283
+ } = event;
284
+ const {
285
+ Escape,
286
+ LeftArrow,
287
+ RightArrow
288
+ } = _constants.KeyCodes;
289
+ if (keyCode === Escape || keyCode === LeftArrow || keyCode === RightArrow) {
290
+ return false;
291
+ }
292
+ return true;
293
+ };
294
+ this.handleMentions = event => {
295
+ if (this.props.isArchive) {
296
+ return;
297
+ }
298
+ const isValidOperation = this.checkMentionOperation(event);
299
+ if (!isValidOperation) {
300
+ return this.onHidePopover();
301
+ }
302
+ const selection = window.getSelection();
303
+ const {
304
+ collaborators
305
+ } = this.props;
306
+ let filteredCollaborators = [];
307
+ const {
308
+ isCollapsed,
309
+ anchorNode,
310
+ anchorOffset
311
+ } = selection;
312
+ if (!isCollapsed || !anchorNode || !anchorNode.data) {
313
+ return this.onHidePopover();
314
+ }
315
+ const text = anchorNode.data;
316
+ const atIndex = this.commentUtilities.getAtIndexWithAnchorPosition(anchorOffset, text);
317
+ if (atIndex === -1) {
318
+ return this.onHidePopover();
319
+ }
320
+ if (atIndex === 0 || text[atIndex - 1] === ' ') {
321
+ if (atIndex === anchorOffset - 1) {
322
+ filteredCollaborators = [...collaborators];
323
+ } else {
324
+ const searchingText = text.substring(atIndex + 1);
325
+ if (searchingText) {
326
+ filteredCollaborators = (0, _dtableUtils.searchCollaborators)(collaborators, searchingText);
327
+ }
328
+ }
329
+ }
330
+ if (filteredCollaborators.length === 0) {
331
+ return this.onHidePopover();
332
+ }
333
+ this.setState({
334
+ filteredCollaborators,
335
+ activeCollaboratorIndex: 0,
336
+ caretPosition: (0, _utils.getSelectionCoords)(),
337
+ range: selection.getRangeAt(0)
338
+ }, () => {
339
+ this.setPopoverPosition();
340
+ });
341
+ };
342
+ this.handleSelectingCollaborator = (event, direction) => {
343
+ event.stopPropagation();
344
+ const {
345
+ filteredCollaborators,
346
+ activeCollaboratorIndex
347
+ } = this.state;
348
+ const collaboratorsLen = filteredCollaborators.length;
349
+ if (collaboratorsLen === 0) {
350
+ return;
351
+ }
352
+ let nextActiveCollaboratorIndex = activeCollaboratorIndex;
353
+ if (direction === DOWN) {
354
+ nextActiveCollaboratorIndex++;
355
+ if (nextActiveCollaboratorIndex >= collaboratorsLen) {
356
+ nextActiveCollaboratorIndex = 0;
357
+ }
358
+ } else {
359
+ nextActiveCollaboratorIndex--;
360
+ if (nextActiveCollaboratorIndex < 0) {
361
+ nextActiveCollaboratorIndex = collaboratorsLen - 1;
362
+ }
363
+ }
364
+ this.setState({
365
+ activeCollaboratorIndex: nextActiveCollaboratorIndex
366
+ });
367
+ };
368
+ this.handleSelectCollaborator = () => {
369
+ const {
370
+ filteredCollaborators,
371
+ activeCollaboratorIndex
372
+ } = this.state;
373
+ if (filteredCollaborators.length === 0) {
374
+ return;
375
+ }
376
+ this.onSelectCollaborator(filteredCollaborators[activeCollaboratorIndex]);
377
+ };
378
+ this.state = {
379
+ filteredCollaborators: [],
380
+ caretPosition: {},
381
+ range: null,
382
+ imageUrlList: [],
383
+ activeCollaboratorIndex: 0,
384
+ largeImageIndex: -1
385
+ };
386
+ this.commentUtilities = new _utils.Utilities();
387
+ }
388
+ componentDidMount() {
389
+ document.addEventListener('mousedown', this.hidePopover);
390
+ if (this.props.autoFocusInput) {
391
+ this.commentRef.focus();
392
+ }
393
+ }
394
+ componentWillUnmount() {
395
+ document.removeEventListener('mousedown', this.hidePopover);
396
+ }
397
+ render() {
398
+ const {
399
+ api
400
+ } = this.props;
401
+ const {
402
+ imageUrlList,
403
+ largeImageIndex,
404
+ filteredCollaborators,
405
+ activeCollaboratorIndex
406
+ } = this.state;
407
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
408
+ className: (0, _classnames.default)('dtable-ui-comment-input', {
409
+ 'dtable-ui-comment-input-archive': !(api !== null && api !== void 0 && api.add)
410
+ }),
411
+ ref: ref => this.commentRef = ref,
412
+ onKeyDown: this.onKeyDown,
413
+ onFocus: this.onFocus,
414
+ onBlur: this.onBlur,
415
+ onKeyUp: this.onKeyUp,
416
+ onMouseUp: this.onMouseUp,
417
+ onPaste: this.onPaste,
418
+ placeholder: (0, _lang.getLocale)('Add_comment'),
419
+ onClick: this.handleImageZoom,
420
+ tabIndex: -1,
421
+ contentEditable: true
422
+ }), filteredCollaborators.length > 0 && /*#__PURE__*/_react.default.createElement(_ModalPortal.default, null, /*#__PURE__*/_react.default.createElement("div", {
423
+ className: "dtable-ui-comment-caret-list",
424
+ ref: ref => this.commentPopoverRef = ref
425
+ }, filteredCollaborators.map((participant, i) => {
426
+ return /*#__PURE__*/_react.default.createElement(_participant.default, {
427
+ key: participant.email,
428
+ index: i,
429
+ activeIndex: activeCollaboratorIndex,
430
+ participant: participant,
431
+ setScrollTop: this.setScrollTop,
432
+ onSelect: this.onSelectCollaborator.bind(this, participant)
433
+ });
434
+ }))), largeImageIndex > -1 && /*#__PURE__*/_react.default.createElement(_ImagePreviewerLightbox.default, {
435
+ imageItems: imageUrlList,
436
+ imageIndex: this.state.largeImageIndex,
437
+ closeImagePopup: this.hideLargeImage,
438
+ moveToPrevImage: this.movePrev,
439
+ moveToNextImage: this.moveNext
440
+ }), /*#__PURE__*/_react.default.createElement(_FileUploader.default, {
441
+ className: "dtable-ui-comment-paste-uploader",
442
+ ref: ref => this.uploaderFileRef = ref,
443
+ onFileUploadSuccess: this.onFileUploadSuccess,
444
+ uploadFile: this.props.uploadFile
445
+ }));
446
+ }
447
+ }
448
+ var _default = exports.default = Input;
File without changes
@@ -0,0 +1,53 @@
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
+ class Participant extends _react.default.Component {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.onSelect = event => {
13
+ event.stopPropagation();
14
+ event.preventDefault();
15
+ this.props.onSelect();
16
+ };
17
+ }
18
+ UNSAFE_componentWillReceiveProps(nextProps) {
19
+ if (nextProps.showParticipantActiveIndex === this.props.participantIndex && nextProps.showParticipantActiveIndex !== this.props.showParticipantActiveIndex) {
20
+ let offsetHeight = this.participantItem.offsetHeight;
21
+ let offsetTop = this.participantItem.offsetTop;
22
+ if (nextProps.showParticipantActiveIndex > this.props.showParticipantActiveIndex) {
23
+ this.props.setScrollTop(offsetTop, offsetHeight, 'down');
24
+ } else {
25
+ this.props.setScrollTop(offsetTop, offsetHeight, 'up');
26
+ }
27
+ }
28
+ }
29
+ render() {
30
+ const {
31
+ participant,
32
+ index,
33
+ activeIndex
34
+ } = this.props;
35
+ const active = index === activeIndex;
36
+ return /*#__PURE__*/_react.default.createElement("div", {
37
+ className: "comment-participant-item ".concat(active ? 'active' : ''),
38
+ ref: ref => this.participantItem = ref,
39
+ onClick: this.onSelect
40
+ }, /*#__PURE__*/_react.default.createElement("div", {
41
+ className: "comment-participant-container"
42
+ }, /*#__PURE__*/_react.default.createElement("div", {
43
+ className: "comment-participant text-truncate"
44
+ }, /*#__PURE__*/_react.default.createElement("img", {
45
+ className: "comment-dtable-ui-participant-avatar ml-2",
46
+ alt: participant.name,
47
+ src: participant.avatar_url
48
+ }), /*#__PURE__*/_react.default.createElement("span", {
49
+ className: "comment-participant-name"
50
+ }, participant.name))));
51
+ }
52
+ }
53
+ var _default = exports.default = Participant;
@@ -0,0 +1,22 @@
1
+ .dtable-ui-comments-participants {
2
+ min-height: 28px;
3
+ }
4
+
5
+ .dtable-ui-comments-participants .dtable-ui-participants-add {
6
+ position: absolute;
7
+ cursor: pointer;
8
+ bottom: -3px;
9
+ }
10
+
11
+ .dtable-ui-comments-participants .dtable-ui-participants-add i {
12
+ background-color: #fff;
13
+ font-size: 16px;
14
+ color: #FF8000;
15
+ border: 2px solid #fff;
16
+ border-radius: 50%;
17
+ }
18
+
19
+ .dtable-ui-comments-participants .dtable-ui-participant-avatar,
20
+ .dtable-ui-comments-participants .dtable-ui-participants-add {
21
+ margin-right: -0.5rem;
22
+ }
@@ -0,0 +1,68 @@
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 _reactstrap = require("reactstrap");
10
+ var _participant = _interopRequireDefault(require("./participant"));
11
+ var _participantSelect = _interopRequireDefault(require("./participant-select"));
12
+ var _lang = require("../../../lang");
13
+ require("./index.css");
14
+ class Participants extends _react.default.Component {
15
+ constructor(props) {
16
+ super(props);
17
+ this.closeParticipantSelect = () => {
18
+ this.setState({
19
+ showParticipantSelect: false
20
+ });
21
+ };
22
+ this.toggleParticipantSelect = () => {
23
+ this.setState({
24
+ showParticipantSelect: !this.state.showParticipantSelect
25
+ });
26
+ };
27
+ this.state = {
28
+ showParticipantSelect: false
29
+ };
30
+ }
31
+ render() {
32
+ const {
33
+ canUpdate,
34
+ participants,
35
+ collaborators
36
+ } = this.props;
37
+ return /*#__PURE__*/_react.default.createElement("div", {
38
+ className: "dtable-ui-comments-participants mb-2 position-relative",
39
+ ref: ref => this.ref = ref
40
+ }, participants.map(participant => {
41
+ return /*#__PURE__*/_react.default.createElement(_participant.default, {
42
+ participant: participant,
43
+ key: participant.email
44
+ });
45
+ }), canUpdate && /*#__PURE__*/_react.default.createElement("span", {
46
+ className: "dtable-ui-participants-add",
47
+ onClick: this.toggleParticipantSelect,
48
+ ref: ref => this.addIcon = ref
49
+ }, /*#__PURE__*/_react.default.createElement("i", {
50
+ "aria-hidden": "true",
51
+ className: "dtable-font dtable-icon-add"
52
+ })), this.addIcon && /*#__PURE__*/_react.default.createElement(_reactstrap.UncontrolledTooltip, {
53
+ delay: {
54
+ show: 0,
55
+ hide: 0
56
+ },
57
+ target: this.addIcon,
58
+ placement: "bottom"
59
+ }, (0, _lang.getLocale)('Add_participants')), this.ref && this.state.showParticipantSelect && /*#__PURE__*/_react.default.createElement(_participantSelect.default, {
60
+ target: this.ref,
61
+ participants: participants,
62
+ collaborators: collaborators,
63
+ onChange: this.props.onChange,
64
+ onClose: this.closeParticipantSelect
65
+ }));
66
+ }
67
+ }
68
+ var _default = exports.default = Participants;
@@ -0,0 +1,5 @@
1
+ .dtable-ui-comments-participants .dtable-ui-participant-avatar .avatar {
2
+ width: 28px;
3
+ height: 28px;
4
+ border: 2px solid #fff;
5
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactstrap = require("reactstrap");
10
+ require("./index.css");
11
+ const Participant = _ref => {
12
+ let {
13
+ participant
14
+ } = _ref;
15
+ const ref = (0, _react.useRef)(null);
16
+ return /*#__PURE__*/_react.default.createElement("span", {
17
+ className: "dtable-ui-participant-avatar"
18
+ }, /*#__PURE__*/_react.default.createElement("img", {
19
+ src: participant.avatar_url,
20
+ className: "avatar",
21
+ ref: ref,
22
+ alt: "avatar"
23
+ }), ref.current && /*#__PURE__*/_react.default.createElement(_reactstrap.UncontrolledTooltip, {
24
+ delay: {
25
+ show: 0,
26
+ hide: 0
27
+ },
28
+ target: ref,
29
+ placement: "bottom"
30
+ }, participant.name));
31
+ };
32
+ var _default = exports.default = Participant;