@enerex/template-studio 1.1.21 → 1.1.22

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,10 +1,10 @@
1
1
  import { jsx as s, jsxs as y } from "react/jsx-runtime";
2
- import I, { useContext as te, useState as S, useEffect as _ } from "react";
3
- import { QueryClient as pe, QueryClientProvider as me, useQuery as O, useMutation as ne, useQueryClient as ue } from "@tanstack/react-query";
4
- import K from "axios";
5
- import { Spinner as U, Form as E, Card as z, Row as G, Col as q, Button as Q } from "react-bootstrap";
2
+ import I, { useContext as ee, useState as S, useEffect as _ } from "react";
3
+ import { QueryClient as pe, QueryClientProvider as me, useQuery as O, useMutation as te, useQueryClient as ue } from "@tanstack/react-query";
4
+ import V from "axios";
5
+ import { Spinner as U, Form as E, Card as K, Row as z, Col as $, Button as G } from "react-bootstrap";
6
6
  import { Controller as ge, useForm as fe } from "react-hook-form";
7
- import W from "react-select";
7
+ import Q from "react-select";
8
8
  const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
9
9
  <html\r
10
10
  dir="ltr"\r
@@ -361,7 +361,7 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
361
361
  </div>\r
362
362
  </body>\r
363
363
  </html>\r
364
- `, re = I.createContext(
364
+ `, ne = I.createContext(
365
365
  void 0
366
366
  ), ye = ({
367
367
  children: t,
@@ -373,7 +373,7 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
373
373
  e(m.apiKey), l(m.clientId), b(m.projectId), o(m.enerexIdentifier), h(m.userName);
374
374
  };
375
375
  return /* @__PURE__ */ s(
376
- re.Provider,
376
+ ne.Provider,
377
377
  {
378
378
  value: {
379
379
  clientId: i,
@@ -386,14 +386,14 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
386
386
  children: t
387
387
  }
388
388
  );
389
- }, T = () => {
390
- const t = te(re);
389
+ }, v = () => {
390
+ const t = ee(ne);
391
391
  if (!t)
392
392
  throw new Error("widgetConfig must be used within a ConfigProvider");
393
393
  return t;
394
- }, se = (t = "", r) => ({ get: async (n, e) => {
394
+ }, re = (t = "", r) => ({ get: async (n, e) => {
395
395
  try {
396
- const a = await K.get(
396
+ const a = await V.get(
397
397
  `${t}${n}`,
398
398
  e ?? r
399
399
  );
@@ -404,7 +404,7 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
404
404
  }
405
405
  }, post: async (n, e, a) => {
406
406
  try {
407
- const o = await K.post(
407
+ const o = await V.post(
408
408
  `${t}${n}`,
409
409
  e,
410
410
  a ?? r
@@ -421,7 +421,7 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
421
421
  API_BASE_URL: "https://dev-socket.enerex.com/common/api"
422
422
  //API_BASE_URL: "https://localhost:44338/api",
423
423
  // more env variables...
424
- }, ie = I.createContext({
424
+ }, se = I.createContext({
425
425
  get: () => {
426
426
  throw new Error("HttpClientContext.get not implemented");
427
427
  },
@@ -429,13 +429,13 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
429
429
  throw new Error("HttpClientContext.post not implemented");
430
430
  }
431
431
  }), he = ({ children: t }) => {
432
- const { clientId: r, apiKey: i } = T(), l = {
432
+ const { clientId: r, apiKey: i } = v(), l = {
433
433
  headers: {
434
434
  client_id: r,
435
435
  "x-api-key": i
436
436
  }
437
- }, { get: n, post: e } = se(k.API_BASE_URL, l);
438
- return /* @__PURE__ */ s(ie.Provider, { value: { get: n, post: e }, children: t });
437
+ }, { get: n, post: e } = re(k.API_BASE_URL, l);
438
+ return /* @__PURE__ */ s(se.Provider, { value: { get: n, post: e }, children: t });
439
439
  }, be = ({ children: t }) => {
440
440
  const r = new pe();
441
441
  return /* @__PURE__ */ s(he, { children: /* @__PURE__ */ s(me, { client: r, children: t }) });
@@ -451,7 +451,7 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
451
451
  i.push({ category: l, entries: n });
452
452
  }), i;
453
453
  }, A = () => {
454
- const t = te(ie);
454
+ const t = ee(se);
455
455
  if (t)
456
456
  return t;
457
457
  throw new Error("useHttpClient must be used within a HttpClientProvider");
@@ -462,16 +462,16 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
462
462
  ExcludeCategory: "/Template/GetExcludeCategories/",
463
463
  SaveTemplate: "/Template/save-update/",
464
464
  TemplateTypes: "/Template/TemplateTypes/"
465
- }, Te = () => {
466
- const t = A(), { enerexIdentifier: r, projectId: i } = T();
465
+ }, ve = () => {
466
+ const t = A(), { enerexIdentifier: r, projectId: i } = v();
467
467
  return O({
468
468
  queryKey: ["getTemplateTags"],
469
469
  queryFn: async (n) => await t.get(
470
470
  `${P.MergeTags}${i}/${r}`
471
471
  )
472
472
  });
473
- }, ve = () => {
474
- const t = A(), { enerexIdentifier: r, projectId: i } = T();
473
+ }, Te = () => {
474
+ const t = A(), { enerexIdentifier: r, projectId: i } = v();
475
475
  return O({
476
476
  queryKey: ["getExcludeCategory"],
477
477
  queryFn: async (n) => await t.get(
@@ -483,9 +483,9 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
483
483
  className: r = "",
484
484
  loading: i = !1
485
485
  }) => {
486
- const { post: l } = se(), { data: n } = Te(), { data: e } = ve(), [a, o] = S(
486
+ const { post: l } = re(), { data: n } = ve(), { data: e } = Te(), [a, o] = S(
487
487
  t ?? { html: D, css: "" }
488
- ), { enerexIdentifier: p, projectId: h, userName: f } = T(), b = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", w = "https://plugins.stripo.email/api/v1/auth";
488
+ ), { enerexIdentifier: p, projectId: h, userName: f } = v(), b = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", w = "https://plugins.stripo.email/api/v1/auth";
489
489
  _(() => {
490
490
  if (n && e && !document.getElementById("UiEditorScript")) {
491
491
  const u = document.createElement("script");
@@ -539,7 +539,7 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
539
539
  /* @__PURE__ */ s("div", { id: "externalSystemContainer" }),
540
540
  /* @__PURE__ */ s("div", { id: "stripoEditorContainer" })
541
541
  ] }) });
542
- }, Y = ({
542
+ }, W = ({
543
543
  label: t,
544
544
  register: r,
545
545
  validation: i,
@@ -568,7 +568,7 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
568
568
  ),
569
569
  e && e[n] ? /* @__PURE__ */ s(E.Control.Feedback, { type: "invalid", children: e[n].message }) : null
570
570
  ] }), Ce = () => {
571
- const t = A(), { enerexIdentifier: r, projectId: i } = T();
571
+ const t = A(), { enerexIdentifier: r, projectId: i } = v();
572
572
  return O({
573
573
  queryKey: ["getTemplatesList"],
574
574
  queryFn: async (n) => await t.get(
@@ -576,8 +576,8 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
576
576
  )
577
577
  });
578
578
  }, Ie = () => {
579
- const t = A(), { enerexIdentifier: r, projectId: i } = T();
580
- return ne({
579
+ const t = A(), { enerexIdentifier: r, projectId: i } = v();
580
+ return te({
581
581
  mutationKey: ["getTemplate"],
582
582
  mutationFn: async ({ id: n }) => {
583
583
  if (n)
@@ -587,7 +587,7 @@ const D = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
587
587
  }
588
588
  });
589
589
  }, Se = () => {
590
- const t = A(), { enerexIdentifier: r, projectId: i } = T();
590
+ const t = A(), { enerexIdentifier: r, projectId: i } = v();
591
591
  return O({
592
592
  queryKey: ["getTemplateTypes"],
593
593
  queryFn: async (n) => await t.get(
@@ -604,9 +604,9 @@ var B = { exports: {} };
604
604
  Licensed under the MIT License (MIT), see
605
605
  http://jedwatson.github.io/classnames
606
606
  */
607
- var X;
607
+ var Y;
608
608
  function Ne() {
609
- return X || (X = 1, function(t) {
609
+ return Y || (Y = 1, function(t) {
610
610
  (function() {
611
611
  var r = {}.hasOwnProperty;
612
612
  function i() {
@@ -638,7 +638,7 @@ function Ne() {
638
638
  }(B)), B.exports;
639
639
  }
640
640
  var _e = Ne();
641
- const J = /* @__PURE__ */ Ee(_e), Ae = ({
641
+ const X = /* @__PURE__ */ Ee(_e), Ae = ({
642
642
  name: t = "",
643
643
  control: r,
644
644
  options: i,
@@ -693,9 +693,9 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
693
693
  })
694
694
  };
695
695
  return b ? /* @__PURE__ */ s(
696
- W,
696
+ Q,
697
697
  {
698
- className: J({
698
+ className: X({
699
699
  "is-invalid": p
700
700
  }),
701
701
  styles: u,
@@ -718,23 +718,23 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
718
718
  control: r,
719
719
  name: t,
720
720
  rules: e,
721
- render: ({ field: { onChange: c, value: g, onBlur: $ } }) => /* @__PURE__ */ s(
722
- W,
721
+ render: ({ field: { onChange: c, value: g, onBlur: q } }) => /* @__PURE__ */ s(
722
+ Q,
723
723
  {
724
- className: J({
724
+ className: X({
725
725
  "is-invalid": p
726
726
  }),
727
727
  styles: u,
728
728
  classNamePrefix: "react-select",
729
729
  isMulti: l,
730
730
  options: i,
731
- onBlur: $,
731
+ onBlur: q,
732
732
  onChange: c,
733
733
  placeholder: n,
734
734
  menuPortalTarget: document.body,
735
735
  value: g,
736
- getOptionLabel: typeof a == "string" ? (v) => v[a] : a,
737
- getOptionValue: (v) => v.id,
736
+ getOptionLabel: typeof a == "string" ? (T) => T[a] : a,
737
+ getOptionValue: (T) => T.id,
738
738
  isDisabled: o,
739
739
  menuPlacement: w,
740
740
  closeMenuOnSelect: m
@@ -743,7 +743,7 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
743
743
  )
744
744
  }
745
745
  );
746
- }, Z = ({
746
+ }, J = ({
747
747
  label: t,
748
748
  name: r,
749
749
  validation: i,
@@ -770,15 +770,15 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
770
770
  ] }), Pe = () => {
771
771
  const t = A();
772
772
  ue();
773
- const { enerexIdentifier: r, projectId: i } = T();
774
- return ne({
773
+ const { enerexIdentifier: r, projectId: i } = v();
774
+ return te({
775
775
  mutationKey: ["saveTemplate"],
776
776
  mutationFn: async (n) => (n.enerexIdentifier = r ?? "", n.projectId = i ?? "", await t.post(
777
777
  `${P.SaveTemplate}`,
778
778
  n
779
779
  ))
780
780
  });
781
- }, ee = { id: "", name: "New (Blank)" }, je = ({
781
+ }, Z = { id: "", name: "New (Blank)" }, je = ({
782
782
  onSelectItem: t,
783
783
  templateLoading: r,
784
784
  onReset: i
@@ -797,17 +797,17 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
797
797
  templateName: "",
798
798
  subject: "",
799
799
  templateType: void 0,
800
- template: ee
800
+ template: Z
801
801
  },
802
802
  mode: "onChange"
803
803
  }), {
804
804
  data: b,
805
805
  refetch: w,
806
806
  isLoading: m
807
- } = Ce(), [u, c] = S([]), [g, $] = S(), [v, H] = S(), { mutateAsync: ae, isPending: N } = Ie(), { mutateAsync: le, isPending: L } = Pe(), { data: j, isLoading: M } = Se(), [F, oe] = S([]);
807
+ } = Ce(), [u, c] = S([]), [g, q] = S(), [T, H] = S(), { mutateAsync: ie, isPending: N } = Ie(), { mutateAsync: ae, isPending: L } = Pe(), { data: j, isLoading: M } = Se(), [F, le] = S([]);
808
808
  _(() => {
809
- j && oe(
810
- j.map((d) => ({
809
+ j && le(
810
+ j.filter((d) => d.id !== void 0).map((d) => ({
811
811
  id: `${d.id}`,
812
812
  name: d.name
813
813
  }))
@@ -817,30 +817,30 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
817
817
  }, [N]), _(() => {
818
818
  c(b ?? []);
819
819
  }, [b]);
820
- const de = async (d) => {
821
- if ($(d), d) {
820
+ const oe = async (d) => {
821
+ if (q(d), d) {
822
822
  if (a("templateName", d?.name), j && j.find((C) => C.id === d.type)) {
823
823
  const C = F.find((R) => R.id === `${d.type}`);
824
824
  C && a("templateType", C);
825
- } else
826
- a("templateType", void 0);
825
+ }
827
826
  e();
828
- }
829
- const x = await ae({ id: d?.id });
827
+ } else
828
+ a("templateName", "");
829
+ const x = await ie({ id: d?.id });
830
830
  H(x || void 0);
831
831
  };
832
832
  _(() => {
833
833
  let d = u.find((x) => x.id === p("template")?.id);
834
- de(d);
834
+ oe(d);
835
835
  }, [p("template")]), _(() => {
836
- t(v && g ? v : void 0);
837
- }, [v, g, t]);
838
- const ce = (d) => {
836
+ t(T && g ? T : void 0);
837
+ }, [T, g, t]);
838
+ const de = (d) => {
839
839
  window.StripoEditorApi.actionsApi.getTemplateData(
840
840
  async (x) => {
841
841
  let C = d.template.id, R = "";
842
842
  g?.type === null && (C = "", R = d.template.id);
843
- const V = {
843
+ const ce = {
844
844
  enerexIdentifier: "",
845
845
  projectId: "",
846
846
  templateId: C,
@@ -851,14 +851,14 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
851
851
  subject: d?.subject ?? "",
852
852
  parent_id: R
853
853
  };
854
- console.log("request", V), await le(V) && (e(), h(), w());
854
+ await ae(ce) && (e(), h(), w());
855
855
  }
856
856
  );
857
857
  };
858
- return /* @__PURE__ */ s(z, { className: "border border-0 text-start", children: /* @__PURE__ */ s(z.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ s("form", { onSubmit: n(ce), children: /* @__PURE__ */ y("div", { className: "template-list-container gap-3", children: [
859
- /* @__PURE__ */ y(G, { children: [
860
- /* @__PURE__ */ s(q, { md: 3, children: /* @__PURE__ */ s(
861
- Z,
858
+ return /* @__PURE__ */ s(K, { className: "border border-0 text-start", children: /* @__PURE__ */ s(K.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ s("form", { onSubmit: n(de), children: /* @__PURE__ */ y("div", { className: "template-list-container gap-3", children: [
859
+ /* @__PURE__ */ y(z, { children: [
860
+ /* @__PURE__ */ s($, { md: 3, children: /* @__PURE__ */ s(
861
+ J,
862
862
  {
863
863
  label: "Type",
864
864
  control: o,
@@ -874,14 +874,14 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
874
874
  ...l("templateType")
875
875
  }
876
876
  ) }),
877
- /* @__PURE__ */ s(q, { md: 3, children: /* @__PURE__ */ s(
878
- Z,
877
+ /* @__PURE__ */ s($, { md: 3, children: /* @__PURE__ */ s(
878
+ J,
879
879
  {
880
880
  label: "Template",
881
881
  control: o,
882
882
  error: f,
883
883
  options: [
884
- ee,
884
+ Z,
885
885
  ...u.filter(
886
886
  (d) => d.type?.toString() === p("templateType")?.id || d.type === null
887
887
  ).map((d) => ({
@@ -893,8 +893,8 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
893
893
  ...l("template")
894
894
  }
895
895
  ) }),
896
- /* @__PURE__ */ s(q, { md: 3, children: /* @__PURE__ */ s(
897
- Y,
896
+ /* @__PURE__ */ s($, { md: 3, children: /* @__PURE__ */ s(
897
+ W,
898
898
  {
899
899
  label: "Name",
900
900
  register: l,
@@ -910,19 +910,19 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
910
910
  }
911
911
  ) }),
912
912
  /* @__PURE__ */ y(
913
- q,
913
+ $,
914
914
  {
915
915
  md: 3,
916
916
  className: "d-flex align-items-end justify-content-end gap-2 mb-3",
917
917
  children: [
918
918
  /* @__PURE__ */ s(
919
- Q,
919
+ G,
920
920
  {
921
921
  style: { width: "70px" },
922
922
  variant: "primary",
923
923
  disabled: m || N || L || M,
924
924
  onClick: () => {
925
- $(void 0), h(), i();
925
+ q(void 0), h(), i();
926
926
  },
927
927
  children: N || L ? /* @__PURE__ */ s(
928
928
  U,
@@ -938,7 +938,7 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
938
938
  }
939
939
  ),
940
940
  /* @__PURE__ */ s(
941
- Q,
941
+ G,
942
942
  {
943
943
  type: "submit",
944
944
  variant: "primary",
@@ -961,8 +961,8 @@ const J = /* @__PURE__ */ Ee(_e), Ae = ({
961
961
  }
962
962
  )
963
963
  ] }),
964
- p("templateType")?.id === "2" && /* @__PURE__ */ s(G, { children: /* @__PURE__ */ s(q, { md: 12, children: /* @__PURE__ */ s(
965
- Y,
964
+ p("templateType")?.id === "2" && /* @__PURE__ */ s(z, { children: /* @__PURE__ */ s($, { md: 12, children: /* @__PURE__ */ s(
965
+ W,
966
966
  {
967
967
  className: "mt-3",
968
968
  label: "Subject",
@@ -354,8 +354,8 @@
354
354
  </div>\r
355
355
  </body>\r
356
356
  </html>\r
357
- `,U=c.createContext(void 0),Z=({children:t,configs:s})=>{const[i,o]=c.useState(s.clientId),[r,e]=c.useState(s.apiKey),[l,a]=c.useState(s.enerexIdentifier),[u,v]=c.useState(s.userName),[b,x]=c.useState(s.projectId),C=g=>{e(g.apiKey),o(g.clientId),x(g.projectId),a(g.enerexIdentifier),v(g.userName)};return n.jsx(U.Provider,{value:{clientId:i,apiKey:r,setConfiguration:C,enerexIdentifier:l,projectId:b,userName:u},children:t})},T=()=>{const t=c.useContext(U);if(!t)throw new Error("widgetConfig must be used within a ConfigProvider");return t},H=(t="",s)=>({get:async(r,e)=>{try{const l=await O.get(`${t}${r}`,e??s);if(l.status===200)return l.data}catch(l){throw l}},post:async(r,e,l)=>{try{const a=await O.post(`${t}${r}`,e,l??s);if(a.status===200)return a.data}catch(a){throw a}}}),j={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"},V=c.createContext({get:()=>{throw new Error("HttpClientContext.get not implemented")},post:()=>{throw new Error("HttpClientContext.post not implemented")}}),R=({children:t})=>{const{clientId:s,apiKey:i}=T(),o={headers:{client_id:s,"x-api-key":i}},{get:r,post:e}=H(j.API_BASE_URL,o);return n.jsx(V.Provider,{value:{get:r,post:e},children:t})},ee=({children:t})=>{const s=new w.QueryClient;return n.jsx(R,{children:n.jsx(w.QueryClientProvider,{client:s,children:t})})},te=t=>{const s=Array.from(new Set(t.map(o=>o.category))),i=[];return s.forEach(o=>{const r=t.filter(e=>e.category===o).map(e=>({label:e.label,value:e.value,hint:e.hint,hidden:e.hidden}));i.push({category:o,entries:r})}),i},N=()=>{const t=c.useContext(V);if(t)return t;throw new Error("useHttpClient must be used within a HttpClientProvider")},_={Template_list:"/Template/list/",Template:"/Template/GetTemplate/",MergeTags:"/Template/TemplateMergeTags/",ExcludeCategory:"/Template/GetExcludeCategories/",SaveTemplate:"/Template/save-update/",TemplateTypes:"/Template/TemplateTypes/"},ne=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useQuery({queryKey:["getTemplateTags"],queryFn:async r=>await t.get(`${_.MergeTags}${i}/${s}`)})},re=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useQuery({queryKey:["getExcludeCategory"],queryFn:async r=>await t.get(`${_.ExcludeCategory}${i}/${s}`)})},se=({templateHTML:t,className:s="",loading:i=!1})=>{const{post:o}=H(),{data:r}=ne(),{data:e}=re(),[l,a]=c.useState(t??{html:A,css:""}),{enerexIdentifier:u,projectId:v,userName:b}=T(),x="https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png",C="https://plugins.stripo.email/api/v1/auth";c.useEffect(()=>{if(r&&e&&!document.getElementById("UiEditorScript")){const y=document.createElement("script");y.id="UiEditorScript",y.type="module",y.src=j.EDITOR_SCRIPT_URL,y.onload=g,document.body.appendChild(y)}},[r,e]);const g=async()=>{window.UIEditor.initEditor(document.querySelector("#stripoEditorContainer"),{html:l.html,css:l.css,modulesExcludedCategories:e??[],forceRecreate:!0,metadata:{emailId:`${v}_${u}`,userId:"1",username:b,avatarUrl:x},locale:"en",onTokenRefreshRequest:async function(y){const m={pluginId:j.EDITOR_PLUGIN_ID,secretKey:j.EDITOR_SECRET_KEY,userId:"12",role:"user"},h=await o(C,m);h&&y(h.token)},codeEditorButtonSelector:"#codeEditor",undoButtonSelector:"#undoButton",redoButtonSelector:"#redoButton",mobileViewButtonSelector:"#mobileViewButton",desktopViewButtonSelector:"#desktopViewButton",mergeTags:te(r??[])})};return n.jsx("div",{className:"position-relative",children:n.jsxs("div",{className:`editor-container ${s}`,children:[i&&n.jsx("div",{className:"loading-overlay",children:n.jsx(p.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1"})}),n.jsx("div",{id:"externalSystemContainer"}),n.jsx("div",{id:"stripoEditorContainer"})]})})},K=({label:t,register:s,validation:i,required:o=!1,name:r,error:e,className:l="",...a})=>n.jsxs(p.Form.Group,{className:l+" mb-1",children:[t?n.jsxs(p.Form.Label,{className:"mb-3 d-block form-label",children:[t,o&&n.jsx("label",{className:"text-danger",children:"*"})]}):null,n.jsx(p.Form.Control,{name:r,type:"text",...a,isInvalid:!!(e&&e[r]),...s?s(r,{...i}):{},className:`react-select__control ${e&&e[r]&&"border border-danger"}`}),e&&e[r]?n.jsx(p.Form.Control.Feedback,{type:"invalid",children:e[r].message}):null]}),ie=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useQuery({queryKey:["getTemplatesList"],queryFn:async r=>await t.get(`${_.Template_list}${i}/${s}`)})},le=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useMutation({mutationKey:["getTemplate"],mutationFn:async({id:r})=>{if(r)return await t.get(`${_.Template}${s}/${r}/${i}`)}})},oe=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useQuery({queryKey:["getTemplateTypes"],queryFn:async r=>await t.get(`${_.TemplateTypes}${s}/${i}`)})};function ae(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var D={exports:{}};/*!
357
+ `,U=c.createContext(void 0),Q=({children:t,configs:s})=>{const[i,o]=c.useState(s.clientId),[r,e]=c.useState(s.apiKey),[l,a]=c.useState(s.enerexIdentifier),[u,v]=c.useState(s.userName),[b,x]=c.useState(s.projectId),C=g=>{e(g.apiKey),o(g.clientId),x(g.projectId),a(g.enerexIdentifier),v(g.userName)};return n.jsx(U.Provider,{value:{clientId:i,apiKey:r,setConfiguration:C,enerexIdentifier:l,projectId:b,userName:u},children:t})},T=()=>{const t=c.useContext(U);if(!t)throw new Error("widgetConfig must be used within a ConfigProvider");return t},H=(t="",s)=>({get:async(r,e)=>{try{const l=await O.get(`${t}${r}`,e??s);if(l.status===200)return l.data}catch(l){throw l}},post:async(r,e,l)=>{try{const a=await O.post(`${t}${r}`,e,l??s);if(a.status===200)return a.data}catch(a){throw a}}}),j={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"},V=c.createContext({get:()=>{throw new Error("HttpClientContext.get not implemented")},post:()=>{throw new Error("HttpClientContext.post not implemented")}}),Z=({children:t})=>{const{clientId:s,apiKey:i}=T(),o={headers:{client_id:s,"x-api-key":i}},{get:r,post:e}=H(j.API_BASE_URL,o);return n.jsx(V.Provider,{value:{get:r,post:e},children:t})},R=({children:t})=>{const s=new w.QueryClient;return n.jsx(Z,{children:n.jsx(w.QueryClientProvider,{client:s,children:t})})},ee=t=>{const s=Array.from(new Set(t.map(o=>o.category))),i=[];return s.forEach(o=>{const r=t.filter(e=>e.category===o).map(e=>({label:e.label,value:e.value,hint:e.hint,hidden:e.hidden}));i.push({category:o,entries:r})}),i},N=()=>{const t=c.useContext(V);if(t)return t;throw new Error("useHttpClient must be used within a HttpClientProvider")},_={Template_list:"/Template/list/",Template:"/Template/GetTemplate/",MergeTags:"/Template/TemplateMergeTags/",ExcludeCategory:"/Template/GetExcludeCategories/",SaveTemplate:"/Template/save-update/",TemplateTypes:"/Template/TemplateTypes/"},te=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useQuery({queryKey:["getTemplateTags"],queryFn:async r=>await t.get(`${_.MergeTags}${i}/${s}`)})},ne=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useQuery({queryKey:["getExcludeCategory"],queryFn:async r=>await t.get(`${_.ExcludeCategory}${i}/${s}`)})},re=({templateHTML:t,className:s="",loading:i=!1})=>{const{post:o}=H(),{data:r}=te(),{data:e}=ne(),[l,a]=c.useState(t??{html:A,css:""}),{enerexIdentifier:u,projectId:v,userName:b}=T(),x="https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png",C="https://plugins.stripo.email/api/v1/auth";c.useEffect(()=>{if(r&&e&&!document.getElementById("UiEditorScript")){const y=document.createElement("script");y.id="UiEditorScript",y.type="module",y.src=j.EDITOR_SCRIPT_URL,y.onload=g,document.body.appendChild(y)}},[r,e]);const g=async()=>{window.UIEditor.initEditor(document.querySelector("#stripoEditorContainer"),{html:l.html,css:l.css,modulesExcludedCategories:e??[],forceRecreate:!0,metadata:{emailId:`${v}_${u}`,userId:"1",username:b,avatarUrl:x},locale:"en",onTokenRefreshRequest:async function(y){const m={pluginId:j.EDITOR_PLUGIN_ID,secretKey:j.EDITOR_SECRET_KEY,userId:"12",role:"user"},h=await o(C,m);h&&y(h.token)},codeEditorButtonSelector:"#codeEditor",undoButtonSelector:"#undoButton",redoButtonSelector:"#redoButton",mobileViewButtonSelector:"#mobileViewButton",desktopViewButtonSelector:"#desktopViewButton",mergeTags:ee(r??[])})};return n.jsx("div",{className:"position-relative",children:n.jsxs("div",{className:`editor-container ${s}`,children:[i&&n.jsx("div",{className:"loading-overlay",children:n.jsx(p.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1"})}),n.jsx("div",{id:"externalSystemContainer"}),n.jsx("div",{id:"stripoEditorContainer"})]})})},K=({label:t,register:s,validation:i,required:o=!1,name:r,error:e,className:l="",...a})=>n.jsxs(p.Form.Group,{className:l+" mb-1",children:[t?n.jsxs(p.Form.Label,{className:"mb-3 d-block form-label",children:[t,o&&n.jsx("label",{className:"text-danger",children:"*"})]}):null,n.jsx(p.Form.Control,{name:r,type:"text",...a,isInvalid:!!(e&&e[r]),...s?s(r,{...i}):{},className:`react-select__control ${e&&e[r]&&"border border-danger"}`}),e&&e[r]?n.jsx(p.Form.Control.Feedback,{type:"invalid",children:e[r].message}):null]}),se=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useQuery({queryKey:["getTemplatesList"],queryFn:async r=>await t.get(`${_.Template_list}${i}/${s}`)})},ie=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useMutation({mutationKey:["getTemplate"],mutationFn:async({id:r})=>{if(r)return await t.get(`${_.Template}${s}/${r}/${i}`)}})},le=()=>{const t=N(),{enerexIdentifier:s,projectId:i}=T();return w.useQuery({queryKey:["getTemplateTypes"],queryFn:async r=>await t.get(`${_.TemplateTypes}${s}/${i}`)})};function oe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var D={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 z;function de(){return z||(z=1,function(t){(function(){var s={}.hasOwnProperty;function i(){for(var e="",l=0;l<arguments.length;l++){var a=arguments[l];a&&(e=r(e,o(a)))}return e}function o(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 l="";for(var a in e)s.call(e,a)&&e[a]&&(l=r(l,a));return l}function r(e,l){return l?e?e+" "+l:e+l:e}t.exports?(i.default=i,t.exports=i):window.classNames=i})()}(D)),D.exports}var ce=de();const G=ae(ce),pe=({name:t="",control:s,options:i,multiple:o=!1,placeholder:r,validation:e,labelKey:l="name",disabled:a,isInvalid:u,value:v,onChange:b,uncontrolled:x,menuPlacement:C="auto",closeOnSelect:g=!0})=>{const y={control:m=>({...m,minHeight:"33px",borderColor:u?"var(--bs-form-invalid-border-color) !important":"var(--ct-input-border-color)",backgroundImage:u?'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:u?"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:m=>({...m,marginTop:0,width:"max-content",minWidth:"100%"}),menuPortal:m=>({...m,zIndex:9999}),multiValueRemove:m=>({...m,display:a?"none":"block"})};return x?n.jsx(M,{className:G({"is-invalid":u}),styles:y,classNamePrefix:"react-select",isMulti:o,options:i,onChange:b,placeholder:r,menuPortalTarget:document.body,value:v,getOptionLabel:typeof l=="string"?m=>m[l]:l,getOptionValue:m=>m.id,isDisabled:a,menuPlacement:C,closeMenuOnSelect:g}):n.jsx(F.Controller,{control:s,name:t,rules:e,render:({field:{onChange:m,value:h,onBlur:L}})=>n.jsx(M,{className:G({"is-invalid":u}),styles:y,classNamePrefix:"react-select",isMulti:o,options:i,onBlur:L,onChange:m,placeholder:r,menuPortalTarget:document.body,value:h,getOptionLabel:typeof l=="string"?S=>S[l]:l,getOptionValue:S=>S.id,isDisabled:a,menuPlacement:C,closeMenuOnSelect:g},h?JSON.stringify(h):"reset")})},W=({label:t,name:s,validation:i,control:o,error:r,...e})=>n.jsxs(p.Form.Group,{className:"mb-1",children:[t&&n.jsxs(p.Form.Label,{className:"mb-3 d-block form-label",children:[t," ",e.required&&n.jsx("span",{className:"text-danger",children:"*"})]}),n.jsx(pe,{control:o,options:e.options??[],validation:i,isInvalid:r&&!!r[s],name:s}),r&&r[s]?n.jsx(p.Form.Control.Feedback,{type:"invalid",children:r[s].message}):null]}),me=()=>{const t=N();w.useQueryClient();const{enerexIdentifier:s,projectId:i}=T();return w.useMutation({mutationKey:["saveTemplate"],mutationFn:async r=>(r.enerexIdentifier=s??"",r.projectId=i??"",await t.post(`${_.SaveTemplate}`,r))})},Y={id:"",name:"New (Blank)"},ue=({onSelectItem:t,templateLoading:s,onReset:i})=>{const{register:o,handleSubmit:r,clearErrors:e,setValue:l,control:a,watch:u,reset:v,formState:{errors:b}}=F.useForm({defaultValues:{templateName:"",subject:"",templateType:void 0,template:Y},mode:"onChange"}),{data:x,refetch:C,isLoading:g}=ie(),[y,m]=c.useState([]),[h,L]=c.useState(),[S,B]=c.useState(),{mutateAsync:ge,isPending:q}=le(),{mutateAsync:ye,isPending:$}=me(),{data:P,isLoading:X}=oe(),[J,he]=c.useState([]);c.useEffect(()=>{P&&he(P.map(d=>({id:`${d.id}`,name:d.name})))},[P]),c.useEffect(()=>{s(!!q)},[q]),c.useEffect(()=>{m(x??[])},[x]);const be=async d=>{if(L(d),d){if(l("templateName",d?.name),P&&P.find(I=>I.id===d.type)){const I=J.find(k=>k.id===`${d.type}`);I&&l("templateType",I)}else l("templateType",void 0);e()}const E=await ge({id:d?.id});B(E||void 0)};c.useEffect(()=>{let d=y.find(E=>E.id===u("template")?.id);be(d)},[u("template")]),c.useEffect(()=>{t(S&&h?S:void 0)},[S,h,t]);const we=d=>{window.StripoEditorApi.actionsApi.getTemplateData(async E=>{let I=d.template.id,k="";h?.type===null&&(I="",k=d.template.id);const Q={enerexIdentifier:"",projectId:"",templateId:I,templateType:d.templateType.id,name:d.templateName,html:E.html,css:E.css,subject:d?.subject??"",parent_id:k};console.log("request",Q),await ye(Q)&&(e(),v(),C())})};return n.jsx(p.Card,{className:"border border-0 text-start",children:n.jsx(p.Card.Body,{className:"pe-0 ps-2",children:n.jsx("form",{onSubmit:r(we),children:n.jsxs("div",{className:"template-list-container gap-3",children:[n.jsxs(p.Row,{children:[n.jsx(p.Col,{md:3,children:n.jsx(W,{label:"Type",control:a,error:b,options:J,required:!0,validation:{required:{value:!0,message:"Template Type is required"}},...o("templateType")})}),n.jsx(p.Col,{md:3,children:n.jsx(W,{label:"Template",control:a,error:b,options:[Y,...y.filter(d=>d.type?.toString()===u("templateType")?.id||d.type===null).map(d=>({id:d.id,name:d.name}))],required:!1,...o("template")})}),n.jsx(p.Col,{md:3,children:n.jsx(K,{label:"Name",register:o,error:b,required:!0,name:"templateName",validation:{required:{value:!0,message:"Template Name is required"}}})}),n.jsxs(p.Col,{md:3,className:"d-flex align-items-end justify-content-end gap-2 mb-3",children:[n.jsx(p.Button,{style:{width:"70px"},variant:"primary",disabled:g||q||$||X,onClick:()=>{L(void 0),v(),i()},children:q||$?n.jsx(p.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:n.jsx("span",{className:"visually-hidden",children:"Loading..."})}):"Clear"}),n.jsx(p.Button,{type:"submit",variant:"primary",style:{width:"80px"},disabled:g||q||$||X,children:q||$?n.jsx(p.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:n.jsx("span",{className:"visually-hidden",children:"Loading..."})}):(h?.id??"")===""?"Save":(h?.projectId??"")===0?"Save as":"Save"})]})]}),u("templateType")?.id==="2"&&n.jsx(p.Row,{children:n.jsx(p.Col,{md:12,children:n.jsx(K,{className:"mt-3",label:"Subject",register:o,error:b,required:!1,name:"subject"})})})]})})})})},fe=({config:t})=>{const[s,i]=c.useState(),[o,r]=c.useState(!1),e=a=>{i(a),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(a?.html??A,a?.css??"","")},l=()=>{r(!1),i(void 0),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(A,"","")};return n.jsx(Z,{configs:t,children:n.jsx(ee,{children:n.jsxs("div",{className:"root-widget",children:[n.jsx(ue,{templateLoading:r,onSelectItem:e,onReset:l}),n.jsx(se,{templateHTML:{css:s?.css??"",html:s?.html??A},loading:o,className:"col-span-5"})]})})})};f.EditorWidget=fe,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
361
+ */var z;function ae(){return z||(z=1,function(t){(function(){var s={}.hasOwnProperty;function i(){for(var e="",l=0;l<arguments.length;l++){var a=arguments[l];a&&(e=r(e,o(a)))}return e}function o(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 l="";for(var a in e)s.call(e,a)&&e[a]&&(l=r(l,a));return l}function r(e,l){return l?e?e+" "+l:e+l:e}t.exports?(i.default=i,t.exports=i):window.classNames=i})()}(D)),D.exports}var de=ae();const G=oe(de),ce=({name:t="",control:s,options:i,multiple:o=!1,placeholder:r,validation:e,labelKey:l="name",disabled:a,isInvalid:u,value:v,onChange:b,uncontrolled:x,menuPlacement:C="auto",closeOnSelect:g=!0})=>{const y={control:m=>({...m,minHeight:"33px",borderColor:u?"var(--bs-form-invalid-border-color) !important":"var(--ct-input-border-color)",backgroundImage:u?'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:u?"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:m=>({...m,marginTop:0,width:"max-content",minWidth:"100%"}),menuPortal:m=>({...m,zIndex:9999}),multiValueRemove:m=>({...m,display:a?"none":"block"})};return x?n.jsx(M,{className:G({"is-invalid":u}),styles:y,classNamePrefix:"react-select",isMulti:o,options:i,onChange:b,placeholder:r,menuPortalTarget:document.body,value:v,getOptionLabel:typeof l=="string"?m=>m[l]:l,getOptionValue:m=>m.id,isDisabled:a,menuPlacement:C,closeMenuOnSelect:g}):n.jsx(F.Controller,{control:s,name:t,rules:e,render:({field:{onChange:m,value:h,onBlur:L}})=>n.jsx(M,{className:G({"is-invalid":u}),styles:y,classNamePrefix:"react-select",isMulti:o,options:i,onBlur:L,onChange:m,placeholder:r,menuPortalTarget:document.body,value:h,getOptionLabel:typeof l=="string"?S=>S[l]:l,getOptionValue:S=>S.id,isDisabled:a,menuPlacement:C,closeMenuOnSelect:g},h?JSON.stringify(h):"reset")})},W=({label:t,name:s,validation:i,control:o,error:r,...e})=>n.jsxs(p.Form.Group,{className:"mb-1",children:[t&&n.jsxs(p.Form.Label,{className:"mb-3 d-block form-label",children:[t," ",e.required&&n.jsx("span",{className:"text-danger",children:"*"})]}),n.jsx(ce,{control:o,options:e.options??[],validation:i,isInvalid:r&&!!r[s],name:s}),r&&r[s]?n.jsx(p.Form.Control.Feedback,{type:"invalid",children:r[s].message}):null]}),pe=()=>{const t=N();w.useQueryClient();const{enerexIdentifier:s,projectId:i}=T();return w.useMutation({mutationKey:["saveTemplate"],mutationFn:async r=>(r.enerexIdentifier=s??"",r.projectId=i??"",await t.post(`${_.SaveTemplate}`,r))})},Y={id:"",name:"New (Blank)"},me=({onSelectItem:t,templateLoading:s,onReset:i})=>{const{register:o,handleSubmit:r,clearErrors:e,setValue:l,control:a,watch:u,reset:v,formState:{errors:b}}=F.useForm({defaultValues:{templateName:"",subject:"",templateType:void 0,template:Y},mode:"onChange"}),{data:x,refetch:C,isLoading:g}=se(),[y,m]=c.useState([]),[h,L]=c.useState(),[S,B]=c.useState(),{mutateAsync:fe,isPending:q}=ie(),{mutateAsync:ge,isPending:$}=pe(),{data:P,isLoading:X}=le(),[J,ye]=c.useState([]);c.useEffect(()=>{P&&ye(P.filter(d=>d.id!==void 0).map(d=>({id:`${d.id}`,name:d.name})))},[P]),c.useEffect(()=>{s(!!q)},[q]),c.useEffect(()=>{m(x??[])},[x]);const he=async d=>{if(L(d),d){if(l("templateName",d?.name),P&&P.find(I=>I.id===d.type)){const I=J.find(k=>k.id===`${d.type}`);I&&l("templateType",I)}e()}else l("templateName","");const E=await fe({id:d?.id});B(E||void 0)};c.useEffect(()=>{let d=y.find(E=>E.id===u("template")?.id);he(d)},[u("template")]),c.useEffect(()=>{t(S&&h?S:void 0)},[S,h,t]);const be=d=>{window.StripoEditorApi.actionsApi.getTemplateData(async E=>{let I=d.template.id,k="";h?.type===null&&(I="",k=d.template.id);const we={enerexIdentifier:"",projectId:"",templateId:I,templateType:d.templateType.id,name:d.templateName,html:E.html,css:E.css,subject:d?.subject??"",parent_id:k};await ge(we)&&(e(),v(),C())})};return n.jsx(p.Card,{className:"border border-0 text-start",children:n.jsx(p.Card.Body,{className:"pe-0 ps-2",children:n.jsx("form",{onSubmit:r(be),children:n.jsxs("div",{className:"template-list-container gap-3",children:[n.jsxs(p.Row,{children:[n.jsx(p.Col,{md:3,children:n.jsx(W,{label:"Type",control:a,error:b,options:J,required:!0,validation:{required:{value:!0,message:"Template Type is required"}},...o("templateType")})}),n.jsx(p.Col,{md:3,children:n.jsx(W,{label:"Template",control:a,error:b,options:[Y,...y.filter(d=>d.type?.toString()===u("templateType")?.id||d.type===null).map(d=>({id:d.id,name:d.name}))],required:!1,...o("template")})}),n.jsx(p.Col,{md:3,children:n.jsx(K,{label:"Name",register:o,error:b,required:!0,name:"templateName",validation:{required:{value:!0,message:"Template Name is required"}}})}),n.jsxs(p.Col,{md:3,className:"d-flex align-items-end justify-content-end gap-2 mb-3",children:[n.jsx(p.Button,{style:{width:"70px"},variant:"primary",disabled:g||q||$||X,onClick:()=>{L(void 0),v(),i()},children:q||$?n.jsx(p.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:n.jsx("span",{className:"visually-hidden",children:"Loading..."})}):"Clear"}),n.jsx(p.Button,{type:"submit",variant:"primary",style:{width:"80px"},disabled:g||q||$||X,children:q||$?n.jsx(p.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:n.jsx("span",{className:"visually-hidden",children:"Loading..."})}):(h?.id??"")===""?"Save":(h?.projectId??"")===0?"Save as":"Save"})]})]}),u("templateType")?.id==="2"&&n.jsx(p.Row,{children:n.jsx(p.Col,{md:12,children:n.jsx(K,{className:"mt-3",label:"Subject",register:o,error:b,required:!1,name:"subject"})})})]})})})})},ue=({config:t})=>{const[s,i]=c.useState(),[o,r]=c.useState(!1),e=a=>{i(a),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(a?.html??A,a?.css??"","")},l=()=>{r(!1),i(void 0),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(A,"","")};return n.jsx(Q,{configs:t,children:n.jsx(R,{children:n.jsxs("div",{className:"root-widget",children:[n.jsx(me,{templateLoading:r,onSelectItem:e,onReset:l}),n.jsx(re,{templateHTML:{css:s?.css??"",html:s?.html??A},loading:o,className:"col-span-5"})]})})})};f.EditorWidget=ue,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enerex/template-studio",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
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",