dtable-ui-component 5.3.0 → 5.3.1-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 (239) hide show
  1. package/assets/dtable-font/dtable-font.eot +0 -0
  2. package/assets/dtable-font/dtable-font.svg +116 -0
  3. package/assets/dtable-font/dtable-font.ttf +0 -0
  4. package/assets/dtable-font/dtable-font.woff +0 -0
  5. package/assets/dtable-font/dtable-font.woff2 +0 -0
  6. package/assets/dtable-font.css +238 -6
  7. package/lib/CheckboxEditor/index.css +3 -20
  8. package/lib/CheckboxEditor/index.js +98 -35
  9. package/lib/CheckboxFormatter/index.js +6 -9
  10. package/lib/CollaboratorEditor/index.css +12 -35
  11. package/lib/CollaboratorEditor/index.js +18 -212
  12. package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.js +26 -29
  13. package/lib/CollaboratorEditor/pc-collaborator-editor/index.js +257 -0
  14. package/lib/CollaboratorItem/index.css +1 -1
  15. package/lib/CollaboratorItem/index.js +6 -2
  16. package/lib/DTableCustomizeCollaboratorSelect/index.css +1 -1
  17. package/lib/DTableCustomizeCollaboratorSelect/index.js +1 -1
  18. package/lib/DTableCustomizeSelect/index.css +2 -2
  19. package/lib/DTableCustomizeSelect/index.js +1 -1
  20. package/lib/DTableFiltersPopover/utils/index.js +1 -7
  21. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +1 -1
  22. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +1 -1
  23. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +2 -2
  24. package/lib/DTableFiltersPopover/widgets/filter-list/index.css +2 -2
  25. package/lib/DTableSelect/index.js +3 -1
  26. package/lib/DTableSelect/utils.js +1 -1
  27. package/lib/DateEditor/index.js +14 -51
  28. package/lib/DateEditor/pc-date-editor-popover.js +145 -12
  29. package/lib/DeleteTip/index.js +50 -0
  30. package/lib/Department-editor/department-single-select.js +1 -1
  31. package/lib/Department-editor/index.js +3 -4
  32. package/lib/DepartmentSingleSelectFormatter/index.js +2 -1
  33. package/lib/DigitalSignEditor/constants.js +7 -0
  34. package/lib/DigitalSignEditor/index.css +69 -0
  35. package/lib/DigitalSignEditor/index.js +182 -0
  36. package/lib/DigitalSignEditor/service.js +38 -0
  37. package/lib/DigitalSignEditor/signature-board/index.css +35 -0
  38. package/lib/DigitalSignEditor/signature-board/index.js +135 -0
  39. package/lib/DigitalSignEditor/signature-board/signature-tool.js +396 -0
  40. package/lib/DigitalSignEditor/utils.js +29 -0
  41. package/lib/DurationEditor/index.js +111 -0
  42. package/lib/EmailEditor/index.js +59 -0
  43. package/lib/FileEditor/addition-previewer/index.css +1 -0
  44. package/lib/FileEditor/addition-previewer/index.js +52 -0
  45. package/lib/FileEditor/addition-previewer/local-file-addition/index.css +1 -0
  46. package/lib/FileEditor/addition-previewer/local-file-addition/index.js +252 -0
  47. package/lib/FileEditor/constants.js +7 -0
  48. package/lib/FileEditor/files-previewer/file-previewer/dropdown-menu.js +74 -0
  49. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.css +5 -0
  50. package/lib/FileEditor/files-previewer/file-previewer/file-name-editor/index.js +77 -0
  51. package/lib/FileEditor/files-previewer/file-previewer/index.css +88 -0
  52. package/lib/FileEditor/files-previewer/file-previewer/index.js +167 -0
  53. package/lib/FileEditor/files-previewer/index.css +56 -0
  54. package/lib/FileEditor/files-previewer/index.js +277 -0
  55. package/lib/FileEditor/index.css +6 -0
  56. package/lib/FileEditor/index.js +244 -11
  57. package/lib/FileEditor/utils.js +22 -0
  58. package/lib/FileItemFormatter/index.js +19 -20
  59. package/lib/FileUploader/index.css +9 -0
  60. package/lib/FileUploader/index.js +268 -14
  61. package/lib/FormulaFormatter/index.js +2 -1
  62. package/lib/FormulaFormatter/utils.js +0 -31
  63. package/lib/GeolocationEditor/country-editor.js +319 -0
  64. package/lib/GeolocationEditor/index.css +641 -0
  65. package/lib/GeolocationEditor/index.js +241 -0
  66. package/lib/GeolocationEditor/location-editor.js +368 -0
  67. package/lib/GeolocationEditor/map-editor/index.js +456 -0
  68. package/lib/GeolocationEditor/map-editor/large-editor/index.css +137 -0
  69. package/lib/GeolocationEditor/map-editor/large-editor/index.js +461 -0
  70. package/lib/GeolocationEditor/map-editor-utils.js +153 -0
  71. package/lib/GeolocationEditor/map-selection-editor/index.js +455 -0
  72. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.css +1 -0
  73. package/lib/GeolocationEditor/map-selection-editor/large-editor/index.js +447 -0
  74. package/lib/GeolocationEditor/parse-geolocation.js +282 -0
  75. package/lib/GeolocationEditor/province-city-editor.js +292 -0
  76. package/lib/GeolocationEditor/province-editor.js +226 -0
  77. package/lib/GeolocationEditor/selector-header-item.js +28 -0
  78. package/lib/GeolocationEditor/selector-list.js +33 -0
  79. package/lib/GeolocationEditor/with-ref.js +27 -0
  80. package/lib/ImageEditor/addition-previewer/image-link/index.css +45 -0
  81. package/lib/ImageEditor/addition-previewer/image-link/index.js +73 -0
  82. package/lib/ImageEditor/addition-previewer/index.css +106 -0
  83. package/lib/ImageEditor/addition-previewer/index.js +63 -0
  84. package/lib/ImageEditor/addition-previewer/local-image-addition/index.css +125 -0
  85. package/lib/ImageEditor/addition-previewer/local-image-addition/index.js +254 -0
  86. package/lib/ImageEditor/constants.js +7 -0
  87. package/lib/ImageEditor/images-previewer/image-preview/index.css +59 -0
  88. package/lib/ImageEditor/images-previewer/image-preview/index.js +155 -0
  89. package/lib/ImageEditor/images-previewer/index.css +18 -0
  90. package/lib/ImageEditor/images-previewer/index.js +140 -0
  91. package/lib/ImageEditor/index.css +24 -0
  92. package/lib/ImageEditor/index.js +194 -0
  93. package/lib/ImageThumbnail/index.css +20 -0
  94. package/lib/ImageThumbnail/index.js +136 -0
  95. package/lib/LinkEditor/pc-link-editor-popover/index.js +1 -1
  96. package/lib/MultipleSelectEditor/index.js +16 -177
  97. package/lib/NumberEditor/index.js +64 -77
  98. package/lib/RoleStatusEditor/index.css +3 -3
  99. package/lib/RoleStatusEditor/index.js +1 -1
  100. package/lib/RowExpandDialog/body/index.css +21 -0
  101. package/lib/RowExpandDialog/body/index.js +279 -0
  102. package/lib/RowExpandDialog/column-content/index.css +43 -0
  103. package/lib/RowExpandDialog/column-content/index.js +50 -0
  104. package/lib/RowExpandDialog/constants.js +114 -0
  105. package/lib/RowExpandDialog/header/index.css +31 -0
  106. package/lib/RowExpandDialog/header/index.js +33 -0
  107. package/lib/RowExpandDialog/index.css +24 -0
  108. package/lib/RowExpandDialog/index.js +268 -0
  109. package/lib/RowExpandDialog/utils.js +83 -0
  110. package/lib/RowExpandEditor/RowExpandAddBtn/index.css +22 -0
  111. package/lib/RowExpandEditor/RowExpandAddBtn/index.js +24 -0
  112. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.css +18 -0
  113. package/lib/RowExpandEditor/RowExpandCheckboxEditor/index.js +43 -0
  114. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.css +5 -0
  115. package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +232 -0
  116. package/lib/RowExpandEditor/RowExpandDateEditor/index.js +130 -0
  117. package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +129 -0
  118. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.css +13 -0
  119. package/lib/RowExpandEditor/RowExpandDigitalSignEditor/index.js +208 -0
  120. package/lib/RowExpandEditor/RowExpandDurationEditor/index.js +105 -0
  121. package/lib/RowExpandEditor/RowExpandEmailEditor/index.css +2 -0
  122. package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +125 -0
  123. package/lib/RowExpandEditor/RowExpandFileEditor/index.css +1 -0
  124. package/lib/RowExpandEditor/RowExpandFileEditor/index.js +146 -0
  125. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.css +17 -0
  126. package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +165 -0
  127. package/lib/RowExpandEditor/RowExpandImageEditor/index.css +6 -0
  128. package/lib/RowExpandEditor/RowExpandImageEditor/index.js +170 -0
  129. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.css +6 -0
  130. package/lib/RowExpandEditor/RowExpandLongTextEditor/index.js +124 -0
  131. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.css +44 -0
  132. package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +224 -0
  133. package/lib/RowExpandEditor/RowExpandNumberEditor/index.js +105 -0
  134. package/lib/RowExpandEditor/RowExpandRateEditor/index.css +13 -0
  135. package/lib/RowExpandEditor/RowExpandRateEditor/index.js +152 -0
  136. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.css +58 -0
  137. package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +192 -0
  138. package/lib/RowExpandEditor/RowExpandTextEditor/index.css +4 -0
  139. package/lib/RowExpandEditor/RowExpandTextEditor/index.js +127 -0
  140. package/lib/RowExpandEditor/RowExpandUrlEditor/index.css +31 -0
  141. package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +130 -0
  142. package/lib/RowExpandEditor/constants.js +44 -0
  143. package/lib/RowExpandEditor/index.css +0 -0
  144. package/lib/RowExpandEditor/index.js +32 -0
  145. package/lib/RowExpandFormatter/RowExpandDepartmentFormatter/index.js +27 -0
  146. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.css +1 -1
  147. package/lib/{RowExpandEmailFormatter → RowExpandFormatter/RowExpandEmailFormatter}/index.js +1 -1
  148. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.css +6 -6
  149. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/index.js +3 -1
  150. package/lib/{RowExpandFileFormatter → RowExpandFormatter/RowExpandFileFormatter}/row-expand-file-item-formatter.js +10 -11
  151. package/lib/{RowExpandFormulaFormatter → RowExpandFormatter/RowExpandFormulaFormatter}/index.js +11 -10
  152. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.css +6 -6
  153. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/index.js +1 -1
  154. package/lib/{RowExpandImageFormatter → RowExpandFormatter/RowExpandImageFormatter}/row-expand-image-item-formatter.js +3 -3
  155. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/collaborator-item-formatter.js +1 -1
  156. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.js +5 -5
  157. package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/utils.js +1 -1
  158. package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.css +1 -1
  159. package/lib/RowExpandFormatter/RowExpandUrlFormatter/index.css +1 -0
  160. package/lib/{RowExpandUrlFormatter → RowExpandFormatter/RowExpandUrlFormatter}/index.js +4 -3
  161. package/lib/RowExpandFormatter/constants.js +60 -0
  162. package/lib/RowExpandFormatter/index.css +26 -0
  163. package/lib/RowExpandFormatter/index.js +84 -100
  164. package/lib/SingleSelectEditor/index.js +16 -156
  165. package/lib/TextEditor/index.js +113 -42
  166. package/lib/UploadProgress/index.js +38 -0
  167. package/lib/UrlEditor/index.js +62 -0
  168. package/lib/common/editor-base.js +53 -0
  169. package/lib/constants/file.js +96 -0
  170. package/lib/constants/index.js +34 -2
  171. package/lib/constants/key-codes.js +109 -0
  172. package/lib/css/cell-editor.css +18 -2
  173. package/lib/hooks/index.js +16 -0
  174. package/lib/index.js +74 -46
  175. package/lib/lang/index.js +16 -14
  176. package/lib/locales/de.json +163 -0
  177. package/lib/locales/en.json +163 -0
  178. package/lib/locales/es.json +163 -0
  179. package/lib/locales/fr.json +163 -0
  180. package/lib/locales/pt.json +163 -0
  181. package/lib/locales/ru.json +163 -0
  182. package/lib/locales/zh-CN.json +163 -0
  183. package/lib/select-editor/index.js +6 -6
  184. package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.js +3 -3
  185. package/lib/select-editor/pc-select-editor/index.css +85 -0
  186. package/lib/select-editor/pc-select-editor/index.js +290 -0
  187. package/lib/utils/cell-comparer.js +35 -0
  188. package/lib/utils/cell.js +55 -0
  189. package/lib/utils/column-utils.js +25 -0
  190. package/lib/utils/editor-utils.js +1 -6
  191. package/lib/utils/get-event-transfer.js +75 -0
  192. package/lib/utils/object-utils.js +61 -0
  193. package/lib/utils/url.js +119 -8
  194. package/lib/utils/utils.js +89 -2
  195. package/package.json +3 -2
  196. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +0 -97
  197. package/lib/FileEditor/pc-files-addition/index.js +0 -1
  198. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
  199. package/lib/FileEditor/pc-files-preview/index.js +0 -1
  200. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
  201. package/lib/FileItemFormatter/assets/file/192/excel.png +0 -0
  202. package/lib/FileItemFormatter/assets/file/192/file.png +0 -0
  203. package/lib/FileItemFormatter/assets/file/192/music.png +0 -0
  204. package/lib/FileItemFormatter/assets/file/192/pdf.png +0 -0
  205. package/lib/FileItemFormatter/assets/file/192/pic.png +0 -0
  206. package/lib/FileItemFormatter/assets/file/192/ppt.png +0 -0
  207. package/lib/FileItemFormatter/assets/file/192/txt.png +0 -0
  208. package/lib/FileItemFormatter/assets/file/192/video.png +0 -0
  209. package/lib/FileItemFormatter/assets/file/192/word.png +0 -0
  210. package/lib/FileItemFormatter/assets/file/24/excel.png +0 -0
  211. package/lib/FileItemFormatter/assets/file/24/file.png +0 -0
  212. package/lib/FileItemFormatter/assets/file/24/music.png +0 -0
  213. package/lib/FileItemFormatter/assets/file/24/pdf.png +0 -0
  214. package/lib/FileItemFormatter/assets/file/24/pic.png +0 -0
  215. package/lib/FileItemFormatter/assets/file/24/ppt.png +0 -0
  216. package/lib/FileItemFormatter/assets/file/24/txt.png +0 -0
  217. package/lib/FileItemFormatter/assets/file/24/video.png +0 -0
  218. package/lib/FileItemFormatter/assets/file/24/word.png +0 -0
  219. package/lib/FileItemFormatter/assets/folder/folder-192.png +0 -0
  220. package/lib/FileItemFormatter/assets/folder/folder-24.png +0 -0
  221. package/lib/FileItemFormatter/utils.js +0 -99
  222. package/lib/MultipleSelectEditor/index.css +0 -9
  223. package/lib/RowExpandUrlFormatter/index.css +0 -1
  224. package/lib/SingleSelectEditor/index.css +0 -14
  225. package/lib/locals/de.js +0 -103
  226. package/lib/locals/en.js +0 -104
  227. package/lib/locals/es.js +0 -103
  228. package/lib/locals/fr.js +0 -103
  229. package/lib/locals/pt.js +0 -103
  230. package/lib/locals/ru.js +0 -103
  231. package/lib/locals/zh-CN.js +0 -104
  232. package/lib/select-editor/pc-select-editor-popover/index.css +0 -71
  233. package/lib/select-editor/pc-select-editor-popover/index.js +0 -122
  234. /package/lib/CollaboratorEditor/{mb-collaborator-editor-popover → mb-collaborator-editor}/index.css +0 -0
  235. /package/lib/CollaboratorEditor/{pc-collaborator-editor-popover → pc-collaborator-editor}/index.css +0 -0
  236. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/index.css +0 -0
  237. /package/lib/{RowExpandLinkFormatter → RowExpandFormatter/RowExpandLinkFormatter}/value-display-utils.js +0 -0
  238. /package/lib/{RowExpandRateFormatter → RowExpandFormatter/RowExpandRateFormatter}/index.js +0 -0
  239. /package/lib/select-editor/{mb-select-editor-popover → mb-select-editor}/index.css +0 -0
@@ -7,21 +7,254 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactstrap = require("reactstrap");
10
+ var _filesPreviewer = _interopRequireDefault(require("./files-previewer"));
11
+ var _additionPreviewer = _interopRequireDefault(require("./addition-previewer"));
12
+ var _constants = require("../constants");
13
+ var _DTableModalHeader = _interopRequireDefault(require("../DTableModalHeader"));
10
14
  var _lang = require("../lang");
11
- var _index = _interopRequireDefault(require("../DTableModalHeader/index"));
15
+ var _constants2 = require("./constants");
16
+ require("./index.css");
12
17
  class FileEditor extends _react.default.Component {
18
+ constructor(props) {
19
+ var _this;
20
+ super(props);
21
+ _this = this;
22
+ this.getValue = () => {
23
+ return this.state.value;
24
+ };
25
+ this.getEditorView = () => {
26
+ const {
27
+ isInModal,
28
+ value
29
+ } = this.props;
30
+ return !value || value.length === 0 || isInModal ? _constants.FILE_EDITOR_STATUS.ADDITION : _constants.FILE_EDITOR_STATUS.PREVIEWER;
31
+ };
32
+ this.deleteImage = function (index) {
33
+ let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
34
+ let uploadLocalFileValue = _this.state.uploadLocalFileValue.slice(0);
35
+ let value = _this.state.value.slice(0);
36
+ if (_this.state.editorView === _constants.FILE_EDITOR_STATUS.PREVIEWER) {
37
+ value.splice(index, 1);
38
+ } else {
39
+ if (type === 'localPicture') {
40
+ uploadLocalFileValue.splice(index, 1);
41
+ }
42
+ }
43
+ _this.setState({
44
+ uploadLocalFileValue: uploadLocalFileValue,
45
+ isUpdated: true,
46
+ value: value
47
+ });
48
+ };
49
+ this.resetAdditionImage = () => {
50
+ this.setState({
51
+ uploadLocalFileValue: [],
52
+ imageLinkValue: []
53
+ });
54
+ };
55
+ this.toggle = e => {
56
+ e.stopPropagation();
57
+ if (this.state.isOpen && this.state.isUpdated) {
58
+ if (this.state.editorView === _constants.FILE_EDITOR_STATUS.ADDITION) {
59
+ let {
60
+ value,
61
+ uploadLocalFileValue
62
+ } = this.state;
63
+ let newValue = value.concat(uploadLocalFileValue);
64
+ this.setState({
65
+ value: newValue
66
+ }, () => {
67
+ this.props.isInModal ? this.props.onCommit(this.getValue()) : this.props.onCommit();
68
+ });
69
+ return;
70
+ }
71
+ this.props.isInModal ? this.props.onCommit(this.getValue()) : this.props.onCommit();
72
+ }
73
+ if (this.props.isInModal) {
74
+ this.props.onToggle();
75
+ }
76
+ const nextIsOpen = !this.state.isOpen;
77
+ this.setState({
78
+ isOpen: nextIsOpen
79
+ }, () => {
80
+ if (!nextIsOpen) {
81
+ this.props.onCommitCancel && this.props.onCommitCancel();
82
+ }
83
+ });
84
+ };
85
+ this.closeEditor = () => {
86
+ this.setState({
87
+ isOpen: false
88
+ });
89
+ };
90
+ this.togglePreviewer = type => {
91
+ this.setState({
92
+ editorView: type
93
+ });
94
+ };
95
+ this.fileUploadCompleted = fileMessage => {
96
+ let uploadLocalFileValue = this.state.uploadLocalFileValue.slice(0);
97
+ let fileUploadMessage = {
98
+ name: fileMessage.name,
99
+ size: fileMessage.size,
100
+ type: fileMessage.type,
101
+ url: fileMessage.url,
102
+ upload_time: fileMessage.upload_time
103
+ };
104
+ uploadLocalFileValue.push(fileUploadMessage);
105
+ this.setState({
106
+ uploadLocalFileValue: uploadLocalFileValue,
107
+ isUpdated: true
108
+ });
109
+ };
110
+ this.addUploadedFile = fileMessageList => {
111
+ const uploadLocalFileValue = [...this.state.uploadLocalFileValue, ...fileMessageList.map(_ref => {
112
+ let {
113
+ name,
114
+ size,
115
+ type,
116
+ url,
117
+ mtime
118
+ } = _ref;
119
+ return {
120
+ name,
121
+ size,
122
+ type: type || 'file',
123
+ url,
124
+ upload_time: mtime
125
+ };
126
+ })];
127
+ this.setState({
128
+ uploadLocalFileValue,
129
+ isUpdated: true
130
+ });
131
+ };
132
+ this.renderHeader = () => {
133
+ let {
134
+ editorView
135
+ } = this.state;
136
+ // if (this.props.isInModal) {
137
+ // return (<span>{getLocale('Add_files')}</span>);
138
+ // }
139
+ if (editorView === _constants.FILE_EDITOR_STATUS.PREVIEWER) {
140
+ return /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('All_files'));
141
+ }
142
+ return /*#__PURE__*/_react.default.createElement("div", {
143
+ onClick: this.showImageListPreviewer
144
+ }, /*#__PURE__*/_react.default.createElement("span", {
145
+ "aria-hidden": "true",
146
+ className: "dtable-font dtable-icon-return mr-2"
147
+ }), /*#__PURE__*/_react.default.createElement("span", null, (0, _lang.getLocale)('Add_files')));
148
+ };
149
+ this.showImageListPreviewer = () => {
150
+ let {
151
+ value,
152
+ uploadLocalFileValue,
153
+ imageLinkValue
154
+ } = this.state;
155
+ let newValue = value.concat(uploadLocalFileValue, imageLinkValue);
156
+ this.setState({
157
+ value: newValue
158
+ });
159
+ this.togglePreviewer(_constants.FILE_EDITOR_STATUS.PREVIEWER);
160
+ };
161
+ this.uploadFile = (file, callback) => {
162
+ return this.props.uploadFile(file, _constants2.FILES_FOLDER, callback);
163
+ };
164
+ this.resetFileValue = () => {
165
+ this.setState({
166
+ uploadLocalFileValue: []
167
+ });
168
+ };
169
+ this.deleteFile = (index, type) => {
170
+ let uploadLocalFileValue = this.state.uploadLocalFileValue.slice(0);
171
+ let value = this.state.value.slice(0);
172
+ if (this.state.editorView === _constants.FILE_EDITOR_STATUS.PREVIEWER) {
173
+ value.splice(index, 1);
174
+ } else {
175
+ if (type === 'localFile') {
176
+ uploadLocalFileValue.splice(index, 1);
177
+ }
178
+ }
179
+ this.setState({
180
+ uploadLocalFileValue: uploadLocalFileValue,
181
+ isUpdated: true,
182
+ value: value
183
+ });
184
+ };
185
+ this.deleteFilesByPreviewer = fileList => {
186
+ const result = this.state.value.filter(file => !fileList.includes(file.name));
187
+ this.setState({
188
+ isUpdated: true,
189
+ value: result
190
+ });
191
+ };
192
+ this.onRenameFile = (index, newName) => {
193
+ let newValue = this.state.value.slice(0);
194
+ let fileItem = newValue[index];
195
+ if (!this.props.renameFile) return;
196
+ this.props.renameFile(fileItem, newName).then(res => {
197
+ const {
198
+ name,
199
+ url
200
+ } = res.data;
201
+ fileItem = {
202
+ ...fileItem,
203
+ name,
204
+ url
205
+ };
206
+ newValue[index] = fileItem;
207
+ this.setState({
208
+ value: newValue
209
+ });
210
+ }).catch(error => {});
211
+ };
212
+ this.onRotateImage = (url, degree) => {
213
+ this.props.rotateImage(url, degree).then(res => {}).catch(error => {});
214
+ };
215
+ this.state = {
216
+ value: props.value || [],
217
+ editorView: this.getEditorView(),
218
+ isOpen: true,
219
+ isShowFileChooser: false,
220
+ uploadLocalFileValue: [],
221
+ imageLinkValue: [],
222
+ isUpdated: false
223
+ };
224
+ }
13
225
  render() {
14
- let {
15
- closeEditor
16
- } = this.props;
17
226
  return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
18
- isOpen: true,
19
- toggle: closeEditor
20
- }, /*#__PURE__*/_react.default.createElement(_index.default, {
21
- toggle: closeEditor
22
- }, (0, _lang.getLocale)('Add_Files')), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, {
23
- className: "file-editor-container"
24
- }));
227
+ className: "dtable-ui-image-editor-dialog dtable-ui-file-editor-dialog",
228
+ contentClassName: "dtable-ui-image-editor-modal",
229
+ isOpen: this.state.isOpen,
230
+ toggle: this.toggle
231
+ }, /*#__PURE__*/_react.default.createElement(_DTableModalHeader.default, {
232
+ toggle: this.toggle
233
+ }, this.renderHeader()), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, {
234
+ className: "p-0"
235
+ }, /*#__PURE__*/_react.default.createElement("div", {
236
+ className: "dtable-ui-image-editor-container dtable-ui-file-editor-container"
237
+ }, this.state.editorView === _constants.FILE_EDITOR_STATUS.PREVIEWER && /*#__PURE__*/_react.default.createElement(_filesPreviewer.default, {
238
+ value: this.state.value,
239
+ config: this.props.config,
240
+ togglePreviewer: this.togglePreviewer,
241
+ deleteFile: this.deleteFile,
242
+ deleteFiles: this.deleteFilesByPreviewer,
243
+ renameFile: this.props.renameFile ? this.onRenameFile : null,
244
+ resetFileValue: this.resetFileValue,
245
+ rotateImage: this.props.rotateImage ? this.onRotateImage : null,
246
+ getDownLoadFiles: this.props.getDownLoadFiles || (() => {})
247
+ }), this.state.editorView === _constants.FILE_EDITOR_STATUS.ADDITION && /*#__PURE__*/_react.default.createElement(_additionPreviewer.default, {
248
+ config: this.props.config,
249
+ deleteImage: this.deleteImage,
250
+ handleFilesChange: this.handleFilesChange,
251
+ uploadLocalFileValue: this.state.uploadLocalFileValue,
252
+ togglePreviewer: this.togglePreviewer,
253
+ fileUploadCompleted: this.fileUploadCompleted,
254
+ addUploadedFile: this.addUploadedFile,
255
+ showImageListPreviewer: this.showImageListPreviewer,
256
+ uploadFile: this.uploadFile
257
+ }))));
25
258
  }
26
259
  }
27
260
  var _default = exports.default = FileEditor;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getFileUploadTime = exports.bytesToSize = void 0;
8
+ var _dayjs = _interopRequireDefault(require("dayjs"));
9
+ const getFileUploadTime = file => {
10
+ return file.upload_time ? (0, _dayjs.default)(file.upload_time).format('YYYY-MM-DD HH:mm') : '';
11
+ };
12
+ exports.getFileUploadTime = getFileUploadTime;
13
+ const bytesToSize = bytes => {
14
+ if (typeof bytes == 'undefined') return ' ';
15
+ if (bytes < 0) return '--';
16
+ const sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
17
+ if (bytes === 0) return bytes + ' ' + sizes[0];
18
+ const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1000)), 10);
19
+ if (i === 0) return bytes + ' ' + sizes[i];
20
+ return (bytes / 1000 ** i).toFixed(1) + ' ' + sizes[i];
21
+ };
22
+ exports.bytesToSize = bytesToSize;
@@ -1,26 +1,25 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
9
- var _utils = require("./utils");
10
- class FileItemFormatter extends _react.Component {
11
- render() {
12
- const {
13
- file
14
- } = this.props;
15
- const {
16
- fileIconUrl,
17
- isImage
18
- } = (0, _utils.getFileThumbnailInfo)(file);
19
- return /*#__PURE__*/_react.default.createElement("img", {
20
- className: "file-item-icon ".concat(isImage ? 'img' : ''),
21
- src: fileIconUrl,
22
- alt: (file === null || file === void 0 ? void 0 : file.name) || ''
23
- });
24
- }
25
- }
26
- exports.default = FileItemFormatter;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _url = require("../utils/url");
10
+ const FileItemFormatter = _ref => {
11
+ let {
12
+ file,
13
+ config
14
+ } = _ref;
15
+ const {
16
+ fileIconUrl,
17
+ isImage
18
+ } = (0, _url.getFileThumbnailInfo)(file, config);
19
+ return /*#__PURE__*/_react.default.createElement("img", {
20
+ className: "file-item-icon ".concat(isImage ? 'img' : ''),
21
+ src: fileIconUrl,
22
+ alt: (file === null || file === void 0 ? void 0 : file.name) || ''
23
+ });
24
+ };
25
+ var _default = exports.default = FileItemFormatter;
@@ -0,0 +1,9 @@
1
+ .dtable-ui-upload-image {
2
+ width: 1px;
3
+ height: 1px;
4
+ opacity: 0;
5
+ position: absolute;
6
+ top: 0;
7
+ font-size: 0;
8
+ cursor: pointer;
9
+ }
@@ -6,26 +6,280 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _dayjs = _interopRequireDefault(require("dayjs"));
10
+ var _utc = _interopRequireDefault(require("dayjs/plugin/utc"));
11
+ var _getEventTransfer = _interopRequireDefault(require("../utils/get-event-transfer"));
12
+ var _url = require("../utils/url");
13
+ require("./index.css");
14
+ _dayjs.default.extend(_utc.default);
15
+ const MAX_UPLOAD_FILES = 10;
9
16
  class FileUploader extends _react.default.Component {
10
17
  constructor(props) {
18
+ var _this2;
11
19
  super(props);
12
- this.onFilesChanged = () => {};
13
- this.uploadFiles = function (fileList) {
14
- let isMultiple = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
15
- };
16
- this.checkRepeat = () => {};
17
- this.cancelUploadFile = () => {};
18
- this.onFileUploadProgress = () => {};
19
- this.onFileUploadSuccss = () => {};
20
- this.onFileUploadFailed = () => {};
21
- this.state = {};
22
- this.uploadFiles = [];
20
+ _this2 = this;
21
+ this.onInputFile = e => {
22
+ e.nativeEvent.stopImmediatePropagation();
23
+ e.stopPropagation();
24
+ };
25
+ this.uploadFileClick = () => {
26
+ this.uploadFileRef.click();
27
+ };
28
+ this.onDragEnter = e => {
29
+ const {
30
+ isSupportDragDrop,
31
+ updateParentTips
32
+ } = this.props;
33
+ if (isSupportDragDrop) {
34
+ e.preventDefault();
35
+ this.enteredCounter++;
36
+ if (this.enteredCounter !== 0) {
37
+ updateParentTips(true);
38
+ }
39
+ }
40
+ };
41
+ this.onDragOver = e => {
42
+ const {
43
+ isSupportDragDrop
44
+ } = this.props;
45
+ if (isSupportDragDrop) {
46
+ e.stopPropagation();
47
+ e.preventDefault();
48
+ }
49
+ };
50
+ this.onDragLeave = e => {
51
+ const {
52
+ isSupportDragDrop,
53
+ updateParentTips
54
+ } = this.props;
55
+ if (isSupportDragDrop) {
56
+ this.enteredCounter--;
57
+ if (this.enteredCounter === 0) {
58
+ updateParentTips(false);
59
+ }
60
+ }
61
+ };
62
+ this.onDrop = event => {
63
+ const {
64
+ isSupportDragDrop,
65
+ updateParentTips,
66
+ onCellTipShow
67
+ } = this.props;
68
+ if (isSupportDragDrop) {
69
+ this.enteredCounter = 0;
70
+ updateParentTips(false);
71
+ let files = event.dataTransfer.files;
72
+ if (files.length === 0) {
73
+ if (onCellTipShow) onCellTipShow(-1);
74
+ return;
75
+ }
76
+ this.handleFilesChange(files);
77
+ event.preventDefault();
78
+ }
79
+ };
80
+ this.onPaste = event => {
81
+ const {
82
+ isSupportPaste
83
+ } = this.props;
84
+ if (isSupportPaste) {
85
+ event.stopPropagation();
86
+ let cliperData = (0, _getEventTransfer.default)(event);
87
+ if (cliperData.files) {
88
+ let files = cliperData.files;
89
+ this.handleFilesChange(files, true);
90
+ }
91
+ }
92
+ };
93
+ this.onMouseEnter = () => {
94
+ const {
95
+ updateParentTips,
96
+ uploadType
97
+ } = this.props;
98
+ if (uploadType === 'image') {
99
+ if (updateParentTips) updateParentTips(true, uploadType);
100
+ }
101
+ };
102
+ this.onMouseLeave = () => {
103
+ const {
104
+ updateParentTips,
105
+ uploadType
106
+ } = this.props;
107
+ if (uploadType === 'image') {
108
+ if (updateParentTips) updateParentTips(false, uploadType);
109
+ }
110
+ };
111
+ this.uploadFilesChange = event => {
112
+ this.handleFilesChange(event.target.files);
113
+ };
114
+ this.handleFilesChange = function (files) {
115
+ let isPasteUpload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
116
+ const _this = _this2;
117
+ const {
118
+ uploadType,
119
+ updateUploadFileList,
120
+ onCellTipShow
121
+ } = _this2.props;
122
+ let uploadFileList = [];
123
+ let dealFileCnt = 0;
124
+ let allFileLen = files.length;
125
+ function checkLoadFinish() {
126
+ if (dealFileCnt === allFileLen - 1) {
127
+ if (uploadFileList.length === 0) {
128
+ if (onCellTipShow) onCellTipShow(uploadFileList.length);
129
+ return;
130
+ }
131
+ if (updateUploadFileList) updateUploadFileList(uploadFileList);
132
+ _this.uploadFilesInBatch(uploadFileList);
133
+ }
134
+ dealFileCnt++;
135
+ }
136
+ for (let i = 0; i < allFileLen; i++) {
137
+ let file = files[i];
138
+ if (isPasteUpload && file.name === 'image.png') {
139
+ let newName = "image-".concat((0, _dayjs.default)().format('YYYY-MM-DD-HH-mm'), ".png");
140
+ file = new File([file], newName, {
141
+ type: file.type
142
+ });
143
+ }
144
+ try {
145
+ let fileReader = new FileReader();
146
+ fileReader.readAsDataURL(file);
147
+ fileReader.addEventListener('load', function (event) {
148
+ let isImage = /image/i.test(file.type);
149
+ if (uploadType === 'file' || isImage) {
150
+ let uploadFileItem = {
151
+ name: file.name,
152
+ fileIconUrl: isImage ? event.target.result : (0, _url.getFileIconUrl)(file.name, file.type),
153
+ isUploading: true,
154
+ isErrorTip: false,
155
+ file: file,
156
+ size: file.size,
157
+ url: '',
158
+ type: uploadType === 'file' ? 'file' : '',
159
+ percent: 0
160
+ };
161
+ uploadFileList.push(uploadFileItem);
162
+ }
163
+ checkLoadFinish();
164
+ }, false);
165
+ fileReader.addEventListener('error', function (e) {
166
+ checkLoadFinish();
167
+ }, false);
168
+ } catch (event) {
169
+ checkLoadFinish();
170
+ }
171
+ }
172
+ };
173
+ this.uploadFilesInBatch = files => {
174
+ const fileUploadPromises = [];
175
+ const length = MAX_UPLOAD_FILES + this.start > files.length ? files.length : MAX_UPLOAD_FILES + this.start;
176
+ for (let i = this.start; i < length; i++) {
177
+ let file = files[i];
178
+ fileUploadPromises.push(this.createPromise(file));
179
+ }
180
+ this.uploadFilesPromise(fileUploadPromises, files);
181
+ };
182
+ this.uploadFilesPromise = (fileUploadPromises, files) => {
183
+ Promise.all(fileUploadPromises).then(res => {
184
+ this.start += MAX_UPLOAD_FILES;
185
+ if (this.start + MAX_UPLOAD_FILES - files.length >= 10) {
186
+ this.start = 0;
187
+ return;
188
+ }
189
+ this.uploadFilesInBatch(files);
190
+ });
191
+ };
192
+ this.handleFileChange = (fileMessage, callback) => {
193
+ const {
194
+ onFileUploadFailed
195
+ } = this.props;
196
+ this.uploadFile(fileMessage).then(res => {
197
+ const data = res;
198
+ this.uploadFileMessage({
199
+ data,
200
+ fileMessage
201
+ });
202
+ callback && callback();
203
+ }).catch(error => {
204
+ fileMessage.isErrorTip = true;
205
+ fileMessage.error = error;
206
+ if (onFileUploadFailed) onFileUploadFailed(fileMessage);
207
+ });
208
+ };
209
+ this.createPromise = fileMessage => {
210
+ const _this = this;
211
+ return new Promise(function (resolve, reject) {
212
+ _this.handleFileChange(fileMessage, resolve);
213
+ });
214
+ };
215
+ this.uploadFileMessage = _ref => {
216
+ let {
217
+ data = {},
218
+ fileMessage
219
+ } = _ref;
220
+ fileMessage.name = data.name;
221
+ fileMessage.isUploading = false;
222
+ fileMessage.size = data.size;
223
+ fileMessage.url = data.url;
224
+ fileMessage.upload_time = (0, _dayjs.default)().utc().format('YYYY-MM-DDTHH:mm:ss.SSSZ');
225
+ this.props.onFileUploadSuccess(fileMessage);
226
+ };
227
+ this.uploadFile = fileMessage => {
228
+ return this.props.uploadFile(fileMessage.file, event => this.onUploadProgress(event, fileMessage));
229
+ };
230
+ this.reuploadFile = fileMessage => {
231
+ fileMessage.isErrorTip = false;
232
+ this.handleFileChange(fileMessage);
233
+ };
234
+ this.onUploadProgress = (event, fileMessage) => {
235
+ const {
236
+ onFileUploadProgress
237
+ } = this.props;
238
+ let uploadPercent = Math.floor(event.loaded / event.total * 100);
239
+ fileMessage.percent = uploadPercent;
240
+ if (onFileUploadProgress) onFileUploadProgress(fileMessage);
241
+ };
242
+ this.enteredCounter = 0; // Determine whether to enter the child element to avoid dragging bubbling bugs。
243
+ this.start = 0;
244
+ }
245
+ componentWillUnmount() {
246
+ // prevent async operation
247
+ this.setState = (state, callback) => {
248
+ return;
249
+ };
23
250
  }
24
251
  render() {
25
- return /*#__PURE__*/_react.default.createElement("input", {
252
+ const {
253
+ uploadType
254
+ } = this.props;
255
+ return /*#__PURE__*/_react.default.createElement("div", {
256
+ onDragEnter: this.onDragEnter,
257
+ onDragOver: this.onDragOver,
258
+ onDragLeave: this.onDragLeave,
259
+ onDrop: this.onDrop,
260
+ onPaste: this.onPaste,
261
+ onMouseEnter: this.onMouseEnter,
262
+ onMouseLeave: this.onMouseLeave,
263
+ onClick: this.uploadFileClick,
264
+ className: this.props.className
265
+ }, this.props.children, uploadType === 'file' && /*#__PURE__*/_react.default.createElement("input", {
266
+ type: "file",
267
+ className: "dtable-ui-upload-image",
268
+ ref: ref => this.uploadFileRef = ref,
269
+ onClick: this.onInputFile,
270
+ onChange: this.uploadFilesChange,
271
+ value: "",
272
+ multiple: true
273
+ }), uploadType === 'image' && /*#__PURE__*/_react.default.createElement("input", {
26
274
  type: "file",
27
- onChange: this.onFilesChanged
28
- });
275
+ className: "dtable-ui-upload-image",
276
+ accept: "image/*",
277
+ ref: ref => this.uploadFileRef = ref,
278
+ onClick: this.onInputFile,
279
+ onChange: this.uploadFilesChange,
280
+ value: "",
281
+ multiple: true
282
+ }));
29
283
  }
30
284
  }
31
285
  var _default = exports.default = FileUploader;
@@ -10,6 +10,7 @@ var _dtableUtils = require("dtable-utils");
10
10
  var _baseFormatterConfig = _interopRequireDefault(require("../formatterConfig/base-formatter-config"));
11
11
  var _TextFormatter = _interopRequireDefault(require("../TextFormatter"));
12
12
  var _utils = require("./utils");
13
+ var _utils2 = require("../utils/utils");
13
14
  var _cellValueValidator = _interopRequireDefault(require("./cell-value-validator"));
14
15
  require("./index.css");
15
16
  class FormulaFormatter extends _react.default.Component {
@@ -114,7 +115,7 @@ class FormulaFormatter extends _react.default.Component {
114
115
  return /*#__PURE__*/_react.default.cloneElement(Formatter, {
115
116
  ...formatterProps
116
117
  });
117
- } else if ((0, _utils.isFunction)(Formatter)) {
118
+ } else if ((0, _utils2.isFunction)(Formatter)) {
118
119
  return /*#__PURE__*/_react.default.createElement(Formatter, formatterProps);
119
120
  }
120
121
  return /*#__PURE__*/_react.default.createElement(_TextFormatter.default, formatterProps);