@enerex/template-studio 1.1.13 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
- import { jsx as s, jsxs as h } from "react/jsx-runtime";
2
- import _, { useContext as te, useState as T, useEffect as k } from "react";
1
+ import { jsx as s, jsxs as b } from "react/jsx-runtime";
2
+ import $, { useContext as te, useState as x, useEffect as k } from "react";
3
3
  import { QueryClient as pe, QueryClientProvider as me, useQuery as j, useMutation as ne, useQueryClient as ue } from "@tanstack/react-query";
4
4
  import V from "axios";
5
- import { Spinner as U, Form as C, ListGroup as K, Popover as W, OverlayTrigger as ge, Card as Q, Button as Y, Row as fe, Col as X } from "react-bootstrap";
5
+ import { Spinner as U, Form as I, ListGroup as K, Popover as W, OverlayTrigger as ge, Card as Q, Button as Y, Row as fe, Col as X } from "react-bootstrap";
6
6
  import { Controller as ye, useForm as he } from "react-hook-form";
7
7
  import J from "react-select";
8
- const re = _.createContext(
8
+ const re = $.createContext(
9
9
  void 0
10
10
  ), be = ({
11
11
  children: t,
12
12
  configs: r
13
13
  }) => {
14
- const [i, a] = _.useState(r.clientId), [n, e] = _.useState(r.apiKey), [o, l] = _.useState(
14
+ const [i, a] = $.useState(r.clientId), [n, e] = $.useState(r.apiKey), [o, l] = $.useState(
15
15
  r.enerexIdentifier
16
- ), [p, u] = _.useState(r.projectId), g = (m) => {
17
- e(m.apiKey), a(m.clientId), u(m.projectId), l(m.enerexIdentifier);
16
+ ), [p, m] = $.useState(r.projectId), u = (h) => {
17
+ e(h.apiKey), a(h.clientId), m(h.projectId), l(h.enerexIdentifier);
18
18
  };
19
19
  return /* @__PURE__ */ s(
20
20
  re.Provider,
@@ -22,14 +22,14 @@ const re = _.createContext(
22
22
  value: {
23
23
  clientId: i,
24
24
  apiKey: n,
25
- setConfiguration: g,
25
+ setConfiguration: u,
26
26
  enerexIdentifier: o,
27
27
  projectId: p
28
28
  },
29
29
  children: t
30
30
  }
31
31
  );
32
- }, x = () => {
32
+ }, w = () => {
33
33
  const t = te(re);
34
34
  if (!t)
35
35
  throw new Error("widgetConfig must be used within a ConfigProvider");
@@ -420,7 +420,7 @@ const re = _.createContext(
420
420
  API_BASE_URL: "https://dev-socket.enerex.com/common/api"
421
421
  //API_BASE_URL: "https://localhost:44338/api",
422
422
  // more env variables...
423
- }, ie = _.createContext({
423
+ }, ie = $.createContext({
424
424
  get: () => {
425
425
  throw new Error("HttpClientContext.get not implemented");
426
426
  },
@@ -428,7 +428,7 @@ const re = _.createContext(
428
428
  throw new Error("HttpClientContext.post not implemented");
429
429
  }
430
430
  }), we = ({ children: t }) => {
431
- const { clientId: r, apiKey: i } = x(), a = {
431
+ const { clientId: r, apiKey: i } = w(), a = {
432
432
  headers: {
433
433
  client_id: r,
434
434
  "x-api-key": i
@@ -454,7 +454,7 @@ const re = _.createContext(
454
454
  if (t)
455
455
  return t;
456
456
  throw new Error("useHttpClient must be used within a HttpClientProvider");
457
- }, $ = {
457
+ }, A = {
458
458
  Template_list: "/Template/list/",
459
459
  Template: "/Template/GetTemplate/",
460
460
  MergeTags: "/Template/TemplateMergeTags/",
@@ -462,19 +462,19 @@ const re = _.createContext(
462
462
  SaveTemplate: "/Template/save-update/",
463
463
  TemplateTypes: "/Template/TemplateTypes/"
464
464
  }, Ce = () => {
465
- const t = P(), { enerexIdentifier: r, projectId: i } = x();
465
+ const t = P(), { enerexIdentifier: r, projectId: i } = w();
466
466
  return j({
467
467
  queryKey: ["getTemplateTags"],
468
468
  queryFn: async (n) => await t.get(
469
- `${$.MergeTags}${i}/${r}`
469
+ `${A.MergeTags}${i}/${r}`
470
470
  )
471
471
  });
472
472
  }, xe = () => {
473
- const t = P(), { enerexIdentifier: r, projectId: i } = x();
473
+ const t = P(), { enerexIdentifier: r, projectId: i } = w();
474
474
  return j({
475
475
  queryKey: ["getExcludeCategory"],
476
476
  queryFn: async (n) => await t.get(
477
- `${$.ExcludeCategory}${i}/${r}`
477
+ `${A.ExcludeCategory}${i}/${r}`
478
478
  )
479
479
  });
480
480
  }, Ie = ({
@@ -482,16 +482,16 @@ const re = _.createContext(
482
482
  className: r = "",
483
483
  loading: i = !1
484
484
  }) => {
485
- const { post: a } = se(), { data: n } = Ce(), { data: e } = xe(), [o, l] = T(
485
+ const { post: a } = se(), { data: n } = Ce(), { data: e } = xe(), [o, l] = x(
486
486
  t ?? { html: H, css: "" }
487
- ), p = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", u = "https://plugins.stripo.email/api/v1/auth";
487
+ ), { enerexIdentifier: p, projectId: m } = w(), u = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", h = "https://plugins.stripo.email/api/v1/auth";
488
488
  k(() => {
489
489
  if (n && e && !document.getElementById("UiEditorScript")) {
490
- const m = document.createElement("script");
491
- m.id = "UiEditorScript", m.type = "module", m.src = q.EDITOR_SCRIPT_URL, m.onload = g, document.body.appendChild(m);
490
+ const g = document.createElement("script");
491
+ g.id = "UiEditorScript", g.type = "module", g.src = q.EDITOR_SCRIPT_URL, g.onload = v, document.body.appendChild(g);
492
492
  }
493
493
  }, [n, e]);
494
- const g = async () => {
494
+ const v = async () => {
495
495
  window.UIEditor.initEditor(
496
496
  document.querySelector("#stripoEditorContainer"),
497
497
  {
@@ -500,20 +500,20 @@ const re = _.createContext(
500
500
  modulesExcludedCategories: e ?? [],
501
501
  forceRecreate: !0,
502
502
  metadata: {
503
- emailId: `plugin_${q.EDITOR_PLUGIN_ID}_demo_1`,
503
+ emailId: `plugin_${q.EDITOR_PLUGIN_ID}_demo_1_${m}_${p}`,
504
504
  userId: "1",
505
505
  username: "Plugin Demo User",
506
- avatarUrl: p
506
+ avatarUrl: u
507
507
  },
508
508
  locale: "en",
509
- onTokenRefreshRequest: async function(m) {
510
- const b = {
509
+ onTokenRefreshRequest: async function(g) {
510
+ const T = {
511
511
  pluginId: q.EDITOR_PLUGIN_ID,
512
512
  secretKey: q.EDITOR_SECRET_KEY,
513
513
  userId: "12",
514
514
  role: "user"
515
- }, w = await a(u, b);
516
- w && m(w.token);
515
+ }, c = await a(h, T);
516
+ c && g(c.token);
517
517
  },
518
518
  codeEditorButtonSelector: "#codeEditor",
519
519
  undoButtonSelector: "#undoButton",
@@ -524,7 +524,7 @@ const re = _.createContext(
524
524
  }
525
525
  );
526
526
  };
527
- return /* @__PURE__ */ s("div", { className: "position-relative", children: /* @__PURE__ */ h("div", { className: `editor-container ${r}`, children: [
527
+ return /* @__PURE__ */ s("div", { className: "position-relative", children: /* @__PURE__ */ b("div", { className: `editor-container ${r}`, children: [
528
528
  i && /* @__PURE__ */ s("div", { className: "loading-overlay", children: /* @__PURE__ */ s(
529
529
  U,
530
530
  {
@@ -546,13 +546,13 @@ const re = _.createContext(
546
546
  name: n,
547
547
  error: e,
548
548
  ...o
549
- }) => /* @__PURE__ */ h(C.Group, { className: "mb-1", children: [
550
- t ? /* @__PURE__ */ h(C.Label, { className: "mb-3 d-block form-label", children: [
549
+ }) => /* @__PURE__ */ b(I.Group, { className: "mb-1", children: [
550
+ t ? /* @__PURE__ */ b(I.Label, { className: "mb-3 d-block form-label", children: [
551
551
  t,
552
552
  a && /* @__PURE__ */ s("label", { className: "text-danger", children: "*" })
553
553
  ] }) : null,
554
554
  /* @__PURE__ */ s(
555
- C.Control,
555
+ I.Control,
556
556
  {
557
557
  name: n,
558
558
  type: "text",
@@ -564,7 +564,7 @@ const re = _.createContext(
564
564
  className: `form-control ${e && e[n] && "border border-danger"}`
565
565
  }
566
566
  ),
567
- e && e[n] ? /* @__PURE__ */ s(C.Control.Feedback, { type: "invalid", children: e[n].message }) : null
567
+ e && e[n] ? /* @__PURE__ */ s(I.Control.Feedback, { type: "invalid", children: e[n].message }) : null
568
568
  ] });
569
569
  function Ne({
570
570
  items: t,
@@ -608,7 +608,7 @@ const Se = (t) => /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg"
608
608
  onCopy: n,
609
609
  onSelect: e,
610
610
  subItem: o = !1
611
- }) => /* @__PURE__ */ h(
611
+ }) => /* @__PURE__ */ b(
612
612
  "div",
613
613
  {
614
614
  className: "ps-1 py-1 d-flex position-relative",
@@ -651,15 +651,15 @@ const Se = (t) => /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg"
651
651
  ) })
652
652
  ]
653
653
  }
654
- ), Pe = () => {
655
- const t = P(), { enerexIdentifier: r, projectId: i } = x();
654
+ ), $e = () => {
655
+ const t = P(), { enerexIdentifier: r, projectId: i } = w();
656
656
  return j({
657
657
  queryKey: ["getTemplatesList"],
658
658
  queryFn: async (n) => await t.get(
659
- `${$.Template_list}${i}/${r}`
659
+ `${A.Template_list}${i}/${r}`
660
660
  )
661
661
  });
662
- }, $e = (t, r = []) => {
662
+ }, Pe = (t, r = []) => {
663
663
  const i = /^(?:\(copy(?:-(\d+))?\)\s)?(.+)$/, a = t.match(i);
664
664
  if (!a) return `(copy) ${t}`;
665
665
  const n = a[2], e = new RegExp(
@@ -671,30 +671,30 @@ const Se = (t) => /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg"
671
671
  let o = 1;
672
672
  const l = r.filter((p) => e.test(p));
673
673
  return l.length === 0 ? `(copy) ${n}` : (l.forEach((p) => {
674
- const u = p.match(e);
675
- if (u && u[1]) {
676
- const g = parseInt(u[1], 10);
677
- !isNaN(g) && g >= o && (o = g + 1);
674
+ const m = p.match(e);
675
+ if (m && m[1]) {
676
+ const u = parseInt(m[1], 10);
677
+ !isNaN(u) && u >= o && (o = u + 1);
678
678
  } else
679
679
  o = Math.max(o, 2);
680
680
  }), `(copy-${o}) ${n}`);
681
681
  }, Ae = () => {
682
- const t = P(), { enerexIdentifier: r, projectId: i } = x();
682
+ const t = P(), { enerexIdentifier: r, projectId: i } = w();
683
683
  return ne({
684
684
  mutationKey: ["getTemplate"],
685
685
  mutationFn: async ({ id: n }) => {
686
686
  if (n)
687
687
  return await t.get(
688
- `${$.Template}${r}/${n}/${i}`
688
+ `${A.Template}${r}/${n}/${i}`
689
689
  );
690
690
  }
691
691
  });
692
692
  }, Re = () => {
693
- const t = P(), { enerexIdentifier: r, projectId: i } = x();
693
+ const t = P(), { enerexIdentifier: r, projectId: i } = w();
694
694
  return j({
695
695
  queryKey: ["getTemplateTypes"],
696
696
  queryFn: async (n) => await t.get(
697
- `${$.TemplateTypes}${r}/${i}`
697
+ `${A.TemplateTypes}${r}/${i}`
698
698
  )
699
699
  });
700
700
  };
@@ -751,13 +751,13 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
751
751
  labelKey: o = "name",
752
752
  disabled: l,
753
753
  isInvalid: p,
754
- value: u,
755
- onChange: g,
756
- uncontrolled: m,
757
- menuPlacement: b = "auto",
758
- closeOnSelect: w = !0
754
+ value: m,
755
+ onChange: u,
756
+ uncontrolled: h,
757
+ menuPlacement: v = "auto",
758
+ closeOnSelect: g = !0
759
759
  }) => {
760
- const A = {
760
+ const T = {
761
761
  control: (c) => ({
762
762
  ...c,
763
763
  minHeight: "33px",
@@ -795,25 +795,25 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
795
795
  display: l ? "none" : "block"
796
796
  })
797
797
  };
798
- return m ? /* @__PURE__ */ s(
798
+ return h ? /* @__PURE__ */ s(
799
799
  J,
800
800
  {
801
801
  className: ee({
802
802
  "is-invalid": p
803
803
  }),
804
- styles: A,
804
+ styles: T,
805
805
  classNamePrefix: "react-select",
806
806
  isMulti: a,
807
807
  options: i,
808
- onChange: g,
808
+ onChange: u,
809
809
  placeholder: n,
810
810
  menuPortalTarget: document.body,
811
- value: u,
811
+ value: m,
812
812
  getOptionLabel: typeof o == "string" ? (c) => c[o] : o,
813
813
  getOptionValue: (c) => c.id,
814
814
  isDisabled: l,
815
- menuPlacement: b,
816
- closeMenuOnSelect: w
815
+ menuPlacement: v,
816
+ closeMenuOnSelect: g
817
817
  }
818
818
  ) : /* @__PURE__ */ s(
819
819
  ye,
@@ -821,13 +821,13 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
821
821
  control: r,
822
822
  name: t,
823
823
  rules: e,
824
- render: ({ field: { onChange: c, value: v, onBlur: R } }) => /* @__PURE__ */ s(
824
+ render: ({ field: { onChange: c, value: C, onBlur: R } }) => /* @__PURE__ */ s(
825
825
  J,
826
826
  {
827
827
  className: ee({
828
828
  "is-invalid": p
829
829
  }),
830
- styles: A,
830
+ styles: T,
831
831
  classNamePrefix: "react-select",
832
832
  isMulti: a,
833
833
  options: i,
@@ -835,14 +835,14 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
835
835
  onChange: c,
836
836
  placeholder: n,
837
837
  menuPortalTarget: document.body,
838
- value: v,
839
- getOptionLabel: typeof o == "string" ? (I) => I[o] : o,
840
- getOptionValue: (I) => I.id,
838
+ value: C,
839
+ getOptionLabel: typeof o == "string" ? (E) => E[o] : o,
840
+ getOptionValue: (E) => E.id,
841
841
  isDisabled: l,
842
- menuPlacement: b,
843
- closeMenuOnSelect: w
842
+ menuPlacement: v,
843
+ closeMenuOnSelect: g
844
844
  },
845
- v ? JSON.stringify(v) : "reset"
845
+ C ? JSON.stringify(C) : "reset"
846
846
  )
847
847
  }
848
848
  );
@@ -853,8 +853,8 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
853
853
  control: a,
854
854
  error: n,
855
855
  ...e
856
- }) => /* @__PURE__ */ h(C.Group, { className: "mb-1", children: [
857
- t && /* @__PURE__ */ h(C.Label, { className: "mb-3 d-block form-label", children: [
856
+ }) => /* @__PURE__ */ b(I.Group, { className: "mb-1", children: [
857
+ t && /* @__PURE__ */ b(I.Label, { className: "mb-3 d-block form-label", children: [
858
858
  t,
859
859
  " ",
860
860
  e.required && /* @__PURE__ */ s("span", { className: "text-danger", children: "*" })
@@ -869,15 +869,15 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
869
869
  name: r
870
870
  }
871
871
  ),
872
- n && n[r] ? /* @__PURE__ */ s(C.Control.Feedback, { type: "invalid", children: n[r].message }) : null
872
+ n && n[r] ? /* @__PURE__ */ s(I.Control.Feedback, { type: "invalid", children: n[r].message }) : null
873
873
  ] }), Be = () => {
874
874
  const t = P();
875
875
  ue();
876
- const { enerexIdentifier: r, projectId: i } = x();
876
+ const { enerexIdentifier: r, projectId: i } = w();
877
877
  return ne({
878
878
  mutationKey: ["saveTemplate"],
879
879
  mutationFn: async (n) => (n.enerexIdentifier = r ?? "", n.projectId = i ?? "", await t.post(
880
- `${$.SaveTemplate}`,
880
+ `${A.SaveTemplate}`,
881
881
  n
882
882
  ))
883
883
  });
@@ -893,7 +893,7 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
893
893
  setValue: o,
894
894
  control: l,
895
895
  reset: p,
896
- formState: { errors: u }
896
+ formState: { errors: m }
897
897
  } = he({
898
898
  defaultValues: {
899
899
  templateName: "",
@@ -901,10 +901,10 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
901
901
  },
902
902
  mode: "onChange"
903
903
  }), {
904
- data: g,
905
- refetch: m,
906
- isLoading: b
907
- } = Pe(), [w, A] = T([]), [c, v] = T(), [R, I] = T(), { mutateAsync: F, isPending: E } = Ae(), { mutateAsync: oe, isPending: O } = Be(), { data: D, isLoading: z } = Re(), [B, ae] = T([]);
904
+ data: u,
905
+ refetch: h,
906
+ isLoading: v
907
+ } = $e(), [g, T] = x([]), [c, C] = x(), [R, E] = x(), { mutateAsync: F, isPending: N } = Ae(), { mutateAsync: oe, isPending: O } = Be(), { data: D, isLoading: z } = Re(), [B, ae] = x([]);
908
908
  k(() => {
909
909
  D && ae(
910
910
  D.map((d) => ({
@@ -913,33 +913,33 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
913
913
  }))
914
914
  );
915
915
  }, [D]), k(() => {
916
- r(!!E);
917
- }, [E]), k(() => {
918
- A(g ?? []);
919
- }, [g]);
916
+ r(!!N);
917
+ }, [N]), k(() => {
918
+ T(u ?? []);
919
+ }, [u]);
920
920
  const le = async (d, f) => {
921
- f && A((y) => {
922
- const N = [...y], S = { ...f };
923
- S.id = "", S.name = $e(
924
- S.name,
925
- N.map((L) => L.name)
926
- ), N.splice(d + 1, 0, S), v(S), o("templateName", S.name);
927
- const G = B.find((L) => L.id === `${f.type}`);
928
- return G ? o("templateType", G) : o("templateType", void 0), e(), F({ id: f?.id }).then((L) => {
929
- L && I(L);
930
- }), N;
921
+ f && T((y) => {
922
+ const S = [...y], L = { ...f };
923
+ L.id = "", L.name = Pe(
924
+ L.name,
925
+ S.map((_) => _.name)
926
+ ), S.splice(d + 1, 0, L), C(L), o("templateName", L.name);
927
+ const G = B.find((_) => _.id === `${f.type}`);
928
+ return G ? o("templateType", G) : o("templateType", void 0), e(), F({ id: f?.id }).then((_) => {
929
+ _ && E(_);
930
+ }), S;
931
931
  });
932
932
  }, ce = async (d) => {
933
- if (v(d), d) {
933
+ if (C(d), d) {
934
934
  if (o("templateName", d?.name), D && D.find((y) => y.id === d.type)) {
935
- const y = B.find((N) => N.id === `${d.type}`);
935
+ const y = B.find((S) => S.id === `${d.type}`);
936
936
  y && o("templateType", y);
937
937
  } else
938
938
  o("templateType", void 0);
939
939
  e();
940
940
  }
941
941
  const f = await F({ id: d?.id });
942
- f && I(f);
942
+ f && E(f);
943
943
  };
944
944
  k(() => {
945
945
  t(R && c ? R : void 0);
@@ -956,16 +956,16 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
956
956
  html: f.html,
957
957
  css: f.css
958
958
  };
959
- await oe(y) && (e(), c?.id === "" && p(), m());
959
+ await oe(y) && (e(), c?.id === "" && p(), h());
960
960
  }
961
961
  );
962
962
  };
963
- return /* @__PURE__ */ s(Q, { className: "border border-0 text-start", children: /* @__PURE__ */ s(Q.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ h("form", { onSubmit: n(de), children: [
963
+ return /* @__PURE__ */ s(Q, { className: "border border-0 text-start", children: /* @__PURE__ */ s(Q.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ b("form", { onSubmit: n(de), children: [
964
964
  /* @__PURE__ */ s("label", { className: "mb-2", children: "Templates" }),
965
965
  /* @__PURE__ */ s("div", { className: "template-list-container mb-3", children: /* @__PURE__ */ s(
966
966
  Ne,
967
967
  {
968
- items: w,
968
+ items: g,
969
969
  renderItem: (d, f) => /* @__PURE__ */ s(
970
970
  _e,
971
971
  {
@@ -985,7 +985,7 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
985
985
  {
986
986
  label: "Template Type",
987
987
  control: l,
988
- error: u,
988
+ error: m,
989
989
  options: B,
990
990
  required: !0,
991
991
  validation: {
@@ -999,7 +999,7 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
999
999
  {
1000
1000
  label: "Template Name",
1001
1001
  register: a,
1002
- error: u,
1002
+ error: m,
1003
1003
  required: !0,
1004
1004
  name: "templateName",
1005
1005
  validation: {
@@ -1008,17 +1008,17 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
1008
1008
  }
1009
1009
  ),
1010
1010
  /* @__PURE__ */ s("hr", {}),
1011
- /* @__PURE__ */ h("div", { className: "d-flex justify-content-between mt-3 ", children: [
1011
+ /* @__PURE__ */ b("div", { className: "d-flex justify-content-between mt-3 ", children: [
1012
1012
  /* @__PURE__ */ s(
1013
1013
  Y,
1014
1014
  {
1015
1015
  style: { width: "70px" },
1016
1016
  variant: "primary",
1017
- disabled: b || E || O || z,
1017
+ disabled: v || N || O || z,
1018
1018
  onClick: () => {
1019
- v(void 0), p(), i();
1019
+ C(void 0), p(), i();
1020
1020
  },
1021
- children: E || O ? /* @__PURE__ */ s(
1021
+ children: N || O ? /* @__PURE__ */ s(
1022
1022
  U,
1023
1023
  {
1024
1024
  animation: "border",
@@ -1037,8 +1037,8 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
1037
1037
  type: "submit",
1038
1038
  variant: "primary",
1039
1039
  style: { width: "80px" },
1040
- disabled: b || E || O || z,
1041
- children: E || O ? /* @__PURE__ */ s(
1040
+ disabled: v || N || O || z,
1041
+ children: N || O ? /* @__PURE__ */ s(
1042
1042
  U,
1043
1043
  {
1044
1044
  animation: "border",
@@ -1054,8 +1054,8 @@ const ee = /* @__PURE__ */ De(qe), Oe = ({
1054
1054
  ] })
1055
1055
  ] }) }) });
1056
1056
  }, We = ({ config: t }) => {
1057
- const [r, i] = T(), [a, n] = T(!1);
1058
- return /* @__PURE__ */ s(be, { configs: t, children: /* @__PURE__ */ s(ve, { children: /* @__PURE__ */ s("div", { className: "root-widget", children: /* @__PURE__ */ h(fe, { children: [
1057
+ const [r, i] = x(), [a, n] = x(!1);
1058
+ return /* @__PURE__ */ s(be, { configs: t, children: /* @__PURE__ */ s(ve, { children: /* @__PURE__ */ s("div", { className: "root-widget", children: /* @__PURE__ */ b(fe, { children: [
1059
1059
  /* @__PURE__ */ s(X, { md: 3, lg: 2, className: "p-0", children: /* @__PURE__ */ s(
1060
1060
  Me,
1061
1061
  {
@@ -1,4 +1,4 @@
1
- (function(g,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("react"),require("@tanstack/react-query"),require("axios"),require("react-bootstrap"),require("react-hook-form"),require("react-select")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tanstack/react-query","axios","react-bootstrap","react-hook-form","react-select"],t):(g=typeof globalThis<"u"?globalThis:g||self,t(g.EnerexTemplateEditor={},g.jsxRuntime,g.React,g.reactQuery,g.axios,g.reactBootstrap,g.reactHookForm,g.Select$1))})(this,function(g,t,c,v,U,d,H,z){"use strict";const G=c.createContext(void 0),Q=({children:n,configs:s})=>{const[i,l]=c.useState(s.clientId),[r,e]=c.useState(s.apiKey),[o,a]=c.useState(s.enerexIdentifier),[f,y]=c.useState(s.projectId),h=u=>{e(u.apiKey),l(u.clientId),y(u.projectId),a(u.enerexIdentifier)};return t.jsx(G.Provider,{value:{clientId:i,apiKey:r,setConfiguration:h,enerexIdentifier:o,projectId:f},children:n})},T=()=>{const n=c.useContext(G);if(!n)throw new Error("widgetConfig must be used within a ConfigProvider");return n},O=`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
1
+ (function(u,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("react"),require("@tanstack/react-query"),require("axios"),require("react-bootstrap"),require("react-hook-form"),require("react-select")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tanstack/react-query","axios","react-bootstrap","react-hook-form","react-select"],t):(u=typeof globalThis<"u"?globalThis:u||self,t(u.EnerexTemplateEditor={},u.jsxRuntime,u.React,u.reactQuery,u.axios,u.reactBootstrap,u.reactHookForm,u.Select$1))})(this,function(u,t,p,T,U,c,H,z){"use strict";const G=p.createContext(void 0),Q=({children:n,configs:s})=>{const[i,l]=p.useState(s.clientId),[r,e]=p.useState(s.apiKey),[o,a]=p.useState(s.enerexIdentifier),[f,g]=p.useState(s.projectId),y=v=>{e(v.apiKey),l(v.clientId),g(v.projectId),a(v.enerexIdentifier)};return t.jsx(G.Provider,{value:{clientId:i,apiKey:r,setConfiguration:y,enerexIdentifier:o,projectId:f},children:n})},C=()=>{const n=p.useContext(G);if(!n)throw new Error("widgetConfig must be used within a ConfigProvider");return n},O=`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
2
2
  <html\r
3
3
  dir="ltr"\r
4
4
  xmlns:o="urn:schemas-microsoft-com:office:office"\r
@@ -354,8 +354,8 @@
354
354
  </div>\r
355
355
  </body>\r
356
356
  </html>\r
357
- `,V=(n="",s)=>({get:async(r,e)=>{try{const o=await U.get(`${n}${r}`,e??s);if(o.status===200)return o.data}catch(o){throw o}},post:async(r,e,o)=>{try{const a=await U.post(`${n}${r}`,e,o??s);if(a.status===200)return a.data}catch(a){throw a}}}),q={EDITOR_SCRIPT_URL:"https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",EDITOR_PLUGIN_ID:"1afdc3161ec7409a8627a1c8561d45f5",EDITOR_SECRET_KEY:"54ba748ed7e94f2e929555783acb03da",API_BASE_URL:"https://dev-socket.enerex.com/common/api"},K=c.createContext({get:()=>{throw new Error("HttpClientContext.get not implemented")},post:()=>{throw new Error("HttpClientContext.post not implemented")}}),Z=({children:n})=>{const{clientId:s,apiKey:i}=T(),l={headers:{client_id:s,"x-api-key":i}},{get:r,post:e}=V(q.API_BASE_URL,l);return t.jsx(K.Provider,{value:{get:r,post:e},children:n})},R=({children:n})=>{const s=new v.QueryClient;return t.jsx(Z,{children:t.jsx(v.QueryClientProvider,{client:s,children:n})})},ee=n=>{const s=Array.from(new Set(n.map(l=>l.category))),i=[];return s.forEach(l=>{const r=n.filter(e=>e.category===l).map(e=>({label:e.label,value:e.value,hint:e.hint,hidden:e.hidden}));i.push({category:l,entries:r})}),i},E=()=>{const n=c.useContext(K);if(n)return n;throw new Error("useHttpClient must be used within a HttpClientProvider")},S={Template_list:"/Template/list/",Template:"/Template/GetTemplate/",MergeTags:"/Template/TemplateMergeTags/",ExcludeCategory:"/Template/GetExcludeCategories/",SaveTemplate:"/Template/save-update/",TemplateTypes:"/Template/TemplateTypes/"},te=()=>{const n=E(),{enerexIdentifier:s,projectId:i}=T();return v.useQuery({queryKey:["getTemplateTags"],queryFn:async r=>await n.get(`${S.MergeTags}${i}/${s}`)})},ne=()=>{const n=E(),{enerexIdentifier:s,projectId:i}=T();return v.useQuery({queryKey:["getExcludeCategory"],queryFn:async r=>await n.get(`${S.ExcludeCategory}${i}/${s}`)})},re=({templateHTML:n,className:s="",loading:i=!1})=>{const{post:l}=V(),{data:r}=te(),{data:e}=ne(),[o,a]=c.useState(n??{html:O,css:""}),f="https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png",y="https://plugins.stripo.email/api/v1/auth";c.useEffect(()=>{if(r&&e&&!document.getElementById("UiEditorScript")){const u=document.createElement("script");u.id="UiEditorScript",u.type="module",u.src=q.EDITOR_SCRIPT_URL,u.onload=h,document.body.appendChild(u)}},[r,e]);const h=async()=>{window.UIEditor.initEditor(document.querySelector("#stripoEditorContainer"),{html:o.html,css:o.css,modulesExcludedCategories:e??[],forceRecreate:!0,metadata:{emailId:`plugin_${q.EDITOR_PLUGIN_ID}_demo_1`,userId:"1",username:"Plugin Demo User",avatarUrl:f},locale:"en",onTokenRefreshRequest:async function(u){const C={pluginId:q.EDITOR_PLUGIN_ID,secretKey:q.EDITOR_SECRET_KEY,userId:"12",role:"user"},x=await l(y,C);x&&u(x.token)},codeEditorButtonSelector:"#codeEditor",undoButtonSelector:"#undoButton",redoButtonSelector:"#redoButton",mobileViewButtonSelector:"#mobileViewButton",desktopViewButtonSelector:"#desktopViewButton",mergeTags:ee(r??[])})};return t.jsx("div",{className:"position-relative",children:t.jsxs("div",{className:`editor-container ${s}`,children:[i&&t.jsx("div",{className:"loading-overlay",children:t.jsx(d.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1"})}),t.jsx("div",{id:"externalSystemContainer"}),t.jsx("div",{id:"stripoEditorContainer"})]})})},se=({label:n,register:s,validation:i,required:l=!1,name:r,error:e,...o})=>t.jsxs(d.Form.Group,{className:"mb-1",children:[n?t.jsxs(d.Form.Label,{className:"mb-3 d-block form-label",children:[n,l&&t.jsx("label",{className:"text-danger",children:"*"})]}):null,t.jsx(d.Form.Control,{name:r,type:"text",...o,isInvalid:!!(e&&e[r]),...s?s(r,{...i}):{},className:`form-control ${e&&e[r]&&"border border-danger"}`}),e&&e[r]?t.jsx(d.Form.Control.Feedback,{type:"invalid",children:e[r].message}):null]});function oe({items:n,renderItem:s,className:i="",keyExtractor:l}){return t.jsx(d.ListGroup,{className:` ${i}`,children:n.map((r,e)=>t.jsx(d.ListGroup.Item,{children:s(r,e)},l?l(r,e):e))})}const ie=n=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",...n,children:t.jsx("path",{d:"M352 528L128 528C119.2 528 112 520.8 112 512L112 288C112 279.2 119.2 272 128 272L176 272L176 224L128 224C92.7 224 64 252.7 64 288L64 512C64 547.3 92.7 576 128 576L352 576C387.3 576 416 547.3 416 512L416 464L368 464L368 512C368 520.8 360.8 528 352 528zM288 368C279.2 368 272 360.8 272 352L272 128C272 119.2 279.2 112 288 112L512 112C520.8 112 528 119.2 528 128L528 352C528 360.8 520.8 368 512 368L288 368zM224 352C224 387.3 252.7 416 288 416L512 416C547.3 416 576 387.3 576 352L576 128C576 92.7 547.3 64 512 64L288 64C252.7 64 224 92.7 224 128L224 352z"})}),le=({children:n,title:s,placement:i})=>{const l=t.jsx(d.Popover,{id:"popover-basic",className:"dark-popover",children:t.jsx(d.Popover.Body,{className:"p-0 text-white",children:s})});return t.jsx(d.OverlayTrigger,{trigger:["hover","focus"],placement:i,overlay:l,containerPadding:0,container:document.body,popperConfig:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",enabled:!0,options:{boundary:"window"}}]},children:n})},ae=({selected:n,group:s,value:i,label:l,onCopy:r,onSelect:e,subItem:o=!1})=>t.jsxs("div",{className:"ps-1 py-1 d-flex position-relative",style:{alignItems:"center"},children:[t.jsx("input",{type:"radio",onChange:()=>{e(i)},className:"me-2",checked:n,name:s}),t.jsx("p",{title:l,className:"mb-0 wraped-text",children:l}),!o&&t.jsx(le,{title:"Copy",placement:"top",children:t.jsx("button",{className:"btn btn-link",type:"button",style:{padding:0,marginLeft:"auto",position:"relative",minWidth:32,flexShrink:0},children:t.jsx(ie,{onClick:()=>r(i),height:20,fill:"black"})})})]}),de=()=>{const n=E(),{enerexIdentifier:s,projectId:i}=T();return v.useQuery({queryKey:["getTemplatesList"],queryFn:async r=>await n.get(`${S.Template_list}${i}/${s}`)})},ce=(n,s=[])=>{const i=/^(?:\(copy(?:-(\d+))?\)\s)?(.+)$/,l=n.match(i);if(!l)return`(copy) ${n}`;const r=l[2],e=new RegExp(`^\\(copy(?:-(\\d+))?\\) ${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`);let o=1;const a=s.filter(f=>e.test(f));return a.length===0?`(copy) ${r}`:(a.forEach(f=>{const y=f.match(e);if(y&&y[1]){const h=parseInt(y[1],10);!isNaN(h)&&h>=o&&(o=h+1)}else o=Math.max(o,2)}),`(copy-${o}) ${r}`)},pe=()=>{const n=E(),{enerexIdentifier:s,projectId:i}=T();return v.useMutation({mutationKey:["getTemplate"],mutationFn:async({id:r})=>{if(r)return await n.get(`${S.Template}${s}/${r}/${i}`)}})},me=()=>{const n=E(),{enerexIdentifier:s,projectId:i}=T();return v.useQuery({queryKey:["getTemplateTypes"],queryFn:async r=>await n.get(`${S.TemplateTypes}${s}/${i}`)})};function fe(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var M={exports:{}};/*!
357
+ `,V=(n="",s)=>({get:async(r,e)=>{try{const o=await U.get(`${n}${r}`,e??s);if(o.status===200)return o.data}catch(o){throw o}},post:async(r,e,o)=>{try{const a=await U.post(`${n}${r}`,e,o??s);if(a.status===200)return a.data}catch(a){throw a}}}),A={EDITOR_SCRIPT_URL:"https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",EDITOR_PLUGIN_ID:"1afdc3161ec7409a8627a1c8561d45f5",EDITOR_SECRET_KEY:"54ba748ed7e94f2e929555783acb03da",API_BASE_URL:"https://dev-socket.enerex.com/common/api"},K=p.createContext({get:()=>{throw new Error("HttpClientContext.get not implemented")},post:()=>{throw new Error("HttpClientContext.post not implemented")}}),Z=({children:n})=>{const{clientId:s,apiKey:i}=C(),l={headers:{client_id:s,"x-api-key":i}},{get:r,post:e}=V(A.API_BASE_URL,l);return t.jsx(K.Provider,{value:{get:r,post:e},children:n})},R=({children:n})=>{const s=new T.QueryClient;return t.jsx(Z,{children:t.jsx(T.QueryClientProvider,{client:s,children:n})})},ee=n=>{const s=Array.from(new Set(n.map(l=>l.category))),i=[];return s.forEach(l=>{const r=n.filter(e=>e.category===l).map(e=>({label:e.label,value:e.value,hint:e.hint,hidden:e.hidden}));i.push({category:l,entries:r})}),i},S=()=>{const n=p.useContext(K);if(n)return n;throw new Error("useHttpClient must be used within a HttpClientProvider")},N={Template_list:"/Template/list/",Template:"/Template/GetTemplate/",MergeTags:"/Template/TemplateMergeTags/",ExcludeCategory:"/Template/GetExcludeCategories/",SaveTemplate:"/Template/save-update/",TemplateTypes:"/Template/TemplateTypes/"},te=()=>{const n=S(),{enerexIdentifier:s,projectId:i}=C();return T.useQuery({queryKey:["getTemplateTags"],queryFn:async r=>await n.get(`${N.MergeTags}${i}/${s}`)})},ne=()=>{const n=S(),{enerexIdentifier:s,projectId:i}=C();return T.useQuery({queryKey:["getExcludeCategory"],queryFn:async r=>await n.get(`${N.ExcludeCategory}${i}/${s}`)})},re=({templateHTML:n,className:s="",loading:i=!1})=>{const{post:l}=V(),{data:r}=te(),{data:e}=ne(),[o,a]=p.useState(n??{html:O,css:""}),{enerexIdentifier:f,projectId:g}=C(),y="https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png",v="https://plugins.stripo.email/api/v1/auth";p.useEffect(()=>{if(r&&e&&!document.getElementById("UiEditorScript")){const h=document.createElement("script");h.id="UiEditorScript",h.type="module",h.src=A.EDITOR_SCRIPT_URL,h.onload=x,document.body.appendChild(h)}},[r,e]);const x=async()=>{window.UIEditor.initEditor(document.querySelector("#stripoEditorContainer"),{html:o.html,css:o.css,modulesExcludedCategories:e??[],forceRecreate:!0,metadata:{emailId:`plugin_${A.EDITOR_PLUGIN_ID}_demo_1_${g}_${f}`,userId:"1",username:"Plugin Demo User",avatarUrl:y},locale:"en",onTokenRefreshRequest:async function(h){const I={pluginId:A.EDITOR_PLUGIN_ID,secretKey:A.EDITOR_SECRET_KEY,userId:"12",role:"user"},d=await l(v,I);d&&h(d.token)},codeEditorButtonSelector:"#codeEditor",undoButtonSelector:"#undoButton",redoButtonSelector:"#redoButton",mobileViewButtonSelector:"#mobileViewButton",desktopViewButtonSelector:"#desktopViewButton",mergeTags:ee(r??[])})};return t.jsx("div",{className:"position-relative",children:t.jsxs("div",{className:`editor-container ${s}`,children:[i&&t.jsx("div",{className:"loading-overlay",children:t.jsx(c.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1"})}),t.jsx("div",{id:"externalSystemContainer"}),t.jsx("div",{id:"stripoEditorContainer"})]})})},se=({label:n,register:s,validation:i,required:l=!1,name:r,error:e,...o})=>t.jsxs(c.Form.Group,{className:"mb-1",children:[n?t.jsxs(c.Form.Label,{className:"mb-3 d-block form-label",children:[n,l&&t.jsx("label",{className:"text-danger",children:"*"})]}):null,t.jsx(c.Form.Control,{name:r,type:"text",...o,isInvalid:!!(e&&e[r]),...s?s(r,{...i}):{},className:`form-control ${e&&e[r]&&"border border-danger"}`}),e&&e[r]?t.jsx(c.Form.Control.Feedback,{type:"invalid",children:e[r].message}):null]});function oe({items:n,renderItem:s,className:i="",keyExtractor:l}){return t.jsx(c.ListGroup,{className:` ${i}`,children:n.map((r,e)=>t.jsx(c.ListGroup.Item,{children:s(r,e)},l?l(r,e):e))})}const ie=n=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",...n,children:t.jsx("path",{d:"M352 528L128 528C119.2 528 112 520.8 112 512L112 288C112 279.2 119.2 272 128 272L176 272L176 224L128 224C92.7 224 64 252.7 64 288L64 512C64 547.3 92.7 576 128 576L352 576C387.3 576 416 547.3 416 512L416 464L368 464L368 512C368 520.8 360.8 528 352 528zM288 368C279.2 368 272 360.8 272 352L272 128C272 119.2 279.2 112 288 112L512 112C520.8 112 528 119.2 528 128L528 352C528 360.8 520.8 368 512 368L288 368zM224 352C224 387.3 252.7 416 288 416L512 416C547.3 416 576 387.3 576 352L576 128C576 92.7 547.3 64 512 64L288 64C252.7 64 224 92.7 224 128L224 352z"})}),le=({children:n,title:s,placement:i})=>{const l=t.jsx(c.Popover,{id:"popover-basic",className:"dark-popover",children:t.jsx(c.Popover.Body,{className:"p-0 text-white",children:s})});return t.jsx(c.OverlayTrigger,{trigger:["hover","focus"],placement:i,overlay:l,containerPadding:0,container:document.body,popperConfig:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",enabled:!0,options:{boundary:"window"}}]},children:n})},ae=({selected:n,group:s,value:i,label:l,onCopy:r,onSelect:e,subItem:o=!1})=>t.jsxs("div",{className:"ps-1 py-1 d-flex position-relative",style:{alignItems:"center"},children:[t.jsx("input",{type:"radio",onChange:()=>{e(i)},className:"me-2",checked:n,name:s}),t.jsx("p",{title:l,className:"mb-0 wraped-text",children:l}),!o&&t.jsx(le,{title:"Copy",placement:"top",children:t.jsx("button",{className:"btn btn-link",type:"button",style:{padding:0,marginLeft:"auto",position:"relative",minWidth:32,flexShrink:0},children:t.jsx(ie,{onClick:()=>r(i),height:20,fill:"black"})})})]}),de=()=>{const n=S(),{enerexIdentifier:s,projectId:i}=C();return T.useQuery({queryKey:["getTemplatesList"],queryFn:async r=>await n.get(`${N.Template_list}${i}/${s}`)})},ce=(n,s=[])=>{const i=/^(?:\(copy(?:-(\d+))?\)\s)?(.+)$/,l=n.match(i);if(!l)return`(copy) ${n}`;const r=l[2],e=new RegExp(`^\\(copy(?:-(\\d+))?\\) ${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`);let o=1;const a=s.filter(f=>e.test(f));return a.length===0?`(copy) ${r}`:(a.forEach(f=>{const g=f.match(e);if(g&&g[1]){const y=parseInt(g[1],10);!isNaN(y)&&y>=o&&(o=y+1)}else o=Math.max(o,2)}),`(copy-${o}) ${r}`)},pe=()=>{const n=S(),{enerexIdentifier:s,projectId:i}=C();return T.useMutation({mutationKey:["getTemplate"],mutationFn:async({id:r})=>{if(r)return await n.get(`${N.Template}${s}/${r}/${i}`)}})},me=()=>{const n=S(),{enerexIdentifier:s,projectId:i}=C();return T.useQuery({queryKey:["getTemplateTypes"],queryFn:async r=>await n.get(`${N.TemplateTypes}${s}/${i}`)})};function fe(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var M={exports:{}};/*!
358
358
  Copyright (c) 2018 Jed Watson.
359
359
  Licensed under the MIT License (MIT), see
360
360
  http://jedwatson.github.io/classnames
361
- */var W;function ue(){return W||(W=1,function(n){(function(){var s={}.hasOwnProperty;function i(){for(var e="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(e=r(e,l(a)))}return e}function l(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return i.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var o="";for(var a in e)s.call(e,a)&&e[a]&&(o=r(o,a));return o}function r(e,o){return o?e?e+" "+o:e+o:e}n.exports?(i.default=i,n.exports=i):window.classNames=i})()}(M)),M.exports}var ge=ue();const Y=fe(ge),ye=({name:n="",control:s,options:i,multiple:l=!1,placeholder:r,validation:e,labelKey:o="name",disabled:a,isInvalid:f,value:y,onChange:h,uncontrolled:u,menuPlacement:C="auto",closeOnSelect:x=!0})=>{const A={control:p=>({...p,minHeight:"33px",borderColor:f?"var(--bs-form-invalid-border-color) !important":"var(--ct-input-border-color)",backgroundImage:f?'url("data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 12%27 width=%2712%27 height=%2712%27 fill=%27none%27 stroke=%27%23fa5c7c%27%3e%3ccircle cx=%276%27 cy=%276%27 r=%274.5%27/%3e%3cpath stroke-linejoin=%27round%27 d=%27M5.8 3.6h.4L6 6.5z%27/%3e%3ccircle cx=%276%27 cy=%278.2%27 r=%27.6%27 fill=%27%23fa5c7c%27 stroke=%27none%27/%3e%3c/svg%3e")':"none",backgroundRepeat:"no-repeat",backgroundPosition:"right calc(0.375em + 0.225rem) center",backgroundSize:"calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)","&:hover":{borderColor:f?"var(--bs-form-invalid-border-color)":"var(--ct-input-border-color)"},"& .react-select__single-value":{color:"var(--ct-input-color) !important"},"& .react-select__placeholder":{color:"var(--ct-input-placeholder-color) !important"},"& .react-select__indicators":{display:"none"}}),menu:p=>({...p,marginTop:0,width:"max-content",minWidth:"100%"}),menuPortal:p=>({...p,zIndex:9999}),multiValueRemove:p=>({...p,display:a?"none":"block"})};return u?t.jsx(z,{className:Y({"is-invalid":f}),styles:A,classNamePrefix:"react-select",isMulti:l,options:i,onChange:h,placeholder:r,menuPortalTarget:document.body,value:y,getOptionLabel:typeof o=="string"?p=>p[o]:o,getOptionValue:p=>p.id,isDisabled:a,menuPlacement:C,closeMenuOnSelect:x}):t.jsx(H.Controller,{control:s,name:n,rules:e,render:({field:{onChange:p,value:I,onBlur:k}})=>t.jsx(z,{className:Y({"is-invalid":f}),styles:A,classNamePrefix:"react-select",isMulti:l,options:i,onBlur:k,onChange:p,placeholder:r,menuPortalTarget:document.body,value:I,getOptionLabel:typeof o=="string"?N=>N[o]:o,getOptionValue:N=>N.id,isDisabled:a,menuPlacement:C,closeMenuOnSelect:x},I?JSON.stringify(I):"reset")})},he=({label:n,name:s,validation:i,control:l,error:r,...e})=>t.jsxs(d.Form.Group,{className:"mb-1",children:[n&&t.jsxs(d.Form.Label,{className:"mb-3 d-block form-label",children:[n," ",e.required&&t.jsx("span",{className:"text-danger",children:"*"})]}),t.jsx(ye,{control:l,options:e.options??[],validation:i,isInvalid:r&&!!r[s],name:s}),r&&r[s]?t.jsx(d.Form.Control.Feedback,{type:"invalid",children:r[s].message}):null]}),be=()=>{const n=E();v.useQueryClient();const{enerexIdentifier:s,projectId:i}=T();return v.useMutation({mutationKey:["saveTemplate"],mutationFn:async r=>(r.enerexIdentifier=s??"",r.projectId=i??"",await n.post(`${S.SaveTemplate}`,r))})},we=({onSelectItem:n,templateLoading:s,onReset:i})=>{const{register:l,handleSubmit:r,clearErrors:e,setValue:o,control:a,reset:f,formState:{errors:y}}=H.useForm({defaultValues:{templateName:"",templateType:void 0},mode:"onChange"}),{data:h,refetch:u,isLoading:C}=de(),[x,A]=c.useState([]),[p,I]=c.useState(),[k,N]=c.useState(),{mutateAsync:B,isPending:L}=pe(),{mutateAsync:Te,isPending:j}=be(),{data:D,isLoading:X}=me(),[F,Ce]=c.useState([]);c.useEffect(()=>{D&&Ce(D.map(m=>({id:`${m.id}`,name:m.name})))},[D]),c.useEffect(()=>{s(!!L)},[L]),c.useEffect(()=>{A(h??[])},[h]);const xe=async(m,b)=>{b&&A(w=>{const _=[...w],P={...b};P.id="",P.name=ce(P.name,_.map($=>$.name)),_.splice(m+1,0,P),I(P),o("templateName",P.name);const J=F.find($=>$.id===`${b.type}`);return J?o("templateType",J):o("templateType",void 0),e(),B({id:b?.id}).then($=>{$&&N($)}),_})},Ie=async m=>{if(I(m),m){if(o("templateName",m?.name),D&&D.find(w=>w.id===m.type)){const w=F.find(_=>_.id===`${m.type}`);w&&o("templateType",w)}else o("templateType",void 0);e()}const b=await B({id:m?.id});b&&N(b)};c.useEffect(()=>{n(k&&p?k:void 0)},[k,p,n]);const Ee=m=>{window.StripoEditorApi.actionsApi.getTemplateData(async b=>{const w={enerexIdentifier:"",projectId:"",templateId:p?.id??"",templateType:m.templateType.id,name:m.templateName,html:b.html,css:b.css};await Te(w)&&(e(),p?.id===""&&f(),u())})};return t.jsx(d.Card,{className:"border border-0 text-start",children:t.jsx(d.Card.Body,{className:"pe-0 ps-2",children:t.jsxs("form",{onSubmit:r(Ee),children:[t.jsx("label",{className:"mb-2",children:"Templates"}),t.jsx("div",{className:"template-list-container mb-3",children:t.jsx(oe,{items:x,renderItem:(m,b)=>t.jsx(ae,{selected:m===p,label:m.name,subItem:m.id==="",onCopy:w=>xe(b,w),onSelect:w=>Ie(w),value:m,group:"templates"})})}),t.jsx(he,{label:"Template Type",control:a,error:y,options:F,required:!0,validation:{required:{value:!0,message:"Template Type is required"}},...l("templateType")}),t.jsx(se,{label:"Template Name",register:l,error:y,required:!0,name:"templateName",validation:{required:{value:!0,message:"Template Name is required"}}}),t.jsx("hr",{}),t.jsxs("div",{className:"d-flex justify-content-between mt-3 ",children:[t.jsx(d.Button,{style:{width:"70px"},variant:"primary",disabled:C||L||j||X,onClick:()=>{I(void 0),f(),i()},children:L||j?t.jsx(d.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:t.jsx("span",{className:"visually-hidden",children:"Loading..."})}):"Clear"}),t.jsx(d.Button,{type:"submit",variant:"primary",style:{width:"80px"},disabled:C||L||j||X,children:L||j?t.jsx(d.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:t.jsx("span",{className:"visually-hidden",children:"Loading..."})}):(p?.id??"")===""?"Save":"Update"})]})]})})})},ve=({config:n})=>{const[s,i]=c.useState(),[l,r]=c.useState(!1),e=a=>{i(a),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&a&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(a?.html??"",a?.css??"","")},o=()=>{r(!1),i(void 0),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(O,"","")};return t.jsx(Q,{configs:n,children:t.jsx(R,{children:t.jsx("div",{className:"root-widget",children:t.jsxs(d.Row,{children:[t.jsx(d.Col,{md:3,lg:2,className:"p-0",children:t.jsx(we,{templateLoading:r,onSelectItem:e,onReset:o})}),t.jsx(d.Col,{md:9,lg:10,children:t.jsx(re,{templateHTML:{css:s?.css??"",html:s?.html??O},loading:l,className:"col-span-5"})})]})})})})};g.EditorWidget=ve,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
361
+ */var W;function ue(){return W||(W=1,function(n){(function(){var s={}.hasOwnProperty;function i(){for(var e="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(e=r(e,l(a)))}return e}function l(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return i.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var o="";for(var a in e)s.call(e,a)&&e[a]&&(o=r(o,a));return o}function r(e,o){return o?e?e+" "+o:e+o:e}n.exports?(i.default=i,n.exports=i):window.classNames=i})()}(M)),M.exports}var ge=ue();const Y=fe(ge),ye=({name:n="",control:s,options:i,multiple:l=!1,placeholder:r,validation:e,labelKey:o="name",disabled:a,isInvalid:f,value:g,onChange:y,uncontrolled:v,menuPlacement:x="auto",closeOnSelect:h=!0})=>{const I={control:d=>({...d,minHeight:"33px",borderColor:f?"var(--bs-form-invalid-border-color) !important":"var(--ct-input-border-color)",backgroundImage:f?'url("data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 12%27 width=%2712%27 height=%2712%27 fill=%27none%27 stroke=%27%23fa5c7c%27%3e%3ccircle cx=%276%27 cy=%276%27 r=%274.5%27/%3e%3cpath stroke-linejoin=%27round%27 d=%27M5.8 3.6h.4L6 6.5z%27/%3e%3ccircle cx=%276%27 cy=%278.2%27 r=%27.6%27 fill=%27%23fa5c7c%27 stroke=%27none%27/%3e%3c/svg%3e")':"none",backgroundRepeat:"no-repeat",backgroundPosition:"right calc(0.375em + 0.225rem) center",backgroundSize:"calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)","&:hover":{borderColor:f?"var(--bs-form-invalid-border-color)":"var(--ct-input-border-color)"},"& .react-select__single-value":{color:"var(--ct-input-color) !important"},"& .react-select__placeholder":{color:"var(--ct-input-placeholder-color) !important"},"& .react-select__indicators":{display:"none"}}),menu:d=>({...d,marginTop:0,width:"max-content",minWidth:"100%"}),menuPortal:d=>({...d,zIndex:9999}),multiValueRemove:d=>({...d,display:a?"none":"block"})};return v?t.jsx(z,{className:Y({"is-invalid":f}),styles:I,classNamePrefix:"react-select",isMulti:l,options:i,onChange:y,placeholder:r,menuPortalTarget:document.body,value:g,getOptionLabel:typeof o=="string"?d=>d[o]:o,getOptionValue:d=>d.id,isDisabled:a,menuPlacement:x,closeMenuOnSelect:h}):t.jsx(H.Controller,{control:s,name:n,rules:e,render:({field:{onChange:d,value:E,onBlur:k}})=>t.jsx(z,{className:Y({"is-invalid":f}),styles:I,classNamePrefix:"react-select",isMulti:l,options:i,onBlur:k,onChange:d,placeholder:r,menuPortalTarget:document.body,value:E,getOptionLabel:typeof o=="string"?L=>L[o]:o,getOptionValue:L=>L.id,isDisabled:a,menuPlacement:x,closeMenuOnSelect:h},E?JSON.stringify(E):"reset")})},he=({label:n,name:s,validation:i,control:l,error:r,...e})=>t.jsxs(c.Form.Group,{className:"mb-1",children:[n&&t.jsxs(c.Form.Label,{className:"mb-3 d-block form-label",children:[n," ",e.required&&t.jsx("span",{className:"text-danger",children:"*"})]}),t.jsx(ye,{control:l,options:e.options??[],validation:i,isInvalid:r&&!!r[s],name:s}),r&&r[s]?t.jsx(c.Form.Control.Feedback,{type:"invalid",children:r[s].message}):null]}),be=()=>{const n=S();T.useQueryClient();const{enerexIdentifier:s,projectId:i}=C();return T.useMutation({mutationKey:["saveTemplate"],mutationFn:async r=>(r.enerexIdentifier=s??"",r.projectId=i??"",await n.post(`${N.SaveTemplate}`,r))})},we=({onSelectItem:n,templateLoading:s,onReset:i})=>{const{register:l,handleSubmit:r,clearErrors:e,setValue:o,control:a,reset:f,formState:{errors:g}}=H.useForm({defaultValues:{templateName:"",templateType:void 0},mode:"onChange"}),{data:y,refetch:v,isLoading:x}=de(),[h,I]=p.useState([]),[d,E]=p.useState(),[k,L]=p.useState(),{mutateAsync:B,isPending:_}=pe(),{mutateAsync:Te,isPending:D}=be(),{data:j,isLoading:X}=me(),[F,Ce]=p.useState([]);p.useEffect(()=>{j&&Ce(j.map(m=>({id:`${m.id}`,name:m.name})))},[j]),p.useEffect(()=>{s(!!_)},[_]),p.useEffect(()=>{I(y??[])},[y]);const xe=async(m,b)=>{b&&I(w=>{const P=[...w],$={...b};$.id="",$.name=ce($.name,P.map(q=>q.name)),P.splice(m+1,0,$),E($),o("templateName",$.name);const J=F.find(q=>q.id===`${b.type}`);return J?o("templateType",J):o("templateType",void 0),e(),B({id:b?.id}).then(q=>{q&&L(q)}),P})},Ie=async m=>{if(E(m),m){if(o("templateName",m?.name),j&&j.find(w=>w.id===m.type)){const w=F.find(P=>P.id===`${m.type}`);w&&o("templateType",w)}else o("templateType",void 0);e()}const b=await B({id:m?.id});b&&L(b)};p.useEffect(()=>{n(k&&d?k:void 0)},[k,d,n]);const Ee=m=>{window.StripoEditorApi.actionsApi.getTemplateData(async b=>{const w={enerexIdentifier:"",projectId:"",templateId:d?.id??"",templateType:m.templateType.id,name:m.templateName,html:b.html,css:b.css};await Te(w)&&(e(),d?.id===""&&f(),v())})};return t.jsx(c.Card,{className:"border border-0 text-start",children:t.jsx(c.Card.Body,{className:"pe-0 ps-2",children:t.jsxs("form",{onSubmit:r(Ee),children:[t.jsx("label",{className:"mb-2",children:"Templates"}),t.jsx("div",{className:"template-list-container mb-3",children:t.jsx(oe,{items:h,renderItem:(m,b)=>t.jsx(ae,{selected:m===d,label:m.name,subItem:m.id==="",onCopy:w=>xe(b,w),onSelect:w=>Ie(w),value:m,group:"templates"})})}),t.jsx(he,{label:"Template Type",control:a,error:g,options:F,required:!0,validation:{required:{value:!0,message:"Template Type is required"}},...l("templateType")}),t.jsx(se,{label:"Template Name",register:l,error:g,required:!0,name:"templateName",validation:{required:{value:!0,message:"Template Name is required"}}}),t.jsx("hr",{}),t.jsxs("div",{className:"d-flex justify-content-between mt-3 ",children:[t.jsx(c.Button,{style:{width:"70px"},variant:"primary",disabled:x||_||D||X,onClick:()=>{E(void 0),f(),i()},children:_||D?t.jsx(c.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:t.jsx("span",{className:"visually-hidden",children:"Loading..."})}):"Clear"}),t.jsx(c.Button,{type:"submit",variant:"primary",style:{width:"80px"},disabled:x||_||D||X,children:_||D?t.jsx(c.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:t.jsx("span",{className:"visually-hidden",children:"Loading..."})}):(d?.id??"")===""?"Save":"Update"})]})]})})})},ve=({config:n})=>{const[s,i]=p.useState(),[l,r]=p.useState(!1),e=a=>{i(a),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&a&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(a?.html??"",a?.css??"","")},o=()=>{r(!1),i(void 0),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(O,"","")};return t.jsx(Q,{configs:n,children:t.jsx(R,{children:t.jsx("div",{className:"root-widget",children:t.jsxs(c.Row,{children:[t.jsx(c.Col,{md:3,lg:2,className:"p-0",children:t.jsx(we,{templateLoading:r,onSelectItem:e,onReset:o})}),t.jsx(c.Col,{md:9,lg:10,children:t.jsx(re,{templateHTML:{css:s?.css??"",html:s?.html??O},loading:l,className:"col-span-5"})})]})})})})};u.EditorWidget=ve,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enerex/template-studio",
3
- "version": "1.1.13",
3
+ "version": "1.1.14",
4
4
  "main": "./dist/enerex-template-editor.umd.js",
5
5
  "module": "./dist/enerex-template-editor.es.js",
6
6
  "types": "./dist/types/index.d.ts",