@enerex/template-studio 1.1.34 → 1.1.35
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,11 +1,11 @@
|
|
|
1
|
-
import { jsx as i, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { QueryClient as _e, QueryClientProvider as Ne, useQuery as
|
|
4
|
-
import
|
|
5
|
-
import { Spinner as
|
|
1
|
+
import { jsx as i, jsxs as P, Fragment as Ee } from "react/jsx-runtime";
|
|
2
|
+
import R, { useContext as ce, useState as I, useRef as Ie, useEffect as E } from "react";
|
|
3
|
+
import { QueryClient as _e, QueryClientProvider as Ne, useQuery as V, useMutation as pe, useQueryClient as Pe } from "@tanstack/react-query";
|
|
4
|
+
import te from "axios";
|
|
5
|
+
import { Spinner as X, Form as D, Card as ne, Row as Ae, Col as L, Button as re } from "react-bootstrap";
|
|
6
6
|
import { Controller as je, useForm as Oe } from "react-hook-form";
|
|
7
|
-
import
|
|
8
|
-
const
|
|
7
|
+
import ie, { components as Le } from "react-select";
|
|
8
|
+
const z = `<!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
|
|
11
11
|
xmlns:o="urn:schemas-microsoft-com:office:office"\r
|
|
@@ -361,101 +361,101 @@ const F = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
361
361
|
</div>\r
|
|
362
362
|
</body>\r
|
|
363
363
|
</html>\r
|
|
364
|
-
`,
|
|
364
|
+
`, me = R.createContext(
|
|
365
365
|
void 0
|
|
366
366
|
), Re = ({
|
|
367
367
|
children: e,
|
|
368
368
|
configs: r
|
|
369
369
|
}) => {
|
|
370
|
-
const [
|
|
370
|
+
const [l, o] = R.useState(r.clientId), [n, t] = R.useState(r.apiKey), [s, d] = R.useState(
|
|
371
371
|
r.enerexIdentifier
|
|
372
|
-
), [p,
|
|
373
|
-
t(
|
|
372
|
+
), [p, C] = R.useState(r.projectId), [j, h] = R.useState(r.userEmail), v = (b) => {
|
|
373
|
+
t(b.apiKey), o(b.clientId), C(b.projectId), d(b.enerexIdentifier), h(b.userEmail);
|
|
374
374
|
};
|
|
375
375
|
return /* @__PURE__ */ i(
|
|
376
|
-
|
|
376
|
+
me.Provider,
|
|
377
377
|
{
|
|
378
378
|
value: {
|
|
379
|
-
clientId:
|
|
379
|
+
clientId: l,
|
|
380
380
|
apiKey: n,
|
|
381
|
-
setConfiguration:
|
|
382
|
-
enerexIdentifier:
|
|
381
|
+
setConfiguration: v,
|
|
382
|
+
enerexIdentifier: s,
|
|
383
383
|
projectId: p,
|
|
384
|
-
userEmail:
|
|
384
|
+
userEmail: j
|
|
385
385
|
},
|
|
386
386
|
children: e
|
|
387
387
|
}
|
|
388
388
|
);
|
|
389
|
-
},
|
|
390
|
-
const e =
|
|
389
|
+
}, A = () => {
|
|
390
|
+
const e = ce(me);
|
|
391
391
|
if (!e)
|
|
392
392
|
throw new Error("widgetConfig must be used within a ConfigProvider");
|
|
393
393
|
return e;
|
|
394
|
-
},
|
|
394
|
+
}, ue = (e = "", r) => ({ get: async (n, t) => {
|
|
395
395
|
try {
|
|
396
|
-
const
|
|
396
|
+
const s = await te.get(
|
|
397
397
|
`${e}${n}`,
|
|
398
398
|
t ?? r
|
|
399
399
|
);
|
|
400
|
-
if (
|
|
401
|
-
return
|
|
402
|
-
} catch (
|
|
403
|
-
throw
|
|
400
|
+
if (s.status === 200)
|
|
401
|
+
return s.data;
|
|
402
|
+
} catch (s) {
|
|
403
|
+
throw s;
|
|
404
404
|
}
|
|
405
|
-
}, post: async (n, t,
|
|
405
|
+
}, post: async (n, t, s) => {
|
|
406
406
|
try {
|
|
407
|
-
const d = await
|
|
407
|
+
const d = await te.post(
|
|
408
408
|
`${e}${n}`,
|
|
409
409
|
t,
|
|
410
|
-
|
|
410
|
+
s ?? r
|
|
411
411
|
);
|
|
412
412
|
if (d.status === 200)
|
|
413
413
|
return d.data;
|
|
414
414
|
} catch (d) {
|
|
415
415
|
throw d;
|
|
416
416
|
}
|
|
417
|
-
} }),
|
|
417
|
+
} }), G = {
|
|
418
418
|
EDITOR_SCRIPT_URL: "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",
|
|
419
419
|
EDITOR_PLUGIN_ID: "1afdc3161ec7409a8627a1c8561d45f5",
|
|
420
420
|
EDITOR_SECRET_KEY: "54ba748ed7e94f2e929555783acb03da",
|
|
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
|
-
},
|
|
424
|
+
}, fe = R.createContext({
|
|
425
425
|
get: () => {
|
|
426
426
|
throw new Error("HttpClientContext.get not implemented");
|
|
427
427
|
},
|
|
428
428
|
post: () => {
|
|
429
429
|
throw new Error("HttpClientContext.post not implemented");
|
|
430
430
|
}
|
|
431
|
-
}),
|
|
432
|
-
const { clientId: r, apiKey:
|
|
431
|
+
}), De = ({ children: e }) => {
|
|
432
|
+
const { clientId: r, apiKey: l } = A(), o = {
|
|
433
433
|
headers: {
|
|
434
434
|
client_id: r,
|
|
435
|
-
"x-api-key":
|
|
435
|
+
"x-api-key": l
|
|
436
436
|
}
|
|
437
|
-
}, { get: n, post: t } =
|
|
438
|
-
return /* @__PURE__ */ i(
|
|
439
|
-
},
|
|
437
|
+
}, { get: n, post: t } = ue(G.API_BASE_URL, o);
|
|
438
|
+
return /* @__PURE__ */ i(fe.Provider, { value: { get: n, post: t }, children: e });
|
|
439
|
+
}, qe = ({ children: e }) => {
|
|
440
440
|
const r = new _e();
|
|
441
|
-
return /* @__PURE__ */ i(
|
|
441
|
+
return /* @__PURE__ */ i(De, { children: /* @__PURE__ */ i(Ne, { client: r, children: e }) });
|
|
442
442
|
}, $e = (e) => {
|
|
443
|
-
const r = Array.from(new Set(e.map((
|
|
444
|
-
return r.forEach((
|
|
445
|
-
const n = e.filter((t) => t.category ===
|
|
443
|
+
const r = Array.from(new Set(e.map((o) => o.category))), l = [];
|
|
444
|
+
return r.forEach((o) => {
|
|
445
|
+
const n = e.filter((t) => t.category === o).map((t) => ({
|
|
446
446
|
label: t.label,
|
|
447
447
|
value: t.value,
|
|
448
448
|
hint: t.hint,
|
|
449
449
|
hidden: t.hidden
|
|
450
450
|
}));
|
|
451
|
-
|
|
452
|
-
}),
|
|
453
|
-
},
|
|
454
|
-
const e =
|
|
451
|
+
l.push({ category: o, entries: n });
|
|
452
|
+
}), l;
|
|
453
|
+
}, B = () => {
|
|
454
|
+
const e = ce(fe);
|
|
455
455
|
if (e)
|
|
456
456
|
return e;
|
|
457
457
|
throw new Error("useHttpClient must be used within a HttpClientProvider");
|
|
458
|
-
},
|
|
458
|
+
}, M = {
|
|
459
459
|
Template_list: "/Template/list/",
|
|
460
460
|
Template: "/Template/GetTemplate/",
|
|
461
461
|
MergeTags: "/Template/TemplateMergeTags/",
|
|
@@ -463,33 +463,33 @@ const F = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
463
463
|
SaveTemplate: "/Template/save-update/",
|
|
464
464
|
TemplateTypes: "/Template/TemplateTypes/"
|
|
465
465
|
}, ke = () => {
|
|
466
|
-
const e =
|
|
467
|
-
return
|
|
466
|
+
const e = B(), { enerexIdentifier: r, projectId: l } = A();
|
|
467
|
+
return V({
|
|
468
468
|
queryKey: ["getTemplateTags"],
|
|
469
469
|
queryFn: async (n) => await e.get(
|
|
470
|
-
`${
|
|
470
|
+
`${M.MergeTags}${l}/${r}`
|
|
471
471
|
)
|
|
472
472
|
});
|
|
473
473
|
}, Be = () => {
|
|
474
|
-
const e =
|
|
475
|
-
return
|
|
474
|
+
const e = B(), { enerexIdentifier: r, projectId: l } = A();
|
|
475
|
+
return V({
|
|
476
476
|
queryKey: ["getExcludeCategory"],
|
|
477
477
|
queryFn: async (n) => await e.get(
|
|
478
|
-
`${
|
|
478
|
+
`${M.ExcludeCategory}${l}/${r}`
|
|
479
479
|
)
|
|
480
480
|
});
|
|
481
481
|
}, Me = ({
|
|
482
482
|
templateHTML: e,
|
|
483
483
|
className: r = "",
|
|
484
|
-
loading:
|
|
484
|
+
loading: l = !1
|
|
485
485
|
}) => {
|
|
486
|
-
const { post:
|
|
487
|
-
e ?? { html:
|
|
488
|
-
), { userEmail: p } =
|
|
489
|
-
|
|
490
|
-
(async () => (await
|
|
486
|
+
const { post: o } = ue(), { data: n } = ke(), { data: t } = Be(), [s, d] = I(
|
|
487
|
+
e ?? { html: z, css: "" }
|
|
488
|
+
), { userEmail: p } = A(), C = Ie(null), j = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", h = "https://plugins.stripo.email/api/v1/auth";
|
|
489
|
+
E(() => {
|
|
490
|
+
(async () => (await v(), n && t && await b(G.EDITOR_SCRIPT_URL)))();
|
|
491
491
|
}, [n, t]);
|
|
492
|
-
async function
|
|
492
|
+
async function v() {
|
|
493
493
|
window.Zone || await new Promise((c, g) => {
|
|
494
494
|
const f = document.createElement("script");
|
|
495
495
|
f.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
|
|
@@ -497,18 +497,18 @@ const F = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
497
497
|
y && f.setAttribute("nonce", y), f.onload = () => c(), f.onerror = () => g(new Error("Failed to load zone.js")), document.head.appendChild(f);
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
|
-
async function
|
|
500
|
+
async function b(c) {
|
|
501
501
|
let g = document.getElementById(
|
|
502
502
|
"UiEditorScript"
|
|
503
503
|
);
|
|
504
504
|
g || (g = document.createElement("script"), g.id = "UiEditorScript", g.src = c, g.onload = async () => {
|
|
505
|
-
await
|
|
505
|
+
await w();
|
|
506
506
|
}, document.body.appendChild(g)), await new Promise(
|
|
507
507
|
(f) => g.addEventListener("load", () => f(), { once: !0 })
|
|
508
508
|
);
|
|
509
509
|
}
|
|
510
|
-
const
|
|
511
|
-
const c =
|
|
510
|
+
const w = async () => {
|
|
511
|
+
const c = C.current;
|
|
512
512
|
if (!c) {
|
|
513
513
|
console.error("Missing #stripoEditorContainer in DOM");
|
|
514
514
|
return;
|
|
@@ -518,28 +518,28 @@ const F = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
518
518
|
return;
|
|
519
519
|
}
|
|
520
520
|
const g = {
|
|
521
|
-
html:
|
|
522
|
-
css:
|
|
521
|
+
html: s.html,
|
|
522
|
+
css: s.css,
|
|
523
523
|
modulesExcludedCategories: t ?? [],
|
|
524
524
|
forceRecreate: !0,
|
|
525
525
|
metadata: {
|
|
526
526
|
emailId: p,
|
|
527
527
|
userId: "1",
|
|
528
528
|
// username: userName,
|
|
529
|
-
avatarUrl:
|
|
529
|
+
avatarUrl: j
|
|
530
530
|
},
|
|
531
531
|
locale: "en",
|
|
532
532
|
onTokenRefreshRequest: async (f) => {
|
|
533
533
|
const y = {
|
|
534
|
-
pluginId:
|
|
535
|
-
secretKey:
|
|
534
|
+
pluginId: G.EDITOR_PLUGIN_ID,
|
|
535
|
+
secretKey: G.EDITOR_SECRET_KEY,
|
|
536
536
|
userId: p,
|
|
537
537
|
role: "user"
|
|
538
|
-
},
|
|
539
|
-
|
|
538
|
+
}, _ = await o(
|
|
539
|
+
h,
|
|
540
540
|
y
|
|
541
541
|
);
|
|
542
|
-
|
|
542
|
+
_?.token && f(_.token);
|
|
543
543
|
},
|
|
544
544
|
mergeTags: $e(n ?? [])
|
|
545
545
|
};
|
|
@@ -553,9 +553,9 @@ const F = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
553
553
|
c.ownerDocument && c.getRootNode() instanceof ShadowRoot && c.getRootNode().querySelector(y) && (g[f] = y);
|
|
554
554
|
await window.UIEditor.initEditor(c, g);
|
|
555
555
|
};
|
|
556
|
-
return /* @__PURE__ */ i("div", { className: "position-relative", children: /* @__PURE__ */
|
|
557
|
-
|
|
558
|
-
|
|
556
|
+
return /* @__PURE__ */ i("div", { className: "position-relative", children: /* @__PURE__ */ P("div", { className: `editor-container ${r}`, children: [
|
|
557
|
+
l && /* @__PURE__ */ i("div", { className: "loading-overlay", children: /* @__PURE__ */ i(
|
|
558
|
+
X,
|
|
559
559
|
{
|
|
560
560
|
animation: "border",
|
|
561
561
|
style: { width: "11px", height: "11px" },
|
|
@@ -565,129 +565,129 @@ const F = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
565
565
|
}
|
|
566
566
|
) }),
|
|
567
567
|
/* @__PURE__ */ i("div", { id: "externalSystemContainer" }),
|
|
568
|
-
/* @__PURE__ */ i("div", { id: "stripoEditorContainer", ref:
|
|
568
|
+
/* @__PURE__ */ i("div", { id: "stripoEditorContainer", ref: C })
|
|
569
569
|
] }) });
|
|
570
|
-
},
|
|
570
|
+
}, se = ({
|
|
571
571
|
label: e,
|
|
572
572
|
register: r,
|
|
573
|
-
validation:
|
|
574
|
-
required:
|
|
573
|
+
validation: l,
|
|
574
|
+
required: o = !1,
|
|
575
575
|
name: n,
|
|
576
576
|
error: t,
|
|
577
|
-
className:
|
|
577
|
+
className: s = "",
|
|
578
578
|
...d
|
|
579
|
-
}) => /* @__PURE__ */
|
|
580
|
-
e ? /* @__PURE__ */
|
|
579
|
+
}) => /* @__PURE__ */ P(D.Group, { className: s + " mb-1", children: [
|
|
580
|
+
e ? /* @__PURE__ */ P(D.Label, { className: "mb-3 d-block form-label", children: [
|
|
581
581
|
e,
|
|
582
|
-
|
|
582
|
+
o && /* @__PURE__ */ i("label", { className: "text-danger", children: "*" })
|
|
583
583
|
] }) : null,
|
|
584
584
|
/* @__PURE__ */ i(
|
|
585
|
-
|
|
585
|
+
D.Control,
|
|
586
586
|
{
|
|
587
587
|
name: n,
|
|
588
588
|
type: "text",
|
|
589
589
|
...d,
|
|
590
590
|
isInvalid: !!(t && t[n]),
|
|
591
591
|
...r ? r(n, {
|
|
592
|
-
...
|
|
592
|
+
...l
|
|
593
593
|
}) : {},
|
|
594
594
|
className: `react-select__control ${t && t[n] && "border border-danger"}`
|
|
595
595
|
}
|
|
596
596
|
),
|
|
597
|
-
t && t[n] ? /* @__PURE__ */ i(
|
|
597
|
+
t && t[n] ? /* @__PURE__ */ i(D.Control.Feedback, { type: "invalid", children: t[n].message }) : null
|
|
598
598
|
] }), Ue = () => {
|
|
599
|
-
const e =
|
|
600
|
-
return
|
|
599
|
+
const e = B(), { enerexIdentifier: r, projectId: l } = A();
|
|
600
|
+
return V({
|
|
601
601
|
queryKey: ["getTemplatesList"],
|
|
602
602
|
queryFn: async (n) => await e.get(
|
|
603
|
-
`${
|
|
603
|
+
`${M.Template_list}${l}/${r}`
|
|
604
604
|
)
|
|
605
605
|
});
|
|
606
606
|
};
|
|
607
|
-
function
|
|
608
|
-
return e.sort((r,
|
|
607
|
+
function W(e) {
|
|
608
|
+
return e.sort((r, l) => r.name.localeCompare(l.name));
|
|
609
609
|
}
|
|
610
610
|
function Fe(e) {
|
|
611
|
-
const r = /* @__PURE__ */ new Map(),
|
|
611
|
+
const r = /* @__PURE__ */ new Map(), l = [];
|
|
612
612
|
e.forEach((t) => r.set(t.id, t));
|
|
613
|
-
let
|
|
614
|
-
for (;
|
|
615
|
-
|
|
616
|
-
const t =
|
|
617
|
-
|
|
613
|
+
let o = e.filter((t) => t.parent_id === 0), n = 0;
|
|
614
|
+
for (; o.length > 0; ) {
|
|
615
|
+
l.push({ level: n, data: o });
|
|
616
|
+
const t = o.map((d) => d.id);
|
|
617
|
+
o = e.filter(
|
|
618
618
|
(d) => t.includes(d.parent_id)
|
|
619
619
|
), n++;
|
|
620
620
|
}
|
|
621
|
-
return
|
|
621
|
+
return l;
|
|
622
622
|
}
|
|
623
|
-
function
|
|
624
|
-
const
|
|
625
|
-
return
|
|
623
|
+
function Y(e, r) {
|
|
624
|
+
const o = Fe(e).find((n) => n.level === r);
|
|
625
|
+
return o ? o.data : [];
|
|
626
626
|
}
|
|
627
627
|
const He = () => {
|
|
628
|
-
const e =
|
|
629
|
-
return
|
|
628
|
+
const e = B(), { enerexIdentifier: r, projectId: l } = A();
|
|
629
|
+
return pe({
|
|
630
630
|
mutationKey: ["getTemplate"],
|
|
631
631
|
mutationFn: async ({ id: n }) => {
|
|
632
632
|
if (n)
|
|
633
633
|
return await e.get(
|
|
634
|
-
`${
|
|
634
|
+
`${M.Template}${r}/${n}/${l}`
|
|
635
635
|
);
|
|
636
636
|
}
|
|
637
637
|
});
|
|
638
638
|
}, ze = () => {
|
|
639
|
-
const e =
|
|
640
|
-
return
|
|
639
|
+
const e = B(), { enerexIdentifier: r, projectId: l } = A();
|
|
640
|
+
return V({
|
|
641
641
|
queryKey: ["getTemplateTypes"],
|
|
642
642
|
queryFn: async (n) => await e.get(
|
|
643
|
-
`${
|
|
643
|
+
`${M.TemplateTypes}${r}/${l}`
|
|
644
644
|
)
|
|
645
645
|
});
|
|
646
646
|
};
|
|
647
647
|
function Ge(e) {
|
|
648
648
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
649
649
|
}
|
|
650
|
-
var
|
|
650
|
+
var J = { exports: {} };
|
|
651
651
|
/*!
|
|
652
652
|
Copyright (c) 2018 Jed Watson.
|
|
653
653
|
Licensed under the MIT License (MIT), see
|
|
654
654
|
http://jedwatson.github.io/classnames
|
|
655
655
|
*/
|
|
656
|
-
var
|
|
656
|
+
var le;
|
|
657
657
|
function Ve() {
|
|
658
|
-
return
|
|
658
|
+
return le || (le = 1, function(e) {
|
|
659
659
|
(function() {
|
|
660
660
|
var r = {}.hasOwnProperty;
|
|
661
|
-
function
|
|
662
|
-
for (var t = "",
|
|
663
|
-
var d = arguments[
|
|
664
|
-
d && (t = n(t,
|
|
661
|
+
function l() {
|
|
662
|
+
for (var t = "", s = 0; s < arguments.length; s++) {
|
|
663
|
+
var d = arguments[s];
|
|
664
|
+
d && (t = n(t, o(d)));
|
|
665
665
|
}
|
|
666
666
|
return t;
|
|
667
667
|
}
|
|
668
|
-
function
|
|
668
|
+
function o(t) {
|
|
669
669
|
if (typeof t == "string" || typeof t == "number")
|
|
670
670
|
return t;
|
|
671
671
|
if (typeof t != "object")
|
|
672
672
|
return "";
|
|
673
673
|
if (Array.isArray(t))
|
|
674
|
-
return
|
|
674
|
+
return l.apply(null, t);
|
|
675
675
|
if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]"))
|
|
676
676
|
return t.toString();
|
|
677
|
-
var
|
|
677
|
+
var s = "";
|
|
678
678
|
for (var d in t)
|
|
679
|
-
r.call(t, d) && t[d] && (
|
|
680
|
-
return
|
|
679
|
+
r.call(t, d) && t[d] && (s = n(s, d));
|
|
680
|
+
return s;
|
|
681
681
|
}
|
|
682
|
-
function n(t,
|
|
683
|
-
return
|
|
682
|
+
function n(t, s) {
|
|
683
|
+
return s ? t ? t + " " + s : t + s : t;
|
|
684
684
|
}
|
|
685
|
-
e.exports ? (
|
|
685
|
+
e.exports ? (l.default = l, e.exports = l) : window.classNames = l;
|
|
686
686
|
})();
|
|
687
|
-
}(
|
|
687
|
+
}(J)), J.exports;
|
|
688
688
|
}
|
|
689
689
|
var Ke = Ve();
|
|
690
|
-
const oe = /* @__PURE__ */ Ge(Ke),
|
|
690
|
+
const oe = /* @__PURE__ */ Ge(Ke), ae = (e) => e.data.isSeparator ? /* @__PURE__ */ i("div", { style: { padding: 0, margin: "2px 0" }, children: /* @__PURE__ */ i(
|
|
691
691
|
"hr",
|
|
692
692
|
{
|
|
693
693
|
style: {
|
|
@@ -700,20 +700,20 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
700
700
|
) }) : /* @__PURE__ */ i(Le.Option, { ...e }), Qe = ({
|
|
701
701
|
name: e = "",
|
|
702
702
|
control: r,
|
|
703
|
-
options:
|
|
704
|
-
multiple:
|
|
703
|
+
options: l,
|
|
704
|
+
multiple: o = !1,
|
|
705
705
|
placeholder: n,
|
|
706
706
|
validation: t,
|
|
707
|
-
labelKey:
|
|
707
|
+
labelKey: s = "name",
|
|
708
708
|
disabled: d,
|
|
709
709
|
isInvalid: p,
|
|
710
|
-
value:
|
|
711
|
-
onChange:
|
|
712
|
-
uncontrolled:
|
|
713
|
-
menuPlacement:
|
|
714
|
-
closeOnSelect:
|
|
710
|
+
value: C,
|
|
711
|
+
onChange: j,
|
|
712
|
+
uncontrolled: h,
|
|
713
|
+
menuPlacement: v = "auto",
|
|
714
|
+
closeOnSelect: b = !0
|
|
715
715
|
}) => {
|
|
716
|
-
const
|
|
716
|
+
const w = {
|
|
717
717
|
control: (c) => ({
|
|
718
718
|
...c,
|
|
719
719
|
minHeight: "33px",
|
|
@@ -751,27 +751,27 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
751
751
|
display: d ? "none" : "block"
|
|
752
752
|
})
|
|
753
753
|
};
|
|
754
|
-
return
|
|
755
|
-
|
|
754
|
+
return h ? /* @__PURE__ */ i(
|
|
755
|
+
ie,
|
|
756
756
|
{
|
|
757
|
-
components: { Option:
|
|
757
|
+
components: { Option: ae },
|
|
758
758
|
isOptionDisabled: (c) => !!c.isSeparator,
|
|
759
759
|
className: oe({
|
|
760
760
|
"is-invalid": p
|
|
761
761
|
}),
|
|
762
|
-
styles:
|
|
762
|
+
styles: w,
|
|
763
763
|
classNamePrefix: "react-select",
|
|
764
|
-
isMulti:
|
|
765
|
-
options:
|
|
766
|
-
onChange:
|
|
764
|
+
isMulti: o,
|
|
765
|
+
options: l,
|
|
766
|
+
onChange: j,
|
|
767
767
|
placeholder: n,
|
|
768
768
|
menuPortalTarget: document.body,
|
|
769
|
-
value:
|
|
770
|
-
getOptionLabel: typeof
|
|
769
|
+
value: C,
|
|
770
|
+
getOptionLabel: typeof s == "string" ? (c) => c[s] : s,
|
|
771
771
|
getOptionValue: (c) => c.id,
|
|
772
772
|
isDisabled: d,
|
|
773
|
-
menuPlacement:
|
|
774
|
-
closeMenuOnSelect:
|
|
773
|
+
menuPlacement: v,
|
|
774
|
+
closeMenuOnSelect: b
|
|
775
775
|
}
|
|
776
776
|
) : /* @__PURE__ */ i(
|
|
777
777
|
je,
|
|
@@ -780,41 +780,41 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
780
780
|
name: e,
|
|
781
781
|
rules: t,
|
|
782
782
|
render: ({ field: { onChange: c, value: g, onBlur: f } }) => /* @__PURE__ */ i(
|
|
783
|
-
|
|
783
|
+
ie,
|
|
784
784
|
{
|
|
785
|
-
components: { Option:
|
|
785
|
+
components: { Option: ae },
|
|
786
786
|
isOptionDisabled: (y) => !!y.isSeparator,
|
|
787
787
|
className: oe({
|
|
788
788
|
"is-invalid": p
|
|
789
789
|
}),
|
|
790
|
-
styles:
|
|
790
|
+
styles: w,
|
|
791
791
|
classNamePrefix: "react-select",
|
|
792
|
-
isMulti:
|
|
793
|
-
options:
|
|
792
|
+
isMulti: o,
|
|
793
|
+
options: l,
|
|
794
794
|
onBlur: f,
|
|
795
795
|
onChange: c,
|
|
796
796
|
placeholder: n,
|
|
797
797
|
menuPortalTarget: document.body,
|
|
798
798
|
value: g,
|
|
799
|
-
getOptionLabel: typeof
|
|
799
|
+
getOptionLabel: typeof s == "string" ? (y) => y[s] : s,
|
|
800
800
|
getOptionValue: (y) => y.id,
|
|
801
801
|
isDisabled: d,
|
|
802
|
-
menuPlacement:
|
|
803
|
-
closeMenuOnSelect:
|
|
802
|
+
menuPlacement: v,
|
|
803
|
+
closeMenuOnSelect: b
|
|
804
804
|
},
|
|
805
805
|
g ? JSON.stringify(g) : "reset"
|
|
806
806
|
)
|
|
807
807
|
}
|
|
808
808
|
);
|
|
809
|
-
},
|
|
809
|
+
}, H = ({
|
|
810
810
|
label: e,
|
|
811
811
|
name: r,
|
|
812
|
-
validation:
|
|
813
|
-
control:
|
|
812
|
+
validation: l,
|
|
813
|
+
control: o,
|
|
814
814
|
error: n,
|
|
815
815
|
...t
|
|
816
|
-
}) => /* @__PURE__ */
|
|
817
|
-
e && /* @__PURE__ */
|
|
816
|
+
}) => /* @__PURE__ */ P(D.Group, { className: "mb-1", children: [
|
|
817
|
+
e && /* @__PURE__ */ P(D.Label, { className: "mb-3 d-block form-label", children: [
|
|
818
818
|
e,
|
|
819
819
|
" ",
|
|
820
820
|
t.required && /* @__PURE__ */ i("span", { className: "text-danger", children: "*" })
|
|
@@ -822,47 +822,48 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
822
822
|
/* @__PURE__ */ i(
|
|
823
823
|
Qe,
|
|
824
824
|
{
|
|
825
|
-
control:
|
|
825
|
+
control: o,
|
|
826
|
+
disabled: t.disabled,
|
|
826
827
|
options: t.options ?? [],
|
|
827
|
-
validation:
|
|
828
|
+
validation: l,
|
|
828
829
|
isInvalid: n && !!n[r],
|
|
829
830
|
name: r
|
|
830
831
|
}
|
|
831
832
|
),
|
|
832
|
-
n && n[r] ? /* @__PURE__ */ i(
|
|
833
|
+
n && n[r] ? /* @__PURE__ */ i(D.Control.Feedback, { type: "invalid", children: n[r].message }) : null
|
|
833
834
|
] }), We = () => {
|
|
834
|
-
const e =
|
|
835
|
+
const e = B();
|
|
835
836
|
Pe();
|
|
836
|
-
const { enerexIdentifier: r, projectId:
|
|
837
|
-
return
|
|
837
|
+
const { enerexIdentifier: r, projectId: l } = A();
|
|
838
|
+
return pe({
|
|
838
839
|
mutationKey: ["saveTemplate"],
|
|
839
|
-
mutationFn: async (n) => (n.enerexIdentifier = r ?? "", n.projectId =
|
|
840
|
-
`${
|
|
840
|
+
mutationFn: async (n) => (n.enerexIdentifier = r ?? "", n.projectId = l ?? "", await e.post(
|
|
841
|
+
`${M.SaveTemplate}`,
|
|
841
842
|
n
|
|
842
843
|
))
|
|
843
844
|
});
|
|
844
|
-
},
|
|
845
|
+
}, F = {
|
|
845
846
|
id: "",
|
|
846
847
|
name: "New (Blank)"
|
|
847
|
-
},
|
|
848
|
+
}, de = {
|
|
848
849
|
id: "",
|
|
849
850
|
name: "Separator",
|
|
850
851
|
isSeparator: !0
|
|
851
852
|
}, Ye = ({
|
|
852
853
|
onSelectItem: e,
|
|
853
854
|
templateLoading: r,
|
|
854
|
-
onReset:
|
|
855
|
+
onReset: l
|
|
855
856
|
}) => {
|
|
856
857
|
const {
|
|
857
|
-
register:
|
|
858
|
+
register: o,
|
|
858
859
|
handleSubmit: n,
|
|
859
860
|
clearErrors: t,
|
|
860
|
-
setValue:
|
|
861
|
+
setValue: s,
|
|
861
862
|
control: d,
|
|
862
863
|
watch: p,
|
|
863
|
-
reset:
|
|
864
|
-
setError:
|
|
865
|
-
formState: { errors:
|
|
864
|
+
reset: C,
|
|
865
|
+
setError: j,
|
|
866
|
+
formState: { errors: h }
|
|
866
867
|
} = Oe({
|
|
867
868
|
defaultValues: {
|
|
868
869
|
templateName: "",
|
|
@@ -870,184 +871,189 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
870
871
|
subTemplateType2: void 0,
|
|
871
872
|
subject: "",
|
|
872
873
|
templateType: void 0,
|
|
873
|
-
template:
|
|
874
|
+
template: F
|
|
874
875
|
},
|
|
875
876
|
mode: "onChange"
|
|
876
877
|
}), {
|
|
877
|
-
data:
|
|
878
|
-
refetch:
|
|
879
|
-
isLoading:
|
|
880
|
-
} = Ue(), [c, g] =
|
|
881
|
-
|
|
882
|
-
if (
|
|
883
|
-
let a =
|
|
884
|
-
|
|
878
|
+
data: v,
|
|
879
|
+
refetch: b,
|
|
880
|
+
isLoading: w
|
|
881
|
+
} = Ue(), [c, g] = I([]), [f, y] = I(), [_, Z] = I(), { mutateAsync: ge, isPending: x } = He(), { mutateAsync: ye, isPending: N } = We(), { data: U, isLoading: q } = ze(), [he, be] = I([]), [$, K] = I([]), [k, Q] = I([]);
|
|
882
|
+
E(() => {
|
|
883
|
+
if (U) {
|
|
884
|
+
let a = U.filter((u) => u.id != null), m = Y(a, 0);
|
|
885
|
+
be(W(m));
|
|
885
886
|
}
|
|
886
|
-
}, [
|
|
887
|
-
const
|
|
887
|
+
}, [U]);
|
|
888
|
+
const we = (a, m) => {
|
|
888
889
|
let u = [];
|
|
889
|
-
return a.forEach((
|
|
890
|
-
m.includes(
|
|
890
|
+
return a.forEach((S, T) => {
|
|
891
|
+
m.includes(T) && T !== 0 && u.push(de), u.push(S);
|
|
891
892
|
}), u;
|
|
892
893
|
};
|
|
893
|
-
|
|
894
|
-
r(!!
|
|
895
|
-
}, [
|
|
896
|
-
|
|
897
|
-
}, [
|
|
898
|
-
const
|
|
899
|
-
y(a), a && !a.readonly ? (
|
|
900
|
-
const m = await
|
|
901
|
-
|
|
894
|
+
E(() => {
|
|
895
|
+
r(!!x);
|
|
896
|
+
}, [x]), E(() => {
|
|
897
|
+
v?.sort((a, m) => a.readonly !== m.readonly ? (a.readonly ? 0 : 1) - (m.readonly ? 0 : 1) : a.name.localeCompare(m.name)), g(v ?? []);
|
|
898
|
+
}, [v]);
|
|
899
|
+
const Te = async (a) => {
|
|
900
|
+
y(a), a && !a.readonly ? (s("templateName", a?.name), t()) : (s("templateName", ""), s("subject", ""));
|
|
901
|
+
const m = await ge({ id: a?.id });
|
|
902
|
+
Z(m || void 0);
|
|
902
903
|
};
|
|
903
|
-
|
|
904
|
-
if (
|
|
905
|
-
let a =
|
|
906
|
-
|
|
907
|
-
|
|
904
|
+
E(() => {
|
|
905
|
+
if (s("template", F), p("templateType")) {
|
|
906
|
+
let a = U?.filter((u) => u.id !== void 0) ?? [], m = Y(a, 1);
|
|
907
|
+
K(
|
|
908
|
+
W(
|
|
908
909
|
m.filter(
|
|
909
910
|
(u) => u.parent_id.toString() === `${p("templateType")?.id}`
|
|
910
911
|
)
|
|
911
912
|
)
|
|
912
|
-
),
|
|
913
|
+
), s("subTemplateType", void 0), s("subTemplateType2", void 0);
|
|
913
914
|
}
|
|
914
|
-
}, [p("templateType")]),
|
|
915
|
-
if (
|
|
916
|
-
let a =
|
|
917
|
-
|
|
918
|
-
|
|
915
|
+
}, [p("templateType")]), E(() => {
|
|
916
|
+
if (s("template", F), p("subTemplateType")) {
|
|
917
|
+
let a = U?.filter((u) => u.id !== void 0) ?? [], m = Y(a, 2);
|
|
918
|
+
Q(
|
|
919
|
+
W(
|
|
919
920
|
m.filter(
|
|
920
921
|
(u) => u.parent_id.toString() === `${p("subTemplateType")?.id}`
|
|
921
922
|
)
|
|
922
923
|
)
|
|
923
|
-
),
|
|
924
|
+
), s("subTemplateType2", void 0);
|
|
924
925
|
}
|
|
925
|
-
}, [p("subTemplateType")]),
|
|
926
|
-
|
|
927
|
-
|
|
926
|
+
}, [p("subTemplateType")]), E(() => {
|
|
927
|
+
const a = ee();
|
|
928
|
+
a.length > 0 && a[0].id !== "" ? s("template", a[0]) : s("template", F);
|
|
929
|
+
}, [p("subTemplateType2")]), E(() => {
|
|
928
930
|
let a = c.find((m) => m.id === p("template")?.id);
|
|
929
|
-
|
|
930
|
-
}, [p("template")]),
|
|
931
|
-
|
|
932
|
-
}, [
|
|
933
|
-
const
|
|
934
|
-
let a = [
|
|
935
|
-
|
|
931
|
+
Te(a);
|
|
932
|
+
}, [p("template")]), E(() => {
|
|
933
|
+
_ && f ? (e(_), s("subject", _.subject ?? "")) : e(void 0);
|
|
934
|
+
}, [_, f, e]);
|
|
935
|
+
const ee = () => {
|
|
936
|
+
let a = [F], m = "templateType";
|
|
937
|
+
k.length > 0 ? m = "subTemplateType2" : $.length > 0 && (m = "subTemplateType");
|
|
936
938
|
let u = c.filter(
|
|
937
|
-
(
|
|
938
|
-
),
|
|
939
|
-
return
|
|
939
|
+
(T) => (T.type?.toString() === p(m)?.id.toString() || T.type === null) && p(m)?.id != null
|
|
940
|
+
), S = we(u, [u.findIndex((T) => !T.readonly)]);
|
|
941
|
+
return S.length > 0 && (S[0].readonly === !0 ? a = [] : a.push(de), a = [
|
|
940
942
|
...a,
|
|
941
|
-
...
|
|
942
|
-
id:
|
|
943
|
-
name: ve(u,
|
|
944
|
-
isSeparator:
|
|
943
|
+
...S.map((O) => ({
|
|
944
|
+
id: O.id,
|
|
945
|
+
name: ve(u, O.id),
|
|
946
|
+
isSeparator: O.isSeparator
|
|
945
947
|
}))
|
|
946
948
|
]), a.length ? a : [];
|
|
947
949
|
}, ve = (a, m) => {
|
|
948
|
-
let u = a.find((
|
|
950
|
+
let u = a.find((S) => S.id === m);
|
|
949
951
|
return u ? `${u.displayName}` : "";
|
|
950
952
|
}, xe = (a) => {
|
|
951
953
|
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
952
954
|
async (m) => {
|
|
953
|
-
let u = a.template.id,
|
|
954
|
-
f?.readonly && (u = "",
|
|
955
|
-
let
|
|
955
|
+
let u = a.template.id, S = "";
|
|
956
|
+
f?.readonly && (u = "", S = a.template.id);
|
|
957
|
+
let T = c.find(
|
|
956
958
|
(Ce) => Ce.name === a.templateName.trim()
|
|
957
959
|
);
|
|
958
|
-
if (
|
|
959
|
-
|
|
960
|
+
if (T && T.id !== u) {
|
|
961
|
+
j("templateName", {
|
|
960
962
|
type: "validate",
|
|
961
963
|
message: "Template name already exists. Please choose a different name."
|
|
962
964
|
});
|
|
963
965
|
return;
|
|
964
966
|
}
|
|
965
|
-
let
|
|
966
|
-
|
|
967
|
+
let O = a.templateType.id;
|
|
968
|
+
k && k.length > 0 ? O = a.subTemplateType2.id : $ && $.length > 0 && (O = a.subTemplateType.id);
|
|
967
969
|
const Se = {
|
|
968
970
|
enerexIdentifier: "",
|
|
969
971
|
projectId: "",
|
|
970
972
|
templateId: u,
|
|
971
|
-
templateType:
|
|
973
|
+
templateType: O,
|
|
972
974
|
name: a.templateName.trim(),
|
|
973
975
|
html: m.html,
|
|
974
976
|
css: m.css,
|
|
975
977
|
subject: a.templateType.id === "2" ? a?.subject ?? "" : "",
|
|
976
|
-
parent_id:
|
|
978
|
+
parent_id: S
|
|
977
979
|
};
|
|
978
|
-
await
|
|
980
|
+
await ye(Se) && (t(), C(), K([]), Q([]), b());
|
|
979
981
|
}
|
|
980
982
|
);
|
|
981
983
|
};
|
|
982
|
-
return /* @__PURE__ */ i(
|
|
983
|
-
/* @__PURE__ */ i(
|
|
984
|
-
|
|
984
|
+
return /* @__PURE__ */ i(ne, { className: "border border-0 text-start", children: /* @__PURE__ */ i(ne.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ i("form", { onSubmit: n(xe), children: /* @__PURE__ */ i("div", { className: "template-list-container gap-3", children: /* @__PURE__ */ P(Ae, { children: [
|
|
985
|
+
/* @__PURE__ */ i(L, { children: /* @__PURE__ */ i(
|
|
986
|
+
H,
|
|
985
987
|
{
|
|
986
988
|
label: "Category",
|
|
987
989
|
control: d,
|
|
988
|
-
error:
|
|
989
|
-
options:
|
|
990
|
+
error: h,
|
|
991
|
+
options: he,
|
|
990
992
|
required: !0,
|
|
993
|
+
disabled: w || x || N || q,
|
|
991
994
|
validation: {
|
|
992
995
|
required: {
|
|
993
996
|
value: !0,
|
|
994
997
|
message: "Select a category"
|
|
995
998
|
}
|
|
996
999
|
},
|
|
997
|
-
...
|
|
1000
|
+
...o("templateType")
|
|
998
1001
|
}
|
|
999
1002
|
) }),
|
|
1000
|
-
|
|
1001
|
-
|
|
1003
|
+
$ && $.length > 0 && /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i(
|
|
1004
|
+
H,
|
|
1002
1005
|
{
|
|
1003
1006
|
label: "Type",
|
|
1004
1007
|
control: d,
|
|
1005
|
-
error:
|
|
1006
|
-
options:
|
|
1008
|
+
error: h,
|
|
1009
|
+
options: $,
|
|
1007
1010
|
required: !0,
|
|
1011
|
+
disabled: w || x || N || q,
|
|
1008
1012
|
validation: {
|
|
1009
1013
|
required: {
|
|
1010
1014
|
value: !0,
|
|
1011
1015
|
message: "Select a type"
|
|
1012
1016
|
}
|
|
1013
1017
|
},
|
|
1014
|
-
...
|
|
1018
|
+
...o("subTemplateType")
|
|
1015
1019
|
}
|
|
1016
1020
|
) }),
|
|
1017
|
-
|
|
1018
|
-
|
|
1021
|
+
k && k.length > 0 && /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i(
|
|
1022
|
+
H,
|
|
1019
1023
|
{
|
|
1020
1024
|
label: "Sub Type",
|
|
1021
1025
|
control: d,
|
|
1022
|
-
error:
|
|
1023
|
-
options:
|
|
1026
|
+
error: h,
|
|
1027
|
+
options: k,
|
|
1024
1028
|
required: !0,
|
|
1029
|
+
disabled: w || x || N || q,
|
|
1025
1030
|
validation: {
|
|
1026
1031
|
required: {
|
|
1027
1032
|
value: !0,
|
|
1028
1033
|
message: "Select a subtype"
|
|
1029
1034
|
}
|
|
1030
1035
|
},
|
|
1031
|
-
...
|
|
1036
|
+
...o("subTemplateType2")
|
|
1032
1037
|
}
|
|
1033
1038
|
) }),
|
|
1034
|
-
/* @__PURE__ */ i(
|
|
1035
|
-
|
|
1039
|
+
/* @__PURE__ */ i(L, { children: /* @__PURE__ */ i(
|
|
1040
|
+
H,
|
|
1036
1041
|
{
|
|
1037
1042
|
label: "Template",
|
|
1038
1043
|
control: d,
|
|
1039
|
-
error:
|
|
1040
|
-
|
|
1044
|
+
error: h,
|
|
1045
|
+
disabled: w || x || N || q,
|
|
1046
|
+
options: ee(),
|
|
1041
1047
|
required: !1,
|
|
1042
|
-
...
|
|
1048
|
+
...o("template")
|
|
1043
1049
|
}
|
|
1044
1050
|
) }),
|
|
1045
|
-
/* @__PURE__ */ i(
|
|
1046
|
-
|
|
1051
|
+
/* @__PURE__ */ i(L, { children: /* @__PURE__ */ i(
|
|
1052
|
+
se,
|
|
1047
1053
|
{
|
|
1048
1054
|
label: "Name",
|
|
1049
|
-
register:
|
|
1050
|
-
error:
|
|
1055
|
+
register: o,
|
|
1056
|
+
error: h,
|
|
1051
1057
|
required: !0,
|
|
1052
1058
|
name: "templateName",
|
|
1053
1059
|
validation: {
|
|
@@ -1058,28 +1064,28 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1058
1064
|
}
|
|
1059
1065
|
}
|
|
1060
1066
|
) }),
|
|
1061
|
-
p("templateType")?.id === "2" && /* @__PURE__ */ i(
|
|
1062
|
-
|
|
1067
|
+
p("templateType")?.id === "2" && /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i(
|
|
1068
|
+
se,
|
|
1063
1069
|
{
|
|
1064
1070
|
label: "Subject",
|
|
1065
|
-
register:
|
|
1066
|
-
error:
|
|
1071
|
+
register: o,
|
|
1072
|
+
error: h,
|
|
1067
1073
|
required: !1,
|
|
1068
1074
|
name: "subject"
|
|
1069
1075
|
}
|
|
1070
1076
|
) }),
|
|
1071
|
-
/* @__PURE__ */
|
|
1077
|
+
/* @__PURE__ */ P(L, { className: "d-flex align-self-start justify-content-end gap-2 mb-1 btn-padding", children: [
|
|
1072
1078
|
/* @__PURE__ */ i(
|
|
1073
|
-
|
|
1079
|
+
re,
|
|
1074
1080
|
{
|
|
1075
1081
|
style: { width: "70px" },
|
|
1076
1082
|
variant: "primary",
|
|
1077
|
-
disabled:
|
|
1083
|
+
disabled: w || x || N || q,
|
|
1078
1084
|
onClick: () => {
|
|
1079
|
-
y(void 0),
|
|
1085
|
+
y(void 0), C(), K([]), Q([]), l();
|
|
1080
1086
|
},
|
|
1081
|
-
children:
|
|
1082
|
-
|
|
1087
|
+
children: x || N ? /* @__PURE__ */ i(
|
|
1088
|
+
X,
|
|
1083
1089
|
{
|
|
1084
1090
|
animation: "border",
|
|
1085
1091
|
style: { width: "11px", height: "11px" },
|
|
@@ -1092,14 +1098,14 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1092
1098
|
}
|
|
1093
1099
|
),
|
|
1094
1100
|
(p("templateType")?.id.toString() !== "2" || (p("templateType")?.id.toString() === "2" && (f?.id ?? "")) !== "") && /* @__PURE__ */ i(Ee, { children: /* @__PURE__ */ i(
|
|
1095
|
-
|
|
1101
|
+
re,
|
|
1096
1102
|
{
|
|
1097
1103
|
type: "submit",
|
|
1098
1104
|
variant: "primary",
|
|
1099
1105
|
style: { width: "80px" },
|
|
1100
|
-
disabled:
|
|
1101
|
-
children:
|
|
1102
|
-
|
|
1106
|
+
disabled: w || x || N || q,
|
|
1107
|
+
children: x || N ? /* @__PURE__ */ i(
|
|
1108
|
+
X,
|
|
1103
1109
|
{
|
|
1104
1110
|
animation: "border",
|
|
1105
1111
|
style: { width: "11px", height: "11px" },
|
|
@@ -1114,15 +1120,15 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1114
1120
|
] })
|
|
1115
1121
|
] }) }) }) }) });
|
|
1116
1122
|
}, st = ({ config: e }) => {
|
|
1117
|
-
const [r,
|
|
1118
|
-
return /* @__PURE__ */ i(Re, { configs: e, children: /* @__PURE__ */ i(
|
|
1123
|
+
const [r, l] = I(), [o, n] = I(!1);
|
|
1124
|
+
return /* @__PURE__ */ i(Re, { configs: e, children: /* @__PURE__ */ i(qe, { children: /* @__PURE__ */ P("div", { className: "root-widget", children: [
|
|
1119
1125
|
/* @__PURE__ */ i(
|
|
1120
1126
|
Ye,
|
|
1121
1127
|
{
|
|
1122
1128
|
templateLoading: n,
|
|
1123
1129
|
onSelectItem: (d) => {
|
|
1124
|
-
if (
|
|
1125
|
-
let p =
|
|
1130
|
+
if (l(d), window.StripoEditorApi && window.StripoEditorApi.actionsApi) {
|
|
1131
|
+
let p = z;
|
|
1126
1132
|
window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1127
1133
|
d?.html ?? p,
|
|
1128
1134
|
d?.css ?? "",
|
|
@@ -1131,8 +1137,8 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1131
1137
|
}
|
|
1132
1138
|
},
|
|
1133
1139
|
onReset: () => {
|
|
1134
|
-
n(!1),
|
|
1135
|
-
|
|
1140
|
+
n(!1), l(void 0), window.StripoEditorApi && window.StripoEditorApi.actionsApi && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1141
|
+
z,
|
|
1136
1142
|
"",
|
|
1137
1143
|
""
|
|
1138
1144
|
);
|
|
@@ -1144,7 +1150,7 @@ const oe = /* @__PURE__ */ Ge(Ke), le = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1144
1150
|
{
|
|
1145
1151
|
templateHTML: {
|
|
1146
1152
|
css: r?.css ?? "",
|
|
1147
|
-
html: r?.html ??
|
|
1153
|
+
html: r?.html ?? z
|
|
1148
1154
|
},
|
|
1149
1155
|
loading: !1,
|
|
1150
1156
|
className: "col-span-5"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(T,n){typeof exports=="object"&&typeof module<"u"?n(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"],n):(T=typeof globalThis<"u"?globalThis:T||self,n(T.EnerexTemplateEditor={},T.jsxRuntime,T.React,T.reactQuery,T.axios,T.reactBootstrap,T.reactHookForm,T.Select$1))})(this,function(T,n,p,_,X,g,Z,V){"use strict";const H=`<!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
|
-
`,
|
|
357
|
+
`,Q=p.createContext(void 0),ae=({children:t,configs:s})=>{const[i,o]=p.useState(s.clientId),[r,e]=p.useState(s.apiKey),[l,d]=p.useState(s.enerexIdentifier),[u,N]=p.useState(s.projectId),[A,w]=p.useState(s.userEmail),E=v=>{e(v.apiKey),o(v.clientId),N(v.projectId),d(v.enerexIdentifier),w(v.userEmail)};return n.jsx(Q.Provider,{value:{clientId:i,apiKey:r,setConfiguration:E,enerexIdentifier:l,projectId:u,userEmail:A},children:t})},q=()=>{const t=p.useContext(Q);if(!t)throw new Error("widgetConfig must be used within a ConfigProvider");return t},R=(t="",s)=>({get:async(r,e)=>{try{const l=await X.get(`${t}${r}`,e??s);if(l.status===200)return l.data}catch(l){throw l}},post:async(r,e,l)=>{try{const d=await X.post(`${t}${r}`,e,l??s);if(d.status===200)return d.data}catch(d){throw d}}}),z={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"},ee=p.createContext({get:()=>{throw new Error("HttpClientContext.get not implemented")},post:()=>{throw new Error("HttpClientContext.post not implemented")}}),de=({children:t})=>{const{clientId:s,apiKey:i}=q(),o={headers:{client_id:s,"x-api-key":i}},{get:r,post:e}=R(z.API_BASE_URL,o);return n.jsx(ee.Provider,{value:{get:r,post:e},children:t})},ce=({children:t})=>{const s=new _.QueryClient;return n.jsx(de,{children:n.jsx(_.QueryClientProvider,{client:s,children:t})})},pe=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},L=()=>{const t=p.useContext(ee);if(t)return t;throw new Error("useHttpClient must be used within a HttpClientProvider")},D={Template_list:"/Template/list/",Template:"/Template/GetTemplate/",MergeTags:"/Template/TemplateMergeTags/",ExcludeCategory:"/Template/GetExcludeCategories/",SaveTemplate:"/Template/save-update/",TemplateTypes:"/Template/TemplateTypes/"},ue=()=>{const t=L(),{enerexIdentifier:s,projectId:i}=q();return _.useQuery({queryKey:["getTemplateTags"],queryFn:async r=>await t.get(`${D.MergeTags}${i}/${s}`)})},me=()=>{const t=L(),{enerexIdentifier:s,projectId:i}=q();return _.useQuery({queryKey:["getExcludeCategory"],queryFn:async r=>await t.get(`${D.ExcludeCategory}${i}/${s}`)})},fe=({templateHTML:t,className:s="",loading:i=!1})=>{const{post:o}=R(),{data:r}=ue(),{data:e}=me(),[l,d]=p.useState(t??{html:H,css:""}),{userEmail:u}=q(),N=p.useRef(null),A="https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png",w="https://plugins.stripo.email/api/v1/auth";p.useEffect(()=>{(async()=>(await E(),r&&e&&await v(z.EDITOR_SCRIPT_URL)))()},[r,e]);async function E(){window.Zone||await new Promise((c,h)=>{const y=document.createElement("script");y.src="https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";const b=document.querySelector("script[nonce]")?.nonce;b&&y.setAttribute("nonce",b),y.onload=()=>c(),y.onerror=()=>h(new Error("Failed to load zone.js")),document.head.appendChild(y)})}async function v(c){let h=document.getElementById("UiEditorScript");h||(h=document.createElement("script"),h.id="UiEditorScript",h.src=c,h.onload=async()=>{await x()},document.body.appendChild(h)),await new Promise(y=>h.addEventListener("load",()=>y(),{once:!0}))}const x=async()=>{const c=N.current;if(!c){console.error("Missing #stripoEditorContainer in DOM");return}if(!window.UIEditor||typeof window.UIEditor.initEditor!="function"){console.error("UIEditor script not loaded or not exposing initEditor");return}const h={html:l.html,css:l.css,modulesExcludedCategories:e??[],forceRecreate:!0,metadata:{emailId:u,userId:"1",avatarUrl:A},locale:"en",onTokenRefreshRequest:async y=>{const b={pluginId:z.EDITOR_PLUGIN_ID,secretKey:z.EDITOR_SECRET_KEY,userId:u,role:"user"},P=await o(w,b);P?.token&&y(P.token)},mergeTags:pe(r??[])};for(const[y,b]of Object.entries({codeEditorButtonSelector:"#codeEditor",undoButtonSelector:"#undoButton",redoButtonSelector:"#redoButton",mobileViewButtonSelector:"#mobileViewButton",desktopViewButtonSelector:"#desktopViewButton"}))c.ownerDocument&&c.getRootNode()instanceof ShadowRoot&&c.getRootNode().querySelector(b)&&(h[y]=b);await window.UIEditor.initEditor(c,h)};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(g.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",ref:N})]})})},te=({label:t,register:s,validation:i,required:o=!1,name:r,error:e,className:l="",...d})=>n.jsxs(g.Form.Group,{className:l+" mb-1",children:[t?n.jsxs(g.Form.Label,{className:"mb-3 d-block form-label",children:[t,o&&n.jsx("label",{className:"text-danger",children:"*"})]}):null,n.jsx(g.Form.Control,{name:r,type:"text",...d,isInvalid:!!(e&&e[r]),...s?s(r,{...i}):{},className:`react-select__control ${e&&e[r]&&"border border-danger"}`}),e&&e[r]?n.jsx(g.Form.Control.Feedback,{type:"invalid",children:e[r].message}):null]}),ge=()=>{const t=L(),{enerexIdentifier:s,projectId:i}=q();return _.useQuery({queryKey:["getTemplatesList"],queryFn:async r=>await t.get(`${D.Template_list}${i}/${s}`)})};function K(t){return t.sort((s,i)=>s.name.localeCompare(i.name))}function ye(t){const s=new Map,i=[];t.forEach(e=>s.set(e.id,e));let o=t.filter(e=>e.parent_id===0),r=0;for(;o.length>0;){i.push({level:r,data:o});const e=o.map(d=>d.id);o=t.filter(d=>e.includes(d.parent_id)),r++}return i}function W(t,s){const o=ye(t).find(r=>r.level===s);return o?o.data:[]}const he=()=>{const t=L(),{enerexIdentifier:s,projectId:i}=q();return _.useMutation({mutationKey:["getTemplate"],mutationFn:async({id:r})=>{if(r)return await t.get(`${D.Template}${s}/${r}/${i}`)}})},be=()=>{const t=L(),{enerexIdentifier:s,projectId:i}=q();return _.useQuery({queryKey:["getTemplateTypes"],queryFn:async r=>await t.get(`${D.TemplateTypes}${s}/${i}`)})};function Te(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var B={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
|
|
361
|
+
*/var ne;function we(){return ne||(ne=1,function(t){(function(){var s={}.hasOwnProperty;function i(){for(var e="",l=0;l<arguments.length;l++){var d=arguments[l];d&&(e=r(e,o(d)))}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 d in e)s.call(e,d)&&e[d]&&(l=r(l,d));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})()}(B)),B.exports}var ve=we();const re=Te(ve),se=t=>t.data.isSeparator?n.jsx("div",{style:{padding:0,margin:"2px 0"},children:n.jsx("hr",{style:{border:0,borderTop:"1px solid #bdbdbdff",padding:0,margin:0}})}):n.jsx(V.components.Option,{...t}),xe=({name:t="",control:s,options:i,multiple:o=!1,placeholder:r,validation:e,labelKey:l="name",disabled:d,isInvalid:u,value:N,onChange:A,uncontrolled:w,menuPlacement:E="auto",closeOnSelect:v=!0})=>{const x={control:c=>({...c,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:c=>({...c,marginTop:0,width:"max-content",minWidth:"100%"}),menuPortal:c=>({...c,zIndex:9999}),multiValueRemove:c=>({...c,display:d?"none":"block"})};return w?n.jsx(V,{components:{Option:se},isOptionDisabled:c=>!!c.isSeparator,className:re({"is-invalid":u}),styles:x,classNamePrefix:"react-select",isMulti:o,options:i,onChange:A,placeholder:r,menuPortalTarget:document.body,value:N,getOptionLabel:typeof l=="string"?c=>c[l]:l,getOptionValue:c=>c.id,isDisabled:d,menuPlacement:E,closeMenuOnSelect:v}):n.jsx(Z.Controller,{control:s,name:t,rules:e,render:({field:{onChange:c,value:h,onBlur:y}})=>n.jsx(V,{components:{Option:se},isOptionDisabled:b=>!!b.isSeparator,className:re({"is-invalid":u}),styles:x,classNamePrefix:"react-select",isMulti:o,options:i,onBlur:y,onChange:c,placeholder:r,menuPortalTarget:document.body,value:h,getOptionLabel:typeof l=="string"?b=>b[l]:l,getOptionValue:b=>b.id,isDisabled:d,menuPlacement:E,closeMenuOnSelect:v},h?JSON.stringify(h):"reset")})},G=({label:t,name:s,validation:i,control:o,error:r,...e})=>n.jsxs(g.Form.Group,{className:"mb-1",children:[t&&n.jsxs(g.Form.Label,{className:"mb-3 d-block form-label",children:[t," ",e.required&&n.jsx("span",{className:"text-danger",children:"*"})]}),n.jsx(xe,{control:o,disabled:e.disabled,options:e.options??[],validation:i,isInvalid:r&&!!r[s],name:s}),r&&r[s]?n.jsx(g.Form.Control.Feedback,{type:"invalid",children:r[s].message}):null]}),Se=()=>{const t=L();_.useQueryClient();const{enerexIdentifier:s,projectId:i}=q();return _.useMutation({mutationKey:["saveTemplate"],mutationFn:async r=>(r.enerexIdentifier=s??"",r.projectId=i??"",await t.post(`${D.SaveTemplate}`,r))})},M={id:"",name:"New (Blank)"},le={id:"",name:"Separator",isSeparator:!0},Ee=({onSelectItem:t,templateLoading:s,onReset:i})=>{const{register:o,handleSubmit:r,clearErrors:e,setValue:l,control:d,watch:u,reset:N,setError:A,formState:{errors:w}}=Z.useForm({defaultValues:{templateName:"",subTemplateType:void 0,subTemplateType2:void 0,subject:"",templateType:void 0,template:M},mode:"onChange"}),{data:E,refetch:v,isLoading:x}=ge(),[c,h]=p.useState([]),[y,b]=p.useState(),[P,ie]=p.useState(),{mutateAsync:Ie,isPending:C}=he(),{mutateAsync:_e,isPending:j}=Se(),{data:U,isLoading:k}=be(),[Ne,qe]=p.useState([]),[$,Y]=p.useState([]),[F,J]=p.useState([]);p.useEffect(()=>{if(U){let a=U.filter(f=>f.id!=null),m=W(a,0);qe(K(m))}},[U]);const Pe=(a,m)=>{let f=[];return a.forEach((I,S)=>{m.includes(S)&&S!==0&&f.push(le),f.push(I)}),f};p.useEffect(()=>{s(!!C)},[C]),p.useEffect(()=>{E?.sort((a,m)=>a.readonly!==m.readonly?(a.readonly?0:1)-(m.readonly?0:1):a.name.localeCompare(m.name)),h(E??[])},[E]);const je=async a=>{b(a),a&&!a.readonly?(l("templateName",a?.name),e()):(l("templateName",""),l("subject",""));const m=await Ie({id:a?.id});ie(m||void 0)};p.useEffect(()=>{if(l("template",M),u("templateType")){let a=U?.filter(f=>f.id!==void 0)??[],m=W(a,1);Y(K(m.filter(f=>f.parent_id.toString()===`${u("templateType")?.id}`))),l("subTemplateType",void 0),l("subTemplateType2",void 0)}},[u("templateType")]),p.useEffect(()=>{if(l("template",M),u("subTemplateType")){let a=U?.filter(f=>f.id!==void 0)??[],m=W(a,2);J(K(m.filter(f=>f.parent_id.toString()===`${u("subTemplateType")?.id}`))),l("subTemplateType2",void 0)}},[u("subTemplateType")]),p.useEffect(()=>{const a=oe();a.length>0&&a[0].id!==""?l("template",a[0]):l("template",M)},[u("subTemplateType2")]),p.useEffect(()=>{let a=c.find(m=>m.id===u("template")?.id);je(a)},[u("template")]),p.useEffect(()=>{P&&y?(t(P),l("subject",P.subject??"")):t(void 0)},[P,y,t]);const oe=()=>{let a=[M],m="templateType";F.length>0?m="subTemplateType2":$.length>0&&(m="subTemplateType");let f=c.filter(S=>(S.type?.toString()===u(m)?.id.toString()||S.type===null)&&u(m)?.id!=null),I=Pe(f,[f.findIndex(S=>!S.readonly)]);return I.length>0&&(I[0].readonly===!0?a=[]:a.push(le),a=[...a,...I.map(O=>({id:O.id,name:Ae(f,O.id),isSeparator:O.isSeparator}))]),a.length?a:[]},Ae=(a,m)=>{let f=a.find(I=>I.id===m);return f?`${f.displayName}`:""},Oe=a=>{window.StripoEditorApi.actionsApi.getTemplateData(async m=>{let f=a.template.id,I="";y?.readonly&&(f="",I=a.template.id);let S=c.find(De=>De.name===a.templateName.trim());if(S&&S.id!==f){A("templateName",{type:"validate",message:"Template name already exists. Please choose a different name."});return}let O=a.templateType.id;F&&F.length>0?O=a.subTemplateType2.id:$&&$.length>0&&(O=a.subTemplateType.id);const Le={enerexIdentifier:"",projectId:"",templateId:f,templateType:O,name:a.templateName.trim(),html:m.html,css:m.css,subject:a.templateType.id==="2"?a?.subject??"":"",parent_id:I};await _e(Le)&&(e(),N(),Y([]),J([]),v())})};return n.jsx(g.Card,{className:"border border-0 text-start",children:n.jsx(g.Card.Body,{className:"pe-0 ps-2",children:n.jsx("form",{onSubmit:r(Oe),children:n.jsx("div",{className:"template-list-container gap-3",children:n.jsxs(g.Row,{children:[n.jsx(g.Col,{children:n.jsx(G,{label:"Category",control:d,error:w,options:Ne,required:!0,disabled:x||C||j||k,validation:{required:{value:!0,message:"Select a category"}},...o("templateType")})}),$&&$.length>0&&n.jsx(g.Col,{children:n.jsx(G,{label:"Type",control:d,error:w,options:$,required:!0,disabled:x||C||j||k,validation:{required:{value:!0,message:"Select a type"}},...o("subTemplateType")})}),F&&F.length>0&&n.jsx(g.Col,{children:n.jsx(G,{label:"Sub Type",control:d,error:w,options:F,required:!0,disabled:x||C||j||k,validation:{required:{value:!0,message:"Select a subtype"}},...o("subTemplateType2")})}),n.jsx(g.Col,{children:n.jsx(G,{label:"Template",control:d,error:w,disabled:x||C||j||k,options:oe(),required:!1,...o("template")})}),n.jsx(g.Col,{children:n.jsx(te,{label:"Name",register:o,error:w,required:!0,name:"templateName",validation:{required:{value:!0,message:"Enter a name"}}})}),u("templateType")?.id==="2"&&n.jsx(g.Col,{children:n.jsx(te,{label:"Subject",register:o,error:w,required:!1,name:"subject"})}),n.jsxs(g.Col,{className:"d-flex align-self-start justify-content-end gap-2 mb-1 btn-padding",children:[n.jsx(g.Button,{style:{width:"70px"},variant:"primary",disabled:x||C||j||k,onClick:()=>{b(void 0),N(),Y([]),J([]),i()},children:C||j?n.jsx(g.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"}),(u("templateType")?.id.toString()!=="2"||(u("templateType")?.id.toString()==="2"&&(y?.id??""))!=="")&&n.jsx(n.Fragment,{children:n.jsx(g.Button,{type:"submit",variant:"primary",style:{width:"80px"},disabled:x||C||j||k,children:C||j?n.jsx(g.Spinner,{animation:"border",style:{width:"11px",height:"11px"},size:"sm",role:"status",className:"me-1",children:n.jsx("span",{className:"visually-hidden",children:"Loading..."})}):y?.readonly?"Save as":"Save"})})]})]})})})})})},Ce=({config:t})=>{const[s,i]=p.useState(),[o,r]=p.useState(!1),e=d=>{if(i(d),window.StripoEditorApi&&window.StripoEditorApi.actionsApi){let u=H;window.StripoEditorApi.actionsApi.updateHtmlAndCss(d?.html??u,d?.css??"","")}},l=()=>{r(!1),i(void 0),window.StripoEditorApi&&window.StripoEditorApi.actionsApi&&window.StripoEditorApi.actionsApi.updateHtmlAndCss(H,"","")};return n.jsx(ae,{configs:t,children:n.jsx(ce,{children:n.jsxs("div",{className:"root-widget",children:[n.jsx(Ee,{templateLoading:r,onSelectItem:e,onReset:l}),n.jsx(fe,{templateHTML:{css:s?.css??"",html:s?.html??H},loading:!1,className:"col-span-5"})]})})})};T.EditorWidget=Ce,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -3,13 +3,16 @@ import type { FieldErrors } from "react-hook-form";
|
|
|
3
3
|
export type HasId = {
|
|
4
4
|
id: string;
|
|
5
5
|
};
|
|
6
|
+
export type HasProjectId = {
|
|
7
|
+
projectId: number;
|
|
8
|
+
};
|
|
6
9
|
export type HasName = {
|
|
7
10
|
name: string;
|
|
8
11
|
};
|
|
9
12
|
export type HasSeparator = {
|
|
10
13
|
isSeparator?: boolean;
|
|
11
14
|
};
|
|
12
|
-
export type BasicEntity = HasId & HasName & HasSeparator
|
|
15
|
+
export type BasicEntity = HasId & HasName & HasSeparator & Partial<HasProjectId>;
|
|
13
16
|
interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
|
|
14
17
|
label?: string;
|
|
15
18
|
name: string;
|