react-vector-pdf 0.6.0 → 0.6.1
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.
- package/README.md +79 -1
- package/dist/index.d.ts +37 -7
- package/dist/react-vector-pdf.css +1 -0
- package/dist/react-vector-pdf.js +1095 -719
- package/package.json +69 -69
package/dist/react-vector-pdf.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { jsPDF as
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
if (
|
|
7
|
-
|
|
1
|
+
import z, { useRef as Ot, createContext as At, useContext as jt, useId as Ct, useState as Yt } from "react";
|
|
2
|
+
import { jsPDF as Ft } from "jspdf";
|
|
3
|
+
var xt = { exports: {} }, bt = {};
|
|
4
|
+
var Et;
|
|
5
|
+
function Ht() {
|
|
6
|
+
if (Et) return bt;
|
|
7
|
+
Et = 1;
|
|
8
8
|
var n = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
9
|
-
function r(
|
|
10
|
-
var
|
|
11
|
-
if (s !== void 0 && (
|
|
9
|
+
function r(i, e, s) {
|
|
10
|
+
var u = null;
|
|
11
|
+
if (s !== void 0 && (u = "" + s), e.key !== void 0 && (u = "" + e.key), "key" in e) {
|
|
12
12
|
s = {};
|
|
13
|
-
for (var
|
|
14
|
-
|
|
15
|
-
} else s =
|
|
16
|
-
return
|
|
13
|
+
for (var c in e)
|
|
14
|
+
c !== "key" && (s[c] = e[c]);
|
|
15
|
+
} else s = e;
|
|
16
|
+
return e = s.ref, {
|
|
17
17
|
$$typeof: n,
|
|
18
|
-
type:
|
|
19
|
-
key:
|
|
20
|
-
ref:
|
|
18
|
+
type: i,
|
|
19
|
+
key: u,
|
|
20
|
+
ref: e !== void 0 ? e : null,
|
|
21
21
|
props: s
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
return
|
|
24
|
+
return bt.Fragment = t, bt.jsx = r, bt.jsxs = r, bt;
|
|
25
25
|
}
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
return
|
|
26
|
+
var vt = {};
|
|
27
|
+
var kt;
|
|
28
|
+
function Lt() {
|
|
29
|
+
return kt || (kt = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
30
30
|
function n(o) {
|
|
31
31
|
if (o == null) return null;
|
|
32
32
|
if (typeof o == "function")
|
|
33
|
-
return o.$$typeof ===
|
|
33
|
+
return o.$$typeof === U ? null : o.displayName || o.name || null;
|
|
34
34
|
if (typeof o == "string") return o;
|
|
35
35
|
switch (o) {
|
|
36
|
-
case
|
|
36
|
+
case l:
|
|
37
37
|
return "Fragment";
|
|
38
|
-
case
|
|
38
|
+
case v:
|
|
39
39
|
return "Profiler";
|
|
40
|
-
case
|
|
40
|
+
case m:
|
|
41
41
|
return "StrictMode";
|
|
42
|
-
case
|
|
42
|
+
case _:
|
|
43
43
|
return "Suspense";
|
|
44
|
-
case
|
|
44
|
+
case W:
|
|
45
45
|
return "SuspenseList";
|
|
46
|
-
case
|
|
46
|
+
case F:
|
|
47
47
|
return "Activity";
|
|
48
48
|
}
|
|
49
49
|
if (typeof o == "object")
|
|
50
50
|
switch (typeof o.tag == "number" && console.error(
|
|
51
51
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
52
52
|
), o.$$typeof) {
|
|
53
|
-
case
|
|
53
|
+
case d:
|
|
54
54
|
return "Portal";
|
|
55
|
-
case
|
|
55
|
+
case x:
|
|
56
56
|
return o.displayName || "Context";
|
|
57
|
-
case
|
|
57
|
+
case C:
|
|
58
58
|
return (o._context.displayName || "Context") + ".Consumer";
|
|
59
|
-
case
|
|
60
|
-
var
|
|
61
|
-
return o = o.displayName, o || (o =
|
|
62
|
-
case
|
|
63
|
-
return
|
|
64
|
-
case
|
|
65
|
-
|
|
59
|
+
case g:
|
|
60
|
+
var w = o.render;
|
|
61
|
+
return o = o.displayName, o || (o = w.displayName || w.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
|
|
62
|
+
case H:
|
|
63
|
+
return w = o.displayName || null, w !== null ? w : n(o.type) || "Memo";
|
|
64
|
+
case O:
|
|
65
|
+
w = o._payload, o = o._init;
|
|
66
66
|
try {
|
|
67
|
-
return n(o(
|
|
67
|
+
return n(o(w));
|
|
68
68
|
} catch {
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -76,74 +76,74 @@ function ut() {
|
|
|
76
76
|
function r(o) {
|
|
77
77
|
try {
|
|
78
78
|
t(o);
|
|
79
|
-
var
|
|
79
|
+
var w = !1;
|
|
80
80
|
} catch {
|
|
81
|
-
|
|
81
|
+
w = !0;
|
|
82
82
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
return
|
|
87
|
-
|
|
83
|
+
if (w) {
|
|
84
|
+
w = console;
|
|
85
|
+
var T = w.error, Y = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
|
|
86
|
+
return T.call(
|
|
87
|
+
w,
|
|
88
88
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
89
|
-
|
|
89
|
+
Y
|
|
90
90
|
), t(o);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
if (o ===
|
|
95
|
-
if (typeof o == "object" && o !== null && o.$$typeof ===
|
|
93
|
+
function i(o) {
|
|
94
|
+
if (o === l) return "<>";
|
|
95
|
+
if (typeof o == "object" && o !== null && o.$$typeof === O)
|
|
96
96
|
return "<...>";
|
|
97
97
|
try {
|
|
98
|
-
var
|
|
99
|
-
return
|
|
98
|
+
var w = n(o);
|
|
99
|
+
return w ? "<" + w + ">" : "<...>";
|
|
100
100
|
} catch {
|
|
101
101
|
return "<...>";
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
var o =
|
|
104
|
+
function e() {
|
|
105
|
+
var o = q.A;
|
|
106
106
|
return o === null ? null : o.getOwner();
|
|
107
107
|
}
|
|
108
108
|
function s() {
|
|
109
109
|
return Error("react-stack-top-frame");
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
if (
|
|
113
|
-
var
|
|
114
|
-
if (
|
|
111
|
+
function u(o) {
|
|
112
|
+
if (L.call(o, "key")) {
|
|
113
|
+
var w = Object.getOwnPropertyDescriptor(o, "key").get;
|
|
114
|
+
if (w && w.isReactWarning) return !1;
|
|
115
115
|
}
|
|
116
116
|
return o.key !== void 0;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
function
|
|
120
|
-
|
|
118
|
+
function c(o, w) {
|
|
119
|
+
function T() {
|
|
120
|
+
E || (E = !0, console.error(
|
|
121
121
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
122
|
-
|
|
122
|
+
w
|
|
123
123
|
));
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
get:
|
|
125
|
+
T.isReactWarning = !0, Object.defineProperty(o, "key", {
|
|
126
|
+
get: T,
|
|
127
127
|
configurable: !0
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function a() {
|
|
131
131
|
var o = n(this.type);
|
|
132
|
-
return
|
|
132
|
+
return M[o] || (M[o] = !0, console.error(
|
|
133
133
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
134
134
|
)), o = this.props.ref, o !== void 0 ? o : null;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
var
|
|
136
|
+
function y(o, w, T, Y, Z, ut) {
|
|
137
|
+
var $ = T.ref;
|
|
138
138
|
return o = {
|
|
139
|
-
$$typeof:
|
|
139
|
+
$$typeof: b,
|
|
140
140
|
type: o,
|
|
141
|
-
key:
|
|
142
|
-
props:
|
|
143
|
-
_owner:
|
|
144
|
-
}, (
|
|
141
|
+
key: w,
|
|
142
|
+
props: T,
|
|
143
|
+
_owner: Y
|
|
144
|
+
}, ($ !== void 0 ? $ : null) !== null ? Object.defineProperty(o, "ref", {
|
|
145
145
|
enumerable: !1,
|
|
146
|
-
get:
|
|
146
|
+
get: a
|
|
147
147
|
}) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
|
|
148
148
|
configurable: !1,
|
|
149
149
|
enumerable: !1,
|
|
@@ -158,109 +158,214 @@ function ut() {
|
|
|
158
158
|
configurable: !1,
|
|
159
159
|
enumerable: !1,
|
|
160
160
|
writable: !0,
|
|
161
|
-
value:
|
|
161
|
+
value: Z
|
|
162
162
|
}), Object.defineProperty(o, "_debugTask", {
|
|
163
163
|
configurable: !1,
|
|
164
164
|
enumerable: !1,
|
|
165
165
|
writable: !0,
|
|
166
|
-
value:
|
|
166
|
+
value: ut
|
|
167
167
|
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
var
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
if (
|
|
174
|
-
for (
|
|
175
|
-
|
|
176
|
-
Object.freeze && Object.freeze(
|
|
169
|
+
function f(o, w, T, Y, Z, ut) {
|
|
170
|
+
var $ = w.children;
|
|
171
|
+
if ($ !== void 0)
|
|
172
|
+
if (Y)
|
|
173
|
+
if (R($)) {
|
|
174
|
+
for (Y = 0; Y < $.length; Y++)
|
|
175
|
+
P($[Y]);
|
|
176
|
+
Object.freeze && Object.freeze($);
|
|
177
177
|
} else
|
|
178
178
|
console.error(
|
|
179
179
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
180
180
|
);
|
|
181
|
-
else
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
var
|
|
185
|
-
return
|
|
181
|
+
else P($);
|
|
182
|
+
if (L.call(w, "key")) {
|
|
183
|
+
$ = n(o);
|
|
184
|
+
var lt = Object.keys(w).filter(function(X) {
|
|
185
|
+
return X !== "key";
|
|
186
186
|
});
|
|
187
|
-
|
|
187
|
+
Y = 0 < lt.length ? "{key: someKey, " + lt.join(": ..., ") + ": ...}" : "{key: someKey}", S[$ + Y] || (lt = 0 < lt.length ? "{" + lt.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
188
188
|
`A props object containing a "key" prop is being spread into JSX:
|
|
189
189
|
let props = %s;
|
|
190
190
|
<%s {...props} />
|
|
191
191
|
React keys must be passed directly to JSX without using spread:
|
|
192
192
|
let props = %s;
|
|
193
193
|
<%s key={someKey} {...props} />`,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
),
|
|
194
|
+
Y,
|
|
195
|
+
$,
|
|
196
|
+
lt,
|
|
197
|
+
$
|
|
198
|
+
), S[$ + Y] = !0);
|
|
199
199
|
}
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
for (var
|
|
203
|
-
|
|
204
|
-
} else
|
|
205
|
-
return
|
|
206
|
-
|
|
200
|
+
if ($ = null, T !== void 0 && (r(T), $ = "" + T), u(w) && (r(w.key), $ = "" + w.key), "key" in w) {
|
|
201
|
+
T = {};
|
|
202
|
+
for (var I in w)
|
|
203
|
+
I !== "key" && (T[I] = w[I]);
|
|
204
|
+
} else T = w;
|
|
205
|
+
return $ && c(
|
|
206
|
+
T,
|
|
207
207
|
typeof o == "function" ? o.displayName || o.name || "Unknown" : o
|
|
208
|
-
),
|
|
208
|
+
), y(
|
|
209
209
|
o,
|
|
210
|
+
$,
|
|
210
211
|
T,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
N
|
|
212
|
+
e(),
|
|
213
|
+
Z,
|
|
214
|
+
ut
|
|
215
215
|
);
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
h(o) ? o._store && (o._store.validated = 1) : typeof o == "object" && o !== null && o.$$typeof ===
|
|
217
|
+
function P(o) {
|
|
218
|
+
h(o) ? o._store && (o._store.validated = 1) : typeof o == "object" && o !== null && o.$$typeof === O && (o._payload.status === "fulfilled" ? h(o._payload.value) && o._payload.value._store && (o._payload.value._store.validated = 1) : o._store && (o._store.validated = 1));
|
|
219
219
|
}
|
|
220
220
|
function h(o) {
|
|
221
|
-
return typeof o == "object" && o !== null && o.$$typeof ===
|
|
221
|
+
return typeof o == "object" && o !== null && o.$$typeof === b;
|
|
222
222
|
}
|
|
223
|
-
var
|
|
223
|
+
var p = z, b = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.portal"), l = /* @__PURE__ */ Symbol.for("react.fragment"), m = /* @__PURE__ */ Symbol.for("react.strict_mode"), v = /* @__PURE__ */ Symbol.for("react.profiler"), C = /* @__PURE__ */ Symbol.for("react.consumer"), x = /* @__PURE__ */ Symbol.for("react.context"), g = /* @__PURE__ */ Symbol.for("react.forward_ref"), _ = /* @__PURE__ */ Symbol.for("react.suspense"), W = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), O = /* @__PURE__ */ Symbol.for("react.lazy"), F = /* @__PURE__ */ Symbol.for("react.activity"), U = /* @__PURE__ */ Symbol.for("react.client.reference"), q = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, R = Array.isArray, at = console.createTask ? console.createTask : function() {
|
|
224
224
|
return null;
|
|
225
225
|
};
|
|
226
|
-
|
|
226
|
+
p = {
|
|
227
227
|
react_stack_bottom_frame: function(o) {
|
|
228
228
|
return o();
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
-
var
|
|
232
|
-
|
|
231
|
+
var E, M = {}, ft = p.react_stack_bottom_frame.bind(
|
|
232
|
+
p,
|
|
233
233
|
s
|
|
234
|
-
)(),
|
|
235
|
-
|
|
236
|
-
var
|
|
237
|
-
return
|
|
234
|
+
)(), st = at(i(s)), S = {};
|
|
235
|
+
vt.Fragment = l, vt.jsx = function(o, w, T) {
|
|
236
|
+
var Y = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
237
|
+
return f(
|
|
238
238
|
o,
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
w,
|
|
240
|
+
T,
|
|
241
241
|
!1,
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
Y ? Error("react-stack-top-frame") : ft,
|
|
243
|
+
Y ? at(i(o)) : st
|
|
244
244
|
);
|
|
245
|
-
},
|
|
246
|
-
var
|
|
247
|
-
return
|
|
245
|
+
}, vt.jsxs = function(o, w, T) {
|
|
246
|
+
var Y = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
247
|
+
return f(
|
|
248
248
|
o,
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
w,
|
|
250
|
+
T,
|
|
251
251
|
!0,
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
Y ? Error("react-stack-top-frame") : ft,
|
|
253
|
+
Y ? at(i(o)) : st
|
|
254
254
|
);
|
|
255
255
|
};
|
|
256
|
-
})()),
|
|
256
|
+
})()), vt;
|
|
257
|
+
}
|
|
258
|
+
var _t;
|
|
259
|
+
function Dt() {
|
|
260
|
+
return _t || (_t = 1, process.env.NODE_ENV === "production" ? xt.exports = Ht() : xt.exports = Lt()), xt.exports;
|
|
261
|
+
}
|
|
262
|
+
var tt = Dt();
|
|
263
|
+
const Wt = 96, Mt = 25.4, zt = Mt / Wt, Xt = 72 / Wt, Bt = [
|
|
264
|
+
"boxShadow",
|
|
265
|
+
"textShadow",
|
|
266
|
+
// "opacity", // Ignored silently
|
|
267
|
+
"zIndex",
|
|
268
|
+
// "display", // Ignored silently
|
|
269
|
+
// "position", // Ignored silently
|
|
270
|
+
"float",
|
|
271
|
+
"overflow",
|
|
272
|
+
"cursor",
|
|
273
|
+
// "transition", // Ignored silently
|
|
274
|
+
"transform"
|
|
275
|
+
// "animation", // Ignored silently
|
|
276
|
+
], Nt = "block", Ut = "inline";
|
|
277
|
+
function it(n) {
|
|
278
|
+
if (!n || !n.endsWith("px")) return;
|
|
279
|
+
const t = parseFloat(n);
|
|
280
|
+
return isNaN(t) ? void 0 : t * zt;
|
|
281
|
+
}
|
|
282
|
+
function qt(n) {
|
|
283
|
+
if (!n || !n.endsWith("px")) return;
|
|
284
|
+
const t = parseFloat(n);
|
|
285
|
+
return isNaN(t) ? void 0 : t * Xt;
|
|
286
|
+
}
|
|
287
|
+
function Rt(n) {
|
|
288
|
+
if (!(!n || n === "rgba(0, 0, 0, 0)" || n === "transparent"))
|
|
289
|
+
return n;
|
|
290
|
+
}
|
|
291
|
+
function Vt(n) {
|
|
292
|
+
if (n === "left" || n === "center" || n === "right" || n === "justify")
|
|
293
|
+
return n;
|
|
294
|
+
}
|
|
295
|
+
function Gt(n) {
|
|
296
|
+
const t = it(n.paddingTop), r = it(n.paddingRight), i = it(n.paddingBottom), e = it(n.paddingLeft);
|
|
297
|
+
if (!(t === void 0 && r === void 0 && i === void 0 && e === void 0))
|
|
298
|
+
return {
|
|
299
|
+
top: t ?? 0,
|
|
300
|
+
right: r ?? 0,
|
|
301
|
+
bottom: i ?? 0,
|
|
302
|
+
left: e ?? 0
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function Jt(n) {
|
|
306
|
+
const t = it(n.marginTop), r = it(n.marginRight), i = it(n.marginBottom), e = it(n.marginLeft);
|
|
307
|
+
if (!(t === void 0 && r === void 0 && i === void 0 && e === void 0))
|
|
308
|
+
return {
|
|
309
|
+
top: t ?? 0,
|
|
310
|
+
right: r ?? 0,
|
|
311
|
+
bottom: i ?? 0,
|
|
312
|
+
left: e ?? 0
|
|
313
|
+
};
|
|
257
314
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return
|
|
315
|
+
function wt(n, t) {
|
|
316
|
+
const r = Ot(null);
|
|
317
|
+
return { ref: r, computeStyle: () => {
|
|
318
|
+
if (!r.current) return {};
|
|
319
|
+
const e = window.getComputedStyle(r.current);
|
|
320
|
+
Bt.forEach((x) => {
|
|
321
|
+
const g = e[x];
|
|
322
|
+
if (g && g !== "none" && g !== "auto" && g !== "0px" && g !== "normal" && g !== "visible" && g !== "static") {
|
|
323
|
+
if (x === "display" && (g === Nt || g === Ut))
|
|
324
|
+
return;
|
|
325
|
+
console.warn(
|
|
326
|
+
`react-vector-pdf: CSS property '${x}' with value '${g}' is not supported and will be ignored.`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
const s = {}, u = qt(e.fontSize);
|
|
331
|
+
u && (s.fontSize = u);
|
|
332
|
+
const c = e.fontWeight;
|
|
333
|
+
e.fontStyle === "italic" ? c === "bold" || c === "700" || parseInt(c) >= 700 ? s.fontStyle = "bolditalic" : s.fontStyle = "italic" : c === "bold" || c === "700" || parseInt(c) >= 700 ? s.fontStyle = "bold" : s.fontStyle = "normal";
|
|
334
|
+
const y = Rt(e.color);
|
|
335
|
+
y && (s.color = y);
|
|
336
|
+
const f = Vt(e.textAlign);
|
|
337
|
+
f && (s.align = f);
|
|
338
|
+
const h = (() => {
|
|
339
|
+
if (e.lineHeight === "normal") return;
|
|
340
|
+
const x = parseFloat(e.lineHeight), g = parseFloat(e.fontSize);
|
|
341
|
+
if (!isNaN(x) && !isNaN(g) && g > 0)
|
|
342
|
+
return x / g;
|
|
343
|
+
})();
|
|
344
|
+
h && (s.lineHeight = h);
|
|
345
|
+
const p = Rt(e.backgroundColor);
|
|
346
|
+
p && (s.fillColor = p);
|
|
347
|
+
const b = Rt(e.borderColor);
|
|
348
|
+
b && (s.borderColor = b);
|
|
349
|
+
const d = it(e.borderTopWidth);
|
|
350
|
+
d && (s.borderWidth = d);
|
|
351
|
+
const l = Gt(e);
|
|
352
|
+
l && (s.padding = l);
|
|
353
|
+
const m = Jt(e);
|
|
354
|
+
if (m && (s.margin = m), e.width && e.width !== "auto") {
|
|
355
|
+
const x = it(e.width);
|
|
356
|
+
x && x > 0 && (s.width = x);
|
|
357
|
+
}
|
|
358
|
+
if (e.height && e.height !== "auto") {
|
|
359
|
+
const x = it(e.height);
|
|
360
|
+
x && x > 0 && (s.height = x);
|
|
361
|
+
}
|
|
362
|
+
const v = it(e.gap) ?? it(e.rowGap);
|
|
363
|
+
v && (s.gap = v);
|
|
364
|
+
const C = it(e.borderRadius);
|
|
365
|
+
return C && (s.radius = C), s;
|
|
366
|
+
} };
|
|
261
367
|
}
|
|
262
|
-
|
|
263
|
-
function tt(n) {
|
|
368
|
+
function St(n) {
|
|
264
369
|
return !n && n !== 0 ? { top: 0, right: 0, bottom: 0, left: 0 } : typeof n == "number" ? { top: n, right: n, bottom: n, left: n } : {
|
|
265
370
|
top: n.top ?? 0,
|
|
266
371
|
right: n.right ?? 0,
|
|
@@ -268,33 +373,33 @@ function tt(n) {
|
|
|
268
373
|
left: n.left ?? 0
|
|
269
374
|
};
|
|
270
375
|
}
|
|
271
|
-
function
|
|
376
|
+
function gt(n) {
|
|
272
377
|
if (!n) return null;
|
|
273
378
|
if (n.startsWith("#")) {
|
|
274
379
|
const r = n.replace("#", "");
|
|
275
380
|
if (r.length === 3) {
|
|
276
|
-
const
|
|
277
|
-
return [
|
|
381
|
+
const i = parseInt(r[0] + r[0], 16), e = parseInt(r[1] + r[1], 16), s = parseInt(r[2] + r[2], 16);
|
|
382
|
+
return [i, e, s, 1];
|
|
278
383
|
}
|
|
279
384
|
if (r.length === 6) {
|
|
280
|
-
const
|
|
281
|
-
return [
|
|
385
|
+
const i = parseInt(r.slice(0, 2), 16), e = parseInt(r.slice(2, 4), 16), s = parseInt(r.slice(4, 6), 16);
|
|
386
|
+
return [i, e, s, 1];
|
|
282
387
|
}
|
|
283
388
|
if (r.length === 8) {
|
|
284
|
-
const
|
|
285
|
-
return [
|
|
389
|
+
const i = parseInt(r.slice(0, 2), 16), e = parseInt(r.slice(2, 4), 16), s = parseInt(r.slice(4, 6), 16), u = parseInt(r.slice(6, 8), 16) / 255;
|
|
390
|
+
return [i, e, s, u];
|
|
286
391
|
}
|
|
287
392
|
}
|
|
288
393
|
const t = n.match(
|
|
289
394
|
/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
|
|
290
395
|
);
|
|
291
396
|
if (t) {
|
|
292
|
-
const r = parseInt(t[1], 10),
|
|
293
|
-
return [r,
|
|
397
|
+
const r = parseInt(t[1], 10), i = parseInt(t[2], 10), e = parseInt(t[3], 10), s = t[4] !== void 0 ? parseFloat(t[4]) : 1;
|
|
398
|
+
return [r, i, e, s];
|
|
294
399
|
}
|
|
295
400
|
return null;
|
|
296
401
|
}
|
|
297
|
-
function
|
|
402
|
+
function It(n, t = !0) {
|
|
298
403
|
if (n <= 0) return String(n);
|
|
299
404
|
const r = [
|
|
300
405
|
[1e3, "M"],
|
|
@@ -311,34 +416,31 @@ function it(n, t = !0) {
|
|
|
311
416
|
[4, "IV"],
|
|
312
417
|
[1, "I"]
|
|
313
418
|
];
|
|
314
|
-
let
|
|
315
|
-
for (const [s,
|
|
316
|
-
for (;
|
|
317
|
-
|
|
318
|
-
return t ?
|
|
419
|
+
let i = n, e = "";
|
|
420
|
+
for (const [s, u] of r)
|
|
421
|
+
for (; i >= s; )
|
|
422
|
+
e += u, i -= s;
|
|
423
|
+
return t ? e : e.toLowerCase();
|
|
319
424
|
}
|
|
320
|
-
function
|
|
425
|
+
function Pt(n, t) {
|
|
321
426
|
return !t || t === "all" ? !0 : t === "first-only" ? n === 1 : t === "except-first" ? n > 1 : Array.isArray(t) ? t.includes(n) : !0;
|
|
322
427
|
}
|
|
323
|
-
class
|
|
428
|
+
class Qt {
|
|
324
429
|
constructor(t = {}) {
|
|
325
430
|
this.cursorX = 0, this.cursorY = 0, this.contentWidth = 0, this.reservedBottomHeight = 0, this.margin = { top: 15, right: 15, bottom: 15, left: 15 }, this.defaultFont = {
|
|
326
431
|
name: void 0,
|
|
327
432
|
style: "normal",
|
|
328
433
|
size: 12
|
|
329
|
-
}, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.generation = 0, this.recordingStack = [], this.recurringItems = [], this.indentStack = [], this.currentIndent = { left: 0, right: 0 }, this.options = t, this.margin = t.margin ?? this.margin, this.defaultFont = {
|
|
434
|
+
}, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.generation = 0, this.recordingStack = [], this.recurringItems = [], this.indentStack = [], this.currentIndent = { left: 0, right: 0 }, this.verticalPaddingStack = [], this.options = t, this.margin = t.margin ?? this.margin, this.defaultFont = {
|
|
330
435
|
name: t.font?.name,
|
|
331
436
|
style: t.font?.style ?? "normal",
|
|
332
437
|
size: t.font?.size ?? 12
|
|
333
|
-
}, this.defaultColor = t.color ?? this.defaultColor, this.defaultLineHeight = t.lineHeight ?? this.defaultLineHeight, this.pdf = new
|
|
438
|
+
}, this.defaultColor = t.color ?? this.defaultColor, this.defaultLineHeight = t.lineHeight ?? this.defaultLineHeight, this.pdf = new Ft({
|
|
334
439
|
unit: t.unit ?? "mm",
|
|
335
440
|
format: t.format ?? "a4",
|
|
336
441
|
orientation: t.orientation ?? "p"
|
|
337
442
|
}), this.pageWidth = this.pdf.internal.pageSize.getWidth(), this.pageHeight = this.pdf.internal.pageSize.getHeight(), this.resetFlowCursor(), this.applyBaseFont();
|
|
338
443
|
}
|
|
339
|
-
// ... getters ...
|
|
340
|
-
// (Keeping getters omitted for brevity in replace block if possible, but replace_file_content needs context)
|
|
341
|
-
// I will target the variable declaration area specifically.
|
|
342
444
|
// Implementation of Stack Methods
|
|
343
445
|
startRecording() {
|
|
344
446
|
this.recordingStack.push([]);
|
|
@@ -368,10 +470,30 @@ class gt {
|
|
|
368
470
|
return this.pageWidth - this.margin.right;
|
|
369
471
|
}
|
|
370
472
|
get contentTop() {
|
|
371
|
-
return this.margin.top;
|
|
473
|
+
return this.margin.top + this.currentVerticalPadding.top;
|
|
372
474
|
}
|
|
373
475
|
get contentBottom() {
|
|
374
|
-
return this.pageHeight - this.margin.bottom - this.
|
|
476
|
+
return this.pageHeight - this.margin.bottom - this.currentVerticalPadding.bottom;
|
|
477
|
+
}
|
|
478
|
+
pushIndent(t, r) {
|
|
479
|
+
this.indentStack.push({ ...this.currentIndent }), this.currentIndent.left += t, this.currentIndent.right += r, this.cursorX += t, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right;
|
|
480
|
+
}
|
|
481
|
+
popIndent() {
|
|
482
|
+
const t = this.indentStack.pop();
|
|
483
|
+
t && (this.currentIndent = t, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Returns the top Y position for content on a given page, accounting for recurring items.
|
|
487
|
+
* This is useful for drawing background boxes that shouldn't overlap headers.
|
|
488
|
+
*/
|
|
489
|
+
getSafeContentTop(t) {
|
|
490
|
+
let r = this.margin.top;
|
|
491
|
+
for (const i of this.recurringItems)
|
|
492
|
+
if (Pt(t, i.scope) && i.y <= r + 10) {
|
|
493
|
+
const e = i.y + i.height;
|
|
494
|
+
e > r && (r = e);
|
|
495
|
+
}
|
|
496
|
+
return r;
|
|
375
497
|
}
|
|
376
498
|
get contentHeight() {
|
|
377
499
|
return this.contentBottom - this.contentTop;
|
|
@@ -385,26 +507,33 @@ class gt {
|
|
|
385
507
|
get baseLineHeight() {
|
|
386
508
|
return this.defaultLineHeight;
|
|
387
509
|
}
|
|
388
|
-
|
|
389
|
-
this.
|
|
510
|
+
pushVerticalPadding(t, r) {
|
|
511
|
+
this.verticalPaddingStack.push({ top: t, bottom: r }), this.cursorY += t;
|
|
390
512
|
}
|
|
391
|
-
|
|
392
|
-
|
|
513
|
+
popVerticalPadding() {
|
|
514
|
+
const t = this.verticalPaddingStack.pop();
|
|
515
|
+
t && (this.cursorY += t.bottom);
|
|
393
516
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
517
|
+
get currentVerticalPadding() {
|
|
518
|
+
let t = 0, r = 0;
|
|
519
|
+
for (const i of this.verticalPaddingStack)
|
|
520
|
+
t += i.top, r += i.bottom;
|
|
521
|
+
return { top: t, bottom: r };
|
|
397
522
|
}
|
|
523
|
+
// Legacy support or override if needed, but we prefer stack
|
|
524
|
+
setReservedHeight(t) {
|
|
525
|
+
}
|
|
526
|
+
// ...
|
|
398
527
|
resetFlowCursor() {
|
|
399
|
-
this.cursorX = this.margin.left + this.currentIndent.left, this.cursorY = this.margin.top, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right;
|
|
528
|
+
this.cursorX = this.margin.left + this.currentIndent.left, this.cursorY = this.margin.top + this.currentVerticalPadding.top, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right - this.currentIndent.left - this.currentIndent.right;
|
|
400
529
|
}
|
|
401
530
|
reset() {
|
|
402
|
-
if (this.pdf = new
|
|
531
|
+
if (this.pdf = new Ft({
|
|
403
532
|
unit: this.options.unit ?? "mm",
|
|
404
533
|
format: this.options.format ?? "a4",
|
|
405
534
|
orientation: this.options.orientation ?? "p"
|
|
406
|
-
}), this.generation++, this.cursorX = 0, this.cursorY = 0, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.resetFlowCursor(), this.applyBaseFont(), this.options.color) {
|
|
407
|
-
const t =
|
|
535
|
+
}), this.generation++, this.cursorX = 0, this.cursorY = 0, this.verticalPaddingStack = [], this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.indentStack = [], this.currentIndent = { left: 0, right: 0 }, this.recordingStack = [], this.resetFlowCursor(), this.applyBaseFont(), this.options.color) {
|
|
536
|
+
const t = gt(this.options.color);
|
|
408
537
|
t && this.pdf.setTextColor(...t);
|
|
409
538
|
}
|
|
410
539
|
this.recurringItems = [];
|
|
@@ -413,20 +542,22 @@ class gt {
|
|
|
413
542
|
this.headerDrawer = t, this.footerDrawer = r;
|
|
414
543
|
}
|
|
415
544
|
applyBaseFont() {
|
|
416
|
-
const t = this.defaultFont.name ?? this.pdf.getFont().fontName, r = this.defaultFont.style,
|
|
545
|
+
const t = this.defaultFont.name ?? this.pdf.getFont().fontName, r = this.defaultFont.style, i = this.defaultFont.size, e = this.defaultColor;
|
|
417
546
|
this.drawOp(() => {
|
|
418
|
-
this.pdf.setFont(t, r), this.pdf.setFontSize(
|
|
419
|
-
const s =
|
|
547
|
+
this.pdf.setFont(t, r), this.pdf.setFontSize(i);
|
|
548
|
+
const s = gt(e);
|
|
420
549
|
s && this.pdf.setTextColor(...s);
|
|
421
550
|
});
|
|
422
551
|
}
|
|
423
552
|
addPage() {
|
|
553
|
+
const t = this.margin.left + this.currentIndent.left;
|
|
424
554
|
this.drawOp(() => {
|
|
425
555
|
this.pdf.addPage();
|
|
426
556
|
}), this.resetFlowCursor();
|
|
427
|
-
const
|
|
428
|
-
for (const
|
|
429
|
-
|
|
557
|
+
const r = this.getPageCount();
|
|
558
|
+
for (const i of this.recurringItems)
|
|
559
|
+
Pt(r, i.scope) && (i.draw(), i.y + i.height > this.cursorY && (this.cursorY = i.y + i.height));
|
|
560
|
+
this.cursorX = t;
|
|
430
561
|
}
|
|
431
562
|
ensureSpace(t) {
|
|
432
563
|
if (this.cursorY + t > this.contentBottom) {
|
|
@@ -434,11 +565,11 @@ class gt {
|
|
|
434
565
|
return;
|
|
435
566
|
}
|
|
436
567
|
const r = this.getPageCount();
|
|
437
|
-
let
|
|
438
|
-
for (;
|
|
439
|
-
|
|
440
|
-
for (const
|
|
441
|
-
if (
|
|
568
|
+
let i = !0;
|
|
569
|
+
for (; i; ) {
|
|
570
|
+
i = !1;
|
|
571
|
+
for (const e of this.recurringItems)
|
|
572
|
+
if (Pt(r, e.scope) && this.cursorY < e.y + e.height && this.cursorY + t > e.y && (this.cursorY = e.y + e.height, i = !0, this.cursorY + t > this.contentBottom)) {
|
|
442
573
|
this.addPage();
|
|
443
574
|
return;
|
|
444
575
|
}
|
|
@@ -446,89 +577,100 @@ class gt {
|
|
|
446
577
|
}
|
|
447
578
|
setTextStyle(t) {
|
|
448
579
|
if (!t) return;
|
|
449
|
-
const r = t.fontSize,
|
|
580
|
+
const r = t.fontSize, i = t.fontStyle, e = t.color;
|
|
450
581
|
this.drawOp(() => {
|
|
451
|
-
if (r && this.pdf.setFontSize(r),
|
|
582
|
+
if (r && this.pdf.setFontSize(r), i) {
|
|
452
583
|
const s = this.pdf.getFont().fontName;
|
|
453
|
-
this.pdf.setFont(s,
|
|
584
|
+
this.pdf.setFont(s, i);
|
|
454
585
|
}
|
|
455
|
-
if (
|
|
456
|
-
const s =
|
|
586
|
+
if (e) {
|
|
587
|
+
const s = gt(e);
|
|
457
588
|
s && (this.pdf.setTextColor(s[0], s[1], s[2]), s[3] !== void 0 ? this.pdf.setGState(
|
|
458
589
|
new this.pdf.GState({ opacity: s[3] })
|
|
459
590
|
) : this.pdf.setGState(new this.pdf.GState({ opacity: 1 })));
|
|
460
591
|
}
|
|
461
592
|
});
|
|
462
593
|
}
|
|
463
|
-
textRaw(t, r,
|
|
464
|
-
this.setTextStyle(
|
|
465
|
-
const
|
|
466
|
-
typeof s == "number" && (
|
|
467
|
-
this.pdf.text(t, r,
|
|
594
|
+
textRaw(t, r, i, e, s, u = "left") {
|
|
595
|
+
this.setTextStyle(e);
|
|
596
|
+
const c = { align: u };
|
|
597
|
+
typeof s == "number" && (c.maxWidth = s), this.drawOp(() => {
|
|
598
|
+
this.pdf.text(t, r, i, c);
|
|
468
599
|
}), this.applyBaseFont();
|
|
469
600
|
}
|
|
470
|
-
box(t, r,
|
|
471
|
-
const
|
|
601
|
+
box(t, r, i, e, s) {
|
|
602
|
+
const u = s ?? {};
|
|
472
603
|
this.drawOp(() => {
|
|
473
|
-
if (
|
|
474
|
-
if (
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
new this.pdf.GState({ opacity:
|
|
478
|
-
), this.pdf.setFillColor(
|
|
604
|
+
if (u.borderWidth || u.borderColor || u.fillColor) {
|
|
605
|
+
if (u.fillColor) {
|
|
606
|
+
const a = gt(u.fillColor);
|
|
607
|
+
a && (a[3] !== void 0 && this.pdf.setGState(
|
|
608
|
+
new this.pdf.GState({ opacity: a[3] })
|
|
609
|
+
), this.pdf.setFillColor(a[0], a[1], a[2]));
|
|
479
610
|
}
|
|
480
|
-
if ((
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
new this.pdf.GState({ opacity:
|
|
484
|
-
), this.pdf.setDrawColor(
|
|
611
|
+
if ((u.borderWidth || u.borderColor) && (u.borderWidth && this.pdf.setLineWidth(u.borderWidth), u.borderColor)) {
|
|
612
|
+
const a = gt(u.borderColor);
|
|
613
|
+
a && (a[3] !== void 0 && this.pdf.setGState(
|
|
614
|
+
new this.pdf.GState({ opacity: a[3] })
|
|
615
|
+
), this.pdf.setDrawColor(a[0], a[1], a[2]));
|
|
485
616
|
}
|
|
486
|
-
let
|
|
487
|
-
|
|
617
|
+
let c = "";
|
|
618
|
+
u.fillColor && (c += "F"), (u.borderWidth || u.borderColor) && (c += "D"), c && (u.radius ? this.pdf.roundedRect(t, r, i, e, u.radius, u.radius, c) : this.pdf.rect(t, r, i, e, c)), this.pdf.setLineWidth(0.2), this.pdf.setDrawColor(0, 0, 0), this.pdf.setGState(new this.pdf.GState({ opacity: 1 }));
|
|
488
619
|
}
|
|
489
620
|
});
|
|
490
621
|
}
|
|
491
|
-
line(t, r,
|
|
622
|
+
line(t, r, i, e) {
|
|
492
623
|
this.drawOp(() => {
|
|
493
|
-
this.pdf.line(t, r,
|
|
624
|
+
this.pdf.line(t, r, i, e);
|
|
494
625
|
});
|
|
495
626
|
}
|
|
496
627
|
async imageFromUrl(t, r = {}) {
|
|
497
|
-
const
|
|
628
|
+
const i = (async () => {
|
|
498
629
|
try {
|
|
499
|
-
const { dataUrl:
|
|
500
|
-
let
|
|
501
|
-
|
|
502
|
-
const h =
|
|
503
|
-
let
|
|
504
|
-
if (r.y === void 0 &&
|
|
505
|
-
const
|
|
506
|
-
|
|
630
|
+
const { dataUrl: e, width: s, height: u } = await this.loadImageAsDataURL(t), c = 0.264583, a = s * c, y = u * c;
|
|
631
|
+
let f = r.w, P = r.h;
|
|
632
|
+
f === void 0 && P === void 0 ? (f = a, P = y) : f === void 0 && P !== void 0 ? f = P * (a / y) : P === void 0 && f !== void 0 && (P = f * (y / a));
|
|
633
|
+
const h = f ?? a, p = P ?? y;
|
|
634
|
+
let b = r.x, d = r.y ?? this.cursorY;
|
|
635
|
+
if (r.y === void 0 && d + p > this.contentBottom && (this.addPage(), d = this.cursorY), b === void 0) {
|
|
636
|
+
const l = r.align ?? "left";
|
|
637
|
+
l === "left" ? b = this.contentLeft : l === "center" ? b = (this.contentLeft + this.contentRight) / 2 - h / 2 : l === "right" && (b = this.contentRight - h);
|
|
638
|
+
}
|
|
639
|
+
if (r.radius && r.radius > 0) {
|
|
640
|
+
const l = r.radius, m = b, v = d, C = h, x = p, _ = l * 0.551784;
|
|
641
|
+
this.pdf.saveGraphicsState(), this.pdf.moveTo(m + l, v), this.pdf.lineTo(m + C - l, v), this.pdf.curveTo(m + C - l + _, v, m + C, v + l - _, m + C, v + l), this.pdf.lineTo(m + C, v + x - l), this.pdf.curveTo(
|
|
642
|
+
m + C,
|
|
643
|
+
v + x - l + _,
|
|
644
|
+
m + C - l + _,
|
|
645
|
+
v + x,
|
|
646
|
+
m + C - l,
|
|
647
|
+
v + x
|
|
648
|
+
), this.pdf.lineTo(m + l, v + x), this.pdf.curveTo(m + l - _, v + x, m, v + x - l + _, m, v + x - l), this.pdf.lineTo(m, v + l), this.pdf.curveTo(m, v + l - _, m + l - _, v, m + l, v), this.pdf.clip();
|
|
507
649
|
}
|
|
508
650
|
return this.pdf.addImage(
|
|
509
|
-
|
|
651
|
+
e,
|
|
510
652
|
r.mime ?? "PNG",
|
|
511
|
-
|
|
512
|
-
|
|
653
|
+
b,
|
|
654
|
+
d,
|
|
513
655
|
h,
|
|
514
|
-
|
|
515
|
-
), { width: h, height:
|
|
516
|
-
} catch (
|
|
517
|
-
return console.error("Failed to load image", t,
|
|
656
|
+
p
|
|
657
|
+
), r.radius && r.radius > 0 && this.pdf.restoreGraphicsState(), { width: h, height: p, x: b, y: d };
|
|
658
|
+
} catch (e) {
|
|
659
|
+
return console.error("Failed to load image", t, e), { width: 0, height: 0, x: 0, y: 0 };
|
|
518
660
|
}
|
|
519
661
|
})();
|
|
520
|
-
return this.registerTask(
|
|
662
|
+
return this.registerTask(i), i;
|
|
521
663
|
}
|
|
522
664
|
queueOperation(t) {
|
|
523
|
-
const r = this.generation,
|
|
665
|
+
const r = this.generation, i = this.opQueue.then(async () => {
|
|
524
666
|
if (this.generation === r)
|
|
525
667
|
try {
|
|
526
668
|
await t();
|
|
527
|
-
} catch (
|
|
528
|
-
console.error("Operation failed",
|
|
669
|
+
} catch (e) {
|
|
670
|
+
console.error("Operation failed", e);
|
|
529
671
|
}
|
|
530
672
|
});
|
|
531
|
-
this.opQueue =
|
|
673
|
+
this.opQueue = i, this.registerTask(i);
|
|
532
674
|
}
|
|
533
675
|
registerTask(t) {
|
|
534
676
|
this.pendingTasks.add(t), t.finally(() => {
|
|
@@ -539,34 +681,34 @@ class gt {
|
|
|
539
681
|
await Promise.all(this.pendingTasks), await this.opQueue;
|
|
540
682
|
}
|
|
541
683
|
loadImageAsDataURL(t) {
|
|
542
|
-
return new Promise((r,
|
|
543
|
-
const
|
|
544
|
-
|
|
684
|
+
return new Promise((r, i) => {
|
|
685
|
+
const e = new Image();
|
|
686
|
+
e.crossOrigin = "anonymous", e.onload = () => {
|
|
545
687
|
const s = document.createElement("canvas");
|
|
546
|
-
s.width =
|
|
547
|
-
const
|
|
548
|
-
if (!
|
|
549
|
-
|
|
688
|
+
s.width = e.width, s.height = e.height;
|
|
689
|
+
const u = s.getContext("2d");
|
|
690
|
+
if (!u) return i(new Error("Canvas 2D context not available"));
|
|
691
|
+
u.drawImage(e, 0, 0), r({
|
|
550
692
|
dataUrl: s.toDataURL("image/png"),
|
|
551
|
-
width:
|
|
552
|
-
height:
|
|
693
|
+
width: e.width,
|
|
694
|
+
height: e.height
|
|
553
695
|
});
|
|
554
|
-
},
|
|
696
|
+
}, e.onerror = (s) => i(s), e.src = t;
|
|
555
697
|
});
|
|
556
698
|
}
|
|
557
|
-
paragraph(t, r,
|
|
558
|
-
const
|
|
699
|
+
paragraph(t, r, i) {
|
|
700
|
+
const e = i ?? this.contentWidth;
|
|
559
701
|
this.setTextStyle(r);
|
|
560
|
-
const s = r?.lineHeight ?? this.defaultLineHeight,
|
|
561
|
-
let
|
|
562
|
-
return
|
|
563
|
-
this.cursorY +
|
|
564
|
-
const h = this.cursorY +
|
|
565
|
-
let
|
|
566
|
-
|
|
567
|
-
this.pdf.text(
|
|
568
|
-
}), this.cursorY +=
|
|
569
|
-
}), this.
|
|
702
|
+
const s = r?.lineHeight ?? this.defaultLineHeight, u = r?.fontSize ?? this.defaultFont.size, c = u * s * 0.3528, a = this.pdf.splitTextToSize(t, e), y = r?.align ?? "left";
|
|
703
|
+
let f = 0;
|
|
704
|
+
return a.forEach((P) => {
|
|
705
|
+
this.cursorY + c > this.contentBottom && this.addPage();
|
|
706
|
+
const h = u * 0.3528, p = (c - h) / 2, b = this.cursorY + h + p;
|
|
707
|
+
let d = this.cursorX;
|
|
708
|
+
y === "center" ? d = this.cursorX + e / 2 : y === "right" && (d = this.cursorX + e), this.drawOp(() => {
|
|
709
|
+
this.pdf.text(P, d, b, { align: y, maxWidth: e });
|
|
710
|
+
}), this.cursorY += c, f += c;
|
|
711
|
+
}), this.applyBaseFont(), f;
|
|
570
712
|
}
|
|
571
713
|
moveCursor(t, r) {
|
|
572
714
|
this.cursorX += t, this.cursorY += r;
|
|
@@ -591,24 +733,26 @@ class gt {
|
|
|
591
733
|
this.pdf.setPage(t);
|
|
592
734
|
}
|
|
593
735
|
}
|
|
594
|
-
measureText(t, r,
|
|
736
|
+
measureText(t, r, i) {
|
|
595
737
|
this.setTextStyle(r);
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
598
|
-
const
|
|
738
|
+
const e = r?.fontSize ?? this.defaultFont.size, s = r?.lineHeight ?? this.defaultLineHeight, u = e * s * 0.3528;
|
|
739
|
+
if (i) {
|
|
740
|
+
const c = this.pdf.splitTextToSize(t, i);
|
|
599
741
|
return {
|
|
600
|
-
width:
|
|
601
|
-
height:
|
|
742
|
+
width: i,
|
|
743
|
+
height: c.length * u
|
|
602
744
|
};
|
|
603
745
|
} else {
|
|
604
|
-
const
|
|
605
|
-
return { width:
|
|
746
|
+
const c = this.pdf.getTextDimensions(t);
|
|
747
|
+
return { width: c.w, height: c.h };
|
|
606
748
|
}
|
|
607
749
|
}
|
|
608
750
|
setMetadata(t) {
|
|
609
|
-
t.title && this.pdf.setDocumentProperties({ title: t.title }), t.author && this.pdf.setDocumentProperties({ author: t.author }), t.subject && this.pdf.setDocumentProperties({ subject: t.subject }), t.keywords && this.pdf.setDocumentProperties({
|
|
751
|
+
t.title && this.pdf.setDocumentProperties({ title: t.title }), t.author && this.pdf.setDocumentProperties({ author: t.author }), t.subject && this.pdf.setDocumentProperties({ subject: t.subject }), t.keywords && (Array.isArray(t.keywords) ? this.pdf.setDocumentProperties({
|
|
610
752
|
keywords: t.keywords.join(", ")
|
|
611
|
-
})
|
|
753
|
+
}) : this.pdf.setDocumentProperties({
|
|
754
|
+
keywords: String(t.keywords)
|
|
755
|
+
}));
|
|
612
756
|
}
|
|
613
757
|
save(t) {
|
|
614
758
|
this.applyHeaderFooter(), this.pdf.save(t);
|
|
@@ -620,488 +764,697 @@ class gt {
|
|
|
620
764
|
* Injects a filled rectangle at the beginning of the page stream.
|
|
621
765
|
* This ensures the background is drawn BEHIND all other content on the page.
|
|
622
766
|
*/
|
|
623
|
-
injectFill(t, r,
|
|
624
|
-
const s = this.pdf.internal.pages
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
767
|
+
injectFill(t, r, i, e) {
|
|
768
|
+
const s = this.pdf.internal.pages;
|
|
769
|
+
let u = s[t];
|
|
770
|
+
if (!u && s[t - 1] && (u = s[t - 1]), !u) return;
|
|
771
|
+
const c = this.pdf.internal.scaleFactor, a = this.pdf.internal.pageSize.getHeight(), y = r.x * c, f = r.h * c, P = r.w * c, h = (a - (r.y + r.h)) * c, p = gt(i);
|
|
772
|
+
if (!p) return;
|
|
773
|
+
const b = ["q"];
|
|
774
|
+
b.push(
|
|
775
|
+
`${(p[0] / 255).toFixed(3)} ${(p[1] / 255).toFixed(3)} ${(p[2] / 255).toFixed(3)} rg`
|
|
776
|
+
);
|
|
777
|
+
let d = !1, l = 0, m = 0, v = 0, C = 0;
|
|
778
|
+
if (typeof e == "number" && e > 0 ? (d = !0, l = m = v = C = e * c) : typeof e == "object" && (e.tl || e.tr || e.br || e.bl) && (d = !0, l = (e.tl ?? 0) * c, m = (e.tr ?? 0) * c, v = (e.br ?? 0) * c, C = (e.bl ?? 0) * c), d) {
|
|
779
|
+
const g = y, _ = y + P, W = h, H = h + f;
|
|
780
|
+
if (b.push(`${(g + l).toFixed(2)} ${H.toFixed(2)} m`), b.push(`${(_ - m).toFixed(2)} ${H.toFixed(2)} l`), m > 0) {
|
|
781
|
+
const O = m * 0.551784;
|
|
782
|
+
b.push(
|
|
783
|
+
`${(_ - m + O).toFixed(2)} ${H.toFixed(2)} ${_.toFixed(
|
|
784
|
+
2
|
|
785
|
+
)} ${(H - m + O).toFixed(2)} ${_.toFixed(2)} ${(H - m).toFixed(2)} c`
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
if (b.push(`${_.toFixed(2)} ${(W + v).toFixed(2)} l`), v > 0) {
|
|
789
|
+
const O = v * 0.551784;
|
|
790
|
+
b.push(
|
|
791
|
+
`${_.toFixed(2)} ${(W + v - O).toFixed(2)} ${(_ - v + O).toFixed(2)} ${W.toFixed(2)} ${(_ - v).toFixed(
|
|
792
|
+
2
|
|
793
|
+
)} ${W.toFixed(2)} c`
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
if (b.push(`${(g + C).toFixed(2)} ${W.toFixed(2)} l`), C > 0) {
|
|
797
|
+
const O = C * 0.551784;
|
|
798
|
+
b.push(
|
|
799
|
+
`${(g + C - O).toFixed(2)} ${W.toFixed(2)} ${g.toFixed(
|
|
800
|
+
2
|
|
801
|
+
)} ${(W + C - O).toFixed(2)} ${g.toFixed(2)} ${(W + C).toFixed(2)} c`
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
if (b.push(`${g.toFixed(2)} ${(H - l).toFixed(2)} l`), l > 0) {
|
|
805
|
+
const O = l * 0.551784;
|
|
806
|
+
b.push(
|
|
807
|
+
`${g.toFixed(2)} ${(H - l + O).toFixed(2)} ${(g + l - O).toFixed(2)} ${H.toFixed(2)} ${(g + l).toFixed(
|
|
808
|
+
2
|
|
809
|
+
)} ${H.toFixed(2)} c`
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
b.push("f");
|
|
813
|
+
} else
|
|
814
|
+
b.push(
|
|
815
|
+
`${y.toFixed(2)} ${h.toFixed(2)} ${P.toFixed(2)} ${f.toFixed(2)} re f`
|
|
816
|
+
);
|
|
817
|
+
b.push("Q"), u && Array.isArray(u) && u.unshift(b.join(" "));
|
|
634
818
|
}
|
|
635
819
|
}
|
|
636
|
-
const
|
|
637
|
-
const n =
|
|
820
|
+
const $t = At(null), pt = () => {
|
|
821
|
+
const n = jt($t);
|
|
638
822
|
if (!n) throw new Error("usePdf must be used within <PdfDocument>");
|
|
639
823
|
return n;
|
|
640
|
-
},
|
|
824
|
+
}, Kt = ({
|
|
641
825
|
options: n,
|
|
642
826
|
header: t,
|
|
643
827
|
footer: r,
|
|
644
|
-
pageNumbers:
|
|
645
|
-
centerLabel:
|
|
828
|
+
pageNumbers: i,
|
|
829
|
+
centerLabel: e,
|
|
646
830
|
metadata: s,
|
|
647
|
-
children:
|
|
648
|
-
onReady:
|
|
649
|
-
filename:
|
|
650
|
-
autoSave:
|
|
831
|
+
children: u,
|
|
832
|
+
onReady: c,
|
|
833
|
+
filename: a,
|
|
834
|
+
autoSave: y = !1
|
|
651
835
|
}) => {
|
|
652
|
-
const
|
|
653
|
-
return
|
|
654
|
-
s &&
|
|
655
|
-
}, [
|
|
656
|
-
const
|
|
657
|
-
if (!
|
|
658
|
-
const
|
|
659
|
-
|
|
660
|
-
},
|
|
661
|
-
if (!
|
|
662
|
-
const
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
836
|
+
const f = z.useMemo(() => new Qt(n), [n]);
|
|
837
|
+
return f.reset(), z.useEffect(() => {
|
|
838
|
+
s && f.setMetadata(s);
|
|
839
|
+
}, [f, s]), z.useEffect(() => {
|
|
840
|
+
const P = (d, l) => !l || l === "all" ? !0 : l === "first-only" ? d === 1 : l === "except-first" ? d > 1 : Array.isArray(l) ? l.includes(d) : !0, h = (d, l) => l === "roman-upper" ? It(d, !0) : l === "roman-lower" ? It(d, !1) : String(d), p = (d, l, m) => {
|
|
841
|
+
if (!i?.enabled || !P(l, i.scope)) return;
|
|
842
|
+
const v = i.preset ?? "page-slash-total", x = (i.template ?? (v === "page-slash-total" ? "Page {page}/{total}" : v === "page-of-total" ? "Page {page} of {total}" : "{page}/{total}")).replace("{page}", h(l, i.format)).replace("{total}", h(m, i.format)), g = i.align ?? "right", _ = g === "left" ? f.contentLeft + (i.offsetX ?? 0) : g === "right" ? f.contentRight - (i.offsetX ?? 0) : (f.contentLeft + f.contentRight) / 2 + (i.offsetX ?? 0), W = d === "header" ? 10 : f.height - 7, H = typeof i.y == "number" ? i.y : W;
|
|
843
|
+
f.textRaw(x, _, H, i.style, void 0, g);
|
|
844
|
+
}, b = (d, l, m) => {
|
|
845
|
+
if (!e?.enabled || !P(l, e.scope)) return;
|
|
846
|
+
const v = "center", C = (f.contentLeft + f.contentRight) / 2 + (e.offsetX ?? 0), x = d === "header" ? 10 : f.height - 7, g = typeof e.y == "number" ? e.y : x;
|
|
847
|
+
f.textRaw(
|
|
848
|
+
e.text,
|
|
849
|
+
C,
|
|
850
|
+
g,
|
|
851
|
+
e.style,
|
|
668
852
|
void 0,
|
|
669
|
-
|
|
853
|
+
v
|
|
670
854
|
);
|
|
671
855
|
};
|
|
672
|
-
return
|
|
673
|
-
(
|
|
674
|
-
t && t(
|
|
856
|
+
return f.setHeaderFooter(
|
|
857
|
+
(d, l, m) => {
|
|
858
|
+
t && t(f, l, m), i?.position === "header" && p("header", l, m), e?.position === "header" && b("header", l);
|
|
675
859
|
},
|
|
676
|
-
(
|
|
677
|
-
|
|
860
|
+
(d, l, m) => {
|
|
861
|
+
i?.position === "footer" && p("footer", l, m), r && r(f, l, m), e?.position === "footer" && b("footer", l);
|
|
678
862
|
}
|
|
679
|
-
),
|
|
680
|
-
|
|
863
|
+
), f.waitForTasks().then(() => {
|
|
864
|
+
c?.(f);
|
|
681
865
|
}), () => {
|
|
682
|
-
|
|
866
|
+
f.reset();
|
|
683
867
|
};
|
|
684
|
-
}, [
|
|
685
|
-
|
|
686
|
-
}, [
|
|
687
|
-
},
|
|
868
|
+
}, [f]), z.useEffect(() => {
|
|
869
|
+
y && a && f.save(a);
|
|
870
|
+
}, [y, a]), /* @__PURE__ */ tt.jsx($t.Provider, { value: f, children: u });
|
|
871
|
+
}, Zt = At(null), Tt = () => jt(Zt), se = ({
|
|
688
872
|
src: n,
|
|
689
873
|
x: t,
|
|
690
874
|
y: r,
|
|
691
|
-
w:
|
|
692
|
-
h:
|
|
875
|
+
w: i,
|
|
876
|
+
h: e,
|
|
693
877
|
mime: s = "PNG",
|
|
694
|
-
flow:
|
|
695
|
-
layout:
|
|
696
|
-
sizing:
|
|
697
|
-
align:
|
|
698
|
-
showInAllPages:
|
|
699
|
-
scope:
|
|
878
|
+
flow: u,
|
|
879
|
+
layout: c,
|
|
880
|
+
sizing: a,
|
|
881
|
+
align: y = "left",
|
|
882
|
+
showInAllPages: f,
|
|
883
|
+
scope: P,
|
|
884
|
+
className: h,
|
|
885
|
+
style: p
|
|
700
886
|
}) => {
|
|
701
|
-
const
|
|
702
|
-
return
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
887
|
+
const b = pt(), d = Tt(), l = Ct(), { ref: m, computeStyle: v } = wt(), C = z.useRef(null);
|
|
888
|
+
return z.useLayoutEffect(() => {
|
|
889
|
+
if (C.current?.pdf === b && C.current?.gen === b.generation)
|
|
890
|
+
return;
|
|
891
|
+
C.current = { pdf: b, gen: b.generation };
|
|
892
|
+
const x = v(), g = i ?? (typeof x.width == "number" ? x.width : void 0), _ = e ?? (typeof x.height == "number" ? x.height : void 0), W = x.margin, H = (typeof W == "number" ? W : W?.bottom) ?? 2, O = c === "flow" || u === !0 || t === void 0 && r === void 0 && c !== "fixed";
|
|
893
|
+
let F = g;
|
|
894
|
+
a === "fill" && (F = b.contentAreaWidth);
|
|
895
|
+
const U = t, q = r, L = async () => {
|
|
896
|
+
const R = b.getCursor(), E = await (async (M, ft) => {
|
|
897
|
+
const st = U, S = q;
|
|
898
|
+
return await b.imageFromUrl(n, {
|
|
899
|
+
x: st,
|
|
900
|
+
y: S,
|
|
901
|
+
w: F,
|
|
902
|
+
h: _,
|
|
715
903
|
mime: s,
|
|
716
|
-
align:
|
|
904
|
+
align: y,
|
|
905
|
+
radius: x.radius
|
|
717
906
|
});
|
|
718
907
|
})();
|
|
719
|
-
|
|
908
|
+
O && E && b.moveCursor(0, E.height + H), f && E && b.registerRecurringItem({
|
|
720
909
|
draw: () => {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
x:
|
|
724
|
-
y:
|
|
725
|
-
w:
|
|
726
|
-
h:
|
|
910
|
+
b.queueOperation(async () => {
|
|
911
|
+
O && b.setCursor(R.x, R.y), await b.imageFromUrl(n, {
|
|
912
|
+
x: U,
|
|
913
|
+
y: O ? R.y : q,
|
|
914
|
+
w: F,
|
|
915
|
+
h: _,
|
|
727
916
|
mime: s,
|
|
728
|
-
align:
|
|
917
|
+
align: y,
|
|
918
|
+
radius: x.radius
|
|
729
919
|
});
|
|
730
920
|
});
|
|
731
921
|
},
|
|
732
|
-
scope:
|
|
733
|
-
y:
|
|
734
|
-
height:
|
|
922
|
+
scope: P ?? "all",
|
|
923
|
+
y: O ? R.y : q ?? 0,
|
|
924
|
+
height: E.height + H
|
|
735
925
|
});
|
|
736
|
-
}
|
|
926
|
+
};
|
|
927
|
+
if (d)
|
|
928
|
+
return d.registerOperation(l, L), () => d.unregisterOperation(l);
|
|
929
|
+
b.queueOperation(L);
|
|
737
930
|
}, [
|
|
738
|
-
|
|
931
|
+
b,
|
|
739
932
|
n,
|
|
740
933
|
t,
|
|
741
934
|
r,
|
|
742
|
-
a,
|
|
743
935
|
i,
|
|
744
|
-
s,
|
|
745
936
|
e,
|
|
746
|
-
|
|
937
|
+
s,
|
|
747
938
|
u,
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
939
|
+
c,
|
|
940
|
+
a,
|
|
941
|
+
y,
|
|
942
|
+
f,
|
|
943
|
+
P,
|
|
944
|
+
h
|
|
945
|
+
]), /* @__PURE__ */ tt.jsx(
|
|
946
|
+
"div",
|
|
947
|
+
{
|
|
948
|
+
ref: m,
|
|
949
|
+
className: h,
|
|
950
|
+
style: {
|
|
951
|
+
...p,
|
|
952
|
+
position: "absolute",
|
|
953
|
+
visibility: "hidden",
|
|
954
|
+
pointerEvents: "none"
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
);
|
|
958
|
+
}, ae = ({
|
|
753
959
|
items: n,
|
|
754
960
|
ordered: t = !1,
|
|
755
961
|
style: r,
|
|
756
|
-
indent:
|
|
757
|
-
markerWidth:
|
|
758
|
-
spacing: s = 2
|
|
962
|
+
indent: i = 5,
|
|
963
|
+
markerWidth: e = 5,
|
|
964
|
+
spacing: s = 2,
|
|
965
|
+
className: u
|
|
759
966
|
}) => {
|
|
760
|
-
const
|
|
761
|
-
return
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
967
|
+
const c = pt(), a = Tt(), y = Ct(), { ref: f, computeStyle: P } = wt(), h = z.useRef(null);
|
|
968
|
+
return z.useLayoutEffect(() => {
|
|
969
|
+
if (h.current?.pdf === c && h.current?.gen === c.generation)
|
|
970
|
+
return;
|
|
971
|
+
h.current = { pdf: c, gen: c.generation };
|
|
972
|
+
const p = P(), b = {
|
|
973
|
+
...p,
|
|
974
|
+
...r
|
|
975
|
+
}, d = async () => {
|
|
976
|
+
const l = typeof p.margin == "number" ? p.margin : p.margin?.top;
|
|
977
|
+
l && c.moveCursor(0, l), n.forEach((v, C) => {
|
|
978
|
+
const x = t ? `${C + 1}.` : "•", g = b.fontSize ?? c.baseFont.size, _ = g * 1.2 * 0.3528;
|
|
979
|
+
c.getCursor().y + _ > c.contentBottom && c.addPage();
|
|
980
|
+
const H = c.getCursor().y, O = c.getCursor().x, F = O + i + e, U = H + g * 0.3528;
|
|
981
|
+
c.textRaw(
|
|
982
|
+
x,
|
|
983
|
+
O + i,
|
|
984
|
+
U,
|
|
985
|
+
b,
|
|
986
|
+
e,
|
|
773
987
|
"right"
|
|
774
|
-
),
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
const L =
|
|
778
|
-
|
|
988
|
+
), c.setCursor(F, H);
|
|
989
|
+
const q = c.contentRight - F;
|
|
990
|
+
c.paragraph(v, b, q);
|
|
991
|
+
const L = c.getCursor().y;
|
|
992
|
+
c.setCursor(O, L + s);
|
|
779
993
|
});
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
994
|
+
const m = typeof p.margin == "number" ? p.margin : p.margin?.bottom;
|
|
995
|
+
m && c.moveCursor(0, m);
|
|
996
|
+
};
|
|
997
|
+
if (a)
|
|
998
|
+
return a.registerOperation(y, d), () => a.unregisterOperation(y);
|
|
999
|
+
c.queueOperation(d);
|
|
1000
|
+
}, [
|
|
1001
|
+
c,
|
|
1002
|
+
a,
|
|
1003
|
+
y,
|
|
1004
|
+
n,
|
|
1005
|
+
t,
|
|
1006
|
+
r,
|
|
1007
|
+
i,
|
|
1008
|
+
e,
|
|
1009
|
+
s,
|
|
1010
|
+
u
|
|
1011
|
+
]), /* @__PURE__ */ tt.jsx(
|
|
1012
|
+
"div",
|
|
1013
|
+
{
|
|
1014
|
+
ref: f,
|
|
1015
|
+
className: u,
|
|
1016
|
+
style: {
|
|
1017
|
+
position: "absolute",
|
|
1018
|
+
visibility: "hidden",
|
|
1019
|
+
pointerEvents: "none"
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
);
|
|
1023
|
+
}, ce = ({
|
|
783
1024
|
width: n = "inherit",
|
|
784
1025
|
height: t = "inherit",
|
|
785
1026
|
className: r,
|
|
786
|
-
style:
|
|
787
|
-
iframeClassName:
|
|
1027
|
+
style: i,
|
|
1028
|
+
iframeClassName: e,
|
|
788
1029
|
iframeStyle: s,
|
|
789
|
-
...
|
|
1030
|
+
...u
|
|
790
1031
|
}) => {
|
|
791
|
-
const [
|
|
792
|
-
const
|
|
793
|
-
|
|
1032
|
+
const [c, a] = Yt(null), y = (f) => {
|
|
1033
|
+
const P = f.getBlobUrl();
|
|
1034
|
+
a(P.toString());
|
|
794
1035
|
};
|
|
795
|
-
return /* @__PURE__ */
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
"
|
|
799
|
-
{
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
color: "#6b7280"
|
|
818
|
-
},
|
|
819
|
-
children: "Generating Preview..."
|
|
820
|
-
}
|
|
821
|
-
)
|
|
822
|
-
] });
|
|
823
|
-
}, Pt = ({
|
|
1036
|
+
return /* @__PURE__ */ tt.jsxs(
|
|
1037
|
+
"div",
|
|
1038
|
+
{
|
|
1039
|
+
className: `pdf-preview-container ${r || ""}`,
|
|
1040
|
+
style: { width: n, height: t, ...i },
|
|
1041
|
+
children: [
|
|
1042
|
+
/* @__PURE__ */ tt.jsx("div", { className: "pdf-preview-hidden", children: /* @__PURE__ */ tt.jsx(Kt, { ...u, onReady: y, autoSave: !1, children: u.children }) }),
|
|
1043
|
+
c ? /* @__PURE__ */ tt.jsx(
|
|
1044
|
+
"iframe",
|
|
1045
|
+
{
|
|
1046
|
+
src: c,
|
|
1047
|
+
width: "100%",
|
|
1048
|
+
height: "100%",
|
|
1049
|
+
className: `pdf-preview-iframe ${e || ""}`,
|
|
1050
|
+
style: s,
|
|
1051
|
+
title: "PDF Preview"
|
|
1052
|
+
}
|
|
1053
|
+
) : /* @__PURE__ */ tt.jsx("div", { className: "pdf-preview-placeholder", children: "Generating Preview..." })
|
|
1054
|
+
]
|
|
1055
|
+
}
|
|
1056
|
+
);
|
|
1057
|
+
}, fe = ({
|
|
824
1058
|
data: n,
|
|
825
1059
|
columns: t,
|
|
826
1060
|
width: r = "100%",
|
|
827
|
-
borderWidth:
|
|
828
|
-
borderColor:
|
|
1061
|
+
borderWidth: i = 0.1,
|
|
1062
|
+
borderColor: e = "#000000",
|
|
829
1063
|
cellPadding: s = 2,
|
|
830
|
-
headerStyle:
|
|
831
|
-
rowStyle:
|
|
832
|
-
alternateRowStyle:
|
|
833
|
-
headerHeight:
|
|
834
|
-
repeatHeader:
|
|
835
|
-
striped:
|
|
1064
|
+
headerStyle: u,
|
|
1065
|
+
rowStyle: c,
|
|
1066
|
+
alternateRowStyle: a,
|
|
1067
|
+
headerHeight: y,
|
|
1068
|
+
repeatHeader: f = !0,
|
|
1069
|
+
striped: P = !1,
|
|
1070
|
+
stripeColor: h = "#E5E7EB",
|
|
1071
|
+
className: p,
|
|
1072
|
+
style: b
|
|
836
1073
|
}) => {
|
|
837
|
-
const
|
|
838
|
-
return
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
1074
|
+
const d = pt(), l = Tt(), m = Ct(), { ref: v, computeStyle: C } = wt(), x = z.useRef(null);
|
|
1075
|
+
return z.useLayoutEffect(() => {
|
|
1076
|
+
if (x.current?.pdf === d && x.current?.gen === d.generation)
|
|
1077
|
+
return;
|
|
1078
|
+
x.current = { pdf: d, gen: d.generation };
|
|
1079
|
+
const g = C(), _ = r === "100%" && g.width ? g.width : r, W = g.borderColor ?? e, H = g.borderWidth ?? i, F = (!!p || !!b) && g.padding ? g.padding : s, U = {
|
|
1080
|
+
color: g.color,
|
|
1081
|
+
fontSize: g.fontSize,
|
|
1082
|
+
fontStyle: g.fontStyle,
|
|
1083
|
+
align: g.align,
|
|
1084
|
+
fillColor: g.fillColor
|
|
1085
|
+
}, q = { ...U, ...c }, L = { ...U, ...u };
|
|
1086
|
+
u?.fontStyle || (L.fontStyle = u?.fontStyle ?? "bold");
|
|
1087
|
+
const R = async () => {
|
|
1088
|
+
const at = typeof g.margin == "number" ? g.margin : g.margin?.top;
|
|
1089
|
+
at && d.moveCursor(0, at);
|
|
1090
|
+
const E = typeof _ == "number" ? _ : parseFloat(_) / 100 * d.contentAreaWidth, M = t.map((I) => typeof I.width == "number" ? I.width : typeof I.width == "string" && I.width.endsWith("%") ? parseFloat(I.width) / 100 * E : 0), ft = M.reduce((I, X) => I + X, 0), st = Math.max(0, E - ft), S = M.filter((I) => I === 0).length;
|
|
1091
|
+
if (S > 0) {
|
|
1092
|
+
const I = st / S;
|
|
1093
|
+
for (let X = 0; X < M.length; X++)
|
|
1094
|
+
M[X] === 0 && (M[X] = I);
|
|
845
1095
|
}
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
borderColor:
|
|
849
|
-
borderWidth:
|
|
850
|
-
fillColor:
|
|
1096
|
+
const o = (I, X, B, et, ct, k, ot = "left", nt = !0) => {
|
|
1097
|
+
nt && d.box(X, B, et, ct, {
|
|
1098
|
+
borderColor: k.borderColor ?? W,
|
|
1099
|
+
borderWidth: k.borderWidth ?? H,
|
|
1100
|
+
fillColor: k.fillColor,
|
|
1101
|
+
radius: k.radius
|
|
851
1102
|
});
|
|
852
|
-
const
|
|
853
|
-
top:
|
|
854
|
-
right:
|
|
855
|
-
bottom:
|
|
856
|
-
left:
|
|
857
|
-
},
|
|
858
|
-
let
|
|
859
|
-
|
|
860
|
-
let
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
let
|
|
864
|
-
|
|
865
|
-
}),
|
|
1103
|
+
const V = St(k.padding ?? F), rt = {
|
|
1104
|
+
top: k.paddingTop ?? V.top,
|
|
1105
|
+
right: k.paddingRight ?? V.right,
|
|
1106
|
+
bottom: k.paddingBottom ?? V.bottom,
|
|
1107
|
+
left: k.paddingLeft ?? V.left
|
|
1108
|
+
}, G = et - rt.left - rt.right, j = d.instance.splitTextToSize(I, G, k), D = (k.fontSize ?? d.baseFont.size) * (k.lineHeight ?? d.baseLineHeight) * 0.3528, A = (k.fontSize ?? d.baseFont.size) * 0.3528, N = j.length * D, Q = ct - rt.top - rt.bottom;
|
|
1109
|
+
let K = 0;
|
|
1110
|
+
k.verticalAlign === "middle" ? K = Math.max(0, (Q - N) / 2) : k.verticalAlign === "bottom" && (K = Math.max(0, Q - N));
|
|
1111
|
+
let dt = B + rt.top + K + A;
|
|
1112
|
+
const ht = k.align ?? ot, mt = d.getCursor();
|
|
1113
|
+
j.forEach((yt) => {
|
|
1114
|
+
let J = X + rt.left;
|
|
1115
|
+
ht === "center" ? J = X + et / 2 : ht === "right" && (J = X + et - rt.right), d.textRaw(yt, J, dt, k, void 0, ht), dt += D;
|
|
1116
|
+
}), d.setCursor(mt.x, mt.y);
|
|
866
1117
|
};
|
|
867
|
-
let
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
let
|
|
871
|
-
t.forEach((
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
),
|
|
882
|
-
}),
|
|
883
|
-
const
|
|
884
|
-
const
|
|
885
|
-
top:
|
|
886
|
-
right:
|
|
887
|
-
bottom:
|
|
888
|
-
left:
|
|
889
|
-
},
|
|
890
|
-
return
|
|
1118
|
+
let w = d.getCursor().y;
|
|
1119
|
+
const T = d.getCursor().x, Y = y ?? 10;
|
|
1120
|
+
w + Y > d.contentBottom && (d.addPage(), w = d.getCursor().y);
|
|
1121
|
+
let Z = T;
|
|
1122
|
+
t.forEach((I, X) => {
|
|
1123
|
+
const B = M[X];
|
|
1124
|
+
o(
|
|
1125
|
+
I.header ?? "",
|
|
1126
|
+
Z,
|
|
1127
|
+
w,
|
|
1128
|
+
B,
|
|
1129
|
+
Y,
|
|
1130
|
+
L,
|
|
1131
|
+
I.align ?? "left"
|
|
1132
|
+
), Z += B;
|
|
1133
|
+
}), w += Y, d.setCursor(T, w);
|
|
1134
|
+
const ut = (I, X, B) => {
|
|
1135
|
+
const et = St(F), ct = {
|
|
1136
|
+
top: B.paddingTop ?? et.top,
|
|
1137
|
+
right: B.paddingRight ?? et.right,
|
|
1138
|
+
bottom: B.paddingBottom ?? et.bottom,
|
|
1139
|
+
left: B.paddingLeft ?? et.left
|
|
1140
|
+
}, k = X - ct.left - ct.right;
|
|
1141
|
+
return d.measureText(I, B, k).height + ct.top + ct.bottom;
|
|
891
1142
|
};
|
|
892
1143
|
new Array(t.length).fill(0), (() => {
|
|
893
|
-
const
|
|
894
|
-
for (let
|
|
895
|
-
const
|
|
896
|
-
let
|
|
897
|
-
for (let
|
|
898
|
-
const
|
|
899
|
-
let
|
|
900
|
-
|
|
901
|
-
let
|
|
902
|
-
for (let
|
|
903
|
-
|
|
904
|
-
if (
|
|
905
|
-
|
|
906
|
-
ri:
|
|
907
|
-
rSpan:
|
|
908
|
-
content:
|
|
909
|
-
width:
|
|
910
|
-
style:
|
|
911
|
-
}),
|
|
1144
|
+
const I = new Array(n.length).fill(0), X = [];
|
|
1145
|
+
for (let k = 0; k < n.length; k++) {
|
|
1146
|
+
const ot = n[k];
|
|
1147
|
+
let nt = 0;
|
|
1148
|
+
for (let V = 0; V < t.length; V++) {
|
|
1149
|
+
const rt = t[V], G = typeof rt.accessor == "function" ? rt.accessor(ot) : ot[rt.accessor];
|
|
1150
|
+
let j = "", D = q, A = 1, N = 1;
|
|
1151
|
+
G && typeof G == "object" && G.content !== void 0 ? (j = String(G.content), G.style && (D = { ...D, ...G.style }), G.colSpan && (A = G.colSpan), G.rowSpan && (N = G.rowSpan)) : j = String(G ?? "");
|
|
1152
|
+
let Q = M[V];
|
|
1153
|
+
for (let dt = 1; dt < A; dt++)
|
|
1154
|
+
V + dt < M.length && (Q += M[V + dt]);
|
|
1155
|
+
if (N > 1) {
|
|
1156
|
+
X.push({
|
|
1157
|
+
ri: k,
|
|
1158
|
+
rSpan: N,
|
|
1159
|
+
content: j,
|
|
1160
|
+
width: Q,
|
|
1161
|
+
style: D ?? {}
|
|
1162
|
+
}), V += A - 1;
|
|
912
1163
|
continue;
|
|
913
1164
|
}
|
|
914
|
-
const
|
|
915
|
-
|
|
1165
|
+
const K = ut(j, Q, D ?? {});
|
|
1166
|
+
K > nt && (nt = K), V += A - 1;
|
|
916
1167
|
}
|
|
917
|
-
|
|
1168
|
+
nt < 8 && (nt = 8), I[k] = nt;
|
|
918
1169
|
}
|
|
919
|
-
|
|
920
|
-
const { ri:
|
|
921
|
-
let
|
|
922
|
-
for (let
|
|
923
|
-
|
|
924
|
-
if (
|
|
925
|
-
const
|
|
926
|
-
|
|
1170
|
+
X.forEach((k) => {
|
|
1171
|
+
const { ri: ot, rSpan: nt, content: V, width: rt, style: G } = k, j = ut(V, rt, G);
|
|
1172
|
+
let D = 0;
|
|
1173
|
+
for (let A = 0; A < nt; A++)
|
|
1174
|
+
ot + A < I.length && (D += I[ot + A]);
|
|
1175
|
+
if (j > D) {
|
|
1176
|
+
const A = j - D, N = Math.min(ot + nt - 1, I.length - 1);
|
|
1177
|
+
I[N] += A;
|
|
927
1178
|
}
|
|
928
1179
|
});
|
|
929
|
-
let
|
|
930
|
-
const
|
|
931
|
-
for (let
|
|
932
|
-
const
|
|
933
|
-
let
|
|
934
|
-
for (let
|
|
935
|
-
const
|
|
936
|
-
let
|
|
937
|
-
if (
|
|
938
|
-
let
|
|
939
|
-
for (let
|
|
940
|
-
|
|
941
|
-
|
|
1180
|
+
let B = w;
|
|
1181
|
+
const et = new Array(t.length).fill(0), ct = d.getCursor().x;
|
|
1182
|
+
for (let k = 0; k < n.length; k++) {
|
|
1183
|
+
const ot = n[k], nt = I[k];
|
|
1184
|
+
let V = nt;
|
|
1185
|
+
for (let j = 0; j < t.length; j++) {
|
|
1186
|
+
const D = t[j], A = typeof D.accessor == "function" ? D.accessor(ot) : ot[D.accessor];
|
|
1187
|
+
let N = 1;
|
|
1188
|
+
if (A && typeof A == "object" && A.rowSpan && (N = A.rowSpan), N > 1) {
|
|
1189
|
+
let Q = 0;
|
|
1190
|
+
for (let K = 0; K < N; K++)
|
|
1191
|
+
k + K < I.length && (Q += I[k + K]);
|
|
1192
|
+
Q > V && (V = Q);
|
|
942
1193
|
}
|
|
943
1194
|
}
|
|
944
|
-
const
|
|
945
|
-
if (
|
|
946
|
-
let
|
|
947
|
-
t.forEach((
|
|
948
|
-
const
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
),
|
|
958
|
-
}),
|
|
1195
|
+
const rt = Math.abs(B - (d.contentTop + (y ?? 10))) < 1;
|
|
1196
|
+
if (B + V > d.contentBottom && !rt && (d.addPage(), B = d.getCursor().y, f && (y ?? 10) !== 0)) {
|
|
1197
|
+
let j = ct;
|
|
1198
|
+
t.forEach((D, A) => {
|
|
1199
|
+
const N = M[A];
|
|
1200
|
+
o(
|
|
1201
|
+
D.header ?? "",
|
|
1202
|
+
j,
|
|
1203
|
+
B,
|
|
1204
|
+
N,
|
|
1205
|
+
y ?? 10,
|
|
1206
|
+
L,
|
|
1207
|
+
D.align ?? "left"
|
|
1208
|
+
), j += N;
|
|
1209
|
+
}), B += y ?? 10;
|
|
959
1210
|
}
|
|
960
|
-
let
|
|
961
|
-
for (let
|
|
962
|
-
if (
|
|
963
|
-
|
|
1211
|
+
let G = ct;
|
|
1212
|
+
for (let j = 0; j < t.length; j++) {
|
|
1213
|
+
if (et[j] > 0) {
|
|
1214
|
+
et[j]--, G += M[j];
|
|
964
1215
|
continue;
|
|
965
1216
|
}
|
|
966
|
-
const
|
|
967
|
-
let
|
|
968
|
-
|
|
969
|
-
let
|
|
970
|
-
|
|
971
|
-
let
|
|
972
|
-
for (let
|
|
973
|
-
|
|
974
|
-
let
|
|
975
|
-
if (
|
|
976
|
-
for (let
|
|
977
|
-
|
|
978
|
-
if (
|
|
979
|
-
|
|
980
|
-
_,
|
|
981
|
-
E,
|
|
982
|
-
B,
|
|
1217
|
+
const D = t[j], A = typeof D.accessor == "function" ? D.accessor(ot) : ot[D.accessor];
|
|
1218
|
+
let N = 1, Q = 1, K = q;
|
|
1219
|
+
k % 2 === 1 && (a ? K = a : P && (K = { ...q, fillColor: h }));
|
|
1220
|
+
let ht = "";
|
|
1221
|
+
A && typeof A == "object" && A.content !== void 0 ? (ht = String(A.content), A.colSpan && (N = A.colSpan), A.rowSpan && (Q = A.rowSpan), A.style && (K = { ...K, ...A.style })) : ht = String(A ?? "");
|
|
1222
|
+
let mt = M[j];
|
|
1223
|
+
for (let J = 1; J < N; J++)
|
|
1224
|
+
j + J < M.length && (mt += M[j + J]);
|
|
1225
|
+
let yt = nt;
|
|
1226
|
+
if (Q > 1)
|
|
1227
|
+
for (let J = 1; J < Q; J++)
|
|
1228
|
+
k + J < I.length && (yt += I[k + J]);
|
|
1229
|
+
if (o(
|
|
1230
|
+
ht,
|
|
983
1231
|
G,
|
|
984
|
-
|
|
985
|
-
|
|
1232
|
+
B,
|
|
1233
|
+
mt,
|
|
1234
|
+
yt,
|
|
1235
|
+
K ?? {},
|
|
1236
|
+
D.align ?? "left",
|
|
986
1237
|
!0
|
|
987
|
-
),
|
|
988
|
-
|
|
989
|
-
for (let
|
|
990
|
-
|
|
1238
|
+
), Q > 1) {
|
|
1239
|
+
et[j] = Q - 1;
|
|
1240
|
+
for (let J = 1; J < N; J++)
|
|
1241
|
+
j + J < et.length && (et[j + J] = Q - 1);
|
|
991
1242
|
}
|
|
992
|
-
|
|
1243
|
+
G += mt, j += N - 1;
|
|
993
1244
|
}
|
|
994
|
-
|
|
1245
|
+
B += nt;
|
|
995
1246
|
}
|
|
996
|
-
|
|
1247
|
+
d.setCursor(ct, B);
|
|
997
1248
|
})();
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
}
|
|
1249
|
+
const lt = typeof g.margin == "number" ? g.margin : g.margin?.bottom;
|
|
1250
|
+
lt && d.moveCursor(0, lt);
|
|
1251
|
+
};
|
|
1252
|
+
if (l)
|
|
1253
|
+
return l.registerOperation(m, R), () => l.unregisterOperation(m);
|
|
1254
|
+
d.queueOperation(R);
|
|
1255
|
+
}, [d, n, t, r, p]), /* @__PURE__ */ tt.jsx(
|
|
1256
|
+
"div",
|
|
1257
|
+
{
|
|
1258
|
+
ref: v,
|
|
1259
|
+
className: p,
|
|
1260
|
+
style: {
|
|
1261
|
+
...b,
|
|
1262
|
+
position: "absolute",
|
|
1263
|
+
visibility: "hidden",
|
|
1264
|
+
pointerEvents: "none"
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
);
|
|
1268
|
+
}, le = ({
|
|
1001
1269
|
children: n,
|
|
1002
1270
|
x: t,
|
|
1003
1271
|
y: r,
|
|
1004
|
-
maxWidth:
|
|
1005
|
-
spacingBelow:
|
|
1006
|
-
|
|
1272
|
+
maxWidth: i,
|
|
1273
|
+
spacingBelow: e = 2,
|
|
1274
|
+
className: s,
|
|
1275
|
+
style: u,
|
|
1276
|
+
...c
|
|
1007
1277
|
}) => {
|
|
1008
|
-
const
|
|
1009
|
-
return
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1278
|
+
const a = pt(), y = Tt(), f = Ct(), { ref: P, computeStyle: h } = wt(), p = z.useRef(null);
|
|
1279
|
+
return z.useLayoutEffect(() => {
|
|
1280
|
+
if (p.current?.pdf === a && p.current?.gen === a.generation)
|
|
1281
|
+
return;
|
|
1282
|
+
p.current = { pdf: a, gen: a.generation };
|
|
1283
|
+
const d = {
|
|
1284
|
+
...h(),
|
|
1285
|
+
...c
|
|
1286
|
+
}, l = async () => {
|
|
1287
|
+
const m = a.getCursor();
|
|
1288
|
+
let v = 0;
|
|
1289
|
+
const C = () => {
|
|
1014
1290
|
if (typeof t == "number" && typeof r == "number")
|
|
1015
|
-
|
|
1291
|
+
a.textRaw(n, t, r, d, i, d.align);
|
|
1016
1292
|
else {
|
|
1017
|
-
|
|
1018
|
-
const
|
|
1019
|
-
e.setCursor(
|
|
1293
|
+
a.setCursor(m.x, m.y), v = a.paragraph(n, d, i);
|
|
1294
|
+
const x = a.getCursor();
|
|
1295
|
+
e > 0 && a.setCursor(x.x, x.y + e);
|
|
1020
1296
|
}
|
|
1021
1297
|
};
|
|
1022
|
-
|
|
1023
|
-
draw:
|
|
1024
|
-
scope:
|
|
1025
|
-
y:
|
|
1026
|
-
height:
|
|
1298
|
+
C(), d.showInAllPages && a.registerRecurringItem({
|
|
1299
|
+
draw: C,
|
|
1300
|
+
scope: d.scope ?? "all",
|
|
1301
|
+
y: m.y,
|
|
1302
|
+
height: v + e
|
|
1027
1303
|
});
|
|
1028
|
-
}
|
|
1304
|
+
};
|
|
1305
|
+
if (y)
|
|
1306
|
+
return y.registerOperation(f, l), () => y.unregisterOperation(f);
|
|
1307
|
+
a.queueOperation(l);
|
|
1029
1308
|
}, [
|
|
1030
|
-
|
|
1309
|
+
a,
|
|
1310
|
+
y,
|
|
1311
|
+
// Add context dependency
|
|
1312
|
+
f,
|
|
1031
1313
|
n,
|
|
1032
1314
|
t,
|
|
1033
1315
|
r,
|
|
1034
|
-
a,
|
|
1035
1316
|
i,
|
|
1036
|
-
|
|
1037
|
-
s
|
|
1038
|
-
|
|
1039
|
-
|
|
1317
|
+
e,
|
|
1318
|
+
s,
|
|
1319
|
+
c.fontSize,
|
|
1320
|
+
c.color,
|
|
1321
|
+
c.align
|
|
1322
|
+
]), /* @__PURE__ */ tt.jsx(
|
|
1323
|
+
"div",
|
|
1324
|
+
{
|
|
1325
|
+
ref: P,
|
|
1326
|
+
className: s,
|
|
1327
|
+
style: {
|
|
1328
|
+
...u,
|
|
1329
|
+
position: "absolute",
|
|
1330
|
+
visibility: "hidden",
|
|
1331
|
+
pointerEvents: "none"
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
);
|
|
1335
|
+
}, te = ({
|
|
1040
1336
|
viewState: n,
|
|
1041
1337
|
style: t,
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
w:
|
|
1045
|
-
h: s
|
|
1338
|
+
className: r,
|
|
1339
|
+
computeStyle: i,
|
|
1340
|
+
w: e,
|
|
1341
|
+
h: s,
|
|
1342
|
+
showInAllPages: u,
|
|
1343
|
+
scope: c
|
|
1046
1344
|
}) => {
|
|
1047
|
-
const
|
|
1048
|
-
return
|
|
1049
|
-
|
|
1345
|
+
const a = pt(), y = z.useRef(null);
|
|
1346
|
+
return z.useLayoutEffect(() => {
|
|
1347
|
+
y.current?.pdf === a && y.current?.gen === a.generation || (y.current = { pdf: a, gen: a.generation }, a.queueOperation(() => {
|
|
1050
1348
|
const f = n.start;
|
|
1051
1349
|
if (!f) return;
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
const l =
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1350
|
+
let h = { ...i(), ...t };
|
|
1351
|
+
const p = !!h.fillColor, b = !!h.borderColor || (h.borderWidth ?? 0) > 0, d = t.padding !== void 0 || t.paddingTop !== void 0 || t.paddingRight !== void 0 || t.paddingBottom !== void 0 || t.paddingLeft !== void 0;
|
|
1352
|
+
(p || b) && !d && !r && (h.padding = 4), u !== void 0 && (h.showInAllPages = u), c !== void 0 && (h.scope = c);
|
|
1353
|
+
const l = St(h.padding), m = {
|
|
1354
|
+
top: h.paddingTop ?? l.top,
|
|
1355
|
+
right: h.paddingRight ?? l.right,
|
|
1356
|
+
bottom: h.paddingBottom ?? l.bottom,
|
|
1357
|
+
left: h.paddingLeft ?? l.left
|
|
1358
|
+
}, C = ((F) => typeof F == "number" ? { top: F, right: F, bottom: F, left: F } : {
|
|
1359
|
+
top: F?.top ?? 0,
|
|
1360
|
+
right: F?.right ?? 0,
|
|
1361
|
+
bottom: F?.bottom ?? 0,
|
|
1362
|
+
left: F?.left ?? 0
|
|
1363
|
+
})(h.margin), x = {
|
|
1364
|
+
top: h.marginTop ?? C.top,
|
|
1365
|
+
right: h.marginRight ?? C.right,
|
|
1366
|
+
bottom: h.marginBottom ?? C.bottom,
|
|
1367
|
+
left: h.marginLeft ?? C.left
|
|
1368
|
+
};
|
|
1369
|
+
let g = e ?? a.contentAreaWidth;
|
|
1370
|
+
typeof h.width == "number" && (g = h.width);
|
|
1371
|
+
const _ = g + m.left + m.right, W = a.getPageCount(), H = a.getCursor(), O = n.start.page ?? W;
|
|
1372
|
+
for (let F = O; F <= W; F++) {
|
|
1373
|
+
a.instance.setPage(F);
|
|
1374
|
+
const U = a.getSafeContentTop ? a.getSafeContentTop(F) : a.contentTop;
|
|
1375
|
+
let q = U, L;
|
|
1376
|
+
if (F === O)
|
|
1377
|
+
q = f.y, F === W ? h.height ? L = h.height : L = H.y - f.y + m.bottom : L = a.height - a.margin.bottom - f.y;
|
|
1378
|
+
else if (F === W) {
|
|
1379
|
+
q = U, h.height, L = H.y - U + m.bottom;
|
|
1380
|
+
const E = a.height - a.margin.bottom;
|
|
1381
|
+
L = Math.min(L, E - U);
|
|
1065
1382
|
} else
|
|
1066
|
-
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
);
|
|
1383
|
+
q = U, L = a.height - a.margin.bottom - U;
|
|
1384
|
+
if (L < 0.5 || isNaN(L)) continue;
|
|
1385
|
+
const R = h.radius ?? 0, at = O === W;
|
|
1386
|
+
if (h.borderWidth && h.borderWidth > 0) {
|
|
1387
|
+
const E = a.instance, M = h.borderWidth, ft = h.borderColor ?? "#000000";
|
|
1388
|
+
E.setLineWidth(M);
|
|
1389
|
+
const st = gt(ft);
|
|
1390
|
+
st && E.setDrawColor(st[0], st[1], st[2]);
|
|
1391
|
+
const S = Math.max(f.x, a.margin.left), o = q, w = _, T = L;
|
|
1392
|
+
if (R > 0 && at)
|
|
1393
|
+
E.roundedRect(S, o, w, T, R, R);
|
|
1394
|
+
else if (R > 0 && !at) {
|
|
1395
|
+
const Y = (Z) => {
|
|
1396
|
+
const $ = R * 0.551784;
|
|
1397
|
+
Z[0] ? (E.moveTo(S, o + R), E.curveTo(S, o + R - $, S + R - $, o, S + R, o)) : E.moveTo(S, o), E.lineTo(S + w - (Z[1] ? R : 0), o), Z[1] ? E.curveTo(
|
|
1398
|
+
S + w - R + $,
|
|
1399
|
+
o,
|
|
1400
|
+
S + w,
|
|
1401
|
+
o + R - $,
|
|
1402
|
+
S + w,
|
|
1403
|
+
o + R
|
|
1404
|
+
) : E.lineTo(S + w, o), E.lineTo(S + w, o + T - (Z[2] ? R : 0)), Z[2] ? E.curveTo(
|
|
1405
|
+
S + w,
|
|
1406
|
+
o + T - R + $,
|
|
1407
|
+
S + w - R + $,
|
|
1408
|
+
o + T,
|
|
1409
|
+
S + w - R,
|
|
1410
|
+
o + T
|
|
1411
|
+
) : E.lineTo(S + w, o + T), E.lineTo(S + (Z[3] ? R : 0), o + T), Z[3] ? E.curveTo(
|
|
1412
|
+
S + R - $,
|
|
1413
|
+
o + T,
|
|
1414
|
+
S,
|
|
1415
|
+
o + T - R + $,
|
|
1416
|
+
S,
|
|
1417
|
+
o + T - R
|
|
1418
|
+
) : E.lineTo(S, o + T), Z[0] ? E.lineTo(S, o + R) : E.lineTo(S, o), E.stroke();
|
|
1419
|
+
};
|
|
1420
|
+
Y(F === O ? [!0, !0, !1, !1] : F === W ? [!1, !1, !0, !0] : [!1, !1, !1, !1]);
|
|
1421
|
+
} else
|
|
1422
|
+
E.line(S, o, S, o + T), E.line(S + w, o, S + w, o + T), F === O && E.line(S, o, S + w, o), F === W && E.line(S, o + T, S + w, o + T);
|
|
1074
1423
|
}
|
|
1075
|
-
if (
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1424
|
+
if (h.fillColor) {
|
|
1425
|
+
const E = Math.max(f.x, a.margin.left), M = q, ft = _, st = L;
|
|
1426
|
+
try {
|
|
1427
|
+
if (a.injectFill) {
|
|
1428
|
+
let S = 0;
|
|
1429
|
+
R > 0 && at ? S = R : R > 0 && (F === O ? S = { tl: R, tr: R, br: 0, bl: 0 } : F === W ? S = { tl: 0, tr: 0, br: R, bl: R } : S = 0), a.injectFill(
|
|
1430
|
+
F,
|
|
1431
|
+
{ x: E, y: M, w: ft, h: st },
|
|
1432
|
+
h.fillColor,
|
|
1433
|
+
S
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
} catch (S) {
|
|
1437
|
+
console.warn("Background injection failed", S);
|
|
1438
|
+
}
|
|
1082
1439
|
}
|
|
1083
1440
|
}
|
|
1084
|
-
if (
|
|
1085
|
-
const
|
|
1086
|
-
const
|
|
1087
|
-
|
|
1441
|
+
if (a.instance.setPage(W), h.showInAllPages) {
|
|
1442
|
+
const F = () => {
|
|
1443
|
+
const U = h.height ?? 20;
|
|
1444
|
+
a.box(f.x, f.y, g, U, h);
|
|
1088
1445
|
};
|
|
1089
|
-
|
|
1090
|
-
draw:
|
|
1091
|
-
scope:
|
|
1446
|
+
a.registerRecurringItem({
|
|
1447
|
+
draw: F,
|
|
1448
|
+
scope: h.scope ?? "all",
|
|
1092
1449
|
y: f.y,
|
|
1093
|
-
height:
|
|
1450
|
+
height: h.height ?? 0
|
|
1094
1451
|
});
|
|
1095
1452
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
}
|
|
1100
|
-
e.setReservedHeight(0), e.popIndent && e.popIndent();
|
|
1101
|
-
});
|
|
1102
|
-
}, [e, t.showInAllPages, t.scope, i, s]), null;
|
|
1453
|
+
n.isAbsolute || (a.setCursor(f.x, H.y), a.popVerticalPadding ? a.popVerticalPadding() : (a.moveCursor(0, m.bottom), a.setReservedHeight(0)), x.bottom > 0 && a.moveCursor(0, x.bottom)), n.hasIndent && a.popIndent && a.popIndent();
|
|
1454
|
+
}));
|
|
1455
|
+
}, [a, t, e, s, u, c]), null;
|
|
1103
1456
|
};
|
|
1104
|
-
function
|
|
1457
|
+
function ee(n) {
|
|
1105
1458
|
return typeof n == "number" ? { top: n, right: n, bottom: n, left: n } : {
|
|
1106
1459
|
top: n?.top ?? 0,
|
|
1107
1460
|
right: n?.right ?? 0,
|
|
@@ -1109,100 +1462,123 @@ function bt(n) {
|
|
|
1109
1462
|
left: n?.left ?? 0
|
|
1110
1463
|
};
|
|
1111
1464
|
}
|
|
1112
|
-
const
|
|
1465
|
+
const re = ({
|
|
1113
1466
|
style: n,
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1467
|
+
className: t,
|
|
1468
|
+
computeStyle: r,
|
|
1469
|
+
x: i,
|
|
1470
|
+
y: e,
|
|
1471
|
+
w: s,
|
|
1472
|
+
h: u,
|
|
1473
|
+
showInAllPages: c,
|
|
1474
|
+
scope: a,
|
|
1475
|
+
viewState: y
|
|
1119
1476
|
}) => {
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1477
|
+
const f = pt(), P = z.useRef(null);
|
|
1478
|
+
return z.useLayoutEffect(() => {
|
|
1479
|
+
P.current?.pdf === f && P.current?.gen === f.generation || (P.current = { pdf: f, gen: f.generation }, f.queueOperation(() => {
|
|
1480
|
+
let p = { ...r(), ...n };
|
|
1481
|
+
const b = !!p.fillColor, d = !!p.borderColor || (p.borderWidth ?? 0) > 0, l = n.padding !== void 0 || n.paddingTop !== void 0 || n.paddingRight !== void 0 || n.paddingBottom !== void 0 || n.paddingLeft !== void 0;
|
|
1482
|
+
(b || d) && !l && !t && (p.padding = 4), c !== void 0 && (p.showInAllPages = c), a !== void 0 && (p.scope = a);
|
|
1483
|
+
const m = St(p.padding), v = {
|
|
1484
|
+
top: p.paddingTop ?? m.top,
|
|
1485
|
+
right: p.paddingRight ?? m.right,
|
|
1486
|
+
bottom: p.paddingBottom ?? m.bottom,
|
|
1487
|
+
left: p.paddingLeft ?? m.left
|
|
1488
|
+
}, C = ee(p.margin), x = {
|
|
1489
|
+
top: p.marginTop ?? C.top,
|
|
1490
|
+
right: p.marginRight ?? C.right,
|
|
1491
|
+
bottom: p.marginBottom ?? C.bottom,
|
|
1492
|
+
left: p.marginLeft ?? C.left
|
|
1493
|
+
};
|
|
1494
|
+
if (typeof i == "number" && typeof e == "number" && typeof s == "number" && typeof u == "number") {
|
|
1495
|
+
y.isAbsolute = !0;
|
|
1496
|
+
const g = f.getPageCount();
|
|
1497
|
+
y.start = { x: i, y: e, page: g }, f.setCursor(i + v.left, e + v.top);
|
|
1137
1498
|
} else {
|
|
1138
|
-
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1499
|
+
y.isAbsolute = !1, x.top > 0 && f.moveCursor(0, x.top), typeof p.height == "number" && p.height > 0 && f.moveCursor(0, p.height);
|
|
1500
|
+
const g = f.getCursor(), _ = f.getPageCount();
|
|
1501
|
+
y.start = { ...g, page: _ }, f.pushIndent ? ((v.left > 0 || v.right > 0) && (f.pushIndent(v.left, v.right), y.hasIndent = !0), f.pushVerticalPadding ? f.pushVerticalPadding(v.top, v.bottom) : (v.top > 0 && f.moveCursor(0, v.top), f.setReservedHeight(v.bottom))) : (f.setCursor(g.x + v.left, g.y + v.top), f.setReservedHeight(v.bottom));
|
|
1141
1502
|
}
|
|
1142
|
-
});
|
|
1143
|
-
}, [e,
|
|
1144
|
-
}
|
|
1145
|
-
function vt(n) {
|
|
1146
|
-
return typeof n == "number" ? { top: n, right: n, bottom: n, left: n } : {
|
|
1147
|
-
top: n?.top ?? 0,
|
|
1148
|
-
right: n?.right ?? 0,
|
|
1149
|
-
bottom: n?.bottom ?? 0,
|
|
1150
|
-
left: n?.left ?? 0
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
const Et = ({
|
|
1503
|
+
}));
|
|
1504
|
+
}, [f, n, i, e, s, u, c, a]), null;
|
|
1505
|
+
}, de = ({
|
|
1154
1506
|
style: n = {},
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1507
|
+
className: t,
|
|
1508
|
+
style: r,
|
|
1509
|
+
children: i,
|
|
1510
|
+
x: e,
|
|
1511
|
+
y: s,
|
|
1512
|
+
w: u,
|
|
1513
|
+
h: c,
|
|
1514
|
+
showInAllPages: a,
|
|
1515
|
+
scope: y
|
|
1160
1516
|
}) => {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1517
|
+
const { ref: f, computeStyle: P } = wt(), h = Ot({}).current;
|
|
1518
|
+
return /* @__PURE__ */ tt.jsxs(z.Fragment, { children: [
|
|
1519
|
+
/* @__PURE__ */ tt.jsx(
|
|
1520
|
+
"div",
|
|
1521
|
+
{
|
|
1522
|
+
ref: f,
|
|
1523
|
+
className: t,
|
|
1524
|
+
style: {
|
|
1525
|
+
...r,
|
|
1526
|
+
position: "absolute",
|
|
1527
|
+
visibility: "hidden",
|
|
1528
|
+
pointerEvents: "none"
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
),
|
|
1532
|
+
/* @__PURE__ */ tt.jsx(
|
|
1533
|
+
re,
|
|
1176
1534
|
{
|
|
1177
1535
|
style: n,
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1536
|
+
className: t,
|
|
1537
|
+
computeStyle: P,
|
|
1538
|
+
x: e,
|
|
1539
|
+
y: s,
|
|
1540
|
+
w: u,
|
|
1541
|
+
h: c,
|
|
1542
|
+
showInAllPages: a,
|
|
1543
|
+
scope: y,
|
|
1544
|
+
viewState: h
|
|
1183
1545
|
}
|
|
1184
1546
|
),
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1547
|
+
n.gap ? z.Children.map(i, (p, b) => /* @__PURE__ */ tt.jsxs(z.Fragment, { children: [
|
|
1548
|
+
b > 0 && /* @__PURE__ */ tt.jsx(oe, { height: n.gap }),
|
|
1549
|
+
p
|
|
1550
|
+
] })) : i,
|
|
1551
|
+
/* @__PURE__ */ tt.jsx(
|
|
1552
|
+
te,
|
|
1188
1553
|
{
|
|
1189
|
-
viewState:
|
|
1554
|
+
viewState: h,
|
|
1190
1555
|
style: n,
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1556
|
+
className: t,
|
|
1557
|
+
computeStyle: P,
|
|
1558
|
+
x: e,
|
|
1559
|
+
y: s,
|
|
1560
|
+
w: u,
|
|
1561
|
+
h: c,
|
|
1562
|
+
showInAllPages: a,
|
|
1563
|
+
scope: y
|
|
1195
1564
|
}
|
|
1196
1565
|
)
|
|
1197
1566
|
] });
|
|
1567
|
+
}, oe = ({ height: n }) => {
|
|
1568
|
+
const t = pt(), r = z.useRef(null);
|
|
1569
|
+
return z.useLayoutEffect(() => {
|
|
1570
|
+
n && (r.current?.pdf === t && r.current?.gen === t.generation || (r.current = { pdf: t, gen: t.generation }, t.queueOperation(() => {
|
|
1571
|
+
t.moveCursor(0, n);
|
|
1572
|
+
})));
|
|
1573
|
+
}, [n, t]), null;
|
|
1198
1574
|
};
|
|
1199
1575
|
export {
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1576
|
+
Kt as PdfDocument,
|
|
1577
|
+
se as PdfImage,
|
|
1578
|
+
ae as PdfList,
|
|
1579
|
+
ce as PdfPreview,
|
|
1580
|
+
Qt as PdfRenderer,
|
|
1581
|
+
fe as PdfTable,
|
|
1582
|
+
le as PdfText,
|
|
1583
|
+
de as PdfView
|
|
1208
1584
|
};
|