@pdfme/ui 3.1.5-dev.9 → 3.2.0-dev.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/dist/__vite-browser-external-jWVCDlBL.js +1 -4
- package/dist/index.js +298 -319
- package/dist/path2d-polyfill.esm-yIGK7UQJ.js +1 -214
- package/dist/types/class.d.ts +1 -0
- package/dist/types/contexts.d.ts +5 -2
- package/dist/types/helper.d.ts +2 -0
- package/package.json +2 -2
- package/src/components/Designer/Canvas/index.tsx +1 -1
- package/src/components/Designer/index.tsx +2 -0
- package/src/components/Paper.tsx +1 -1
- package/src/components/Renderer.tsx +1 -1
- package/src/i18n.ts +28 -7
@@ -1,214 +1 @@
|
|
1
|
-
function F(n, a, r) {
|
2
|
-
if (r || arguments.length === 2)
|
3
|
-
for (var t = 0, o = a.length, l; t < o; t++)
|
4
|
-
(l || !(t in a)) && (l || (l = Array.prototype.slice.call(a, 0, t)), l[t] = a[t]);
|
5
|
-
return n.concat(l || Array.prototype.slice.call(a));
|
6
|
-
}
|
7
|
-
var q = {
|
8
|
-
a: 7,
|
9
|
-
c: 6,
|
10
|
-
h: 1,
|
11
|
-
l: 2,
|
12
|
-
m: 2,
|
13
|
-
q: 4,
|
14
|
-
s: 4,
|
15
|
-
t: 2,
|
16
|
-
v: 1,
|
17
|
-
z: 0
|
18
|
-
}, Z = /([astvzqmhlc])([^astvzqmhlc]*)/gi, _ = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;
|
19
|
-
function U(n) {
|
20
|
-
var a = n.match(_);
|
21
|
-
return a ? a.map(Number) : [];
|
22
|
-
}
|
23
|
-
function j(n) {
|
24
|
-
var a = [], r = String(n).trim();
|
25
|
-
return r[0] !== "M" && r[0] !== "m" || r.replace(Z, function(t, o, l) {
|
26
|
-
var s = U(l), u = o.toLowerCase(), h = o;
|
27
|
-
if (u === "m" && s.length > 2 && (a.push(F([h], s.splice(0, 2), !0)), u = "l", h = h === "m" ? "l" : "L"), s.length < q[u])
|
28
|
-
return "";
|
29
|
-
for (a.push(F([h], s.splice(0, q[u]), !0)); s.length >= q[u] && s.length && q[u]; )
|
30
|
-
a.push(F([h], s.splice(0, q[u]), !0));
|
31
|
-
return "";
|
32
|
-
}), a;
|
33
|
-
}
|
34
|
-
function B(n, a) {
|
35
|
-
var r = n.x * Math.cos(a) - n.y * Math.sin(a), t = n.y * Math.cos(a) + n.x * Math.sin(a);
|
36
|
-
n.x = r, n.y = t;
|
37
|
-
}
|
38
|
-
function J(n, a, r) {
|
39
|
-
n.x += a, n.y += r;
|
40
|
-
}
|
41
|
-
function H(n, a) {
|
42
|
-
n.x *= a, n.y *= a;
|
43
|
-
}
|
44
|
-
var L = (
|
45
|
-
/** @class */
|
46
|
-
function() {
|
47
|
-
function n(a) {
|
48
|
-
var r;
|
49
|
-
this.commands = [], a && a instanceof n ? (r = this.commands).push.apply(r, a.commands) : a && (this.commands = j(a));
|
50
|
-
}
|
51
|
-
return n.prototype.addPath = function(a) {
|
52
|
-
var r;
|
53
|
-
a && a instanceof n && (r = this.commands).push.apply(r, a.commands);
|
54
|
-
}, n.prototype.moveTo = function(a, r) {
|
55
|
-
this.commands.push(["M", a, r]);
|
56
|
-
}, n.prototype.lineTo = function(a, r) {
|
57
|
-
this.commands.push(["L", a, r]);
|
58
|
-
}, n.prototype.arc = function(a, r, t, o, l, s) {
|
59
|
-
this.commands.push(["AC", a, r, t, o, l, !!s]);
|
60
|
-
}, n.prototype.arcTo = function(a, r, t, o, l) {
|
61
|
-
this.commands.push(["AT", a, r, t, o, l]);
|
62
|
-
}, n.prototype.ellipse = function(a, r, t, o, l, s, u, h) {
|
63
|
-
this.commands.push(["E", a, r, t, o, l, s, u, !!h]);
|
64
|
-
}, n.prototype.closePath = function() {
|
65
|
-
this.commands.push(["Z"]);
|
66
|
-
}, n.prototype.bezierCurveTo = function(a, r, t, o, l, s) {
|
67
|
-
this.commands.push(["C", a, r, t, o, l, s]);
|
68
|
-
}, n.prototype.quadraticCurveTo = function(a, r, t, o) {
|
69
|
-
this.commands.push(["Q", a, r, t, o]);
|
70
|
-
}, n.prototype.rect = function(a, r, t, o) {
|
71
|
-
this.commands.push(["R", a, r, t, o]);
|
72
|
-
}, n.prototype.roundRect = function(a, r, t, o, l) {
|
73
|
-
typeof l > "u" ? this.commands.push(["RR", a, r, t, o, 0]) : this.commands.push(["RR", a, r, t, o, l]);
|
74
|
-
}, n;
|
75
|
-
}()
|
76
|
-
);
|
77
|
-
function N(n, a) {
|
78
|
-
var r = 0, t = 0, o, l, s, u, h, v, P, C, I, A, S, G, D, p, f, z, d, b, m, E, Q, g = null, R = null, y = null, T = null, M = null, k = null;
|
79
|
-
n.beginPath();
|
80
|
-
for (var i = 0; i < a.length; ++i) {
|
81
|
-
b = a[i][0], b !== "S" && b !== "s" && b !== "C" && b !== "c" && (g = null, R = null), b !== "T" && b !== "t" && b !== "Q" && b !== "q" && (y = null, T = null);
|
82
|
-
var e = void 0;
|
83
|
-
switch (b) {
|
84
|
-
case "m":
|
85
|
-
case "M":
|
86
|
-
e = a[i], b === "m" ? (r += e[1], t += e[2]) : (r = e[1], t = e[2]), (b === "M" || !M) && (M = { x: r, y: t }), n.moveTo(r, t);
|
87
|
-
break;
|
88
|
-
case "l":
|
89
|
-
e = a[i], r += e[1], t += e[2], n.lineTo(r, t);
|
90
|
-
break;
|
91
|
-
case "L":
|
92
|
-
e = a[i], r = e[1], t = e[2], n.lineTo(r, t);
|
93
|
-
break;
|
94
|
-
case "H":
|
95
|
-
e = a[i], r = e[1], n.lineTo(r, t);
|
96
|
-
break;
|
97
|
-
case "h":
|
98
|
-
e = a[i], r += e[1], n.lineTo(r, t);
|
99
|
-
break;
|
100
|
-
case "V":
|
101
|
-
e = a[i], t = e[1], n.lineTo(r, t);
|
102
|
-
break;
|
103
|
-
case "v":
|
104
|
-
e = a[i], t += e[1], n.lineTo(r, t);
|
105
|
-
break;
|
106
|
-
case "a":
|
107
|
-
case "A":
|
108
|
-
if (e = a[i], k === null)
|
109
|
-
throw new Error("This should never happen");
|
110
|
-
b === "a" ? (r += e[6], t += e[7]) : (r = e[6], t = e[7]), p = e[1], f = e[2], P = e[3] * Math.PI / 180, s = !!e[4], u = !!e[5], h = { x: r, y: t }, v = {
|
111
|
-
x: (k.x - h.x) / 2,
|
112
|
-
y: (k.y - h.y) / 2
|
113
|
-
}, B(v, -P), C = v.x * v.x / (p * p) + v.y * v.y / (f * f), C > 1 && (C = Math.sqrt(C), p *= C, f *= C), m = {
|
114
|
-
x: p * v.y / f,
|
115
|
-
y: -(f * v.x) / p
|
116
|
-
}, I = p * p * f * f, A = p * p * v.y * v.y + f * f * v.x * v.x, u !== s ? H(m, Math.sqrt((I - A) / A) || 0) : H(m, -Math.sqrt((I - A) / A) || 0), l = Math.atan2((v.y - m.y) / f, (v.x - m.x) / p), o = Math.atan2(-(v.y + m.y) / f, -(v.x + m.x) / p), B(m, P), J(m, (h.x + k.x) / 2, (h.y + k.y) / 2), n.save(), n.translate(m.x, m.y), n.rotate(P), n.scale(p, f), n.arc(0, 0, 1, l, o, !u), n.restore();
|
117
|
-
break;
|
118
|
-
case "C":
|
119
|
-
e = a[i], g = e[3], R = e[4], r = e[5], t = e[6], n.bezierCurveTo(e[1], e[2], g, R, r, t);
|
120
|
-
break;
|
121
|
-
case "c":
|
122
|
-
e = a[i], n.bezierCurveTo(e[1] + r, e[2] + t, e[3] + r, e[4] + t, e[5] + r, e[6] + t), g = e[3] + r, R = e[4] + t, r += e[5], t += e[6];
|
123
|
-
break;
|
124
|
-
case "S":
|
125
|
-
e = a[i], (g === null || R === null) && (g = r, R = t), n.bezierCurveTo(2 * r - g, 2 * t - R, e[1], e[2], e[3], e[4]), g = e[1], R = e[2], r = e[3], t = e[4];
|
126
|
-
break;
|
127
|
-
case "s":
|
128
|
-
e = a[i], (g === null || R === null) && (g = r, R = t), n.bezierCurveTo(2 * r - g, 2 * t - R, e[1] + r, e[2] + t, e[3] + r, e[4] + t), g = e[1] + r, R = e[2] + t, r += e[3], t += e[4];
|
129
|
-
break;
|
130
|
-
case "Q":
|
131
|
-
e = a[i], y = e[1], T = e[2], r = e[3], t = e[4], n.quadraticCurveTo(y, T, r, t);
|
132
|
-
break;
|
133
|
-
case "q":
|
134
|
-
e = a[i], y = e[1] + r, T = e[2] + t, r += e[3], t += e[4], n.quadraticCurveTo(y, T, r, t);
|
135
|
-
break;
|
136
|
-
case "T":
|
137
|
-
e = a[i], (y === null || T === null) && (y = r, T = t), y = 2 * r - y, T = 2 * t - T, r = e[1], t = e[2], n.quadraticCurveTo(y, T, r, t);
|
138
|
-
break;
|
139
|
-
case "t":
|
140
|
-
e = a[i], (y === null || T === null) && (y = r, T = t), y = 2 * r - y, T = 2 * t - T, r += e[1], t += e[2], n.quadraticCurveTo(y, T, r, t);
|
141
|
-
break;
|
142
|
-
case "z":
|
143
|
-
case "Z":
|
144
|
-
M && (r = M.x, t = M.y), M = null, n.closePath();
|
145
|
-
break;
|
146
|
-
case "AC":
|
147
|
-
e = a[i], r = e[1], t = e[2], D = e[3], l = e[4], o = e[5], E = e[6], n.arc(r, t, D, l, o, E);
|
148
|
-
break;
|
149
|
-
case "AT":
|
150
|
-
e = a[i], S = e[1], G = e[2], r = e[3], t = e[4], D = e[5], n.arcTo(S, G, r, t, D);
|
151
|
-
break;
|
152
|
-
case "E":
|
153
|
-
e = a[i], r = e[1], t = e[2], p = e[3], f = e[4], P = e[5], l = e[6], o = e[7], E = e[8], n.save(), n.translate(r, t), n.rotate(P), n.scale(p, f), n.arc(0, 0, 1, l, o, E), n.restore();
|
154
|
-
break;
|
155
|
-
case "R":
|
156
|
-
e = a[i], r = e[1], t = e[2], z = e[3], d = e[4], M = { x: r, y: t }, n.rect(r, t, z, d);
|
157
|
-
break;
|
158
|
-
case "RR":
|
159
|
-
e = a[i], r = e[1], t = e[2], z = e[3], d = e[4], Q = e[5], M = { x: r, y: t }, n.roundRect(r, t, z, d, Q);
|
160
|
-
break;
|
161
|
-
}
|
162
|
-
k ? (k.x = r, k.y = t) : k = { x: r, y: t };
|
163
|
-
}
|
164
|
-
}
|
165
|
-
function K(n) {
|
166
|
-
if (!(!n || !n.CanvasRenderingContext2D || n.Path2D)) {
|
167
|
-
var a = n.CanvasRenderingContext2D, r = a.prototype.fill, t = a.prototype.stroke, o = a.prototype.isPointInPath;
|
168
|
-
a.prototype.fill = function() {
|
169
|
-
for (var s = [], u = 0; u < arguments.length; u++)
|
170
|
-
s[u] = arguments[u];
|
171
|
-
if (s[0] instanceof L) {
|
172
|
-
var h = s[0], v = s[1] || "nonzero";
|
173
|
-
N(this, h.commands), r.apply(this, [v]);
|
174
|
-
} else {
|
175
|
-
var v = s[0] || "nonzero";
|
176
|
-
return r.apply(this, [v]);
|
177
|
-
}
|
178
|
-
}, a.prototype.stroke = function(s) {
|
179
|
-
s && N(this, s.commands), t.apply(this);
|
180
|
-
}, a.prototype.isPointInPath = function() {
|
181
|
-
for (var s = [], u = 0; u < arguments.length; u++)
|
182
|
-
s[u] = arguments[u];
|
183
|
-
if (s[0] instanceof L) {
|
184
|
-
var h = s[0], v = s[1], P = s[2], C = s[3] || "nonzero";
|
185
|
-
return N(this, h.commands), o.apply(this, [v, P, C]);
|
186
|
-
} else
|
187
|
-
return o.apply(this, s);
|
188
|
-
}, n.Path2D = L;
|
189
|
-
}
|
190
|
-
}
|
191
|
-
function V(n, a, r, t, o) {
|
192
|
-
var l = this;
|
193
|
-
if (o === void 0 && (o = 0), typeof o == "number" && (o = [o]), Array.isArray(o)) {
|
194
|
-
if (o.length === 0 || o.length > 4)
|
195
|
-
throw new RangeError("Failed to execute 'roundRect' on '".concat(this.constructor.name, "': ").concat(o.length, " radii provided. Between one and four radii are necessary."));
|
196
|
-
o.forEach(function(C) {
|
197
|
-
if (C < 0)
|
198
|
-
throw new RangeError("Failed to execute 'roundRect' on '".concat(l.constructor.name, "': Radius value ").concat(C, " is negative."));
|
199
|
-
});
|
200
|
-
} else
|
201
|
-
return;
|
202
|
-
if (o.length === 1 && o[0] === 0)
|
203
|
-
return this.rect(n, a, r, t);
|
204
|
-
var s = Math.min(r, t) / 2, u, h, v, P = u = h = v = Math.min(s, o[0]);
|
205
|
-
o.length === 2 && (u = v = Math.min(s, o[1])), o.length === 3 && (u = v = Math.min(s, o[1]), h = Math.min(s, o[2])), o.length === 4 && (u = Math.min(s, o[1]), h = Math.min(s, o[2]), v = Math.min(s, o[3])), this.moveTo(n, a + t - v), this.arcTo(n, a, n + P, a, P), this.arcTo(n + r, a, n + r, a + u, u), this.arcTo(n + r, a + t, n + r - h, a + t, h), this.arcTo(n, a + t, n, a + t - v, v), this.moveTo(n, a);
|
206
|
-
}
|
207
|
-
function O(n) {
|
208
|
-
if (!(!n || !n.CanvasRenderingContext2D)) {
|
209
|
-
var a = n.CanvasRenderingContext2D, r = n.Path2D;
|
210
|
-
a && !a.prototype.roundRect && (a.prototype.roundRect = V), r && !r.prototype.roundRect && (r.prototype.roundRect = V);
|
211
|
-
}
|
212
|
-
}
|
213
|
-
K(window);
|
214
|
-
O(window);
|
1
|
+
function D(a,o,r){if(r||arguments.length===2)for(var n=0,s=o.length,c;n<s;n++)(c||!(n in o))&&(c||(c=Array.prototype.slice.call(o,0,n)),c[n]=o[n]);return a.concat(c||Array.prototype.slice.call(o))}var M={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},H=/([astvzqmhlc])([^astvzqmhlc]*)/gi,N=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function V(a){var o=a.match(N);return o?o.map(Number):[]}function j(a){var o=[],r=String(a).trim();return r[0]!=="M"&&r[0]!=="m"||r.replace(H,function(n,s,c){var e=V(c),h=s.toLowerCase(),u=s;if(h==="m"&&e.length>2&&(o.push(D([u],e.splice(0,2),!0)),h="l",u=u==="m"?"l":"L"),e.length<M[h])return"";for(o.push(D([u],e.splice(0,M[h]),!0));e.length>=M[h]&&e.length&&M[h];)o.push(D([u],e.splice(0,M[h]),!0));return""}),o}function F(a,o){var r=a.x*Math.cos(o)-a.y*Math.sin(o),n=a.y*Math.cos(o)+a.x*Math.sin(o);a.x=r,a.y=n}function G(a,o,r){a.x+=o,a.y+=r}function Z(a,o){a.x*=o,a.y*=o}var E=function(){function a(o){var r;this.commands=[],o&&o instanceof a?(r=this.commands).push.apply(r,o.commands):o&&(this.commands=j(o))}return a.prototype.addPath=function(o){var r;o&&o instanceof a&&(r=this.commands).push.apply(r,o.commands)},a.prototype.moveTo=function(o,r){this.commands.push(["M",o,r])},a.prototype.lineTo=function(o,r){this.commands.push(["L",o,r])},a.prototype.arc=function(o,r,n,s,c,e){this.commands.push(["AC",o,r,n,s,c,!!e])},a.prototype.arcTo=function(o,r,n,s,c){this.commands.push(["AT",o,r,n,s,c])},a.prototype.ellipse=function(o,r,n,s,c,e,h,u){this.commands.push(["E",o,r,n,s,c,e,h,!!u])},a.prototype.closePath=function(){this.commands.push(["Z"])},a.prototype.bezierCurveTo=function(o,r,n,s,c,e){this.commands.push(["C",o,r,n,s,c,e])},a.prototype.quadraticCurveTo=function(o,r,n,s){this.commands.push(["Q",o,r,n,s])},a.prototype.rect=function(o,r,n,s){this.commands.push(["R",o,r,n,s])},a.prototype.roundRect=function(o,r,n,s,c){typeof c>"u"?this.commands.push(["RR",o,r,n,s,0]):this.commands.push(["RR",o,r,n,s,c])},a}();function L(a,o){var r=0,n=0,s,c,e,h,u,i,g,b,A,R,I,Q,q,p,m,P,w,d,T,z,S,v=null,x=null,y=null,f=null,C=null,k=null;a.beginPath();for(var l=0;l<o.length;++l){d=o[l][0],d!=="S"&&d!=="s"&&d!=="C"&&d!=="c"&&(v=null,x=null),d!=="T"&&d!=="t"&&d!=="Q"&&d!=="q"&&(y=null,f=null);var t=void 0;switch(d){case"m":case"M":t=o[l],d==="m"?(r+=t[1],n+=t[2]):(r=t[1],n=t[2]),(d==="M"||!C)&&(C={x:r,y:n}),a.moveTo(r,n);break;case"l":t=o[l],r+=t[1],n+=t[2],a.lineTo(r,n);break;case"L":t=o[l],r=t[1],n=t[2],a.lineTo(r,n);break;case"H":t=o[l],r=t[1],a.lineTo(r,n);break;case"h":t=o[l],r+=t[1],a.lineTo(r,n);break;case"V":t=o[l],n=t[1],a.lineTo(r,n);break;case"v":t=o[l],n+=t[1],a.lineTo(r,n);break;case"a":case"A":if(t=o[l],k===null)throw new Error("This should never happen");d==="a"?(r+=t[6],n+=t[7]):(r=t[6],n=t[7]),p=t[1],m=t[2],g=t[3]*Math.PI/180,e=!!t[4],h=!!t[5],u={x:r,y:n},i={x:(k.x-u.x)/2,y:(k.y-u.y)/2},F(i,-g),b=i.x*i.x/(p*p)+i.y*i.y/(m*m),b>1&&(b=Math.sqrt(b),p*=b,m*=b),T={x:p*i.y/m,y:-(m*i.x)/p},A=p*p*m*m,R=p*p*i.y*i.y+m*m*i.x*i.x,h!==e?Z(T,Math.sqrt((A-R)/R)||0):Z(T,-Math.sqrt((A-R)/R)||0),c=Math.atan2((i.y-T.y)/m,(i.x-T.x)/p),s=Math.atan2(-(i.y+T.y)/m,-(i.x+T.x)/p),F(T,g),G(T,(u.x+k.x)/2,(u.y+k.y)/2),a.save(),a.translate(T.x,T.y),a.rotate(g),a.scale(p,m),a.arc(0,0,1,c,s,!h),a.restore();break;case"C":t=o[l],v=t[3],x=t[4],r=t[5],n=t[6],a.bezierCurveTo(t[1],t[2],v,x,r,n);break;case"c":t=o[l],a.bezierCurveTo(t[1]+r,t[2]+n,t[3]+r,t[4]+n,t[5]+r,t[6]+n),v=t[3]+r,x=t[4]+n,r+=t[5],n+=t[6];break;case"S":t=o[l],(v===null||x===null)&&(v=r,x=n),a.bezierCurveTo(2*r-v,2*n-x,t[1],t[2],t[3],t[4]),v=t[1],x=t[2],r=t[3],n=t[4];break;case"s":t=o[l],(v===null||x===null)&&(v=r,x=n),a.bezierCurveTo(2*r-v,2*n-x,t[1]+r,t[2]+n,t[3]+r,t[4]+n),v=t[1]+r,x=t[2]+n,r+=t[3],n+=t[4];break;case"Q":t=o[l],y=t[1],f=t[2],r=t[3],n=t[4],a.quadraticCurveTo(y,f,r,n);break;case"q":t=o[l],y=t[1]+r,f=t[2]+n,r+=t[3],n+=t[4],a.quadraticCurveTo(y,f,r,n);break;case"T":t=o[l],(y===null||f===null)&&(y=r,f=n),y=2*r-y,f=2*n-f,r=t[1],n=t[2],a.quadraticCurveTo(y,f,r,n);break;case"t":t=o[l],(y===null||f===null)&&(y=r,f=n),y=2*r-y,f=2*n-f,r+=t[1],n+=t[2],a.quadraticCurveTo(y,f,r,n);break;case"z":case"Z":C&&(r=C.x,n=C.y),C=null,a.closePath();break;case"AC":t=o[l],r=t[1],n=t[2],q=t[3],c=t[4],s=t[5],z=t[6],a.arc(r,n,q,c,s,z);break;case"AT":t=o[l],I=t[1],Q=t[2],r=t[3],n=t[4],q=t[5],a.arcTo(I,Q,r,n,q);break;case"E":t=o[l],r=t[1],n=t[2],p=t[3],m=t[4],g=t[5],c=t[6],s=t[7],z=t[8],a.save(),a.translate(r,n),a.rotate(g),a.scale(p,m),a.arc(0,0,1,c,s,z),a.restore();break;case"R":t=o[l],r=t[1],n=t[2],P=t[3],w=t[4],C={x:r,y:n},a.rect(r,n,P,w);break;case"RR":t=o[l],r=t[1],n=t[2],P=t[3],w=t[4],S=t[5],C={x:r,y:n},a.roundRect(r,n,P,w,S);break}k?(k.x=r,k.y=n):k={x:r,y:n}}}function J(a){if(!(!a||!a.CanvasRenderingContext2D||a.Path2D)){var o=a.CanvasRenderingContext2D,r=o.prototype.fill,n=o.prototype.stroke,s=o.prototype.isPointInPath;o.prototype.fill=function(){for(var c=[],e=0;e<arguments.length;e++)c[e]=arguments[e];if(c[0]instanceof E){var h=c[0],u=c[1]||"nonzero";L(this,h.commands),r.apply(this,[u])}else{var u=c[0]||"nonzero";return r.apply(this,[u])}},o.prototype.stroke=function(c){c&&L(this,c.commands),n.apply(this)},o.prototype.isPointInPath=function(){for(var c=[],e=0;e<arguments.length;e++)c[e]=arguments[e];if(c[0]instanceof E){var h=c[0],u=c[1],i=c[2],g=c[3]||"nonzero";return L(this,h.commands),s.apply(this,[u,i,g])}else return s.apply(this,c)},a.Path2D=E}}function B(a,o,r,n,s){var c=this;if(s===void 0&&(s=0),typeof s=="number"&&(s=[s]),Array.isArray(s)){if(s.length===0||s.length>4)throw new RangeError("Failed to execute 'roundRect' on '".concat(this.constructor.name,"': ").concat(s.length," radii provided. Between one and four radii are necessary."));s.forEach(function(b){if(b<0)throw new RangeError("Failed to execute 'roundRect' on '".concat(c.constructor.name,"': Radius value ").concat(b," is negative."))})}else return;if(s.length===1&&s[0]===0)return this.rect(a,o,r,n);var e=Math.min(r,n)/2,h,u,i,g=h=u=i=Math.min(e,s[0]);s.length===2&&(h=i=Math.min(e,s[1])),s.length===3&&(h=i=Math.min(e,s[1]),u=Math.min(e,s[2])),s.length===4&&(h=Math.min(e,s[1]),u=Math.min(e,s[2]),i=Math.min(e,s[3])),this.moveTo(a,o+n-i),this.arcTo(a,o,a+g,o,g),this.arcTo(a+r,o,a+r,o+h,h),this.arcTo(a+r,o+n,a+r-u,o+n,u),this.arcTo(a,o+n,a,o+n-i,i),this.moveTo(a,o)}function K(a){if(!(!a||!a.CanvasRenderingContext2D)){var o=a.CanvasRenderingContext2D,r=a.Path2D;o&&!o.prototype.roundRect&&(o.prototype.roundRect=B),r&&!r.prototype.roundRect&&(r.prototype.roundRect=B)}}J(window),K(window);
|
package/dist/types/class.d.ts
CHANGED
@@ -22,6 +22,7 @@ export declare abstract class BaseUIClass {
|
|
22
22
|
schemas: Record<string, import("zod").objectOutputType<{
|
23
23
|
type: import("zod").ZodString;
|
24
24
|
readOnly: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
25
|
+
readOnlyValue: import("zod").ZodOptional<import("zod").ZodString>;
|
25
26
|
position: import("zod").ZodObject<{
|
26
27
|
x: import("zod").ZodNumber;
|
27
28
|
y: import("zod").ZodNumber;
|
package/dist/types/contexts.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { Plugins, UIOptions } from '@pdfme/common';
|
3
|
-
export declare const I18nContext: import("react").Context<(key: "height" | "width" | "type" | "rotate" | "opacity" | "cancel" | "field" | "fieldName" | "align" | "edit" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "addNewField" | "editField" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "hexColorPrompt" | "schemas.textColor" | "schemas.bgColor" | "schemas.horizontal" | "schemas.vertical" | "schemas.left" | "schemas.center" | "schemas.right" | "schemas.top" | "schemas.middle" | "schemas.bottom" | "schemas.text.fontName" | "schemas.text.size" | "schemas.text.spacing" | "schemas.text.textAlign" | "schemas.text.verticalAlign" | "schemas.text.lineHeight" | "schemas.text.min" | "schemas.text.max" | "schemas.text.fit" | "schemas.text.dynamicFontSize" | "schemas.barcodes.barColor" | "schemas.
|
3
|
+
export declare const I18nContext: import("react").Context<(key: "height" | "width" | "type" | "rotate" | "opacity" | "cancel" | "field" | "fieldName" | "align" | "edit" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "addNewField" | "editField" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "hexColorPrompt" | "schemas.color" | "schemas.borderWidth" | "schemas.borderColor" | "schemas.textColor" | "schemas.bgColor" | "schemas.horizontal" | "schemas.vertical" | "schemas.left" | "schemas.center" | "schemas.right" | "schemas.top" | "schemas.middle" | "schemas.bottom" | "schemas.text.fontName" | "schemas.text.size" | "schemas.text.spacing" | "schemas.text.textAlign" | "schemas.text.verticalAlign" | "schemas.text.lineHeight" | "schemas.text.min" | "schemas.text.max" | "schemas.text.fit" | "schemas.text.dynamicFontSize" | "schemas.barcodes.barColor" | "schemas.barcodes.includetext", dict?: {
|
4
4
|
cancel: string;
|
5
5
|
field: string;
|
6
6
|
fieldName: string;
|
@@ -23,6 +23,9 @@ export declare const I18nContext: import("react").Context<(key: "height" | "widt
|
|
23
23
|
commitBulkUpdateFieldName: string;
|
24
24
|
bulkUpdateFieldName: string;
|
25
25
|
hexColorPrompt: string;
|
26
|
+
'schemas.color': string;
|
27
|
+
'schemas.borderWidth': string;
|
28
|
+
'schemas.borderColor': string;
|
26
29
|
'schemas.textColor': string;
|
27
30
|
'schemas.bgColor': string;
|
28
31
|
'schemas.horizontal': string;
|
@@ -44,7 +47,7 @@ export declare const I18nContext: import("react").Context<(key: "height" | "widt
|
|
44
47
|
'schemas.text.fit': string;
|
45
48
|
'schemas.text.dynamicFontSize': string;
|
46
49
|
'schemas.barcodes.barColor': string;
|
47
|
-
'schemas.
|
50
|
+
'schemas.barcodes.includetext': string;
|
48
51
|
} | undefined) => string>;
|
49
52
|
export declare const FontContext: import("react").Context<Record<string, {
|
50
53
|
data: (string | Uint8Array | ArrayBuffer) & (string | Uint8Array | ArrayBuffer | undefined);
|
package/dist/types/helper.d.ts
CHANGED
@@ -38,11 +38,13 @@ export declare const templateSchemas2SchemasList: (_template: Template) => Promi
|
|
38
38
|
opacity?: number | undefined;
|
39
39
|
rotate?: number | undefined;
|
40
40
|
readOnly?: boolean | undefined;
|
41
|
+
readOnlyValue?: string | undefined;
|
41
42
|
}[][]>;
|
42
43
|
export declare const generateColumnsAndSampledataIfNeeded: (template: Template) => {
|
43
44
|
schemas: Record<string, import("zod").objectOutputType<{
|
44
45
|
type: import("zod").ZodString;
|
45
46
|
readOnly: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
47
|
+
readOnlyValue: import("zod").ZodOptional<import("zod").ZodString>;
|
46
48
|
position: import("zod").ZodObject<{
|
47
49
|
x: import("zod").ZodNumber;
|
48
50
|
y: import("zod").ZodNumber;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/ui",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.2.0-dev.1",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -26,7 +26,7 @@
|
|
26
26
|
"module": "dist/index.js",
|
27
27
|
"types": "dist/types/index.d.ts",
|
28
28
|
"scripts": {
|
29
|
-
"
|
29
|
+
"dev": "npm-run-all --parallel devBuild:watch devBuildType:watch",
|
30
30
|
"devBuild:watch": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=esm --watch",
|
31
31
|
"devBuildType:watch": "tsc --emitDeclarationOnly --watch",
|
32
32
|
"build": "vite build && tsc --emitDeclarationOnly",
|
@@ -383,7 +383,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
383
383
|
}}
|
384
384
|
stopEditing={() => setEditing(false)}
|
385
385
|
outline={`1px ${hoveringSchemaId === schema.id ? 'solid' : 'dashed'} ${
|
386
|
-
token.colorPrimary
|
386
|
+
schema.readOnly ? 'transparent' : token.colorPrimary
|
387
387
|
}`}
|
388
388
|
scale={scale}
|
389
389
|
/>
|
@@ -113,6 +113,8 @@ const TemplateEditor = ({
|
|
113
113
|
)?.propPanel;
|
114
114
|
set(tgt, 'data', propPanel?.defaultValue || '');
|
115
115
|
Object.assign(tgt, propPanel?.defaultSchema || {});
|
116
|
+
} else if (key === 'data' && tgt.readOnly) {
|
117
|
+
set(tgt, 'readOnlyValue', value);
|
116
118
|
}
|
117
119
|
|
118
120
|
return acc;
|
package/src/components/Paper.tsx
CHANGED
package/src/i18n.ts
CHANGED
@@ -25,6 +25,9 @@ const dictEn: { [key in keyof Dict]: string } = {
|
|
25
25
|
commitBulkUpdateFieldName: 'Commit Changes',
|
26
26
|
bulkUpdateFieldName: 'Bulk update field names',
|
27
27
|
hexColorPrompt: 'Please enter a valid hex color code.',
|
28
|
+
'schemas.color': 'Color',
|
29
|
+
'schemas.borderWidth': 'Border Width',
|
30
|
+
'schemas.borderColor': 'Border Color',
|
28
31
|
'schemas.textColor': 'Text Color',
|
29
32
|
'schemas.bgColor': 'Background Color',
|
30
33
|
'schemas.horizontal': 'Horizontal',
|
@@ -46,7 +49,7 @@ const dictEn: { [key in keyof Dict]: string } = {
|
|
46
49
|
'schemas.text.fit': 'Fit',
|
47
50
|
'schemas.text.dynamicFontSize': 'Dynamic Font Size',
|
48
51
|
'schemas.barcodes.barColor': 'Bar Color',
|
49
|
-
'schemas.
|
52
|
+
'schemas.barcodes.includetext': 'Include Text',
|
50
53
|
};
|
51
54
|
|
52
55
|
const dictJa: { [key in keyof Dict]: string } = {
|
@@ -72,6 +75,9 @@ const dictJa: { [key in keyof Dict]: string } = {
|
|
72
75
|
commitBulkUpdateFieldName: '変更を反映',
|
73
76
|
bulkUpdateFieldName: '項目名を一括変更',
|
74
77
|
hexColorPrompt: '有効な16進数のカラーコードを入力してください。',
|
78
|
+
'schemas.color': '色',
|
79
|
+
'schemas.borderWidth': '枠線の太さ',
|
80
|
+
'schemas.borderColor': '枠線の色',
|
75
81
|
'schemas.textColor': 'テキストの色',
|
76
82
|
'schemas.bgColor': '背景色',
|
77
83
|
'schemas.horizontal': '水平',
|
@@ -93,7 +99,7 @@ const dictJa: { [key in keyof Dict]: string } = {
|
|
93
99
|
'schemas.text.fit': 'フィット',
|
94
100
|
'schemas.text.dynamicFontSize': '動的フォントサイズ',
|
95
101
|
'schemas.barcodes.barColor': 'バーの色',
|
96
|
-
'schemas.
|
102
|
+
'schemas.barcodes.includetext': 'テキストを含める',
|
97
103
|
};
|
98
104
|
|
99
105
|
const dictAr: { [key in keyof Dict]: string } = {
|
@@ -119,6 +125,9 @@ const dictAr: { [key in keyof Dict]: string } = {
|
|
119
125
|
commitBulkUpdateFieldName: 'تنفيذ التغييرات',
|
120
126
|
bulkUpdateFieldName: 'تغيير الأسماء',
|
121
127
|
hexColorPrompt: 'الرجاء إدخال رمز لون سداسي عشري صالح.',
|
128
|
+
'schemas.color': 'اللون',
|
129
|
+
'schemas.borderWidth': 'عرض الحدود',
|
130
|
+
'schemas.borderColor': 'لون الحدود',
|
122
131
|
'schemas.textColor': 'لون الخط',
|
123
132
|
'schemas.bgColor': 'لون الخلفية',
|
124
133
|
'schemas.horizontal': 'أفقي',
|
@@ -140,7 +149,7 @@ const dictAr: { [key in keyof Dict]: string } = {
|
|
140
149
|
'schemas.text.fit': 'ملاءمة',
|
141
150
|
'schemas.text.dynamicFontSize': 'حجم الخط الديناميكي',
|
142
151
|
'schemas.barcodes.barColor': 'لون الشريط',
|
143
|
-
'schemas.
|
152
|
+
'schemas.barcodes.includetext': 'تضمين النص',
|
144
153
|
};
|
145
154
|
|
146
155
|
const dictTh: { [key in keyof Dict]: string } = {
|
@@ -166,6 +175,9 @@ const dictTh: { [key in keyof Dict]: string } = {
|
|
166
175
|
commitBulkUpdateFieldName: 'ยืนยันการแก้ไข',
|
167
176
|
bulkUpdateFieldName: 'แก้ไขชื่อฟิลด์เป็นชุด',
|
168
177
|
hexColorPrompt: 'กรุณาใส่รหัสสีแบบฐานสิบหกที่ถูกต้อง',
|
178
|
+
'schemas.color': 'สี',
|
179
|
+
'schemas.borderWidth': 'ความกว้างของเส้นขอบ',
|
180
|
+
'schemas.borderColor': 'สีขอบ',
|
169
181
|
'schemas.textColor': 'สีข้อความ',
|
170
182
|
'schemas.bgColor': 'สีพื้นหลัง',
|
171
183
|
'schemas.horizontal': 'แนวนอน',
|
@@ -187,7 +199,7 @@ const dictTh: { [key in keyof Dict]: string } = {
|
|
187
199
|
'schemas.text.fit': 'พอดี',
|
188
200
|
'schemas.text.dynamicFontSize': 'ขนาดตัวอักษรแบบไดนามิก',
|
189
201
|
'schemas.barcodes.barColor': 'สีบาร์',
|
190
|
-
'schemas.
|
202
|
+
'schemas.barcodes.includetext': 'รวมข้อความ',
|
191
203
|
};
|
192
204
|
|
193
205
|
const dictIt: { [key in keyof Dict]: string } = {
|
@@ -214,6 +226,9 @@ const dictIt: { [key in keyof Dict]: string } = {
|
|
214
226
|
commitBulkUpdateFieldName: 'Salva cambiamenti',
|
215
227
|
bulkUpdateFieldName: 'Modifica nomi campi in blocco',
|
216
228
|
hexColorPrompt: 'Inserisci un codice colore esadecimale valido.',
|
229
|
+
'schemas.color': 'Colore',
|
230
|
+
'schemas.borderWidth': 'Spessore bordo',
|
231
|
+
'schemas.borderColor': 'Colore bordo',
|
217
232
|
'schemas.textColor': 'Colore testo',
|
218
233
|
'schemas.bgColor': 'Colore sfondo',
|
219
234
|
'schemas.horizontal': 'Orizzontale',
|
@@ -235,7 +250,7 @@ const dictIt: { [key in keyof Dict]: string } = {
|
|
235
250
|
'schemas.text.fit': 'Adatta',
|
236
251
|
'schemas.text.dynamicFontSize': 'Dimensione font dinamica',
|
237
252
|
'schemas.barcodes.barColor': 'Colore barra',
|
238
|
-
'schemas.
|
253
|
+
'schemas.barcodes.includetext': 'Includi testo',
|
239
254
|
};
|
240
255
|
|
241
256
|
const dictPl: { [key in keyof Dict]: string } = {
|
@@ -261,6 +276,9 @@ const dictPl: { [key in keyof Dict]: string } = {
|
|
261
276
|
commitBulkUpdateFieldName: 'Zaakceptuj zmiany',
|
262
277
|
bulkUpdateFieldName: 'Masowo aktualizuj klucze pól',
|
263
278
|
hexColorPrompt: 'Wprowadź poprawny kod koloru szesnastkowego.',
|
279
|
+
'schemas.color': 'Kolor',
|
280
|
+
'schemas.borderWidth': 'Szerokość obramowania',
|
281
|
+
'schemas.borderColor': 'Kolor obramowania',
|
264
282
|
'schemas.textColor': 'Kolor tekstu',
|
265
283
|
'schemas.bgColor': 'Kolor tła',
|
266
284
|
'schemas.horizontal': 'Poziomo',
|
@@ -282,7 +300,7 @@ const dictPl: { [key in keyof Dict]: string } = {
|
|
282
300
|
'schemas.text.fit': 'Dopasowanie',
|
283
301
|
'schemas.text.dynamicFontSize': 'Dynamiczny rozmiar czcionki',
|
284
302
|
'schemas.barcodes.barColor': 'Kolor paska',
|
285
|
-
'schemas.
|
303
|
+
'schemas.barcodes.includetext': 'Dołącz tekst',
|
286
304
|
};
|
287
305
|
|
288
306
|
const dictDe: { [key in keyof Dict]: string } = {
|
@@ -309,6 +327,9 @@ const dictDe: { [key in keyof Dict]: string } = {
|
|
309
327
|
commitBulkUpdateFieldName: 'Änderungen übernehmen',
|
310
328
|
bulkUpdateFieldName: 'Mehrfachaktualisierung der Feldnamen',
|
311
329
|
hexColorPrompt: 'Bitte geben Sie einen gültigen Hex-Farbcode ein.',
|
330
|
+
'schemas.color': 'Farbe',
|
331
|
+
'schemas.borderWidth': 'Rahmenbreite',
|
332
|
+
'schemas.borderColor': 'Rahmenfarbe',
|
312
333
|
'schemas.textColor': 'Textfarbe',
|
313
334
|
'schemas.bgColor': 'Hintergrundfarbe',
|
314
335
|
'schemas.horizontal': 'Horizontal',
|
@@ -330,7 +351,7 @@ const dictDe: { [key in keyof Dict]: string } = {
|
|
330
351
|
'schemas.text.fit': 'Anpassen',
|
331
352
|
'schemas.text.dynamicFontSize': 'Dynamische Schriftgröße',
|
332
353
|
'schemas.barcodes.barColor': 'Strichcodefarbe',
|
333
|
-
'schemas.
|
354
|
+
'schemas.barcodes.includetext': 'Text anzeigen',
|
334
355
|
};
|
335
356
|
|
336
357
|
const dictionaries: { [key in Lang]: Dict } = {
|