@nokecy/qc-ui 1.1.76 → 1.1.79

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 (85) hide show
  1. package/dist/cjs/attachment/AttachmentFileButton.d.ts +4 -0
  2. package/dist/cjs/attachment/AttachmentFileButton.js +86 -0
  3. package/dist/cjs/attachment/AttachmentImageUpload.d.ts +16 -0
  4. package/dist/cjs/attachment/AttachmentImageUpload.js +206 -0
  5. package/dist/cjs/attachment/AttachmentPanel.d.ts +8 -0
  6. package/dist/cjs/attachment/AttachmentPanel.js +63 -0
  7. package/dist/cjs/attachment/AttachmentVideoUpload.d.ts +13 -0
  8. package/dist/cjs/attachment/AttachmentVideoUpload.js +88 -0
  9. package/dist/cjs/attachment/ChunkedDragger.d.ts +14 -0
  10. package/dist/cjs/attachment/ChunkedDragger.js +160 -0
  11. package/dist/cjs/attachment/attachmentList.d.ts +91 -0
  12. package/dist/cjs/attachment/attachmentList.js +214 -0
  13. package/dist/cjs/attachment/chunkUpload.d.ts +26 -0
  14. package/dist/cjs/attachment/chunkUpload.js +276 -0
  15. package/dist/cjs/attachment/env.d.ts +41 -0
  16. package/dist/cjs/attachment/env.js +41 -0
  17. package/dist/cjs/attachment/index.d.ts +20 -0
  18. package/dist/cjs/attachment/index.js +92 -0
  19. package/dist/cjs/index.d.ts +2 -0
  20. package/dist/cjs/index.js +24 -0
  21. package/dist/cjs/standardList/StandardAgGridPlus.d.ts +58 -0
  22. package/dist/cjs/standardList/StandardAgGridPlus.js +698 -0
  23. package/dist/cjs/standardList/dateFormat.d.ts +16 -0
  24. package/dist/cjs/standardList/dateFormat.js +56 -0
  25. package/dist/cjs/standardList/emptyState.d.ts +36 -0
  26. package/dist/cjs/standardList/emptyState.js +89 -0
  27. package/dist/cjs/standardList/enumColumns.d.ts +31 -0
  28. package/dist/cjs/standardList/enumColumns.js +87 -0
  29. package/dist/cjs/standardList/gridColumnDefs.d.ts +33 -0
  30. package/dist/cjs/standardList/gridColumnDefs.js +61 -0
  31. package/dist/cjs/standardList/groupedHeaders.d.ts +28 -0
  32. package/dist/cjs/standardList/groupedHeaders.js +84 -0
  33. package/dist/cjs/standardList/groupedHeaders.less +29 -0
  34. package/dist/cjs/standardList/index.d.ts +20 -0
  35. package/dist/cjs/standardList/index.js +176 -0
  36. package/dist/cjs/standardList/listDateDisplay.d.ts +9 -0
  37. package/dist/cjs/standardList/listDateDisplay.js +64 -0
  38. package/dist/cjs/standardList/listDefaultSort.d.ts +38 -0
  39. package/dist/cjs/standardList/listDefaultSort.js +139 -0
  40. package/dist/cjs/standardList/listRefresh.d.ts +25 -0
  41. package/dist/cjs/standardList/listRefresh.js +53 -0
  42. package/dist/esm/attachment/AttachmentFileButton.d.ts +4 -0
  43. package/dist/esm/attachment/AttachmentFileButton.js +77 -0
  44. package/dist/esm/attachment/AttachmentImageUpload.d.ts +16 -0
  45. package/dist/esm/attachment/AttachmentImageUpload.js +199 -0
  46. package/dist/esm/attachment/AttachmentPanel.d.ts +8 -0
  47. package/dist/esm/attachment/AttachmentPanel.js +52 -0
  48. package/dist/esm/attachment/AttachmentVideoUpload.d.ts +13 -0
  49. package/dist/esm/attachment/AttachmentVideoUpload.js +82 -0
  50. package/dist/esm/attachment/ChunkedDragger.d.ts +14 -0
  51. package/dist/esm/attachment/ChunkedDragger.js +153 -0
  52. package/dist/esm/attachment/attachmentList.d.ts +91 -0
  53. package/dist/esm/attachment/attachmentList.js +207 -0
  54. package/dist/esm/attachment/chunkUpload.d.ts +26 -0
  55. package/dist/esm/attachment/chunkUpload.js +272 -0
  56. package/dist/esm/attachment/env.d.ts +41 -0
  57. package/dist/esm/attachment/env.js +35 -0
  58. package/dist/esm/attachment/index.d.ts +20 -0
  59. package/dist/esm/attachment/index.js +14 -0
  60. package/dist/esm/index.d.ts +2 -0
  61. package/dist/esm/index.js +2 -0
  62. package/dist/esm/standardList/StandardAgGridPlus.d.ts +58 -0
  63. package/dist/esm/standardList/StandardAgGridPlus.js +691 -0
  64. package/dist/esm/standardList/dateFormat.d.ts +16 -0
  65. package/dist/esm/standardList/dateFormat.js +50 -0
  66. package/dist/esm/standardList/emptyState.d.ts +36 -0
  67. package/dist/esm/standardList/emptyState.js +83 -0
  68. package/dist/esm/standardList/enumColumns.d.ts +31 -0
  69. package/dist/esm/standardList/enumColumns.js +82 -0
  70. package/dist/esm/standardList/gridColumnDefs.d.ts +33 -0
  71. package/dist/esm/standardList/gridColumnDefs.js +55 -0
  72. package/dist/esm/standardList/groupedHeaders.d.ts +28 -0
  73. package/dist/esm/standardList/groupedHeaders.js +78 -0
  74. package/dist/esm/standardList/groupedHeaders.less +29 -0
  75. package/dist/esm/standardList/index.d.ts +20 -0
  76. package/dist/esm/standardList/index.js +15 -0
  77. package/dist/esm/standardList/listDateDisplay.d.ts +9 -0
  78. package/dist/esm/standardList/listDateDisplay.js +58 -0
  79. package/dist/esm/standardList/listDefaultSort.d.ts +38 -0
  80. package/dist/esm/standardList/listDefaultSort.js +133 -0
  81. package/dist/esm/standardList/listRefresh.d.ts +25 -0
  82. package/dist/esm/standardList/listRefresh.js +47 -0
  83. package/dist/umd/qc-ui.min.css +1 -1
  84. package/dist/umd/qc-ui.min.js +1 -1
  85. package/package.json +1 -1
@@ -0,0 +1,276 @@
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.splitFile = exports.createVideoProtocol = exports.createFileProtocol = exports.CHUNK_SIZE = void 0;
8
+ var _env = require("./env");
9
+ 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; }
10
+ 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); } }
11
+ 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); }); }; } /**
12
+ * 附件上传协议:普通文件(带断点续传与合并校验)与视频(分块后确认)。
13
+ * 两套协议的端点、参数大小写、进度算法与收尾都不同,各自照原样实现,不合并成带开关的一套。
14
+ *
15
+ * @author nokecy
16
+ */
17
+ /** 分块大小,同时也是切块上传的阈值。 */
18
+ var CHUNK_SIZE = exports.CHUNK_SIZE = 5 * 1024 * 1024;
19
+ /** 把文件切成 `chunks` 块。 */
20
+ var splitFile = exports.splitFile = function splitFile(file, eachSize, chunks) {
21
+ return new Promise(function (resolve, reject) {
22
+ try {
23
+ setTimeout(function () {
24
+ var fileChunk = [];
25
+ for (var chunk = 0; chunks > 0; chunks--) {
26
+ fileChunk.push(file.slice(chunk, chunk + eachSize));
27
+ chunk += eachSize;
28
+ }
29
+ resolve(fileChunk);
30
+ }, 0);
31
+ } catch (e) {
32
+ console.error(e);
33
+ reject(new Error('文件切块发生错误'));
34
+ }
35
+ });
36
+ };
37
+ var toFormData = function toFormData(param) {
38
+ var formData = new FormData();
39
+ for (var p in param) formData.append(p, param[p]);
40
+ return formData;
41
+ };
42
+ var headersOf = function headersOf(env) {
43
+ var _env$getHeaders, _env$getHeaders2;
44
+ return (_env$getHeaders = (_env$getHeaders2 = env.getHeaders) === null || _env$getHeaders2 === void 0 ? void 0 : _env$getHeaders2.call(env)) !== null && _env$getHeaders !== void 0 ? _env$getHeaders : {};
45
+ };
46
+
47
+ /** 普通文件协议。 */
48
+ var createFileProtocol = exports.createFileProtocol = function createFileProtocol(env) {
49
+ var endpoints = (0, _env.resolveEndpoints)(env);
50
+ var postFile = function postFile(param, onProgress) {
51
+ return env.post("".concat(env.serverUrl()).concat(endpoints.upload), toFormData(param), {
52
+ headers: headersOf(env),
53
+ onUploadProgress: function onUploadProgress(e) {
54
+ if (param.chunked) {
55
+ e.percent = Number(((param.chunk * (param.eachSize - 1) + e.loaded) / param.fullSize * 100).toFixed(2));
56
+ } else {
57
+ e.percent = Number((e.loaded / e.total * 100).toFixed(2));
58
+ }
59
+ onProgress(e);
60
+ }
61
+ }).then(function (rs) {
62
+ return {
63
+ nextchunk: rs.data.nextchunk,
64
+ filename: rs.data.filename
65
+ };
66
+ });
67
+ };
68
+ var validateFile = function validateFile(body) {
69
+ return env.post("".concat(env.serverUrl()).concat(endpoints.validate), body, {
70
+ headers: headersOf(env)
71
+ }).then(function (rs) {
72
+ return rs.data;
73
+ });
74
+ };
75
+
76
+ /** 单文件上传,返回 `{ nextchunk, filename }`。 */
77
+ var uploadSingle = function uploadSingle(file, onProgress) {
78
+ return postFile({
79
+ file: file,
80
+ uid: file.uid,
81
+ fileName: file.fileName
82
+ }, onProgress);
83
+ };
84
+
85
+ /** 分块上传:服务端返回的 `nextchunk` 决定下一块(断点续传),最后合并校验,校验不通过则抛错。 */
86
+ var uploadChunked = /*#__PURE__*/function () {
87
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file, onProgress) {
88
+ var chunks, fileChunks, currentChunk, i, _yield$postFile, nextchunk, data;
89
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
90
+ while (1) switch (_context.prev = _context.next) {
91
+ case 0:
92
+ chunks = Math.ceil(file.size / CHUNK_SIZE);
93
+ _context.next = 3;
94
+ return splitFile(file, CHUNK_SIZE, chunks);
95
+ case 3:
96
+ fileChunks = _context.sent;
97
+ currentChunk = 0;
98
+ i = 0;
99
+ case 6:
100
+ if (!(i < fileChunks.length)) {
101
+ _context.next = 16;
102
+ break;
103
+ }
104
+ if (!(Number(currentChunk) === i)) {
105
+ _context.next = 13;
106
+ break;
107
+ }
108
+ _context.next = 10;
109
+ return postFile({
110
+ chunked: true,
111
+ chunk: i,
112
+ chunks: chunks,
113
+ eachSize: CHUNK_SIZE,
114
+ fileName: file.name,
115
+ fullSize: file.size,
116
+ uid: file.uid,
117
+ file: fileChunks[i]
118
+ }, onProgress);
119
+ case 10:
120
+ _yield$postFile = _context.sent;
121
+ nextchunk = _yield$postFile.nextchunk;
122
+ currentChunk = nextchunk;
123
+ case 13:
124
+ i++;
125
+ _context.next = 6;
126
+ break;
127
+ case 16:
128
+ _context.next = 18;
129
+ return validateFile({
130
+ chunks: fileChunks.length,
131
+ fileName: file.name,
132
+ fullSize: file.size,
133
+ uid: file.uid
134
+ });
135
+ case 18:
136
+ data = _context.sent;
137
+ if (data.isValid) {
138
+ _context.next = 21;
139
+ break;
140
+ }
141
+ throw new Error('文件校验异常');
142
+ case 21:
143
+ return _context.abrupt("return", data);
144
+ case 22:
145
+ case "end":
146
+ return _context.stop();
147
+ }
148
+ }, _callee);
149
+ }));
150
+ return function uploadChunked(_x, _x2) {
151
+ return _ref.apply(this, arguments);
152
+ };
153
+ }();
154
+ return {
155
+ uploadSingle: uploadSingle,
156
+ uploadChunked: uploadChunked
157
+ };
158
+ };
159
+
160
+ /** 视频协议。 */
161
+ var createVideoProtocol = exports.createVideoProtocol = function createVideoProtocol(env) {
162
+ var endpoints = (0, _env.resolveEndpoints)(env);
163
+ var postFile = function postFile(param, onProgress) {
164
+ return env.post("".concat(env.serverUrl()).concat(endpoints.uploadVideoChunk), toFormData(param), {
165
+ headers: headersOf(env),
166
+ // 视频接口的参数是大写开头,下面的 `chunked` 恒为 undefined,进度始终按单次请求计算——沿用原行为。
167
+ onUploadProgress: function onUploadProgress(e) {
168
+ if (param.chunked) {
169
+ e.percent = Number(((param.chunk * (param.eachSize - 1) + e.loaded) / param.fullSize * 100).toFixed(2));
170
+ } else {
171
+ e.percent = Number((e.loaded / e.total * 100).toFixed(2));
172
+ }
173
+ onProgress(e);
174
+ }
175
+ }).then(function (rs) {
176
+ return {
177
+ nextchunk: rs.data.nextchunk,
178
+ filename: rs.data.filename
179
+ };
180
+ });
181
+ };
182
+ var confirm = function confirm(body) {
183
+ return env.post("".concat(env.serverUrl()).concat(endpoints.confirmVideo), body, {
184
+ headers: headersOf(env)
185
+ }).then(function (rs) {
186
+ return rs.data;
187
+ });
188
+ };
189
+
190
+ /** 单文件上传后确认;确认失败时返回 undefined 而不抛错——沿用原行为。 */
191
+ var uploadSingle = function uploadSingle(file, onProgress) {
192
+ return postFile({
193
+ File: file,
194
+ Uid: file.uid,
195
+ FileName: file.fileName
196
+ }, onProgress).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
197
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
198
+ while (1) switch (_context2.prev = _context2.next) {
199
+ case 0:
200
+ _context2.prev = 0;
201
+ _context2.next = 3;
202
+ return confirm({
203
+ Chunks: 1,
204
+ FileName: file.name,
205
+ FullSize: file.size,
206
+ Uid: file.uid
207
+ });
208
+ case 3:
209
+ return _context2.abrupt("return", _context2.sent);
210
+ case 6:
211
+ _context2.prev = 6;
212
+ _context2.t0 = _context2["catch"](0);
213
+ return _context2.abrupt("return", undefined);
214
+ case 9:
215
+ case "end":
216
+ return _context2.stop();
217
+ }
218
+ }, _callee2, null, [[0, 6]]);
219
+ })));
220
+ };
221
+
222
+ /** 分块上传:每一块都按顺序上传(不按 nextchunk 跳块、不检查 isValid),最后确认。 */
223
+ var uploadChunked = /*#__PURE__*/function () {
224
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(file, onProgress) {
225
+ var Chunks, fileChunks, i;
226
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
227
+ while (1) switch (_context3.prev = _context3.next) {
228
+ case 0:
229
+ Chunks = Math.ceil(file.size / CHUNK_SIZE);
230
+ _context3.next = 3;
231
+ return splitFile(file, CHUNK_SIZE, Chunks);
232
+ case 3:
233
+ fileChunks = _context3.sent;
234
+ i = 0;
235
+ case 5:
236
+ if (!(i < fileChunks.length)) {
237
+ _context3.next = 11;
238
+ break;
239
+ }
240
+ _context3.next = 8;
241
+ return postFile({
242
+ Chunked: true,
243
+ Chunk: i,
244
+ Chunks: Chunks,
245
+ EachSize: CHUNK_SIZE,
246
+ FileName: file.name,
247
+ FullSize: file.size,
248
+ Uid: file.uid,
249
+ File: fileChunks[i]
250
+ }, onProgress);
251
+ case 8:
252
+ i++;
253
+ _context3.next = 5;
254
+ break;
255
+ case 11:
256
+ return _context3.abrupt("return", confirm({
257
+ Chunks: fileChunks.length,
258
+ FileName: file.name,
259
+ FullSize: file.size,
260
+ Uid: file.uid
261
+ }));
262
+ case 12:
263
+ case "end":
264
+ return _context3.stop();
265
+ }
266
+ }, _callee3);
267
+ }));
268
+ return function uploadChunked(_x3, _x4) {
269
+ return _ref3.apply(this, arguments);
270
+ };
271
+ }();
272
+ return {
273
+ uploadSingle: uploadSingle,
274
+ uploadChunked: uploadChunked
275
+ };
276
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * 附件上传的宿主环境:后端地址、传输层与接口路径。
3
+ * qc-ui 不依赖具体的 HTTP 库,宿主把自己的 POST 实现与地址前缀注入进来。
4
+ *
5
+ * @author nokecy
6
+ */
7
+ /** 附件服务的接口路径(相对于 `serverUrl()`)。`validate` 沿用后端的拼写 `valiate`。 */
8
+ export interface AttachmentEndpoints {
9
+ /** 普通文件上传(单文件与分块共用) */
10
+ upload: string;
11
+ /** 普通文件分块合并后的校验 */
12
+ validate: string;
13
+ /** 视频分块上传 */
14
+ uploadVideoChunk: string;
15
+ /** 视频上传完成后的确认 */
16
+ confirmVideo: string;
17
+ /** 按 blobName 下载,blobName 直接拼在末尾 */
18
+ downloadByBlobName: string;
19
+ }
20
+ export declare const defaultAttachmentEndpoints: AttachmentEndpoints;
21
+ /** `post` 的第三个参数,约定与 axios 一致。 */
22
+ export interface AttachmentPostConfig {
23
+ headers?: Record<string, string | undefined>;
24
+ onUploadProgress?: (event: any) => void;
25
+ }
26
+ /** 宿主注入的环境。 */
27
+ export interface AttachmentEnv {
28
+ /** 后端地址前缀,如 `() => window.serverUrl.apiServerUrl`;与路径直接拼接,不加斜杠 */
29
+ serverUrl: () => string;
30
+ /** 发 POST 请求(multipart 或 JSON),约定与 `axios.post` 一致,返回含 `data` 的响应 */
31
+ post: (url: string, data: any, config?: AttachmentPostConfig) => Promise<{
32
+ data: any;
33
+ }>;
34
+ /** 每次请求附带的请求头(例如防伪令牌),请求时才读取 */
35
+ getHeaders?: () => Record<string, string | undefined>;
36
+ /** 覆盖默认的接口路径 */
37
+ endpoints?: Partial<AttachmentEndpoints>;
38
+ }
39
+ export declare const resolveEndpoints: (env: AttachmentEnv) => AttachmentEndpoints;
40
+ /** 按 blobName 拼出下载地址。 */
41
+ export declare const getBlobDownloadUrl: (env: AttachmentEnv, blobName: string) => string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveEndpoints = exports.getBlobDownloadUrl = exports.defaultAttachmentEndpoints = void 0;
7
+ 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); }
8
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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); }
13
+ /**
14
+ * 附件上传的宿主环境:后端地址、传输层与接口路径。
15
+ * qc-ui 不依赖具体的 HTTP 库,宿主把自己的 POST 实现与地址前缀注入进来。
16
+ *
17
+ * @author nokecy
18
+ */
19
+
20
+ /** 附件服务的接口路径(相对于 `serverUrl()`)。`validate` 沿用后端的拼写 `valiate`。 */
21
+
22
+ var defaultAttachmentEndpoints = exports.defaultAttachmentEndpoints = {
23
+ upload: '/api/attachmentManage/temp-blob/upload',
24
+ validate: '/api/attachmentManage/temp-blob/valiate',
25
+ uploadVideoChunk: '/api/attachmentManage/temp-blob/upload-video-chunk',
26
+ confirmVideo: '/api/attachmentManage/temp-blob/confirm-video',
27
+ downloadByBlobName: '/api/attachmentManage/blob/by-blob-name/'
28
+ };
29
+
30
+ /** `post` 的第三个参数,约定与 axios 一致。 */
31
+
32
+ /** 宿主注入的环境。 */
33
+
34
+ var resolveEndpoints = exports.resolveEndpoints = function resolveEndpoints(env) {
35
+ return _objectSpread(_objectSpread({}, defaultAttachmentEndpoints), env.endpoints);
36
+ };
37
+
38
+ /** 按 blobName 拼出下载地址。 */
39
+ var getBlobDownloadUrl = exports.getBlobDownloadUrl = function getBlobDownloadUrl(env, blobName) {
40
+ return "".concat(env.serverUrl()).concat(resolveEndpoints(env).downloadByBlobName).concat(blobName);
41
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 附件上传:拖拽上传(普通文件断点续传 / 视频分块)、附件列表、图片墙。
3
+ * 传输层与接口路径由宿主通过 `env` 注入。
4
+ *
5
+ * @author nokecy
6
+ */
7
+ export { default as AttachmentPanel } from './AttachmentPanel';
8
+ export type { AttachmentPanelProps } from './AttachmentPanel';
9
+ export { default as AttachmentFileButton } from './AttachmentFileButton';
10
+ export { default as AttachmentImageUpload } from './AttachmentImageUpload';
11
+ export type { AttachmentImageUploadProps } from './AttachmentImageUpload';
12
+ export { default as AttachmentVideoUpload } from './AttachmentVideoUpload';
13
+ export type { AttachmentVideoUploadProps } from './AttachmentVideoUpload';
14
+ export { default as ChunkedDragger } from './ChunkedDragger';
15
+ export type { ChunkedDraggerProps } from './ChunkedDragger';
16
+ export { formatAttachmentDate } from './attachmentList';
17
+ export type { AttachmentListProps } from './attachmentList';
18
+ export { defaultAttachmentEndpoints, getBlobDownloadUrl, resolveEndpoints } from './env';
19
+ export type { AttachmentEndpoints, AttachmentEnv, AttachmentPostConfig } from './env';
20
+ export { CHUNK_SIZE, createFileProtocol, createVideoProtocol, splitFile } from './chunkUpload';
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AttachmentFileButton", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _AttachmentFileButton.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "AttachmentImageUpload", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _AttachmentImageUpload.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "AttachmentPanel", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _AttachmentPanel.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "AttachmentVideoUpload", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _AttachmentVideoUpload.default;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "CHUNK_SIZE", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _chunkUpload.CHUNK_SIZE;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "ChunkedDragger", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _ChunkedDragger.default;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "createFileProtocol", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _chunkUpload.createFileProtocol;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "createVideoProtocol", {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _chunkUpload.createVideoProtocol;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "defaultAttachmentEndpoints", {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _env.defaultAttachmentEndpoints;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "formatAttachmentDate", {
61
+ enumerable: true,
62
+ get: function get() {
63
+ return _attachmentList.formatAttachmentDate;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "getBlobDownloadUrl", {
67
+ enumerable: true,
68
+ get: function get() {
69
+ return _env.getBlobDownloadUrl;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "resolveEndpoints", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _env.resolveEndpoints;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "splitFile", {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _chunkUpload.splitFile;
82
+ }
83
+ });
84
+ var _AttachmentPanel = _interopRequireDefault(require("./AttachmentPanel"));
85
+ var _AttachmentFileButton = _interopRequireDefault(require("./AttachmentFileButton"));
86
+ var _AttachmentImageUpload = _interopRequireDefault(require("./AttachmentImageUpload"));
87
+ var _AttachmentVideoUpload = _interopRequireDefault(require("./AttachmentVideoUpload"));
88
+ var _ChunkedDragger = _interopRequireDefault(require("./ChunkedDragger"));
89
+ var _attachmentList = require("./attachmentList");
90
+ var _env = require("./env");
91
+ var _chunkUpload = require("./chunkUpload");
92
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -32,6 +32,8 @@ export type { ColumnConfig } from "./array-table/columnHelper";
32
32
  export type { CentralizedColumnScheme, QueryScheme, SchemeStorageAdapter, SchemeSyncDataDto, CurrentSchemeDto, SchemeStorageConfig, LocalStorageAdapterConfig, BackendApiAdapterConfig, UseSchemeManagerConfig, GridPlusContextValue, GlobalConfigPermissions, } from "./ag-grid-plus";
33
33
  export * from './adapters';
34
34
  export * from "./readPretty";
35
+ export * from "./standardList";
36
+ export * from "./attachment";
35
37
  export { createEntitySelect } from "./entitySelect";
36
38
  export { default as ExportButton, buildExportUrl, DEFAULT_EXPORT_TEMPLATE_API, resolveExportAction, resolveExportError, resolveFileName } from "./exportButton";
37
39
  export type { ExportButtonProps, ExportTemplateApi, ExportTemplateOption } from "./exportButton";
package/dist/cjs/index.js CHANGED
@@ -529,6 +529,30 @@ Object.keys(_readPretty).forEach(function (key) {
529
529
  }
530
530
  });
531
531
  });
532
+ var _standardList = require("./standardList");
533
+ Object.keys(_standardList).forEach(function (key) {
534
+ if (key === "default" || key === "__esModule") return;
535
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
536
+ if (key in exports && exports[key] === _standardList[key]) return;
537
+ Object.defineProperty(exports, key, {
538
+ enumerable: true,
539
+ get: function get() {
540
+ return _standardList[key];
541
+ }
542
+ });
543
+ });
544
+ var _attachment = require("./attachment");
545
+ Object.keys(_attachment).forEach(function (key) {
546
+ if (key === "default" || key === "__esModule") return;
547
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
548
+ if (key in exports && exports[key] === _attachment[key]) return;
549
+ Object.defineProperty(exports, key, {
550
+ enumerable: true,
551
+ get: function get() {
552
+ return _attachment[key];
553
+ }
554
+ });
555
+ });
532
556
  var _entitySelect = require("./entitySelect");
533
557
  var _exportButton = _interopRequireWildcard(require("./exportButton"));
534
558
  var _download = require("./utils/download");
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import type { AgGridColumnPropsClone, GridRef } from '../ag-grid-plus/interface';
3
+ import { type EnumFallbackRenderer } from './enumColumns';
4
+ import './groupedHeaders.less';
5
+ import { type ListSortPolicy } from './listDefaultSort';
6
+ /**
7
+ * 标准列表的宿主口径。
8
+ * - `enumFallbackRenderer`:枚举列未命中时的显示(如「未知(原码)」);不传则显示原码。
9
+ * - `sortPolicy`:默认排序识别的状态字段与记录时间字段。
10
+ */
11
+ export interface StandardListPolicy {
12
+ enumFallbackRenderer?: EnumFallbackRenderer;
13
+ sortPolicy?: ListSortPolicy;
14
+ }
15
+ /**
16
+ * 标准列表列定义:在表格列定义上补 businessKey。
17
+ * businessKey 为 true 表示该列是业务单号(如 mrpID、mpsID),不按「ID 结尾」当内部键隐藏。
18
+ * @author nokecy
19
+ */
20
+ export type AppGridColumn = AgGridColumnPropsClone & {
21
+ businessKey?: boolean;
22
+ };
23
+ /**
24
+ * 标准列表基座:在 AgGridPlus 外面包一层公司列表规范(序号、内部字段隐藏、日期显示、分组表头、空态四分支、
25
+ * 默认排序、枚举回退等)。宿主的页面一律经宿主自己的薄封装导入它,这里加一次,等于所有列表页都有了。
26
+ * 与路由相关的刷新令牌和宿主口径(未知值文案、排序字段)由宿主通过属性传入。
27
+ *
28
+ * 这层目前做三件事:
29
+ *
30
+ * 1. **从表单页保存返回时,把列表刷新一遍**。
31
+ * 起因是 `pubGoBack()` 只 push 回父路径再关掉表单页标签,而列表页在 KeepAlive 缓存里,
32
+ * push 回去是直接复原缓存的那棵树,不会重新请求——用户刚保存的记录不在列表里,
33
+ * 于是以为没存上,再存一遍。全仓 196 处返回都是这个行为。
34
+ * 为什么不直接 `dropByCacheKey(列表路径)` 把缓存丢掉:那样确实会重新加载,
35
+ * 但连筛选条件、滚动位置、分页和列宽一起丢了。用户进表单前设的筛选,回来就没了。
36
+ * 走 URL 上的 refresh 标记只重新取数,页面状态原样保留。
37
+ *
38
+ * 2. **空态四分支(U2)**:无数据 / 筛选无结果 / 无权限(403) / 加载失败。
39
+ * qc-ui 只支持一句空数据文字(overlayNoRowsTemplateText),分不出四种情况。
40
+ * 这里用 AG-Grid 原生的 `noRowsOverlayComponent`(优先级高于 overlayNoRowsTemplate)
41
+ * 挂 `GridEmptyState`,请求成败与是否带筛选经 context 传给 overlay 组件。
42
+ * 业务页可通过 `emptyActions` 注入「无数据」分支的操作(通常是 Access 包裹的新建按钮),
43
+ * 或用自己的 `noRowsOverlayComponent` 整体覆盖。
44
+ *
45
+ * 3. **valueEnum 文字对比度**:qc-ui 把 `valueEnum.color` 当 CSS 文字色,缺 color 时写成
46
+ * `#ffffff`(销售跟踪「类型」列「普通订单」白底白字就是这条)。封装层给 columnDefs
47
+ * 和 AgGridColumn 统一套 `gridValueEnum()`:缺色用 inherit,浅色 / 预设名收成白底 ≥4.5:1。
48
+ *
49
+ * 4. **列定义上的 live `sort`**:AG Grid 把 `ColDef.sort` 当受控属性,每次 columnDefs 引用变化
50
+ * 都会强制写回。送货单点「送货日期」降序后再点单元格,选中态 setState 重建列定义,
51
+ * 默认「单号升序」被重新套上,排序就自己变了。封装层把 `sort` 收成只用于建列的 `initialSort`。
52
+ *
53
+ * @author nokecy
54
+ */
55
+ declare const StandardAgGridColumn: React.FC<any>;
56
+ declare const StandardAgGridPlus: React.FC<any>;
57
+ export { StandardAgGridColumn, StandardAgGridPlus };
58
+ export type { GridRef };