@cecee/document-flip-book 1.0.19 → 1.0.20

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 (91) hide show
  1. package/dist/cjs/AccountingBook/assets/active-line.png +0 -0
  2. package/dist/cjs/AccountingBook/assets/default-line.png +0 -0
  3. package/dist/cjs/AccountingBook/assets/filp-bg.png +0 -0
  4. package/dist/cjs/AccountingBook/components/AccountingVoucher/index.d.ts +26 -0
  5. package/dist/cjs/AccountingBook/components/AccountingVoucher/index.js +398 -0
  6. package/dist/cjs/AccountingBook/components/AccountingVoucher/index.less +231 -0
  7. package/dist/cjs/AccountingBook/components/ExportModal.d.ts +10 -0
  8. package/dist/cjs/AccountingBook/components/ExportModal.js +96 -0
  9. package/dist/cjs/AccountingBook/components/FilpPage.d.ts +7 -0
  10. package/dist/cjs/AccountingBook/components/FilpPage.js +39 -0
  11. package/dist/cjs/AccountingBook/components/HeaderBar.d.ts +28 -0
  12. package/dist/cjs/AccountingBook/components/HeaderBar.js +245 -0
  13. package/dist/cjs/AccountingBook/components/ImagePageRenderer.d.ts +11 -0
  14. package/dist/cjs/AccountingBook/components/ImagePageRenderer.js +91 -0
  15. package/dist/cjs/AccountingBook/components/LoadingComponent.d.ts +7 -0
  16. package/dist/cjs/AccountingBook/components/LoadingComponent.js +54 -0
  17. package/dist/cjs/AccountingBook/components/PDFPageRenderer.d.ts +13 -0
  18. package/dist/cjs/AccountingBook/components/PDFPageRenderer.js +259 -0
  19. package/dist/cjs/AccountingBook/components/index.less +6 -0
  20. package/dist/cjs/AccountingBook/constants.d.ts +11 -0
  21. package/dist/cjs/AccountingBook/constants.js +25 -0
  22. package/dist/cjs/AccountingBook/hooks/useAmountSearch.d.ts +24 -0
  23. package/dist/cjs/AccountingBook/hooks/useAmountSearch.js +165 -0
  24. package/dist/cjs/AccountingBook/hooks/usePageFlip.d.ts +15 -0
  25. package/dist/cjs/AccountingBook/hooks/usePageFlip.js +67 -0
  26. package/dist/cjs/AccountingBook/index.d.ts +29 -1
  27. package/dist/cjs/AccountingBook/index.js +1163 -7
  28. package/dist/cjs/AccountingBook/index.less +188 -0
  29. package/dist/cjs/AccountingBook/types.d.ts +84 -0
  30. package/dist/cjs/AccountingBook/types.js +5 -0
  31. package/dist/cjs/AccountingBook/utils/canvasUtils.d.ts +51 -0
  32. package/dist/cjs/AccountingBook/utils/canvasUtils.js +499 -0
  33. package/dist/cjs/AccountingBook/utils/html.d.ts +9 -0
  34. package/dist/cjs/AccountingBook/utils/html.js +97 -0
  35. package/dist/cjs/AccountingBook/utils/utils.d.ts +38 -0
  36. package/dist/cjs/AccountingBook/utils/utils.js +204 -0
  37. package/dist/cjs/DocumentFlipBook/ExportModal.d.ts +1 -1
  38. package/dist/cjs/DocumentFlipBook/ExportModal.js +1 -1
  39. package/dist/cjs/DocumentFlipBook/HeaderBar.d.ts +2 -1
  40. package/dist/cjs/DocumentFlipBook/HeaderBar.js +13 -11
  41. package/dist/cjs/DocumentFlipBook/SideTabs.js +111 -6
  42. package/dist/cjs/DocumentFlipBook/index.d.ts +1 -0
  43. package/dist/cjs/DocumentFlipBook/index.js +6 -3
  44. package/dist/cjs/DocumentFlipBook/index.less +235 -9
  45. package/dist/cjs/declarations.d.ts +21 -0
  46. package/dist/esm/AccountingBook/assets/active-line.png +0 -0
  47. package/dist/esm/AccountingBook/assets/default-line.png +0 -0
  48. package/dist/esm/AccountingBook/assets/filp-bg.png +0 -0
  49. package/dist/esm/AccountingBook/components/AccountingVoucher/index.d.ts +26 -0
  50. package/dist/esm/AccountingBook/components/AccountingVoucher/index.js +391 -0
  51. package/dist/esm/AccountingBook/components/AccountingVoucher/index.less +231 -0
  52. package/dist/esm/AccountingBook/components/ExportModal.d.ts +10 -0
  53. package/dist/esm/AccountingBook/components/ExportModal.js +88 -0
  54. package/dist/esm/AccountingBook/components/FilpPage.d.ts +7 -0
  55. package/dist/esm/AccountingBook/components/FilpPage.js +33 -0
  56. package/dist/esm/AccountingBook/components/HeaderBar.d.ts +28 -0
  57. package/dist/esm/AccountingBook/components/HeaderBar.js +236 -0
  58. package/dist/esm/AccountingBook/components/ImagePageRenderer.d.ts +11 -0
  59. package/dist/esm/AccountingBook/components/ImagePageRenderer.js +85 -0
  60. package/dist/esm/AccountingBook/components/LoadingComponent.d.ts +7 -0
  61. package/dist/esm/AccountingBook/components/LoadingComponent.js +48 -0
  62. package/dist/esm/AccountingBook/components/PDFPageRenderer.d.ts +13 -0
  63. package/dist/esm/AccountingBook/components/PDFPageRenderer.js +252 -0
  64. package/dist/esm/AccountingBook/components/index.less +6 -0
  65. package/dist/esm/AccountingBook/constants.d.ts +11 -0
  66. package/dist/esm/AccountingBook/constants.js +17 -0
  67. package/dist/esm/AccountingBook/hooks/useAmountSearch.d.ts +24 -0
  68. package/dist/esm/AccountingBook/hooks/useAmountSearch.js +158 -0
  69. package/dist/esm/AccountingBook/hooks/usePageFlip.d.ts +15 -0
  70. package/dist/esm/AccountingBook/hooks/usePageFlip.js +61 -0
  71. package/dist/esm/AccountingBook/index.d.ts +29 -1
  72. package/dist/esm/AccountingBook/index.js +1162 -6
  73. package/dist/esm/AccountingBook/index.less +188 -0
  74. package/dist/esm/AccountingBook/types.d.ts +84 -0
  75. package/dist/esm/AccountingBook/types.js +1 -0
  76. package/dist/esm/AccountingBook/utils/canvasUtils.d.ts +51 -0
  77. package/dist/esm/AccountingBook/utils/canvasUtils.js +493 -0
  78. package/dist/esm/AccountingBook/utils/html.d.ts +9 -0
  79. package/dist/esm/AccountingBook/utils/html.js +89 -0
  80. package/dist/esm/AccountingBook/utils/utils.d.ts +38 -0
  81. package/dist/esm/AccountingBook/utils/utils.js +195 -0
  82. package/dist/esm/DocumentFlipBook/ExportModal.d.ts +1 -1
  83. package/dist/esm/DocumentFlipBook/ExportModal.js +1 -1
  84. package/dist/esm/DocumentFlipBook/HeaderBar.d.ts +2 -1
  85. package/dist/esm/DocumentFlipBook/HeaderBar.js +13 -11
  86. package/dist/esm/DocumentFlipBook/SideTabs.js +110 -5
  87. package/dist/esm/DocumentFlipBook/index.d.ts +1 -0
  88. package/dist/esm/DocumentFlipBook/index.js +6 -3
  89. package/dist/esm/DocumentFlipBook/index.less +235 -9
  90. package/dist/esm/declarations.d.ts +21 -0
  91. package/package.json +8 -2
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ export declare function formatAmount(amount: string): string[];
3
+ export declare const getSupportedImageExtensions: () => string[];
4
+ export declare const isImageFile: (url: any) => boolean;
5
+ export declare const classifyPages: (pages: React.ReactNode[], filterType?: string) => any[];
6
+ /**
7
+ * 路径格式化:清理首尾空格、反引号和引号
8
+ */
9
+ export declare const formatPath: (path: string) => string;
10
+ /**
11
+ * 全局统一获取附件地址
12
+ * 自动区分环境:dev / test / production
13
+ * 自动处理代理 / 正式域名
14
+ */
15
+ export declare const getAttachmentUrl: (url: string) => string;
16
+ export interface PdfDocumentLike {
17
+ numPages: number;
18
+ getPage: (pageNum: number) => Promise<any>;
19
+ cleanup?: () => void;
20
+ }
21
+ /**
22
+ * PDF 缓存工厂
23
+ */
24
+ export declare const createPdfDocumentCache: (loadDocument: (path: string) => Promise<PdfDocumentLike>) => {
25
+ getDocument(path: string): Promise<PdfDocumentLike>;
26
+ getPageCount(path: string): Promise<number>;
27
+ clear(path: string): void;
28
+ clearAll(): void;
29
+ };
30
+ /**
31
+ * 全局 PDF 缓存实例
32
+ */
33
+ export declare const globalPdfCache: {
34
+ getDocument(path: string): Promise<PdfDocumentLike>;
35
+ getPageCount(path: string): Promise<number>;
36
+ clear(path: string): void;
37
+ clearAll(): void;
38
+ };
@@ -0,0 +1,195 @@
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); }
2
+ 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ 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; }
8
+ 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); } }
9
+ 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); }); }; }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ 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."); }
12
+ 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); }
13
+ 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; }
14
+ 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; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ import React from "react";
17
+ import { pdfjs } from 'react-pdf';
18
+ export function formatAmount(amount) {
19
+ var result = new Array(11).fill(' ');
20
+ if (!amount || amount === '0' || amount === '0.00') return result;
21
+ var numAmount = parseFloat(amount);
22
+ if (isNaN(numAmount) || numAmount === 0) return result;
23
+ var formattedAmount = numAmount.toFixed(2);
24
+ var _formattedAmount$spli = formattedAmount.split('.'),
25
+ _formattedAmount$spli2 = _slicedToArray(_formattedAmount$spli, 2),
26
+ intPart = _formattedAmount$spli2[0],
27
+ _formattedAmount$spli3 = _formattedAmount$spli2[1],
28
+ decPart = _formattedAmount$spli3 === void 0 ? '00' : _formattedAmount$spli3;
29
+ var paddedInt = intPart.padStart(9, ' ');
30
+ return (paddedInt + decPart).split('').slice(0, 11);
31
+ }
32
+
33
+ // 获取支持的图片格式
34
+ export var getSupportedImageExtensions = function getSupportedImageExtensions() {
35
+ return ['png', 'jpg', 'jpeg', 'webp', 'bmp', 'gif'];
36
+ };
37
+
38
+ // 判断是否为图片文件
39
+ export var isImageFile = function isImageFile(url) {
40
+ if (!url) return false;
41
+ var extensions = getSupportedImageExtensions();
42
+ // 移除查询参数后再判断后缀
43
+ var cleanUrl = url.split('?')[0].toLowerCase();
44
+ return extensions.some(function (ext) {
45
+ return cleanUrl.endsWith(".".concat(ext));
46
+ });
47
+ };
48
+ export var classifyPages = function classifyPages(pages, filterType) {
49
+ var result = [];
50
+ // 如果传了筛选类型,直接筛选
51
+ if (filterType) {
52
+ return pages.filter(function (page) {
53
+ var _page$key;
54
+ if (! /*#__PURE__*/React.isValidElement(page)) return false;
55
+ var key = ((_page$key = page.key) === null || _page$key === void 0 ? void 0 : _page$key.toString()) || '';
56
+ if (filterType === 'voucher') return key.includes('voucher-');
57
+ if (filterType === 'attachment') return key.includes('attachment-');
58
+ if (filterType === 'all') return true;
59
+ return false;
60
+ });
61
+ }
62
+ // 原来的逻辑(生成筛选菜单)
63
+ pages.forEach(function (page) {
64
+ var _page$key2;
65
+ if (! /*#__PURE__*/React.isValidElement(page)) return;
66
+ var key = ((_page$key2 = page.key) === null || _page$key2 === void 0 ? void 0 : _page$key2.toString()) || '';
67
+ if (key.includes('voucher-') && !result.some(function (i) {
68
+ return i.type === 'voucher';
69
+ })) {
70
+ result.push({
71
+ name: '记账凭证',
72
+ type: 'voucher'
73
+ });
74
+ }
75
+ if (key.includes('attachment-') && !result.some(function (i) {
76
+ return i.type === 'attachment';
77
+ })) {
78
+ result.push({
79
+ name: '原始附件',
80
+ type: 'attachment'
81
+ });
82
+ }
83
+ });
84
+
85
+ // 最前面插入【全部数据】
86
+ result.unshift({
87
+ name: '全部数据',
88
+ type: 'all'
89
+ });
90
+ return result;
91
+ };
92
+
93
+ /**
94
+ * 路径格式化:清理首尾空格、反引号和引号
95
+ */
96
+ export var formatPath = function formatPath(path) {
97
+ if (!path) return '';
98
+ return String(path).trim().replace(/^[`'"]|[`'"]$/g, '').trim();
99
+ };
100
+
101
+ /**
102
+ * 全局统一获取附件地址
103
+ * 自动区分环境:dev / test / production
104
+ * 自动处理代理 / 正式域名
105
+ */
106
+ export var getAttachmentUrl = function getAttachmentUrl(url) {
107
+ if (!url) return '';
108
+
109
+ // 先清理路径
110
+ var formattedUrl = formatPath(url);
111
+
112
+ // 开发环境 = 本地代理(解决跨域)
113
+ if (process.env.NODE_ENV === 'development') {
114
+ return formattedUrl.replace('https://assets.gks.cc/', '/api-pub/').replace('https://pub.gks.cc/', '/api-pub/');
115
+ }
116
+
117
+ // 测试 + 生产环境 = 真实域名
118
+ return formattedUrl;
119
+ };
120
+
121
+ // ================= PDF 缓存逻辑 =================
122
+
123
+ var PDF_OPTIONS = {
124
+ cMapUrl: "https://unpkg.com/pdfjs-dist@".concat(pdfjs.version, "/cmaps/"),
125
+ cMapPacked: true,
126
+ standardFontDataUrl: "https://unpkg.com/pdfjs-dist@".concat(pdfjs.version, "/standard_fonts/")
127
+ };
128
+
129
+ /**
130
+ * PDF 缓存工厂
131
+ */
132
+ export var createPdfDocumentCache = function createPdfDocumentCache(loadDocument) {
133
+ var cache = new Map();
134
+ return {
135
+ getDocument: function getDocument(path) {
136
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
137
+ var doc;
138
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
139
+ while (1) switch (_context.prev = _context.next) {
140
+ case 0:
141
+ if (!cache.has(path)) {
142
+ _context.next = 2;
143
+ break;
144
+ }
145
+ return _context.abrupt("return", cache.get(path));
146
+ case 2:
147
+ _context.next = 4;
148
+ return loadDocument(path);
149
+ case 4:
150
+ doc = _context.sent;
151
+ cache.set(path, doc);
152
+ return _context.abrupt("return", doc);
153
+ case 7:
154
+ case "end":
155
+ return _context.stop();
156
+ }
157
+ }, _callee);
158
+ }))();
159
+ },
160
+ getPageCount: function getPageCount(path) {
161
+ var _this = this;
162
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
163
+ var doc;
164
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
165
+ while (1) switch (_context2.prev = _context2.next) {
166
+ case 0:
167
+ _context2.next = 2;
168
+ return _this.getDocument(path);
169
+ case 2:
170
+ doc = _context2.sent;
171
+ return _context2.abrupt("return", doc.numPages);
172
+ case 4:
173
+ case "end":
174
+ return _context2.stop();
175
+ }
176
+ }, _callee2);
177
+ }))();
178
+ },
179
+ clear: function clear(path) {
180
+ cache.delete(path);
181
+ },
182
+ clearAll: function clearAll() {
183
+ cache.clear();
184
+ }
185
+ };
186
+ };
187
+
188
+ /**
189
+ * 全局 PDF 缓存实例
190
+ */
191
+ export var globalPdfCache = createPdfDocumentCache(function (path) {
192
+ return pdfjs.getDocument(_objectSpread({
193
+ url: path
194
+ }, PDF_OPTIONS)).promise;
195
+ });
@@ -3,7 +3,7 @@ import './index.less';
3
3
  interface ExportModalProps {
4
4
  visible: boolean;
5
5
  onCancel: () => void;
6
- onConfirm: (type: 'pdf' | 'html') => void;
6
+ onConfirm: (type: 'pdf' | 'epub') => void;
7
7
  themeColor?: string;
8
8
  }
9
9
  declare const ExportModal: React.FC<ExportModalProps>;
@@ -71,7 +71,7 @@ var ExportModal = function ExportModal(_ref) {
71
71
  children: "PDF \u6587\u6863"
72
72
  })
73
73
  }), /*#__PURE__*/_jsx(Radio, {
74
- value: "html",
74
+ value: "epub",
75
75
  className: "export-radio",
76
76
  children: /*#__PURE__*/_jsx("span", {
77
77
  style: {
@@ -7,6 +7,7 @@ interface HeaderBarProps {
7
7
  currentPage: number;
8
8
  totalPages: number;
9
9
  themeColor?: string;
10
+ iconColor?: string;
10
11
  onBack?: () => void;
11
12
  onRequestFullscreen?: () => void;
12
13
  onClose?: () => void;
@@ -15,7 +16,7 @@ interface HeaderBarProps {
15
16
  onNextPage: () => void;
16
17
  onGoLast: () => void;
17
18
  onPrint: () => void;
18
- onDownload: (type?: 'pdf' | 'html') => void;
19
+ onDownload: (type?: 'pdf' | 'epub') => void;
19
20
  onRefresh?: () => void;
20
21
  onSearch?: (val: string) => void;
21
22
  }
@@ -28,7 +28,9 @@ var HeaderBar = function HeaderBar(_ref) {
28
28
  onRefresh = _ref.onRefresh,
29
29
  onSearch = _ref.onSearch,
30
30
  _ref$themeColor = _ref.themeColor,
31
- themeColor = _ref$themeColor === void 0 ? '#9F7D4E' : _ref$themeColor;
31
+ themeColor = _ref$themeColor === void 0 ? '#9F7D4E' : _ref$themeColor,
32
+ _ref$iconColor = _ref.iconColor,
33
+ iconColor = _ref$iconColor === void 0 ? '#0064ff' : _ref$iconColor;
32
34
  var _useState = useState(''),
33
35
  _useState2 = _slicedToArray(_useState, 2),
34
36
  keyword = _useState2[0],
@@ -59,7 +61,7 @@ var HeaderBar = function HeaderBar(_ref) {
59
61
  children: [/*#__PURE__*/_jsx(LeftOutlined, {
60
62
  style: {
61
63
  fontSize: 16,
62
- color: '#0064ff'
64
+ color: iconColor
63
65
  }
64
66
  }), /*#__PURE__*/_jsx("span", {
65
67
  children: "\u8FD4\u56DE"
@@ -76,7 +78,7 @@ var HeaderBar = function HeaderBar(_ref) {
76
78
  children: [/*#__PURE__*/_jsx(ReloadOutlined, {
77
79
  style: {
78
80
  fontSize: 16,
79
- color: '#0064ff'
81
+ color: iconColor
80
82
  }
81
83
  }), /*#__PURE__*/_jsx("span", {
82
84
  children: "\u5237\u65B0"
@@ -91,7 +93,7 @@ var HeaderBar = function HeaderBar(_ref) {
91
93
  children: [/*#__PURE__*/_jsx(FullscreenOutlined, {
92
94
  style: {
93
95
  fontSize: 16,
94
- color: '#0064ff'
96
+ color: iconColor
95
97
  }
96
98
  }), /*#__PURE__*/_jsx("span", {
97
99
  children: "\u5168\u5C4F"
@@ -103,7 +105,7 @@ var HeaderBar = function HeaderBar(_ref) {
103
105
  children: [/*#__PURE__*/_jsx(FullscreenExitOutlined, {
104
106
  style: {
105
107
  fontSize: 16,
106
- color: '#0064ff'
108
+ color: iconColor
107
109
  }
108
110
  }), /*#__PURE__*/_jsx("span", {
109
111
  children: "\u9000\u51FA\u5168\u5C4F"
@@ -118,7 +120,7 @@ var HeaderBar = function HeaderBar(_ref) {
118
120
  children: [/*#__PURE__*/_jsx(StepBackwardOutlined, {
119
121
  style: {
120
122
  fontSize: 16,
121
- color: '#0064ff'
123
+ color: iconColor
122
124
  }
123
125
  }), /*#__PURE__*/_jsx("span", {
124
126
  children: "\u5230\u5934"
@@ -131,7 +133,7 @@ var HeaderBar = function HeaderBar(_ref) {
131
133
  children: [/*#__PURE__*/_jsx(CaretLeftOutlined, {
132
134
  style: {
133
135
  fontSize: 16,
134
- color: '#0064ff'
136
+ color: iconColor
135
137
  }
136
138
  }), /*#__PURE__*/_jsx("span", {
137
139
  children: "\u4E0A\u9875"
@@ -147,7 +149,7 @@ var HeaderBar = function HeaderBar(_ref) {
147
149
  children: [/*#__PURE__*/_jsx(CaretRightOutlined, {
148
150
  style: {
149
151
  fontSize: 16,
150
- color: '#0064ff'
152
+ color: iconColor
151
153
  }
152
154
  }), /*#__PURE__*/_jsx("span", {
153
155
  children: "\u4E0B\u9875"
@@ -160,7 +162,7 @@ var HeaderBar = function HeaderBar(_ref) {
160
162
  children: [/*#__PURE__*/_jsx(StepForwardOutlined, {
161
163
  style: {
162
164
  fontSize: 16,
163
- color: '#0064ff'
165
+ color: iconColor
164
166
  }
165
167
  }), /*#__PURE__*/_jsx("span", {
166
168
  children: "\u5230\u5C3E"
@@ -178,7 +180,7 @@ var HeaderBar = function HeaderBar(_ref) {
178
180
  children: [/*#__PURE__*/_jsx(PrinterOutlined, {
179
181
  style: {
180
182
  fontSize: 16,
181
- color: '#0064ff'
183
+ color: iconColor
182
184
  }
183
185
  }), /*#__PURE__*/_jsx("span", {
184
186
  children: "\u6253\u5370"
@@ -192,7 +194,7 @@ var HeaderBar = function HeaderBar(_ref) {
192
194
  children: [/*#__PURE__*/_jsx(DownloadOutlined, {
193
195
  style: {
194
196
  fontSize: 16,
195
- color: '#0064ff'
197
+ color: iconColor
196
198
  }
197
199
  }), /*#__PURE__*/_jsx("span", {
198
200
  children: "\u4E0B\u8F7D"
@@ -1,13 +1,64 @@
1
- import React from 'react';
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useState, useEffect, useRef } from 'react';
2
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { Fragment as _Fragment } from "react/jsx-runtime";
11
+ var MAX_VISIBLE_TABS = 5;
3
12
  export default function SideTabs(props) {
4
13
  var items = props.items,
5
14
  activeKey = props.activeKey,
6
15
  className = props.className,
7
16
  onSelect = props.onSelect;
8
- return /*#__PURE__*/_jsx("div", {
9
- className: ['dfb-sideTabs', className].filter(Boolean).join(' '),
10
- children: items.map(function (it) {
17
+ var _useState = useState(false),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ isDropdownOpen = _useState2[0],
20
+ setIsDropdownOpen = _useState2[1];
21
+ var dropdownRef = useRef(null);
22
+
23
+ // 根据标签数量动态设置样式类名
24
+ var getContainerClassName = function getContainerClassName() {
25
+ var baseClasses = ['dfb-sideTabs', className].filter(Boolean).join(' ');
26
+ if (items.length > MAX_VISIBLE_TABS) {
27
+ return "".concat(baseClasses, " dfb-sideTabs--dropdown");
28
+ } else if (items.length >= 6) {
29
+ return "".concat(baseClasses, " dfb-sideTabs--overlap");
30
+ }
31
+ return baseClasses;
32
+ };
33
+
34
+ // 显示的标签和折叠的标签
35
+ var visibleItems = items.slice(0, MAX_VISIBLE_TABS);
36
+ var shouldShowDropdown = items.length > MAX_VISIBLE_TABS;
37
+ var isActiveInDropdown = activeKey && !visibleItems.some(function (item) {
38
+ return item.key === activeKey;
39
+ });
40
+ var activeItemInDropdown = isActiveInDropdown ? items.find(function (item) {
41
+ return item.key === activeKey;
42
+ }) : null;
43
+
44
+ // 点击外部关闭下拉菜单
45
+ useEffect(function () {
46
+ var handleClickOutside = function handleClickOutside(event) {
47
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
48
+ setIsDropdownOpen(false);
49
+ }
50
+ };
51
+ if (isDropdownOpen) {
52
+ document.addEventListener('mousedown', handleClickOutside);
53
+ }
54
+ return function () {
55
+ document.removeEventListener('mousedown', handleClickOutside);
56
+ };
57
+ }, [isDropdownOpen]);
58
+ return /*#__PURE__*/_jsxs("div", {
59
+ className: getContainerClassName(),
60
+ ref: dropdownRef,
61
+ children: [visibleItems.map(function (it) {
11
62
  return /*#__PURE__*/_jsx("button", {
12
63
  type: "button",
13
64
  className: ['dfb-sideTab', activeKey === it.key ? 'is-active' : ''].join(' '),
@@ -22,6 +73,60 @@ export default function SideTabs(props) {
22
73
  children: it.label
23
74
  })
24
75
  }, it.key);
25
- })
76
+ }), shouldShowDropdown && /*#__PURE__*/_jsxs(_Fragment, {
77
+ children: [/*#__PURE__*/_jsx("button", {
78
+ type: "button",
79
+ className: ['dfb-sideTab', 'dfb-sideTab--more', isActiveInDropdown ? 'is-active' : ''].join(' '),
80
+ style: isActiveInDropdown && activeItemInDropdown ? {
81
+ background: activeItemInDropdown.color
82
+ } : {},
83
+ onClick: function onClick() {
84
+ return setIsDropdownOpen(!isDropdownOpen);
85
+ },
86
+ children: /*#__PURE__*/_jsx("span", {
87
+ className: "dfb-sideTabText",
88
+ children: "\u66F4\u591A"
89
+ })
90
+ }), isDropdownOpen && /*#__PURE__*/_jsxs("div", {
91
+ className: "dfb-sideTabs__dropdown",
92
+ onClick: function onClick(e) {
93
+ return e.stopPropagation();
94
+ },
95
+ children: [/*#__PURE__*/_jsxs("div", {
96
+ className: "dfb-sideTabs__dropdown-header",
97
+ children: [/*#__PURE__*/_jsx("span", {
98
+ children: "\u66F4\u591A\u6807\u7B7E"
99
+ }), /*#__PURE__*/_jsx("button", {
100
+ type: "button",
101
+ className: "dfb-sideTabs__dropdown-close",
102
+ onClick: function onClick() {
103
+ return setIsDropdownOpen(false);
104
+ },
105
+ children: "\u2715"
106
+ })]
107
+ }), /*#__PURE__*/_jsx("div", {
108
+ className: "dfb-sideTabs__dropdown-content",
109
+ children: items.map(function (it) {
110
+ return /*#__PURE__*/_jsxs("button", {
111
+ type: "button",
112
+ className: ['dfb-sideTabs__dropdown-item', activeKey === it.key ? 'is-active' : ''].join(' '),
113
+ onClick: function onClick() {
114
+ onSelect(it);
115
+ setIsDropdownOpen(false);
116
+ },
117
+ children: [/*#__PURE__*/_jsx("span", {
118
+ className: "dfb-sideTabs__dropdown-item-color",
119
+ style: {
120
+ background: it.color
121
+ }
122
+ }), /*#__PURE__*/_jsx("span", {
123
+ className: "dfb-sideTabs__dropdown-item-text",
124
+ children: it.label
125
+ })]
126
+ }, it.key);
127
+ })
128
+ })]
129
+ })]
130
+ })]
26
131
  });
27
132
  }
@@ -6,6 +6,7 @@ interface DocumentFlipBookProps {
6
6
  title?: string;
7
7
  id?: string;
8
8
  themeColor?: string;
9
+ iconColor?: string;
9
10
  documentInfo: {
10
11
  fd: string;
11
12
  com00cs?: any[];
@@ -32,6 +32,8 @@ var DocumentFlipBook = function DocumentFlipBook(_ref) {
32
32
  id = _ref.id,
33
33
  _ref$themeColor = _ref.themeColor,
34
34
  themeColor = _ref$themeColor === void 0 ? '#9F7D4E' : _ref$themeColor,
35
+ _ref$iconColor = _ref.iconColor,
36
+ iconColor = _ref$iconColor === void 0 ? '#0064ff' : _ref$iconColor,
35
37
  documentInfo = _ref.documentInfo,
36
38
  onBack = _ref.onBack,
37
39
  onRequestFullscreen = _ref.onRequestFullscreen,
@@ -357,7 +359,7 @@ var DocumentFlipBook = function DocumentFlipBook(_ref) {
357
359
  while (1) switch (_context2.prev = _context2.next) {
358
360
  case 0:
359
361
  type = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 'pdf';
360
- if (!(type === 'html')) {
362
+ if (!(type === 'epub')) {
361
363
  _context2.next = 9;
362
364
  break;
363
365
  }
@@ -528,7 +530,7 @@ var DocumentFlipBook = function DocumentFlipBook(_ref) {
528
530
  style: {
529
531
  width: '100%',
530
532
  minHeight: VIEWPORT_HEIGHT,
531
- height: '100%',
533
+ height: VIEWPORT_HEIGHT,
532
534
  objectFit: 'contain',
533
535
  objectPosition: 'center top'
534
536
  }
@@ -556,7 +558,8 @@ var DocumentFlipBook = function DocumentFlipBook(_ref) {
556
558
  onPrint: handlePrint,
557
559
  onDownload: handleDownload,
558
560
  onRefresh: handleRefresh,
559
- themeColor: themeColor
561
+ themeColor: themeColor,
562
+ iconColor: iconColor
560
563
  }), /*#__PURE__*/_jsx("div", {
561
564
  className: "dfb-stage",
562
565
  children: /*#__PURE__*/_jsx(Spin, {