@pdfme/ui 5.3.11-dev.11 → 5.3.11-dev.13

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 CHANGED
@@ -82204,7 +82204,12 @@ function createSingleTable(a, s) {
82204
82204
  }
82205
82205
  p.showHead = p.showHead === !1 ? !1 : !p.__isSplit;
82206
82206
  const v = parseInput(p, a), b = c.font || getDefaultFont(), g = getFallbackFontName(b), x = parseContent4Table(v, g);
82207
- return Table$2.create({ input: v, content: x, font: b, _cache: u });
82207
+ return Table$2.create({
82208
+ input: v,
82209
+ content: x,
82210
+ font: b,
82211
+ _cache: u
82212
+ });
82208
82213
  }
82209
82214
  const DEFAULT_OPACITY = 1, HEX_COLOR_PATTERN = "^#(?:[A-Fa-f0-9]{6})$", getBody$1 = (a) => typeof a == "string" ? JSON.parse(a || "[]") : a || [], getBodyWithRange = (a, s) => {
82210
82215
  const c = getBody$1(a);
@@ -82297,7 +82302,11 @@ const DEFAULT_OPACITY = 1, HEX_COLOR_PATTERN = "^#(?:[A-Fa-f0-9]{6})$", getBody$
82297
82302
  if (!s)
82298
82303
  return;
82299
82304
  const { font: b = getDefaultFont(), colorType: g } = p, [x, y] = await Promise.all([
82300
- embedAndGetFontObj({ pdfDoc: c, font: b, _cache: v }),
82305
+ embedAndGetFontObj({
82306
+ pdfDoc: c,
82307
+ font: b,
82308
+ _cache: v
82309
+ }),
82301
82310
  getFontKitFont(A.fontName, b, v)
82302
82311
  ]), f = getFontProp({ value: s, fontKitFont: y, schema: A, colorType: g }), { fontSize: m, color: C, alignment: S, verticalAlignment: w, lineHeight: I, characterSpacing: T } = f, $ = A.fontName ? A.fontName : getFallbackFontName(b), P = x && x[$], E = d.getHeight(), { width: B, height: R, rotate: O, position: { x: M, y: k }, opacity: D } = convertForPdfLayoutProps({ schema: A, pageHeight: E, applyRotateTranslate: !1 });
82303
82312
  if (A.backgroundColor) {
@@ -82973,9 +82982,11 @@ const arrayBufferToBase64 = (a) => {
82973
82982
  const v = Object.entries(u);
82974
82983
  for (let g = 0; g < v.length; g++) {
82975
82984
  const [, x] = v[g];
82976
- if (!x || typeof x != "object" || !("propPanel" in x) || !x.propPanel || typeof x.propPanel != "object") continue;
82985
+ if (!x || typeof x != "object" || !("propPanel" in x) || !x.propPanel || typeof x.propPanel != "object")
82986
+ continue;
82977
82987
  const y = x.propPanel;
82978
- if (!("defaultSchema" in y) || !y.defaultSchema || typeof y.defaultSchema != "object") continue;
82988
+ if (!("defaultSchema" in y) || !y.defaultSchema || typeof y.defaultSchema != "object")
82989
+ continue;
82979
82990
  const f = y.defaultSchema;
82980
82991
  if (!("type" in f) || typeof f.type != "string") continue;
82981
82992
  const m = f.type;
@@ -138618,104 +138629,102 @@ function isAfter(a, s) {
138618
138629
  }
138619
138630
  const { Text: Text$4 } = Typography, Item = React.memo(
138620
138631
  /* eslint-disable react/prop-types */
138621
- React.forwardRef(
138622
- function a({
138623
- icon: s,
138624
- value: c,
138625
- status: u,
138626
- title: d,
138627
- required: p,
138628
- readOnly: A,
138629
- style: v,
138630
- dragOverlay: b,
138631
- onClick: g,
138632
- onMouseEnter: x,
138633
- onMouseLeave: y,
138634
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
138635
- dragging: f,
138636
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
138637
- fadeIn: m,
138638
- listeners: C,
138639
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
138640
- sorting: S,
138641
- transition: w,
138642
- transform: I,
138643
- ...T
138644
- }, $) {
138645
- const P = reactExports.useContext(I18nContext);
138646
- reactExports.useEffect(() => {
138647
- if (b)
138648
- return document.body.style.cursor = "grabbing", () => {
138649
- document.body.style.cursor = "";
138650
- };
138651
- }, [b]);
138652
- const { x: E, y: B, scaleX: R, scaleY: O } = I || { x: 0, y: 0, scaleX: 1, scaleY: 1 };
138653
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
138654
- "li",
138655
- {
138656
- style: {
138657
- marginTop: 10,
138658
- transition: w,
138659
- transform: `translate(${E}px, ${B}px) scale(${R}, ${O})`
138660
- },
138661
- onMouseEnter: x,
138662
- onMouseLeave: y,
138663
- ref: $,
138664
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
138665
- "div",
138666
- {
138667
- style: {
138668
- display: "flex",
138669
- alignItems: "center",
138670
- cursor: "pointer",
138671
- gap: "0.5rem",
138672
- ...v
138673
- },
138674
- ...T,
138675
- onClick: () => g && g(),
138676
- children: [
138677
- /* @__PURE__ */ jsxRuntimeExports.jsx(
138678
- Button$1,
138679
- {
138680
- ...C,
138681
- style: {
138682
- display: "flex",
138683
- alignItems: "center",
138684
- background: "none",
138685
- boxShadow: "none",
138686
- border: "none",
138687
- paddingLeft: "0.25rem"
138688
- },
138689
- icon: /* @__PURE__ */ jsxRuntimeExports.jsx(GripVertical, { size: 15, style: { cursor: "grab" } })
138690
- }
138691
- ),
138692
- s,
138693
- /* @__PURE__ */ jsxRuntimeExports.jsx(
138694
- Text$4,
138695
- {
138696
- style: {
138697
- overflow: "hidden",
138698
- whiteSpace: "nowrap",
138699
- textOverflow: "ellipsis",
138700
- width: "100%"
138701
- },
138702
- title: d || "",
138703
- children: u === void 0 ? c : /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { style: { display: "flex", alignItems: "center" }, children: [
138704
- /* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { size: 15, style: { marginRight: "0.25rem" } }),
138705
- u === "is-warning" ? P("noKeyName") : c,
138706
- u === "is-danger" ? P("notUniq") : ""
138707
- ] })
138708
- }
138709
- ),
138710
- A && /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { size: 15, style: { marginRight: "0.5rem" } }),
138711
- p && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "red", marginRight: "0.5rem" }, children: "*" })
138712
- ]
138713
- }
138714
- )
138715
- }
138716
- );
138717
- }
138718
- )
138632
+ React.forwardRef(function a({
138633
+ icon: s,
138634
+ value: c,
138635
+ status: u,
138636
+ title: d,
138637
+ required: p,
138638
+ readOnly: A,
138639
+ style: v,
138640
+ dragOverlay: b,
138641
+ onClick: g,
138642
+ onMouseEnter: x,
138643
+ onMouseLeave: y,
138644
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
138645
+ dragging: f,
138646
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
138647
+ fadeIn: m,
138648
+ listeners: C,
138649
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
138650
+ sorting: S,
138651
+ transition: w,
138652
+ transform: I,
138653
+ ...T
138654
+ }, $) {
138655
+ const P = reactExports.useContext(I18nContext);
138656
+ reactExports.useEffect(() => {
138657
+ if (b)
138658
+ return document.body.style.cursor = "grabbing", () => {
138659
+ document.body.style.cursor = "";
138660
+ };
138661
+ }, [b]);
138662
+ const { x: E, y: B, scaleX: R, scaleY: O } = I || { x: 0, y: 0, scaleX: 1, scaleY: 1 };
138663
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
138664
+ "li",
138665
+ {
138666
+ style: {
138667
+ marginTop: 10,
138668
+ transition: w,
138669
+ transform: `translate(${E}px, ${B}px) scale(${R}, ${O})`
138670
+ },
138671
+ onMouseEnter: x,
138672
+ onMouseLeave: y,
138673
+ ref: $,
138674
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
138675
+ "div",
138676
+ {
138677
+ style: {
138678
+ display: "flex",
138679
+ alignItems: "center",
138680
+ cursor: "pointer",
138681
+ gap: "0.5rem",
138682
+ ...v
138683
+ },
138684
+ ...T,
138685
+ onClick: () => g && g(),
138686
+ children: [
138687
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
138688
+ Button$1,
138689
+ {
138690
+ ...C,
138691
+ style: {
138692
+ display: "flex",
138693
+ alignItems: "center",
138694
+ background: "none",
138695
+ boxShadow: "none",
138696
+ border: "none",
138697
+ paddingLeft: "0.25rem"
138698
+ },
138699
+ icon: /* @__PURE__ */ jsxRuntimeExports.jsx(GripVertical, { size: 15, style: { cursor: "grab" } })
138700
+ }
138701
+ ),
138702
+ s,
138703
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
138704
+ Text$4,
138705
+ {
138706
+ style: {
138707
+ overflow: "hidden",
138708
+ whiteSpace: "nowrap",
138709
+ textOverflow: "ellipsis",
138710
+ width: "100%"
138711
+ },
138712
+ title: d || "",
138713
+ children: u === void 0 ? c : /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { style: { display: "flex", alignItems: "center" }, children: [
138714
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { size: 15, style: { marginRight: "0.25rem" } }),
138715
+ u === "is-warning" ? P("noKeyName") : c,
138716
+ u === "is-danger" ? P("notUniq") : ""
138717
+ ] })
138718
+ }
138719
+ ),
138720
+ A && /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { size: 15, style: { marginRight: "0.5rem" } }),
138721
+ p && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "red", marginRight: "0.5rem" }, children: "*" })
138722
+ ]
138723
+ }
138724
+ )
138725
+ }
138726
+ );
138727
+ })
138719
138728
  );
138720
138729
  Item.displayName = "Item";
138721
138730
  const usePrevious = (a) => {
@@ -138908,13 +138917,12 @@ const usePrevious = (a) => {
138908
138917
  }), I = useMountStatus(), T = m && !I, $ = {
138909
138918
  ...f,
138910
138919
  onClick: (D) => c(d.id, D.shiftKey)
138911
- }, P = typeof d.type == "string" ? d.type : "", E = Object.entries(x).find(
138912
- ([, D]) => {
138913
- if (!D || typeof D != "object" || !D.propPanel || typeof D.propPanel != "object" || !D.propPanel.defaultSchema || typeof D.propPanel.defaultSchema != "object") return !1;
138914
- const H = D.propPanel.defaultSchema;
138915
- return "type" in H && typeof H.type == "string" && H.type === P;
138916
- }
138917
- ), [B, R] = E || ["", void 0];
138920
+ }, P = typeof d.type == "string" ? d.type : "", E = Object.entries(x).find(([, D]) => {
138921
+ if (!D || typeof D != "object" || !D.propPanel || typeof D.propPanel != "object" || !D.propPanel.defaultSchema || typeof D.propPanel.defaultSchema != "object")
138922
+ return !1;
138923
+ const H = D.propPanel.defaultSchema;
138924
+ return "type" in H && typeof H.type == "string" && H.type === P;
138925
+ }), [B, R] = E || ["", void 0];
138918
138926
  let O;
138919
138927
  d.name ? p.find((D) => d.name && D.name === d.name && D.id !== d.id) && (O = "is-danger") : O = "is-warning";
138920
138928
  let M = g("edit");
@@ -138960,13 +138968,12 @@ const usePrevious = (a) => {
138960
138968
  }, I = (T) => {
138961
138969
  const $ = typeof T == "string" ? c.find((O) => O.id === T) : T;
138962
138970
  if (!$) return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
138963
- const P = typeof $.type == "string" ? $.type : "", E = Object.entries(m).find(
138964
- ([, O]) => {
138965
- if (!O || typeof O != "object" || !O.propPanel || typeof O.propPanel != "object" || !O.propPanel.defaultSchema || typeof O.propPanel.defaultSchema != "object") return !1;
138966
- const M = O.propPanel.defaultSchema;
138967
- return "type" in M && typeof M.type == "string" && M.type === P;
138968
- }
138969
- ), [B, R] = E || ["", void 0];
138971
+ const P = typeof $.type == "string" ? $.type : "", E = Object.entries(m).find(([, O]) => {
138972
+ if (!O || typeof O != "object" || !O.propPanel || typeof O.propPanel != "object" || !O.propPanel.defaultSchema || typeof O.propPanel.defaultSchema != "object")
138973
+ return !1;
138974
+ const M = O.propPanel.defaultSchema;
138975
+ return "type" in M && typeof M.type == "string" && M.type === P;
138976
+ }), [B, R] = E || ["", void 0];
138970
138977
  return R ? /* @__PURE__ */ jsxRuntimeExports.jsx(
138971
138978
  PluginIcon,
138972
138979
  {
@@ -154649,13 +154656,17 @@ var updateSchemaByPath = function a(s, c, u) {
154649
154656
  };
154650
154657
  const FormRenderComponent = withProvider(FormCore, defaultWidgets), AlignWidget = (a) => {
154651
154658
  const { activeElements: s, changeSchemas: c, schemas: u, pageSize: d, schema: p } = a, A = (g) => {
154652
- const x = s.map((E) => E.id), y = u.filter((E) => x.includes(E.id)), f = ["left", "center", "right"].includes(g), m = f ? "x" : "y", C = f ? "width" : "height", S = y.length === 1, w = d && typeof d == "object" ? C === "width" ? d.width : d.height : 0, I = S ? 0 : Math.min(...y.map((E) => {
154653
- const B = E.position && typeof E.position == "object" ? E.position : { x: 0, y: 0 };
154654
- return m === "x" ? B.x : B.y;
154655
- })), T = S ? w : Math.max(...y.map((E) => {
154656
- const B = E.position && typeof E.position == "object" ? E.position : { x: 0, y: 0 }, R = m === "x" ? B.x : B.y, O = E, M = C === "width" ? O.width || 0 : O.height || 0;
154657
- return R + M;
154658
- }));
154659
+ const x = s.map((E) => E.id), y = u.filter((E) => x.includes(E.id)), f = ["left", "center", "right"].includes(g), m = f ? "x" : "y", C = f ? "width" : "height", S = y.length === 1, w = d && typeof d == "object" ? C === "width" ? d.width : d.height : 0, I = S ? 0 : Math.min(
154660
+ ...y.map((E) => {
154661
+ const B = E.position && typeof E.position == "object" ? E.position : { x: 0, y: 0 };
154662
+ return m === "x" ? B.x : B.y;
154663
+ })
154664
+ ), T = S ? w : Math.max(
154665
+ ...y.map((E) => {
154666
+ const B = E.position && typeof E.position == "object" ? E.position : { x: 0, y: 0 }, R = m === "x" ? B.x : B.y, O = E, M = C === "width" ? O.width || 0 : O.height || 0;
154667
+ return R + M;
154668
+ })
154669
+ );
154659
154670
  let $ = I, P = (E) => 0;
154660
154671
  ["center", "middle"].includes(g) ? ($ = (I + T) / 2, P = (E) => E / 2) : ["right", "bottom"].includes(g) && ($ = T, P = (E) => E), c(
154661
154672
  y.map((E) => {
@@ -154668,13 +154679,17 @@ const FormRenderComponent = withProvider(FormCore, defaultWidgets), AlignWidget
154668
154679
  })
154669
154680
  );
154670
154681
  }, v = (g) => {
154671
- const x = s.map((R) => R.id), y = u.filter((R) => x.includes(R.id)), f = g === "vertical", m = f ? "y" : "x", C = f ? "height" : "width", S = Math.min(...y.map((R) => {
154672
- const O = R.position && typeof R.position == "object" ? R.position : { x: 0, y: 0 };
154673
- return m === "x" ? O.x : O.y;
154674
- })), w = Math.max(...y.map((R) => {
154675
- const O = R.position && typeof R.position == "object" ? R.position : { x: 0, y: 0 }, M = m === "x" ? O.x : O.y, k = R, D = C === "width" ? k.width || 0 : k.height || 0;
154676
- return M + D;
154677
- }));
154682
+ const x = s.map((R) => R.id), y = u.filter((R) => x.includes(R.id)), f = g === "vertical", m = f ? "y" : "x", C = f ? "height" : "width", S = Math.min(
154683
+ ...y.map((R) => {
154684
+ const O = R.position && typeof R.position == "object" ? R.position : { x: 0, y: 0 };
154685
+ return m === "x" ? O.x : O.y;
154686
+ })
154687
+ ), w = Math.max(
154688
+ ...y.map((R) => {
154689
+ const O = R.position && typeof R.position == "object" ? R.position : { x: 0, y: 0 }, M = m === "x" ? O.x : O.y, k = R, D = C === "width" ? k.width || 0 : k.height || 0;
154690
+ return M + D;
154691
+ })
154692
+ );
154678
154693
  if (y.length < 3) return;
154679
154694
  const I = S, T = w - S, $ = y.reduce((R, O) => {
154680
154695
  const M = O, k = C === "width" ? M.width || 0 : M.height || 0;
@@ -154851,13 +154866,12 @@ const FormRenderComponent = withProvider(FormCore, defaultWidgets), AlignWidget
154851
154866
  )
154852
154867
  )), U.length && d(U);
154853
154868
  });
154854
- }, 100), I = Object.values(g).find(
154855
- (k) => {
154856
- if (!k || typeof k != "object" || !k.propPanel || typeof k.propPanel != "object" || !k.propPanel.defaultSchema || typeof k.propPanel.defaultSchema != "object") return !1;
154857
- const D = k.propPanel.defaultSchema;
154858
- return "type" in D && typeof D.type == "string" && D.type === A.type;
154859
- }
154860
- ), T = (O = I == null ? void 0 : I.propPanel) == null ? void 0 : O.schema;
154869
+ }, 100), I = Object.values(g).find((k) => {
154870
+ if (!k || typeof k != "object" || !k.propPanel || typeof k.propPanel != "object" || !k.propPanel.defaultSchema || typeof k.propPanel.defaultSchema != "object")
154871
+ return !1;
154872
+ const D = k.propPanel.defaultSchema;
154873
+ return "type" in D && typeof D.type == "string" && D.type === A.type;
154874
+ }), T = (O = I == null ? void 0 : I.propPanel) == null ? void 0 : O.schema;
154861
154875
  T || console.error(`[@pdfme/ui] No propPanel.schema for ${A.type}.
154862
154876
  Check this document: https://pdfme.com/docs/custom-schemas`);
154863
154877
  const $ = [];
@@ -154972,7 +154986,15 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
154972
154986
  }, R = { ...B.properties };
154973
154987
  if (typeof T == "function") {
154974
154988
  const { size: k, schemas: D, pageSize: H, changeSchemas: U, activeElements: V, deselectSchema: N, activeSchema: F } = a, L = T({
154975
- ...{ size: k, schemas: D, pageSize: H, changeSchemas: U, activeElements: V, deselectSchema: N, activeSchema: F },
154989
+ ...{
154990
+ size: k,
154991
+ schemas: D,
154992
+ pageSize: H,
154993
+ changeSchemas: U,
154994
+ activeElements: V,
154995
+ deselectSchema: N,
154996
+ activeSchema: F
154997
+ },
154976
154998
  options: x,
154977
154999
  theme: s,
154978
155000
  i18n: y
@@ -165900,9 +165922,7 @@ var InitialMoveable = /* @__PURE__ */ function(a) {
165900
165922
  const className = "pdfme-moveable", Moveable = (a, s) => {
165901
165923
  const { token: c } = theme.useToken();
165902
165924
  return reactExports.useEffect(() => {
165903
- const u = document.querySelector(`.${className}`), d = document.querySelectorAll(
165904
- `.${className} .moveable-line`
165905
- );
165925
+ const u = document.querySelector(`.${className}`), d = document.querySelectorAll(`.${className} .moveable-line`);
165906
165926
  u instanceof HTMLElement && (u.style.setProperty("--moveable-color", c.colorPrimary), Array.from(d).forEach((p) => {
165907
165927
  p instanceof HTMLElement && p.style.setProperty("--moveable-color", c.colorPrimary);
165908
165928
  }));
@@ -166831,9 +166851,7 @@ const guideStyle = (a, s, c, u) => ({
166831
166851
  return Object.values(T).forEach((ie) => {
166832
166852
  ie && typeof ie == "object" && "propPanel" in ie && ie.propPanel && typeof ie.propPanel == "object" && "defaultSchema" in ie.propPanel && ie.propPanel.defaultSchema && te.push(ie.propPanel.defaultSchema);
166833
166853
  }), Z.every((ie) => {
166834
- const ue = te.find(
166835
- (me) => me && "type" in me && me.type === ie
166836
- );
166854
+ const ue = te.find((me) => me && "type" in me && me.type === ie);
166837
166855
  return ue && "rotate" in ue;
166838
166856
  });
166839
166857
  }, [b, u, g, T]);
@@ -167380,9 +167398,15 @@ const guideStyle = (a, s, c, u) => ({
167380
167398
  }), c;
167381
167399
  }, AppContextProvider = ({ children: a, lang: s, font: c, plugins: u, options: d }) => {
167382
167400
  let p = defaultTheme;
167383
- d.theme && (p = deepMerge(p, d.theme));
167401
+ d.theme && (p = deepMerge(
167402
+ p,
167403
+ d.theme
167404
+ ));
167384
167405
  let A = getDict(s);
167385
- return d.labels && (A = deepMerge(A, d.labels)), /* @__PURE__ */ jsxRuntimeExports.jsx(ConfigProvider, { theme: p, children: /* @__PURE__ */ jsxRuntimeExports.jsx(I18nContext.Provider, { value: (v) => i18n(v, A), children: /* @__PURE__ */ jsxRuntimeExports.jsx(FontContext.Provider, { value: c, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PluginsRegistry.Provider, { value: u, children: /* @__PURE__ */ jsxRuntimeExports.jsx(OptionsContext.Provider, { value: d, children: a }) }) }) }) });
167406
+ return d.labels && (A = deepMerge(
167407
+ A,
167408
+ d.labels
167409
+ )), /* @__PURE__ */ jsxRuntimeExports.jsx(ConfigProvider, { theme: p, children: /* @__PURE__ */ jsxRuntimeExports.jsx(I18nContext.Provider, { value: (v) => i18n(v, A), children: /* @__PURE__ */ jsxRuntimeExports.jsx(FontContext.Provider, { value: c, children: /* @__PURE__ */ jsxRuntimeExports.jsx(PluginsRegistry.Provider, { value: u, children: /* @__PURE__ */ jsxRuntimeExports.jsx(OptionsContext.Provider, { value: d, children: a }) }) }) }) });
167386
167410
  };
167387
167411
  class Designer extends BaseUIClass {
167388
167412
  constructor(s) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.3.11-dev.11",
3
+ "version": "5.3.11-dev.13",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -48,12 +48,18 @@ const deepMerge = <T extends Record<string, unknown>, U extends Record<string, u
48
48
  const AppContextProvider = ({ children, lang, font, plugins, options }: Props) => {
49
49
  let theme = defaultTheme;
50
50
  if (options.theme) {
51
- theme = deepMerge(theme as unknown as Record<string, unknown>, options.theme as unknown as Record<string, unknown>) as typeof theme;
51
+ theme = deepMerge(
52
+ theme as unknown as Record<string, unknown>,
53
+ options.theme as unknown as Record<string, unknown>,
54
+ ) as typeof theme;
52
55
  }
53
56
 
54
57
  let dict = getDict(lang);
55
58
  if (options.labels) {
56
- dict = deepMerge(dict as unknown as Record<string, unknown>, options.labels as unknown as Record<string, unknown>) as typeof dict;
59
+ dict = deepMerge(
60
+ dict as unknown as Record<string, unknown>,
61
+ options.labels as unknown as Record<string, unknown>,
62
+ ) as typeof dict;
57
63
  }
58
64
 
59
65
  return (
@@ -1,5 +1,11 @@
1
1
  import React, { useEffect, forwardRef, Ref } from 'react';
2
- import MoveableComponent, { OnDrag, OnRotate, OnRotateEnd, OnClick, OnResize } from 'react-moveable';
2
+ import MoveableComponent, {
3
+ OnDrag,
4
+ OnRotate,
5
+ OnRotateEnd,
6
+ OnClick,
7
+ OnResize,
8
+ } from 'react-moveable';
3
9
  import { theme } from 'antd';
4
10
 
5
11
  type Props = {
@@ -27,9 +33,7 @@ const Moveable = (props: Props, ref: Ref<MoveableComponent>) => {
27
33
  const { token } = theme.useToken();
28
34
  useEffect(() => {
29
35
  const containerElement = document.querySelector(`.${className}`);
30
- const containerElement2 = document.querySelectorAll(
31
- `.${className} .moveable-line`,
32
- );
36
+ const containerElement2 = document.querySelectorAll(`.${className} .moveable-line`);
33
37
  if (containerElement instanceof HTMLElement) {
34
38
  containerElement.style.setProperty('--moveable-color', token.colorPrimary);
35
39
  Array.from(containerElement2).forEach((e) => {
@@ -1,5 +1,8 @@
1
1
  import React, { useEffect } from 'react';
2
- import SelectoComponent, { OnSelect as SelectoOnSelect, OnDragStart as SelectoOnDragStart } from 'react-selecto';
2
+ import SelectoComponent, {
3
+ OnSelect as SelectoOnSelect,
4
+ OnDragStart as SelectoOnDragStart,
5
+ } from 'react-selecto';
3
6
  import { SELECTABLE_CLASSNAME } from '../../../constants.js';
4
7
  import { theme } from 'antd';
5
8
 
@@ -331,28 +331,28 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
331
331
  );
332
332
  const schemaTypes = selectedSchemas.map((s) => s.type);
333
333
  const uniqueSchemaTypes = [...new Set(schemaTypes)];
334
-
334
+
335
335
  // Create a type-safe array of default schemas
336
336
  const defaultSchemas: Record<string, unknown>[] = [];
337
-
337
+
338
338
  // Safely iterate through plugins registry
339
- Object.values(pluginsRegistry).forEach(plugin => {
340
- if (plugin &&
341
- typeof plugin === 'object' &&
342
- 'propPanel' in plugin &&
343
- plugin.propPanel &&
344
- typeof plugin.propPanel === 'object' &&
345
- 'defaultSchema' in plugin.propPanel &&
346
- plugin.propPanel.defaultSchema) {
339
+ Object.values(pluginsRegistry).forEach((plugin) => {
340
+ if (
341
+ plugin &&
342
+ typeof plugin === 'object' &&
343
+ 'propPanel' in plugin &&
344
+ plugin.propPanel &&
345
+ typeof plugin.propPanel === 'object' &&
346
+ 'defaultSchema' in plugin.propPanel &&
347
+ plugin.propPanel.defaultSchema
348
+ ) {
347
349
  defaultSchemas.push(plugin.propPanel.defaultSchema as Record<string, unknown>);
348
350
  }
349
351
  });
350
352
 
351
353
  // Check if all schema types have rotate property
352
- return uniqueSchemaTypes.every(type => {
353
- const matchingSchema = defaultSchemas.find(ds =>
354
- ds && 'type' in ds && ds.type === type
355
- );
354
+ return uniqueSchemaTypes.every((type) => {
355
+ const matchingSchema = defaultSchemas.find((ds) => ds && 'type' in ds && ds.type === type);
356
356
  return matchingSchema && 'rotate' in matchingSchema;
357
357
  });
358
358
  }, [activeElements, pageCursor, schemasList, pluginsRegistry]);
@@ -375,7 +375,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
375
375
  const inputEvent = e.inputEvent as MouseEvent | TouchEvent;
376
376
  const target = inputEvent.target as Element | null;
377
377
  const isMoveableElement = moveable.current?.isMoveableElement(target as Element);
378
-
378
+
379
379
  if ((inputEvent.type === 'touchstart' && e.isTrusted) || isMoveableElement) {
380
380
  e.stop();
381
381
  }
@@ -383,7 +383,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
383
383
  if (paperRefs.current[pageCursor] === target) {
384
384
  onEdit([]);
385
385
  }
386
-
386
+
387
387
  // Check if the target is an HTMLElement and has an id property
388
388
  const targetElement = target as HTMLElement | null;
389
389
  if (targetElement && targetElement.id === DELETE_BTN_ID) {
@@ -396,10 +396,10 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
396
396
  const added = e.added as HTMLElement[];
397
397
  const removed = e.removed as HTMLElement[];
398
398
  const selected = e.selected as HTMLElement[];
399
-
399
+
400
400
  const isClick = inputEvent.type === 'mousedown';
401
401
  let newActiveElements: HTMLElement[] = isClick ? selected : [];
402
-
402
+
403
403
  if (!isClick && added.length > 0) {
404
404
  newActiveElements = activeElements.concat(added);
405
405
  }
@@ -411,7 +411,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
411
411
  if (newActiveElements != activeElements) {
412
412
  setEditing(false);
413
413
  }
414
-
414
+
415
415
  // For MacOS CMD+SHIFT+3/4 screenshots where the keydown event is never received, check mouse too
416
416
  const mouseEvent = inputEvent as MouseEvent;
417
417
  if (mouseEvent && typeof mouseEvent.shiftKey === 'boolean' && !mouseEvent.shiftKey) {
@@ -517,7 +517,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
517
517
  onChange={(arg) => {
518
518
  // Use type assertion to safely handle the argument
519
519
  type ChangeArg = { key: string; value: unknown };
520
- const args = Array.isArray(arg) ? arg as ChangeArg[] : [arg as ChangeArg];
520
+ const args = Array.isArray(arg) ? (arg as ChangeArg[]) : [arg as ChangeArg];
521
521
  changeSchemas(args.map(({ key, value }) => ({ key, value, schemaId: schema.id })));
522
522
  }}
523
523
  stopEditing={() => setEditing(false)}
@@ -38,17 +38,18 @@ const PluginIcon = (props: PluginIconProps) => {
38
38
  const { plugin, label, size, styles } = props;
39
39
  const { token } = theme.useToken();
40
40
  const options = useContext(OptionsContext);
41
-
41
+
42
42
  // Safely access plugin properties with proper type checking
43
- const defaultSchemaType = plugin.propPanel &&
44
- typeof plugin.propPanel === 'object' &&
45
- plugin.propPanel.defaultSchema &&
46
- typeof plugin.propPanel.defaultSchema === 'object' &&
47
- 'type' in plugin.propPanel.defaultSchema &&
48
- typeof plugin.propPanel.defaultSchema.type === 'string'
49
- ? plugin.propPanel.defaultSchema.type
43
+ const defaultSchemaType =
44
+ plugin.propPanel &&
45
+ typeof plugin.propPanel === 'object' &&
46
+ plugin.propPanel.defaultSchema &&
47
+ typeof plugin.propPanel.defaultSchema === 'object' &&
48
+ 'type' in plugin.propPanel.defaultSchema &&
49
+ typeof plugin.propPanel.defaultSchema.type === 'string'
50
+ ? plugin.propPanel.defaultSchema.type
50
51
  : '';
51
-
52
+
52
53
  const icon = options.icons?.[defaultSchemaType] ?? plugin.icon;
53
54
  const iconStyles = {
54
55
  ...styles,