@enerex/template-studio 1.1.38 → 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 +682 -576
- 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/queries/types.d.ts +3 -1
- 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 ie = `<!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:
|
|
381
|
+
clientId: l,
|
|
382
382
|
apiKey: i,
|
|
383
|
-
setConfiguration:
|
|
384
|
-
enerexIdentifier:
|
|
385
|
-
projectId:
|
|
386
|
-
userEmail:
|
|
387
|
-
isAdmin:
|
|
388
|
-
defaultSelector:
|
|
389
|
-
meBaseUrl:
|
|
383
|
+
setConfiguration: f,
|
|
384
|
+
enerexIdentifier: d,
|
|
385
|
+
projectId: b,
|
|
386
|
+
userEmail: A,
|
|
387
|
+
isAdmin: _,
|
|
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
|
|
401
|
+
const d = await _e.get(
|
|
402
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 (i, e,
|
|
410
|
+
}, post: async (i, e, d) => {
|
|
411
411
|
try {
|
|
412
|
-
const
|
|
412
|
+
const o = await _e.post(
|
|
413
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 i = t.filter((e) => e.category ===
|
|
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
473
|
queryFn: async (i) => await t.get(
|
|
473
|
-
`${
|
|
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
481
|
queryFn: async (i) => await t.get(
|
|
481
|
-
`${
|
|
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: i } =
|
|
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,252 +522,261 @@ const ie = `<!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
|
-
|
|
544
|
-
|
|
543
|
+
}, T = await i(
|
|
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:
|
|
582
|
+
validation: l,
|
|
583
|
+
required: a = !1,
|
|
583
584
|
name: i,
|
|
584
585
|
error: e,
|
|
585
|
-
className:
|
|
586
|
-
...
|
|
587
|
-
}) => /* @__PURE__ */ S(
|
|
588
|
-
t ? /* @__PURE__ */ S(
|
|
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
|
-
|
|
593
|
+
/* @__PURE__ */ n(
|
|
594
|
+
H.Control,
|
|
594
595
|
{
|
|
595
596
|
name: i,
|
|
596
597
|
type: "text",
|
|
597
|
-
...
|
|
598
|
+
...o,
|
|
598
599
|
isInvalid: !!(e && e[i]),
|
|
599
600
|
...s ? s(i, {
|
|
600
|
-
...
|
|
601
|
+
...l
|
|
601
602
|
}) : {},
|
|
602
603
|
className: `react-select__control ${e && e[i] && "border border-danger"}`
|
|
603
604
|
}
|
|
604
605
|
),
|
|
605
|
-
e && e[i] ? /* @__PURE__ */
|
|
606
|
-
] }),
|
|
606
|
+
e && e[i] ? /* @__PURE__ */ n(H.Control.Feedback, { type: "invalid", children: e[i].message }) : null
|
|
607
|
+
] }), bt = ({
|
|
607
608
|
show: t,
|
|
608
609
|
variant: s,
|
|
609
|
-
title:
|
|
610
|
-
message:
|
|
610
|
+
title: l = "Are you sure?",
|
|
611
|
+
message: a,
|
|
611
612
|
label: i = "Name",
|
|
612
613
|
value: e = "",
|
|
613
|
-
placeholder:
|
|
614
|
-
requiredMessage:
|
|
615
|
-
externalError:
|
|
616
|
-
externalErrorMessage:
|
|
617
|
-
confirmText:
|
|
618
|
-
cancelText:
|
|
619
|
-
confirmButtonVariant:
|
|
620
|
-
onConfirm:
|
|
621
|
-
onCancel:
|
|
622
|
-
onInputChange:
|
|
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
|
|
623
624
|
}) => {
|
|
624
|
-
const [
|
|
625
|
-
if (
|
|
626
|
-
t && (
|
|
627
|
-
}, [t, e]),
|
|
628
|
-
|
|
629
|
-
}, [
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
632
|
-
|
|
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);
|
|
633
634
|
return;
|
|
634
635
|
}
|
|
635
|
-
|
|
636
|
+
u(v.trim());
|
|
636
637
|
};
|
|
637
|
-
return /* @__PURE__ */
|
|
638
|
+
return /* @__PURE__ */ n("div", { className: "template-studio-modal-overlay", children: /* @__PURE__ */ S("div", { className: "template-studio-modal", children: [
|
|
638
639
|
/* @__PURE__ */ S("div", { className: "template-studio-modal-header", children: [
|
|
639
|
-
/* @__PURE__ */
|
|
640
|
-
/* @__PURE__ */
|
|
640
|
+
/* @__PURE__ */ n("h4", { children: l }),
|
|
641
|
+
/* @__PURE__ */ n("button", { className: "template-studio-modal-close", onClick: j, children: "✕" })
|
|
641
642
|
] }),
|
|
642
643
|
/* @__PURE__ */ S("div", { className: "template-studio-modal-body", children: [
|
|
643
|
-
|
|
644
|
+
a && /* @__PURE__ */ n("p", { children: a }),
|
|
644
645
|
s === "input" && /* @__PURE__ */ S("div", { className: "mb-3", children: [
|
|
645
646
|
/* @__PURE__ */ S("label", { className: "form-label", children: [
|
|
646
647
|
i,
|
|
647
|
-
/* @__PURE__ */
|
|
648
|
+
/* @__PURE__ */ n("span", { className: "text-danger", children: "*" })
|
|
648
649
|
] }),
|
|
649
|
-
/* @__PURE__ */
|
|
650
|
+
/* @__PURE__ */ n(
|
|
650
651
|
"input",
|
|
651
652
|
{
|
|
652
653
|
type: "text",
|
|
653
|
-
className: `form-control ${
|
|
654
|
-
placeholder:
|
|
655
|
-
value:
|
|
656
|
-
onChange: (
|
|
657
|
-
|
|
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);
|
|
658
659
|
},
|
|
659
660
|
autoFocus: !0
|
|
660
661
|
}
|
|
661
662
|
),
|
|
662
|
-
|
|
663
|
+
f && P && /* @__PURE__ */ n("div", { className: "invalid-feedback d-block", children: pe })
|
|
663
664
|
] })
|
|
664
665
|
] }),
|
|
665
666
|
/* @__PURE__ */ S("div", { className: "template-studio-modal-footer", children: [
|
|
666
|
-
/* @__PURE__ */
|
|
667
|
-
/* @__PURE__ */
|
|
667
|
+
/* @__PURE__ */ n("button", { className: "btn btn-secondary", onClick: j, children: m }),
|
|
668
|
+
/* @__PURE__ */ n(
|
|
668
669
|
"button",
|
|
669
670
|
{
|
|
670
|
-
className: `btn btn-${
|
|
671
|
-
onClick:
|
|
672
|
-
children:
|
|
671
|
+
className: `btn btn-${_}`,
|
|
672
|
+
onClick: K,
|
|
673
|
+
children: A
|
|
673
674
|
}
|
|
674
675
|
)
|
|
675
676
|
] })
|
|
676
677
|
] }) });
|
|
677
|
-
},
|
|
678
|
-
const t =
|
|
679
|
-
return
|
|
678
|
+
}, vt = () => {
|
|
679
|
+
const t = V(), { enerexIdentifier: s, projectId: l } = B();
|
|
680
|
+
return ce({
|
|
680
681
|
queryKey: ["getTemplatesList"],
|
|
681
682
|
queryFn: async (i) => await t.get(
|
|
682
|
-
`${
|
|
683
|
+
`${G.Template_list}${l}/${s}`
|
|
683
684
|
)
|
|
684
685
|
});
|
|
685
686
|
};
|
|
686
|
-
function
|
|
687
|
-
return t.sort((s,
|
|
687
|
+
function be(t) {
|
|
688
|
+
return t.sort((s, l) => s.name.localeCompare(l.name));
|
|
688
689
|
}
|
|
689
|
-
function
|
|
690
|
-
const s = /* @__PURE__ */ new Map(),
|
|
690
|
+
function wt(t) {
|
|
691
|
+
const s = /* @__PURE__ */ new Map(), l = [];
|
|
691
692
|
t.forEach((e) => s.set(e.id, e));
|
|
692
|
-
let
|
|
693
|
-
for (;
|
|
694
|
-
|
|
695
|
-
const e =
|
|
696
|
-
|
|
697
|
-
(
|
|
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)
|
|
698
699
|
), i++;
|
|
699
700
|
}
|
|
700
|
-
return
|
|
701
|
+
return l;
|
|
701
702
|
}
|
|
702
|
-
function
|
|
703
|
-
const
|
|
704
|
-
return
|
|
703
|
+
function ve(t, s) {
|
|
704
|
+
const a = wt(t).find((i) => i.level === s);
|
|
705
|
+
return a ? a.data : [];
|
|
705
706
|
}
|
|
706
|
-
const
|
|
707
|
-
const t =
|
|
708
|
-
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({
|
|
709
719
|
mutationKey: ["getTemplate"],
|
|
710
720
|
mutationFn: async ({ id: i }) => {
|
|
711
721
|
if (i)
|
|
712
722
|
return await t.get(
|
|
713
|
-
`${
|
|
723
|
+
`${G.Template}${s}/${i}/${l}`
|
|
714
724
|
);
|
|
715
725
|
}
|
|
716
726
|
});
|
|
717
|
-
},
|
|
718
|
-
const t =
|
|
719
|
-
return
|
|
727
|
+
}, St = () => {
|
|
728
|
+
const t = V(), { enerexIdentifier: s, projectId: l } = B();
|
|
729
|
+
return ce({
|
|
720
730
|
queryKey: ["getTemplateTypes"],
|
|
721
731
|
queryFn: async (i) => await t.get(
|
|
722
|
-
`${
|
|
732
|
+
`${G.TemplateTypes}${s}/${l}`
|
|
723
733
|
)
|
|
724
734
|
});
|
|
725
735
|
};
|
|
726
|
-
function
|
|
736
|
+
function Ct(t) {
|
|
727
737
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
728
738
|
}
|
|
729
|
-
var
|
|
739
|
+
var we = { exports: {} };
|
|
730
740
|
/*!
|
|
731
741
|
Copyright (c) 2018 Jed Watson.
|
|
732
742
|
Licensed under the MIT License (MIT), see
|
|
733
743
|
http://jedwatson.github.io/classnames
|
|
734
744
|
*/
|
|
735
|
-
var
|
|
736
|
-
function
|
|
737
|
-
return
|
|
745
|
+
var Pe;
|
|
746
|
+
function Nt() {
|
|
747
|
+
return Pe || (Pe = 1, function(t) {
|
|
738
748
|
(function() {
|
|
739
749
|
var s = {}.hasOwnProperty;
|
|
740
|
-
function
|
|
741
|
-
for (var e = "",
|
|
742
|
-
var
|
|
743
|
-
|
|
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)));
|
|
744
754
|
}
|
|
745
755
|
return e;
|
|
746
756
|
}
|
|
747
|
-
function
|
|
757
|
+
function a(e) {
|
|
748
758
|
if (typeof e == "string" || typeof e == "number")
|
|
749
759
|
return e;
|
|
750
760
|
if (typeof e != "object")
|
|
751
761
|
return "";
|
|
752
762
|
if (Array.isArray(e))
|
|
753
|
-
return
|
|
763
|
+
return l.apply(null, e);
|
|
754
764
|
if (e.toString !== Object.prototype.toString && !e.toString.toString().includes("[native code]"))
|
|
755
765
|
return e.toString();
|
|
756
|
-
var
|
|
757
|
-
for (var
|
|
758
|
-
s.call(e,
|
|
759
|
-
return
|
|
766
|
+
var d = "";
|
|
767
|
+
for (var o in e)
|
|
768
|
+
s.call(e, o) && e[o] && (d = i(d, o));
|
|
769
|
+
return d;
|
|
760
770
|
}
|
|
761
|
-
function i(e,
|
|
762
|
-
return
|
|
771
|
+
function i(e, d) {
|
|
772
|
+
return d ? e ? e + " " + d : e + d : e;
|
|
763
773
|
}
|
|
764
|
-
t.exports ? (
|
|
774
|
+
t.exports ? (l.default = l, t.exports = l) : window.classNames = l;
|
|
765
775
|
})();
|
|
766
|
-
}(
|
|
776
|
+
}(we)), we.exports;
|
|
767
777
|
}
|
|
768
|
-
var
|
|
769
|
-
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(
|
|
770
780
|
"hr",
|
|
771
781
|
{
|
|
772
782
|
style: {
|
|
@@ -776,34 +786,37 @@ const Ie = /* @__PURE__ */ ft(gt), _e = (t) => t.data.isSeparator ? /* @__PURE__
|
|
|
776
786
|
margin: 0
|
|
777
787
|
}
|
|
778
788
|
}
|
|
779
|
-
) }) : /* @__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 = ({
|
|
780
793
|
name: t = "",
|
|
781
794
|
control: s,
|
|
782
|
-
options:
|
|
783
|
-
multiple:
|
|
795
|
+
options: l,
|
|
796
|
+
multiple: a = !1,
|
|
784
797
|
placeholder: i,
|
|
785
798
|
validation: e,
|
|
786
|
-
labelKey:
|
|
787
|
-
disabled:
|
|
788
|
-
isInvalid:
|
|
789
|
-
value:
|
|
790
|
-
onChange:
|
|
791
|
-
uncontrolled:
|
|
792
|
-
menuPlacement:
|
|
793
|
-
closeOnSelect:
|
|
799
|
+
labelKey: d = "name",
|
|
800
|
+
disabled: o,
|
|
801
|
+
isInvalid: b,
|
|
802
|
+
value: D,
|
|
803
|
+
onChange: A,
|
|
804
|
+
uncontrolled: m,
|
|
805
|
+
menuPlacement: _ = "auto",
|
|
806
|
+
closeOnSelect: u = !0
|
|
794
807
|
}) => {
|
|
795
|
-
const
|
|
796
|
-
control: (
|
|
797
|
-
...
|
|
808
|
+
const j = {
|
|
809
|
+
control: (h) => ({
|
|
810
|
+
...h,
|
|
798
811
|
minHeight: "33px",
|
|
799
812
|
// state.isFocused can display different borderColor if you need it
|
|
800
|
-
borderColor:
|
|
801
|
-
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",
|
|
802
815
|
backgroundRepeat: "no-repeat",
|
|
803
816
|
backgroundPosition: "right calc(0.375em + 0.225rem) center",
|
|
804
817
|
backgroundSize: "calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)",
|
|
805
818
|
"&:hover": {
|
|
806
|
-
borderColor:
|
|
819
|
+
borderColor: b ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
|
|
807
820
|
},
|
|
808
821
|
"& .react-select__single-value": {
|
|
809
822
|
color: "var(--ct-input-color) !important"
|
|
@@ -815,544 +828,637 @@ const Ie = /* @__PURE__ */ ft(gt), _e = (t) => t.data.isSeparator ? /* @__PURE__
|
|
|
815
828
|
display: "none"
|
|
816
829
|
}
|
|
817
830
|
}),
|
|
818
|
-
menu: (
|
|
819
|
-
...
|
|
831
|
+
menu: (h) => ({
|
|
832
|
+
...h,
|
|
820
833
|
marginTop: 0,
|
|
821
834
|
width: "max-content",
|
|
822
835
|
minWidth: "100%"
|
|
823
836
|
}),
|
|
824
|
-
menuPortal: (
|
|
825
|
-
...
|
|
837
|
+
menuPortal: (h) => ({
|
|
838
|
+
...h,
|
|
826
839
|
zIndex: 9999
|
|
827
840
|
}),
|
|
828
|
-
multiValueRemove: (
|
|
829
|
-
...
|
|
830
|
-
display:
|
|
841
|
+
multiValueRemove: (h) => ({
|
|
842
|
+
...h,
|
|
843
|
+
display: o ? "none" : "block"
|
|
831
844
|
})
|
|
832
845
|
};
|
|
833
|
-
return
|
|
834
|
-
|
|
846
|
+
return m ? /* @__PURE__ */ n(
|
|
847
|
+
Ae,
|
|
835
848
|
{
|
|
836
|
-
components: { Option:
|
|
837
|
-
isOptionDisabled: (
|
|
838
|
-
className:
|
|
839
|
-
"is-invalid":
|
|
849
|
+
components: { Option: $e },
|
|
850
|
+
isOptionDisabled: (h) => !!h.isSeparator,
|
|
851
|
+
className: Oe({
|
|
852
|
+
"is-invalid": b
|
|
840
853
|
}),
|
|
841
|
-
styles:
|
|
854
|
+
styles: j,
|
|
842
855
|
classNamePrefix: "react-select",
|
|
843
|
-
isMulti:
|
|
844
|
-
options:
|
|
845
|
-
onChange:
|
|
856
|
+
isMulti: a,
|
|
857
|
+
options: l,
|
|
858
|
+
onChange: A,
|
|
846
859
|
placeholder: i,
|
|
847
860
|
menuPortalTarget: document.body,
|
|
848
|
-
value:
|
|
849
|
-
getOptionLabel: typeof
|
|
850
|
-
getOptionValue: (
|
|
851
|
-
isDisabled:
|
|
852
|
-
menuPlacement:
|
|
853
|
-
closeMenuOnSelect:
|
|
861
|
+
value: D,
|
|
862
|
+
getOptionLabel: typeof d == "string" ? (h) => h[d] : d,
|
|
863
|
+
getOptionValue: (h) => h.id,
|
|
864
|
+
isDisabled: o,
|
|
865
|
+
menuPlacement: _,
|
|
866
|
+
closeMenuOnSelect: u
|
|
854
867
|
}
|
|
855
|
-
) : /* @__PURE__ */
|
|
856
|
-
|
|
868
|
+
) : /* @__PURE__ */ n(
|
|
869
|
+
dt,
|
|
857
870
|
{
|
|
858
871
|
control: s,
|
|
859
872
|
name: t,
|
|
860
873
|
rules: e,
|
|
861
|
-
render: ({ field: { onChange:
|
|
862
|
-
|
|
874
|
+
render: ({ field: { onChange: h, value: v, onBlur: y } }) => /* @__PURE__ */ n(
|
|
875
|
+
Ae,
|
|
863
876
|
{
|
|
864
|
-
components: { Option:
|
|
865
|
-
isOptionDisabled: (
|
|
866
|
-
className:
|
|
867
|
-
"is-invalid":
|
|
877
|
+
components: { Option: $e },
|
|
878
|
+
isOptionDisabled: (f) => !!f.isSeparator,
|
|
879
|
+
className: Oe({
|
|
880
|
+
"is-invalid": b
|
|
868
881
|
}),
|
|
869
|
-
styles:
|
|
882
|
+
styles: j,
|
|
870
883
|
classNamePrefix: "react-select",
|
|
871
|
-
isMulti:
|
|
872
|
-
options:
|
|
873
|
-
onBlur:
|
|
874
|
-
onChange:
|
|
884
|
+
isMulti: a,
|
|
885
|
+
options: l,
|
|
886
|
+
onBlur: y,
|
|
887
|
+
onChange: h,
|
|
875
888
|
placeholder: i,
|
|
876
889
|
menuPortalTarget: document.body,
|
|
877
|
-
value:
|
|
878
|
-
getOptionLabel: typeof
|
|
879
|
-
getOptionValue: (
|
|
880
|
-
isDisabled:
|
|
881
|
-
menuPlacement:
|
|
882
|
-
closeMenuOnSelect:
|
|
890
|
+
value: v,
|
|
891
|
+
getOptionLabel: typeof d == "string" ? (f) => f[d] : d,
|
|
892
|
+
getOptionValue: (f) => f.id,
|
|
893
|
+
isDisabled: o,
|
|
894
|
+
menuPlacement: _,
|
|
895
|
+
closeMenuOnSelect: u
|
|
883
896
|
},
|
|
884
|
-
|
|
897
|
+
v ? v.id || v.value || JSON.stringify(v) : "reset"
|
|
885
898
|
)
|
|
886
899
|
}
|
|
887
900
|
);
|
|
888
|
-
},
|
|
901
|
+
}, oe = ({
|
|
889
902
|
label: t,
|
|
890
903
|
name: s,
|
|
891
|
-
validation:
|
|
892
|
-
control:
|
|
904
|
+
validation: l,
|
|
905
|
+
control: a,
|
|
893
906
|
error: i,
|
|
894
907
|
...e
|
|
895
|
-
}) => /* @__PURE__ */ S(
|
|
896
|
-
t && /* @__PURE__ */ S(
|
|
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: [
|
|
897
910
|
t,
|
|
898
911
|
" ",
|
|
899
|
-
e.required && /* @__PURE__ */
|
|
912
|
+
e.required && /* @__PURE__ */ n("span", { className: "text-danger", children: "*" })
|
|
900
913
|
] }),
|
|
901
|
-
/* @__PURE__ */
|
|
902
|
-
|
|
914
|
+
/* @__PURE__ */ n(
|
|
915
|
+
Et,
|
|
903
916
|
{
|
|
904
|
-
control:
|
|
917
|
+
control: a,
|
|
905
918
|
disabled: e.disabled,
|
|
906
919
|
options: e.options ?? [],
|
|
907
|
-
validation:
|
|
920
|
+
validation: l,
|
|
908
921
|
isInvalid: i && !!i[s],
|
|
909
922
|
name: s
|
|
910
923
|
}
|
|
911
924
|
),
|
|
912
|
-
i && i[s] ? /* @__PURE__ */
|
|
913
|
-
] }),
|
|
914
|
-
const t =
|
|
915
|
-
|
|
916
|
-
const { enerexIdentifier: s, projectId:
|
|
917
|
-
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({
|
|
918
931
|
mutationKey: ["saveTemplate"],
|
|
919
|
-
mutationFn: async (i) => (i.enerexIdentifier = s ?? "", i.projectId =
|
|
920
|
-
`${
|
|
932
|
+
mutationFn: async (i) => (i.enerexIdentifier = s ?? "", i.projectId = l ?? "", await t.post(
|
|
933
|
+
`${G.SaveTemplate}`,
|
|
921
934
|
i
|
|
922
935
|
))
|
|
923
936
|
});
|
|
924
|
-
},
|
|
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 = {
|
|
925
994
|
id: "",
|
|
926
995
|
name: "New (Blank)"
|
|
927
|
-
},
|
|
996
|
+
}, De = {
|
|
928
997
|
id: "",
|
|
929
998
|
name: "Separator",
|
|
930
999
|
isSeparator: !0
|
|
931
|
-
},
|
|
1000
|
+
}, kt = ({
|
|
932
1001
|
onSelectItem: t,
|
|
933
1002
|
templateLoading: s,
|
|
934
|
-
onReset:
|
|
935
|
-
editorInitialized:
|
|
1003
|
+
onReset: l,
|
|
1004
|
+
editorInitialized: a
|
|
936
1005
|
}) => {
|
|
937
|
-
const { isAdmin: i, defaultSelector: e } =
|
|
938
|
-
register:
|
|
939
|
-
handleSubmit:
|
|
940
|
-
clearErrors:
|
|
941
|
-
setValue:
|
|
942
|
-
control:
|
|
943
|
-
watch:
|
|
944
|
-
reset:
|
|
945
|
-
setError:
|
|
946
|
-
getValues:
|
|
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,
|
|
947
1016
|
formState: { errors: y }
|
|
948
|
-
} =
|
|
1017
|
+
} = ct({
|
|
949
1018
|
defaultValues: {
|
|
950
1019
|
templateName: "",
|
|
951
1020
|
subTemplateType: void 0,
|
|
952
1021
|
subTemplateType2: void 0,
|
|
953
1022
|
subject: "",
|
|
954
1023
|
templateType: void 0,
|
|
955
|
-
template:
|
|
1024
|
+
template: Z
|
|
956
1025
|
},
|
|
957
1026
|
mode: "onChange"
|
|
958
1027
|
}), {
|
|
959
|
-
data:
|
|
960
|
-
refetch:
|
|
961
|
-
isLoading:
|
|
962
|
-
} =
|
|
963
|
-
|
|
964
|
-
if (
|
|
965
|
-
let
|
|
966
|
-
|
|
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));
|
|
967
1036
|
}
|
|
968
|
-
}, [
|
|
969
|
-
const
|
|
970
|
-
let
|
|
971
|
-
return
|
|
972
|
-
|
|
973
|
-
}),
|
|
1037
|
+
}, [F]);
|
|
1038
|
+
const Ge = (r, c) => {
|
|
1039
|
+
let p = [];
|
|
1040
|
+
return r.forEach((C, k) => {
|
|
1041
|
+
c.includes(k) && k !== 0 && p.push(De), p.push(C);
|
|
1042
|
+
}), p;
|
|
974
1043
|
};
|
|
975
|
-
|
|
976
|
-
s(!!(
|
|
977
|
-
}, [
|
|
978
|
-
|
|
979
|
-
}, [
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
const
|
|
983
|
-
|
|
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();
|
|
984
1053
|
};
|
|
985
|
-
|
|
986
|
-
if ((e === void 0 || e.templateId === void 0 ||
|
|
987
|
-
let
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
(
|
|
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}`
|
|
992
1061
|
)
|
|
993
1062
|
)
|
|
994
|
-
),
|
|
1063
|
+
), m("subTemplateType", void 0), m("subTemplateType2", void 0);
|
|
995
1064
|
}
|
|
996
|
-
}, [
|
|
997
|
-
if ((e === void 0 || e.templateId === void 0) &&
|
|
998
|
-
let
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
(
|
|
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}`
|
|
1003
1072
|
)
|
|
1004
1073
|
)
|
|
1005
|
-
),
|
|
1074
|
+
), m("subTemplateType2", void 0);
|
|
1006
1075
|
}
|
|
1007
|
-
}, [
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
}, [
|
|
1011
|
-
let
|
|
1012
|
-
|
|
1013
|
-
}, [
|
|
1014
|
-
const [
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
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);
|
|
1018
1087
|
}, 1e3));
|
|
1019
|
-
}, [
|
|
1020
|
-
const
|
|
1021
|
-
let
|
|
1022
|
-
|
|
1023
|
-
let
|
|
1024
|
-
(
|
|
1025
|
-
), C =
|
|
1026
|
-
return C.length > 0 && (C[0].readonly === !0 && !i ?
|
|
1027
|
-
...
|
|
1028
|
-
...C.map((
|
|
1029
|
-
id:
|
|
1030
|
-
name:
|
|
1031
|
-
|
|
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
|
|
1032
1102
|
}))
|
|
1033
|
-
]),
|
|
1103
|
+
]), r.length ? r : [];
|
|
1034
1104
|
};
|
|
1035
|
-
|
|
1105
|
+
E(() => {
|
|
1036
1106
|
if (e && e.type1) {
|
|
1037
|
-
const
|
|
1038
|
-
(
|
|
1107
|
+
const r = fe?.find(
|
|
1108
|
+
(c) => `${c.id}` === e.type1
|
|
1039
1109
|
);
|
|
1040
|
-
|
|
1110
|
+
m("templateType", r);
|
|
1041
1111
|
}
|
|
1042
|
-
}, [
|
|
1112
|
+
}, [F, fe]), E(() => {
|
|
1043
1113
|
if (e && e.type2) {
|
|
1044
|
-
const
|
|
1045
|
-
(
|
|
1114
|
+
const r = O?.find(
|
|
1115
|
+
(c) => `${c.id}` === e.type2
|
|
1046
1116
|
);
|
|
1047
|
-
|
|
1117
|
+
m("subTemplateType", r);
|
|
1048
1118
|
}
|
|
1049
|
-
}, [
|
|
1119
|
+
}, [F, O]), E(() => {
|
|
1050
1120
|
if (e && e.type3) {
|
|
1051
|
-
const
|
|
1052
|
-
(
|
|
1121
|
+
const r = $?.find(
|
|
1122
|
+
(c) => `${c.id}` === e.type3
|
|
1053
1123
|
);
|
|
1054
|
-
|
|
1124
|
+
m("subTemplateType2", r);
|
|
1055
1125
|
}
|
|
1056
|
-
}, [
|
|
1057
|
-
if (e && e.templateId &&
|
|
1058
|
-
const
|
|
1059
|
-
(
|
|
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
|
|
1060
1130
|
);
|
|
1061
|
-
|
|
1131
|
+
ee(!0), r && (te(r), m("template", r));
|
|
1062
1132
|
}
|
|
1063
|
-
}, [
|
|
1064
|
-
const
|
|
1065
|
-
let
|
|
1066
|
-
return
|
|
1067
|
-
},
|
|
1133
|
+
}, [P, a]);
|
|
1134
|
+
const ze = (r, c) => {
|
|
1135
|
+
let p = r.find((C) => C.id === c);
|
|
1136
|
+
return p ? `${p.displayName}` : "";
|
|
1137
|
+
}, Qe = (r) => {
|
|
1068
1138
|
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
1069
|
-
async (
|
|
1070
|
-
let
|
|
1071
|
-
|
|
1072
|
-
let
|
|
1073
|
-
(
|
|
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()
|
|
1074
1144
|
);
|
|
1075
|
-
if (
|
|
1076
|
-
|
|
1145
|
+
if (k && k.id !== p) {
|
|
1146
|
+
h("templateName", {
|
|
1077
1147
|
type: "validate",
|
|
1078
1148
|
message: "Template name already exists. Please choose a different name."
|
|
1079
1149
|
});
|
|
1080
1150
|
return;
|
|
1081
1151
|
}
|
|
1082
|
-
let
|
|
1083
|
-
|
|
1084
|
-
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 = {
|
|
1085
1155
|
enerexIdentifier: "",
|
|
1086
1156
|
projectId: "",
|
|
1087
|
-
templateId:
|
|
1088
|
-
templateType:
|
|
1089
|
-
name:
|
|
1090
|
-
html:
|
|
1091
|
-
css:
|
|
1092
|
-
subject:
|
|
1157
|
+
templateId: p,
|
|
1158
|
+
templateType: x,
|
|
1159
|
+
name: r.templateName.trim(),
|
|
1160
|
+
html: c.html,
|
|
1161
|
+
css: c.css,
|
|
1162
|
+
subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
|
|
1093
1163
|
parent_id: C
|
|
1094
1164
|
};
|
|
1095
|
-
if (await
|
|
1096
|
-
if (
|
|
1097
|
-
|
|
1165
|
+
if (await ue(Q)) {
|
|
1166
|
+
if (A(), L?.readonly && !i)
|
|
1167
|
+
j(), se([]), ie([]);
|
|
1098
1168
|
else {
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1169
|
+
const R = await me({ id: p });
|
|
1170
|
+
R ? re(R) : ae();
|
|
1101
1171
|
}
|
|
1102
|
-
|
|
1172
|
+
await g();
|
|
1103
1173
|
}
|
|
1104
1174
|
}
|
|
1105
1175
|
);
|
|
1106
|
-
},
|
|
1107
|
-
|
|
1108
|
-
|
|
1176
|
+
}, ae = () => {
|
|
1177
|
+
Se(!0), s(!1), re(void 0), t(void 0), setTimeout(() => {
|
|
1178
|
+
Se(!1);
|
|
1109
1179
|
}, 0);
|
|
1110
|
-
},
|
|
1111
|
-
const
|
|
1112
|
-
if (
|
|
1113
|
-
(
|
|
1180
|
+
}, Ye = (r, c) => {
|
|
1181
|
+
const p = c.trim(), C = "";
|
|
1182
|
+
if (P.find(
|
|
1183
|
+
(x) => x.name === p && x.id !== C
|
|
1114
1184
|
)) {
|
|
1115
|
-
|
|
1185
|
+
ge(!0);
|
|
1116
1186
|
return;
|
|
1117
1187
|
}
|
|
1118
|
-
|
|
1119
|
-
async (
|
|
1120
|
-
const
|
|
1121
|
-
let Y =
|
|
1122
|
-
|
|
1123
|
-
const
|
|
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 = {
|
|
1124
1194
|
enerexIdentifier: "",
|
|
1125
1195
|
projectId: "",
|
|
1126
1196
|
templateId: C,
|
|
1127
1197
|
templateType: Y,
|
|
1128
|
-
name:
|
|
1129
|
-
html:
|
|
1130
|
-
css:
|
|
1131
|
-
subject:
|
|
1132
|
-
parent_id:
|
|
1198
|
+
name: p,
|
|
1199
|
+
html: x.html,
|
|
1200
|
+
css: x.css,
|
|
1201
|
+
subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
|
|
1202
|
+
parent_id: Q
|
|
1133
1203
|
};
|
|
1134
|
-
await
|
|
1204
|
+
await ue(R) && (A(), ae(), j(), se([]), ie([]), await g(), m("template", void 0));
|
|
1135
1205
|
}
|
|
1136
1206
|
);
|
|
1137
|
-
},
|
|
1207
|
+
}, Je = (r) => {
|
|
1138
1208
|
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
1139
|
-
async (
|
|
1140
|
-
let
|
|
1141
|
-
(
|
|
1209
|
+
async (c) => {
|
|
1210
|
+
let p = r.template.id, C = "", k = P.find(
|
|
1211
|
+
(R) => R.name === r.templateName.trim()
|
|
1142
1212
|
);
|
|
1143
|
-
if (
|
|
1144
|
-
|
|
1213
|
+
if (k && k.id !== p) {
|
|
1214
|
+
h("templateName", {
|
|
1145
1215
|
type: "validate",
|
|
1146
1216
|
message: "Template name already exists. Please choose a different name."
|
|
1147
1217
|
});
|
|
1148
1218
|
return;
|
|
1149
1219
|
}
|
|
1150
|
-
let
|
|
1151
|
-
|
|
1152
|
-
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 = {
|
|
1153
1223
|
enerexIdentifier: "",
|
|
1154
1224
|
projectId: "",
|
|
1155
|
-
templateId:
|
|
1156
|
-
templateType:
|
|
1157
|
-
name:
|
|
1158
|
-
html:
|
|
1159
|
-
css:
|
|
1160
|
-
subject:
|
|
1225
|
+
templateId: p,
|
|
1226
|
+
templateType: x,
|
|
1227
|
+
name: r.templateName.trim(),
|
|
1228
|
+
html: c.html,
|
|
1229
|
+
css: c.css,
|
|
1230
|
+
subject: r.templateType.id === "2" ? r?.subject ?? "" : "",
|
|
1161
1231
|
parent_id: C
|
|
1162
1232
|
};
|
|
1163
|
-
if (await
|
|
1164
|
-
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1233
|
+
if (await ue(Q)) {
|
|
1234
|
+
A();
|
|
1235
|
+
const R = await me({ id: p });
|
|
1236
|
+
R ? re(R) : ae(), await g();
|
|
1167
1237
|
}
|
|
1168
1238
|
}
|
|
1169
1239
|
);
|
|
1170
|
-
},
|
|
1171
|
-
|
|
1172
|
-
},
|
|
1173
|
-
if (
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1240
|
+
}, Xe = () => {
|
|
1241
|
+
He("input"), ye(!0), ge(!1);
|
|
1242
|
+
}, Ze = (r) => {
|
|
1243
|
+
if (W === "input") {
|
|
1244
|
+
const c = v();
|
|
1245
|
+
Ye(c, r || "");
|
|
1176
1246
|
return;
|
|
1177
1247
|
}
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
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,
|
|
1183
1266
|
{
|
|
1184
1267
|
label: "Category",
|
|
1185
|
-
control:
|
|
1268
|
+
control: _,
|
|
1186
1269
|
error: y,
|
|
1187
|
-
options:
|
|
1270
|
+
options: fe,
|
|
1188
1271
|
required: !0,
|
|
1189
|
-
disabled:
|
|
1272
|
+
disabled: T || N || I || q || o || !a,
|
|
1190
1273
|
validation: {
|
|
1191
1274
|
required: {
|
|
1192
1275
|
value: !0,
|
|
1193
1276
|
message: "Select a category"
|
|
1194
1277
|
}
|
|
1195
1278
|
},
|
|
1196
|
-
...
|
|
1279
|
+
...b("templateType")
|
|
1197
1280
|
}
|
|
1198
1281
|
) }),
|
|
1199
|
-
|
|
1200
|
-
|
|
1282
|
+
O && O.length > 0 && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1283
|
+
oe,
|
|
1201
1284
|
{
|
|
1202
1285
|
label: "Type",
|
|
1203
|
-
control:
|
|
1286
|
+
control: _,
|
|
1204
1287
|
error: y,
|
|
1205
|
-
options:
|
|
1288
|
+
options: O,
|
|
1206
1289
|
required: !0,
|
|
1207
|
-
disabled:
|
|
1290
|
+
disabled: T || N || I || q || o || !a,
|
|
1208
1291
|
validation: {
|
|
1209
1292
|
required: {
|
|
1210
1293
|
value: !0,
|
|
1211
1294
|
message: "Select a type"
|
|
1212
1295
|
}
|
|
1213
1296
|
},
|
|
1214
|
-
...
|
|
1297
|
+
...b("subTemplateType")
|
|
1215
1298
|
}
|
|
1216
1299
|
) }),
|
|
1217
|
-
|
|
1218
|
-
|
|
1300
|
+
$ && $.length > 0 && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1301
|
+
oe,
|
|
1219
1302
|
{
|
|
1220
1303
|
label: "Sub Type",
|
|
1221
|
-
control:
|
|
1304
|
+
control: _,
|
|
1222
1305
|
error: y,
|
|
1223
|
-
options:
|
|
1306
|
+
options: $,
|
|
1224
1307
|
required: !0,
|
|
1225
|
-
disabled:
|
|
1308
|
+
disabled: T || N || I || q || o || !a,
|
|
1226
1309
|
validation: {
|
|
1227
1310
|
required: {
|
|
1228
1311
|
value: !0,
|
|
1229
1312
|
message: "Select a subtype"
|
|
1230
1313
|
}
|
|
1231
1314
|
},
|
|
1232
|
-
...
|
|
1315
|
+
...b("subTemplateType2")
|
|
1233
1316
|
}
|
|
1234
1317
|
) }),
|
|
1235
|
-
/* @__PURE__ */
|
|
1236
|
-
|
|
1318
|
+
/* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1319
|
+
oe,
|
|
1237
1320
|
{
|
|
1238
1321
|
label: "Template",
|
|
1239
|
-
control:
|
|
1322
|
+
control: _,
|
|
1240
1323
|
error: y,
|
|
1241
|
-
disabled:
|
|
1242
|
-
options:
|
|
1324
|
+
disabled: T || N || I || q || o || !a,
|
|
1325
|
+
options: Ne(),
|
|
1243
1326
|
required: !1,
|
|
1244
|
-
...
|
|
1327
|
+
...b("template")
|
|
1245
1328
|
}
|
|
1246
1329
|
) }),
|
|
1247
|
-
/* @__PURE__ */
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1330
|
+
/* @__PURE__ */ S(U, { className: "d-flex align-self-start", children: [
|
|
1331
|
+
/* @__PURE__ */ n(
|
|
1332
|
+
je,
|
|
1333
|
+
{
|
|
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
|
+
}
|
|
1259
1344
|
}
|
|
1260
1345
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
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,
|
|
1357
|
+
{
|
|
1358
|
+
animation: "border",
|
|
1359
|
+
style: { width: "11px", height: "11px" },
|
|
1360
|
+
size: "sm",
|
|
1361
|
+
role: "status",
|
|
1362
|
+
className: "me-1",
|
|
1363
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1364
|
+
}
|
|
1365
|
+
) : L ? L?.is_favourite ? /* @__PURE__ */ n(X, { variant: "filled" }) : /* @__PURE__ */ n(X, { variant: "outlined" }) : /* @__PURE__ */ n(X, { variant: "outlined" })
|
|
1366
|
+
}
|
|
1367
|
+
)
|
|
1368
|
+
] }),
|
|
1369
|
+
le?.key?.toString() === "12" && /* @__PURE__ */ n(U, { children: /* @__PURE__ */ n(
|
|
1370
|
+
je,
|
|
1265
1371
|
{
|
|
1266
1372
|
label: "Subject",
|
|
1267
|
-
register:
|
|
1373
|
+
register: b,
|
|
1268
1374
|
error: y,
|
|
1269
1375
|
required: !1,
|
|
1270
1376
|
name: "subject"
|
|
1271
1377
|
}
|
|
1272
1378
|
) }),
|
|
1273
|
-
/* @__PURE__ */ S(
|
|
1274
|
-
/* @__PURE__ */
|
|
1275
|
-
|
|
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,
|
|
1276
1382
|
{
|
|
1277
1383
|
style: { width: "70px" },
|
|
1278
1384
|
variant: "primary",
|
|
1279
|
-
disabled:
|
|
1385
|
+
disabled: T || N || I || q || o || !a,
|
|
1280
1386
|
onClick: () => {
|
|
1281
|
-
|
|
1387
|
+
te(void 0), j(), se([]), ie([]), l();
|
|
1282
1388
|
},
|
|
1283
|
-
children:
|
|
1284
|
-
|
|
1389
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1390
|
+
z,
|
|
1285
1391
|
{
|
|
1286
1392
|
animation: "border",
|
|
1287
1393
|
style: { width: "11px", height: "11px" },
|
|
1288
1394
|
size: "sm",
|
|
1289
1395
|
role: "status",
|
|
1290
1396
|
className: "me-1",
|
|
1291
|
-
children: /* @__PURE__ */
|
|
1397
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1292
1398
|
}
|
|
1293
1399
|
) : "Clear"
|
|
1294
1400
|
}
|
|
1295
1401
|
),
|
|
1296
|
-
(
|
|
1297
|
-
!(
|
|
1298
|
-
|
|
1402
|
+
(le?.key?.toString() !== "12" || (le?.key?.toString() === "12" && (L?.id ?? "")) !== "") && /* @__PURE__ */ S(Ee, { children: [
|
|
1403
|
+
!(L?.readonly && i) && /* @__PURE__ */ n(
|
|
1404
|
+
J,
|
|
1299
1405
|
{
|
|
1300
1406
|
type: "button",
|
|
1301
|
-
onClick:
|
|
1407
|
+
onClick: D(Qe),
|
|
1302
1408
|
variant: "primary",
|
|
1303
1409
|
style: { width: "80px" },
|
|
1304
|
-
disabled:
|
|
1305
|
-
children:
|
|
1306
|
-
|
|
1410
|
+
disabled: T || N || I || q || o || !a,
|
|
1411
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1412
|
+
z,
|
|
1307
1413
|
{
|
|
1308
1414
|
animation: "border",
|
|
1309
1415
|
style: { width: "11px", height: "11px" },
|
|
1310
1416
|
size: "sm",
|
|
1311
1417
|
role: "status",
|
|
1312
1418
|
className: "me-1",
|
|
1313
|
-
children: /* @__PURE__ */
|
|
1419
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1314
1420
|
}
|
|
1315
|
-
) :
|
|
1421
|
+
) : L?.readonly ? "Save as" : "Save"
|
|
1316
1422
|
}
|
|
1317
1423
|
),
|
|
1318
|
-
(
|
|
1319
|
-
|
|
1424
|
+
(le?.key?.toString() === "28" || Ie?.key?.toString() === "9" && nt?.key?.toString() === "3" && (rt?.id ?? "") !== "") && /* @__PURE__ */ n(
|
|
1425
|
+
J,
|
|
1320
1426
|
{
|
|
1321
1427
|
type: "button",
|
|
1322
1428
|
variant: "primary",
|
|
1323
1429
|
style: { width: "80px" },
|
|
1324
|
-
onClick: () =>
|
|
1325
|
-
disabled:
|
|
1326
|
-
children:
|
|
1327
|
-
|
|
1430
|
+
onClick: () => Xe(),
|
|
1431
|
+
disabled: T || N || I || q || o || !a,
|
|
1432
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1433
|
+
z,
|
|
1328
1434
|
{
|
|
1329
1435
|
animation: "border",
|
|
1330
1436
|
style: { width: "11px", height: "11px" },
|
|
1331
1437
|
size: "sm",
|
|
1332
1438
|
role: "status",
|
|
1333
1439
|
className: "me-1",
|
|
1334
|
-
children: /* @__PURE__ */
|
|
1440
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1335
1441
|
}
|
|
1336
1442
|
) : "Save as"
|
|
1337
1443
|
}
|
|
1338
1444
|
),
|
|
1339
|
-
|
|
1340
|
-
|
|
1445
|
+
L?.readonly && i && /* @__PURE__ */ n(
|
|
1446
|
+
J,
|
|
1341
1447
|
{
|
|
1342
1448
|
type: "button",
|
|
1343
|
-
onClick:
|
|
1449
|
+
onClick: D(Je),
|
|
1344
1450
|
variant: "primary",
|
|
1345
1451
|
style: { width: "80px" },
|
|
1346
|
-
disabled:
|
|
1347
|
-
children:
|
|
1348
|
-
|
|
1452
|
+
disabled: T || N || I || q || o || !a,
|
|
1453
|
+
children: N || I || o ? /* @__PURE__ */ n(
|
|
1454
|
+
z,
|
|
1349
1455
|
{
|
|
1350
1456
|
animation: "border",
|
|
1351
1457
|
style: { width: "11px", height: "11px" },
|
|
1352
1458
|
size: "sm",
|
|
1353
1459
|
role: "status",
|
|
1354
1460
|
className: "me-1",
|
|
1355
|
-
children: /* @__PURE__ */
|
|
1461
|
+
children: /* @__PURE__ */ n("span", { className: "visually-hidden", children: "Loading..." })
|
|
1356
1462
|
}
|
|
1357
1463
|
) : "Save"
|
|
1358
1464
|
}
|
|
@@ -1360,70 +1466,70 @@ const Ie = /* @__PURE__ */ ft(gt), _e = (t) => t.data.isSeparator ? /* @__PURE__
|
|
|
1360
1466
|
] })
|
|
1361
1467
|
] })
|
|
1362
1468
|
] }) }) }) }) }),
|
|
1363
|
-
/* @__PURE__ */
|
|
1364
|
-
|
|
1469
|
+
/* @__PURE__ */ n(
|
|
1470
|
+
bt,
|
|
1365
1471
|
{
|
|
1366
|
-
show:
|
|
1367
|
-
variant:
|
|
1368
|
-
title:
|
|
1369
|
-
message:
|
|
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 ""?' : "",
|
|
1370
1476
|
label: "New Name",
|
|
1371
1477
|
requiredMessage: "Enter a new name",
|
|
1372
|
-
externalError:
|
|
1478
|
+
externalError: Ve,
|
|
1373
1479
|
externalErrorMessage: "Template name already exists. Please choose a different name",
|
|
1374
|
-
confirmText:
|
|
1375
|
-
confirmButtonVariant:
|
|
1376
|
-
onConfirm:
|
|
1377
|
-
onCancel: () =>
|
|
1378
|
-
onInputChange: () =>
|
|
1480
|
+
confirmText: W === "confirm" ? "Ok" : "Save as",
|
|
1481
|
+
confirmButtonVariant: W === "confirm" ? "danger" : "primary",
|
|
1482
|
+
onConfirm: Ze,
|
|
1483
|
+
onCancel: () => ye(!1),
|
|
1484
|
+
onInputChange: () => ge(!1)
|
|
1379
1485
|
}
|
|
1380
1486
|
)
|
|
1381
1487
|
] });
|
|
1382
|
-
},
|
|
1383
|
-
const [s,
|
|
1384
|
-
|
|
1385
|
-
t.isAdmin ||
|
|
1488
|
+
}, Rt = ({ config: t }) => {
|
|
1489
|
+
const [s, l] = w(!1), [a, i] = w(), [e, d] = w(!1);
|
|
1490
|
+
E(() => {
|
|
1491
|
+
t.isAdmin || d(!0);
|
|
1386
1492
|
}, []);
|
|
1387
|
-
const [
|
|
1388
|
-
return /* @__PURE__ */
|
|
1389
|
-
/* @__PURE__ */
|
|
1390
|
-
|
|
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,
|
|
1391
1497
|
{
|
|
1392
|
-
templateLoading:
|
|
1393
|
-
onSelectItem: (
|
|
1394
|
-
if (i(
|
|
1395
|
-
let
|
|
1498
|
+
templateLoading: b,
|
|
1499
|
+
onSelectItem: (m) => {
|
|
1500
|
+
if (i(m), t.isAdmin && d(!0), window.StripoEditorApi && window.StripoEditorApi.actionsApi) {
|
|
1501
|
+
let _ = de;
|
|
1396
1502
|
console.log("selected template:"), window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1397
|
-
|
|
1398
|
-
|
|
1503
|
+
m?.html ?? _,
|
|
1504
|
+
m?.css ?? "",
|
|
1399
1505
|
""
|
|
1400
1506
|
);
|
|
1401
1507
|
}
|
|
1402
1508
|
},
|
|
1403
1509
|
editorInitialized: s,
|
|
1404
1510
|
onReset: () => {
|
|
1405
|
-
|
|
1406
|
-
|
|
1511
|
+
b(!1), i(void 0), window.StripoEditorApi && window.StripoEditorApi.actionsApi && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
1512
|
+
de,
|
|
1407
1513
|
"",
|
|
1408
1514
|
""
|
|
1409
1515
|
);
|
|
1410
1516
|
}
|
|
1411
1517
|
}
|
|
1412
1518
|
),
|
|
1413
|
-
e && /* @__PURE__ */
|
|
1414
|
-
|
|
1519
|
+
e && /* @__PURE__ */ n(
|
|
1520
|
+
ht,
|
|
1415
1521
|
{
|
|
1416
|
-
onEditorInitialized:
|
|
1522
|
+
onEditorInitialized: l,
|
|
1417
1523
|
templateHTML: {
|
|
1418
|
-
css:
|
|
1419
|
-
html:
|
|
1524
|
+
css: a?.css ?? "",
|
|
1525
|
+
html: a?.html ?? de
|
|
1420
1526
|
},
|
|
1421
|
-
loading:
|
|
1527
|
+
loading: o,
|
|
1422
1528
|
className: "col-span-5"
|
|
1423
1529
|
}
|
|
1424
1530
|
)
|
|
1425
1531
|
] }) }) });
|
|
1426
1532
|
};
|
|
1427
1533
|
export {
|
|
1428
|
-
|
|
1534
|
+
Rt as EditorWidget
|
|
1429
1535
|
};
|