@pdfme/ui 4.3.2 → 4.4.0
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/index.es.js +183 -144
- package/dist/index.umd.js +7 -7
- package/dist/types/helper.d.ts +0 -1
- package/package.json +1 -1
- package/src/Designer.tsx +1 -1
- package/src/class.ts +2 -1
- package/src/components/Designer/index.tsx +1 -1
- package/src/components/Preview.tsx +5 -8
- package/src/helper.ts +1 -2
- package/src/hooks.ts +1 -1
package/dist/index.es.js
CHANGED
@@ -9365,7 +9365,7 @@ const UIOptions = CommonOptions.extend({
|
|
9365
9365
|
}), HTMLElementSchema = z.any().refine((a) => a instanceof HTMLElement), UIProps = CommonProps.extend({
|
9366
9366
|
domContainer: HTMLElementSchema,
|
9367
9367
|
options: UIOptions.optional()
|
9368
|
-
}), PreviewProps = UIProps.extend({ inputs: Inputs }).strict(), DesignerProps = UIProps.extend({}).strict(), uniq = (a) => Array.from(new Set(a)), getFallbackFontName = (a) => {
|
9368
|
+
}), PreviewProps = UIProps.extend({ inputs: Inputs }).strict(), DesignerProps = UIProps.extend({}).strict(), cloneDeep$1 = (a) => JSON.parse(JSON.stringify(a)), uniq = (a) => Array.from(new Set(a)), getFallbackFontName = (a) => {
|
9369
9369
|
const s = "", $ = Object.entries(a).reduce((_, _e) => {
|
9370
9370
|
const [tt, nt] = _e;
|
9371
9371
|
return !_ && nt.fallback ? tt : _;
|
@@ -9428,55 +9428,163 @@ ${_e}`);
|
|
9428
9428
|
const { template: $, plugins: _ } = a;
|
9429
9429
|
_ && checkPlugins({ plugins: _, template: $ });
|
9430
9430
|
}
|
9431
|
-
}, checkInputs = (a) => checkProps(a, Inputs), checkUIOptions = (a) => checkProps(a, UIOptions), checkTemplate = (a) => checkProps(a, Template), checkUIProps = (a) => checkProps(a, UIProps), checkPreviewProps = (a) => checkProps(a, PreviewProps), checkDesignerProps = (a) => checkProps(a, DesignerProps)
|
9432
|
-
|
9433
|
-
|
9434
|
-
|
9435
|
-
|
9436
|
-
|
9437
|
-
|
9438
|
-
|
9439
|
-
|
9440
|
-
|
9441
|
-
|
9442
|
-
|
9443
|
-
|
9444
|
-
|
9445
|
-
|
9446
|
-
|
9447
|
-
|
9448
|
-
|
9449
|
-
|
9450
|
-
|
9451
|
-
|
9452
|
-
|
9453
|
-
|
9431
|
+
}, checkInputs = (a) => checkProps(a, Inputs), checkUIOptions = (a) => checkProps(a, UIOptions), checkTemplate = (a) => checkProps(a, Template), checkUIProps = (a) => checkProps(a, UIProps), checkPreviewProps = (a) => checkProps(a, PreviewProps), checkDesignerProps = (a) => checkProps(a, DesignerProps);
|
9432
|
+
class Node {
|
9433
|
+
constructor({ width: s = 0, height: $ = 0 } = {}) {
|
9434
|
+
Object.defineProperty(this, "index", {
|
9435
|
+
enumerable: !0,
|
9436
|
+
configurable: !0,
|
9437
|
+
writable: !0,
|
9438
|
+
value: 0
|
9439
|
+
}), Object.defineProperty(this, "key", {
|
9440
|
+
enumerable: !0,
|
9441
|
+
configurable: !0,
|
9442
|
+
writable: !0,
|
9443
|
+
value: void 0
|
9444
|
+
}), Object.defineProperty(this, "schema", {
|
9445
|
+
enumerable: !0,
|
9446
|
+
configurable: !0,
|
9447
|
+
writable: !0,
|
9448
|
+
value: void 0
|
9449
|
+
}), Object.defineProperty(this, "children", {
|
9450
|
+
enumerable: !0,
|
9451
|
+
configurable: !0,
|
9452
|
+
writable: !0,
|
9453
|
+
value: []
|
9454
|
+
}), Object.defineProperty(this, "width", {
|
9455
|
+
enumerable: !0,
|
9456
|
+
configurable: !0,
|
9457
|
+
writable: !0,
|
9458
|
+
value: 0
|
9459
|
+
}), Object.defineProperty(this, "height", {
|
9460
|
+
enumerable: !0,
|
9461
|
+
configurable: !0,
|
9462
|
+
writable: !0,
|
9463
|
+
value: 0
|
9464
|
+
}), Object.defineProperty(this, "padding", {
|
9465
|
+
enumerable: !0,
|
9466
|
+
configurable: !0,
|
9467
|
+
writable: !0,
|
9468
|
+
value: [0, 0, 0, 0]
|
9469
|
+
}), Object.defineProperty(this, "position", {
|
9470
|
+
enumerable: !0,
|
9471
|
+
configurable: !0,
|
9472
|
+
writable: !0,
|
9473
|
+
value: { x: 0, y: 0 }
|
9474
|
+
}), this.width = s, this.height = $;
|
9454
9475
|
}
|
9455
|
-
|
9456
|
-
|
9457
|
-
for (const it of lt) {
|
9458
|
-
const ft = at.get(it) + et;
|
9459
|
-
st.set(it + et, ft), et += ft;
|
9476
|
+
setIndex(s) {
|
9477
|
+
this.index = s;
|
9460
9478
|
}
|
9461
|
-
|
9462
|
-
|
9463
|
-
if (!isBlankPdf(a.basePdf) || s.size === 0)
|
9464
|
-
return a;
|
9465
|
-
const $ = { schemas: [{}], basePdf: a.basePdf }, _ = $.schemas, _e = a.basePdf.height, tt = a.basePdf.padding[0], nt = a.basePdf.padding[2];
|
9466
|
-
for (let at = 0; at < a.schemas.length; at += 1) {
|
9467
|
-
const ot = a.schemas[at];
|
9468
|
-
_[at] || (_[at] = {});
|
9469
|
-
for (const [rt, st] of Object.entries(ot)) {
|
9470
|
-
const { position: lt, height: et } = st;
|
9471
|
-
let it = lt.y, ut = at;
|
9472
|
-
for (const [ft, ht] of s)
|
9473
|
-
it > ft && (it += ht);
|
9474
|
-
for (; it + et >= _e - nt; )
|
9475
|
-
it = it + tt - (_e - nt) + tt, ut++;
|
9476
|
-
_[ut] || (_[ut] = {}), _[ut][rt] = { ...st, position: { ...lt, y: it } };
|
9477
|
-
}
|
9479
|
+
setKeyAndSchema(s, $) {
|
9480
|
+
this.key = s, this.schema = $;
|
9478
9481
|
}
|
9479
|
-
|
9482
|
+
setWidth(s) {
|
9483
|
+
this.width = s;
|
9484
|
+
}
|
9485
|
+
setHeight(s) {
|
9486
|
+
this.height = s;
|
9487
|
+
}
|
9488
|
+
setPadding(s) {
|
9489
|
+
this.padding = s;
|
9490
|
+
}
|
9491
|
+
setPosition(s) {
|
9492
|
+
this.position = s;
|
9493
|
+
}
|
9494
|
+
insertChild(s) {
|
9495
|
+
const $ = this.getChildCount();
|
9496
|
+
s.setIndex($), this.children.splice($, 0, s);
|
9497
|
+
}
|
9498
|
+
getChildCount() {
|
9499
|
+
return this.children.length;
|
9500
|
+
}
|
9501
|
+
getChild(s) {
|
9502
|
+
return this.children[s];
|
9503
|
+
}
|
9504
|
+
}
|
9505
|
+
function createPage(a) {
|
9506
|
+
const s = new Node({ ...a });
|
9507
|
+
return s.setPadding(a.padding), s;
|
9508
|
+
}
|
9509
|
+
function createNode(a) {
|
9510
|
+
const { position: s, width: $, height: _, key: _e, schema: tt } = a, nt = new Node({ width: $, height: _ });
|
9511
|
+
return nt.setPosition(s), nt.setKeyAndSchema(_e, tt), nt;
|
9512
|
+
}
|
9513
|
+
function resortChildren(a, s) {
|
9514
|
+
a.children = a.children.sort(($, _) => {
|
9515
|
+
const _e = s.get($.key), tt = s.get(_.key);
|
9516
|
+
if (_e === void 0 || tt === void 0)
|
9517
|
+
throw new Error("[@pdfme/common] order is not defined");
|
9518
|
+
return _e - tt;
|
9519
|
+
}).map(($, _) => ($.setIndex(_), $));
|
9520
|
+
}
|
9521
|
+
async function createOnePage(a) {
|
9522
|
+
const { basePdf: s, schemaObj: $, orderMap: _, input: _e, options: tt, _cache: nt, getDynamicHeights: at } = a, ot = createPage(s), rt = [], st = Object.entries($).sort((it, ut) => it[1].position.y - ut[1].position.y), lt = /* @__PURE__ */ new Map();
|
9523
|
+
for (const [it, ut] of st) {
|
9524
|
+
const { position: ft, width: ht } = ut, dt = { schema: ut, basePdf: s, options: tt, _cache: nt }, gt = await at((_e == null ? void 0 : _e[it]) || "", dt), pt = gt.reduce((ct, vt) => ct + vt, 0), mt = ut.height;
|
9525
|
+
pt !== mt && lt.set(ft.y + mt, pt - mt), gt.forEach((ct, vt) => {
|
9526
|
+
let At = ut.position.y + gt.reduce((bt, Et, St) => St < vt ? bt + Et : bt, 0);
|
9527
|
+
for (const [bt, Et] of lt.entries())
|
9528
|
+
bt <= ut.position.y && (At += Et);
|
9529
|
+
const xt = createNode({ key: it, schema: ut, position: { ...ft, y: At }, width: ht, height: ct });
|
9530
|
+
rt.push(At + ct + s.padding[2]), ot.insertChild(xt);
|
9531
|
+
});
|
9532
|
+
}
|
9533
|
+
const et = Math.max(...rt, s.height - s.padding[2]);
|
9534
|
+
return ot.setHeight(et), resortChildren(ot, _), ot;
|
9535
|
+
}
|
9536
|
+
function breakIntoPages(a) {
|
9537
|
+
const { longPage: s, orderMap: $, basePdf: _ } = a, _e = [createPage(_)], [tt, , nt] = _.padding, at = [], ot = (lt) => _.height - nt - (lt > 0 ? tt : 0), rt = (lt, et) => {
|
9538
|
+
var ut;
|
9539
|
+
const it = lt - et * (_.height - tt - nt);
|
9540
|
+
for (; _e.length <= et; )
|
9541
|
+
_e[et] || (_e.push(createPage(_)), at.push({ page: et, value: (it - tt) * -1 }));
|
9542
|
+
return it + (((ut = at.find((ft) => ft.page === et)) == null ? void 0 : ut.value) || 0);
|
9543
|
+
}, st = s.children.sort((lt, et) => lt.position.y - et.position.y);
|
9544
|
+
for (let lt = 0; lt < st.length; lt++) {
|
9545
|
+
const { key: et, schema: it, position: ut, height: ft, width: ht } = st[lt], { y: dt, x: gt } = ut;
|
9546
|
+
let pt = Math.floor(dt / ot(_e.length - 1)), mt = rt(dt, pt);
|
9547
|
+
if (mt + ft > _.height - nt && (pt++, mt = rt(dt, pt)), !et || !it)
|
9548
|
+
throw new Error("[@pdfme/common] key or schema is undefined");
|
9549
|
+
const ct = createNode({ key: et, schema: it, position: { x: gt, y: mt }, width: ht, height: ft });
|
9550
|
+
_e[pt].insertChild(ct);
|
9551
|
+
}
|
9552
|
+
return _e.forEach((lt) => resortChildren(lt, $)), _e;
|
9553
|
+
}
|
9554
|
+
function createNewTemplate(a, s) {
|
9555
|
+
const $ = {
|
9556
|
+
schemas: Array.from({ length: a.length }, () => ({})),
|
9557
|
+
basePdf: s
|
9558
|
+
}, _ = /* @__PURE__ */ new Map();
|
9559
|
+
return cloneDeep$1(a).forEach((_e, tt) => {
|
9560
|
+
_e.children.forEach((nt) => {
|
9561
|
+
const { key: at, schema: ot } = nt;
|
9562
|
+
if (!at || !ot)
|
9563
|
+
throw new Error("[@pdfme/common] key or schema is undefined");
|
9564
|
+
_.has(at) || _.set(at, []), _.get(at).push(nt);
|
9565
|
+
const rt = _e.children.filter((lt) => lt.key === at), st = _.get(at).length - rt.length;
|
9566
|
+
if (rt.length > 0) {
|
9567
|
+
if (!rt[0].schema)
|
9568
|
+
throw new Error("[@pdfme/common] schema is undefined");
|
9569
|
+
const lt = rt[0].schema, et = rt.reduce((ut, ft) => ut + ft.height, 0), it = rt[0].position;
|
9570
|
+
lt.__bodyRange = {
|
9571
|
+
start: Math.max(st - 1, 0),
|
9572
|
+
end: st + rt.length - 1
|
9573
|
+
}, $.schemas[tt][at] = Object.assign({}, lt, { position: it, height: et });
|
9574
|
+
}
|
9575
|
+
});
|
9576
|
+
}), $;
|
9577
|
+
}
|
9578
|
+
const getDynamicTemplate = async (a) => {
|
9579
|
+
const { template: s } = a;
|
9580
|
+
if (!isBlankPdf(s.basePdf))
|
9581
|
+
return s;
|
9582
|
+
const $ = s.basePdf, _ = [];
|
9583
|
+
for (const _e of s.schemas) {
|
9584
|
+
const tt = new Map(Object.keys(_e).map((ot, rt) => [ot, rt])), nt = await createOnePage({ basePdf: $, schemaObj: _e, orderMap: tt, ...a }), at = breakIntoPages({ longPage: nt, basePdf: $, orderMap: tt });
|
9585
|
+
_.push(...at);
|
9586
|
+
}
|
9587
|
+
return createNewTemplate(_, s.basePdf);
|
9480
9588
|
}, DEFAULT_LANG = "en", DESTROYED_ERR_MSG = "[@pdfme/ui] this instance is already destroyed", SELECTABLE_CLASSNAME = "selectable", RULER_HEIGHT = 30, PAGE_GAP = 10, RIGHT_SIDEBAR_WIDTH = 400, BACKGROUND_COLOR = "rgb(74, 74, 74)";
|
9481
9589
|
var pdf_worker_entry = {}, pdf_worker = { exports: {} };
|
9482
9590
|
(function(a, s) {
|
@@ -60088,7 +60196,7 @@ const uuid$6 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (a)
|
|
60088
60196
|
$ && (s = -s);
|
60089
60197
|
const _ = `${a}`.split("e");
|
60090
60198
|
return +`${_[0]}e${_[1] ? Number(_[1]) + s : s}`;
|
60091
|
-
}, round = (a, s) => shift(Math.round(shift(a, s, !1)), s, !0),
|
60199
|
+
}, round = (a, s) => shift(Math.round(shift(a, s, !1)), s, !0), flatten = (a) => [].concat(...a), up = "up", shiftUp = "shift+up", down = "down", shiftDown = "shift+down", left = "left", shiftLeft = "shift+left", right = "right", shiftRight = "shift+right", rmWin = "backspace", rmMac = "delete", esc = "esc", copyWin = "ctrl+c", copyMac = "command+c", pasteWin = "ctrl+v", pasteMac = "command+v", redoWin = "ctrl+y", redoMac = "shift+command+z", undoWin = "ctrl+z", undoMac = "command+z", saveWin = "ctrl+s", saveMac = "command+s", selectAllWin = "ctrl+a", selectAllMac = "command+a", keys$2 = [
|
60092
60200
|
up,
|
60093
60201
|
shiftUp,
|
60094
60202
|
down,
|
@@ -60195,7 +60303,7 @@ const uuid$6 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (a)
|
|
60195
60303
|
) : []
|
60196
60304
|
), _e), []);
|
60197
60305
|
}, template2SchemasList = async (a) => {
|
60198
|
-
const s = cloneDeep$
|
60306
|
+
const s = cloneDeep$1(a), { basePdf: $, schemas: _ } = s, _e = sortSchemasList(s);
|
60199
60307
|
let tt = [];
|
60200
60308
|
if (isBlankPdf($))
|
60201
60309
|
tt = _.map(() => ({
|
@@ -60207,7 +60315,7 @@ const uuid$6 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (a)
|
|
60207
60315
|
tt = await getPdfPageSizes(st);
|
60208
60316
|
}
|
60209
60317
|
const nt = _e.length, at = tt.length;
|
60210
|
-
return (nt < at ? _e.concat(new Array(at - nt).fill(cloneDeep$
|
60318
|
+
return (nt < at ? _e.concat(new Array(at - nt).fill(cloneDeep$1([]))) : _e.slice(0, tt.length)).map((rt, st) => (Object.values(rt).forEach((lt) => {
|
60211
60319
|
const { width: et, height: it } = tt[st], ut = lt.position.x + lt.width, ft = lt.position.y + lt.height;
|
60212
60320
|
if (et < ut) {
|
60213
60321
|
const ht = ut - et;
|
@@ -60219,7 +60327,7 @@ const uuid$6 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (a)
|
|
60219
60327
|
}
|
60220
60328
|
}), rt));
|
60221
60329
|
}, schemasList2template = (a, s) => ({
|
60222
|
-
schemas: cloneDeep$
|
60330
|
+
schemas: cloneDeep$1(a).map(
|
60223
60331
|
($) => $.reduce((_, _e) => {
|
60224
60332
|
const tt = _e.key;
|
60225
60333
|
return delete _e.id, delete _e.key, _[tt] = _e, _;
|
@@ -60288,7 +60396,7 @@ const uuid$6 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (a)
|
|
60288
60396
|
const { objs: s, schemas: $, basePdf: _, pluginsRegistry: _e, pageSize: tt, commitSchemas: nt } = a, at = s.reduce((ot, { key: rt, value: st, schemaId: lt }) => {
|
60289
60397
|
const et = ot.find((it) => it.id === lt);
|
60290
60398
|
return et && (set$2(et, rt, st), rt === "type" ? handleTypeChange(et, rt, st, _e) : ["position.x", "position.y", "width", "height"].includes(rt) && handlePositionSizeChange(et, rt, st, _, tt)), ot;
|
60291
|
-
}, cloneDeep$
|
60399
|
+
}, cloneDeep$1($));
|
60292
60400
|
nt(at);
|
60293
60401
|
}, DEFAULT_FONT_SIZE = 13, ALIGN_LEFT = "left", ALIGN_CENTER = "center", ALIGN_RIGHT = "right", DEFAULT_ALIGNMENT = ALIGN_LEFT, VERTICAL_ALIGN_TOP = "top", VERTICAL_ALIGN_MIDDLE = "middle", VERTICAL_ALIGN_BOTTOM = "bottom", DEFAULT_VERTICAL_ALIGNMENT = VERTICAL_ALIGN_TOP, DEFAULT_LINE_HEIGHT = 1, DEFAULT_CHARACTER_SPACING = 0, DEFAULT_FONT_COLOR = "#000000", PLACEHOLDER_FONT_COLOR = "#A0A0A0", DYNAMIC_FIT_VERTICAL = "vertical", DYNAMIC_FIT_HORIZONTAL = "horizontal", DEFAULT_DYNAMIC_FIT = DYNAMIC_FIT_VERTICAL, DEFAULT_DYNAMIC_MIN_FONT_SIZE = 4, DEFAULT_DYNAMIC_MAX_FONT_SIZE = 72, FONT_SIZE_ADJUSTMENT = 0.25, ENCODING_MAPPING = {
|
60294
60402
|
utf16le: "utf-16le",
|
@@ -81615,7 +81723,7 @@ const convertForPdfLayoutProps = ({ schema: a, pageHeight: s, applyRotateTransla
|
|
81615
81723
|
const ot = 1 - Math.max(tt, nt, at), rt = tt === 0 ? 0 : (1 - tt - ot) / (1 - ot), st = nt === 0 ? 0 : (1 - nt - ot) / (1 - ot), lt = at === 0 ? 0 : (1 - at - ot) / (1 - ot);
|
81616
81724
|
return cmyk(rt, st, lt, ot);
|
81617
81725
|
}
|
81618
|
-
}, hex2PrintingColor = (a, s) => (s == null ? void 0 : s.toLocaleLowerCase()) == "cmyk" ? hex2CmykColor(a) : hex2RgbColor(a),
|
81726
|
+
}, hex2PrintingColor = (a, s) => (s == null ? void 0 : s.toLocaleLowerCase()) == "cmyk" ? hex2CmykColor(a) : hex2RgbColor(a), embedAndGetFontObj = async (a) => {
|
81619
81727
|
const { pdfDoc: s, font: $, _cache: _ } = a;
|
81620
81728
|
if (_.has(s))
|
81621
81729
|
return _.get(s);
|
@@ -82391,21 +82499,6 @@ function mapCellStyle(a) {
|
|
82391
82499
|
cellPadding: a.padding
|
82392
82500
|
};
|
82393
82501
|
}
|
82394
|
-
function createTableWithAvailableHeight(a, s, $) {
|
82395
|
-
let _ = s;
|
82396
|
-
const _e = [];
|
82397
|
-
let tt = 0;
|
82398
|
-
for (; _ > 0 && tt < a.length; ) {
|
82399
|
-
const nt = a.slice(0, tt + 1).pop();
|
82400
|
-
if (!nt)
|
82401
|
-
break;
|
82402
|
-
const at = nt.height;
|
82403
|
-
if (_ - at < 0)
|
82404
|
-
break;
|
82405
|
-
_e.push(nt.raw), _ -= at, tt++;
|
82406
|
-
}
|
82407
|
-
return createSingleTable(_e, $);
|
82408
|
-
}
|
82409
82502
|
function getTableOptions(a, s) {
|
82410
82503
|
const $ = a.headWidthPercentages.reduce((nt, at, ot) => ({ ...nt, [ot]: { cellWidth: a.width * (at / 100) } }), {}), _ = Object.entries(a.columnStyles.alignment || {}).reduce((nt, [at, ot]) => ({ ...nt, [at]: { alignment: ot } }), {}), _e = /* @__PURE__ */ new Set([
|
82411
82504
|
...Object.keys($).map(Number),
|
@@ -82466,74 +82559,21 @@ function createSingleTable(a, s) {
|
|
82466
82559
|
const { options: $, _cache: _, basePdf: _e } = s;
|
82467
82560
|
if (!isBlankPdf(_e))
|
82468
82561
|
throw new Error("[@pdfme/schema/table] Custom PDF is not supported");
|
82469
|
-
const tt =
|
82470
|
-
|
82471
|
-
|
82472
|
-
|
82473
|
-
const { basePdf: $, schema: _ } = s;
|
82474
|
-
if (!isBlankPdf($))
|
82475
|
-
throw new Error("[@pdfme/schema/table] Custom PDF is not supported");
|
82476
|
-
const _e = $.height, tt = $.padding[2], nt = $.padding[0];
|
82477
|
-
let at = _e - tt - _.position.y;
|
82478
|
-
const ot = await createSingleTable(a, s);
|
82479
|
-
let rt = ot.body;
|
82480
|
-
const st = [];
|
82481
|
-
for (; rt.length > 0; ) {
|
82482
|
-
const lt = st.length === 0 ? at - ot.getHeadHeight() : at - nt, et = await createTableWithAvailableHeight(rt, lt, s);
|
82483
|
-
if (st.push(et), rt = rt.slice(et.body.length), rt.length > 0) {
|
82484
|
-
const it = cloneDeep$1(_);
|
82485
|
-
it.showHead = !1, it.position.y = nt, s.schema = it, at = _e - nt - tt;
|
82486
|
-
}
|
82562
|
+
const tt = cloneDeep$1(s.schema), { start: nt } = tt.__bodyRange || { start: 0 };
|
82563
|
+
if (nt % 2 === 1) {
|
82564
|
+
const lt = tt.bodyStyles.alternateBackgroundColor;
|
82565
|
+
tt.bodyStyles.alternateBackgroundColor = tt.bodyStyles.backgroundColor, tt.bodyStyles.backgroundColor = lt;
|
82487
82566
|
}
|
82488
|
-
|
82567
|
+
tt.showHead = nt === 0;
|
82568
|
+
const at = parseInput(tt, a), ot = $.font || getDefaultFont(), rt = getFallbackFontName(ot), st = parseContent4Table(at, rt);
|
82569
|
+
return Table$3.create({ input: at, content: st, font: ot, _cache: _ });
|
82489
82570
|
}
|
82490
|
-
const
|
82491
|
-
const { template: s, input: $, options: _, _cache: _e } = a, tt = Object.assign(cloneDeep$1(s), { schemas: [] });
|
82492
|
-
let nt = 0;
|
82493
|
-
for (const at of s.schemas) {
|
82494
|
-
const ot = [];
|
82495
|
-
for (const [rt, st] of Object.entries(at))
|
82496
|
-
if (st.type === "table") {
|
82497
|
-
st.__bodyRange = void 0;
|
82498
|
-
const lt = getBody$1($ == null ? void 0 : $[rt]), et = await createMultiTables(lt, {
|
82499
|
-
schema: st,
|
82500
|
-
basePdf: tt.basePdf,
|
82501
|
-
options: _,
|
82502
|
-
_cache: _e
|
82503
|
-
});
|
82504
|
-
if (et.length > 1) {
|
82505
|
-
const it = et[0];
|
82506
|
-
st.__bodyRange = { start: 0, end: it.body.length };
|
82507
|
-
const ut = et.map((ht) => ht.body);
|
82508
|
-
et.slice(1).forEach((ht, dt) => {
|
82509
|
-
const gt = nt + dt + 1, pt = {
|
82510
|
-
[rt]: {
|
82511
|
-
...st,
|
82512
|
-
position: { x: st.position.x, y: ht.settings.startY },
|
82513
|
-
height: ht.getHeight(),
|
82514
|
-
showHead: !1,
|
82515
|
-
__bodyRange: {
|
82516
|
-
start: ut.slice(0, dt + 1).reduce((mt, ct) => mt + ct.length, 0),
|
82517
|
-
end: ut.slice(0, dt + 2).reduce((mt, ct) => mt + ct.length, 0)
|
82518
|
-
},
|
82519
|
-
content: typeof $[rt] != "string" ? JSON.stringify($[rt] || "[]") : $[rt]
|
82520
|
-
}
|
82521
|
-
};
|
82522
|
-
ot[gt] = pt;
|
82523
|
-
});
|
82524
|
-
}
|
82525
|
-
}
|
82526
|
-
tt.schemas.push(at), ot.forEach((rt, st) => {
|
82527
|
-
tt.schemas[st] ? tt.schemas[st] = { ...tt.schemas[st], ...rt } : tt.schemas[st] = rt;
|
82528
|
-
}), nt++;
|
82529
|
-
}
|
82530
|
-
return tt;
|
82531
|
-
}, getDynamicHeightForTable = async (a, s) => {
|
82571
|
+
const getDynamicHeightsForTable = async (a, s) => {
|
82532
82572
|
var tt;
|
82533
82573
|
if (s.schema.type !== "table")
|
82534
|
-
return Promise.resolve(s.schema.height);
|
82574
|
+
return Promise.resolve([s.schema.height]);
|
82535
82575
|
const $ = s.schema, _ = ((tt = $.__bodyRange) == null ? void 0 : tt.start) === 0 ? getBody$1(a) : getBodyWithRange(a, $.__bodyRange);
|
82536
|
-
return (await createSingleTable(_, s)).
|
82576
|
+
return (await createSingleTable(_, s)).allRows().map((nt) => nt.height);
|
82537
82577
|
}, builtInPlugins = { Text: text };
|
82538
82578
|
class BaseUIClass {
|
82539
82579
|
constructor(s) {
|
@@ -82546,7 +82586,7 @@ class BaseUIClass {
|
|
82546
82586
|
}, this.render();
|
82547
82587
|
}, 100), this.resizeObserver = new ResizeObserver(this.setSize), checkUIProps(s);
|
82548
82588
|
const { domContainer: $, template: _, options: _e = {}, plugins: tt = {} } = s;
|
82549
|
-
this.domContainer = $, this.template = cloneDeep$
|
82589
|
+
this.domContainer = $, this.template = cloneDeep$1(_), this.options = _e, this.size = {
|
82550
82590
|
height: this.domContainer.clientHeight || window.innerHeight,
|
82551
82591
|
width: this.domContainer.clientWidth || window.innerWidth
|
82552
82592
|
}, this.resizeObserver.observe(this.domContainer);
|
@@ -82573,7 +82613,7 @@ class BaseUIClass {
|
|
82573
82613
|
updateTemplate(s) {
|
82574
82614
|
if (checkTemplate(s), !this.domContainer)
|
82575
82615
|
throw Error(DESTROYED_ERR_MSG);
|
82576
|
-
this.template = cloneDeep$
|
82616
|
+
this.template = cloneDeep$1(s), this.render();
|
82577
82617
|
}
|
82578
82618
|
updateOptions(s) {
|
82579
82619
|
checkUIOptions(s);
|
@@ -82588,7 +82628,7 @@ class BaseUIClass {
|
|
82588
82628
|
}
|
82589
82629
|
class PreviewUI extends BaseUIClass {
|
82590
82630
|
constructor(s) {
|
82591
|
-
super(s), checkPreviewProps(s), this.inputs = convertToStingObjectArray(cloneDeep$
|
82631
|
+
super(s), checkPreviewProps(s), this.inputs = convertToStingObjectArray(cloneDeep$1(s.inputs));
|
82592
82632
|
}
|
82593
82633
|
getInputs() {
|
82594
82634
|
if (!this.domContainer)
|
@@ -136500,8 +136540,8 @@ const { Text: Text$4 } = Typography$1, Item = React$a.memo(
|
|
136500
136540
|
const mt = pt === "undo", ct = mt ? rt : st;
|
136501
136541
|
if (ct.current.length <= 0)
|
136502
136542
|
return;
|
136503
|
-
(mt ? st : rt).current.push(cloneDeep$
|
136504
|
-
const vt = cloneDeep$
|
136543
|
+
(mt ? st : rt).current.push(cloneDeep$1(_e[a]));
|
136544
|
+
const vt = cloneDeep$1(_e);
|
136505
136545
|
vt[a] = ct.current.pop(), lt(vt);
|
136506
136546
|
};
|
136507
136547
|
initShortCuts({
|
@@ -136521,7 +136561,7 @@ const { Text: Text$4 } = Typography$1, Item = React$a.memo(
|
|
136521
136561
|
x: St.x + 10 > Bt.width - Et ? Bt.width - Et : St.x + 10,
|
136522
136562
|
y: St.y + 10 > Bt.height - bt ? Bt.height - bt : St.y + 10
|
136523
136563
|
};
|
136524
|
-
return Object.assign(cloneDeep$
|
136564
|
+
return Object.assign(cloneDeep$1(vt), { id: At, key: xt, position: Ot });
|
136525
136565
|
});
|
136526
136566
|
nt(_e[a].concat(ct)), et(ct.map((vt) => document.getElementById(vt.id))), ut.current = ct;
|
136527
136567
|
},
|
@@ -162422,8 +162462,8 @@ const Guides$2 = Guides$1, guideStyle = (a, s, $, _) => ({
|
|
162422
162462
|
});
|
162423
162463
|
const It = reactExports.useCallback(
|
162424
162464
|
(Tt) => {
|
162425
|
-
nt.current = [], tt.current.push(cloneDeep$
|
162426
|
-
const Dt = cloneDeep$
|
162465
|
+
nt.current = [], tt.current.push(cloneDeep$1(ht[gt]));
|
162466
|
+
const Dt = cloneDeep$1(ht);
|
162427
162467
|
Dt[gt] = Tt, dt(Dt), _(schemasList2template(Dt, a.basePdf));
|
162428
162468
|
},
|
162429
162469
|
[a, ht, gt, _]
|
@@ -162499,10 +162539,10 @@ const Guides$2 = Guides$1, guideStyle = (a, s, $, _) => ({
|
|
162499
162539
|
}, Nt = () => {
|
162500
162540
|
if (gt === 0 || !window.confirm(rt("removePageConfirm")))
|
162501
162541
|
return;
|
162502
|
-
const Tt = cloneDeep$
|
162542
|
+
const Tt = cloneDeep$1(ht);
|
162503
162543
|
Tt.splice(gt, 1), _t(Tt, gt - 1);
|
162504
162544
|
}, Mt = () => {
|
162505
|
-
const Tt = cloneDeep$
|
162545
|
+
const Tt = cloneDeep$1(ht);
|
162506
162546
|
Tt.splice(gt + 1, 0, []), _t(Tt, gt + 1);
|
162507
162547
|
};
|
162508
162548
|
xt !== a && (bt(a), kt(a));
|
@@ -162635,7 +162675,7 @@ class Designer extends BaseUIClass {
|
|
162635
162675
|
updateTemplate(s) {
|
162636
162676
|
if (checkTemplate(s), !this.domContainer)
|
162637
162677
|
throw Error(DESTROYED_ERR_MSG);
|
162638
|
-
this.template = cloneDeep$
|
162678
|
+
this.template = cloneDeep$1(s), this.onChangeTemplateCallback && this.onChangeTemplateCallback(s), this.render();
|
162639
162679
|
}
|
162640
162680
|
onSaveTemplate(s) {
|
162641
162681
|
this.onSaveTemplateCallback = s;
|
@@ -162789,8 +162829,7 @@ const Designer$1 = Designer, { Text } = Typography$1, icons = {
|
|
162789
162829
|
input: vt,
|
162790
162830
|
options: { font: tt },
|
162791
162831
|
_cache,
|
162792
|
-
|
162793
|
-
getDynamicHeight: (St, Bt) => Bt.schema.type !== "table" ? Promise.resolve(Bt.schema.height) : getDynamicHeightForTable(St, Bt)
|
162832
|
+
getDynamicHeights: (St, Bt) => Bt.schema.type !== "table" ? Promise.resolve([Bt.schema.height]) : getDynamicHeightsForTable(St, Bt)
|
162794
162833
|
}).then(async (St) => {
|
162795
162834
|
const Bt = await template2SchemasList(St);
|
162796
162835
|
ft(Bt), await mt(St);
|