fan-standard-comp 3.1.3 → 3.1.4

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 (244) hide show
  1. package/package.json +1 -1
  2. package/dist/f26952c118ab6cdcd23dc0028ee98c11.svg +0 -173
  3. package/dist/fan-standard-comp.umd.js +0 -597
  4. package/dist/fonts/iconfont.eot +0 -0
  5. package/dist/fonts/iconfont.ttf +0 -0
  6. package/dist/fonts/iconfont.woff +0 -0
  7. package/es/ButtonGroup/ButtonList.d.ts +0 -2
  8. package/es/ButtonGroup/ButtonList.js +0 -37
  9. package/es/ButtonGroup/ButtonMenu.d.ts +0 -2
  10. package/es/ButtonGroup/ButtonMenu.js +0 -38
  11. package/es/ButtonGroup/PopConfirmTitle.d.ts +0 -9
  12. package/es/ButtonGroup/PopConfirmTitle.js +0 -37
  13. package/es/ButtonGroup/index.d.ts +0 -30
  14. package/es/ButtonGroup/index.js +0 -374
  15. package/es/ButtonGroup/style/index.less +0 -36
  16. package/es/DragContent/DragBar.js +0 -21
  17. package/es/DragContent/index.d.ts +0 -14
  18. package/es/DragContent/index.js +0 -173
  19. package/es/DragContent/index.less +0 -44
  20. package/es/FormComp/ChunkUploader/api.js +0 -76
  21. package/es/FormComp/ChunkUploader/index.js +0 -391
  22. package/es/FormComp/ChunkUploader/lib.js +0 -96
  23. package/es/FormComp/ChunkUploader/style/style.less +0 -3
  24. package/es/FormComp/ChunkUploader/upload-queue.class.js +0 -167
  25. package/es/FormComp/ChunkUploader/worker.js +0 -23
  26. package/es/FormComp/EditButton/index.d.ts +0 -26
  27. package/es/FormComp/EditButton/index.js +0 -140
  28. package/es/FormComp/FieldComponent/ReUpload.d.ts +0 -3
  29. package/es/FormComp/FieldComponent/ReUpload.js +0 -131
  30. package/es/FormComp/FieldComponent/RefactorTreeSelect.js +0 -251
  31. package/es/FormComp/FieldComponent/TitleNode.d.ts +0 -6
  32. package/es/FormComp/FieldComponent/TitleNode.js +0 -9
  33. package/es/FormComp/FieldComponent/index.d.ts +0 -38
  34. package/es/FormComp/FieldComponent/index.js +0 -413
  35. package/es/FormComp/FieldComponent/setReadonlyValues.js +0 -236
  36. package/es/FormComp/FieldComponent/style/index.less +0 -116
  37. package/es/FormComp/RenderItemGroup/index.d.ts +0 -37
  38. package/es/FormComp/RenderItemGroup/index.js +0 -234
  39. package/es/FormComp/Uploader/index.d.ts +0 -19
  40. package/es/FormComp/Uploader/index.js +0 -275
  41. package/es/FormComp/Uploader/style/index.less +0 -14
  42. package/es/FormComp/Uploader/util.d.ts +0 -8
  43. package/es/FormComp/Uploader/util.js +0 -38
  44. package/es/FormComp/VarTemplate/index.js +0 -293
  45. package/es/FormComp/index.d.ts +0 -1
  46. package/es/FormComp/index.js +0 -1
  47. package/es/NavLeafScroll/index.js +0 -379
  48. package/es/NavLeafScroll/style/index.less +0 -119
  49. package/es/RefactorTree/data.d.ts +0 -7
  50. package/es/RefactorTree/index.d.ts +0 -40
  51. package/es/RefactorTree/index.js +0 -167
  52. package/es/RefactorTree/indexTreeNode.d.ts +0 -39
  53. package/es/RefactorTree/indexTreeNode.js +0 -237
  54. package/es/RefactorTree/style/index.d.ts +0 -1
  55. package/es/RefactorTree/style/index.js +0 -1
  56. package/es/RefactorTree/style/index.less +0 -22
  57. package/es/RefactorTree/util.d.ts +0 -42
  58. package/es/RefactorTree/util.js +0 -187
  59. package/es/SpecIcon/fonts/demo.css +0 -539
  60. package/es/SpecIcon/fonts/demo_index.html +0 -1315
  61. package/es/SpecIcon/fonts/iconfont.css +0 -211
  62. package/es/SpecIcon/fonts/iconfont.eot +0 -0
  63. package/es/SpecIcon/fonts/iconfont.js +0 -41
  64. package/es/SpecIcon/fonts/iconfont.json +0 -352
  65. package/es/SpecIcon/fonts/iconfont.svg +0 -173
  66. package/es/SpecIcon/fonts/iconfont.ttf +0 -0
  67. package/es/SpecIcon/fonts/iconfont.woff +0 -0
  68. package/es/SpecIcon/fonts/iconfont.woff2 +0 -0
  69. package/es/SpecIcon/index.d.ts +0 -17
  70. package/es/SpecIcon/index.js +0 -77
  71. package/es/SpecIcon/style/iconfont.less +0 -213
  72. package/es/SpecIcon/style/index.less +0 -98
  73. package/es/SplitterLayout/Pane.d.ts +0 -13
  74. package/es/SplitterLayout/Pane.js +0 -36
  75. package/es/SplitterLayout/index.js +0 -375
  76. package/es/SplitterLayout/index.less +0 -58
  77. package/es/StandardContent/SplitterLayout/Pane.js +0 -50
  78. package/es/StandardContent/SplitterLayout/index.js +0 -374
  79. package/es/StandardContent/SplitterLayout/index.less +0 -58
  80. package/es/StandardContent/SubfieldContent.d.ts +0 -17
  81. package/es/StandardContent/SubfieldContent.js +0 -41
  82. package/es/StandardContent/WrapperContent.d.ts +0 -13
  83. package/es/StandardContent/WrapperContent.js +0 -29
  84. package/es/StandardContent/data.d.ts +0 -101
  85. package/es/StandardContent/style/index.less +0 -80
  86. package/es/StandardDragModal/index.d.ts +0 -11
  87. package/es/StandardDragModal/index.js +0 -30
  88. package/es/StandardFilter/index.d.ts +0 -35
  89. package/es/StandardFilter/index.js +0 -253
  90. package/es/StandardFilter/style/index.less +0 -62
  91. package/es/StandardForm/ActionList.js +0 -44
  92. package/es/StandardForm/StepForm.d.ts +0 -19
  93. package/es/StandardForm/StepForm.js +0 -267
  94. package/es/StandardForm/TabForm.d.ts +0 -19
  95. package/es/StandardForm/TabForm.js +0 -122
  96. package/es/StandardForm/index.d.ts +0 -32
  97. package/es/StandardForm/index.js +0 -170
  98. package/es/StandardForm/style/index.less +0 -58
  99. package/es/StandardModal/UpdateFormRef.js +0 -18
  100. package/es/StandardModal/index.d.ts +0 -44
  101. package/es/StandardModal/index.js +0 -495
  102. package/es/StandardModal/style/index.less +0 -50
  103. package/es/StandardPanel/index.d.ts +0 -28
  104. package/es/StandardPanel/index.js +0 -134
  105. package/es/StandardPanel/style/index.less +0 -135
  106. package/es/StandardTable/index.d.ts +0 -22
  107. package/es/StandardTable/index.js +0 -126
  108. package/es/StandardTable/style/index.d.ts +0 -1
  109. package/es/StandardTable/style/index.js +0 -1
  110. package/es/StandardTable/style/index.less +0 -206
  111. package/es/components/IconNode/index.d.ts +0 -16
  112. package/es/components/IconNode/index.js +0 -28
  113. package/es/components/index.d.ts +0 -2
  114. package/es/components/index.js +0 -2
  115. package/es/data/func.code.js +0 -112
  116. package/es/data/general.config.js +0 -172
  117. package/es/data/index.js +0 -3
  118. package/es/index.d.ts +0 -24
  119. package/es/index.js +0 -31
  120. package/es/styles/index.less +0 -0
  121. package/es/theme/spec-variable.less +0 -48
  122. package/es/utils/ValueFormat.js +0 -50
  123. package/es/utils/filterPermission.js +0 -111
  124. package/es/utils/getParentNodes.js +0 -215
  125. package/es/utils/index.js +0 -3
  126. package/lib/ButtonGroup/ButtonList.d.ts +0 -2
  127. package/lib/ButtonGroup/ButtonList.js +0 -55
  128. package/lib/ButtonGroup/ButtonMenu.d.ts +0 -2
  129. package/lib/ButtonGroup/ButtonMenu.js +0 -51
  130. package/lib/ButtonGroup/PopConfirmTitle.d.ts +0 -9
  131. package/lib/ButtonGroup/PopConfirmTitle.js +0 -48
  132. package/lib/ButtonGroup/index.d.ts +0 -30
  133. package/lib/ButtonGroup/index.js +0 -405
  134. package/lib/ButtonGroup/style/index.less +0 -36
  135. package/lib/DragContent/DragBar.js +0 -33
  136. package/lib/DragContent/index.d.ts +0 -14
  137. package/lib/DragContent/index.js +0 -191
  138. package/lib/DragContent/index.less +0 -44
  139. package/lib/FormComp/ChunkUploader/api.js +0 -89
  140. package/lib/FormComp/ChunkUploader/index.js +0 -410
  141. package/lib/FormComp/ChunkUploader/lib.js +0 -113
  142. package/lib/FormComp/ChunkUploader/style/style.less +0 -3
  143. package/lib/FormComp/ChunkUploader/upload-queue.class.js +0 -174
  144. package/lib/FormComp/ChunkUploader/worker.js +0 -28
  145. package/lib/FormComp/EditButton/index.d.ts +0 -26
  146. package/lib/FormComp/EditButton/index.js +0 -159
  147. package/lib/FormComp/FieldComponent/ReUpload.d.ts +0 -3
  148. package/lib/FormComp/FieldComponent/ReUpload.js +0 -151
  149. package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +0 -274
  150. package/lib/FormComp/FieldComponent/TitleNode.d.ts +0 -6
  151. package/lib/FormComp/FieldComponent/TitleNode.js +0 -19
  152. package/lib/FormComp/FieldComponent/index.d.ts +0 -38
  153. package/lib/FormComp/FieldComponent/index.js +0 -457
  154. package/lib/FormComp/FieldComponent/setReadonlyValues.js +0 -263
  155. package/lib/FormComp/FieldComponent/style/index.less +0 -116
  156. package/lib/FormComp/RenderItemGroup/index.d.ts +0 -37
  157. package/lib/FormComp/RenderItemGroup/index.js +0 -255
  158. package/lib/FormComp/Uploader/index.d.ts +0 -19
  159. package/lib/FormComp/Uploader/index.js +0 -301
  160. package/lib/FormComp/Uploader/style/index.less +0 -14
  161. package/lib/FormComp/Uploader/util.d.ts +0 -8
  162. package/lib/FormComp/Uploader/util.js +0 -47
  163. package/lib/FormComp/VarTemplate/index.js +0 -308
  164. package/lib/FormComp/index.d.ts +0 -1
  165. package/lib/FormComp/index.js +0 -15
  166. package/lib/NavLeafScroll/index.js +0 -397
  167. package/lib/NavLeafScroll/style/index.less +0 -119
  168. package/lib/RefactorTree/data.d.ts +0 -7
  169. package/lib/RefactorTree/index.d.ts +0 -40
  170. package/lib/RefactorTree/index.js +0 -190
  171. package/lib/RefactorTree/indexTreeNode.d.ts +0 -39
  172. package/lib/RefactorTree/indexTreeNode.js +0 -260
  173. package/lib/RefactorTree/style/index.d.ts +0 -1
  174. package/lib/RefactorTree/style/index.js +0 -3
  175. package/lib/RefactorTree/style/index.less +0 -22
  176. package/lib/RefactorTree/util.d.ts +0 -42
  177. package/lib/RefactorTree/util.js +0 -195
  178. package/lib/SpecIcon/fonts/demo.css +0 -539
  179. package/lib/SpecIcon/fonts/demo_index.html +0 -1315
  180. package/lib/SpecIcon/fonts/iconfont.css +0 -211
  181. package/lib/SpecIcon/fonts/iconfont.eot +0 -0
  182. package/lib/SpecIcon/fonts/iconfont.js +0 -43
  183. package/lib/SpecIcon/fonts/iconfont.json +0 -352
  184. package/lib/SpecIcon/fonts/iconfont.svg +0 -173
  185. package/lib/SpecIcon/fonts/iconfont.ttf +0 -0
  186. package/lib/SpecIcon/fonts/iconfont.woff +0 -0
  187. package/lib/SpecIcon/fonts/iconfont.woff2 +0 -0
  188. package/lib/SpecIcon/index.d.ts +0 -17
  189. package/lib/SpecIcon/index.js +0 -90
  190. package/lib/SpecIcon/style/iconfont.less +0 -213
  191. package/lib/SpecIcon/style/index.less +0 -98
  192. package/lib/SplitterLayout/Pane.d.ts +0 -13
  193. package/lib/SplitterLayout/Pane.js +0 -48
  194. package/lib/SplitterLayout/index.js +0 -386
  195. package/lib/SplitterLayout/index.less +0 -58
  196. package/lib/StandardContent/SplitterLayout/Pane.js +0 -62
  197. package/lib/StandardContent/SplitterLayout/index.js +0 -387
  198. package/lib/StandardContent/SplitterLayout/index.less +0 -58
  199. package/lib/StandardContent/SubfieldContent.d.ts +0 -17
  200. package/lib/StandardContent/SubfieldContent.js +0 -56
  201. package/lib/StandardContent/WrapperContent.d.ts +0 -13
  202. package/lib/StandardContent/WrapperContent.js +0 -43
  203. package/lib/StandardContent/data.d.ts +0 -101
  204. package/lib/StandardContent/style/index.less +0 -80
  205. package/lib/StandardDragModal/index.d.ts +0 -11
  206. package/lib/StandardDragModal/index.js +0 -43
  207. package/lib/StandardFilter/index.d.ts +0 -35
  208. package/lib/StandardFilter/index.js +0 -272
  209. package/lib/StandardFilter/style/index.less +0 -62
  210. package/lib/StandardForm/ActionList.js +0 -57
  211. package/lib/StandardForm/StepForm.d.ts +0 -19
  212. package/lib/StandardForm/StepForm.js +0 -295
  213. package/lib/StandardForm/TabForm.d.ts +0 -19
  214. package/lib/StandardForm/TabForm.js +0 -148
  215. package/lib/StandardForm/index.d.ts +0 -32
  216. package/lib/StandardForm/index.js +0 -197
  217. package/lib/StandardForm/style/index.less +0 -58
  218. package/lib/StandardModal/UpdateFormRef.js +0 -32
  219. package/lib/StandardModal/index.d.ts +0 -44
  220. package/lib/StandardModal/index.js +0 -525
  221. package/lib/StandardModal/style/index.less +0 -50
  222. package/lib/StandardPanel/index.d.ts +0 -28
  223. package/lib/StandardPanel/index.js +0 -155
  224. package/lib/StandardPanel/style/index.less +0 -135
  225. package/lib/StandardTable/index.d.ts +0 -22
  226. package/lib/StandardTable/index.js +0 -143
  227. package/lib/StandardTable/style/index.d.ts +0 -1
  228. package/lib/StandardTable/style/index.js +0 -3
  229. package/lib/StandardTable/style/index.less +0 -206
  230. package/lib/components/IconNode/index.d.ts +0 -16
  231. package/lib/components/IconNode/index.js +0 -39
  232. package/lib/components/index.d.ts +0 -2
  233. package/lib/components/index.js +0 -15
  234. package/lib/data/func.code.js +0 -119
  235. package/lib/data/general.config.js +0 -179
  236. package/lib/data/index.js +0 -23
  237. package/lib/index.d.ts +0 -24
  238. package/lib/index.js +0 -236
  239. package/lib/styles/index.less +0 -0
  240. package/lib/theme/spec-variable.less +0 -48
  241. package/lib/utils/ValueFormat.js +0 -58
  242. package/lib/utils/filterPermission.js +0 -127
  243. package/lib/utils/getParentNodes.js +0 -226
  244. package/lib/utils/index.js +0 -35
@@ -1,173 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
-
9
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
11
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
- import React, { useEffect, useRef, useState } from 'react';
14
- import classNames from 'classnames';
15
- import DragBar from './DragBar';
16
-
17
- var DragContent = function DragContent(props) {
18
- var children = props.children,
19
- className = props.className,
20
- direction = props.direction,
21
- _props$moveMaxWidth = props.moveMaxWidth,
22
- moveMaxWidth = _props$moveMaxWidth === void 0 ? 0 : _props$moveMaxWidth,
23
- _props$moveMaxHeight = props.moveMaxHeight,
24
- moveMaxHeight = _props$moveMaxHeight === void 0 ? 0 : _props$moveMaxHeight,
25
- style = props.style,
26
- dragMouseDown = props.dragMouseDown,
27
- dragMouseMove = props.dragMouseMove,
28
- dragMouseUp = props.dragMouseUp;
29
- var divRef = useRef();
30
-
31
- var _useState = useState(0),
32
- _useState2 = _slicedToArray(_useState, 2),
33
- targetWidth = _useState2[0],
34
- setTargetWidth = _useState2[1];
35
-
36
- var _useState3 = useState(0),
37
- _useState4 = _slicedToArray(_useState3, 2),
38
- targetHeight = _useState4[0],
39
- setTargetHeight = _useState4[1];
40
-
41
- useEffect(function () {
42
- setTargetWidth(divRef.current.offsetWidth);
43
- setTargetHeight(divRef.current.offsetHeight);
44
- }, []);
45
-
46
- var onmousedown = function onmousedown(e, direction) {
47
- var parent = divRef.current;
48
- var nextNode = parent.nextSibling; //相邻兄弟节点
49
-
50
- var prevNode = parent.previousSibling; //相邻兄弟节点
51
- //获取前后兄弟节点宽高
52
-
53
- var prevWidth = 0,
54
- prevHeight = 0,
55
- nextWidth = 0,
56
- nextHeight = 0;
57
-
58
- if (prevNode) {
59
- prevWidth = prevNode.offsetWidth;
60
- prevHeight = prevNode.offsetHeight;
61
- }
62
-
63
- if (nextNode) {
64
- nextWidth = nextNode.offsetWidth;
65
- nextHeight = nextNode.offsetHeight;
66
- } //鼠标按下
67
-
68
-
69
- if (dragMouseDown) dragMouseDown(e, direction);
70
- var initWidth = parent.offsetWidth;
71
- var initHeight = parent.offsetHeight; // let initLeft = parent.offsetLeft;
72
- // let initTop = parent.offsetTop;
73
-
74
- var startX = e.clientX;
75
- var startY = e.clientY;
76
-
77
- document.onmousemove = function (e) {
78
- var currX = e.clientX;
79
- var currY = e.clientY;
80
- var disY = currY - startY;
81
- var disX = currX - startX;
82
- var hasT = /top/.test(direction);
83
- var hasB = /bottom/.test(direction);
84
- var hasL = /left/.test(direction);
85
- var hasR = /right/.test(direction);
86
-
87
- if (hasL || hasR) {
88
- var newWidth = initWidth + (hasL ? -disX : hasR ? disX : 0);
89
- var width = newWidth > 0 ? newWidth : 0; //获取兄弟节点可变动的宽度
90
-
91
- var changeWidth = hasL ? prevWidth : hasR ? nextWidth : 0;
92
- var maxWidth = changeWidth + initWidth;
93
-
94
- if (moveMaxWidth > 0 && maxWidth > moveMaxWidth) {
95
- maxWidth = moveMaxWidth;
96
- } //拉伸容器宽度不可小于初始宽度
97
- //判断拉伸宽度不可超过 拉伸容器宽度+变动的兄弟容器宽度或设置的最大宽度
98
-
99
-
100
- if (width > targetWidth && width <= maxWidth) {
101
- //左拉且有前兄弟节点即变化其宽度
102
- if (hasL && prevNode) {
103
- var newPrevWidth = prevWidth + (hasL ? disX : hasR ? -disX : 0);
104
- prevNode.style.width = newPrevWidth + 'px';
105
- } //右拉且有后兄弟节点即变化其宽度
106
-
107
-
108
- if (hasR && nextNode) {
109
- var newNextWidth = nextWidth + (hasL ? disX : hasR ? -disX : 0);
110
- nextNode.style.width = newNextWidth + 'px';
111
- } //设置拉伸容器的宽度
112
-
113
-
114
- parent.style.width = width + "px";
115
- }
116
- }
117
-
118
- if (hasT || hasB) {
119
- var newHeight = initHeight + (hasT ? -disY : hasB ? disY : 0);
120
- var height = newHeight > 0 ? newHeight : 0; //获取兄弟节点需要变动的高度
121
-
122
- var changeHeight = hasT ? prevHeight : hasB ? nextHeight : 0;
123
- var maxHeight = changeHeight + initHeight;
124
-
125
- if (moveMaxHeight > 0 && maxHeight > moveMaxHeight) {
126
- maxHeight = moveMaxHeight;
127
- } //拉伸容器高度不可小于初始高度
128
- //判断拉伸高度不可超过 拉伸容器高度+变动的兄弟容器高度或设置的最大高度
129
-
130
-
131
- if (height > targetHeight && height <= maxHeight) {
132
- //上拉且有前兄弟节点即变化其高度
133
- if (hasT && prevNode) {
134
- var newPrevHeight = prevHeight + (hasT ? disY : hasB ? -disY : 0);
135
- prevNode.style.height = newPrevHeight + 'px';
136
- } //下拉且有后兄弟节点即变化其高度
137
-
138
-
139
- if (hasB && nextNode) {
140
- var newNextHeight = nextHeight + (hasT ? disY : hasB ? -disY : 0);
141
- nextNode.style.height = newNextHeight + 'px';
142
- } //设置拉伸容器的高度
143
-
144
-
145
- parent.style.height = height + "px";
146
- }
147
- } //鼠标按下
148
-
149
-
150
- if (dragMouseMove) dragMouseMove(e, direction);
151
- };
152
-
153
- document.onmouseup = function (e) {
154
- document.onmousemove = document.onmouseup = null; //鼠标按下
155
-
156
- if (dragMouseUp) dragMouseUp(e, direction);
157
- };
158
- };
159
-
160
- return /*#__PURE__*/React.createElement("div", {
161
- ref: divRef,
162
- className: classNames("spec-grid-dragContent", className),
163
- style: style
164
- }, children, direction && direction.map(function (item, idx) {
165
- return /*#__PURE__*/React.createElement(DragBar, {
166
- key: idx,
167
- direction: item,
168
- onMouseDown: onmousedown
169
- });
170
- }));
171
- };
172
-
173
- export default DragContent;
@@ -1,44 +0,0 @@
1
- @root-entry-name: default;
2
- @import (reference) '~antd/es/style/themes/index';
3
-
4
-
5
- .spec-grid-dragContent{
6
- position: relative;
7
- // padding: 5px;
8
-
9
- .spec-grid-dragbar-left-horizontal{
10
- height: 100%;
11
- width: 5px;
12
- position: absolute;
13
- left: 0;
14
- top: 0;
15
- cursor: col-resize;
16
-
17
- }
18
- .spec-grid-dragbar-right-horizontal{
19
- height: 100%;
20
- width: 5px;
21
- position: absolute;
22
- right: 0;
23
- top: 0;
24
- cursor: col-resize;
25
- }
26
- .spec-grid-dragbar-up-vertical{
27
- height: 5px;
28
- width: 100%;
29
- position: absolute;
30
- left: 0;
31
- top: 0;
32
- cursor: row-resize;
33
- }
34
- .spec-grid-dragbar-down-vertical{
35
- height: 5px;
36
- width: 100%;
37
- position: absolute;
38
- left: 0;
39
- bottom: 0;
40
- cursor: row-resize;
41
- }
42
- }
43
-
44
-
@@ -1,76 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
-
3
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
-
5
- import axios from 'axios';
6
- /**
7
- * 查询文件上传情况
8
- * @param {String} fileHash 文件内容Hash
9
- * @param {String} fileName 文件名
10
- * @param {Number} chunksLength 分片数量
11
- */
12
-
13
- export function queryFileInfo(_ref) {
14
- var fileHash = _ref.fileHash,
15
- fileName = _ref.fileName,
16
- size = _ref.size,
17
- sizeStr = _ref.sizeStr,
18
- chunksLength = _ref.chunksLength;
19
- console.log('queryFileInfo ==> 查询文件上传情况');
20
- return axios.get('/getFileInfo', {
21
- params: {
22
- fileHash: fileHash,
23
- fileName: fileName,
24
- size: size,
25
- sizeStr: sizeStr,
26
- chunksLength: chunksLength
27
- }
28
- }).then(function (_ref2) {
29
- var data = _ref2.data;
30
- return data;
31
- });
32
- }
33
- /**
34
- * 上传文件分片
35
- * @param {String} fileContentHash 文件的Hash
36
- * @param {Number} chunkIndex 分片序号
37
- * @param {Blob} chunk 文件分片
38
- */
39
-
40
- export function uploadChunk(fileContentHash, chunkIndex, chunk) {
41
- var formData = new FormData();
42
- formData.append('fileContentHash', fileContentHash);
43
- formData.append('chunkIndex', chunkIndex);
44
- formData.append('chunk', chunk);
45
- return axios.post('/uploadChunk', formData).then(function (_ref3) {
46
- var result = _ref3.data;
47
- return result;
48
- });
49
- }
50
- export function lockChunk(fileHash, chunkIndex) {
51
- return axios.post('/lockChunk', {
52
- fileHash: fileHash,
53
- chunkIndex: chunkIndex
54
- }).then( /*#__PURE__*/function () {
55
- var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref4) {
56
- var result;
57
- return regeneratorRuntime.wrap(function _callee$(_context) {
58
- while (1) {
59
- switch (_context.prev = _context.next) {
60
- case 0:
61
- result = _ref4.data;
62
- return _context.abrupt("return", result);
63
-
64
- case 2:
65
- case "end":
66
- return _context.stop();
67
- }
68
- }
69
- }, _callee);
70
- }));
71
-
72
- return function (_x) {
73
- return _ref5.apply(this, arguments);
74
- };
75
- }());
76
- }
@@ -1,391 +0,0 @@
1
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
2
-
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
-
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
6
-
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8
-
9
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
-
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
-
13
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
-
15
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
16
-
17
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
18
-
19
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
20
-
21
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
22
-
23
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
-
25
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
-
27
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
-
29
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
30
-
31
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
32
-
33
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
-
35
- /* eslint-disable no-unused-vars */
36
- import React, { useEffect, useState, useRef } from 'react';
37
- import PropTypes from 'prop-types';
38
- import { getComponentDisplayName, splitFileToChunks, calFileContentHash, bytesToSize, guid } from './lib';
39
- import { queryFileInfo } from './api';
40
- import UploadQueue from './upload-queue.class';
41
- import './style/style.less';
42
- /**
43
- * 初始化组件
44
- * @param {ReactComponent} component 本高阶组件
45
- * @param {ReactComponent} WrappedComponent 被包装的具体实现组件
46
- */
47
-
48
- function useComponentInit(component, WrappedComponent) {
49
- var intervalIDArr = [];
50
-
51
- var _useState = useState([]),
52
- _useState2 = _slicedToArray(_useState, 2),
53
- filesList = _useState2[0],
54
- setFilesList = _useState2[1]; // 定义管理上传的列表
55
-
56
- /* 定义上传队列,初始化就创建一个UploadQueue类实例 */
57
-
58
-
59
- var _useState3 = useState(new UploadQueue({
60
- /* 设立一个定时器,定时(根据hash)查询文件是否上传完成(因为后端需要把所有分片合并起来,因此需要一定的时间) */
61
- fileFinishCb: function fileFinishCb(fileHash) {
62
- /* 查询文件是否上传完成;是的话则更新状态,渲染上传结果 */
63
- console.log('调用=》fileFinishCb==》查询文件是否上传完成;是的话则更新状态,渲染上传结果');
64
-
65
- function checkIfFinish() {
66
- return _checkIfFinish.apply(this, arguments);
67
- }
68
- /*
69
- 第一次定时器会很快触发,这是针对小文件,争取尽快渲染上传结果
70
- 之后的定时器则是针对较大的文件,以较大的时间间隔来触发查询
71
- */
72
-
73
-
74
- function _checkIfFinish() {
75
- _checkIfFinish = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
76
- var remoteFileInfo;
77
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
78
- while (1) {
79
- switch (_context3.prev = _context3.next) {
80
- case 0:
81
- _context3.next = 2;
82
- return queryFileInfo({
83
- fileHash: fileHash
84
- });
85
-
86
- case 2:
87
- remoteFileInfo = _context3.sent;
88
- console.log('请求接口queryFileInfo=》 完成分片上传后,更新上传状态');
89
-
90
- if (!(remoteFileInfo.status === 'finish')) {
91
- _context3.next = 7;
92
- break;
93
- }
94
-
95
- updateFileInfo.call({
96
- filesList: filesList,
97
- setFilesList: setFilesList
98
- }, fileHash, {
99
- status: remoteFileInfo.status,
100
- url: remoteFileInfo.publicPath
101
- });
102
- return _context3.abrupt("return", true);
103
-
104
- case 7:
105
- console.log('更新上传状态==》remoteFileInfo', remoteFileInfo);
106
- return _context3.abrupt("return", false);
107
-
108
- case 9:
109
- case "end":
110
- return _context3.stop();
111
- }
112
- }
113
- }, _callee3);
114
- }));
115
- return _checkIfFinish.apply(this, arguments);
116
- }
117
-
118
- setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
119
- var intervalID;
120
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
121
- while (1) {
122
- switch (_context2.prev = _context2.next) {
123
- case 0:
124
- _context2.next = 2;
125
- return checkIfFinish();
126
-
127
- case 2:
128
- _context2.t0 = _context2.sent;
129
-
130
- if (!(_context2.t0 === false)) {
131
- _context2.next = 6;
132
- break;
133
- }
134
-
135
- intervalID = setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
136
- return regeneratorRuntime.wrap(function _callee$(_context) {
137
- while (1) {
138
- switch (_context.prev = _context.next) {
139
- case 0:
140
- _context.next = 2;
141
- return checkIfFinish();
142
-
143
- case 2:
144
- _context.t0 = _context.sent;
145
-
146
- if (!(_context.t0 === true)) {
147
- _context.next = 6;
148
- break;
149
- }
150
-
151
- clearInterval(intervalID);
152
- intervalIDArr.splice(intervalIDArr.indexOf(intervalIDArr), 1);
153
-
154
- case 6:
155
- case "end":
156
- return _context.stop();
157
- }
158
- }
159
- }, _callee);
160
- })), 5000);
161
- intervalIDArr.push(intervalID);
162
-
163
- case 6:
164
- case "end":
165
- return _context2.stop();
166
- }
167
- }
168
- }, _callee2);
169
- })), 500);
170
- }
171
- })),
172
- _useState4 = _slicedToArray(_useState3, 1),
173
- uploadQueue = _useState4[0];
174
-
175
- useEffect(function () {
176
- /* 定义displayName是为了在浏览器开发者工具里更好地显示高阶组件名称 */
177
- component.displayName = "withUploader(".concat(getComponentDisplayName(WrappedComponent), ")");
178
- component.defaultProps = {
179
- perChunkSize: 1024 * 512,
180
- errorCb: function errorCb() {},
181
- finishCb: function finishCb() {}
182
- };
183
- component.propTypes = {
184
- perChunkSize: PropTypes.number,
185
- errorCb: PropTypes.func,
186
- finishCb: PropTypes.func
187
- };
188
- }, [component, WrappedComponent]);
189
- /* 清理所有定时器 */
190
-
191
- useEffect(function () {
192
- return function () {
193
- intervalIDArr.forEach(function (intervalID) {
194
- return clearInterval(intervalID);
195
- });
196
- };
197
- }, [intervalIDArr]);
198
- return {
199
- filesList: filesList,
200
- setFilesList: setFilesList,
201
- uploadQueue: uploadQueue
202
- };
203
- }
204
- /**
205
- * 根据用户选择上传的文件来初始化文件信息,并添加到state里
206
- * @param {File} file 用户选择上传的文件
207
- */
208
-
209
-
210
- function initFilesListState(file) {
211
- var fileInfo = {
212
- hash: guid(),
213
- // 用uuid来假装hash
214
- fileName: file.name,
215
- status: 'init',
216
- publicPath: '',
217
- size: file.size,
218
- sizeStr: bytesToSize(file.size) // 转换当前字节数
219
-
220
- };
221
- this.setFilesList([].concat(_toConsumableArray(this.filesList), [fileInfo]));
222
- console.log('根据用户选择上传的文件来初始化文件信息', fileInfo);
223
- return fileInfo;
224
- }
225
- /**
226
- * 根据文件hash查询当前组件管理的文件列表里是否已存在目标文件
227
- * @param {String} hash 文件hash
228
- */
229
-
230
-
231
- function checkDuplicateByHash(hash) {
232
- return this.filesList.some(function (file) {
233
- return file.hash === hash;
234
- });
235
- }
236
- /**
237
- * 根据文件hash,从当前组件管理的文件列表中删除目标文件信息
238
- * @param {Object} currentFileInfo 用户当前选择上传的文件的信息
239
- */
240
-
241
-
242
- function removeFile(currentFileInfo) {
243
- this.setFilesList(function (filesList) {
244
- return filesList.filter(function (file) {
245
- return currentFileInfo.hash !== file.hash;
246
- });
247
- });
248
- }
249
- /**
250
- * 更新state中的文件信息
251
- * @param {String} hash 文件hash
252
- * @param {Object} newFileAttrs 需要更新的文件信息字段;不需要更新的字段就不需要传进来
253
- */
254
-
255
-
256
- function updateFileInfo(hash, newFileAttrs) {
257
- console.log('updateFileInfo=》 更新state中的文件信息');
258
- this.setFilesList(function (filesList) {
259
- return filesList.map(function (file) {
260
- return file.hash === hash ? _objectSpread(_objectSpread({}, file), newFileAttrs) : file;
261
- });
262
- });
263
- console.log('最新的this.filesList=》', this.filesList);
264
- }
265
- /**
266
- * <input type="file">的change事件回调函数
267
- * @param {Number} perChunkSize 每个分片的大小
268
- * @param {Function} errorCb 错误异常的处理函数
269
- */
270
-
271
-
272
- function returnFileInputChangeCb(_ref3) {
273
- var _this = this;
274
-
275
- var perChunkSize = _ref3.perChunkSize,
276
- errorCb = _ref3.errorCb;
277
- console.log('调用input更新事件');
278
- return /*#__PURE__*/function () {
279
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(event) {
280
- var file, currentFileInfo, chunksArr, fileContentHash, remoteFileInfo;
281
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
282
- while (1) {
283
- switch (_context4.prev = _context4.next) {
284
- case 0:
285
- file = event.target.files[0];
286
- currentFileInfo = initFilesListState.call(_this, file);
287
- console.log('当前已选择需要上传的文件', file);
288
- chunksArr = splitFileToChunks(file, perChunkSize); // 文件分片
289
-
290
- _context4.next = 6;
291
- return calFileContentHash(chunksArr);
292
-
293
- case 6:
294
- fileContentHash = _context4.sent;
295
-
296
- // 计算文件内容的hash
297
- if (checkDuplicateByHash.call(_this, fileContentHash)) {
298
- removeFile.call(_this, currentFileInfo);
299
- errorCb({
300
- errorCode: 1,
301
- message: 'duplicate file found by hash'
302
- });
303
- }
304
-
305
- console.log('当前文件内的fileContentHash', fileContentHash);
306
- updateFileInfo.call(_this, currentFileInfo.hash, {
307
- hash: fileContentHash
308
- });
309
- /* 查询该文件上传情况 */
310
-
311
- _context4.next = 12;
312
- return queryFileInfo(_objectSpread(_objectSpread({}, currentFileInfo), {}, {
313
- fileHash: fileContentHash,
314
- chunksLength: chunksArr.length
315
- }));
316
-
317
- case 12:
318
- remoteFileInfo = _context4.sent;
319
- console.log('请求接口queryFileInfo=》初始化,返回当前文件上传情况 =>remoteFileInfo:', remoteFileInfo);
320
- updateFileInfo.call(_this, fileContentHash, {
321
- status: remoteFileInfo.status,
322
- url: remoteFileInfo.publicPath,
323
- chunks: remoteFileInfo.chunks,
324
- chunksLength: remoteFileInfo.chunksLength
325
- });
326
- /* 秒传 */
327
-
328
- if (!(remoteFileInfo.status === 'finish')) {
329
- _context4.next = 17;
330
- break;
331
- }
332
-
333
- return _context4.abrupt("return");
334
-
335
- case 17:
336
- _this.uploadQueue.addChunksToQueue(remoteFileInfo, chunksArr); // 建立上传队列
337
-
338
-
339
- _this.uploadQueue.run(); // 触发上传
340
-
341
-
342
- case 19:
343
- case "end":
344
- return _context4.stop();
345
- }
346
- }
347
- }, _callee4);
348
- }));
349
-
350
- return function (_x) {
351
- return _ref4.apply(this, arguments);
352
- };
353
- }();
354
- }
355
- /**
356
- * 高阶组件的主函数
357
- * @param {ReactComponent} WrappedComponent 被封装的具体实现的组件
358
- */
359
-
360
-
361
- export default function withUploader(WrappedComponent) {
362
- return function UploaderHoc(props) {
363
- var perChunkSize = props.perChunkSize,
364
- errorCb = props.errorCb,
365
- restProps = _objectWithoutProperties(props, ["perChunkSize", "errorCb"]);
366
-
367
- var fileInputRef = useRef(null);
368
- var state = useComponentInit(UploaderHoc, WrappedComponent);
369
- /* 组装传给具体实现组件的props */
370
-
371
- var spreadProps = _objectSpread(_objectSpread({}, restProps), {}, {
372
- // 透传
373
- triggerFile: function triggerFile() {
374
- return fileInputRef.current.click();
375
- },
376
- filesList: state.filesList
377
- });
378
-
379
- return /*#__PURE__*/React.createElement("div", {
380
- className: "upload-hoc"
381
- }, /*#__PURE__*/React.createElement("input", {
382
- ref: fileInputRef,
383
- type: "file",
384
- className: "upload-hoc_file-input",
385
- onChange: returnFileInputChangeCb.call(state, {
386
- perChunkSize: perChunkSize,
387
- errorCb: errorCb
388
- })
389
- }), /*#__PURE__*/React.createElement(WrappedComponent, spreadProps));
390
- };
391
- }