react-vector-pdf 0.3.4 → 0.3.5
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.
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import A, { createContext as
|
|
2
|
-
import { jsPDF as
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
if (
|
|
7
|
-
|
|
1
|
+
import A, { createContext as at, useContext as ft, useState as ct } from "react";
|
|
2
|
+
import { jsPDF as tt } from "jspdf";
|
|
3
|
+
var Q = { exports: {} }, $ = {};
|
|
4
|
+
var et;
|
|
5
|
+
function lt() {
|
|
6
|
+
if (et) return $;
|
|
7
|
+
et = 1;
|
|
8
8
|
var i = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
9
9
|
function r(n, o, s) {
|
|
10
|
-
var
|
|
11
|
-
if (s !== void 0 && (
|
|
10
|
+
var a = null;
|
|
11
|
+
if (s !== void 0 && (a = "" + s), o.key !== void 0 && (a = "" + o.key), "key" in o) {
|
|
12
12
|
s = {};
|
|
13
|
-
for (var
|
|
14
|
-
|
|
13
|
+
for (var c in o)
|
|
14
|
+
c !== "key" && (s[c] = o[c]);
|
|
15
15
|
} else s = o;
|
|
16
16
|
return o = s.ref, {
|
|
17
17
|
$$typeof: i,
|
|
18
18
|
type: n,
|
|
19
|
-
key:
|
|
19
|
+
key: a,
|
|
20
20
|
ref: o !== void 0 ? o : null,
|
|
21
21
|
props: s
|
|
22
22
|
};
|
|
@@ -24,24 +24,24 @@ function ct() {
|
|
|
24
24
|
return $.Fragment = t, $.jsx = r, $.jsxs = r, $;
|
|
25
25
|
}
|
|
26
26
|
var V = {};
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
return
|
|
27
|
+
var rt;
|
|
28
|
+
function ut() {
|
|
29
|
+
return rt || (rt = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
30
30
|
function i(e) {
|
|
31
31
|
if (e == null) return null;
|
|
32
32
|
if (typeof e == "function")
|
|
33
33
|
return e.$$typeof === S ? null : e.displayName || e.name || null;
|
|
34
34
|
if (typeof e == "string") return e;
|
|
35
35
|
switch (e) {
|
|
36
|
-
case
|
|
36
|
+
case h:
|
|
37
37
|
return "Fragment";
|
|
38
|
-
case
|
|
38
|
+
case X:
|
|
39
39
|
return "Profiler";
|
|
40
40
|
case O:
|
|
41
41
|
return "StrictMode";
|
|
42
|
-
case
|
|
42
|
+
case J:
|
|
43
43
|
return "Suspense";
|
|
44
|
-
case
|
|
44
|
+
case b:
|
|
45
45
|
return "SuspenseList";
|
|
46
46
|
case W:
|
|
47
47
|
return "Activity";
|
|
@@ -50,21 +50,21 @@ function lt() {
|
|
|
50
50
|
switch (typeof e.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
|
), e.$$typeof) {
|
|
53
|
-
case
|
|
53
|
+
case E:
|
|
54
54
|
return "Portal";
|
|
55
|
-
case
|
|
55
|
+
case U:
|
|
56
56
|
return e.displayName || "Context";
|
|
57
57
|
case N:
|
|
58
58
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
59
|
-
case
|
|
60
|
-
var
|
|
61
|
-
return e = e.displayName, e || (e =
|
|
62
|
-
case
|
|
63
|
-
return
|
|
59
|
+
case B:
|
|
60
|
+
var l = e.render;
|
|
61
|
+
return e = e.displayName, e || (e = l.displayName || l.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
62
|
+
case R:
|
|
63
|
+
return l = e.displayName || null, l !== null ? l : i(e.type) || "Memo";
|
|
64
64
|
case P:
|
|
65
|
-
|
|
65
|
+
l = e._payload, e = e._init;
|
|
66
66
|
try {
|
|
67
|
-
return i(e(
|
|
67
|
+
return i(e(l));
|
|
68
68
|
} catch {
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -76,27 +76,27 @@ function lt() {
|
|
|
76
76
|
function r(e) {
|
|
77
77
|
try {
|
|
78
78
|
t(e);
|
|
79
|
-
var
|
|
79
|
+
var l = !1;
|
|
80
80
|
} catch {
|
|
81
|
-
|
|
81
|
+
l = !0;
|
|
82
82
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
return
|
|
87
|
-
|
|
83
|
+
if (l) {
|
|
84
|
+
l = console;
|
|
85
|
+
var g = l.error, C = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
86
|
+
return g.call(
|
|
87
|
+
l,
|
|
88
88
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
89
|
-
|
|
89
|
+
C
|
|
90
90
|
), t(e);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function n(e) {
|
|
94
|
-
if (e ===
|
|
94
|
+
if (e === h) return "<>";
|
|
95
95
|
if (typeof e == "object" && e !== null && e.$$typeof === P)
|
|
96
96
|
return "<...>";
|
|
97
97
|
try {
|
|
98
|
-
var
|
|
99
|
-
return
|
|
98
|
+
var l = i(e);
|
|
99
|
+
return l ? "<" + l + ">" : "<...>";
|
|
100
100
|
} catch {
|
|
101
101
|
return "<...>";
|
|
102
102
|
}
|
|
@@ -108,42 +108,42 @@ function lt() {
|
|
|
108
108
|
function s() {
|
|
109
109
|
return Error("react-stack-top-frame");
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function a(e) {
|
|
112
112
|
if (D.call(e, "key")) {
|
|
113
|
-
var
|
|
114
|
-
if (
|
|
113
|
+
var l = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
114
|
+
if (l && l.isReactWarning) return !1;
|
|
115
115
|
}
|
|
116
116
|
return e.key !== void 0;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
function
|
|
120
|
-
|
|
118
|
+
function c(e, l) {
|
|
119
|
+
function g() {
|
|
120
|
+
T || (T = !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
|
+
l
|
|
123
123
|
));
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
get:
|
|
125
|
+
g.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
126
|
+
get: g,
|
|
127
127
|
configurable: !0
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function u() {
|
|
131
131
|
var e = i(this.type);
|
|
132
|
-
return
|
|
132
|
+
return w[e] || (w[e] = !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
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
var
|
|
136
|
+
function m(e, l, g, C, L, _) {
|
|
137
|
+
var y = g.ref;
|
|
138
138
|
return e = {
|
|
139
139
|
$$typeof: j,
|
|
140
140
|
type: e,
|
|
141
|
-
key:
|
|
142
|
-
props:
|
|
143
|
-
_owner:
|
|
144
|
-
}, (
|
|
141
|
+
key: l,
|
|
142
|
+
props: g,
|
|
143
|
+
_owner: C
|
|
144
|
+
}, (y !== void 0 ? y : null) !== null ? Object.defineProperty(e, "ref", {
|
|
145
145
|
enumerable: !1,
|
|
146
|
-
get:
|
|
146
|
+
get: u
|
|
147
147
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
148
148
|
configurable: !1,
|
|
149
149
|
enumerable: !1,
|
|
@@ -166,61 +166,61 @@ function lt() {
|
|
|
166
166
|
value: _
|
|
167
167
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
var
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
if (Y(
|
|
174
|
-
for (
|
|
175
|
-
|
|
176
|
-
Object.freeze && Object.freeze(
|
|
169
|
+
function f(e, l, g, C, L, _) {
|
|
170
|
+
var y = l.children;
|
|
171
|
+
if (y !== void 0)
|
|
172
|
+
if (C)
|
|
173
|
+
if (Y(y)) {
|
|
174
|
+
for (C = 0; C < y.length; C++)
|
|
175
|
+
x(y[C]);
|
|
176
|
+
Object.freeze && Object.freeze(y);
|
|
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 (D.call(
|
|
183
|
-
|
|
184
|
-
var
|
|
185
|
-
return
|
|
181
|
+
else x(y);
|
|
182
|
+
if (D.call(l, "key")) {
|
|
183
|
+
y = i(e);
|
|
184
|
+
var M = Object.keys(l).filter(function(st) {
|
|
185
|
+
return st !== "key";
|
|
186
186
|
});
|
|
187
|
-
|
|
187
|
+
C = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", F[y + C] || (M = 0 < M.length ? "{" + M.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
|
-
), F[
|
|
194
|
+
C,
|
|
195
|
+
y,
|
|
196
|
+
M,
|
|
197
|
+
y
|
|
198
|
+
), F[y + C] = !0);
|
|
199
199
|
}
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
for (var K in
|
|
203
|
-
K !== "key" && (
|
|
204
|
-
} else
|
|
205
|
-
return
|
|
206
|
-
|
|
200
|
+
if (y = null, g !== void 0 && (r(g), y = "" + g), a(l) && (r(l.key), y = "" + l.key), "key" in l) {
|
|
201
|
+
g = {};
|
|
202
|
+
for (var K in l)
|
|
203
|
+
K !== "key" && (g[K] = l[K]);
|
|
204
|
+
} else g = l;
|
|
205
|
+
return y && c(
|
|
206
|
+
g,
|
|
207
207
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
208
|
-
),
|
|
208
|
+
), m(
|
|
209
209
|
e,
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
y,
|
|
211
|
+
g,
|
|
212
212
|
o(),
|
|
213
213
|
L,
|
|
214
214
|
_
|
|
215
215
|
);
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
217
|
+
function x(e) {
|
|
218
|
+
d(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? d(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function d(e) {
|
|
221
221
|
return typeof e == "object" && e !== null && e.$$typeof === j;
|
|
222
222
|
}
|
|
223
|
-
var H = A, j = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
223
|
+
var H = A, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), E = /* @__PURE__ */ Symbol.for("react.portal"), h = /* @__PURE__ */ Symbol.for("react.fragment"), O = /* @__PURE__ */ Symbol.for("react.strict_mode"), X = /* @__PURE__ */ Symbol.for("react.profiler"), N = /* @__PURE__ */ Symbol.for("react.consumer"), U = /* @__PURE__ */ Symbol.for("react.context"), B = /* @__PURE__ */ Symbol.for("react.forward_ref"), J = /* @__PURE__ */ Symbol.for("react.suspense"), b = /* @__PURE__ */ Symbol.for("react.suspense_list"), R = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), W = /* @__PURE__ */ Symbol.for("react.activity"), S = /* @__PURE__ */ Symbol.for("react.client.reference"), p = H.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, Y = Array.isArray, z = console.createTask ? console.createTask : function() {
|
|
224
224
|
return null;
|
|
225
225
|
};
|
|
226
226
|
H = {
|
|
@@ -228,42 +228,42 @@ React keys must be passed directly to JSX without using spread:
|
|
|
228
228
|
return e();
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
-
var
|
|
231
|
+
var T, w = {}, k = H.react_stack_bottom_frame.bind(
|
|
232
232
|
H,
|
|
233
233
|
s
|
|
234
|
-
)(),
|
|
235
|
-
V.Fragment =
|
|
236
|
-
var
|
|
237
|
-
return
|
|
234
|
+
)(), v = z(n(s)), F = {};
|
|
235
|
+
V.Fragment = h, V.jsx = function(e, l, g) {
|
|
236
|
+
var C = 1e4 > p.recentlyCreatedOwnerStacks++;
|
|
237
|
+
return f(
|
|
238
238
|
e,
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
l,
|
|
240
|
+
g,
|
|
241
241
|
!1,
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
C ? Error("react-stack-top-frame") : k,
|
|
243
|
+
C ? z(n(e)) : v
|
|
244
244
|
);
|
|
245
|
-
}, V.jsxs = function(e,
|
|
246
|
-
var
|
|
247
|
-
return
|
|
245
|
+
}, V.jsxs = function(e, l, g) {
|
|
246
|
+
var C = 1e4 > p.recentlyCreatedOwnerStacks++;
|
|
247
|
+
return f(
|
|
248
248
|
e,
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
l,
|
|
250
|
+
g,
|
|
251
251
|
!0,
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
C ? Error("react-stack-top-frame") : k,
|
|
253
|
+
C ? z(n(e)) : v
|
|
254
254
|
);
|
|
255
255
|
};
|
|
256
256
|
})()), V;
|
|
257
257
|
}
|
|
258
|
-
var
|
|
259
|
-
function
|
|
260
|
-
return
|
|
258
|
+
var ot;
|
|
259
|
+
function ht() {
|
|
260
|
+
return ot || (ot = 1, process.env.NODE_ENV === "production" ? Q.exports = lt() : Q.exports = ut()), Q.exports;
|
|
261
261
|
}
|
|
262
|
-
var
|
|
262
|
+
var I = ht();
|
|
263
263
|
function Z(i) {
|
|
264
264
|
return !i && i !== 0 ? { top: 0, right: 0, bottom: 0, left: 0 } : typeof i == "number" ? { top: i, right: i, bottom: i, left: i } : { top: i.top ?? 0, right: i.right ?? 0, bottom: i.bottom ?? 0, left: i.left ?? 0 };
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function G(i) {
|
|
267
267
|
const t = i.replace("#", "");
|
|
268
268
|
if (t.length === 3) {
|
|
269
269
|
const r = parseInt(t[0] + t[0], 16), n = parseInt(t[1] + t[1], 16), o = parseInt(t[2] + t[2], 16);
|
|
@@ -275,7 +275,7 @@ function Q(i) {
|
|
|
275
275
|
}
|
|
276
276
|
return null;
|
|
277
277
|
}
|
|
278
|
-
function
|
|
278
|
+
function nt(i, t = !0) {
|
|
279
279
|
if (i <= 0) return String(i);
|
|
280
280
|
const r = [
|
|
281
281
|
[1e3, "M"],
|
|
@@ -293,22 +293,22 @@ function ot(i, t = !0) {
|
|
|
293
293
|
[1, "I"]
|
|
294
294
|
];
|
|
295
295
|
let n = i, o = "";
|
|
296
|
-
for (const [s,
|
|
296
|
+
for (const [s, a] of r)
|
|
297
297
|
for (; n >= s; )
|
|
298
|
-
o +=
|
|
298
|
+
o += a, n -= s;
|
|
299
299
|
return t ? o : o.toLowerCase();
|
|
300
300
|
}
|
|
301
|
-
class
|
|
301
|
+
class dt {
|
|
302
302
|
constructor(t = {}) {
|
|
303
303
|
this.cursorX = 0, this.cursorY = 0, this.contentWidth = 0, this.margin = { top: 15, right: 15, bottom: 15, left: 15 }, this.defaultFont = {
|
|
304
304
|
name: void 0,
|
|
305
305
|
style: "normal",
|
|
306
306
|
size: 12
|
|
307
|
-
}, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.margin = t.margin ?? this.margin, this.defaultFont = {
|
|
307
|
+
}, this.defaultColor = "#111827", this.defaultLineHeight = 1.25, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.generation = 0, this.options = t, this.margin = t.margin ?? this.margin, this.defaultFont = {
|
|
308
308
|
name: t.font?.name,
|
|
309
309
|
style: t.font?.style ?? "normal",
|
|
310
310
|
size: t.font?.size ?? 12
|
|
311
|
-
}, this.defaultColor = t.color ?? this.defaultColor, this.defaultLineHeight = t.lineHeight ?? this.defaultLineHeight, this.pdf = new
|
|
311
|
+
}, this.defaultColor = t.color ?? this.defaultColor, this.defaultLineHeight = t.lineHeight ?? this.defaultLineHeight, this.pdf = new tt({
|
|
312
312
|
unit: t.unit ?? "mm",
|
|
313
313
|
format: t.format ?? "a4",
|
|
314
314
|
orientation: t.orientation ?? "p"
|
|
@@ -350,13 +350,23 @@ class ht {
|
|
|
350
350
|
resetFlowCursor() {
|
|
351
351
|
this.cursorX = this.margin.left, this.cursorY = this.margin.top, this.contentWidth = this.pageWidth - this.margin.left - this.margin.right;
|
|
352
352
|
}
|
|
353
|
+
reset() {
|
|
354
|
+
if (this.pdf = new tt({
|
|
355
|
+
unit: this.options.unit ?? "mm",
|
|
356
|
+
format: this.options.format ?? "a4",
|
|
357
|
+
orientation: this.options.orientation ?? "p"
|
|
358
|
+
}), this.generation++, this.cursorX = 0, this.cursorY = 0, this.pendingTasks = /* @__PURE__ */ new Set(), this.opQueue = Promise.resolve(), this.resetFlowCursor(), this.applyBaseFont(), this.options.color) {
|
|
359
|
+
const t = G(this.options.color);
|
|
360
|
+
t && this.pdf.setTextColor(...t);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
353
363
|
setHeaderFooter(t, r) {
|
|
354
364
|
this.headerDrawer = t, this.footerDrawer = r;
|
|
355
365
|
}
|
|
356
366
|
applyBaseFont() {
|
|
357
367
|
const t = this.defaultFont.name ?? this.pdf.getFont().fontName;
|
|
358
368
|
this.pdf.setFont(t, this.defaultFont.style), this.pdf.setFontSize(this.defaultFont.size);
|
|
359
|
-
const r =
|
|
369
|
+
const r = G(this.defaultColor);
|
|
360
370
|
r && this.pdf.setTextColor(...r);
|
|
361
371
|
}
|
|
362
372
|
addPage() {
|
|
@@ -372,26 +382,26 @@ class ht {
|
|
|
372
382
|
this.pdf.setFont(r, t.fontStyle);
|
|
373
383
|
}
|
|
374
384
|
if (t.color) {
|
|
375
|
-
const r =
|
|
385
|
+
const r = G(t.color);
|
|
376
386
|
r && this.pdf.setTextColor(...r);
|
|
377
387
|
}
|
|
378
388
|
}
|
|
379
389
|
}
|
|
380
|
-
textRaw(t, r, n, o, s,
|
|
390
|
+
textRaw(t, r, n, o, s, a = "left") {
|
|
381
391
|
this.setTextStyle(o);
|
|
382
|
-
const
|
|
383
|
-
typeof s == "number" && (
|
|
392
|
+
const c = { align: a };
|
|
393
|
+
typeof s == "number" && (c.maxWidth = s), this.pdf.text(t, r, n, c), this.applyBaseFont();
|
|
384
394
|
}
|
|
385
395
|
box(t, r, n, o, s) {
|
|
386
|
-
const
|
|
387
|
-
if (
|
|
388
|
-
const
|
|
389
|
-
|
|
396
|
+
const a = s ?? {};
|
|
397
|
+
if (a.fillColor) {
|
|
398
|
+
const c = G(a.fillColor);
|
|
399
|
+
c && this.pdf.setFillColor(...c), this.pdf.rect(t, r, n, o, "F");
|
|
390
400
|
}
|
|
391
|
-
if (
|
|
392
|
-
if (
|
|
393
|
-
const
|
|
394
|
-
|
|
401
|
+
if (a.borderWidth || a.borderColor) {
|
|
402
|
+
if (a.borderWidth && this.pdf.setLineWidth(a.borderWidth), a.borderColor) {
|
|
403
|
+
const c = G(a.borderColor);
|
|
404
|
+
c && this.pdf.setDrawColor(...c);
|
|
395
405
|
}
|
|
396
406
|
this.pdf.rect(t, r, n, o), this.pdf.setLineWidth(0.2), this.pdf.setDrawColor(0, 0, 0);
|
|
397
407
|
}
|
|
@@ -402,23 +412,23 @@ class ht {
|
|
|
402
412
|
async imageFromUrl(t, r = {}) {
|
|
403
413
|
const n = (async () => {
|
|
404
414
|
try {
|
|
405
|
-
const { dataUrl: o, width: s, height:
|
|
406
|
-
let
|
|
407
|
-
|
|
408
|
-
const
|
|
409
|
-
let j = r.x,
|
|
410
|
-
if (r.y === void 0 &&
|
|
411
|
-
const
|
|
412
|
-
|
|
415
|
+
const { dataUrl: o, width: s, height: a } = await this.loadImageAsDataURL(t), c = 0.264583, u = s * c, m = a * c;
|
|
416
|
+
let f = r.w, x = r.h;
|
|
417
|
+
f === void 0 && x === void 0 ? (f = u, x = m) : f === void 0 && x !== void 0 ? f = x * (u / m) : x === void 0 && f !== void 0 && (x = f * (m / u));
|
|
418
|
+
const d = f ?? u, H = x ?? m;
|
|
419
|
+
let j = r.x, E = r.y ?? this.cursorY;
|
|
420
|
+
if (r.y === void 0 && E + H > this.contentBottom && (this.addPage(), E = this.cursorY), j === void 0) {
|
|
421
|
+
const h = r.align ?? "left";
|
|
422
|
+
h === "left" ? j = this.contentLeft : h === "center" ? j = (this.contentLeft + this.contentRight) / 2 - d / 2 : h === "right" && (j = this.contentRight - d);
|
|
413
423
|
}
|
|
414
424
|
return this.pdf.addImage(
|
|
415
425
|
o,
|
|
416
426
|
r.mime ?? "PNG",
|
|
417
427
|
j,
|
|
418
|
-
|
|
419
|
-
|
|
428
|
+
E,
|
|
429
|
+
d,
|
|
420
430
|
H
|
|
421
|
-
), { width:
|
|
431
|
+
), { width: d, height: H, x: j, y: E };
|
|
422
432
|
} catch (o) {
|
|
423
433
|
return console.error("Failed to load image", t, o), { width: 0, height: 0, x: 0, y: 0 };
|
|
424
434
|
}
|
|
@@ -426,14 +436,15 @@ class ht {
|
|
|
426
436
|
return this.registerTask(n), n;
|
|
427
437
|
}
|
|
428
438
|
queueOperation(t) {
|
|
429
|
-
const r = this.opQueue.then(async () => {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
439
|
+
const r = this.generation, n = this.opQueue.then(async () => {
|
|
440
|
+
if (this.generation === r)
|
|
441
|
+
try {
|
|
442
|
+
await t();
|
|
443
|
+
} catch (o) {
|
|
444
|
+
console.error("Operation failed", o);
|
|
445
|
+
}
|
|
435
446
|
});
|
|
436
|
-
this.opQueue =
|
|
447
|
+
this.opQueue = n, this.registerTask(n);
|
|
437
448
|
}
|
|
438
449
|
registerTask(t) {
|
|
439
450
|
this.pendingTasks.add(t), t.finally(() => {
|
|
@@ -449,9 +460,9 @@ class ht {
|
|
|
449
460
|
o.crossOrigin = "anonymous", o.onload = () => {
|
|
450
461
|
const s = document.createElement("canvas");
|
|
451
462
|
s.width = o.width, s.height = o.height;
|
|
452
|
-
const
|
|
453
|
-
if (!
|
|
454
|
-
|
|
463
|
+
const a = s.getContext("2d");
|
|
464
|
+
if (!a) return n(new Error("Canvas 2D context not available"));
|
|
465
|
+
a.drawImage(o, 0, 0), r({
|
|
455
466
|
dataUrl: s.toDataURL("image/png"),
|
|
456
467
|
width: o.width,
|
|
457
468
|
height: o.height
|
|
@@ -462,13 +473,13 @@ class ht {
|
|
|
462
473
|
paragraph(t, r, n) {
|
|
463
474
|
const o = n ?? this.contentWidth;
|
|
464
475
|
this.setTextStyle(r);
|
|
465
|
-
const s = r?.lineHeight ?? this.defaultLineHeight,
|
|
466
|
-
let
|
|
467
|
-
return
|
|
468
|
-
this.cursorY +
|
|
469
|
-
const
|
|
470
|
-
this.pdf.text(
|
|
471
|
-
}), this.cursorY += 1, this.applyBaseFont(),
|
|
476
|
+
const s = r?.lineHeight ?? this.defaultLineHeight, a = r?.fontSize ?? this.defaultFont.size, c = a * s * 0.3528, u = this.pdf.splitTextToSize(t, o), m = r?.align ?? "left";
|
|
477
|
+
let f = 0;
|
|
478
|
+
return u.forEach((x) => {
|
|
479
|
+
this.cursorY + c > this.contentBottom && this.addPage();
|
|
480
|
+
const d = this.cursorY + a * 0.3528;
|
|
481
|
+
this.pdf.text(x, this.cursorX, d, { align: m, maxWidth: o }), this.cursorY += c, f += c;
|
|
482
|
+
}), this.cursorY += 1, this.applyBaseFont(), f;
|
|
472
483
|
}
|
|
473
484
|
moveCursor(t, r) {
|
|
474
485
|
this.cursorX += t, this.cursorY += r;
|
|
@@ -492,16 +503,16 @@ class ht {
|
|
|
492
503
|
}
|
|
493
504
|
measureText(t, r, n) {
|
|
494
505
|
this.setTextStyle(r);
|
|
495
|
-
const o = r?.fontSize ?? this.defaultFont.size, s = r?.lineHeight ?? this.defaultLineHeight,
|
|
506
|
+
const o = r?.fontSize ?? this.defaultFont.size, s = r?.lineHeight ?? this.defaultLineHeight, a = o * s * 0.3528;
|
|
496
507
|
if (n) {
|
|
497
|
-
const
|
|
508
|
+
const c = this.pdf.splitTextToSize(t, n);
|
|
498
509
|
return {
|
|
499
510
|
width: n,
|
|
500
|
-
height:
|
|
511
|
+
height: c.length * a
|
|
501
512
|
};
|
|
502
513
|
} else {
|
|
503
|
-
const
|
|
504
|
-
return { width:
|
|
514
|
+
const c = this.pdf.getTextDimensions(t);
|
|
515
|
+
return { width: c.w, height: c.h };
|
|
505
516
|
}
|
|
506
517
|
}
|
|
507
518
|
setMetadata(t) {
|
|
@@ -512,57 +523,62 @@ class ht {
|
|
|
512
523
|
save(t) {
|
|
513
524
|
this.applyHeaderFooter(), this.pdf.save(t);
|
|
514
525
|
}
|
|
526
|
+
getBlobUrl() {
|
|
527
|
+
return this.applyHeaderFooter(), this.pdf.output("bloburl");
|
|
528
|
+
}
|
|
515
529
|
}
|
|
516
|
-
const
|
|
517
|
-
const i =
|
|
530
|
+
const it = at(null), q = () => {
|
|
531
|
+
const i = ft(it);
|
|
518
532
|
if (!i) throw new Error("usePdf must be used within <PdfDocument>");
|
|
519
533
|
return i;
|
|
520
|
-
},
|
|
534
|
+
}, gt = ({
|
|
521
535
|
options: i,
|
|
522
536
|
header: t,
|
|
523
537
|
footer: r,
|
|
524
538
|
pageNumbers: n,
|
|
525
539
|
centerLabel: o,
|
|
526
540
|
metadata: s,
|
|
527
|
-
children:
|
|
528
|
-
onReady:
|
|
529
|
-
filename:
|
|
530
|
-
autoSave:
|
|
541
|
+
children: a,
|
|
542
|
+
onReady: c,
|
|
543
|
+
filename: u,
|
|
544
|
+
autoSave: m = !1
|
|
531
545
|
}) => {
|
|
532
|
-
const
|
|
546
|
+
const f = A.useMemo(() => new dt(i), [i]);
|
|
533
547
|
return A.useEffect(() => {
|
|
534
|
-
s &&
|
|
535
|
-
}, [
|
|
536
|
-
const
|
|
537
|
-
if (!n?.enabled || !
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
}, j = (
|
|
541
|
-
if (!o?.enabled || !
|
|
542
|
-
const
|
|
543
|
-
|
|
548
|
+
s && f.setMetadata(s);
|
|
549
|
+
}, [f, s]), A.useEffect(() => {
|
|
550
|
+
const x = (E, h) => !h || h === "all" ? !0 : h === "first-only" ? E === 1 : h === "except-first" ? E > 1 : Array.isArray(h) ? h.includes(E) : !0, d = (E, h) => h === "roman-upper" ? nt(E, !0) : h === "roman-lower" ? nt(E, !1) : String(E), H = (E, h, O) => {
|
|
551
|
+
if (!n?.enabled || !x(h, n.scope)) return;
|
|
552
|
+
const X = n.preset ?? "page-slash-total", U = (n.template ?? (X === "page-slash-total" ? "Page {page}/{total}" : X === "page-of-total" ? "Page {page} of {total}" : "{page}/{total}")).replace("{page}", d(h, n.format)).replace("{total}", d(O, n.format)), B = n.align ?? "right", J = B === "left" ? f.contentLeft + (n.offsetX ?? 0) : B === "right" ? f.contentRight - (n.offsetX ?? 0) : (f.contentLeft + f.contentRight) / 2 + (n.offsetX ?? 0), b = E === "header" ? 10 : f.height - 7, R = typeof n.y == "number" ? n.y : b;
|
|
553
|
+
f.textRaw(U, J, R, n.style, void 0, B);
|
|
554
|
+
}, j = (E, h, O) => {
|
|
555
|
+
if (!o?.enabled || !x(h, o.scope)) return;
|
|
556
|
+
const X = "center", N = (f.contentLeft + f.contentRight) / 2 + (o.offsetX ?? 0), U = E === "header" ? 10 : f.height - 7, B = typeof o.y == "number" ? o.y : U;
|
|
557
|
+
f.textRaw(
|
|
544
558
|
o.text,
|
|
545
559
|
N,
|
|
546
|
-
|
|
560
|
+
B,
|
|
547
561
|
o.style,
|
|
548
562
|
void 0,
|
|
549
|
-
|
|
563
|
+
X
|
|
550
564
|
);
|
|
551
565
|
};
|
|
552
|
-
|
|
553
|
-
(
|
|
554
|
-
t && t(
|
|
566
|
+
return f.setHeaderFooter(
|
|
567
|
+
(E, h, O) => {
|
|
568
|
+
t && t(f, h, O), n?.position === "header" && H("header", h, O), o?.position === "header" && j("header", h);
|
|
555
569
|
},
|
|
556
|
-
(
|
|
557
|
-
n?.position === "footer" && H("footer",
|
|
570
|
+
(E, h, O) => {
|
|
571
|
+
n?.position === "footer" && H("footer", h, O), r && r(f, h, O), o?.position === "footer" && j("footer", h);
|
|
558
572
|
}
|
|
559
|
-
),
|
|
560
|
-
|
|
561
|
-
})
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}, [
|
|
565
|
-
|
|
573
|
+
), f.waitForTasks().then(() => {
|
|
574
|
+
c?.(f);
|
|
575
|
+
}), () => {
|
|
576
|
+
f.reset();
|
|
577
|
+
};
|
|
578
|
+
}, [f]), A.useEffect(() => {
|
|
579
|
+
m && u && f.save(u);
|
|
580
|
+
}, [m, u]), /* @__PURE__ */ I.jsx(it.Provider, { value: f, children: a });
|
|
581
|
+
}, xt = ({
|
|
566
582
|
x: i,
|
|
567
583
|
y: t,
|
|
568
584
|
w: r,
|
|
@@ -570,65 +586,65 @@ const nt = st(null), q = () => {
|
|
|
570
586
|
children: o,
|
|
571
587
|
...s
|
|
572
588
|
}) => {
|
|
573
|
-
const
|
|
574
|
-
top: s.paddingTop ??
|
|
575
|
-
right: s.paddingRight ??
|
|
576
|
-
bottom: s.paddingBottom ??
|
|
577
|
-
left: s.paddingLeft ??
|
|
578
|
-
},
|
|
589
|
+
const a = q(), c = Z(s.padding), u = {
|
|
590
|
+
top: s.paddingTop ?? c.top,
|
|
591
|
+
right: s.paddingRight ?? c.right,
|
|
592
|
+
bottom: s.paddingBottom ?? c.bottom,
|
|
593
|
+
left: s.paddingLeft ?? c.left
|
|
594
|
+
}, m = A.useRef(
|
|
579
595
|
{}
|
|
580
596
|
).current;
|
|
581
597
|
return typeof i == "number" && typeof t == "number" && typeof r == "number" && typeof n == "number" ? (A.useEffect(() => {
|
|
582
|
-
|
|
583
|
-
|
|
598
|
+
a.queueOperation(() => {
|
|
599
|
+
a.box(i, t, r, n, s);
|
|
584
600
|
});
|
|
585
|
-
}, [i, t, r, n]), /* @__PURE__ */
|
|
586
|
-
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
const
|
|
590
|
-
|
|
601
|
+
}, [a, i, t, r, n]), /* @__PURE__ */ I.jsx(A.Fragment, { children: o })) : (A.useEffect(() => {
|
|
602
|
+
a.queueOperation(() => {
|
|
603
|
+
const f = a.getCursor();
|
|
604
|
+
m.start = { ...f };
|
|
605
|
+
const x = f.x + u.left, d = f.y + u.top;
|
|
606
|
+
a.setCursor(x, d);
|
|
591
607
|
});
|
|
592
|
-
}, []), /* @__PURE__ */
|
|
608
|
+
}, [a]), /* @__PURE__ */ I.jsxs(A.Fragment, { children: [
|
|
593
609
|
o,
|
|
594
|
-
/* @__PURE__ */
|
|
610
|
+
/* @__PURE__ */ I.jsx(pt, { boxState: m, pad: u, style: s })
|
|
595
611
|
] }));
|
|
596
|
-
},
|
|
612
|
+
}, pt = ({ boxState: i, style: t, pad: r }) => {
|
|
597
613
|
const n = q();
|
|
598
614
|
return A.useEffect(() => {
|
|
599
615
|
n.queueOperation(() => {
|
|
600
616
|
const o = i.start;
|
|
601
617
|
if (!o) return;
|
|
602
|
-
const s = n.getCursor(),
|
|
603
|
-
n.box(o.x, o.y, n.contentAreaWidth,
|
|
618
|
+
const s = n.getCursor(), c = Math.max(s.y - o.y - r.top, 0) + r.top + r.bottom;
|
|
619
|
+
n.box(o.x, o.y, n.contentAreaWidth, c, t), n.setCursor(o.x, o.y + c);
|
|
604
620
|
});
|
|
605
|
-
}, []), null;
|
|
606
|
-
},
|
|
621
|
+
}, [n]), null;
|
|
622
|
+
}, Rt = ({
|
|
607
623
|
src: i,
|
|
608
624
|
x: t,
|
|
609
625
|
y: r,
|
|
610
626
|
w: n,
|
|
611
627
|
h: o,
|
|
612
628
|
mime: s = "PNG",
|
|
613
|
-
flow:
|
|
614
|
-
align:
|
|
629
|
+
flow: a,
|
|
630
|
+
align: c = "left"
|
|
615
631
|
}) => {
|
|
616
|
-
const
|
|
632
|
+
const u = q();
|
|
617
633
|
return A.useEffect(() => {
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
const
|
|
621
|
-
x:
|
|
622
|
-
y:
|
|
634
|
+
const m = a === !0 || t === void 0 && r === void 0, f = t, x = r;
|
|
635
|
+
u.queueOperation(async () => {
|
|
636
|
+
const d = await u.imageFromUrl(i, {
|
|
637
|
+
x: f,
|
|
638
|
+
y: x,
|
|
623
639
|
w: n,
|
|
624
640
|
h: o,
|
|
625
641
|
mime: s,
|
|
626
|
-
align:
|
|
642
|
+
align: c
|
|
627
643
|
});
|
|
628
|
-
|
|
644
|
+
m && d && u.moveCursor(0, d.height + 2);
|
|
629
645
|
});
|
|
630
|
-
}, [i, t, r, n, o, s,
|
|
631
|
-
},
|
|
646
|
+
}, [u, i, t, r, n, o, s, a, c]), null;
|
|
647
|
+
}, Tt = ({
|
|
632
648
|
items: i,
|
|
633
649
|
ordered: t = !1,
|
|
634
650
|
style: r,
|
|
@@ -636,26 +652,67 @@ const nt = st(null), q = () => {
|
|
|
636
652
|
markerWidth: o = 5,
|
|
637
653
|
spacing: s = 2
|
|
638
654
|
}) => {
|
|
639
|
-
const
|
|
655
|
+
const a = q();
|
|
640
656
|
return A.useEffect(() => {
|
|
641
|
-
|
|
642
|
-
i.forEach((
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
657
|
+
a.queueOperation(() => {
|
|
658
|
+
i.forEach((c, u) => {
|
|
659
|
+
const m = t ? `${u + 1}.` : "•", f = a.getCursor().y, x = a.getCursor().x, d = x + n + o, H = r?.fontSize ?? a.baseFont.size, j = f + H * 0.3528;
|
|
660
|
+
a.textRaw(
|
|
661
|
+
m,
|
|
662
|
+
x + n,
|
|
647
663
|
j,
|
|
648
664
|
r,
|
|
649
665
|
o,
|
|
650
666
|
"right"
|
|
651
|
-
),
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
|
|
667
|
+
), a.setCursor(d, f);
|
|
668
|
+
const E = a.contentRight - d;
|
|
669
|
+
a.paragraph(c, r, E);
|
|
670
|
+
const h = a.getCursor().y;
|
|
671
|
+
a.setCursor(x, h + s);
|
|
656
672
|
});
|
|
657
673
|
});
|
|
658
|
-
}, [i, t, r, n, o, s]), null;
|
|
674
|
+
}, [a, i, t, r, n, o, s]), null;
|
|
675
|
+
}, Ct = ({
|
|
676
|
+
width: i = "100%",
|
|
677
|
+
height: t = "500px",
|
|
678
|
+
className: r,
|
|
679
|
+
style: n,
|
|
680
|
+
iframeClassName: o,
|
|
681
|
+
iframeStyle: s,
|
|
682
|
+
...a
|
|
683
|
+
}) => {
|
|
684
|
+
const [c, u] = ct(null), m = (f) => {
|
|
685
|
+
const x = f.getBlobUrl();
|
|
686
|
+
u(x.toString());
|
|
687
|
+
};
|
|
688
|
+
return /* @__PURE__ */ I.jsxs("div", { className: r, style: { width: i, height: t, ...n }, children: [
|
|
689
|
+
/* @__PURE__ */ I.jsx("div", { style: { display: "none" }, children: /* @__PURE__ */ I.jsx(gt, { ...a, onReady: m, autoSave: !1, children: a.children }) }),
|
|
690
|
+
c ? /* @__PURE__ */ I.jsx(
|
|
691
|
+
"iframe",
|
|
692
|
+
{
|
|
693
|
+
src: c,
|
|
694
|
+
width: "100%",
|
|
695
|
+
height: "100%",
|
|
696
|
+
className: o,
|
|
697
|
+
style: { border: "none", ...s },
|
|
698
|
+
title: "PDF Preview"
|
|
699
|
+
}
|
|
700
|
+
) : /* @__PURE__ */ I.jsx(
|
|
701
|
+
"div",
|
|
702
|
+
{
|
|
703
|
+
style: {
|
|
704
|
+
width: "100%",
|
|
705
|
+
height: "100%",
|
|
706
|
+
display: "flex",
|
|
707
|
+
alignItems: "center",
|
|
708
|
+
justifyContent: "center",
|
|
709
|
+
backgroundColor: "#f3f4f6",
|
|
710
|
+
color: "#6b7280"
|
|
711
|
+
},
|
|
712
|
+
children: "Generating Preview..."
|
|
713
|
+
}
|
|
714
|
+
)
|
|
715
|
+
] });
|
|
659
716
|
}, Et = ({
|
|
660
717
|
data: i,
|
|
661
718
|
columns: t,
|
|
@@ -663,156 +720,156 @@ const nt = st(null), q = () => {
|
|
|
663
720
|
borderWidth: n = 0.1,
|
|
664
721
|
borderColor: o = "#000000",
|
|
665
722
|
cellPadding: s = 2,
|
|
666
|
-
headerStyle:
|
|
667
|
-
rowStyle:
|
|
668
|
-
alternateRowStyle:
|
|
669
|
-
headerHeight:
|
|
723
|
+
headerStyle: a,
|
|
724
|
+
rowStyle: c,
|
|
725
|
+
alternateRowStyle: u,
|
|
726
|
+
headerHeight: m
|
|
670
727
|
}) => {
|
|
671
|
-
const
|
|
728
|
+
const f = q();
|
|
672
729
|
return A.useEffect(() => {
|
|
673
|
-
|
|
674
|
-
const
|
|
675
|
-
if (
|
|
676
|
-
const
|
|
677
|
-
for (let
|
|
678
|
-
|
|
730
|
+
f.queueOperation(() => {
|
|
731
|
+
const x = typeof r == "number" ? r : parseFloat(r) / 100 * f.contentAreaWidth, d = t.map((b) => typeof b.width == "number" ? b.width : typeof b.width == "string" && b.width.endsWith("%") ? parseFloat(b.width) / 100 * x : 0), H = d.reduce((b, R) => b + R, 0), j = Math.max(0, x - H), E = d.filter((b) => b === 0).length;
|
|
732
|
+
if (E > 0) {
|
|
733
|
+
const b = j / E;
|
|
734
|
+
for (let R = 0; R < d.length; R++)
|
|
735
|
+
d[R] === 0 && (d[R] = b);
|
|
679
736
|
}
|
|
680
|
-
const
|
|
681
|
-
Y &&
|
|
737
|
+
const h = (b, R, P, W, S, p, D = "left", Y = !0) => {
|
|
738
|
+
Y && f.box(R, P, W, S, {
|
|
682
739
|
borderColor: p.borderColor ?? o,
|
|
683
740
|
borderWidth: p.borderWidth ?? n,
|
|
684
741
|
fillColor: p.fillColor
|
|
685
742
|
});
|
|
686
|
-
const z = Z(p.padding ?? s),
|
|
743
|
+
const z = Z(p.padding ?? s), T = {
|
|
687
744
|
top: p.paddingTop ?? z.top,
|
|
688
745
|
right: p.paddingRight ?? z.right,
|
|
689
746
|
bottom: p.paddingBottom ?? z.bottom,
|
|
690
747
|
left: p.paddingLeft ?? z.left
|
|
691
|
-
},
|
|
692
|
-
let
|
|
693
|
-
p.verticalAlign === "middle" ?
|
|
694
|
-
let
|
|
695
|
-
const L = p.align ?? D, _ =
|
|
696
|
-
|
|
697
|
-
let
|
|
698
|
-
L === "center" ?
|
|
699
|
-
}),
|
|
748
|
+
}, w = W - T.left - T.right, k = f.instance.splitTextToSize(b, w, p), v = (p.fontSize ?? f.baseFont.size) * (p.lineHeight ?? f.baseLineHeight) * 0.3528, F = (p.fontSize ?? f.baseFont.size) * 0.3528, e = k.length * v, l = S - T.top - T.bottom;
|
|
749
|
+
let g = 0;
|
|
750
|
+
p.verticalAlign === "middle" ? g = Math.max(0, (l - e) / 2) : p.verticalAlign === "bottom" && (g = Math.max(0, l - e));
|
|
751
|
+
let C = P + T.top + g + F;
|
|
752
|
+
const L = p.align ?? D, _ = f.getCursor();
|
|
753
|
+
k.forEach((y) => {
|
|
754
|
+
let M = R + T.left;
|
|
755
|
+
L === "center" ? M = R + W / 2 : L === "right" && (M = R + W - T.right), f.textRaw(y, M, C, p, void 0, L), C += v;
|
|
756
|
+
}), f.setCursor(_.x, _.y);
|
|
700
757
|
};
|
|
701
|
-
let O =
|
|
702
|
-
const
|
|
703
|
-
O + N >
|
|
704
|
-
let
|
|
705
|
-
t.forEach((
|
|
706
|
-
const P =
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
758
|
+
let O = f.getCursor().y;
|
|
759
|
+
const X = f.getCursor().x, N = m ?? 10;
|
|
760
|
+
O + N > f.contentBottom && (f.addPage(), O = f.getCursor().y);
|
|
761
|
+
let U = X;
|
|
762
|
+
t.forEach((b, R) => {
|
|
763
|
+
const P = d[R];
|
|
764
|
+
h(
|
|
765
|
+
b.header ?? "",
|
|
766
|
+
U,
|
|
710
767
|
O,
|
|
711
768
|
P,
|
|
712
769
|
N,
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
),
|
|
716
|
-
}), O += N,
|
|
717
|
-
const
|
|
770
|
+
a ?? { fontStyle: "bold" },
|
|
771
|
+
b.align ?? "left"
|
|
772
|
+
), U += P;
|
|
773
|
+
}), O += N, f.setCursor(X, O);
|
|
774
|
+
const B = (b, R, P) => {
|
|
718
775
|
const W = Z(s), S = {
|
|
719
776
|
top: P.paddingTop ?? W.top,
|
|
720
777
|
right: P.paddingRight ?? W.right,
|
|
721
778
|
bottom: P.paddingBottom ?? W.bottom,
|
|
722
779
|
left: P.paddingLeft ?? W.left
|
|
723
|
-
}, p =
|
|
724
|
-
return
|
|
780
|
+
}, p = R - S.left - S.right;
|
|
781
|
+
return f.measureText(b, P, p).height + S.top + S.bottom;
|
|
725
782
|
};
|
|
726
783
|
new Array(t.length).fill(0), (() => {
|
|
727
|
-
const
|
|
784
|
+
const b = new Array(i.length).fill(0);
|
|
728
785
|
for (let S = 0; S < i.length; S++) {
|
|
729
786
|
const p = i[S];
|
|
730
787
|
let D = 0;
|
|
731
788
|
for (let Y = 0; Y < t.length; Y++) {
|
|
732
|
-
const z = t[Y],
|
|
733
|
-
let
|
|
734
|
-
if (
|
|
735
|
-
Y +=
|
|
789
|
+
const z = t[Y], T = typeof z.accessor == "function" ? z.accessor(p) : p[z.accessor];
|
|
790
|
+
let w = "", k = c, v = 1, F = 1;
|
|
791
|
+
if (T && typeof T == "object" && T.content !== void 0 ? (w = String(T.content), T.style && (k = T.style), T.colSpan && (v = T.colSpan), T.rowSpan && (F = T.rowSpan)) : w = String(T ?? ""), F > 1) {
|
|
792
|
+
Y += v - 1;
|
|
736
793
|
continue;
|
|
737
794
|
}
|
|
738
|
-
let e =
|
|
739
|
-
for (let
|
|
740
|
-
Y +
|
|
741
|
-
const
|
|
742
|
-
|
|
795
|
+
let e = d[Y];
|
|
796
|
+
for (let g = 1; g < v; g++)
|
|
797
|
+
Y + g < d.length && (e += d[Y + g]);
|
|
798
|
+
const l = B(w, e, k ?? {});
|
|
799
|
+
l > D && (D = l), Y += v - 1;
|
|
743
800
|
}
|
|
744
|
-
D < 8 && (D = 8),
|
|
801
|
+
D < 8 && (D = 8), b[S] = D;
|
|
745
802
|
}
|
|
746
|
-
let
|
|
747
|
-
const P = new Array(t.length).fill(0), W =
|
|
803
|
+
let R = O;
|
|
804
|
+
const P = new Array(t.length).fill(0), W = f.getCursor().x;
|
|
748
805
|
for (let S = 0; S < i.length; S++) {
|
|
749
|
-
const p = i[S], D =
|
|
806
|
+
const p = i[S], D = b[S];
|
|
750
807
|
let Y = D;
|
|
751
|
-
for (let
|
|
752
|
-
const
|
|
808
|
+
for (let w = 0; w < t.length; w++) {
|
|
809
|
+
const k = t[w], v = typeof k.accessor == "function" ? k.accessor(p) : p[k.accessor];
|
|
753
810
|
let F = 1;
|
|
754
|
-
if (
|
|
811
|
+
if (v && typeof v == "object" && v.rowSpan && (F = v.rowSpan), F > 1) {
|
|
755
812
|
let e = 0;
|
|
756
|
-
for (let
|
|
757
|
-
S +
|
|
813
|
+
for (let l = 0; l < F; l++)
|
|
814
|
+
S + l < b.length && (e += b[S + l]);
|
|
758
815
|
e > Y && (Y = e);
|
|
759
816
|
}
|
|
760
817
|
}
|
|
761
|
-
const z = Math.abs(
|
|
762
|
-
if (
|
|
763
|
-
let
|
|
764
|
-
t.forEach((
|
|
765
|
-
const F =
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
818
|
+
const z = Math.abs(R - (f.contentTop + (m ?? 10))) < 1;
|
|
819
|
+
if (R + Y > f.contentBottom && !z && (f.addPage(), R = f.getCursor().y, m !== 0)) {
|
|
820
|
+
let w = W;
|
|
821
|
+
t.forEach((k, v) => {
|
|
822
|
+
const F = d[v];
|
|
823
|
+
h(
|
|
824
|
+
k.header ?? "",
|
|
825
|
+
w,
|
|
826
|
+
R,
|
|
770
827
|
F,
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
),
|
|
775
|
-
}),
|
|
828
|
+
m ?? 10,
|
|
829
|
+
a ?? { fontStyle: "bold" },
|
|
830
|
+
k.align ?? "left"
|
|
831
|
+
), w += F;
|
|
832
|
+
}), R += m ?? 10;
|
|
776
833
|
}
|
|
777
|
-
let
|
|
778
|
-
for (let
|
|
779
|
-
if (P[
|
|
780
|
-
P[
|
|
834
|
+
let T = W;
|
|
835
|
+
for (let w = 0; w < t.length; w++) {
|
|
836
|
+
if (P[w] > 0) {
|
|
837
|
+
P[w]--, T += d[w];
|
|
781
838
|
continue;
|
|
782
839
|
}
|
|
783
|
-
const
|
|
784
|
-
let F = 1, e = 1,
|
|
785
|
-
|
|
786
|
-
let
|
|
840
|
+
const k = t[w], v = typeof k.accessor == "function" ? k.accessor(p) : p[k.accessor];
|
|
841
|
+
let F = 1, e = 1, l = S % 2 === 1 && u ? u : c, g = "";
|
|
842
|
+
v && typeof v == "object" && v.content !== void 0 ? (g = String(v.content), v.colSpan && (F = v.colSpan), v.rowSpan && (e = v.rowSpan), v.style && (l = { ...l, ...v.style })) : g = String(v ?? "");
|
|
843
|
+
let C = d[w];
|
|
787
844
|
for (let _ = 1; _ < F; _++)
|
|
788
|
-
|
|
845
|
+
w + _ < d.length && (C += d[w + _]);
|
|
789
846
|
let L = D;
|
|
790
847
|
if (e > 1)
|
|
791
848
|
for (let _ = 1; _ < e; _++)
|
|
792
|
-
S + _ <
|
|
793
|
-
if (
|
|
794
|
-
|
|
795
|
-
E,
|
|
796
|
-
v,
|
|
849
|
+
S + _ < b.length && (L += b[S + _]);
|
|
850
|
+
if (h(
|
|
851
|
+
g,
|
|
797
852
|
T,
|
|
853
|
+
R,
|
|
854
|
+
C,
|
|
798
855
|
L,
|
|
799
|
-
|
|
800
|
-
|
|
856
|
+
l ?? {},
|
|
857
|
+
k.align ?? "left",
|
|
801
858
|
!0
|
|
802
859
|
), e > 1) {
|
|
803
|
-
P[
|
|
860
|
+
P[w] = e - 1;
|
|
804
861
|
for (let _ = 1; _ < F; _++)
|
|
805
|
-
|
|
862
|
+
w + _ < P.length && (P[w + _] = e - 1);
|
|
806
863
|
}
|
|
807
|
-
|
|
864
|
+
T += C, w += F - 1;
|
|
808
865
|
}
|
|
809
|
-
|
|
866
|
+
R += D;
|
|
810
867
|
}
|
|
811
|
-
|
|
868
|
+
f.setCursor(W, R);
|
|
812
869
|
})();
|
|
813
870
|
});
|
|
814
|
-
}, [i, t, r]), null;
|
|
815
|
-
},
|
|
871
|
+
}, [f, i, t, r]), null;
|
|
872
|
+
}, St = ({
|
|
816
873
|
children: i,
|
|
817
874
|
x: t,
|
|
818
875
|
y: r,
|
|
@@ -820,20 +877,29 @@ const nt = st(null), q = () => {
|
|
|
820
877
|
spacingBelow: o = 2,
|
|
821
878
|
...s
|
|
822
879
|
}) => {
|
|
823
|
-
const
|
|
880
|
+
const a = q();
|
|
824
881
|
return A.useEffect(() => {
|
|
825
|
-
|
|
882
|
+
a.queueOperation(() => {
|
|
826
883
|
if (typeof t == "number" && typeof r == "number")
|
|
827
|
-
|
|
884
|
+
a.textRaw(i, t, r, s, n, s.align);
|
|
828
885
|
else {
|
|
829
|
-
|
|
830
|
-
const
|
|
831
|
-
|
|
886
|
+
a.paragraph(i, s, n);
|
|
887
|
+
const c = a.getCursor();
|
|
888
|
+
a.setCursor(c.x, c.y + o);
|
|
832
889
|
}
|
|
833
890
|
});
|
|
834
|
-
}, [
|
|
891
|
+
}, [
|
|
892
|
+
a,
|
|
893
|
+
i,
|
|
894
|
+
t,
|
|
895
|
+
r,
|
|
896
|
+
n,
|
|
897
|
+
o,
|
|
898
|
+
s.fontSize,
|
|
899
|
+
s.align
|
|
900
|
+
]), null;
|
|
835
901
|
};
|
|
836
|
-
function
|
|
902
|
+
function mt(i) {
|
|
837
903
|
return typeof i == "number" ? { top: i, right: i, bottom: i, left: i } : {
|
|
838
904
|
top: i?.top ?? 0,
|
|
839
905
|
right: i?.right ?? 0,
|
|
@@ -841,61 +907,62 @@ function gt(i) {
|
|
|
841
907
|
left: i?.left ?? 0
|
|
842
908
|
};
|
|
843
909
|
}
|
|
844
|
-
const
|
|
910
|
+
const Pt = ({ style: i = {}, children: t }) => {
|
|
845
911
|
const r = q(), n = Z(i.padding), o = {
|
|
846
912
|
top: i.paddingTop ?? n.top,
|
|
847
913
|
right: i.paddingRight ?? n.right,
|
|
848
914
|
bottom: i.paddingBottom ?? n.bottom,
|
|
849
915
|
left: i.paddingLeft ?? n.left
|
|
850
|
-
}, s =
|
|
916
|
+
}, s = mt(i.margin), a = {
|
|
851
917
|
top: i.marginTop ?? s.top,
|
|
852
918
|
right: i.marginRight ?? s.right,
|
|
853
919
|
bottom: i.marginBottom ?? s.bottom,
|
|
854
920
|
left: i.marginLeft ?? s.left
|
|
855
|
-
},
|
|
921
|
+
}, c = A.useRef(
|
|
856
922
|
{}
|
|
857
923
|
).current;
|
|
858
924
|
return A.useEffect(() => {
|
|
859
925
|
r.queueOperation(() => {
|
|
860
|
-
|
|
861
|
-
const
|
|
862
|
-
|
|
926
|
+
a.top > 0 && r.moveCursor(0, a.top);
|
|
927
|
+
const u = r.getCursor();
|
|
928
|
+
c.start = { ...u }, r.setCursor(u.x + o.left, u.y + o.top);
|
|
863
929
|
});
|
|
864
|
-
}, []), /* @__PURE__ */
|
|
930
|
+
}, [r]), /* @__PURE__ */ I.jsxs(A.Fragment, { children: [
|
|
865
931
|
t,
|
|
866
|
-
/* @__PURE__ */
|
|
867
|
-
|
|
932
|
+
/* @__PURE__ */ I.jsx(
|
|
933
|
+
bt,
|
|
868
934
|
{
|
|
869
|
-
viewState:
|
|
935
|
+
viewState: c,
|
|
870
936
|
style: i,
|
|
871
937
|
pad: o,
|
|
872
|
-
margin:
|
|
938
|
+
margin: a
|
|
873
939
|
}
|
|
874
940
|
)
|
|
875
941
|
] });
|
|
876
|
-
},
|
|
942
|
+
}, bt = ({ viewState: i, style: t, pad: r, margin: n }) => {
|
|
877
943
|
const o = q();
|
|
878
944
|
return A.useEffect(() => {
|
|
879
945
|
o.queueOperation(() => {
|
|
880
946
|
const s = i.start;
|
|
881
947
|
if (!s) return;
|
|
882
|
-
const
|
|
883
|
-
let
|
|
884
|
-
t.height && (
|
|
885
|
-
let
|
|
886
|
-
typeof t.width == "number" && (
|
|
887
|
-
const
|
|
888
|
-
o.setCursor(s.x,
|
|
948
|
+
const a = o.getCursor();
|
|
949
|
+
let u = Math.max(a.y - s.y - r.top, 0) + r.top + r.bottom;
|
|
950
|
+
t.height && (u = t.height);
|
|
951
|
+
let m = o.contentAreaWidth;
|
|
952
|
+
typeof t.width == "number" && (m = t.width), (t.borderColor || t.fillColor || t.borderWidth) && o.box(s.x, s.y, m, u, t);
|
|
953
|
+
const f = s.y + u + n.bottom;
|
|
954
|
+
o.setCursor(s.x, f);
|
|
889
955
|
});
|
|
890
|
-
}, []), null;
|
|
956
|
+
}, [o]), null;
|
|
891
957
|
};
|
|
892
958
|
export {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
959
|
+
xt as PdfBox,
|
|
960
|
+
gt as PdfDocument,
|
|
961
|
+
Rt as PdfImage,
|
|
962
|
+
Tt as PdfList,
|
|
963
|
+
Ct as PdfPreview,
|
|
964
|
+
dt as PdfRenderer,
|
|
898
965
|
Et as PdfTable,
|
|
899
|
-
|
|
900
|
-
|
|
966
|
+
St as PdfText,
|
|
967
|
+
Pt as PdfView
|
|
901
968
|
};
|