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
@@ -0,0 +1,135 @@
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 _signatureTool = _interopRequireDefault(require("./signature-tool"));
11
+ var _Loading = _interopRequireDefault(require("../../Loading"));
12
+ var _lang = require("../../lang");
13
+ require("./index.css");
14
+ class SignatureBoard extends _react.Component {
15
+ constructor(props) {
16
+ super(props);
17
+ this.initSignTool = () => {
18
+ let signatureBoardCanvas = document.querySelector('#signature_board_canvas');
19
+ if (!this.signatureBoard || !signatureBoardCanvas) return;
20
+ signatureBoardCanvas.style.width = "".concat(this.signatureBoard.offsetWidth, "px");
21
+ signatureBoardCanvas.style.height = "".concat(this.signatureBoard.offsetHeight, "px");
22
+ this.signatureTool = new _signatureTool.default(signatureBoardCanvas, {
23
+ minLineWidth: 2,
24
+ maxLineWidth: 4,
25
+ onStart: this.onStartSign
26
+ });
27
+ };
28
+ this.onStartSign = () => {
29
+ this.hasChanged = true;
30
+ this.setState({
31
+ isEmpty: false,
32
+ signImageUrl: null
33
+ });
34
+ };
35
+ this.checkHasChanged = () => {
36
+ return this.hasChanged;
37
+ };
38
+ this.clear = () => {
39
+ this.hasChanged = true;
40
+ this.signatureTool.clear();
41
+ this.setState({
42
+ isEmpty: true,
43
+ signImageUrl: null
44
+ });
45
+ };
46
+ this.getPNG = () => {
47
+ if (this.signatureTool.isEmpty()) return null;
48
+ return this.signatureTool.getPNG();
49
+ };
50
+ this.getJPG = quality => {
51
+ if (this.signatureTool.isEmpty()) return null;
52
+ return this.signatureTool.getJPG(quality);
53
+ };
54
+ this.convert2BlobPNG = callback => {
55
+ if (this.signatureTool.isEmpty()) {
56
+ callback && callback(null);
57
+ return;
58
+ }
59
+ this.signatureTool.convert2BlobPNG(callback);
60
+ };
61
+ this.convert2BlobJPG = callback => {
62
+ if (this.signatureTool.isEmpty()) {
63
+ callback && callback(null);
64
+ return;
65
+ }
66
+ this.signatureTool.convert2BlobJPG(callback);
67
+ };
68
+ this.onClickSignImage = () => {
69
+ if (this.props.onClickSignImage) {
70
+ this.props.onClickSignImage();
71
+ }
72
+ };
73
+ this.renderTips = () => {
74
+ const {
75
+ isEmpty
76
+ } = this.state;
77
+ if (!isEmpty) return null;
78
+ return /*#__PURE__*/_react.default.createElement("div", {
79
+ className: "signature-board-tips"
80
+ }, (0, _lang.getLocale)('Please_sign_on_this_panel'));
81
+ };
82
+ this.renderSignImage = () => {
83
+ const {
84
+ isEmpty,
85
+ signImageUrl,
86
+ loadingSignImage
87
+ } = this.state;
88
+ if (isEmpty || !signImageUrl) return null;
89
+ let img = new Image();
90
+ img.src = signImageUrl;
91
+ img.onload = () => {
92
+ this.setState({
93
+ loadingSignImage: false
94
+ });
95
+ };
96
+ img.onerror = () => {
97
+ this.setState({
98
+ loadingSignImage: false
99
+ });
100
+ };
101
+ return /*#__PURE__*/_react.default.createElement("div", {
102
+ className: "signature-board-image-wrapper",
103
+ style: {
104
+ zIndex: 2
105
+ },
106
+ onClick: this.onClickSignImage
107
+ }, loadingSignImage ? /*#__PURE__*/_react.default.createElement(_Loading.default, null) : /*#__PURE__*/_react.default.createElement("img", {
108
+ src: signImageUrl,
109
+ alt: "",
110
+ draggable: false
111
+ }));
112
+ };
113
+ this.state = {
114
+ isEmpty: !props.signImageUrl,
115
+ signImageUrl: props.signImageUrl,
116
+ loadingSignImage: !!props.signImageUrl
117
+ };
118
+ this.hasChanged = false;
119
+ }
120
+ componentDidMount() {
121
+ this.initSignTool();
122
+ }
123
+ componentWillUnmount() {
124
+ this.setState = () => {};
125
+ }
126
+ render() {
127
+ return /*#__PURE__*/_react.default.createElement("div", {
128
+ className: "signature-board",
129
+ ref: ref => this.signatureBoard = ref
130
+ }, /*#__PURE__*/_react.default.createElement("canvas", {
131
+ id: "signature_board_canvas"
132
+ }), this.renderTips(), this.renderSignImage());
133
+ }
134
+ }
135
+ var _default = exports.default = SignatureBoard;
@@ -0,0 +1,396 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const DEFAULT_IMAGE_TYPE = 'image/png';
8
+ class SignatureTool {
9
+ constructor(_canvas, options) {
10
+ var _this = this;
11
+ this.startDraw = event => {
12
+ event.preventDefault();
13
+ this.canDraw = true;
14
+ this.ctx.strokeStyle = this.color;
15
+ this.initPoint(event);
16
+ this.onStart && this.onStart(event);
17
+ };
18
+ this.drawing = event => {
19
+ event.preventDefault();
20
+ if (!this.canDraw) return;
21
+ this.initPoint(event);
22
+ if (this.points.length < 2) return;
23
+ const point = this.points.slice(-1)[0];
24
+ const prePoint = this.points.slice(-2, -1)[0];
25
+ if (window.requestAnimationFrame) {
26
+ window.requestAnimationFrame(() => this.onDraw(prePoint, point));
27
+ } else {
28
+ this.onDraw(prePoint, point);
29
+ }
30
+ };
31
+ this.endDraw = event => {
32
+ if (!this.canDraw) return;
33
+ if (this.points.length < 2) {
34
+ this.drawPoint(this.points[0]);
35
+ }
36
+ this.canDraw = false;
37
+ this.canAddHistory = true;
38
+ this.points = [];
39
+ this.onEnd && this.onEnd(event);
40
+ };
41
+ this.getLineWidth = speed => {
42
+ // thinner if moving faster, thicker if moving slower
43
+ const minSpeed = this.minSpeed > 10 ? 10 : this.minSpeed < 1 ? 1 : this.minSpeed;
44
+ const addWidth = (this.maxLineWidth - this.minLineWidth) * speed / minSpeed;
45
+ const lineWidth = Math.max(this.maxLineWidth - addWidth, this.minLineWidth);
46
+ return Math.min(lineWidth, this.maxLineWidth);
47
+ };
48
+ this.getRadianData = (x1, y1, x2, y2) => {
49
+ const dis_x = x2 - x1;
50
+ const dis_y = y2 - y1;
51
+
52
+ // 1 has no radian
53
+ if (dis_x === 0) {
54
+ return {
55
+ val: 0,
56
+ pos: -1
57
+ }; // 1.1 vertical movement only
58
+ }
59
+ if (dis_y === 0) {
60
+ return {
61
+ val: 0,
62
+ pos: 1
63
+ }; // 1.2 horizontal movement only
64
+ }
65
+
66
+ // 2 has radian
67
+ const val = Math.abs(Math.atan(dis_y / dis_x));
68
+ // eslint-disable-next-line no-mixed-operators
69
+ if (x2 > x1 && y2 < y1 || x2 < x1 && y2 > y1) {
70
+ return {
71
+ val,
72
+ pos: 1
73
+ }; // 2.1 down-right or up-left movement
74
+ }
75
+ return {
76
+ val,
77
+ pos: -1
78
+ }; // 2.2 down-left or up-right movement
79
+ };
80
+ this.getRadianPoints = (radianData, x, y, halfLineWidth) => {
81
+ // 1 has no radian
82
+ if (radianData.val === 0) {
83
+ // 1.1 horizontal movement only
84
+ if (radianData.pos === 1) {
85
+ return [{
86
+ x,
87
+ y: y + halfLineWidth
88
+ },
89
+ // a trapezoidal point at half the line width above the current point
90
+ {
91
+ x,
92
+ y: y - halfLineWidth
93
+ } // a trapezoidal point at half the line width below the current point
94
+ ];
95
+ }
96
+
97
+ // 1.2 vertical movement only
98
+ return [{
99
+ y,
100
+ x: x + halfLineWidth
101
+ },
102
+ // a trapezoidal point at half the line width to the right of the current point
103
+ {
104
+ y,
105
+ x: x - halfLineWidth
106
+ } // a trapezoidal point at half the line width to the left of the current point
107
+ ];
108
+ }
109
+
110
+ // 2 has radian
111
+ // the distance between the trapezoidal point and the current point according to the radian
112
+ const dis_x = Math.sin(radianData.val) * halfLineWidth; // horizontal distance
113
+ const dis_y = Math.cos(radianData.val) * halfLineWidth; // vertical distance
114
+
115
+ // 2.1 down-right or up-left movement
116
+ if (radianData.pos === 1) {
117
+ return [{
118
+ x: x + dis_x,
119
+ y: y + dis_y
120
+ },
121
+ // a trapezoidal point at the up-right of the current point
122
+ {
123
+ x: x - dis_x,
124
+ y: y - dis_y
125
+ } // a trapezoidal point at the down-left of the current point
126
+ ];
127
+ }
128
+
129
+ // 2.2 down-left or up-right movement
130
+ return [{
131
+ x: x + dis_x,
132
+ y: y - dis_y
133
+ },
134
+ // a trapezoidal point at the down-right of the current point
135
+ {
136
+ x: x - dis_x,
137
+ y: y + dis_y
138
+ } // a trapezoidal point at the up-left of the current point
139
+ ];
140
+ };
141
+ this.initPoint = event => {
142
+ const time = Date.now();
143
+ const prePoint = this.points.slice(-1)[0];
144
+ if (prePoint && prePoint.time === time) {
145
+ return;
146
+ }
147
+ const rect = this.canvas.getBoundingClientRect();
148
+ // eslint-disable-next-line no-mixed-operators
149
+ const e = event.touches && event.touches[0] || event;
150
+ const x = e.clientX - rect.left;
151
+ const y = e.clientY - rect.top;
152
+
153
+ // moved but current position not changed
154
+ if (prePoint && prePoint.x === x && prePoint.y === y) {
155
+ return;
156
+ }
157
+ const point = {
158
+ x,
159
+ y,
160
+ time
161
+ };
162
+ if (this.openStroke && prePoint) {
163
+ const prePoint2 = this.points.slice(-2, -1)[0];
164
+ point.distance = Math.sqrt(Math.pow(point.x - prePoint.x, 2) + Math.pow(point.y - prePoint.y, 2));
165
+ point.speed = point.distance / (point.time - prePoint.time || 0.1);
166
+ point.lineWidth = this.getLineWidth(point.speed);
167
+ if (prePoint2 && prePoint2.lineWidth && prePoint.lineWidth) {
168
+ // "maxWidthDiffRate" protection: prevent too large width difference between two adjacent lines
169
+ const rate = (point.lineWidth - prePoint.lineWidth) / prePoint.lineWidth;
170
+ let maxRate = this.maxWidthDiffRate / 100;
171
+ maxRate = maxRate > 1 ? 1 : maxRate < 0.01 ? 0.01 : maxRate;
172
+ if (Math.abs(rate) > maxRate) {
173
+ const per = rate > 0 ? maxRate : -maxRate;
174
+ point.lineWidth = prePoint.lineWidth * (1 + per);
175
+ }
176
+ }
177
+ }
178
+ this.points.push(point);
179
+ this.points = this.points.slice(-3);
180
+ };
181
+ this.onDraw = (prePoint, point) => {
182
+ if (this.openStroke) {
183
+ this.drawLineWithStrokes(prePoint, point);
184
+ return;
185
+ }
186
+ this.drawLine(prePoint, point);
187
+ };
188
+ this.drawArcLine = (startPointX, startPointY, controlPointX, controlPointY, endPointX, endPointY, lineWidth) => {
189
+ this.ctx.lineWidth = Number(lineWidth.toFixed(1));
190
+ this.ctx.beginPath();
191
+ this.ctx.moveTo(Number(startPointX.toFixed(1)), Number(startPointY.toFixed(1)));
192
+ this.ctx.quadraticCurveTo(Number(controlPointX.toFixed(1)), Number(controlPointY.toFixed(1)), Number(endPointX.toFixed(1)), Number(endPointY.toFixed(1)));
193
+ this.ctx.stroke();
194
+ };
195
+ this.drawTrapezoid = (point1, point2, point3, point4) => {
196
+ this.ctx.beginPath();
197
+ this.ctx.moveTo(Number(point1.x.toFixed(1)), Number(point1.y.toFixed(1)));
198
+ this.ctx.lineTo(Number(point2.x.toFixed(1)), Number(point2.y.toFixed(1)));
199
+ this.ctx.lineTo(Number(point3.x.toFixed(1)), Number(point3.y.toFixed(1)));
200
+ this.ctx.lineTo(Number(point4.x.toFixed(1)), Number(point4.y.toFixed(1)));
201
+ this.ctx.fillStyle = this.color;
202
+ this.ctx.fill();
203
+ };
204
+ this.drawLine = (prePoint, point) => {
205
+ point.lastX = prePoint.x + (point.x - prePoint.x) * 0.5;
206
+ point.lastY = prePoint.y + (point.y - prePoint.y) * 0.5;
207
+ if (typeof prePoint.lastX === 'number') {
208
+ this.drawArcLine(prePoint.lastX, prePoint.lastY, prePoint.x, prePoint.y, point.lastX, point.lastY, this.minLineWidth);
209
+ }
210
+ };
211
+ this.drawLineWithStrokes = (prePoint, point) => {
212
+ const dis_x = point.x - prePoint.x;
213
+ const dis_y = point.y - prePoint.y;
214
+ if (Math.abs(dis_x) + Math.abs(dis_y) <= this.scale) {
215
+ point.lastX1 = point.lastX2 = prePoint.x + dis_x * 0.5;
216
+ point.lastY1 = point.lastY2 = prePoint.y + dis_y * 0.5;
217
+ } else {
218
+ // draw smoother line with three parts
219
+ // part1(30%): arc line
220
+ // part2(40%): trapezoid
221
+ // part3(30%): arc line
222
+ point.lastX1 = prePoint.x + dis_x * 0.3;
223
+ point.lastY1 = prePoint.y + dis_y * 0.3;
224
+ point.lastX2 = prePoint.x + dis_x * 0.7;
225
+ point.lastY2 = prePoint.y + dis_y * 0.7;
226
+ }
227
+ point.perLineWidth = (prePoint.lineWidth + point.lineWidth) / 2;
228
+ if (typeof prePoint.lastX1 !== 'number') {
229
+ point.isFirstPoint = true;
230
+ return;
231
+ }
232
+
233
+ // draw arc line: part1 or part3 of the line
234
+ this.drawArcLine(prePoint.lastX2, prePoint.lastY2, prePoint.x, prePoint.y, point.lastX1, point.lastY1, point.perLineWidth);
235
+ if (prePoint.isFirstPoint) return;
236
+ if (prePoint.lastX1 === prePoint.lastX2 && prePoint.lastY1 === prePoint.lastY2) return;
237
+
238
+ // draw trapezoid: between par1 and part3
239
+ const data = this.getRadianData(prePoint.lastX1, prePoint.lastY1, prePoint.lastX2, prePoint.lastY2);
240
+ const points1 = this.getRadianPoints(data, prePoint.lastX1, prePoint.lastY1, prePoint.perLineWidth / 2);
241
+ const points2 = this.getRadianPoints(data, prePoint.lastX2, prePoint.lastY2, point.perLineWidth / 2);
242
+ this.drawTrapezoid(points1[0], points2[0], points2[1], points1[1]);
243
+ };
244
+ this.drawPoint = point => {
245
+ this.ctx.fillStyle = this.color;
246
+ this.ctx.beginPath();
247
+ this.ctx.arc(point.x, point.y, this.minLineWidth, 0, 2 * Math.PI);
248
+ this.ctx.fill();
249
+ };
250
+ this.toDataURL = function () {
251
+ let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_IMAGE_TYPE;
252
+ let quality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
253
+ if (_this.canvas.width === _this.width) {
254
+ return _this.canvas.toDataURL(type, quality);
255
+ }
256
+ const canvas = document.createElement('canvas');
257
+ canvas.width = _this.width;
258
+ canvas.height = _this.height;
259
+ const ctx = canvas.getContext('2d');
260
+ ctx.drawImage(_this.canvas, 0, 0, canvas.width, canvas.height);
261
+ return canvas.toDataURL(type, quality);
262
+ };
263
+ this.toBlob = function (callback) {
264
+ let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_IMAGE_TYPE;
265
+ let quality = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
266
+ if (_this.canvas.width === _this.width) {
267
+ return _this.canvas.toBlob(blob => {
268
+ callback && callback(blob);
269
+ }, type, quality);
270
+ }
271
+ const canvas = document.createElement('canvas');
272
+ canvas.width = _this.width;
273
+ canvas.height = _this.height;
274
+ const ctx = canvas.getContext('2d');
275
+ ctx.drawImage(_this.canvas, 0, 0, canvas.width, canvas.height);
276
+ return canvas.toBlob(blob => {
277
+ callback && callback(blob);
278
+ }, type, quality);
279
+ };
280
+ this.clear = () => {
281
+ this.ctx.clearRect(0, 0, this.width, this.height);
282
+ this.initBgColor();
283
+ };
284
+ this.isEmpty = () => {
285
+ const canvas = document.createElement('canvas');
286
+ const ctx = canvas.getContext('2d');
287
+ canvas.width = this.canvas.width;
288
+ canvas.height = this.canvas.height;
289
+ if (this.bgColor) {
290
+ ctx.fillStyle = this.bgColor;
291
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
292
+ } else if (this.scale !== 1) {
293
+ ctx.scale(this.scale, this.scale);
294
+ }
295
+ return canvas.toDataURL() === this.canvas.toDataURL();
296
+ };
297
+ this.getBase64PNG = () => {
298
+ return this.toDataURL();
299
+ };
300
+ this.getBase64JPG = function () {
301
+ let quality = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.8;
302
+ return _this.toDataURL('image/jpeg', quality);
303
+ };
304
+ this.convert2BlobPNG = callback => {
305
+ this.toBlob(callback);
306
+ };
307
+ this.convert2BlobJPG = function (callback) {
308
+ let quality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.8;
309
+ _this.toBlob(callback, 'image/jpeg', quality);
310
+ };
311
+ this.width = 600;
312
+ this.height = 300;
313
+ this.scale = window.devicePixelRatio || 1;
314
+ this.color = '#000';
315
+ this.bgColor = 'transparent';
316
+ this.openStroke = true;
317
+ this.canDraw = false;
318
+ this.minLineWidth = 4;
319
+ this.maxLineWidth = 6;
320
+ this.minSpeed = 1.5; // the minimum speed which the minimum line width required(ranges: 1.0 - 10.0)
321
+ this.maxWidthDiffRate = 20; // the maximum percentage of the increase(decrease) of the width of two adjacent lines(ranges: 1 - 100)
322
+ this.points = [];
323
+ this.init(_canvas, options);
324
+ }
325
+ init(canvas, options) {
326
+ if (!canvas) return;
327
+ this.canvas = canvas;
328
+ this.ctx = this.canvas.getContext('2d');
329
+ this.width = options.width || canvas.clientWidth || this.width;
330
+ this.height = options.height || canvas.clientHeight || this.height;
331
+ this.scale = options.scale || this.scale;
332
+ this.color = options.color || this.color;
333
+ this.bgColor = options.bgColor || this.bgColor;
334
+ this.openStroke = options.openStroke === undefined ? this.openStroke : !!options.openStroke;
335
+ this.minLineWidth = options.minLineWidth || this.minLineWidth;
336
+ this.maxLineWidth = options.maxLineWidth || this.maxLineWidth;
337
+ this.minSpeed = options.minSpeed || this.minSpeed;
338
+ this.maxWidthDiffRate = options.maxWidthDiffRate || this.maxWidthDiffRate;
339
+ this.onStart = options.onStart;
340
+ this.onEnd = options.onEnd;
341
+ this.initOffsets();
342
+ this.ctx.lineCap = 'round'; // use rounded corners on both ends of the line
343
+ this.ctx.lineJoin = 'round'; // use rounded corners where lines meet
344
+ this.initBgColor();
345
+ this.addEvents();
346
+ }
347
+ initOffsets() {
348
+ if (this.scale > 0) {
349
+ this.canvas.height = this.height * this.scale;
350
+ this.canvas.width = this.width * this.scale;
351
+ if (this.scale !== 1) {
352
+ this.canvas.style.width = this.width + 'px';
353
+ this.canvas.style.height = this.height + 'px';
354
+ this.ctx.scale(this.scale, this.scale);
355
+ }
356
+ }
357
+ }
358
+ initBgColor() {
359
+ if (!this.bgColor) return;
360
+ this.ctx.fillStyle = this.bgColor;
361
+ this.ctx.fillRect(0, 0, this.width, this.height);
362
+ }
363
+ addEvents() {
364
+ this.removeEvents();
365
+ this.canvas.style.touchAction = 'none';
366
+
367
+ // mobile
368
+ if ('ontouchstart' in window || navigator.maxTouchPoints) {
369
+ this.canvas.addEventListener('touchstart', this.startDraw);
370
+ this.canvas.addEventListener('touchmove', this.drawing);
371
+ document.addEventListener('touchcancel', this.endDraw);
372
+ document.addEventListener('touchend', this.endDraw);
373
+ return;
374
+ }
375
+
376
+ // pc
377
+ this.canvas.addEventListener('mousedown', this.startDraw);
378
+ this.canvas.addEventListener('mousemove', this.drawing);
379
+ document.addEventListener('mouseup', this.endDraw);
380
+ }
381
+ removeEvents() {
382
+ this.canvas.style.touchAction = 'auto';
383
+
384
+ // mobile
385
+ this.canvas.removeEventListener('touchstart', this.startDraw);
386
+ this.canvas.removeEventListener('touchmove', this.drawing);
387
+ document.removeEventListener('touchend', this.endDraw);
388
+ document.removeEventListener('touchcancel', this.endDraw);
389
+
390
+ // pc
391
+ this.canvas.removeEventListener('mousedown', this.startDraw);
392
+ this.canvas.removeEventListener('mousemove', this.drawing);
393
+ document.removeEventListener('mouseup', this.endDraw);
394
+ }
395
+ }
396
+ var _default = exports.default = SignatureTool;
@@ -0,0 +1,29 @@
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
+ var _utc = _interopRequireDefault(require("dayjs/plugin/utc"));
10
+ var _dtableUtils = require("dtable-utils");
11
+ _dayjs.default.extend(_utc.default);
12
+ class DigitalSignUtils {
13
+ static getSignImageUrl(sign) {
14
+ return (0, _dtableUtils.getDigitalSignImageUrl)(sign);
15
+ }
16
+ static getUpdatedSign(_ref) {
17
+ let {
18
+ username,
19
+ sign_image_url
20
+ } = _ref;
21
+ const time = (0, _dayjs.default)().utc().format('YYYY-MM-DDTHH:mm:ss.SSSZ');
22
+ return {
23
+ username,
24
+ sign_image_url,
25
+ sign_time: time
26
+ };
27
+ }
28
+ }
29
+ var _default = exports.default = DigitalSignUtils;
@@ -0,0 +1,111 @@
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 _reactDom = _interopRequireDefault(require("react-dom"));
10
+ var _dtableUtils = require("dtable-utils");
11
+ var _classnames = _interopRequireDefault(require("classnames"));
12
+ var _constants = require("../constants");
13
+ class DurationEditor extends _react.default.Component {
14
+ constructor(props) {
15
+ super(props);
16
+ this.onChange = event => {
17
+ let value = event.target.value.trim().replace(/[^.-\d::]/g, '');
18
+ if (value === this.state.value) {
19
+ return;
20
+ }
21
+ this.setState({
22
+ value
23
+ });
24
+ };
25
+ this.onKeyDown = event => {
26
+ let {
27
+ selectionStart,
28
+ selectionEnd,
29
+ value
30
+ } = event.currentTarget;
31
+ if (event.keyCode === _constants.KeyCodes.Enter) {
32
+ event.preventDefault();
33
+ this.onBlur();
34
+ if (this.props.selectDownCell) this.props.selectDownCell();
35
+ } else if (event.keyCode === _constants.KeyCodes.LeftArrow && selectionStart === 0 || event.keyCode === _constants.KeyCodes.RightArrow && selectionEnd === value.length) {
36
+ event.stopPropagation();
37
+ }
38
+ };
39
+ this.getValue = () => {
40
+ const {
41
+ column
42
+ } = this.props;
43
+ const newDuration = (0, _dtableUtils.formatDurationToNumber)(this.getInputNode().value, column.data);
44
+ return newDuration;
45
+ };
46
+ this.getInputNode = () => {
47
+ const domNode = _reactDom.default.findDOMNode(this.input);
48
+ if (domNode.tagName === 'INPUT') {
49
+ return domNode;
50
+ }
51
+ return domNode.querySelector('input:not([type=hidden])');
52
+ };
53
+ this.onBlur = () => {
54
+ this.props.isInModal ? this.props.onCommit(this.getValue()) : this.props.onBlur();
55
+ };
56
+ this.setInputRef = input => {
57
+ this.input = input;
58
+ return this.input;
59
+ };
60
+ this.onPaste = e => {
61
+ e.stopPropagation();
62
+ };
63
+ this.onCut = e => {
64
+ e.stopPropagation();
65
+ };
66
+ let {
67
+ value: _value,
68
+ column: _column
69
+ } = props;
70
+ this.initValue = _value || _value === 0 ? (0, _dtableUtils.getDurationDisplayString)(_value, _column.data) : '';
71
+ this.state = {
72
+ value: this.initValue
73
+ };
74
+ }
75
+ componentDidMount() {
76
+ if (this.props.isInModal) {
77
+ this.input.focus();
78
+ }
79
+ }
80
+ render() {
81
+ const {
82
+ column,
83
+ isInModal,
84
+ className
85
+ } = this.props;
86
+ const data = column.data || {};
87
+ const {
88
+ duration_format
89
+ } = data;
90
+ const style = isInModal ? {
91
+ textAlign: 'left',
92
+ width: '320px'
93
+ } : {
94
+ textAlign: 'right'
95
+ };
96
+ return /*#__PURE__*/_react.default.createElement("input", {
97
+ ref: this.setInputRef,
98
+ type: "text",
99
+ className: (0, _classnames.default)('form-control', className),
100
+ value: this.state.value,
101
+ onBlur: this.onBlur,
102
+ onPaste: this.onPaste,
103
+ onCut: this.onCut,
104
+ onKeyDown: this.onKeyDown,
105
+ onChange: this.onChange,
106
+ style: style,
107
+ placeholder: duration_format
108
+ });
109
+ }
110
+ }
111
+ var _default = exports.default = DurationEditor;