fan-standard-comp 3.1.10 → 3.2.0

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 (170) hide show
  1. package/Readme.md +35 -0
  2. package/dist/fan-standard-comp.umd.js +15 -15
  3. package/es/ButtonGroup/ButtonList.js +0 -3
  4. package/es/ButtonGroup/ButtonMenu.js +0 -3
  5. package/es/ButtonGroup/PopConfirmTitle.js +5 -15
  6. package/es/ButtonGroup/index.js +212 -216
  7. package/es/ButtonGroup/style/index.less +1 -1
  8. package/es/DragContent/DragBar.js +2 -6
  9. package/es/DragContent/index.js +44 -75
  10. package/es/FormComp/ChunkUploader/api.js +6 -10
  11. package/es/FormComp/ChunkUploader/index.js +105 -171
  12. package/es/FormComp/ChunkUploader/lib.js +4 -17
  13. package/es/FormComp/ChunkUploader/upload-queue.class.js +10 -45
  14. package/es/FormComp/ChunkUploader/worker.js +0 -3
  15. package/es/FormComp/EditButton/index.js +24 -49
  16. package/es/FormComp/FieldComponent/ReUpload.js +18 -38
  17. package/es/FormComp/FieldComponent/RefactorTreeSelect.js +36 -74
  18. package/es/FormComp/FieldComponent/TitleNode.js +1 -3
  19. package/es/FormComp/FieldComponent/index.js +38 -74
  20. package/es/FormComp/FieldComponent/setReadonlyValues.js +34 -63
  21. package/es/FormComp/RenderItemGroup/index.js +46 -74
  22. package/es/FormComp/Uploader/index.js +36 -77
  23. package/es/FormComp/Uploader/util.js +0 -6
  24. package/es/FormComp/VarTemplate/index.js +58 -96
  25. package/es/NavLeafScroll/index.js +172 -154
  26. package/es/NavLeafScroll/style/index.less +33 -1
  27. package/es/RefactorTree/index.js +36 -53
  28. package/es/RefactorTree/indexTreeNode.js +35 -68
  29. package/es/RefactorTree/util.js +9 -43
  30. package/es/SpecIcon/fonts/iconfont.js +7 -12
  31. package/es/SpecIcon/index.js +16 -25
  32. package/es/SplitterLayout/Pane.js +2 -5
  33. package/es/SplitterLayout/index.js +20 -70
  34. package/es/StandardContent/SplitterLayout/Pane.js +6 -10
  35. package/es/StandardContent/SplitterLayout/index.js +12 -63
  36. package/es/StandardContent/SubfieldContent.js +12 -14
  37. package/es/StandardContent/WrapperContent.js +8 -10
  38. package/es/StandardDragModal/ChangeStandardModal.d.ts +44 -0
  39. package/es/StandardDragModal/ChangeStandardModal.js +493 -0
  40. package/es/StandardDragModal/DraggableModal.d.ts +7 -0
  41. package/es/StandardDragModal/DraggableModal.js +31 -0
  42. package/es/StandardDragModal/DraggableModalContext.d.ts +9 -0
  43. package/es/StandardDragModal/DraggableModalContext.js +5 -0
  44. package/es/StandardDragModal/DraggableModalInner.d.ts +16 -0
  45. package/es/StandardDragModal/DraggableModalInner.js +114 -0
  46. package/es/StandardDragModal/DraggableModalProvider.d.ts +4 -0
  47. package/es/StandardDragModal/DraggableModalProvider.js +40 -0
  48. package/es/StandardDragModal/Modal.d.ts +11 -0
  49. package/es/StandardDragModal/Modal.js +24 -0
  50. package/es/StandardDragModal/ResizeHandle.d.ts +2 -0
  51. package/es/StandardDragModal/ResizeHandle.js +8 -0
  52. package/es/StandardDragModal/clamp.d.ts +1 -0
  53. package/es/StandardDragModal/clamp.js +3 -0
  54. package/es/StandardDragModal/draggableModalReducer.d.ts +66 -0
  55. package/es/StandardDragModal/draggableModalReducer.js +157 -0
  56. package/es/StandardDragModal/getWindowSize.d.ts +4 -0
  57. package/es/StandardDragModal/getWindowSize.js +6 -0
  58. package/es/StandardDragModal/index.d.ts +3 -11
  59. package/es/StandardDragModal/index.js +3 -30
  60. package/es/StandardDragModal/index.less +65 -0
  61. package/es/StandardDragModal/useDrag.d.ts +5 -0
  62. package/es/StandardDragModal/useDrag.js +66 -0
  63. package/es/StandardDragModal/usePrevious.d.ts +1 -0
  64. package/es/StandardDragModal/usePrevious.js +8 -0
  65. package/es/StandardDragModal/useResize.d.ts +7 -0
  66. package/es/StandardDragModal/useResize.js +74 -0
  67. package/es/StandardFilter/index.js +30 -70
  68. package/es/StandardForm/ActionList.js +5 -7
  69. package/es/StandardForm/StepForm.js +50 -71
  70. package/es/StandardForm/TabForm.js +58 -70
  71. package/es/StandardForm/index.js +37 -56
  72. package/es/StandardModal/UpdateFormRef.js +1 -4
  73. package/es/StandardModal/index.d.ts +0 -1
  74. package/es/StandardModal/index.js +113 -157
  75. package/es/StandardPanel/index.js +19 -35
  76. package/es/StandardTable/index.js +18 -29
  77. package/es/components/IconNode/index.js +0 -4
  78. package/es/index.d.ts +1 -0
  79. package/es/index.js +15 -14
  80. package/es/utils/ValueFormat.js +0 -9
  81. package/es/utils/dictSelectUtil.js +153 -0
  82. package/es/utils/filterPermission.js +16 -34
  83. package/es/utils/getParentNodes.js +24 -47
  84. package/es/utils/index.js +2 -1
  85. package/lib/ButtonGroup/ButtonList.js +1 -13
  86. package/lib/ButtonGroup/ButtonMenu.js +1 -8
  87. package/lib/ButtonGroup/PopConfirmTitle.js +3 -16
  88. package/lib/ButtonGroup/index.js +215 -239
  89. package/lib/ButtonGroup/style/index.less +1 -1
  90. package/lib/DragContent/DragBar.js +2 -10
  91. package/lib/DragContent/index.js +47 -85
  92. package/lib/FormComp/ChunkUploader/api.js +6 -15
  93. package/lib/FormComp/ChunkUploader/index.js +107 -185
  94. package/lib/FormComp/ChunkUploader/lib.js +8 -27
  95. package/lib/FormComp/ChunkUploader/upload-queue.class.js +10 -46
  96. package/lib/FormComp/ChunkUploader/worker.js +1 -5
  97. package/lib/FormComp/EditButton/index.js +26 -60
  98. package/lib/FormComp/FieldComponent/ReUpload.js +21 -50
  99. package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +38 -89
  100. package/lib/FormComp/FieldComponent/TitleNode.js +1 -5
  101. package/lib/FormComp/FieldComponent/index.js +38 -110
  102. package/lib/FormComp/FieldComponent/setReadonlyValues.js +37 -79
  103. package/lib/FormComp/RenderItemGroup/index.js +46 -87
  104. package/lib/FormComp/Uploader/index.js +38 -95
  105. package/lib/FormComp/Uploader/util.js +1 -9
  106. package/lib/FormComp/VarTemplate/index.js +62 -106
  107. package/lib/FormComp/index.js +0 -2
  108. package/lib/NavLeafScroll/index.js +174 -165
  109. package/lib/NavLeafScroll/style/index.less +33 -1
  110. package/lib/RefactorTree/index.js +36 -67
  111. package/lib/RefactorTree/indexTreeNode.js +37 -83
  112. package/lib/RefactorTree/util.js +11 -45
  113. package/lib/SpecIcon/fonts/iconfont.js +7 -12
  114. package/lib/SpecIcon/index.js +16 -30
  115. package/lib/SplitterLayout/Pane.js +0 -7
  116. package/lib/SplitterLayout/index.js +18 -72
  117. package/lib/StandardContent/SplitterLayout/Pane.js +6 -14
  118. package/lib/StandardContent/SplitterLayout/index.js +12 -68
  119. package/lib/StandardContent/SubfieldContent.js +12 -21
  120. package/lib/StandardContent/WrapperContent.js +8 -16
  121. package/lib/StandardDragModal/ChangeStandardModal.d.ts +44 -0
  122. package/lib/StandardDragModal/ChangeStandardModal.js +502 -0
  123. package/lib/StandardDragModal/DraggableModal.d.ts +7 -0
  124. package/lib/StandardDragModal/DraggableModal.js +40 -0
  125. package/lib/StandardDragModal/DraggableModalContext.d.ts +9 -0
  126. package/lib/StandardDragModal/DraggableModalContext.js +15 -0
  127. package/lib/StandardDragModal/DraggableModalInner.d.ts +16 -0
  128. package/lib/StandardDragModal/DraggableModalInner.js +124 -0
  129. package/lib/StandardDragModal/DraggableModalProvider.d.ts +4 -0
  130. package/lib/StandardDragModal/DraggableModalProvider.js +48 -0
  131. package/lib/StandardDragModal/Modal.d.ts +11 -0
  132. package/lib/StandardDragModal/Modal.js +32 -0
  133. package/lib/StandardDragModal/ResizeHandle.d.ts +2 -0
  134. package/lib/StandardDragModal/ResizeHandle.js +18 -0
  135. package/lib/StandardDragModal/clamp.d.ts +1 -0
  136. package/lib/StandardDragModal/clamp.js +10 -0
  137. package/lib/StandardDragModal/draggableModalReducer.d.ts +66 -0
  138. package/lib/StandardDragModal/draggableModalReducer.js +167 -0
  139. package/lib/StandardDragModal/getWindowSize.d.ts +4 -0
  140. package/lib/StandardDragModal/getWindowSize.js +13 -0
  141. package/lib/StandardDragModal/index.d.ts +3 -11
  142. package/lib/StandardDragModal/index.js +33 -38
  143. package/lib/StandardDragModal/index.less +65 -0
  144. package/lib/StandardDragModal/useDrag.d.ts +5 -0
  145. package/lib/StandardDragModal/useDrag.js +73 -0
  146. package/lib/StandardDragModal/usePrevious.d.ts +1 -0
  147. package/lib/StandardDragModal/usePrevious.js +15 -0
  148. package/lib/StandardDragModal/useResize.d.ts +7 -0
  149. package/lib/StandardDragModal/useResize.js +81 -0
  150. package/lib/StandardFilter/index.js +28 -78
  151. package/lib/StandardForm/ActionList.js +5 -12
  152. package/lib/StandardForm/StepForm.js +52 -90
  153. package/lib/StandardForm/TabForm.js +61 -88
  154. package/lib/StandardForm/index.js +40 -75
  155. package/lib/StandardModal/UpdateFormRef.js +4 -12
  156. package/lib/StandardModal/index.d.ts +0 -1
  157. package/lib/StandardModal/index.js +115 -182
  158. package/lib/StandardPanel/index.js +22 -48
  159. package/lib/StandardTable/index.js +18 -38
  160. package/lib/components/IconNode/index.js +0 -7
  161. package/lib/components/index.js +0 -2
  162. package/lib/data/index.js +4 -7
  163. package/lib/index.d.ts +1 -0
  164. package/lib/index.js +50 -68
  165. package/lib/utils/ValueFormat.js +0 -10
  166. package/lib/utils/dictSelectUtil.js +161 -0
  167. package/lib/utils/filterPermission.js +15 -39
  168. package/lib/utils/getParentNodes.js +25 -52
  169. package/lib/utils/index.js +24 -9
  170. package/package.json +5 -4
@@ -4,76 +4,59 @@ import "antd/es/button/style";
4
4
  import _Button from "antd/es/button";
5
5
  import "antd/es/message/style";
6
6
  import _message from "antd/es/message";
7
-
8
7
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
-
10
8
  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."); }
11
-
12
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
13
-
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
10
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
-
16
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
-
18
12
  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."); }
19
-
20
13
  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); }
21
-
22
14
  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; }
23
-
24
- 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; }
25
-
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
26
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
-
28
17
  import { __awaiter } from "tslib";
29
18
  import React, { useMemo, useState, useCallback, useEffect } from 'react';
30
19
  import { PlusOutlined } from '@ant-design/icons';
31
- import { getAccept, getBase64 } from "./util"; // import RcUpload from 'rc-upload';
32
-
20
+ import { getAccept, getBase64 } from "./util";
21
+ // import RcUpload from 'rc-upload';
33
22
  import StandardModal from "../../StandardModal";
34
23
  var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
35
24
  var accept = props.accept,
36
- extraExt = props.extraExt,
37
- fileType = props.fileType,
38
- className = props.className,
39
- isOnly = props.isOnly,
40
- children = props.children,
41
- onChange = props.onChange,
42
- value = props.value,
43
- _props$size = props.size,
44
- size = _props$size === void 0 ? 2 * 1024 * 1024 : _props$size,
45
- _props$modalSize = props.modalSize,
46
- modalSize = _props$modalSize === void 0 ? 'md' : _props$modalSize,
47
- _props$modalConfig = props.modalConfig,
48
- modalConfig = _props$modalConfig === void 0 ? {} : _props$modalConfig,
49
- onPreview = props.onPreview,
50
- beforeUpload = props.beforeUpload,
51
- limit = props.limit; // 图片预览数据
52
-
25
+ extraExt = props.extraExt,
26
+ fileType = props.fileType,
27
+ className = props.className,
28
+ isOnly = props.isOnly,
29
+ children = props.children,
30
+ onChange = props.onChange,
31
+ value = props.value,
32
+ _props$size = props.size,
33
+ size = _props$size === void 0 ? 2 * 1024 * 1024 : _props$size,
34
+ _props$modalSize = props.modalSize,
35
+ modalSize = _props$modalSize === void 0 ? 'md' : _props$modalSize,
36
+ _props$modalConfig = props.modalConfig,
37
+ modalConfig = _props$modalConfig === void 0 ? {} : _props$modalConfig,
38
+ onPreview = props.onPreview,
39
+ beforeUpload = props.beforeUpload,
40
+ limit = props.limit; // 图片预览数据
53
41
  var _useState = useState({
54
- visible: false,
55
- url: ''
56
- }),
57
- _useState2 = _slicedToArray(_useState, 2),
58
- showConfig = _useState2[0],
59
- setShowConfig = _useState2[1]; // 用于展示的缩略图
60
-
61
-
42
+ visible: false,
43
+ url: ''
44
+ }),
45
+ _useState2 = _slicedToArray(_useState, 2),
46
+ showConfig = _useState2[0],
47
+ setShowConfig = _useState2[1]; // 用于展示的缩略图
62
48
  var _useState3 = useState([]),
63
- _useState4 = _slicedToArray(_useState3, 2),
64
- fileList = _useState4[0],
65
- setFileList = _useState4[1];
66
-
49
+ _useState4 = _slicedToArray(_useState3, 2),
50
+ fileList = _useState4[0],
51
+ setFileList = _useState4[1];
67
52
  useEffect(function () {
68
53
  if (!value) {
69
54
  setFileList([]);
70
55
  return;
71
56
  }
72
-
73
57
  var S4 = function S4() {
74
58
  return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
75
59
  };
76
-
77
60
  if (Object.prototype.toString.call(value) === '[object Array]') {
78
61
  setFileList(value.map(function (file, index) {
79
62
  file.uid = file.uid || "".concat(S4(), "-").concat(S4());
@@ -83,7 +66,6 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
83
66
  }));
84
67
  return;
85
68
  }
86
-
87
69
  if (Object.prototype.toString.call(value) === '[object Object]') {
88
70
  setFileList([Object.assign({
89
71
  uid: "".concat(S4(), "-").concat(S4()),
@@ -92,7 +74,6 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
92
74
  }, value)]);
93
75
  return;
94
76
  }
95
-
96
77
  if (Object.prototype.toString.call(value) === '[object String]') {
97
78
  setFileList([{
98
79
  uid: "".concat(S4(), "-").concat(S4()),
@@ -105,18 +86,15 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
105
86
  }, [value]);
106
87
  var splitAccept = useMemo(function () {
107
88
  var res = getAccept(fileType);
108
-
109
89
  if (extraExt) {
110
90
  res = res + ',' + extraExt;
111
91
  }
112
-
113
92
  if (accept) {
114
93
  res = res + ',' + accept;
115
94
  }
116
-
117
95
  return res;
118
- }, [fileType, extraExt]); // 点击文件链接或预览图标时的回调
119
-
96
+ }, [fileType, extraExt]);
97
+ // 点击文件链接或预览图标时的回调
120
98
  var handlePreview = useCallback(function (file) {
121
99
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
122
100
  var res;
@@ -128,23 +106,18 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
128
106
  _context.next = 5;
129
107
  break;
130
108
  }
131
-
132
109
  _context.next = 3;
133
110
  return getBase64(file.originFileObj);
134
-
135
111
  case 3:
136
112
  res = _context.sent;
137
-
138
113
  if (res && res.status === 'success') {
139
114
  file.preview = res.url;
140
115
  }
141
-
142
116
  case 5:
143
117
  setShowConfig({
144
118
  visible: true,
145
119
  url: file.url || file.preview
146
120
  });
147
-
148
121
  case 6:
149
122
  case "end":
150
123
  return _context.stop();
@@ -152,17 +125,14 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
152
125
  }
153
126
  }, _callee);
154
127
  }));
155
- }, [setShowConfig]); // 检查文件是否规范
156
-
128
+ }, [setShowConfig]);
129
+ // 检查文件是否规范
157
130
  var handleCheck = useCallback(function (file) {
158
131
  var isLtSize = file.size < size;
159
-
160
132
  if (!isLtSize) {
161
133
  _message.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7".concat(Math.round(size / 1024 / 1024 * 100) / 100, "MB!"));
162
-
163
134
  return false;
164
135
  }
165
-
166
136
  return true;
167
137
  }, [fileType, size]);
168
138
  var handleChange = useCallback(function (res) {
@@ -176,27 +146,22 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
176
146
  _context2.next = 4;
177
147
  break;
178
148
  }
179
-
180
149
  setFileList(res.fileList);
181
150
  onChange && onChange(isOnly ? res.fileList[0] && res.fileList[0].originFileObj : res.fileList);
182
151
  return _context2.abrupt("return");
183
-
184
152
  case 4:
185
153
  isOk = handleCheck(res.file);
186
-
187
154
  if (isOk) {
188
155
  list = res.fileList.map(function (file) {
189
156
  if (!file.url) {
190
157
  file.url = file.thumbUrl;
191
158
  }
192
-
193
159
  return file;
194
160
  });
195
161
  result = _toConsumableArray(list);
196
162
  setFileList(list);
197
163
  onChange && onChange(isOnly ? result[0] && result[0].originFileObj : result);
198
164
  }
199
-
200
165
  case 6:
201
166
  case "end":
202
167
  return _context2.stop();
@@ -204,12 +169,12 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
204
169
  }
205
170
  }, _callee2);
206
171
  }));
207
- }, [isOnly, handleCheck]); // 渲染预览窗口
208
-
172
+ }, [isOnly, handleCheck]);
173
+ // 渲染预览窗口
209
174
  var renderPreviewComponent = useMemo(function () {
210
175
  if (fileType === 'image' || fileType === 'svg') {
211
176
  var visible = showConfig.visible,
212
- url = showConfig.url;
177
+ url = showConfig.url;
213
178
  return /*#__PURE__*/React.createElement(StandardModal, Object.assign({
214
179
  visible: visible,
215
180
  hideFooter: true,
@@ -233,7 +198,6 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
233
198
  alt: ""
234
199
  })));
235
200
  }
236
-
237
201
  return null;
238
202
  }, [fileType, showConfig]);
239
203
  var renderChildrenComponent = useMemo(function () {
@@ -245,20 +209,16 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
245
209
  className: "ant-upload-text"
246
210
  }, "\u70B9\u51FB\u9009\u62E9"));
247
211
  }
248
-
249
212
  return /*#__PURE__*/React.createElement(_Button, {
250
213
  className: 'spec-uploader-button'
251
214
  }, /*#__PURE__*/React.createElement(PlusOutlined, null), "\u70B9\u51FB\u9009\u62E9");
252
215
  };
253
-
254
216
  if (children) {
255
217
  return /*#__PURE__*/React.createElement(React.Fragment, null, " ", children, " ");
256
218
  }
257
-
258
219
  if (isOnly && fileList.length === 1 || limit && fileList.length === limit) {
259
220
  return null;
260
221
  }
261
-
262
222
  return /*#__PURE__*/React.createElement(React.Fragment, null, renderButton());
263
223
  }, [fileType, isOnly, children, fileList, limit]);
264
224
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Upload, Object.assign({}, props, {
@@ -274,5 +234,4 @@ var Uploader = /*#__PURE__*/React.forwardRef(function (props, ref) {
274
234
  onChange: handleChange
275
235
  }), renderChildrenComponent), renderPreviewComponent);
276
236
  }); // as IUploader
277
-
278
237
  export default Uploader;
@@ -2,14 +2,12 @@ export function getBase64(file) {
2
2
  return new Promise(function (resolve) {
3
3
  var reader = new FileReader();
4
4
  reader.readAsDataURL(file);
5
-
6
5
  reader.onload = function () {
7
6
  return resolve({
8
7
  status: 'success',
9
8
  url: reader.result
10
9
  });
11
10
  };
12
-
13
11
  reader.onerror = function (error) {
14
12
  return resolve({
15
13
  status: 'error',
@@ -22,16 +20,12 @@ export function getAccept(fileType) {
22
20
  switch (fileType) {
23
21
  case 'image':
24
22
  return '.jpg,.png';
25
-
26
23
  case 'svg':
27
24
  return '.svg';
28
-
29
25
  case 'office':
30
26
  return '.doc,.docx,.pdf,.xls,.xlsx';
31
-
32
27
  case 'zip':
33
28
  return '.rar,.zip';
34
-
35
29
  default:
36
30
  return '.rar,.zip,.doc,.docx,.pdf,.jpg,.png';
37
31
  }
@@ -1,48 +1,32 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
2
  import "antd/es/tag/style";
4
3
  import _Tag from "antd/es/tag";
5
4
  import "antd/es/input/style";
6
5
  import _Input from "antd/es/input";
7
-
8
- 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; }
9
-
10
- 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; }
11
-
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
8
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
-
14
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
15
-
16
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
17
-
18
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
19
-
20
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
-
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
12
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
13
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
23
-
24
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
25
-
14
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
26
15
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
27
-
28
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
29
-
30
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
-
32
- 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; }
33
-
16
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
17
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
20
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
34
21
  /**
35
22
  * Created by S.C. on 2019/11/16.
36
23
  */
37
24
  import React, { Component } from 'react';
38
25
  var TextArea = _Input.TextArea;
39
26
  var isIE = !!document.all;
40
-
41
27
  var VarTemplate = /*#__PURE__*/function (_Component) {
42
28
  _inherits(VarTemplate, _Component);
43
-
44
29
  var _super = _createSuper(VarTemplate);
45
-
46
30
  _createClass(VarTemplate, null, [{
47
31
  key: "getDerivedStateFromProps",
48
32
  value: function getDerivedStateFromProps(nextProps) {
@@ -51,48 +35,37 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
51
35
  if ('value' in nextProps) {
52
36
  return _objectSpread({}, nextProps.value || {});
53
37
  }
54
-
55
38
  return null;
56
39
  }
57
40
  }]);
58
-
59
41
  function VarTemplate(props) {
60
42
  var _this;
61
-
62
43
  _classCallCheck(this, VarTemplate);
63
-
64
44
  _this = _super.call(this, props);
65
-
66
45
  _defineProperty(_assertThisInitialized(_this), "handleBlur", function (e) {
67
46
  _this.getCurrentCursor();
68
47
  });
69
-
70
- _defineProperty(_assertThisInitialized(_this), "handleFocus", function (e) {// console.log('获取焦点')
48
+ _defineProperty(_assertThisInitialized(_this), "handleFocus", function (e) {
49
+ // console.log('获取焦点')
71
50
  // this.$emit('focus', event)
72
51
  });
73
-
74
52
  _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (e) {
75
53
  var onChange = _this.props.onChange;
76
-
77
54
  _this.getCurrentCursor();
78
-
79
55
  _this.setState({
80
56
  currentContent: e.target.value,
81
57
  startNum: e.target.value.length,
82
58
  endNum: e.target.value.length,
83
59
  wordCount: e.target.value.length
84
60
  });
85
-
86
61
  if (onChange) onChange(e.target.value);
87
62
  });
88
-
89
63
  _defineProperty(_assertThisInitialized(_this), "setTagWords", function (key) {
90
64
  var onChange = _this.props.onChange;
91
65
  var _this$state = _this.state,
92
- currentContent = _this$state.currentContent,
93
- startNum = _this$state.startNum,
94
- endNum = _this$state.endNum;
95
-
66
+ currentContent = _this$state.currentContent,
67
+ startNum = _this$state.startNum,
68
+ endNum = _this$state.endNum;
96
69
  _this.setState({
97
70
  currentContent: _this.insertContent(currentContent, key, startNum, endNum),
98
71
  startNum: startNum + key.length,
@@ -101,65 +74,51 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
101
74
  // 光标起始位置累加
102
75
  wordCount: _this.insertContent(currentContent, key, startNum, endNum).length
103
76
  });
104
-
105
77
  if (onChange) onChange(_this.insertContent(currentContent, key, startNum, endNum));
106
78
  setTimeout(function () {
107
79
  _this.moveToCursor(); // 重新定位光标
108
-
109
80
  });
110
81
  });
111
-
112
82
  _defineProperty(_assertThisInitialized(_this), "insertContent", function (str, insertStr, start, end) {
113
83
  if (start !== end) {
114
84
  var _prevStr = str.substring(0, start);
115
-
116
85
  var _nextStr = str.substring(end, str.length);
117
-
118
86
  return _prevStr + insertStr + _nextStr;
119
87
  }
120
-
121
88
  var prevStr = str.substring(0, start);
122
89
  var nextStr = str.substring(start, str.length);
123
90
  return prevStr + insertStr + nextStr;
124
91
  });
125
-
126
92
  _defineProperty(_assertThisInitialized(_this), "getCurrentCursor", function () {
127
93
  var start = 0;
128
94
  var end = 0;
129
-
130
95
  var oTextarea = _this.content.querySelector('textarea'); // 获取textarea标签
131
-
132
-
133
96
  if (isIE) {
134
97
  // selection 当前激活选中区,即高亮文本块,和/或文当中用户可执行某些操作的其它元素。
135
98
  // createRange 从当前文本选中区中创建 TextRange 对象,
136
99
  // 或从控件选中区中创建 controlRange 集合。
137
- var sTextRange = document.selection.createRange(); // 判断选中的是不是textarea对象
138
-
100
+ var sTextRange = document.selection.createRange();
101
+ // 判断选中的是不是textarea对象
139
102
  if (sTextRange.parentElement() === oTextarea) {
140
103
  // 创建一个TextRange对象
141
- var oTextRange = document.body.createTextRange(); // 移动文本范围以便范围的开始和结束位置能够完全包含给定元素的文本。
142
-
143
- oTextRange.moveToElementText(oTextarea); // 这里我们比较oTextRange和sTextRange的开头,的到选中区域的开头位置
144
-
104
+ var oTextRange = document.body.createTextRange();
105
+ // 移动文本范围以便范围的开始和结束位置能够完全包含给定元素的文本。
106
+ oTextRange.moveToElementText(oTextarea);
107
+ // 这里我们比较oTextRange和sTextRange的开头,的到选中区域的开头位置
145
108
  for (start = 0; oTextRange.compareEndPoints('StartToStart', sTextRange) < 0; start++) {
146
109
  oTextRange.moveStart('character', 1);
147
- } // 需要计算一下\n的数目(按字符移动的方式不计\n,所以这里加上)
148
-
149
-
110
+ }
111
+ // 需要计算一下\n的数目(按字符移动的方式不计\n,所以这里加上)
150
112
  for (var i = 0; i <= start; i++) {
151
113
  if (oTextarea.value.charAt(i) === '\n') {
152
114
  start++;
153
115
  }
154
- } // 再计算一次结束的位置
155
-
156
-
116
+ }
117
+ // 再计算一次结束的位置
157
118
  oTextRange.moveToElementText(oTextarea);
158
-
159
119
  for (end = 0; oTextRange.compareEndPoints('StartToEnd', sTextRange) < 0; end++) {
160
120
  oTextRange.moveStart('character', 1);
161
121
  }
162
-
163
122
  for (var j = 0; j <= end; j++) {
164
123
  if (oTextarea.value.charAt(j) === '\n') {
165
124
  end++;
@@ -170,27 +129,21 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
170
129
  start = oTextarea.selectionStart;
171
130
  end = oTextarea.selectionEnd;
172
131
  }
173
-
174
132
  _this.setState({
175
133
  startNum: start,
176
134
  endNum: end
177
135
  });
178
136
  });
179
-
180
137
  _defineProperty(_assertThisInitialized(_this), "moveToCursor", function () {
181
138
  var _this$state2 = _this.state,
182
- startNum = _this$state2.startNum,
183
- endNum = _this$state2.endNum;
184
-
139
+ startNum = _this$state2.startNum,
140
+ endNum = _this$state2.endNum;
185
141
  var oTextarea = _this.content.querySelector('textarea');
186
-
187
142
  var start = startNum;
188
143
  var end = endNum;
189
-
190
144
  if (isNaN(start) || isNaN(end)) {
191
145
  alert('位置输入错误');
192
146
  }
193
-
194
147
  if (isIE) {
195
148
  var oTextRange = oTextarea.createTextRange();
196
149
  var LStart = startNum;
@@ -198,26 +151,21 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
198
151
  var _start = 0;
199
152
  var _end = 0;
200
153
  var value = oTextarea.value;
201
-
202
154
  for (var i = 0; i < value.length && i < LStart; i++) {
203
155
  var c = value.charAt(i);
204
-
205
156
  if (c !== '\n') {
206
157
  _start++;
207
158
  }
208
159
  }
209
-
210
160
  for (var j = value.length - 1; j >= LEnd && j >= 0; j--) {
211
161
  var _c = value.charAt(j);
212
-
213
162
  if (_c !== '\n') {
214
163
  _end++;
215
164
  }
216
165
  }
217
-
218
166
  oTextRange.moveStart('character', _start);
219
- oTextRange.moveEnd('character', -_end); // oTextRange.collapse(true);
220
-
167
+ oTextRange.moveEnd('character', -_end);
168
+ // oTextRange.collapse(true);
221
169
  oTextRange.select();
222
170
  oTextarea.focus();
223
171
  } else {
@@ -226,9 +174,7 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
226
174
  oTextarea.selectionEnd = endNum;
227
175
  }
228
176
  });
229
-
230
177
  var _value = props.value || '';
231
-
232
178
  _this.state = {
233
179
  currentContent: _value,
234
180
  startNum: _value.length,
@@ -236,25 +182,43 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
236
182
  endNum: _value.length,
237
183
  // 光标结束位置(当选中文本时)
238
184
  wordCount: _value.length // 输入框内的字符数总和(包含占位符所需要的长度)
239
-
240
185
  };
186
+
241
187
  _this.content = /*#__PURE__*/React.createRef();
242
188
  return _this;
243
189
  }
244
190
 
191
+ /**
192
+ * 指定位置插入标签占位符字符串,当光标有选中一段字符时,会将直接将其替换
193
+ * @param {str} 需要做插入的字符串
194
+ * @param {insertStr} 需要插入的字符串
195
+ * @param {start} 指定开始位置
196
+ * @param {end} 指定结束位置
197
+ * */
198
+
199
+ /**
200
+ * 获取当前(上一次)光标的位置
201
+ * @参考 http://blog.csdn.net/chadcao/article/details/6575927
202
+ * @TODO IE、火狐浏览器下未验证
203
+ */
204
+
205
+ /**
206
+ * 跳转到上一次光标的位置
207
+ * @参考 http://blog.csdn.net/chadcao/article/details/6575927
208
+ * @TODO IE、火狐浏览器下未验证
209
+ */
245
210
  _createClass(VarTemplate, [{
246
211
  key: "render",
247
212
  value: function render() {
248
213
  var _this2 = this;
249
-
250
214
  var _this$props = this.props,
251
- size = _this$props.size,
252
- style = _this$props.style,
253
- tags = _this$props.tags,
254
- disabled = _this$props.disabled;
215
+ size = _this$props.size,
216
+ style = _this$props.style,
217
+ tags = _this$props.tags,
218
+ disabled = _this$props.disabled;
255
219
  var _this$state3 = this.state,
256
- currentContent = _this$state3.currentContent,
257
- wordCount = _this$state3.wordCount;
220
+ currentContent = _this$state3.currentContent,
221
+ wordCount = _this$state3.wordCount;
258
222
  return /*#__PURE__*/React.createElement("div", {
259
223
  className: "vart-wrap",
260
224
  style: style,
@@ -286,8 +250,6 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
286
250
  })));
287
251
  }
288
252
  }]);
289
-
290
253
  return VarTemplate;
291
254
  }(Component);
292
-
293
255
  export default VarTemplate;