@nokecy/qc-ui-business 0.0.0-stage → 2.0.0-beta.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 (197) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/adapters/abpPagedApiAdapter.d.ts +8 -0
  3. package/dist/cjs/adapters/abpPagedApiAdapter.js +35 -0
  4. package/dist/cjs/adapters/index.d.ts +2 -0
  5. package/dist/cjs/adapters/index.js +12 -0
  6. package/dist/cjs/attachment/AttachmentFileButton.d.ts +4 -0
  7. package/dist/cjs/attachment/AttachmentFileButton.js +96 -0
  8. package/dist/cjs/attachment/AttachmentImageUpload.d.ts +16 -0
  9. package/dist/cjs/attachment/AttachmentImageUpload.js +213 -0
  10. package/dist/cjs/attachment/AttachmentPanel.d.ts +8 -0
  11. package/dist/cjs/attachment/AttachmentPanel.js +71 -0
  12. package/dist/cjs/attachment/AttachmentVideoUpload.d.ts +13 -0
  13. package/dist/cjs/attachment/AttachmentVideoUpload.js +98 -0
  14. package/dist/cjs/attachment/ChunkedDragger.d.ts +14 -0
  15. package/dist/cjs/attachment/ChunkedDragger.js +168 -0
  16. package/dist/cjs/attachment/attachmentList.d.ts +95 -0
  17. package/dist/cjs/attachment/attachmentList.js +219 -0
  18. package/dist/cjs/attachment/chunkUpload.d.ts +26 -0
  19. package/dist/cjs/attachment/chunkUpload.js +276 -0
  20. package/dist/cjs/attachment/env.d.ts +41 -0
  21. package/dist/cjs/attachment/env.js +41 -0
  22. package/dist/cjs/attachment/index.d.ts +20 -0
  23. package/dist/cjs/attachment/index.js +92 -0
  24. package/dist/cjs/dialogSelect/index.d.ts +7 -0
  25. package/dist/cjs/dialogSelect/index.js +24 -0
  26. package/dist/cjs/entitySelect/index.d.ts +59 -0
  27. package/dist/cjs/entitySelect/index.js +188 -0
  28. package/dist/cjs/exportButton/exportAction.d.ts +74 -0
  29. package/dist/cjs/exportButton/exportAction.js +199 -0
  30. package/dist/cjs/exportButton/index.d.ts +39 -0
  31. package/dist/cjs/exportButton/index.js +289 -0
  32. package/dist/cjs/generatedListPage/ConfigurableToolbar.d.ts +37 -0
  33. package/dist/cjs/generatedListPage/ConfigurableToolbar.js +189 -0
  34. package/dist/cjs/generatedListPage/GeneratedListPage.d.ts +8 -0
  35. package/dist/cjs/generatedListPage/GeneratedListPage.js +574 -0
  36. package/dist/cjs/generatedListPage/OptionsColumn.d.ts +9 -0
  37. package/dist/cjs/generatedListPage/OptionsColumn.js +161 -0
  38. package/dist/cjs/generatedListPage/PerformanceMonitor.d.ts +55 -0
  39. package/dist/cjs/generatedListPage/PerformanceMonitor.js +288 -0
  40. package/dist/cjs/generatedListPage/RequestManager.d.ts +97 -0
  41. package/dist/cjs/generatedListPage/RequestManager.js +402 -0
  42. package/dist/cjs/generatedListPage/_utils/AccessWrapper.d.ts +16 -0
  43. package/dist/cjs/generatedListPage/_utils/AccessWrapper.js +29 -0
  44. package/dist/cjs/generatedListPage/_utils/defaultHandlers.d.ts +22 -0
  45. package/dist/cjs/generatedListPage/_utils/defaultHandlers.js +228 -0
  46. package/dist/cjs/generatedListPage/_utils/toAbpPagedRequest.d.ts +15 -0
  47. package/dist/cjs/generatedListPage/_utils/toAbpPagedRequest.js +26 -0
  48. package/dist/cjs/generatedListPage/index.d.ts +20 -0
  49. package/dist/cjs/generatedListPage/index.js +92 -0
  50. package/dist/cjs/generatedListPage/types.d.ts +249 -0
  51. package/dist/cjs/generatedListPage/types.js +5 -0
  52. package/dist/cjs/generatedListPage/usePermissionCheck.d.ts +66 -0
  53. package/dist/cjs/generatedListPage/usePermissionCheck.js +150 -0
  54. package/dist/cjs/generatedListPage/useRequestManager.d.ts +35 -0
  55. package/dist/cjs/generatedListPage/useRequestManager.js +121 -0
  56. package/dist/cjs/importModal/index.d.ts +35 -0
  57. package/dist/cjs/importModal/index.js +156 -0
  58. package/dist/cjs/index.d.ts +16 -0
  59. package/dist/cjs/index.js +158 -0
  60. package/dist/cjs/standardFormDialog/FormValidation.d.ts +150 -0
  61. package/dist/cjs/standardFormDialog/FormValidation.js +229 -0
  62. package/dist/cjs/standardFormDialog/PortalManager.d.ts +94 -0
  63. package/dist/cjs/standardFormDialog/PortalManager.js +251 -0
  64. package/dist/cjs/standardFormDialog/StandardFormDialog.d.ts +10 -0
  65. package/dist/cjs/standardFormDialog/StandardFormDialog.js +558 -0
  66. package/dist/cjs/standardFormDialog/index.d.ts +7 -0
  67. package/dist/cjs/standardFormDialog/index.js +83 -0
  68. package/dist/cjs/standardFormDialog/types.d.ts +116 -0
  69. package/dist/cjs/standardFormDialog/types.js +5 -0
  70. package/dist/cjs/standardFormDialog/useStandardFormSchema.d.ts +68 -0
  71. package/dist/cjs/standardFormDialog/useStandardFormSchema.js +197 -0
  72. package/dist/cjs/standardFormDialog/withStandardForm.d.ts +193 -0
  73. package/dist/cjs/standardFormDialog/withStandardForm.js +414 -0
  74. package/dist/cjs/standardList/AgGridPlus.d.ts +6 -0
  75. package/dist/cjs/standardList/AgGridPlus.js +25 -0
  76. package/dist/cjs/standardList/StandardAgGridPlus.d.ts +65 -0
  77. package/dist/cjs/standardList/StandardAgGridPlus.js +691 -0
  78. package/dist/cjs/standardList/dateFormat.d.ts +16 -0
  79. package/dist/cjs/standardList/dateFormat.js +56 -0
  80. package/dist/cjs/standardList/dateQueryPrecision.d.ts +6 -0
  81. package/dist/cjs/standardList/dateQueryPrecision.js +30 -0
  82. package/dist/cjs/standardList/emptyState.d.ts +43 -0
  83. package/dist/cjs/standardList/emptyState.js +113 -0
  84. package/dist/cjs/standardList/enumColumns.d.ts +31 -0
  85. package/dist/cjs/standardList/enumColumns.js +87 -0
  86. package/dist/cjs/standardList/gridColumnDefs.d.ts +33 -0
  87. package/dist/cjs/standardList/gridColumnDefs.js +61 -0
  88. package/dist/cjs/standardList/groupedHeaders.d.ts +28 -0
  89. package/dist/cjs/standardList/groupedHeaders.js +84 -0
  90. package/dist/cjs/standardList/groupedHeaders.less +29 -0
  91. package/dist/cjs/standardList/index.d.ts +23 -0
  92. package/dist/cjs/standardList/index.js +203 -0
  93. package/dist/cjs/standardList/listDateDisplay.d.ts +9 -0
  94. package/dist/cjs/standardList/listDateDisplay.js +64 -0
  95. package/dist/cjs/standardList/listDefaultSort.d.ts +41 -0
  96. package/dist/cjs/standardList/listDefaultSort.js +151 -0
  97. package/dist/cjs/standardList/listRefresh.d.ts +25 -0
  98. package/dist/cjs/standardList/listRefresh.js +53 -0
  99. package/dist/esm/adapters/abpPagedApiAdapter.d.ts +8 -0
  100. package/dist/esm/adapters/abpPagedApiAdapter.js +29 -0
  101. package/dist/esm/adapters/index.d.ts +2 -0
  102. package/dist/esm/adapters/index.js +1 -0
  103. package/dist/esm/attachment/AttachmentFileButton.d.ts +4 -0
  104. package/dist/esm/attachment/AttachmentFileButton.js +88 -0
  105. package/dist/esm/attachment/AttachmentImageUpload.d.ts +16 -0
  106. package/dist/esm/attachment/AttachmentImageUpload.js +207 -0
  107. package/dist/esm/attachment/AttachmentPanel.d.ts +8 -0
  108. package/dist/esm/attachment/AttachmentPanel.js +61 -0
  109. package/dist/esm/attachment/AttachmentVideoUpload.d.ts +13 -0
  110. package/dist/esm/attachment/AttachmentVideoUpload.js +93 -0
  111. package/dist/esm/attachment/ChunkedDragger.d.ts +14 -0
  112. package/dist/esm/attachment/ChunkedDragger.js +163 -0
  113. package/dist/esm/attachment/attachmentList.d.ts +95 -0
  114. package/dist/esm/attachment/attachmentList.js +214 -0
  115. package/dist/esm/attachment/chunkUpload.d.ts +26 -0
  116. package/dist/esm/attachment/chunkUpload.js +272 -0
  117. package/dist/esm/attachment/env.d.ts +41 -0
  118. package/dist/esm/attachment/env.js +35 -0
  119. package/dist/esm/attachment/index.d.ts +20 -0
  120. package/dist/esm/attachment/index.js +14 -0
  121. package/dist/esm/dialogSelect/index.d.ts +7 -0
  122. package/dist/esm/dialogSelect/index.js +19 -0
  123. package/dist/esm/entitySelect/index.d.ts +59 -0
  124. package/dist/esm/entitySelect/index.js +180 -0
  125. package/dist/esm/exportButton/exportAction.d.ts +74 -0
  126. package/dist/esm/exportButton/exportAction.js +193 -0
  127. package/dist/esm/exportButton/index.d.ts +39 -0
  128. package/dist/esm/exportButton/index.js +255 -0
  129. package/dist/esm/generatedListPage/ConfigurableToolbar.d.ts +37 -0
  130. package/dist/esm/generatedListPage/ConfigurableToolbar.js +183 -0
  131. package/dist/esm/generatedListPage/GeneratedListPage.d.ts +8 -0
  132. package/dist/esm/generatedListPage/GeneratedListPage.js +565 -0
  133. package/dist/esm/generatedListPage/OptionsColumn.d.ts +9 -0
  134. package/dist/esm/generatedListPage/OptionsColumn.js +155 -0
  135. package/dist/esm/generatedListPage/PerformanceMonitor.d.ts +55 -0
  136. package/dist/esm/generatedListPage/PerformanceMonitor.js +282 -0
  137. package/dist/esm/generatedListPage/RequestManager.d.ts +97 -0
  138. package/dist/esm/generatedListPage/RequestManager.js +396 -0
  139. package/dist/esm/generatedListPage/_utils/AccessWrapper.d.ts +16 -0
  140. package/dist/esm/generatedListPage/_utils/AccessWrapper.js +23 -0
  141. package/dist/esm/generatedListPage/_utils/defaultHandlers.d.ts +22 -0
  142. package/dist/esm/generatedListPage/_utils/defaultHandlers.js +223 -0
  143. package/dist/esm/generatedListPage/_utils/toAbpPagedRequest.d.ts +15 -0
  144. package/dist/esm/generatedListPage/_utils/toAbpPagedRequest.js +20 -0
  145. package/dist/esm/generatedListPage/index.d.ts +20 -0
  146. package/dist/esm/generatedListPage/index.js +26 -0
  147. package/dist/esm/generatedListPage/types.d.ts +249 -0
  148. package/dist/esm/generatedListPage/types.js +1 -0
  149. package/dist/esm/generatedListPage/usePermissionCheck.d.ts +66 -0
  150. package/dist/esm/generatedListPage/usePermissionCheck.js +145 -0
  151. package/dist/esm/generatedListPage/useRequestManager.d.ts +35 -0
  152. package/dist/esm/generatedListPage/useRequestManager.js +116 -0
  153. package/dist/esm/importModal/index.d.ts +35 -0
  154. package/dist/esm/importModal/index.js +151 -0
  155. package/dist/esm/index.d.ts +16 -0
  156. package/dist/esm/index.js +10 -0
  157. package/dist/esm/standardFormDialog/FormValidation.d.ts +150 -0
  158. package/dist/esm/standardFormDialog/FormValidation.js +223 -0
  159. package/dist/esm/standardFormDialog/PortalManager.d.ts +94 -0
  160. package/dist/esm/standardFormDialog/PortalManager.js +245 -0
  161. package/dist/esm/standardFormDialog/StandardFormDialog.d.ts +10 -0
  162. package/dist/esm/standardFormDialog/StandardFormDialog.js +552 -0
  163. package/dist/esm/standardFormDialog/index.d.ts +7 -0
  164. package/dist/esm/standardFormDialog/index.js +6 -0
  165. package/dist/esm/standardFormDialog/types.d.ts +116 -0
  166. package/dist/esm/standardFormDialog/types.js +1 -0
  167. package/dist/esm/standardFormDialog/useStandardFormSchema.d.ts +68 -0
  168. package/dist/esm/standardFormDialog/useStandardFormSchema.js +191 -0
  169. package/dist/esm/standardFormDialog/withStandardForm.d.ts +193 -0
  170. package/dist/esm/standardFormDialog/withStandardForm.js +409 -0
  171. package/dist/esm/standardList/AgGridPlus.d.ts +6 -0
  172. package/dist/esm/standardList/AgGridPlus.js +18 -0
  173. package/dist/esm/standardList/StandardAgGridPlus.d.ts +65 -0
  174. package/dist/esm/standardList/StandardAgGridPlus.js +687 -0
  175. package/dist/esm/standardList/dateFormat.d.ts +16 -0
  176. package/dist/esm/standardList/dateFormat.js +50 -0
  177. package/dist/esm/standardList/dateQueryPrecision.d.ts +6 -0
  178. package/dist/esm/standardList/dateQueryPrecision.js +25 -0
  179. package/dist/esm/standardList/emptyState.d.ts +43 -0
  180. package/dist/esm/standardList/emptyState.js +108 -0
  181. package/dist/esm/standardList/enumColumns.d.ts +31 -0
  182. package/dist/esm/standardList/enumColumns.js +82 -0
  183. package/dist/esm/standardList/gridColumnDefs.d.ts +33 -0
  184. package/dist/esm/standardList/gridColumnDefs.js +55 -0
  185. package/dist/esm/standardList/groupedHeaders.d.ts +28 -0
  186. package/dist/esm/standardList/groupedHeaders.js +78 -0
  187. package/dist/esm/standardList/groupedHeaders.less +29 -0
  188. package/dist/esm/standardList/index.d.ts +23 -0
  189. package/dist/esm/standardList/index.js +17 -0
  190. package/dist/esm/standardList/listDateDisplay.d.ts +9 -0
  191. package/dist/esm/standardList/listDateDisplay.js +58 -0
  192. package/dist/esm/standardList/listDefaultSort.d.ts +41 -0
  193. package/dist/esm/standardList/listDefaultSort.js +145 -0
  194. package/dist/esm/standardList/listRefresh.d.ts +25 -0
  195. package/dist/esm/standardList/listRefresh.js +47 -0
  196. package/package.json +67 -4
  197. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) QC_UI contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ import type { PagedApiAdapter } from '@nokecy/qc-ui-components/adapters/pagedApiAdapter';
2
+ /**
3
+ * ABP 默认分页适配器。
4
+ * 请求映射为 { Filter, Sorting, SkipCount, MaxResultCount }(有 maxResultCount 时才带分页字段);
5
+ * 响应读取 { items, totalCount }。字节级复刻库内现有 ABP 行为。
6
+ * @author nokecy
7
+ */
8
+ export declare const abpPagedApiAdapter: PagedApiAdapter;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.abpPagedApiAdapter = void 0;
7
+ /**
8
+ * ABP 默认分页适配器。
9
+ * 请求映射为 { Filter, Sorting, SkipCount, MaxResultCount }(有 maxResultCount 时才带分页字段);
10
+ * 响应读取 { items, totalCount }。字节级复刻库内现有 ABP 行为。
11
+ * @author nokecy
12
+ */
13
+ var abpPagedApiAdapter = exports.abpPagedApiAdapter = {
14
+ toRequest: function toRequest(_ref) {
15
+ var skipCount = _ref.skipCount,
16
+ maxResultCount = _ref.maxResultCount,
17
+ filter = _ref.filter,
18
+ sorter = _ref.sorter;
19
+ var request = {
20
+ Filter: filter,
21
+ Sorting: sorter
22
+ };
23
+ if (maxResultCount != null) {
24
+ request.SkipCount = skipCount !== null && skipCount !== void 0 ? skipCount : 0;
25
+ request.MaxResultCount = maxResultCount;
26
+ }
27
+ return request;
28
+ },
29
+ getItems: function getItems(response) {
30
+ return (response === null || response === void 0 ? void 0 : response.items) || [];
31
+ },
32
+ getTotal: function getTotal(response) {
33
+ return (response === null || response === void 0 ? void 0 : response.totalCount) || 0;
34
+ }
35
+ };
@@ -0,0 +1,2 @@
1
+ export type { GenericPagedQuery, PagedApiAdapter } from '@nokecy/qc-ui-components/adapters/index';
2
+ export { abpPagedApiAdapter } from './abpPagedApiAdapter';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "abpPagedApiAdapter", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _abpPagedApiAdapter.abpPagedApiAdapter;
10
+ }
11
+ });
12
+ var _abpPagedApiAdapter = require("./abpPagedApiAdapter");
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { type AttachmentListProps } from './attachmentList';
3
+ declare const AttachmentFileButton: (props: AttachmentListProps) => React.JSX.Element;
4
+ export default AttachmentFileButton;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _icons = require("@ant-design/icons");
9
+ var _antd = require("antd");
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _AgGridPlus = _interopRequireDefault(require("../standardList/AgGridPlus"));
12
+ var _attachmentList = require("./attachmentList");
13
+ var _ChunkedDragger = _interopRequireDefault(require("./ChunkedDragger"));
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
+ 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."); }
20
+ 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
+ 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; }
22
+ 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; } }
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /**
24
+ * 附件按钮:点击弹出「文件列表」窗口,窗口内是拖拽上传区和已上传文件列表。
25
+ *
26
+ * @author nokecy
27
+ */
28
+ var AttachmentFileButton = function AttachmentFileButton(props) {
29
+ var ref = props.ref;
30
+ var env = props.env,
31
+ gridComponent = props.gridComponent,
32
+ disabled = props.disabled;
33
+ var Grid = gridComponent !== null && gridComponent !== void 0 ? gridComponent : _AgGridPlus.default;
34
+ var tableRef = (0, _react.useRef)(undefined);
35
+ var _useState = (0, _react.useState)(false),
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ open = _useState2[0],
38
+ setOpen = _useState2[1];
39
+ var _useAttachmentFiles = (0, _attachmentList.useAttachmentFiles)(props),
40
+ state = _useAttachmentFiles.state,
41
+ onFileChange = _useAttachmentFiles.onFileChange,
42
+ chongfuVerify = _useAttachmentFiles.chongfuVerify,
43
+ columnDefs = _useAttachmentFiles.columnDefs;
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
45
+ ref: ref,
46
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
47
+ type: "primary",
48
+ onClick: function onClick() {
49
+ return setOpen(true);
50
+ },
51
+ children: state && state.length > 0 ? '已上传文件' : '上传'
52
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Modal, {
53
+ title: "\u6587\u4EF6\u5217\u8868",
54
+ open: open,
55
+ width: 1160,
56
+ onOk: function onOk() {
57
+ return setOpen(false);
58
+ },
59
+ onCancel: function onCancel() {
60
+ return setOpen(false);
61
+ },
62
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChunkedDragger.default, {
63
+ env: env,
64
+ fileList: state,
65
+ disabled: disabled,
66
+ onChange: onFileChange,
67
+ showUploadList: false,
68
+ multiple: true,
69
+ chongfuVerify: chongfuVerify,
70
+ children: disabled || state && state.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
71
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Grid, {
72
+ pagination: false,
73
+ style: {
74
+ minHeight: 130,
75
+ overflowY: 'auto',
76
+ textAlign: 'left',
77
+ height: state ? state.length * 40 : undefined
78
+ },
79
+ hideTool: true,
80
+ search: false,
81
+ gridRef: tableRef,
82
+ dataSource: state || [],
83
+ columnDefs: columnDefs
84
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
85
+ className: "ant-upload-drag-icon",
86
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CloudUploadOutlined, {})
87
+ })]
88
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
89
+ className: "ant-upload-drag-icon",
90
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.InboxOutlined, {})
91
+ })
92
+ })
93
+ })]
94
+ });
95
+ };
96
+ var _default = exports.default = AttachmentFileButton;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { type AttachmentEnv } from './env';
3
+ export interface AttachmentImageUploadProps {
4
+ /** 宿主环境(用于拼图片地址) */
5
+ env: AttachmentEnv;
6
+ /** 上传一批图片,返回已入库的文件信息(含 blobName、fileName) */
7
+ uploadImages: (files: File[]) => Promise<any[] | undefined>;
8
+ /** 允许的图片数量,大于 1 时值是对象数组,否则是单个 blobName */
9
+ quantity?: number;
10
+ readOnly?: boolean;
11
+ value?: any;
12
+ defaultValue?: any;
13
+ onChange?: (value: any) => void;
14
+ }
15
+ declare const _default: React.ForwardRefExoticComponent<AttachmentImageUploadProps & React.RefAttributes<HTMLDivElement>>;
16
+ export default _default;
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _icons = require("@ant-design/icons");
9
+ var _ahooks = require("ahooks");
10
+ var _antd = require("antd");
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _env = require("./env");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
17
+ 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); } }
18
+ 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); }); }; }
19
+ 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; }
20
+ 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; }
21
+ 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; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
23
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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
+ 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); }
27
+ 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; }
28
+ 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; } }
29
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /**
30
+ * 图片附件:照片墙形式的上传与预览。
31
+ * 上传调用由宿主通过 `uploadImages` 注入(返回每个文件的 blobName 与 fileName)。
32
+ *
33
+ * @author nokecy
34
+ */
35
+ var getBase64 = function getBase64(file) {
36
+ return new Promise(function (resolve, reject) {
37
+ var reader = new FileReader();
38
+ reader.readAsDataURL(file);
39
+ reader.onload = function () {
40
+ return resolve(reader.result);
41
+ };
42
+ reader.onerror = function (error) {
43
+ return reject(error);
44
+ };
45
+ });
46
+ };
47
+ var AttachmentImageUpload = function AttachmentImageUpload(props, ref) {
48
+ var env = props.env,
49
+ uploadImages = props.uploadImages,
50
+ quantity = props.quantity,
51
+ readOnly = props.readOnly;
52
+ var quantityVisible = !!quantity && quantity > 1;
53
+ var _useState = (0, _react.useState)(false),
54
+ _useState2 = _slicedToArray(_useState, 2),
55
+ previewOpen = _useState2[0],
56
+ setPreviewOpen = _useState2[1];
57
+ var _useState3 = (0, _react.useState)(''),
58
+ _useState4 = _slicedToArray(_useState3, 2),
59
+ previewImage = _useState4[0],
60
+ setPreviewImage = _useState4[1];
61
+ var _useControllableValue = (0, _ahooks.useControllableValue)(props, {
62
+ defaultValue: null
63
+ }),
64
+ _useControllableValue2 = _slicedToArray(_useControllableValue, 2),
65
+ state = _useControllableValue2[0],
66
+ setState = _useControllableValue2[1];
67
+ var _useState5 = (0, _react.useState)([]),
68
+ _useState6 = _slicedToArray(_useState5, 2),
69
+ fileList = _useState6[0],
70
+ setFileList = _useState6[1];
71
+ var _useState7 = (0, _react.useState)(false),
72
+ _useState8 = _slicedToArray(_useState7, 2),
73
+ action = _useState8[0],
74
+ setAction = _useState8[1];
75
+ (0, _react.useEffect)(function () {
76
+ if (action) return;
77
+ if (state) {
78
+ var arr = [];
79
+ if (state.length > 0) {
80
+ state.forEach(function (i) {
81
+ arr.push(_objectSpread(_objectSpread({}, i), {}, {
82
+ name: i.blobName,
83
+ url: (0, _env.getBlobDownloadUrl)(env, i.blobName)
84
+ }));
85
+ });
86
+ }
87
+ setFileList(arr);
88
+ }
89
+ }, [state]);
90
+ var handlePreview = /*#__PURE__*/function () {
91
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
92
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
93
+ while (1) switch (_context.prev = _context.next) {
94
+ case 0:
95
+ if (!(!file.url && !file.preview)) {
96
+ _context.next = 4;
97
+ break;
98
+ }
99
+ _context.next = 3;
100
+ return getBase64(file.originFileObj);
101
+ case 3:
102
+ file.preview = _context.sent;
103
+ case 4:
104
+ setPreviewImage(file.url || file.preview);
105
+ setPreviewOpen(true);
106
+ case 6:
107
+ case "end":
108
+ return _context.stop();
109
+ }
110
+ }, _callee);
111
+ }));
112
+ return function handlePreview(_x) {
113
+ return _ref.apply(this, arguments);
114
+ };
115
+ }();
116
+ var handleChange = function handleChange(_ref2) {
117
+ var newFileList = _ref2.fileList;
118
+ if (newFileList.length > 0) {
119
+ setAction(true);
120
+ // 同名文件只保留一份
121
+ var uniqueFilesSet = new Set();
122
+ var uniqueFileList = newFileList.filter(function (item) {
123
+ if (!uniqueFilesSet.has(item.name)) {
124
+ uniqueFilesSet.add(item.name);
125
+ return true;
126
+ }
127
+ return false;
128
+ });
129
+ var _files = uniqueFileList.map(function (item) {
130
+ return item.originFileObj;
131
+ });
132
+ uploadImages(_files).then(function (res) {
133
+ if (res && res.length > 0) {
134
+ var _res$;
135
+ var stateCopy = [];
136
+ uniqueFileList.forEach(function (item) {
137
+ res.forEach(function (item2) {
138
+ if (item.name === item2.fileName) stateCopy.push(_objectSpread(_objectSpread({}, item), item2));
139
+ });
140
+ });
141
+ setFileList(uniqueFileList);
142
+ setState(quantityVisible ? stateCopy : (_res$ = res[0]) === null || _res$ === void 0 ? void 0 : _res$.blobName);
143
+ }
144
+ }).catch(function () {
145
+ setFileList(uniqueFileList);
146
+ setState(undefined);
147
+ });
148
+ } else {
149
+ setFileList(newFileList);
150
+ setState(undefined);
151
+ }
152
+ };
153
+ var uploadButton = /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
154
+ style: {
155
+ border: 0,
156
+ background: 'none'
157
+ },
158
+ type: "button",
159
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.PlusOutlined, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
160
+ style: {
161
+ marginTop: 8
162
+ },
163
+ children: "\u4E0A\u4F20"
164
+ })]
165
+ });
166
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
167
+ ref: ref,
168
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Upload, {
169
+ action: "",
170
+ listType: "picture-card",
171
+ fileList: fileList,
172
+ onPreview: handlePreview,
173
+ onChange: handleChange,
174
+ onRemove: function onRemove(file) {
175
+ if (readOnly) return false;
176
+ if (fileList && fileList.length > 0) setFileList(fileList.filter(function (item) {
177
+ return item.id !== file.id;
178
+ }));
179
+ if (state && state.length > 0) setState(state.filter(function (item) {
180
+ return item.id !== file.id;
181
+ }));
182
+ },
183
+ beforeUpload: function beforeUpload(file) {
184
+ // 同名文件拦截;本组件自己上传,这里始终阻止 antd 的默认上传
185
+ if (fileList.some(function (item) {
186
+ return item.name === file.name;
187
+ })) {
188
+ _antd.message.error('文件名重复,请重新上传');
189
+ return false;
190
+ }
191
+ return false;
192
+ },
193
+ children: (fileList === null || fileList === void 0 ? void 0 : fileList.length) >= (quantityVisible ? quantity : 1) ? null : readOnly ? null : uploadButton
194
+ }), previewImage && /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Image, {
195
+ styles: {
196
+ root: {
197
+ display: 'none'
198
+ }
199
+ },
200
+ preview: {
201
+ open: previewOpen,
202
+ onOpenChange: function onOpenChange(open) {
203
+ return setPreviewOpen(open);
204
+ },
205
+ afterOpenChange: function afterOpenChange(visible) {
206
+ return !visible && setPreviewImage('');
207
+ }
208
+ },
209
+ src: previewImage
210
+ })]
211
+ });
212
+ };
213
+ var _default = exports.default = /*#__PURE__*/_react.default.forwardRef(AttachmentImageUpload);
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { type AttachmentListProps } from './attachmentList';
3
+ export interface AttachmentPanelProps extends AttachmentListProps {
4
+ /** 隐藏列表下方的上传图标 */
5
+ btnVisible?: boolean;
6
+ }
7
+ declare const AttachmentPanel: (props: AttachmentPanelProps) => React.JSX.Element;
8
+ export default AttachmentPanel;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _icons = require("@ant-design/icons");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _AgGridPlus = _interopRequireDefault(require("../standardList/AgGridPlus"));
11
+ var _attachmentList = require("./attachmentList");
12
+ var _ChunkedDragger = _interopRequireDefault(require("./ChunkedDragger"));
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ /**
18
+ * 附件面板:拖拽上传区 + 已上传文件列表(下载、移除、上传进度)。
19
+ *
20
+ * @author nokecy
21
+ */
22
+
23
+ var AttachmentPanel = function AttachmentPanel(props) {
24
+ var ref = props.ref;
25
+ var env = props.env,
26
+ gridComponent = props.gridComponent,
27
+ disabled = props.disabled,
28
+ btnVisible = props.btnVisible;
29
+ var Grid = gridComponent !== null && gridComponent !== void 0 ? gridComponent : _AgGridPlus.default;
30
+ var tableRef = (0, _react.useRef)(undefined);
31
+ var _useAttachmentFiles = (0, _attachmentList.useAttachmentFiles)(props),
32
+ state = _useAttachmentFiles.state,
33
+ onFileChange = _useAttachmentFiles.onFileChange,
34
+ chongfuVerify = _useAttachmentFiles.chongfuVerify,
35
+ columnDefs = _useAttachmentFiles.columnDefs;
36
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
37
+ ref: ref,
38
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChunkedDragger.default, {
39
+ env: env,
40
+ fileList: state,
41
+ disabled: disabled,
42
+ onChange: onFileChange,
43
+ showUploadList: false,
44
+ multiple: true,
45
+ chongfuVerify: chongfuVerify,
46
+ children: disabled || state && state.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
47
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Grid, {
48
+ pagination: false,
49
+ style: {
50
+ minHeight: 130,
51
+ overflowY: 'auto',
52
+ textAlign: 'left',
53
+ height: state ? state.length * 40 : undefined
54
+ },
55
+ hideTool: true,
56
+ search: false,
57
+ gridRef: tableRef,
58
+ dataSource: state || [],
59
+ columnDefs: columnDefs
60
+ }), !btnVisible ? /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
61
+ className: "ant-upload-drag-icon",
62
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CloudUploadOutlined, {})
63
+ }) : null]
64
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
65
+ className: "ant-upload-drag-icon",
66
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.InboxOutlined, {})
67
+ })
68
+ })
69
+ });
70
+ };
71
+ var _default = exports.default = AttachmentPanel;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { AttachmentEnv } from './env';
3
+ export interface AttachmentVideoUploadProps {
4
+ /** 宿主环境(传输层、地址前缀、接口路径) */
5
+ env: AttachmentEnv;
6
+ value?: any;
7
+ defaultValue?: any;
8
+ onChange?: (value: any) => void;
9
+ /** 上传后的回调,参数是最新列表 */
10
+ changeCallBack?: (list: any[]) => void;
11
+ }
12
+ declare const _default: React.ForwardRefExoticComponent<AttachmentVideoUploadProps & React.RefAttributes<HTMLSpanElement>>;
13
+ export default _default;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _icons = require("@ant-design/icons");
8
+ var _ahooks = require("ahooks");
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _ChunkedDragger = _interopRequireDefault(require("./ChunkedDragger"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+ 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."); }
15
+ 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); }
16
+ 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; }
17
+ 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; } }
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /**
19
+ * 视频附件:拖拽上传(单个)+ 已选文件名列表,走视频分块协议。
20
+ *
21
+ * @author nokecy
22
+ */
23
+ var AttachmentVideoUpload = function AttachmentVideoUpload(props, ref) {
24
+ var env = props.env,
25
+ changeCallBack = props.changeCallBack;
26
+ var _useControllableValue = (0, _ahooks.useControllableValue)(props),
27
+ _useControllableValue2 = _slicedToArray(_useControllableValue, 2),
28
+ state = _useControllableValue2[0],
29
+ setState = _useControllableValue2[1];
30
+ var onFileChange = function onFileChange(info) {
31
+ var list = info.fileList.map(function (a) {
32
+ var _a$response, _a$response2, _a$response3, _a$response4;
33
+ a.blobName = (_a$response = a.response) === null || _a$response === void 0 ? void 0 : _a$response.blobName;
34
+ a.filename = a.name;
35
+ a.size = (_a$response2 = a.response) === null || _a$response2 === void 0 ? void 0 : _a$response2.size;
36
+ a.thumbnailBlobName = (_a$response3 = a.response) === null || _a$response3 === void 0 ? void 0 : _a$response3.thumbnailBlobName;
37
+ a.thumbnailSize = (_a$response4 = a.response) === null || _a$response4 === void 0 ? void 0 : _a$response4.thumbnailSize;
38
+ a.contentType = a.type;
39
+ return a;
40
+ });
41
+ setState(list);
42
+ changeCallBack === null || changeCallBack === void 0 || changeCallBack(list);
43
+ };
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
45
+ ref: ref,
46
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChunkedDragger.default, {
47
+ env: env,
48
+ kind: "video",
49
+ fileList: state,
50
+ disabled: false,
51
+ onChange: onFileChange,
52
+ showUploadList: false,
53
+ multiple: true,
54
+ maxCount: 1,
55
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
56
+ className: "ant-upload-drag-icon",
57
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.InboxOutlined, {})
58
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
59
+ className: "ant-upload-text",
60
+ children: "\u628A\u6587\u4EF6\u62D6\u5165\u6216\u70B9\u51FB\u7A7A\u767D\u533A\u57DF\uFF0C\u5B8C\u6210\u4E0A\u4F20"
61
+ })]
62
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
63
+ style: {
64
+ marginTop: 12
65
+ },
66
+ children: state && state.map(function (item, index) {
67
+ var _item$uid;
68
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
69
+ style: {
70
+ display: 'flex',
71
+ alignItems: 'center',
72
+ marginBottom: 10
73
+ },
74
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
75
+ style: {
76
+ width: 560,
77
+ paddingLeft: 8,
78
+ paddingRight: 8,
79
+ backgroundColor: '#f0f0f0',
80
+ display: 'flex',
81
+ justifyContent: 'space-between',
82
+ alignItems: 'center'
83
+ },
84
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
85
+ children: item.name
86
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
87
+ onClick: function onClick() {
88
+ return setState(undefined);
89
+ },
90
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.DeleteOutlined, {})
91
+ })]
92
+ })
93
+ }, (_item$uid = item.uid) !== null && _item$uid !== void 0 ? _item$uid : index);
94
+ })
95
+ })]
96
+ });
97
+ };
98
+ var _default = exports.default = /*#__PURE__*/_react.default.forwardRef(AttachmentVideoUpload);
@@ -0,0 +1,14 @@
1
+ import type { DraggerProps } from 'antd';
2
+ import React from 'react';
3
+ import { type AttachmentEnv } from './env';
4
+ export interface ChunkedDraggerProps extends DraggerProps {
5
+ /** 宿主环境(传输层、地址前缀、接口路径) */
6
+ env: AttachmentEnv;
7
+ /** 上传协议,默认普通文件 */
8
+ kind?: 'file' | 'video';
9
+ /** 文件选择前的重复校验,返回 `Upload.LIST_IGNORE` 拒绝;仅普通文件使用 */
10
+ chongfuVerify?: DraggerProps['beforeUpload'];
11
+ children?: React.ReactNode;
12
+ }
13
+ declare const ChunkedDragger: React.FC<ChunkedDraggerProps>;
14
+ export default ChunkedDragger;