@pdfme/ui 5.3.8-dev.57 → 5.3.8-dev.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/index.es.js +127 -60
  2. package/dist/types/src/components/Designer/LeftSidebar.d.ts +1 -1
  3. package/dist/types/src/components/Designer/PluginIcon.d.ts +1 -1
  4. package/package.json +1 -1
  5. package/src/Designer.tsx +4 -4
  6. package/src/Form.tsx +1 -3
  7. package/src/Viewer.tsx +1 -1
  8. package/src/components/AppContextProvider.tsx +1 -1
  9. package/src/components/CtlBar.tsx +1 -1
  10. package/src/components/Designer/Canvas/Guides.tsx +1 -1
  11. package/src/components/Designer/Canvas/Moveable.tsx +2 -2
  12. package/src/components/Designer/Canvas/Padding.tsx +10 -8
  13. package/src/components/Designer/Canvas/index.tsx +27 -14
  14. package/src/components/Designer/LeftSidebar.tsx +57 -49
  15. package/src/components/Designer/PluginIcon.tsx +21 -8
  16. package/src/components/Designer/RightSidebar/DetailView/AlignWidget.tsx +44 -44
  17. package/src/components/Designer/RightSidebar/DetailView/ButtonGroupWidget.tsx +3 -3
  18. package/src/components/Designer/RightSidebar/DetailView/index.tsx +51 -23
  19. package/src/components/Designer/RightSidebar/ListView/Item.tsx +4 -4
  20. package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +56 -47
  21. package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +2 -3
  22. package/src/components/Designer/RightSidebar/ListView/index.tsx +10 -3
  23. package/src/components/Designer/index.tsx +41 -19
  24. package/src/components/Preview.tsx +25 -14
  25. package/src/components/Renderer.tsx +35 -22
  26. package/src/components/Root.tsx +1 -1
  27. package/src/components/Spinner.tsx +1 -1
  28. package/src/components/StaticSchema.tsx +39 -21
  29. package/src/constants.ts +1 -1
  30. package/src/helper.ts +7 -7
  31. package/src/hooks.ts +3 -3
  32. package/src/types/react-guides.d.ts +1 -1
package/dist/index.es.js CHANGED
@@ -138842,7 +138842,12 @@ const { Text: Text$4 } = Typography, Item = React.memo(
138842
138842
  return Array.from(p.body.children).forEach((A) => v(A)), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: u, title: s, dangerouslySetInnerHTML: { __html: p.body.innerHTML } });
138843
138843
  }, PluginIcon = (a) => {
138844
138844
  var g;
138845
- const { plugin: s, label: c, size: u, styles: d } = a, { token: p } = theme.useToken(), A = ((g = reactExports.useContext(OptionsContext).icons) == null ? void 0 : g[s.propPanel.defaultSchema.type]) ?? s.icon, b = { ...d, color: p.colorText, display: "flex", justifyContent: "center" };
138845
+ const { plugin: s, label: c, size: u, styles: d } = a, { token: p } = theme.useToken(), A = ((g = reactExports.useContext(OptionsContext).icons) == null ? void 0 : g[s.propPanel.defaultSchema.type]) ?? s.icon, b = {
138846
+ ...d,
138847
+ color: p.colorText,
138848
+ display: "flex",
138849
+ justifyContent: "center"
138850
+ };
138846
138851
  return A ? u ? getWithModifiedSize(A, c, u, b) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: b, title: c, dangerouslySetInnerHTML: { __html: A } }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { ...d, overflow: "hidden", fontSize: 10 }, title: c, children: c });
138847
138852
  }, SelectableSortableItem = ({
138848
138853
  isSelected: a,
@@ -138908,7 +138913,15 @@ const { Text: Text$4 } = Typography, Item = React.memo(
138908
138913
  const $ = typeof P == "string" ? c.find((B) => B.id === P) : P, [T, E] = Object.entries(m).find(
138909
138914
  ([B, R]) => (R == null ? void 0 : R.propPanel.defaultSchema.type) === ($ == null ? void 0 : $.type)
138910
138915
  );
138911
- return E ? /* @__PURE__ */ jsxRuntimeExports.jsx(PluginIcon, { plugin: E, label: T, size: 20, styles: { marginRight: "0.5rem" } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
138916
+ return E ? /* @__PURE__ */ jsxRuntimeExports.jsx(
138917
+ PluginIcon,
138918
+ {
138919
+ plugin: E,
138920
+ label: T,
138921
+ size: 20,
138922
+ styles: { marginRight: "0.5rem" }
138923
+ }
138924
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
138912
138925
  };
138913
138926
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
138914
138927
  DndContext,
@@ -139036,20 +139049,31 @@ const { Text: Text$4 } = Typography, Item = React.memo(
139036
139049
  onEdit: u
139037
139050
  }
139038
139051
  ),
139039
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { paddingTop: "0.5rem", display: "flex", alignItems: "center", justifyContent: "flex-end" }, children: x ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
139040
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { size: "small", type: "text", onClick: S, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("u", { children: [
139041
- " ",
139042
- g("commitBulkUpdateFieldName")
139043
- ] }) }),
139044
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { margin: "0 1rem" }, children: "/" }),
139045
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { size: "small", type: "text", onClick: () => y(!1), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("u", { children: [
139046
- " ",
139047
- g("cancel")
139048
- ] }) })
139049
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { size: "small", type: "text", onClick: w, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("u", { children: [
139050
- " ",
139051
- g("bulkUpdateFieldName")
139052
- ] }) }) })
139052
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
139053
+ "div",
139054
+ {
139055
+ style: {
139056
+ paddingTop: "0.5rem",
139057
+ display: "flex",
139058
+ alignItems: "center",
139059
+ justifyContent: "flex-end"
139060
+ },
139061
+ children: x ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
139062
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { size: "small", type: "text", onClick: S, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("u", { children: [
139063
+ " ",
139064
+ g("commitBulkUpdateFieldName")
139065
+ ] }) }),
139066
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { margin: "0 1rem" }, children: "/" }),
139067
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { size: "small", type: "text", onClick: () => y(!1), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("u", { children: [
139068
+ " ",
139069
+ g("cancel")
139070
+ ] }) })
139071
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { size: "small", type: "text", onClick: w, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("u", { children: [
139072
+ " ",
139073
+ g("bulkUpdateFieldName")
139074
+ ] }) })
139075
+ }
139076
+ )
139053
139077
  ] })
139054
139078
  ] });
139055
139079
  };
@@ -154740,9 +154764,11 @@ const FormRenderComponent = withProvider(FormCore, defaultWidgets), AlignWidget
154740
154764
  }
154741
154765
  }
154742
154766
  R.length && A.validateFields().then(() => d(R)).catch((O) => {
154743
- O.errorFields.length && (R = R.filter((M) => !O.errorFields.find(
154744
- (_) => _.name.includes(M.key)
154745
- ))), R.length && d(R);
154767
+ O.errorFields.length && (R = R.filter(
154768
+ (M) => !O.errorFields.find(
154769
+ (_) => _.name.includes(M.key)
154770
+ )
154771
+ )), R.length && d(R);
154746
154772
  });
154747
154773
  }, 100), w = Object.values(g).find(
154748
154774
  (E) => (E == null ? void 0 : E.propPanel.defaultSchema.type) === v.type
@@ -154769,14 +154795,26 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
154769
154795
  type: "string",
154770
154796
  required: !0,
154771
154797
  span: 12,
154772
- rules: [{
154773
- validator: C,
154774
- message: b("validation.uniqueName")
154775
- }],
154798
+ rules: [
154799
+ {
154800
+ validator: C,
154801
+ message: b("validation.uniqueName")
154802
+ }
154803
+ ],
154776
154804
  props: { autoComplete: "off" }
154777
154805
  },
154778
- editable: { title: b("editable"), type: "boolean", span: 8, hidden: ($ == null ? void 0 : $.readOnly) !== void 0 },
154779
- required: { title: b("required"), type: "boolean", span: 16, hidden: "{{!formData.editable}}" },
154806
+ editable: {
154807
+ title: b("editable"),
154808
+ type: "boolean",
154809
+ span: 8,
154810
+ hidden: ($ == null ? void 0 : $.readOnly) !== void 0
154811
+ },
154812
+ required: {
154813
+ title: b("required"),
154814
+ type: "boolean",
154815
+ span: 16,
154816
+ hidden: "{{!formData.editable}}"
154817
+ },
154780
154818
  "-": { type: "void", widget: "Divider" },
154781
154819
  align: { title: b("align"), type: "void", widget: "AlignWidget" },
154782
154820
  position: {
@@ -154969,14 +155007,20 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
154969
155007
  outline: s
154970
155008
  },
154971
155009
  children: [
154972
- u.required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: {
154973
- color: "red",
154974
- position: "absolute",
154975
- top: -12,
154976
- left: -12,
154977
- fontSize: 18,
154978
- fontWeight: 700
154979
- }, children: "*" }),
155010
+ u.required && /* @__PURE__ */ jsxRuntimeExports.jsx(
155011
+ "span",
155012
+ {
155013
+ style: {
155014
+ color: "red",
155015
+ position: "absolute",
155016
+ top: -12,
155017
+ left: -12,
155018
+ fontSize: 18,
155019
+ fontWeight: 700
155020
+ },
155021
+ children: "*"
155022
+ }
155023
+ ),
154980
155024
  a
154981
155025
  ]
154982
155026
  }
@@ -155037,7 +155081,11 @@ Check this document: https://pdfme.com/docs/custom-schemas`), /* @__PURE__ */ js
155037
155081
  ) }),
155038
155082
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { visibility: y ? "hidden" : "visible" }, children: a.children })
155039
155083
  ] });
155040
- }, LeftSidebar = ({ height: a, scale: s, basePdf: c }) => {
155084
+ }, LeftSidebar = ({
155085
+ height: a,
155086
+ scale: s,
155087
+ basePdf: c
155088
+ }) => {
155041
155089
  const { token: u } = theme.useToken(), d = reactExports.useContext(PluginsRegistry), [p, v] = reactExports.useState(!1);
155042
155090
  return reactExports.useEffect(() => {
155043
155091
  const A = () => {
@@ -155060,23 +155108,14 @@ Check this document: https://pdfme.com/docs/custom-schemas`), /* @__PURE__ */ js
155060
155108
  textAlign: "center",
155061
155109
  overflow: p ? "visible" : "auto"
155062
155110
  },
155063
- children: Object.entries(d).map(([A, b]) => b != null && b.propPanel.defaultSchema ? /* @__PURE__ */ jsxRuntimeExports.jsx(
155064
- Draggable$1,
155111
+ children: Object.entries(d).map(([A, b]) => b != null && b.propPanel.defaultSchema ? /* @__PURE__ */ jsxRuntimeExports.jsx(Draggable$1, { scale: s, basePdf: c, plugin: b, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
155112
+ Button$1,
155065
155113
  {
155066
- scale: s,
155067
- basePdf: c,
155068
- plugin: b,
155069
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
155070
- Button$1,
155071
- {
155072
- onMouseDown: () => v(!0),
155073
- style: { width: 35, height: 35, marginTop: "0.25rem", padding: "0.25rem" },
155074
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(PluginIcon, { plugin: b, label: A })
155075
- }
155076
- )
155077
- },
155078
- A
155079
- ) : null)
155114
+ onMouseDown: () => v(!0),
155115
+ style: { width: 35, height: 35, marginTop: "0.25rem", padding: "0.25rem" },
155116
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(PluginIcon, { plugin: b, label: A })
155117
+ }
155118
+ ) }, A) : null)
155080
155119
  }
155081
155120
  );
155082
155121
  }, Paper = (a) => {
@@ -164921,7 +164960,13 @@ const guideStyle = (a, s, c, u) => ({
164921
164960
  }
164922
164961
  return u;
164923
164962
  }, Padding = ({ basePdf: a }) => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isBlankPdf(a) && a.padding.map((s, c) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: getPaddingStyle(c, s, theme.useToken().token.colorError) }, String(c))) }), StaticSchema = (a) => {
164924
- const { template: { schemas: s, basePdf: c }, input: u, scale: d, totalPages: p, currentPage: v } = a;
164963
+ const {
164964
+ template: { schemas: s, basePdf: c },
164965
+ input: u,
164966
+ scale: d,
164967
+ totalPages: p,
164968
+ currentPage: v
164969
+ } = a;
164925
164970
  return !isBlankPdf(c) || !c.staticSchema ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: c.staticSchema.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx(
164926
164971
  Renderer,
164927
164972
  {
@@ -165178,7 +165223,10 @@ const guideStyle = (a, s, c, u) => ({
165178
165223
  let oe = te;
165179
165224
  if (K !== "designer" && ae.readOnly) {
165180
165225
  const fe = {
165181
- ...g.flat().reduce((me, Ee) => (me[Ee.name] = Ee.content || "", me), {}),
165226
+ ...g.flat().reduce(
165227
+ (me, Ee) => (me[Ee.name] = Ee.content || "", me),
165228
+ {}
165229
+ ),
165182
165230
  totalPages: g.length,
165183
165231
  currentPage: V + 1
165184
165232
  };
@@ -165377,7 +165425,12 @@ const guideStyle = (a, s, c, u) => ({
165377
165425
  onChangeTemplate: u,
165378
165426
  onPageCursorChange: d
165379
165427
  }) => {
165380
- const p = reactExports.useRef([]), v = reactExports.useRef([]), A = reactExports.useRef(null), b = reactExports.useRef([]), g = reactExports.useContext(I18nContext), x = reactExports.useContext(PluginsRegistry), y = reactExports.useContext(OptionsContext), f = getMaxZoom(), [m, C] = reactExports.useState(null), [S, w] = reactExports.useState([]), [I, P] = reactExports.useState([[]]), [$, T] = reactExports.useState(0), [E, B] = reactExports.useState(1), [R, O] = reactExports.useState(!0), [M, _] = reactExports.useState(null), { backgrounds: D, pageSizes: U, scale: G, error: Q, refresh: L } = useUIPreProcessor({ template: a, size: s, zoomLevel: E, maxZoom: f }), F = (oe) => {
165428
+ const p = reactExports.useRef([]), v = reactExports.useRef([]), A = reactExports.useRef(null), b = reactExports.useRef([]), g = reactExports.useContext(I18nContext), x = reactExports.useContext(PluginsRegistry), y = reactExports.useContext(OptionsContext), f = getMaxZoom(), [m, C] = reactExports.useState(null), [S, w] = reactExports.useState([]), [I, P] = reactExports.useState([[]]), [$, T] = reactExports.useState(0), [E, B] = reactExports.useState(1), [R, O] = reactExports.useState(!0), [M, _] = reactExports.useState(null), { backgrounds: D, pageSizes: U, scale: G, error: Q, refresh: L } = useUIPreProcessor({
165429
+ template: a,
165430
+ size: s,
165431
+ zoomLevel: E,
165432
+ maxZoom: f
165433
+ }), F = (oe) => {
165381
165434
  w(oe), C(null);
165382
165435
  }, j = () => {
165383
165436
  w([]), C(null);
@@ -165447,8 +165500,16 @@ const guideStyle = (a, s, c, u) => ({
165447
165500
  ...oe,
165448
165501
  name: de(g("field")),
165449
165502
  position: {
165450
- x: se(be, oe.position.x, Ae.width - me - oe.width),
165451
- y: se(fe, oe.position.y, Ae.height - Ee - oe.height)
165503
+ x: se(
165504
+ be,
165505
+ oe.position.x,
165506
+ Ae.width - me - oe.width
165507
+ ),
165508
+ y: se(
165509
+ fe,
165510
+ oe.position.y,
165511
+ Ae.height - Ee - oe.height
165512
+ )
165452
165513
  },
165453
165514
  required: oe.readOnly ? !1 : y.requiredByDefault || oe.required || !1
165454
165515
  };
@@ -165489,7 +165550,10 @@ const guideStyle = (a, s, c, u) => ({
165489
165550
  onDragEnd: (oe) => {
165490
165551
  var ue, xe;
165491
165552
  if (!oe.active) return;
165492
- const fe = oe.active, me = b.current[$].getBoundingClientRect(), Ee = ((ue = fe.rect.current.initial) == null ? void 0 : ue.left) || 0, be = ((xe = fe.rect.current.initial) == null ? void 0 : xe.top) || 0, Ae = me.left - Ee + scaleDragPosAdjustment(20, G), de = me.top - be, se = (oe.delta.y - de) / G, ie = (oe.delta.x - Ae) / G, le = { x: round$1(px2mm(Math.max(0, ie)), 2), y: round$1(px2mm(Math.max(0, se)), 2) };
165553
+ const fe = oe.active, me = b.current[$].getBoundingClientRect(), Ee = ((ue = fe.rect.current.initial) == null ? void 0 : ue.left) || 0, be = ((xe = fe.rect.current.initial) == null ? void 0 : xe.top) || 0, Ae = me.left - Ee + scaleDragPosAdjustment(20, G), de = me.top - be, se = (oe.delta.y - de) / G, ie = (oe.delta.x - Ae) / G, le = {
165554
+ x: round$1(px2mm(Math.max(0, ie)), 2),
165555
+ y: round$1(px2mm(Math.max(0, se)), 2)
165556
+ };
165493
165557
  q({ ...fe.data.current, position: le });
165494
165558
  },
165495
165559
  onDragStart: j,
@@ -165750,7 +165814,12 @@ const { Text } = Typography, icons = {
165750
165814
  size: c,
165751
165815
  onChangeInput: u
165752
165816
  }) => {
165753
- const { token: d } = theme.useToken(), p = reactExports.useContext(FontContext), v = getMaxZoom(), A = reactExports.useRef(null), b = reactExports.useRef([]), [g, x] = reactExports.useState(0), [y, f] = reactExports.useState(0), [m, C] = reactExports.useState(1), [S, w] = reactExports.useState([[]]), { backgrounds: I, pageSizes: P, scale: $, error: T, refresh: E } = useUIPreProcessor({ template: a, size: c, zoomLevel: m, maxZoom: v }), B = !!u, R = s[g], O = (D) => {
165817
+ const { token: d } = theme.useToken(), p = reactExports.useContext(FontContext), v = getMaxZoom(), A = reactExports.useRef(null), b = reactExports.useRef([]), [g, x] = reactExports.useState(0), [y, f] = reactExports.useState(0), [m, C] = reactExports.useState(1), [S, w] = reactExports.useState([[]]), { backgrounds: I, pageSizes: P, scale: $, error: T, refresh: E } = useUIPreProcessor({
165818
+ template: a,
165819
+ size: c,
165820
+ zoomLevel: m,
165821
+ maxZoom: v
165822
+ }), B = !!u, R = s[g], O = (D) => {
165754
165823
  getDynamicTemplate({
165755
165824
  template: D,
165756
165825
  input: R,
@@ -165786,9 +165855,7 @@ const { Text } = Typography, icons = {
165786
165855
  if (F === j) return;
165787
165856
  M({ name: U.name, value: F }), U.type === "table" && (G = !0);
165788
165857
  } else {
165789
- const F = S[y].find(
165790
- (j) => j.id === U.id
165791
- );
165858
+ const F = S[y].find((j) => j.id === U.id);
165792
165859
  if (!F) return;
165793
165860
  F[Q] = L;
165794
165861
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { BasePdf } from '@pdfme/common';
3
- declare const LeftSidebar: ({ height, scale, basePdf }: {
3
+ declare const LeftSidebar: ({ height, scale, basePdf, }: {
4
4
  height: number;
5
5
  scale: number;
6
6
  basePdf: BasePdf;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Plugin } from "@pdfme/common";
2
+ import { Plugin } from '@pdfme/common';
3
3
  interface PluginIconProps {
4
4
  plugin: Plugin<any>;
5
5
  label: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.3.8-dev.57",
3
+ "version": "5.3.8-dev.58",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
package/src/Designer.tsx CHANGED
@@ -47,9 +47,9 @@ class Designer extends BaseUIClass {
47
47
  public onChangeTemplate(cb: (template: Template) => void) {
48
48
  this.onChangeTemplateCallback = cb;
49
49
  }
50
-
50
+
51
51
  public getPageCursor() {
52
- return this.pageCursor
52
+ return this.pageCursor;
53
53
  }
54
54
 
55
55
  protected render() {
@@ -78,12 +78,12 @@ class Designer extends BaseUIClass {
78
78
  }
79
79
  }}
80
80
  onPageCursorChange={(newPageCursor: number) => {
81
- this.pageCursor = newPageCursor
81
+ this.pageCursor = newPageCursor;
82
82
  }}
83
83
  size={this.size}
84
84
  />
85
85
  </AppContextProvider>,
86
- this.domContainer
86
+ this.domContainer,
87
87
  );
88
88
  }
89
89
  }
package/src/Form.tsx CHANGED
@@ -46,8 +46,6 @@ class Form extends PreviewUI {
46
46
  });
47
47
  }
48
48
 
49
-
50
-
51
49
  protected render() {
52
50
  if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
53
51
  ReactDOM.render(
@@ -75,7 +73,7 @@ class Form extends PreviewUI {
75
73
  }}
76
74
  />
77
75
  </AppContextProvider>,
78
- this.domContainer
76
+ this.domContainer,
79
77
  );
80
78
  }
81
79
  }
package/src/Viewer.tsx CHANGED
@@ -22,7 +22,7 @@ class Viewer extends PreviewUI {
22
22
  >
23
23
  <Preview template={this.template} size={this.size} inputs={this.inputs} />
24
24
  </AppContextProvider>,
25
- this.domContainer
25
+ this.domContainer,
26
26
  );
27
27
  }
28
28
  }
@@ -18,7 +18,7 @@ const isObject = (item: any): item is Record<string, any> =>
18
18
 
19
19
  const deepMerge = <T extends Record<string, any>, U extends Record<string, any>>(
20
20
  target: T,
21
- source: U
21
+ source: U,
22
22
  ): T & U => {
23
23
  let output = { ...target } as T & U;
24
24
 
@@ -7,7 +7,7 @@ import { Plus, Minus, ChevronLeft, ChevronRight, Ellipsis } from 'lucide-react';
7
7
  import type { MenuProps } from 'antd';
8
8
  import { theme, Typography, Button, Dropdown } from 'antd';
9
9
  import { I18nContext } from '../contexts.js';
10
- import { getMaxZoom } from "../helper.js";
10
+ import { getMaxZoom } from '../helper.js';
11
11
 
12
12
  const { Text } = Typography;
13
13
 
@@ -7,7 +7,7 @@ const guideStyle = (
7
7
  top: number,
8
8
  left: number,
9
9
  height: number,
10
- width: number
10
+ width: number,
11
11
  ): React.CSSProperties => ({
12
12
  position: 'absolute',
13
13
  top,
@@ -86,12 +86,12 @@ const _Moveable = (props: Props, ref: Ref<any>) => {
86
86
  useEffect(() => {
87
87
  const containerElement = document.querySelector(`.${className}`) as HTMLElement | null;
88
88
  const containerElement2 = document.querySelectorAll(
89
- `.${className} .moveable-line`
89
+ `.${className} .moveable-line`,
90
90
  ) as NodeListOf<HTMLElement>;
91
91
  if (containerElement) {
92
92
  containerElement.style.setProperty('--moveable-color', token.colorPrimary);
93
93
  Array.from(containerElement2).map((e) =>
94
- e.style.setProperty('--moveable-color', token.colorPrimary)
94
+ e.style.setProperty('--moveable-color', token.colorPrimary),
95
95
  );
96
96
  }
97
97
  }, [props.target]);
@@ -43,12 +43,14 @@ const getPaddingStyle = (i: number, p: number, color: string): CSS.Properties =>
43
43
  };
44
44
 
45
45
  const Padding = ({ basePdf }: { basePdf: BasePdf }) => {
46
- return <>
47
- {isBlankPdf(basePdf) &&
48
- basePdf.padding.map((p, i) => (
49
- <div key={String(i)} style={getPaddingStyle(i, p, theme.useToken().token.colorError)} />
50
- ))}
51
- </>
52
- }
46
+ return (
47
+ <>
48
+ {isBlankPdf(basePdf) &&
49
+ basePdf.padding.map((p, i) => (
50
+ <div key={String(i)} style={getPaddingStyle(i, p, theme.useToken().token.colorError)} />
51
+ ))}
52
+ </>
53
+ );
54
+ };
53
55
 
54
- export default Padding;
56
+ export default Padding;
@@ -10,7 +10,15 @@ import React, {
10
10
  useCallback,
11
11
  } from 'react';
12
12
  import { theme, Button } from 'antd';
13
- import { ZOOM, SchemaForUI, Size, ChangeSchemas, BasePdf, isBlankPdf, replacePlaceholders } from '@pdfme/common';
13
+ import {
14
+ ZOOM,
15
+ SchemaForUI,
16
+ Size,
17
+ ChangeSchemas,
18
+ BasePdf,
19
+ isBlankPdf,
20
+ replacePlaceholders,
21
+ } from '@pdfme/common';
14
22
  import { PluginsRegistry } from '../../../contexts.js';
15
23
  import { X } from 'lucide-react';
16
24
  import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
@@ -81,7 +89,6 @@ interface OnClick {
81
89
 
82
90
  const mm2px = (mm: number) => mm * 3.7795275591;
83
91
 
84
-
85
92
  const DELETE_BTN_ID = uuid();
86
93
  const fmt4Num = (prop: string) => Number(prop.replace('px', ''));
87
94
  const fmt = (prop: string) => round(fmt4Num(prop) / ZOOM, 2);
@@ -373,16 +380,16 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
373
380
 
374
381
  const rotatable = useMemo(() => {
375
382
  const selectedSchemas = (schemasList[pageCursor] || []).filter((s) =>
376
- activeElements.map((ae) => ae.id).includes(s.id)
383
+ activeElements.map((ae) => ae.id).includes(s.id),
377
384
  );
378
385
  const schemaTypes = selectedSchemas.map((s) => s.type);
379
386
  const uniqueSchemaTypes = [...new Set(schemaTypes)];
380
387
  const defaultSchemas = Object.values(pluginsRegistry).map(
381
- (plugin) => plugin?.propPanel.defaultSchema
388
+ (plugin) => plugin?.propPanel.defaultSchema,
382
389
  );
383
390
 
384
391
  return uniqueSchemaTypes.every(
385
- (type) => defaultSchemas.find((ds) => ds.type === type)?.rotate !== undefined
392
+ (type) => defaultSchemas.find((ds) => ds.type === type)?.rotate !== undefined,
386
393
  );
387
394
  }, [activeElements, pageCursor, schemasList, pluginsRegistry]);
388
395
 
@@ -452,7 +459,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
452
459
  <StaticSchema
453
460
  template={{ schemas: schemasList, basePdf }}
454
461
  input={Object.fromEntries(
455
- schemasList.flat().map(({ name, content = '' }) => [name, content])
462
+ schemasList.flat().map(({ name, content = '' }) => [name, content]),
456
463
  )}
457
464
  scale={scale}
458
465
  totalPages={schemasList.length}
@@ -501,17 +508,20 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
501
508
  const mode =
502
509
  editing && activeElements.map((ae) => ae.id).includes(schema.id)
503
510
  ? 'designer'
504
- : 'viewer'
511
+ : 'viewer';
505
512
 
506
513
  const content = schema.content || '';
507
514
  let value = content;
508
515
 
509
516
  if (mode !== 'designer' && schema.readOnly) {
510
517
  const variables = {
511
- ...schemasList.flat().reduce((acc, currSchema) => {
512
- acc[currSchema.name] = currSchema.content || '';
513
- return acc;
514
- }, {} as Record<string, string>),
518
+ ...schemasList.flat().reduce(
519
+ (acc, currSchema) => {
520
+ acc[currSchema.name] = currSchema.content || '';
521
+ return acc;
522
+ },
523
+ {} as Record<string, string>,
524
+ ),
515
525
  totalPages: schemasList.length,
516
526
  currentPage: index + 1,
517
527
  };
@@ -532,11 +542,14 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
532
542
  changeSchemas(args.map(({ key, value }) => ({ key, value, schemaId: schema.id })));
533
543
  }}
534
544
  stopEditing={() => setEditing(false)}
535
- outline={`1px ${hoveringSchemaId === schema.id ? 'solid' : 'dashed'} ${schema.readOnly && hoveringSchemaId !== schema.id ? 'transparent' : token.colorPrimary
536
- }`}
545
+ outline={`1px ${hoveringSchemaId === schema.id ? 'solid' : 'dashed'} ${
546
+ schema.readOnly && hoveringSchemaId !== schema.id
547
+ ? 'transparent'
548
+ : token.colorPrimary
549
+ }`}
537
550
  scale={scale}
538
551
  />
539
- )
552
+ );
540
553
  }}
541
554
  />
542
555
  </div>