@enerex/template-studio 1.1.37 → 1.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/enerex-template-editor.es.js +833 -575
- package/dist/enerex-template-editor.umd.js +13 -3
- package/dist/template-studio.css +1 -1
- package/dist/types/component/form-input/select.d.ts +5 -2
- package/dist/types/component/icons/star-icon.d.ts +8 -0
- package/dist/types/component/modal/index.d.ts +24 -0
- package/dist/types/queries/types.d.ts +3 -1
- package/dist/types/type/application-type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { QueryClient as
|
|
4
|
-
import
|
|
5
|
-
import { Spinner as
|
|
6
|
-
import { Controller as
|
|
7
|
-
import
|
|
8
|
-
const
|
|
1
|
+
import { jsx as n, jsxs as S, Fragment as Ee } from "react/jsx-runtime";
|
|
2
|
+
import M, { useContext as qe, useState as w, useRef as st, useEffect as E } from "react";
|
|
3
|
+
import { QueryClient as it, QueryClientProvider as at, useQuery as ce, useMutation as Te, useQueryClient as lt } from "@tanstack/react-query";
|
|
4
|
+
import _e from "axios";
|
|
5
|
+
import { Spinner as z, Form as H, Card as ke, Row as ot, Col as U, Button as J } from "react-bootstrap";
|
|
6
|
+
import { Controller as dt, useForm as ct } from "react-hook-form";
|
|
7
|
+
import Ae, { components as Le } from "react-select";
|
|
8
|
+
const de = `<!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,159 +361,160 @@ const z = `<!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
|
+
`, Re = M.createContext(
|
|
365
365
|
void 0
|
|
366
|
-
),
|
|
366
|
+
), pt = ({
|
|
367
367
|
children: t,
|
|
368
368
|
configs: s
|
|
369
369
|
}) => {
|
|
370
|
-
const [
|
|
370
|
+
const [l, a] = M.useState(s.clientId), [i, e] = M.useState(s.apiKey), [d, o] = M.useState(
|
|
371
371
|
s.enerexIdentifier
|
|
372
|
-
), [
|
|
372
|
+
), [b, D] = M.useState(s.projectId), [A, m] = M.useState(s.userEmail), [_, u] = M.useState(s.isAdmin), [j, h] = M.useState(s.meBaseUrl), [v, y] = M.useState(
|
|
373
373
|
s.defaultSelector
|
|
374
|
-
),
|
|
375
|
-
e(
|
|
374
|
+
), f = (g) => {
|
|
375
|
+
e(g.apiKey), a(g.clientId), D(g.projectId), o(g.enerexIdentifier), m(g.userEmail), u(g.isAdmin), y(g.defaultSelector), h(g.meBaseUrl);
|
|
376
376
|
};
|
|
377
|
-
return /* @__PURE__ */
|
|
378
|
-
|
|
377
|
+
return /* @__PURE__ */ n(
|
|
378
|
+
Re.Provider,
|
|
379
379
|
{
|
|
380
380
|
value: {
|
|
381
|
-
clientId:
|
|
382
|
-
apiKey:
|
|
383
|
-
setConfiguration:
|
|
384
|
-
enerexIdentifier:
|
|
385
|
-
projectId:
|
|
386
|
-
userEmail:
|
|
381
|
+
clientId: l,
|
|
382
|
+
apiKey: i,
|
|
383
|
+
setConfiguration: f,
|
|
384
|
+
enerexIdentifier: d,
|
|
385
|
+
projectId: b,
|
|
386
|
+
userEmail: A,
|
|
387
387
|
isAdmin: _,
|
|
388
|
-
defaultSelector:
|
|
389
|
-
meBaseUrl:
|
|
388
|
+
defaultSelector: v,
|
|
389
|
+
meBaseUrl: j
|
|
390
390
|
},
|
|
391
391
|
children: t
|
|
392
392
|
}
|
|
393
393
|
);
|
|
394
|
-
},
|
|
395
|
-
const t =
|
|
394
|
+
}, B = () => {
|
|
395
|
+
const t = qe(Re);
|
|
396
396
|
if (!t)
|
|
397
397
|
throw new Error("widgetConfig must be used within a ConfigProvider");
|
|
398
398
|
return t;
|
|
399
|
-
},
|
|
399
|
+
}, Me = (t = "", s) => ({ get: async (i, e) => {
|
|
400
400
|
try {
|
|
401
|
-
const
|
|
402
|
-
`${t}${
|
|
401
|
+
const d = await _e.get(
|
|
402
|
+
`${t}${i}`,
|
|
403
403
|
e ?? s
|
|
404
404
|
);
|
|
405
|
-
if (
|
|
406
|
-
return
|
|
407
|
-
} catch (
|
|
408
|
-
throw
|
|
405
|
+
if (d.status === 200)
|
|
406
|
+
return d.data;
|
|
407
|
+
} catch (d) {
|
|
408
|
+
throw d;
|
|
409
409
|
}
|
|
410
|
-
}, post: async (
|
|
410
|
+
}, post: async (i, e, d) => {
|
|
411
411
|
try {
|
|
412
|
-
const
|
|
413
|
-
`${t}${
|
|
412
|
+
const o = await _e.post(
|
|
413
|
+
`${t}${i}`,
|
|
414
414
|
e,
|
|
415
|
-
|
|
415
|
+
d ?? s
|
|
416
416
|
);
|
|
417
|
-
if (
|
|
418
|
-
return
|
|
419
|
-
} catch (
|
|
420
|
-
throw
|
|
417
|
+
if (o.status === 200)
|
|
418
|
+
return o.data;
|
|
419
|
+
} catch (o) {
|
|
420
|
+
throw o;
|
|
421
421
|
}
|
|
422
|
-
} }),
|
|
422
|
+
} }), Be = M.createContext({
|
|
423
423
|
get: () => {
|
|
424
424
|
throw new Error("HttpClientContext.get not implemented");
|
|
425
425
|
},
|
|
426
426
|
post: () => {
|
|
427
427
|
throw new Error("HttpClientContext.post not implemented");
|
|
428
428
|
}
|
|
429
|
-
}),
|
|
430
|
-
const { clientId: s, apiKey:
|
|
429
|
+
}), mt = ({ children: t }) => {
|
|
430
|
+
const { clientId: s, apiKey: l, isAdmin: a, meBaseUrl: i } = B(), e = {
|
|
431
431
|
headers: {
|
|
432
432
|
client_id: s,
|
|
433
|
-
"x-api-key":
|
|
434
|
-
"Security-Context":
|
|
433
|
+
"x-api-key": l,
|
|
434
|
+
"Security-Context": a ? "admin" : "viewer"
|
|
435
435
|
}
|
|
436
|
-
}, { get:
|
|
437
|
-
return /* @__PURE__ */
|
|
438
|
-
},
|
|
439
|
-
const s = new
|
|
440
|
-
return /* @__PURE__ */
|
|
441
|
-
},
|
|
436
|
+
}, { get: d, post: o } = Me(i, e);
|
|
437
|
+
return /* @__PURE__ */ n(Be.Provider, { value: { get: d, post: o }, children: t });
|
|
438
|
+
}, ut = ({ children: t }) => {
|
|
439
|
+
const s = new it();
|
|
440
|
+
return /* @__PURE__ */ n(mt, { children: /* @__PURE__ */ n(at, { client: s, children: t }) });
|
|
441
|
+
}, he = {
|
|
442
442
|
EDITOR_SCRIPT_URL: "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",
|
|
443
443
|
EDITOR_PLUGIN_ID: "1afdc3161ec7409a8627a1c8561d45f5",
|
|
444
444
|
EDITOR_SECRET_KEY: "54ba748ed7e94f2e929555783acb03da"
|
|
445
|
-
},
|
|
446
|
-
const s = Array.from(new Set(t.map((
|
|
447
|
-
return s.forEach((
|
|
448
|
-
const
|
|
445
|
+
}, ft = (t) => {
|
|
446
|
+
const s = Array.from(new Set(t.map((a) => a.category))), l = [];
|
|
447
|
+
return s.forEach((a) => {
|
|
448
|
+
const i = t.filter((e) => e.category === a).map((e) => ({
|
|
449
449
|
label: e.label,
|
|
450
450
|
value: e.value,
|
|
451
451
|
hint: e.hint,
|
|
452
452
|
hidden: e.hidden
|
|
453
453
|
}));
|
|
454
|
-
|
|
455
|
-
}),
|
|
456
|
-
},
|
|
457
|
-
const t =
|
|
454
|
+
l.push({ category: a, entries: i });
|
|
455
|
+
}), l;
|
|
456
|
+
}, V = () => {
|
|
457
|
+
const t = qe(Be);
|
|
458
458
|
if (t)
|
|
459
459
|
return t;
|
|
460
460
|
throw new Error("useHttpClient must be used within a HttpClientProvider");
|
|
461
|
-
},
|
|
461
|
+
}, G = {
|
|
462
462
|
Template_list: "/Template/list/",
|
|
463
463
|
Template: "/Template/GetTemplate/",
|
|
464
464
|
MergeTags: "/Template/TemplateMergeTags/",
|
|
465
465
|
ExcludeCategory: "/Template/GetExcludeCategories/",
|
|
466
466
|
SaveTemplate: "/Template/save-update/",
|
|
467
|
-
TemplateTypes: "/Template/TemplateTypes/"
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
467
|
+
TemplateTypes: "/Template/TemplateTypes/",
|
|
468
|
+
markFavourite: "/Template/MarkFavourite/"
|
|
469
|
+
}, yt = () => {
|
|
470
|
+
const t = V(), { enerexIdentifier: s, projectId: l } = B();
|
|
471
|
+
return ce({
|
|
471
472
|
queryKey: ["getTemplateTags"],
|
|
472
|
-
queryFn: async (
|
|
473
|
-
`${
|
|
473
|
+
queryFn: async (i) => await t.get(
|
|
474
|
+
`${G.MergeTags}${l}/${s}`
|
|
474
475
|
)
|
|
475
476
|
});
|
|
476
|
-
},
|
|
477
|
-
const t =
|
|
478
|
-
return
|
|
477
|
+
}, gt = () => {
|
|
478
|
+
const t = V(), { enerexIdentifier: s, projectId: l } = B();
|
|
479
|
+
return ce({
|
|
479
480
|
queryKey: ["getExcludeCategory"],
|
|
480
|
-
queryFn: async (
|
|
481
|
-
`${
|
|
481
|
+
queryFn: async (i) => await t.get(
|
|
482
|
+
`${G.ExcludeCategory}${l}/${s}`
|
|
482
483
|
)
|
|
483
484
|
});
|
|
484
|
-
},
|
|
485
|
+
}, ht = ({
|
|
485
486
|
templateHTML: t,
|
|
486
487
|
className: s = "",
|
|
487
|
-
loading:
|
|
488
|
-
onEditorInitialized:
|
|
488
|
+
loading: l = !1,
|
|
489
|
+
onEditorInitialized: a
|
|
489
490
|
}) => {
|
|
490
|
-
const { post:
|
|
491
|
-
t ?? { html:
|
|
492
|
-
), { userEmail:
|
|
493
|
-
|
|
494
|
-
(async () => (await
|
|
495
|
-
}, [e,
|
|
496
|
-
async function
|
|
497
|
-
window.Zone || await new Promise((
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
|
|
491
|
+
const { post: i } = Me(), { data: e } = yt(), { data: d } = gt(), [o, b] = w(
|
|
492
|
+
t ?? { html: de, css: "" }
|
|
493
|
+
), { userEmail: D } = B(), A = st(null), m = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", _ = "https://plugins.stripo.email/api/v1/auth";
|
|
494
|
+
E(() => {
|
|
495
|
+
(async () => (await u(), e && d && await j(he.EDITOR_SCRIPT_URL)))();
|
|
496
|
+
}, [e, d]);
|
|
497
|
+
async function u() {
|
|
498
|
+
window.Zone || await new Promise((v, y) => {
|
|
499
|
+
const f = document.createElement("script");
|
|
500
|
+
f.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
|
|
501
|
+
const g = document.querySelector("script[nonce]")?.nonce;
|
|
502
|
+
g && f.setAttribute("nonce", g), f.onload = () => v(), f.onerror = () => y(new Error("Failed to load zone.js")), document.head.appendChild(f);
|
|
502
503
|
});
|
|
503
504
|
}
|
|
504
|
-
async function
|
|
505
|
-
let
|
|
505
|
+
async function j(v) {
|
|
506
|
+
let y = document.getElementById(
|
|
506
507
|
"UiEditorScript"
|
|
507
508
|
);
|
|
508
|
-
|
|
509
|
-
await
|
|
510
|
-
}, document.body.appendChild(
|
|
511
|
-
(
|
|
509
|
+
y || (y = document.createElement("script"), y.id = "UiEditorScript", y.src = v, y.onload = async () => {
|
|
510
|
+
await h();
|
|
511
|
+
}, document.body.appendChild(y)), await new Promise(
|
|
512
|
+
(f) => y.addEventListener("load", () => f(), { once: !0 })
|
|
512
513
|
);
|
|
513
514
|
}
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
if (!
|
|
515
|
+
const h = async () => {
|
|
516
|
+
const v = A.current;
|
|
517
|
+
if (!v) {
|
|
517
518
|
console.error("Missing #stripoEditorContainer in DOM");
|
|
518
519
|
return;
|
|
519
520
|
}
|
|
@@ -521,181 +522,261 @@ const z = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:
|
|
|
521
522
|
console.error("UIEditor script not loaded or not exposing initEditor");
|
|
522
523
|
return;
|
|
523
524
|
}
|
|
524
|
-
const
|
|
525
|
-
html:
|
|
526
|
-
css:
|
|
527
|
-
modulesExcludedCategories:
|
|
525
|
+
const y = {
|
|
526
|
+
html: o.html,
|
|
527
|
+
css: o.css,
|
|
528
|
+
modulesExcludedCategories: d ?? [],
|
|
528
529
|
forceRecreate: !0,
|
|
529
530
|
metadata: {
|
|
530
|
-
emailId:
|
|
531
|
+
emailId: D,
|
|
531
532
|
userId: "1",
|
|
532
533
|
// username: userName,
|
|
533
|
-
avatarUrl:
|
|
534
|
+
avatarUrl: m
|
|
534
535
|
},
|
|
535
536
|
locale: "en",
|
|
536
|
-
onTokenRefreshRequest: async (
|
|
537
|
-
const
|
|
538
|
-
pluginId:
|
|
539
|
-
secretKey:
|
|
540
|
-
userId:
|
|
537
|
+
onTokenRefreshRequest: async (f) => {
|
|
538
|
+
const g = {
|
|
539
|
+
pluginId: he.EDITOR_PLUGIN_ID,
|
|
540
|
+
secretKey: he.EDITOR_SECRET_KEY,
|
|
541
|
+
userId: D,
|
|
541
542
|
role: "user"
|
|
542
|
-
},
|
|
543
|
+
}, T = await i(
|
|
543
544
|
_,
|
|
544
|
-
|
|
545
|
+
g
|
|
545
546
|
);
|
|
546
|
-
|
|
547
|
+
T?.token && f(T.token);
|
|
547
548
|
},
|
|
548
549
|
onTemplateLoaded: () => {
|
|
549
|
-
|
|
550
|
+
a && a(!0);
|
|
550
551
|
},
|
|
551
|
-
mergeTags:
|
|
552
|
+
mergeTags: ft(e ?? [])
|
|
552
553
|
};
|
|
553
|
-
for (const [
|
|
554
|
+
for (const [f, g] of Object.entries({
|
|
554
555
|
codeEditorButtonSelector: "#codeEditor",
|
|
555
556
|
undoButtonSelector: "#undoButton",
|
|
556
557
|
redoButtonSelector: "#redoButton",
|
|
557
558
|
mobileViewButtonSelector: "#mobileViewButton",
|
|
558
559
|
desktopViewButtonSelector: "#desktopViewButton"
|
|
559
560
|
}))
|
|
560
|
-
|
|
561
|
-
await window.UIEditor.initEditor(
|
|
561
|
+
v.ownerDocument && v.getRootNode() instanceof ShadowRoot && v.getRootNode().querySelector(g) && (y[f] = g);
|
|
562
|
+
await window.UIEditor.initEditor(v, y);
|
|
562
563
|
};
|
|
563
|
-
return /* @__PURE__ */
|
|
564
|
-
|
|
565
|
-
|
|
564
|
+
return /* @__PURE__ */ n("div", { className: "position-relative", children: /* @__PURE__ */ S("div", { className: `editor-container ${s}`, children: [
|
|
565
|
+
l && /* @__PURE__ */ n("div", { className: "loading-overlay", children: /* @__PURE__ */ n(
|
|
566
|
+
z,
|
|
566
567
|
{
|
|
567
568
|
animation: "border",
|
|
568
569
|
style: { width: "11px", height: "11px" },
|
|
569
570
|
size: "sm",
|
|
570
571
|
role: "status",
|
|
571
572
|
className: "me-1",
|
|
572
|
-
children: /* @__PURE__ */
|
|
573
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
573
574
|
}
|
|
574
575
|
) }),
|
|
575
|
-
/* @__PURE__ */
|
|
576
|
-
/* @__PURE__ */
|
|
576
|
+
/* @__PURE__ */ n("div", { id: "externalSystemContainer" }),
|
|
577
|
+
/* @__PURE__ */ n("div", { id: "stripoEditorContainer", ref: A })
|
|
577
578
|
] }) });
|
|
578
|
-
},
|
|
579
|
+
}, je = ({
|
|
579
580
|
label: t,
|
|
580
581
|
register: s,
|
|
581
|
-
validation:
|
|
582
|
-
required:
|
|
583
|
-
name:
|
|
582
|
+
validation: l,
|
|
583
|
+
required: a = !1,
|
|
584
|
+
name: i,
|
|
584
585
|
error: e,
|
|
585
|
-
className:
|
|
586
|
-
...
|
|
587
|
-
}) => /* @__PURE__ */
|
|
588
|
-
t ? /* @__PURE__ */
|
|
586
|
+
className: d = "",
|
|
587
|
+
...o
|
|
588
|
+
}) => /* @__PURE__ */ S(H.Group, { className: d + " mb-1", style: { width: "100%" }, children: [
|
|
589
|
+
t ? /* @__PURE__ */ S(H.Label, { className: "mb-3 d-block form-label ts-label-height", children: [
|
|
589
590
|
t,
|
|
590
|
-
|
|
591
|
+
a && /* @__PURE__ */ n("label", { className: "text-danger", children: "*" })
|
|
591
592
|
] }) : null,
|
|
592
|
-
/* @__PURE__ */
|
|
593
|
+
/* @__PURE__ */ n(
|
|
593
594
|
H.Control,
|
|
594
595
|
{
|
|
595
|
-
name:
|
|
596
|
+
name: i,
|
|
596
597
|
type: "text",
|
|
597
|
-
...
|
|
598
|
-
isInvalid: !!(e && e[
|
|
599
|
-
...s ? s(
|
|
600
|
-
...
|
|
598
|
+
...o,
|
|
599
|
+
isInvalid: !!(e && e[i]),
|
|
600
|
+
...s ? s(i, {
|
|
601
|
+
...l
|
|
601
602
|
}) : {},
|
|
602
|
-
className: `react-select__control ${e && e[
|
|
603
|
+
className: `react-select__control ${e && e[i] && "border border-danger"}`
|
|
603
604
|
}
|
|
604
605
|
),
|
|
605
|
-
e && e[
|
|
606
|
-
] }),
|
|
607
|
-
|
|
608
|
-
|
|
606
|
+
e && e[i] ? /* @__PURE__ */ n(H.Control.Feedback, { type: "invalid", children: e[i].message }) : null
|
|
607
|
+
] }), bt = ({
|
|
608
|
+
show: t,
|
|
609
|
+
variant: s,
|
|
610
|
+
title: l = "Are you sure?",
|
|
611
|
+
message: a,
|
|
612
|
+
label: i = "Name",
|
|
613
|
+
value: e = "",
|
|
614
|
+
placeholder: d = "",
|
|
615
|
+
requiredMessage: o = "This field is required",
|
|
616
|
+
externalError: b = !1,
|
|
617
|
+
externalErrorMessage: D = "",
|
|
618
|
+
confirmText: A = "Ok",
|
|
619
|
+
cancelText: m = "Cancel",
|
|
620
|
+
confirmButtonVariant: _ = "danger",
|
|
621
|
+
onConfirm: u,
|
|
622
|
+
onCancel: j,
|
|
623
|
+
onInputChange: h
|
|
624
|
+
}) => {
|
|
625
|
+
const [v, y] = w(e), [f, g] = w(!1);
|
|
626
|
+
if (E(() => {
|
|
627
|
+
t && (y(e), g(!1));
|
|
628
|
+
}, [t, e]), E(() => {
|
|
629
|
+
b && g(!0);
|
|
630
|
+
}, [b]), !t) return null;
|
|
631
|
+
const T = s === "input" && !v.trim(), P = s === "input" && (T || b), pe = T ? o : b ? D : "", K = () => {
|
|
632
|
+
if (P) {
|
|
633
|
+
g(!0);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
u(v.trim());
|
|
637
|
+
};
|
|
638
|
+
return /* @__PURE__ */ n("div", { className: "template-studio-modal-overlay", children: /* @__PURE__ */ S("div", { className: "template-studio-modal", children: [
|
|
639
|
+
/* @__PURE__ */ S("div", { className: "template-studio-modal-header", children: [
|
|
640
|
+
/* @__PURE__ */ n("h4", { children: l }),
|
|
641
|
+
/* @__PURE__ */ n("button", { className: "template-studio-modal-close", onClick: j, children: "✕" })
|
|
642
|
+
] }),
|
|
643
|
+
/* @__PURE__ */ S("div", { className: "template-studio-modal-body", children: [
|
|
644
|
+
a && /* @__PURE__ */ n("p", { children: a }),
|
|
645
|
+
s === "input" && /* @__PURE__ */ S("div", { className: "mb-3", children: [
|
|
646
|
+
/* @__PURE__ */ S("label", { className: "form-label", children: [
|
|
647
|
+
i,
|
|
648
|
+
/* @__PURE__ */ n("span", { className: "text-danger", children: "*" })
|
|
649
|
+
] }),
|
|
650
|
+
/* @__PURE__ */ n(
|
|
651
|
+
"input",
|
|
652
|
+
{
|
|
653
|
+
type: "text",
|
|
654
|
+
className: `form-control ${f && P ? "is-invalid" : ""}`,
|
|
655
|
+
placeholder: d,
|
|
656
|
+
value: v,
|
|
657
|
+
onChange: (ee) => {
|
|
658
|
+
y(ee.target.value), f && g(!1), h?.(ee.target.value);
|
|
659
|
+
},
|
|
660
|
+
autoFocus: !0
|
|
661
|
+
}
|
|
662
|
+
),
|
|
663
|
+
f && P && /* @__PURE__ */ n("div", { className: "invalid-feedback d-block", children: pe })
|
|
664
|
+
] })
|
|
665
|
+
] }),
|
|
666
|
+
/* @__PURE__ */ S("div", { className: "template-studio-modal-footer", children: [
|
|
667
|
+
/* @__PURE__ */ n("button", { className: "btn btn-secondary", onClick: j, children: m }),
|
|
668
|
+
/* @__PURE__ */ n(
|
|
669
|
+
"button",
|
|
670
|
+
{
|
|
671
|
+
className: `btn btn-${_}`,
|
|
672
|
+
onClick: K,
|
|
673
|
+
children: A
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
] })
|
|
677
|
+
] }) });
|
|
678
|
+
}, vt = () => {
|
|
679
|
+
const t = V(), { enerexIdentifier: s, projectId: l } = B();
|
|
680
|
+
return ce({
|
|
609
681
|
queryKey: ["getTemplatesList"],
|
|
610
|
-
queryFn: async (
|
|
611
|
-
`${
|
|
682
|
+
queryFn: async (i) => await t.get(
|
|
683
|
+
`${G.Template_list}${l}/${s}`
|
|
612
684
|
)
|
|
613
685
|
});
|
|
614
686
|
};
|
|
615
|
-
function
|
|
616
|
-
return t.sort((s,
|
|
687
|
+
function be(t) {
|
|
688
|
+
return t.sort((s, l) => s.name.localeCompare(l.name));
|
|
617
689
|
}
|
|
618
|
-
function
|
|
619
|
-
const s = /* @__PURE__ */ new Map(),
|
|
690
|
+
function wt(t) {
|
|
691
|
+
const s = /* @__PURE__ */ new Map(), l = [];
|
|
620
692
|
t.forEach((e) => s.set(e.id, e));
|
|
621
|
-
let
|
|
622
|
-
for (;
|
|
623
|
-
|
|
624
|
-
const e =
|
|
625
|
-
|
|
626
|
-
(
|
|
627
|
-
),
|
|
693
|
+
let a = t.filter((e) => e.parent_id === 0), i = 0;
|
|
694
|
+
for (; a.length > 0; ) {
|
|
695
|
+
l.push({ level: i, data: a });
|
|
696
|
+
const e = a.map((o) => o.id);
|
|
697
|
+
a = t.filter(
|
|
698
|
+
(o) => e.includes(o.parent_id)
|
|
699
|
+
), i++;
|
|
628
700
|
}
|
|
629
|
-
return
|
|
701
|
+
return l;
|
|
630
702
|
}
|
|
631
|
-
function
|
|
632
|
-
const
|
|
633
|
-
return
|
|
703
|
+
function ve(t, s) {
|
|
704
|
+
const a = wt(t).find((i) => i.level === s);
|
|
705
|
+
return a ? a.data : [];
|
|
634
706
|
}
|
|
635
|
-
const
|
|
636
|
-
const t =
|
|
637
|
-
return
|
|
707
|
+
const Tt = () => {
|
|
708
|
+
const t = V(), { enerexIdentifier: s, projectId: l } = B();
|
|
709
|
+
return Te({
|
|
710
|
+
mutationKey: ["markFavourite"],
|
|
711
|
+
mutationFn: async (i) => await t.post(
|
|
712
|
+
`${G.markFavourite}${l}/${s}`,
|
|
713
|
+
i
|
|
714
|
+
)
|
|
715
|
+
});
|
|
716
|
+
}, xt = () => {
|
|
717
|
+
const t = V(), { enerexIdentifier: s, projectId: l } = B();
|
|
718
|
+
return Te({
|
|
638
719
|
mutationKey: ["getTemplate"],
|
|
639
|
-
mutationFn: async ({ id:
|
|
640
|
-
if (
|
|
720
|
+
mutationFn: async ({ id: i }) => {
|
|
721
|
+
if (i)
|
|
641
722
|
return await t.get(
|
|
642
|
-
`${
|
|
723
|
+
`${G.Template}${s}/${i}/${l}`
|
|
643
724
|
);
|
|
644
725
|
}
|
|
645
726
|
});
|
|
646
|
-
},
|
|
647
|
-
const t =
|
|
648
|
-
return
|
|
727
|
+
}, St = () => {
|
|
728
|
+
const t = V(), { enerexIdentifier: s, projectId: l } = B();
|
|
729
|
+
return ce({
|
|
649
730
|
queryKey: ["getTemplateTypes"],
|
|
650
|
-
queryFn: async (
|
|
651
|
-
`${
|
|
731
|
+
queryFn: async (i) => await t.get(
|
|
732
|
+
`${G.TemplateTypes}${s}/${l}`
|
|
652
733
|
)
|
|
653
734
|
});
|
|
654
735
|
};
|
|
655
|
-
function
|
|
736
|
+
function Ct(t) {
|
|
656
737
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
657
738
|
}
|
|
658
|
-
var
|
|
739
|
+
var we = { exports: {} };
|
|
659
740
|
/*!
|
|
660
741
|
Copyright (c) 2018 Jed Watson.
|
|
661
742
|
Licensed under the MIT License (MIT), see
|
|
662
743
|
http://jedwatson.github.io/classnames
|
|
663
744
|
*/
|
|
664
|
-
var
|
|
665
|
-
function
|
|
666
|
-
return
|
|
745
|
+
var Pe;
|
|
746
|
+
function Nt() {
|
|
747
|
+
return Pe || (Pe = 1, function(t) {
|
|
667
748
|
(function() {
|
|
668
749
|
var s = {}.hasOwnProperty;
|
|
669
|
-
function
|
|
670
|
-
for (var e = "",
|
|
671
|
-
var
|
|
672
|
-
|
|
750
|
+
function l() {
|
|
751
|
+
for (var e = "", d = 0; d < arguments.length; d++) {
|
|
752
|
+
var o = arguments[d];
|
|
753
|
+
o && (e = i(e, a(o)));
|
|
673
754
|
}
|
|
674
755
|
return e;
|
|
675
756
|
}
|
|
676
|
-
function
|
|
757
|
+
function a(e) {
|
|
677
758
|
if (typeof e == "string" || typeof e == "number")
|
|
678
759
|
return e;
|
|
679
760
|
if (typeof e != "object")
|
|
680
761
|
return "";
|
|
681
762
|
if (Array.isArray(e))
|
|
682
|
-
return
|
|
763
|
+
return l.apply(null, e);
|
|
683
764
|
if (e.toString !== Object.prototype.toString && !e.toString.toString().includes("[native code]"))
|
|
684
765
|
return e.toString();
|
|
685
|
-
var
|
|
686
|
-
for (var
|
|
687
|
-
s.call(e,
|
|
688
|
-
return
|
|
766
|
+
var d = "";
|
|
767
|
+
for (var o in e)
|
|
768
|
+
s.call(e, o) && e[o] && (d = i(d, o));
|
|
769
|
+
return d;
|
|
689
770
|
}
|
|
690
|
-
function
|
|
691
|
-
return
|
|
771
|
+
function i(e, d) {
|
|
772
|
+
return d ? e ? e + " " + d : e + d : e;
|
|
692
773
|
}
|
|
693
|
-
t.exports ? (
|
|
774
|
+
t.exports ? (l.default = l, t.exports = l) : window.classNames = l;
|
|
694
775
|
})();
|
|
695
|
-
}(
|
|
776
|
+
}(we)), we.exports;
|
|
696
777
|
}
|
|
697
|
-
var
|
|
698
|
-
const
|
|
778
|
+
var It = Nt();
|
|
779
|
+
const Oe = /* @__PURE__ */ Ct(It), $e = (t) => t.data.isSeparator ? /* @__PURE__ */ n("div", { style: { padding: 0, margin: "2px 0" }, children: /* @__PURE__ */ n(
|
|
699
780
|
"hr",
|
|
700
781
|
{
|
|
701
782
|
style: {
|
|
@@ -705,34 +786,37 @@ const he = /* @__PURE__ */ et(nt), be = (t) => t.data.isSeparator ? /* @__PURE__
|
|
|
705
786
|
margin: 0
|
|
706
787
|
}
|
|
707
788
|
}
|
|
708
|
-
) }) : /* @__PURE__ */
|
|
789
|
+
) }) : t.data.icon ? /* @__PURE__ */ S("div", { className: "d-flex align-items-center", children: [
|
|
790
|
+
/* @__PURE__ */ n(Le.Option, { ...t }),
|
|
791
|
+
/* @__PURE__ */ n("span", { className: "px-1 template-studio-dropdown-postfix-icon", children: t.data.icon })
|
|
792
|
+
] }) : /* @__PURE__ */ n(Le.Option, { ...t }), Et = ({
|
|
709
793
|
name: t = "",
|
|
710
794
|
control: s,
|
|
711
|
-
options:
|
|
712
|
-
multiple:
|
|
713
|
-
placeholder:
|
|
795
|
+
options: l,
|
|
796
|
+
multiple: a = !1,
|
|
797
|
+
placeholder: i,
|
|
714
798
|
validation: e,
|
|
715
|
-
labelKey:
|
|
716
|
-
disabled:
|
|
717
|
-
isInvalid:
|
|
718
|
-
value:
|
|
719
|
-
onChange:
|
|
720
|
-
uncontrolled:
|
|
799
|
+
labelKey: d = "name",
|
|
800
|
+
disabled: o,
|
|
801
|
+
isInvalid: b,
|
|
802
|
+
value: D,
|
|
803
|
+
onChange: A,
|
|
804
|
+
uncontrolled: m,
|
|
721
805
|
menuPlacement: _ = "auto",
|
|
722
|
-
closeOnSelect:
|
|
806
|
+
closeOnSelect: u = !0
|
|
723
807
|
}) => {
|
|
724
|
-
const
|
|
725
|
-
control: (
|
|
726
|
-
...
|
|
808
|
+
const j = {
|
|
809
|
+
control: (h) => ({
|
|
810
|
+
...h,
|
|
727
811
|
minHeight: "33px",
|
|
728
812
|
// state.isFocused can display different borderColor if you need it
|
|
729
|
-
borderColor:
|
|
730
|
-
backgroundImage:
|
|
813
|
+
borderColor: b ? "var(--bs-form-invalid-border-color) !important" : "var(--ct-input-border-color)",
|
|
814
|
+
backgroundImage: b ? '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",
|
|
731
815
|
backgroundRepeat: "no-repeat",
|
|
732
816
|
backgroundPosition: "right calc(0.375em + 0.225rem) center",
|
|
733
817
|
backgroundSize: "calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)",
|
|
734
818
|
"&:hover": {
|
|
735
|
-
borderColor:
|
|
819
|
+
borderColor: b ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
|
|
736
820
|
},
|
|
737
821
|
"& .react-select__single-value": {
|
|
738
822
|
color: "var(--ct-input-color) !important"
|
|
@@ -744,534 +828,708 @@ const he = /* @__PURE__ */ et(nt), be = (t) => t.data.isSeparator ? /* @__PURE__
|
|
|
744
828
|
display: "none"
|
|
745
829
|
}
|
|
746
830
|
}),
|
|
747
|
-
menu: (
|
|
748
|
-
...
|
|
831
|
+
menu: (h) => ({
|
|
832
|
+
...h,
|
|
749
833
|
marginTop: 0,
|
|
750
834
|
width: "max-content",
|
|
751
835
|
minWidth: "100%"
|
|
752
836
|
}),
|
|
753
|
-
menuPortal: (
|
|
754
|
-
...
|
|
837
|
+
menuPortal: (h) => ({
|
|
838
|
+
...h,
|
|
755
839
|
zIndex: 9999
|
|
756
840
|
}),
|
|
757
|
-
multiValueRemove: (
|
|
758
|
-
...
|
|
759
|
-
display:
|
|
841
|
+
multiValueRemove: (h) => ({
|
|
842
|
+
...h,
|
|
843
|
+
display: o ? "none" : "block"
|
|
760
844
|
})
|
|
761
845
|
};
|
|
762
|
-
return
|
|
763
|
-
|
|
846
|
+
return m ? /* @__PURE__ */ n(
|
|
847
|
+
Ae,
|
|
764
848
|
{
|
|
765
|
-
components: { Option:
|
|
766
|
-
isOptionDisabled: (
|
|
767
|
-
className:
|
|
768
|
-
"is-invalid":
|
|
849
|
+
components: { Option: $e },
|
|
850
|
+
isOptionDisabled: (h) => !!h.isSeparator,
|
|
851
|
+
className: Oe({
|
|
852
|
+
"is-invalid": b
|
|
769
853
|
}),
|
|
770
|
-
styles:
|
|
854
|
+
styles: j,
|
|
771
855
|
classNamePrefix: "react-select",
|
|
772
|
-
isMulti:
|
|
773
|
-
options:
|
|
774
|
-
onChange:
|
|
775
|
-
placeholder:
|
|
856
|
+
isMulti: a,
|
|
857
|
+
options: l,
|
|
858
|
+
onChange: A,
|
|
859
|
+
placeholder: i,
|
|
776
860
|
menuPortalTarget: document.body,
|
|
777
|
-
value:
|
|
778
|
-
getOptionLabel: typeof
|
|
779
|
-
getOptionValue: (
|
|
780
|
-
isDisabled:
|
|
861
|
+
value: D,
|
|
862
|
+
getOptionLabel: typeof d == "string" ? (h) => h[d] : d,
|
|
863
|
+
getOptionValue: (h) => h.id,
|
|
864
|
+
isDisabled: o,
|
|
781
865
|
menuPlacement: _,
|
|
782
|
-
closeMenuOnSelect:
|
|
866
|
+
closeMenuOnSelect: u
|
|
783
867
|
}
|
|
784
|
-
) : /* @__PURE__ */
|
|
785
|
-
|
|
868
|
+
) : /* @__PURE__ */ n(
|
|
869
|
+
dt,
|
|
786
870
|
{
|
|
787
871
|
control: s,
|
|
788
872
|
name: t,
|
|
789
873
|
rules: e,
|
|
790
|
-
render: ({ field: { onChange:
|
|
791
|
-
|
|
874
|
+
render: ({ field: { onChange: h, value: v, onBlur: y } }) => /* @__PURE__ */ n(
|
|
875
|
+
Ae,
|
|
792
876
|
{
|
|
793
|
-
components: { Option:
|
|
794
|
-
isOptionDisabled: (
|
|
795
|
-
className:
|
|
796
|
-
"is-invalid":
|
|
877
|
+
components: { Option: $e },
|
|
878
|
+
isOptionDisabled: (f) => !!f.isSeparator,
|
|
879
|
+
className: Oe({
|
|
880
|
+
"is-invalid": b
|
|
797
881
|
}),
|
|
798
|
-
styles:
|
|
882
|
+
styles: j,
|
|
799
883
|
classNamePrefix: "react-select",
|
|
800
|
-
isMulti:
|
|
801
|
-
options:
|
|
802
|
-
onBlur:
|
|
803
|
-
onChange:
|
|
804
|
-
placeholder:
|
|
884
|
+
isMulti: a,
|
|
885
|
+
options: l,
|
|
886
|
+
onBlur: y,
|
|
887
|
+
onChange: h,
|
|
888
|
+
placeholder: i,
|
|
805
889
|
menuPortalTarget: document.body,
|
|
806
|
-
value:
|
|
807
|
-
getOptionLabel: typeof
|
|
808
|
-
getOptionValue: (
|
|
809
|
-
isDisabled:
|
|
890
|
+
value: v,
|
|
891
|
+
getOptionLabel: typeof d == "string" ? (f) => f[d] : d,
|
|
892
|
+
getOptionValue: (f) => f.id,
|
|
893
|
+
isDisabled: o,
|
|
810
894
|
menuPlacement: _,
|
|
811
|
-
closeMenuOnSelect:
|
|
895
|
+
closeMenuOnSelect: u
|
|
812
896
|
},
|
|
813
|
-
|
|
897
|
+
v ? v.id || v.value || JSON.stringify(v) : "reset"
|
|
814
898
|
)
|
|
815
899
|
}
|
|
816
900
|
);
|
|
817
|
-
},
|
|
901
|
+
}, oe = ({
|
|
818
902
|
label: t,
|
|
819
903
|
name: s,
|
|
820
|
-
validation:
|
|
821
|
-
control:
|
|
822
|
-
error:
|
|
904
|
+
validation: l,
|
|
905
|
+
control: a,
|
|
906
|
+
error: i,
|
|
823
907
|
...e
|
|
824
|
-
}) => /* @__PURE__ */
|
|
825
|
-
t && /* @__PURE__ */
|
|
908
|
+
}) => /* @__PURE__ */ S(H.Group, { className: "mb-1", children: [
|
|
909
|
+
t && /* @__PURE__ */ S(H.Label, { className: "mb-3 d-block form-label ts-label-height", children: [
|
|
826
910
|
t,
|
|
827
911
|
" ",
|
|
828
|
-
e.required && /* @__PURE__ */
|
|
912
|
+
e.required && /* @__PURE__ */ n("span", { className: "text-danger", children: "*" })
|
|
829
913
|
] }),
|
|
830
|
-
/* @__PURE__ */
|
|
831
|
-
|
|
914
|
+
/* @__PURE__ */ n(
|
|
915
|
+
Et,
|
|
832
916
|
{
|
|
833
|
-
control:
|
|
917
|
+
control: a,
|
|
834
918
|
disabled: e.disabled,
|
|
835
919
|
options: e.options ?? [],
|
|
836
|
-
validation:
|
|
837
|
-
isInvalid:
|
|
920
|
+
validation: l,
|
|
921
|
+
isInvalid: i && !!i[s],
|
|
838
922
|
name: s
|
|
839
923
|
}
|
|
840
924
|
),
|
|
841
|
-
|
|
842
|
-
] }),
|
|
843
|
-
const t =
|
|
844
|
-
|
|
845
|
-
const { enerexIdentifier: s, projectId:
|
|
846
|
-
return
|
|
925
|
+
i && i[s] ? /* @__PURE__ */ n(H.Control.Feedback, { type: "invalid", children: i[s].message }) : null
|
|
926
|
+
] }), _t = () => {
|
|
927
|
+
const t = V();
|
|
928
|
+
lt();
|
|
929
|
+
const { enerexIdentifier: s, projectId: l } = B();
|
|
930
|
+
return Te({
|
|
847
931
|
mutationKey: ["saveTemplate"],
|
|
848
|
-
mutationFn: async (
|
|
849
|
-
`${
|
|
850
|
-
|
|
932
|
+
mutationFn: async (i) => (i.enerexIdentifier = s ?? "", i.projectId = l ?? "", await t.post(
|
|
933
|
+
`${G.SaveTemplate}`,
|
|
934
|
+
i
|
|
851
935
|
))
|
|
852
936
|
});
|
|
853
|
-
},
|
|
937
|
+
}, X = (t) => {
|
|
938
|
+
let s = /* @__PURE__ */ n(
|
|
939
|
+
"span",
|
|
940
|
+
{
|
|
941
|
+
style: { width: "20px", height: "20px", display: "inline-block" }
|
|
942
|
+
}
|
|
943
|
+
);
|
|
944
|
+
return t.variant === "filled" ? s = /* @__PURE__ */ n(
|
|
945
|
+
"svg",
|
|
946
|
+
{
|
|
947
|
+
version: "1.0",
|
|
948
|
+
id: "Layer_1",
|
|
949
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
950
|
+
width: "20px",
|
|
951
|
+
height: "20px",
|
|
952
|
+
viewBox: "0 0 64 64",
|
|
953
|
+
"enable-background": "new 0 0 64 64",
|
|
954
|
+
children: /* @__PURE__ */ n(
|
|
955
|
+
"path",
|
|
956
|
+
{
|
|
957
|
+
fill: "#2196F3",
|
|
958
|
+
d: `M63.893,24.277c-0.238-0.711-0.854-1.229-1.595-1.343l-19.674-3.006L33.809,1.15\r
|
|
959
|
+
C33.479,0.448,32.773,0,31.998,0s-1.48,0.448-1.811,1.15l-8.815,18.778L1.698,22.935c-0.741,0.113-1.356,0.632-1.595,1.343\r
|
|
960
|
+
c-0.238,0.71-0.059,1.494,0.465,2.031l14.294,14.657L11.484,61.67c-0.124,0.756,0.195,1.517,0.822,1.957\r
|
|
961
|
+
c0.344,0.243,0.747,0.366,1.151,0.366c0.332,0,0.666-0.084,0.968-0.25l17.572-9.719l17.572,9.719c0.302,0.166,0.636,0.25,0.968,0.25\r
|
|
962
|
+
c0.404,0,0.808-0.123,1.151-0.366c0.627-0.44,0.946-1.201,0.822-1.957l-3.378-20.704l14.294-14.657\r
|
|
963
|
+
C63.951,25.771,64.131,24.987,63.893,24.277z`
|
|
964
|
+
}
|
|
965
|
+
)
|
|
966
|
+
}
|
|
967
|
+
) : t.variant === "outlined" && (s = /* @__PURE__ */ n(
|
|
968
|
+
"svg",
|
|
969
|
+
{
|
|
970
|
+
version: "1.0",
|
|
971
|
+
id: "Layer_1",
|
|
972
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
973
|
+
width: "20px",
|
|
974
|
+
height: "20px",
|
|
975
|
+
viewBox: "0 0 64 64",
|
|
976
|
+
enableBackground: "new 0 0 64 64",
|
|
977
|
+
children: /* @__PURE__ */ n(
|
|
978
|
+
"path",
|
|
979
|
+
{
|
|
980
|
+
fill: t.fill || "rgba(247, 216, 40, 0)",
|
|
981
|
+
stroke: t.stroke || "#000000",
|
|
982
|
+
strokeWidth: t.strokeWidth || "2",
|
|
983
|
+
d: `M63.893,24.277c-0.238-0.711-0.854-1.229-1.595-1.343l-19.674-3.006L33.809,1.15\r
|
|
984
|
+
C33.479,0.448,32.773,0,31.998,0s-1.48,0.448-1.811,1.15l-8.815,18.778L1.698,22.935c-0.741,0.113-1.356,0.632-1.595,1.343\r
|
|
985
|
+
c-0.238,0.71-0.059,1.494,0.465,2.031l14.294,14.657L11.484,61.67c-0.124,0.756,0.195,1.517,0.822,1.957\r
|
|
986
|
+
c0.344,0.243,0.747,0.366,1.151,0.366c0.332,0,0.666-0.084,0.968-0.25l17.572-9.719l17.572,9.719c0.302,0.166,0.636,0.25,0.968,0.25\r
|
|
987
|
+
c0.404,0,0.808-0.123,1.151-0.366c0.627-0.44,0.946-1.201,0.822-1.957l-3.378-20.704l14.294-14.657\r
|
|
988
|
+
C63.951,25.771,64.131,24.987,63.893,24.277z`
|
|
989
|
+
}
|
|
990
|
+
)
|
|
991
|
+
}
|
|
992
|
+
)), s;
|
|
993
|
+
}, Z = {
|
|
854
994
|
id: "",
|
|
855
995
|
name: "New (Blank)"
|
|
856
|
-
},
|
|
996
|
+
}, De = {
|
|
857
997
|
id: "",
|
|
858
998
|
name: "Separator",
|
|
859
999
|
isSeparator: !0
|
|
860
|
-
},
|
|
1000
|
+
}, kt = ({
|
|
861
1001
|
onSelectItem: t,
|
|
862
1002
|
templateLoading: s,
|
|
863
|
-
onReset:
|
|
864
|
-
editorInitialized:
|
|
1003
|
+
onReset: l,
|
|
1004
|
+
editorInitialized: a
|
|
865
1005
|
}) => {
|
|
866
|
-
const { isAdmin:
|
|
867
|
-
register:
|
|
868
|
-
handleSubmit:
|
|
869
|
-
clearErrors:
|
|
870
|
-
setValue:
|
|
871
|
-
control:
|
|
872
|
-
watch:
|
|
873
|
-
reset:
|
|
874
|
-
setError:
|
|
875
|
-
|
|
876
|
-
|
|
1006
|
+
const { isAdmin: i, defaultSelector: e } = B(), { mutateAsync: d, isPending: o } = Tt(), {
|
|
1007
|
+
register: b,
|
|
1008
|
+
handleSubmit: D,
|
|
1009
|
+
clearErrors: A,
|
|
1010
|
+
setValue: m,
|
|
1011
|
+
control: _,
|
|
1012
|
+
watch: u,
|
|
1013
|
+
reset: j,
|
|
1014
|
+
setError: h,
|
|
1015
|
+
getValues: v,
|
|
1016
|
+
formState: { errors: y }
|
|
1017
|
+
} = ct({
|
|
877
1018
|
defaultValues: {
|
|
878
1019
|
templateName: "",
|
|
879
1020
|
subTemplateType: void 0,
|
|
880
1021
|
subTemplateType2: void 0,
|
|
881
1022
|
subject: "",
|
|
882
1023
|
templateType: void 0,
|
|
883
|
-
template:
|
|
1024
|
+
template: Z
|
|
884
1025
|
},
|
|
885
1026
|
mode: "onChange"
|
|
886
1027
|
}), {
|
|
887
|
-
data:
|
|
888
|
-
refetch:
|
|
889
|
-
isLoading:
|
|
890
|
-
} =
|
|
891
|
-
|
|
892
|
-
if (
|
|
893
|
-
let
|
|
894
|
-
|
|
1028
|
+
data: f,
|
|
1029
|
+
refetch: g,
|
|
1030
|
+
isLoading: T
|
|
1031
|
+
} = vt(), [P, pe] = w([]), [K, ee] = w(!1), [L, te] = w(), [ne, re] = w(), { mutateAsync: me, isPending: N } = xt(), { mutateAsync: ue, isPending: I } = _t(), { data: F, isLoading: q } = St(), [fe, Fe] = w([]), [O, se] = w([]), [$, ie] = w([]), [Ue, ye] = w(!1), [W, He] = w("confirm"), [Ve, ge] = w(!1), [xe, Se] = w(!1);
|
|
1032
|
+
E(() => {
|
|
1033
|
+
if (F) {
|
|
1034
|
+
let r = F.filter((p) => p.id != null), c = ve(r, 0);
|
|
1035
|
+
Fe(be(c));
|
|
895
1036
|
}
|
|
896
|
-
}, [
|
|
897
|
-
const
|
|
1037
|
+
}, [F]);
|
|
1038
|
+
const Ge = (r, c) => {
|
|
898
1039
|
let p = [];
|
|
899
|
-
return
|
|
900
|
-
|
|
1040
|
+
return r.forEach((C, k) => {
|
|
1041
|
+
c.includes(k) && k !== 0 && p.push(De), p.push(C);
|
|
901
1042
|
}), p;
|
|
902
1043
|
};
|
|
903
|
-
|
|
904
|
-
s(!!(
|
|
905
|
-
}, [
|
|
906
|
-
|
|
907
|
-
}, [
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
const
|
|
911
|
-
|
|
1044
|
+
E(() => {
|
|
1045
|
+
s(!!(T || N || I || q || !a));
|
|
1046
|
+
}, [T, N, I, q, a]), E(() => {
|
|
1047
|
+
f?.sort((r, c) => r.readonly !== c.readonly ? (r.readonly ? 0 : 1) - (c.readonly ? 0 : 1) : r.name.localeCompare(c.name)), pe(f ?? []);
|
|
1048
|
+
}, [f]);
|
|
1049
|
+
const Ke = async (r) => {
|
|
1050
|
+
te(r), r && (i || !r.readonly) ? (m("templateName", r?.name), A()) : (m("templateName", ""), m("subject", ""));
|
|
1051
|
+
const c = await me({ id: r?.id });
|
|
1052
|
+
c ? re(c) : ae();
|
|
912
1053
|
};
|
|
913
|
-
|
|
914
|
-
if ((e === void 0 || e.templateId === void 0 ||
|
|
915
|
-
let
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
(p) => p.parent_id.toString() === `${
|
|
1054
|
+
E(() => {
|
|
1055
|
+
if ((e === void 0 || e.templateId === void 0 || K) && m("template", Z), u("templateType")) {
|
|
1056
|
+
let r = F?.filter((p) => p.id !== void 0) ?? [], c = ve(r, 1);
|
|
1057
|
+
se(
|
|
1058
|
+
be(
|
|
1059
|
+
c.filter(
|
|
1060
|
+
(p) => p.parent_id.toString() === `${u("templateType")?.id}`
|
|
920
1061
|
)
|
|
921
1062
|
)
|
|
922
|
-
),
|
|
1063
|
+
), m("subTemplateType", void 0), m("subTemplateType2", void 0);
|
|
923
1064
|
}
|
|
924
|
-
}, [
|
|
925
|
-
if ((e === void 0 || e.templateId === void 0) &&
|
|
926
|
-
let
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
(p) => p.parent_id.toString() === `${
|
|
1065
|
+
}, [u("templateType")]), E(() => {
|
|
1066
|
+
if ((e === void 0 || e.templateId === void 0) && m("template", Z), u("subTemplateType")) {
|
|
1067
|
+
let r = F?.filter((p) => p.id !== void 0) ?? [], c = ve(r, 2);
|
|
1068
|
+
ie(
|
|
1069
|
+
be(
|
|
1070
|
+
c.filter(
|
|
1071
|
+
(p) => p.parent_id.toString() === `${u("subTemplateType")?.id}`
|
|
931
1072
|
)
|
|
932
1073
|
)
|
|
933
|
-
),
|
|
1074
|
+
), m("subTemplateType2", void 0);
|
|
934
1075
|
}
|
|
935
|
-
}, [
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
}, [
|
|
939
|
-
let
|
|
940
|
-
|
|
941
|
-
}, [
|
|
942
|
-
const [
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}, 1e3))
|
|
947
|
-
}, [
|
|
948
|
-
const
|
|
949
|
-
let
|
|
950
|
-
|
|
951
|
-
let p =
|
|
952
|
-
(
|
|
953
|
-
),
|
|
954
|
-
return
|
|
955
|
-
...
|
|
956
|
-
...
|
|
957
|
-
id:
|
|
958
|
-
name:
|
|
959
|
-
|
|
1076
|
+
}, [u("subTemplateType")]), E(() => {
|
|
1077
|
+
const r = Ne();
|
|
1078
|
+
r.length > 0 && r[0].id !== "" ? (e === void 0 || e.templateId === void 0 || K) && m("template", r[0]) : (e === void 0 || e.templateId === void 0 || K) && m("template", Z);
|
|
1079
|
+
}, [u("subTemplateType2")]), E(() => {
|
|
1080
|
+
let r = P.find((c) => c.id === u("template")?.id);
|
|
1081
|
+
Ke(r);
|
|
1082
|
+
}, [u("template")]);
|
|
1083
|
+
const [We, Ce] = w(!1);
|
|
1084
|
+
E(() => {
|
|
1085
|
+
xe || We || ne && L && a && (Ce(!0), t(ne), m("subject", ne.subject ?? ""), setTimeout(() => {
|
|
1086
|
+
Ce(!1);
|
|
1087
|
+
}, 1e3));
|
|
1088
|
+
}, [ne, L, a, xe]);
|
|
1089
|
+
const Ne = () => {
|
|
1090
|
+
let r = [Z], c = "templateType";
|
|
1091
|
+
$.length > 0 ? c = "subTemplateType2" : O.length > 0 && (c = "subTemplateType");
|
|
1092
|
+
let p = P.filter(
|
|
1093
|
+
(k) => (k.type?.toString() === u(c)?.id.toString() || k.type === null) && u(c)?.id != null
|
|
1094
|
+
), C = Ge(p, [p.findIndex((k) => !k.readonly)]);
|
|
1095
|
+
return C.length > 0 && (C[0].readonly === !0 && !i ? r = [] : r.push(De), r = [
|
|
1096
|
+
...r,
|
|
1097
|
+
...C.map((x) => ({
|
|
1098
|
+
id: x.id,
|
|
1099
|
+
name: ze(p, x.id),
|
|
1100
|
+
icon: et(p, x.id) ? /* @__PURE__ */ n(X, { variant: "filled" }) : /* @__PURE__ */ n(X, { variant: "empty" }),
|
|
1101
|
+
isSeparator: x.isSeparator
|
|
960
1102
|
}))
|
|
961
|
-
]),
|
|
1103
|
+
]), r.length ? r : [];
|
|
962
1104
|
};
|
|
963
|
-
|
|
1105
|
+
E(() => {
|
|
964
1106
|
if (e && e.type1) {
|
|
965
|
-
const
|
|
966
|
-
(
|
|
1107
|
+
const r = fe?.find(
|
|
1108
|
+
(c) => `${c.id}` === e.type1
|
|
967
1109
|
);
|
|
968
|
-
|
|
1110
|
+
m("templateType", r);
|
|
969
1111
|
}
|
|
970
|
-
}, [
|
|
1112
|
+
}, [F, fe]), E(() => {
|
|
971
1113
|
if (e && e.type2) {
|
|
972
|
-
const
|
|
973
|
-
(
|
|
1114
|
+
const r = O?.find(
|
|
1115
|
+
(c) => `${c.id}` === e.type2
|
|
974
1116
|
);
|
|
975
|
-
|
|
1117
|
+
m("subTemplateType", r);
|
|
976
1118
|
}
|
|
977
|
-
}, [
|
|
1119
|
+
}, [F, O]), E(() => {
|
|
978
1120
|
if (e && e.type3) {
|
|
979
|
-
const
|
|
980
|
-
(
|
|
1121
|
+
const r = $?.find(
|
|
1122
|
+
(c) => `${c.id}` === e.type3
|
|
981
1123
|
);
|
|
982
|
-
|
|
1124
|
+
m("subTemplateType2", r);
|
|
983
1125
|
}
|
|
984
|
-
}, [
|
|
985
|
-
if (e && e.templateId &&
|
|
986
|
-
const
|
|
987
|
-
(
|
|
1126
|
+
}, [F, $]), E(() => {
|
|
1127
|
+
if (e && e.templateId && P && P.length > 0 && !K && a) {
|
|
1128
|
+
const r = P?.find(
|
|
1129
|
+
(c) => `${c.id}` === e.templateId
|
|
988
1130
|
);
|
|
989
|
-
|
|
1131
|
+
ee(!0), r && (te(r), m("template", r));
|
|
990
1132
|
}
|
|
991
|
-
}, [
|
|
992
|
-
const
|
|
993
|
-
let p =
|
|
1133
|
+
}, [P, a]);
|
|
1134
|
+
const ze = (r, c) => {
|
|
1135
|
+
let p = r.find((C) => C.id === c);
|
|
994
1136
|
return p ? `${p.displayName}` : "";
|
|
995
|
-
},
|
|
1137
|
+
}, Qe = (r) => {
|
|
996
1138
|
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
997
|
-
async (
|
|
998
|
-
let p =
|
|
999
|
-
|
|
1000
|
-
let
|
|
1001
|
-
(
|
|
1139
|
+
async (c) => {
|
|
1140
|
+
let p = r.template.id, C = "";
|
|
1141
|
+
L?.readonly && (p = "", C = r.template.id);
|
|
1142
|
+
let k = P.find(
|
|
1143
|
+
(R) => R.name === r.templateName.trim()
|
|
1002
1144
|
);
|
|
1003
|
-
if (
|
|
1004
|
-
|
|
1145
|
+
if (k && k.id !== p) {
|
|
1146
|
+
h("templateName", {
|
|
1005
1147
|
type: "validate",
|
|
1006
1148
|
message: "Template name already exists. Please choose a different name."
|
|
1007
1149
|
});
|
|
1008
1150
|
return;
|
|
1009
1151
|
}
|
|
1010
|
-
let
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1152
|
+
let x = r.templateType.id;
|
|
1153
|
+
$ && $.length > 0 ? x = r.subTemplateType2.id : O && O.length > 0 && (x = r.subTemplateType.id);
|
|
1154
|
+
const Q = {
|
|
1013
1155
|
enerexIdentifier: "",
|
|
1014
1156
|
projectId: "",
|
|
1015
1157
|
templateId: p,
|
|
1016
|
-
templateType:
|
|
1017
|
-
name:
|
|
1018
|
-
html:
|
|
1019
|
-
css:
|
|
1020
|
-
subject:
|
|
1021
|
-
parent_id:
|
|
1158
|
+
templateType: x,
|
|
1159
|
+
name: r.templateName.trim(),
|
|
1160
|
+
html: c.html,
|
|
1161
|
+
css: c.css,
|
|
1162
|
+
subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
|
|
1163
|
+
parent_id: C
|
|
1022
1164
|
};
|
|
1023
|
-
if (await
|
|
1024
|
-
if (
|
|
1025
|
-
|
|
1165
|
+
if (await ue(Q)) {
|
|
1166
|
+
if (A(), L?.readonly && !i)
|
|
1167
|
+
j(), se([]), ie([]);
|
|
1026
1168
|
else {
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1169
|
+
const R = await me({ id: p });
|
|
1170
|
+
R ? re(R) : ae();
|
|
1029
1171
|
}
|
|
1030
|
-
|
|
1172
|
+
await g();
|
|
1031
1173
|
}
|
|
1032
1174
|
}
|
|
1033
1175
|
);
|
|
1034
|
-
},
|
|
1176
|
+
}, ae = () => {
|
|
1177
|
+
Se(!0), s(!1), re(void 0), t(void 0), setTimeout(() => {
|
|
1178
|
+
Se(!1);
|
|
1179
|
+
}, 0);
|
|
1180
|
+
}, Ye = (r, c) => {
|
|
1181
|
+
const p = c.trim(), C = "";
|
|
1182
|
+
if (P.find(
|
|
1183
|
+
(x) => x.name === p && x.id !== C
|
|
1184
|
+
)) {
|
|
1185
|
+
ge(!0);
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
ye(!1), window.StripoEditorApi.actionsApi.getTemplateData(
|
|
1189
|
+
async (x) => {
|
|
1190
|
+
const Q = r.template.id;
|
|
1191
|
+
let Y = r.templateType.id;
|
|
1192
|
+
$?.length ? Y = r.subTemplateType2.id : O?.length && (Y = r.subTemplateType.id);
|
|
1193
|
+
const R = {
|
|
1194
|
+
enerexIdentifier: "",
|
|
1195
|
+
projectId: "",
|
|
1196
|
+
templateId: C,
|
|
1197
|
+
templateType: Y,
|
|
1198
|
+
name: p,
|
|
1199
|
+
html: x.html,
|
|
1200
|
+
css: x.css,
|
|
1201
|
+
subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
|
|
1202
|
+
parent_id: Q
|
|
1203
|
+
};
|
|
1204
|
+
await ue(R) && (A(), ae(), j(), se([]), ie([]), await g(), m("template", void 0));
|
|
1205
|
+
}
|
|
1206
|
+
);
|
|
1207
|
+
}, Je = (r) => {
|
|
1035
1208
|
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
1036
|
-
async (
|
|
1037
|
-
let p =
|
|
1038
|
-
(
|
|
1209
|
+
async (c) => {
|
|
1210
|
+
let p = r.template.id, C = "", k = P.find(
|
|
1211
|
+
(R) => R.name === r.templateName.trim()
|
|
1039
1212
|
);
|
|
1040
|
-
if (
|
|
1041
|
-
|
|
1213
|
+
if (k && k.id !== p) {
|
|
1214
|
+
h("templateName", {
|
|
1042
1215
|
type: "validate",
|
|
1043
1216
|
message: "Template name already exists. Please choose a different name."
|
|
1044
1217
|
});
|
|
1045
1218
|
return;
|
|
1046
1219
|
}
|
|
1047
|
-
let
|
|
1048
|
-
|
|
1049
|
-
const
|
|
1220
|
+
let x = r.templateType.id;
|
|
1221
|
+
$ && $.length > 0 ? x = r.subTemplateType2.id : O && O.length > 0 && (x = r.subTemplateType.id);
|
|
1222
|
+
const Q = {
|
|
1050
1223
|
enerexIdentifier: "",
|
|
1051
1224
|
projectId: "",
|
|
1052
1225
|
templateId: p,
|
|
1053
|
-
templateType:
|
|
1054
|
-
name:
|
|
1055
|
-
html:
|
|
1056
|
-
css:
|
|
1057
|
-
subject:
|
|
1058
|
-
parent_id:
|
|
1226
|
+
templateType: x,
|
|
1227
|
+
name: r.templateName.trim(),
|
|
1228
|
+
html: c.html,
|
|
1229
|
+
css: c.css,
|
|
1230
|
+
subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
|
|
1231
|
+
parent_id: C
|
|
1059
1232
|
};
|
|
1060
|
-
if (await
|
|
1061
|
-
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1233
|
+
if (await ue(Q)) {
|
|
1234
|
+
A();
|
|
1235
|
+
const R = await me({ id: p });
|
|
1236
|
+
R ? re(R) : ae(), await g();
|
|
1064
1237
|
}
|
|
1065
1238
|
}
|
|
1066
1239
|
);
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
{
|
|
1108
|
-
label: "Sub Type",
|
|
1109
|
-
control: C,
|
|
1110
|
-
error: x,
|
|
1111
|
-
options: j,
|
|
1112
|
-
required: !0,
|
|
1113
|
-
disabled: u || E || I || D || !i,
|
|
1114
|
-
validation: {
|
|
1115
|
-
required: {
|
|
1116
|
-
value: !0,
|
|
1117
|
-
message: "Select a subtype"
|
|
1118
|
-
}
|
|
1119
|
-
},
|
|
1120
|
-
...a("subTemplateType2")
|
|
1121
|
-
}
|
|
1122
|
-
) }),
|
|
1123
|
-
/* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
|
|
1124
|
-
W,
|
|
1125
|
-
{
|
|
1126
|
-
label: "Template",
|
|
1127
|
-
control: C,
|
|
1128
|
-
error: x,
|
|
1129
|
-
disabled: u || E || I || D || !i,
|
|
1130
|
-
options: pe(),
|
|
1131
|
-
required: !1,
|
|
1132
|
-
...a("template")
|
|
1133
|
-
}
|
|
1134
|
-
) }),
|
|
1135
|
-
/* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
|
|
1136
|
-
ye,
|
|
1137
|
-
{
|
|
1138
|
-
label: "Name",
|
|
1139
|
-
register: a,
|
|
1140
|
-
error: x,
|
|
1141
|
-
required: !0,
|
|
1142
|
-
name: "templateName",
|
|
1143
|
-
validation: {
|
|
1144
|
-
required: {
|
|
1145
|
-
value: !0,
|
|
1146
|
-
message: "Enter a name"
|
|
1147
|
-
}
|
|
1240
|
+
}, Xe = () => {
|
|
1241
|
+
He("input"), ye(!0), ge(!1);
|
|
1242
|
+
}, Ze = (r) => {
|
|
1243
|
+
if (W === "input") {
|
|
1244
|
+
const c = v();
|
|
1245
|
+
Ye(c, r || "");
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
}, et = (r, c) => {
|
|
1249
|
+
let p = r.find((C) => C.id === c);
|
|
1250
|
+
if (p)
|
|
1251
|
+
return p.is_favourite;
|
|
1252
|
+
}, tt = async () => {
|
|
1253
|
+
let r = u("templateType")?.id;
|
|
1254
|
+
$ && $.length > 0 ? r = u("subTemplateType2")?.id : O && O.length > 0 && (r = u("subTemplateType")?.id), await d({
|
|
1255
|
+
categoryId: r ?? "",
|
|
1256
|
+
templateId: u("template")?.id ?? ""
|
|
1257
|
+
}), L && te({
|
|
1258
|
+
...L,
|
|
1259
|
+
is_favourite: !0
|
|
1260
|
+
}), await g();
|
|
1261
|
+
}, le = u("templateType"), Ie = u("subTemplateType"), nt = u("subTemplateType2"), rt = u("template");
|
|
1262
|
+
return /* @__PURE__ */ S(Ee, { children: [
|
|
1263
|
+
/* @__PURE__ */ n(ke, { className: "border border-0 text-start", children: /* @__PURE__ */ n(ke.Body, { className: "pe-0 ps-2", children: /* @__PURE__ */ n("form", { children: /* @__PURE__ */ n("div", { className: "template-list-container gap-3", children: /* @__PURE__ */ S(ot, { children: [
|
|
1264
|
+
/* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1265
|
+
oe,
|
|
1266
|
+
{
|
|
1267
|
+
label: "Category",
|
|
1268
|
+
control: _,
|
|
1269
|
+
error: y,
|
|
1270
|
+
options: fe,
|
|
1271
|
+
required: !0,
|
|
1272
|
+
disabled: T || N || I || q || o || !a,
|
|
1273
|
+
validation: {
|
|
1274
|
+
required: {
|
|
1275
|
+
value: !0,
|
|
1276
|
+
message: "Select a category"
|
|
1277
|
+
}
|
|
1278
|
+
},
|
|
1279
|
+
...b("templateType")
|
|
1148
1280
|
}
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
ye,
|
|
1153
|
-
{
|
|
1154
|
-
label: "Subject",
|
|
1155
|
-
register: a,
|
|
1156
|
-
error: x,
|
|
1157
|
-
required: !1,
|
|
1158
|
-
name: "subject"
|
|
1159
|
-
}
|
|
1160
|
-
) }),
|
|
1161
|
-
/* @__PURE__ */ $(M, { className: "d-flex align-self-start justify-content-end gap-2 mb-1 btn-padding", children: [
|
|
1162
|
-
/* @__PURE__ */ l(
|
|
1163
|
-
se,
|
|
1281
|
+
) }),
|
|
1282
|
+
O && O.length > 0 && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1283
|
+
oe,
|
|
1164
1284
|
{
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1285
|
+
label: "Type",
|
|
1286
|
+
control: _,
|
|
1287
|
+
error: y,
|
|
1288
|
+
options: O,
|
|
1289
|
+
required: !0,
|
|
1290
|
+
disabled: T || N || I || q || o || !a,
|
|
1291
|
+
validation: {
|
|
1292
|
+
required: {
|
|
1293
|
+
value: !0,
|
|
1294
|
+
message: "Select a type"
|
|
1295
|
+
}
|
|
1170
1296
|
},
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1297
|
+
...b("subTemplateType")
|
|
1298
|
+
}
|
|
1299
|
+
) }),
|
|
1300
|
+
$ && $.length > 0 && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1301
|
+
oe,
|
|
1302
|
+
{
|
|
1303
|
+
label: "Sub Type",
|
|
1304
|
+
control: _,
|
|
1305
|
+
error: y,
|
|
1306
|
+
options: $,
|
|
1307
|
+
required: !0,
|
|
1308
|
+
disabled: T || N || I || q || o || !a,
|
|
1309
|
+
validation: {
|
|
1310
|
+
required: {
|
|
1311
|
+
value: !0,
|
|
1312
|
+
message: "Select a subtype"
|
|
1180
1313
|
}
|
|
1181
|
-
|
|
1314
|
+
},
|
|
1315
|
+
...b("subTemplateType2")
|
|
1316
|
+
}
|
|
1317
|
+
) }),
|
|
1318
|
+
/* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1319
|
+
oe,
|
|
1320
|
+
{
|
|
1321
|
+
label: "Template",
|
|
1322
|
+
control: _,
|
|
1323
|
+
error: y,
|
|
1324
|
+
disabled: T || N || I || q || o || !a,
|
|
1325
|
+
options: Ne(),
|
|
1326
|
+
required: !1,
|
|
1327
|
+
...b("template")
|
|
1182
1328
|
}
|
|
1183
|
-
),
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1329
|
+
) }),
|
|
1330
|
+
/* @__PURE__ */ S(U, { className: "d-flex align-self-start", children: [
|
|
1331
|
+
/* @__PURE__ */ n(
|
|
1332
|
+
je,
|
|
1187
1333
|
{
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1334
|
+
label: "Name",
|
|
1335
|
+
register: b,
|
|
1336
|
+
error: y,
|
|
1337
|
+
required: !0,
|
|
1338
|
+
name: "templateName",
|
|
1339
|
+
validation: {
|
|
1340
|
+
required: {
|
|
1341
|
+
value: !0,
|
|
1342
|
+
message: "Enter a name"
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
),
|
|
1347
|
+
Ie?.key?.toString() === "9" && /* @__PURE__ */ n(
|
|
1348
|
+
J,
|
|
1349
|
+
{
|
|
1350
|
+
className: "template-favourite-btn",
|
|
1351
|
+
style: { width: "26px", marginTop: "25px" },
|
|
1352
|
+
variant: "light",
|
|
1353
|
+
disabled: T || N || I || q || o || (L ? L?.is_favourite : !1),
|
|
1354
|
+
onClick: tt,
|
|
1355
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1356
|
+
z,
|
|
1195
1357
|
{
|
|
1196
1358
|
animation: "border",
|
|
1197
1359
|
style: { width: "11px", height: "11px" },
|
|
1198
1360
|
size: "sm",
|
|
1199
1361
|
role: "status",
|
|
1200
1362
|
className: "me-1",
|
|
1201
|
-
children: /* @__PURE__ */
|
|
1363
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1202
1364
|
}
|
|
1203
|
-
) :
|
|
1365
|
+
) : L ? L?.is_favourite ? /* @__PURE__ */ n(X, { variant: "filled" }) : /* @__PURE__ */ n(X, { variant: "outlined" }) : /* @__PURE__ */ n(X, { variant: "outlined" })
|
|
1204
1366
|
}
|
|
1205
|
-
)
|
|
1206
|
-
|
|
1207
|
-
|
|
1367
|
+
)
|
|
1368
|
+
] }),
|
|
1369
|
+
le?.key?.toString() === "12" && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1370
|
+
je,
|
|
1371
|
+
{
|
|
1372
|
+
label: "Subject",
|
|
1373
|
+
register: b,
|
|
1374
|
+
error: y,
|
|
1375
|
+
required: !1,
|
|
1376
|
+
name: "subject"
|
|
1377
|
+
}
|
|
1378
|
+
) }),
|
|
1379
|
+
/* @__PURE__ */ S(U, { className: "d-flex align-self-start justify-content-end gap-2 mb-1 btn-padding", children: [
|
|
1380
|
+
/* @__PURE__ */ n(
|
|
1381
|
+
J,
|
|
1208
1382
|
{
|
|
1209
|
-
|
|
1210
|
-
onClick: c(Oe),
|
|
1383
|
+
style: { width: "70px" },
|
|
1211
1384
|
variant: "primary",
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1385
|
+
disabled: T || N || I || q || o || !a,
|
|
1386
|
+
onClick: () => {
|
|
1387
|
+
te(void 0), j(), se([]), ie([]), l();
|
|
1388
|
+
},
|
|
1389
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1390
|
+
z,
|
|
1216
1391
|
{
|
|
1217
1392
|
animation: "border",
|
|
1218
1393
|
style: { width: "11px", height: "11px" },
|
|
1219
1394
|
size: "sm",
|
|
1220
1395
|
role: "status",
|
|
1221
1396
|
className: "me-1",
|
|
1222
|
-
children: /* @__PURE__ */
|
|
1397
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1223
1398
|
}
|
|
1224
|
-
) : "
|
|
1399
|
+
) : "Clear"
|
|
1225
1400
|
}
|
|
1226
|
-
)
|
|
1401
|
+
),
|
|
1402
|
+
(le?.key?.toString() !== "12" || (le?.key?.toString() === "12" && (L?.id ?? "")) !== "") && /* @__PURE__ */ S(Ee, { children: [
|
|
1403
|
+
!(L?.readonly && i) && /* @__PURE__ */ n(
|
|
1404
|
+
J,
|
|
1405
|
+
{
|
|
1406
|
+
type: "button",
|
|
1407
|
+
onClick: D(Qe),
|
|
1408
|
+
variant: "primary",
|
|
1409
|
+
style: { width: "80px" },
|
|
1410
|
+
disabled: T || N || I || q || o || !a,
|
|
1411
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1412
|
+
z,
|
|
1413
|
+
{
|
|
1414
|
+
animation: "border",
|
|
1415
|
+
style: { width: "11px", height: "11px" },
|
|
1416
|
+
size: "sm",
|
|
1417
|
+
role: "status",
|
|
1418
|
+
className: "me-1",
|
|
1419
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1420
|
+
}
|
|
1421
|
+
) : L?.readonly ? "Save as" : "Save"
|
|
1422
|
+
}
|
|
1423
|
+
),
|
|
1424
|
+
(le?.key?.toString() === "28" || Ie?.key?.toString() === "9" && nt?.key?.toString() === "3" && (rt?.id ?? "") !== "") && /* @__PURE__ */ n(
|
|
1425
|
+
J,
|
|
1426
|
+
{
|
|
1427
|
+
type: "button",
|
|
1428
|
+
variant: "primary",
|
|
1429
|
+
style: { width: "80px" },
|
|
1430
|
+
onClick: () => Xe(),
|
|
1431
|
+
disabled: T || N || I || q || o || !a,
|
|
1432
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1433
|
+
z,
|
|
1434
|
+
{
|
|
1435
|
+
animation: "border",
|
|
1436
|
+
style: { width: "11px", height: "11px" },
|
|
1437
|
+
size: "sm",
|
|
1438
|
+
role: "status",
|
|
1439
|
+
className: "me-1",
|
|
1440
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1441
|
+
}
|
|
1442
|
+
) : "Save as"
|
|
1443
|
+
}
|
|
1444
|
+
),
|
|
1445
|
+
L?.readonly && i && /* @__PURE__ */ n(
|
|
1446
|
+
J,
|
|
1447
|
+
{
|
|
1448
|
+
type: "button",
|
|
1449
|
+
onClick: D(Je),
|
|
1450
|
+
variant: "primary",
|
|
1451
|
+
style: { width: "80px" },
|
|
1452
|
+
disabled: T || N || I || q || o || !a,
|
|
1453
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1454
|
+
z,
|
|
1455
|
+
{
|
|
1456
|
+
animation: "border",
|
|
1457
|
+
style: { width: "11px", height: "11px" },
|
|
1458
|
+
size: "sm",
|
|
1459
|
+
role: "status",
|
|
1460
|
+
className: "me-1",
|
|
1461
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1462
|
+
}
|
|
1463
|
+
) : "Save"
|
|
1464
|
+
}
|
|
1465
|
+
)
|
|
1466
|
+
] })
|
|
1227
1467
|
] })
|
|
1228
|
-
] })
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1468
|
+
] }) }) }) }) }),
|
|
1469
|
+
/* @__PURE__ */ n(
|
|
1470
|
+
bt,
|
|
1471
|
+
{
|
|
1472
|
+
show: Ue,
|
|
1473
|
+
variant: W,
|
|
1474
|
+
title: W === "confirm" ? "Are you sure?" : "Save Template As",
|
|
1475
|
+
message: W === "confirm" ? 'Are you sure you want to remove custom template ""?' : "",
|
|
1476
|
+
label: "New Name",
|
|
1477
|
+
requiredMessage: "Enter a new name",
|
|
1478
|
+
externalError: Ve,
|
|
1479
|
+
externalErrorMessage: "Template name already exists. Please choose a different name",
|
|
1480
|
+
confirmText: W === "confirm" ? "Ok" : "Save as",
|
|
1481
|
+
confirmButtonVariant: W === "confirm" ? "danger" : "primary",
|
|
1482
|
+
onConfirm: Ze,
|
|
1483
|
+
onCancel: () => ye(!1),
|
|
1484
|
+
onInputChange: () => ge(!1)
|
|
1485
|
+
}
|
|
1486
|
+
)
|
|
1487
|
+
] });
|
|
1488
|
+
}, Rt = ({ config: t }) => {
|
|
1489
|
+
const [s, l] = w(!1), [a, i] = w(), [e, d] = w(!1);
|
|
1490
|
+
E(() => {
|
|
1491
|
+
t.isAdmin || d(!0);
|
|
1234
1492
|
}, []);
|
|
1235
|
-
const [
|
|
1236
|
-
return /* @__PURE__ */
|
|
1237
|
-
/* @__PURE__ */
|
|
1238
|
-
|
|
1493
|
+
const [o, b] = w(!1);
|
|
1494
|
+
return /* @__PURE__ */ n(pt, { configs: t, children: /* @__PURE__ */ n(ut, { children: /* @__PURE__ */ S("div", { className: "root-widget", children: [
|
|
1495
|
+
/* @__PURE__ */ n(
|
|
1496
|
+
kt,
|
|
1239
1497
|
{
|
|
1240
|
-
templateLoading:
|
|
1241
|
-
onSelectItem: (
|
|
1242
|
-
if (
|
|
1243
|
-
let _ =
|
|
1244
|
-
window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1245
|
-
|
|
1246
|
-
|
|
1498
|
+
templateLoading: b,
|
|
1499
|
+
onSelectItem: (m) => {
|
|
1500
|
+
if (i(m), t.isAdmin && d(!0), window.StripoEditorApi && window.StripoEditorApi.actionsApi) {
|
|
1501
|
+
let _ = de;
|
|
1502
|
+
console.log("selected template:"), window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1503
|
+
m?.html ?? _,
|
|
1504
|
+
m?.css ?? "",
|
|
1247
1505
|
""
|
|
1248
1506
|
);
|
|
1249
1507
|
}
|
|
1250
1508
|
},
|
|
1251
1509
|
editorInitialized: s,
|
|
1252
1510
|
onReset: () => {
|
|
1253
|
-
|
|
1254
|
-
|
|
1511
|
+
b(!1), i(void 0), window.StripoEditorApi && window.StripoEditorApi.actionsApi && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1512
|
+
de,
|
|
1255
1513
|
"",
|
|
1256
1514
|
""
|
|
1257
1515
|
);
|
|
1258
1516
|
}
|
|
1259
1517
|
}
|
|
1260
1518
|
),
|
|
1261
|
-
e && /* @__PURE__ */
|
|
1262
|
-
|
|
1519
|
+
e && /* @__PURE__ */ n(
|
|
1520
|
+
ht,
|
|
1263
1521
|
{
|
|
1264
|
-
onEditorInitialized:
|
|
1522
|
+
onEditorInitialized: l,
|
|
1265
1523
|
templateHTML: {
|
|
1266
|
-
css:
|
|
1267
|
-
html:
|
|
1524
|
+
css: a?.css ?? "",
|
|
1525
|
+
html: a?.html ?? de
|
|
1268
1526
|
},
|
|
1269
|
-
loading:
|
|
1527
|
+
loading: o,
|
|
1270
1528
|
className: "col-span-5"
|
|
1271
1529
|
}
|
|
1272
1530
|
)
|
|
1273
1531
|
] }) }) });
|
|
1274
1532
|
};
|
|
1275
1533
|
export {
|
|
1276
|
-
|
|
1534
|
+
Rt as EditorWidget
|
|
1277
1535
|
};
|