@enerex/template-studio 1.1.41 → 1.1.44
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 +971 -899
- package/dist/enerex-template-editor.umd.js +5 -5
- package/dist/template-studio.css +1 -1
- package/dist/types/component/TemplateList/SortableTh.d.ts +11 -0
- package/dist/types/component/TemplateList/index.d.ts +0 -1
- package/dist/types/component/TemplateList/pagination/pagination.d.ts +0 -1
- package/dist/types/component/TemplateList/template-row.d.ts +0 -1
- package/dist/types/component/editor/index.d.ts +0 -1
- package/dist/types/component/editormodal/index.d.ts +0 -1
- package/dist/types/component/form-input/select.d.ts +0 -1
- package/dist/types/component/form-input/textbox.d.ts +0 -1
- package/dist/types/component/icons/down-icon.d.ts +6 -0
- package/dist/types/component/icons/ellipsis-vertical-icon.d.ts +6 -0
- package/dist/types/component/icons/maximize-icon.d.ts +2 -0
- package/dist/types/component/icons/restore-icon.d.ts +2 -0
- package/dist/types/component/icons/up-icon.d.ts +6 -0
- package/dist/types/component/loader/index.d.ts +0 -1
- package/dist/types/component/modal/index.d.ts +0 -1
- package/dist/types/component/notification/notification.d.ts +0 -1
- package/dist/types/component/template-form/index.d.ts +0 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/pages/home.d.ts +3 -0
- package/dist/types/queries/types.d.ts +2 -0
- package/dist/types/utils/utility.d.ts +1 -0
- package/package.json +6 -5
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import { jsx as t, jsxs 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 t, jsxs as d, Fragment as ye } from "react/jsx-runtime";
|
|
2
|
+
import G, { useContext as ke, useEffect as L, useState as C, useRef as te, useCallback as Se, createContext as He, memo as ze, useMemo as ae } from "react";
|
|
3
|
+
import { QueryClient as Ge, QueryClientProvider as We, useQuery as ge, useMutation as ce, useQueryClient as Ye } from "@tanstack/react-query";
|
|
4
|
+
import we from "axios";
|
|
5
|
+
import { Spinner as Qe } from "react-bootstrap";
|
|
6
|
+
import { Controller as Xe, useForm as Je } from "react-hook-form";
|
|
7
|
+
import $e, { components as Ae } from "react-select";
|
|
8
|
+
const Fe = G.createContext(
|
|
9
9
|
void 0
|
|
10
|
-
),
|
|
10
|
+
), Ze = ({
|
|
11
11
|
children: e,
|
|
12
12
|
configs: n
|
|
13
13
|
}) => {
|
|
14
|
-
const [
|
|
14
|
+
const [r, a] = G.useState(n.clientId), [i, s] = G.useState(n.apiKey), [l, o] = G.useState(
|
|
15
15
|
n.enerexIdentifier
|
|
16
|
-
), [
|
|
16
|
+
), [c, v] = G.useState(n.projectId), [E, I] = G.useState(n.userEmail), [b, x] = G.useState(n.isAdmin), [u, p] = G.useState(n.meBaseUrl), [T, h] = G.useState(
|
|
17
17
|
n.defaultSelector
|
|
18
|
-
),
|
|
19
|
-
|
|
18
|
+
), y = (g) => {
|
|
19
|
+
s(g.apiKey), a(g.clientId), v(g.projectId), o(g.enerexIdentifier), I(g.userEmail), x(g.isAdmin), h(g.defaultSelector), p(g.meBaseUrl);
|
|
20
20
|
};
|
|
21
21
|
return /* @__PURE__ */ t(
|
|
22
|
-
|
|
22
|
+
Fe.Provider,
|
|
23
23
|
{
|
|
24
24
|
value: {
|
|
25
|
-
clientId:
|
|
25
|
+
clientId: r,
|
|
26
26
|
apiKey: i,
|
|
27
|
-
setConfiguration:
|
|
27
|
+
setConfiguration: y,
|
|
28
28
|
enerexIdentifier: l,
|
|
29
|
-
projectId:
|
|
30
|
-
userEmail:
|
|
31
|
-
isAdmin:
|
|
32
|
-
defaultSelector:
|
|
33
|
-
meBaseUrl:
|
|
29
|
+
projectId: c,
|
|
30
|
+
userEmail: E,
|
|
31
|
+
isAdmin: b,
|
|
32
|
+
defaultSelector: T,
|
|
33
|
+
meBaseUrl: u
|
|
34
34
|
},
|
|
35
35
|
children: e
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
|
-
},
|
|
39
|
-
const e =
|
|
38
|
+
}, V = () => {
|
|
39
|
+
const e = ke(Fe);
|
|
40
40
|
if (!e)
|
|
41
41
|
throw new Error("widgetConfig must be used within a ConfigProvider");
|
|
42
42
|
return e;
|
|
43
|
-
},
|
|
43
|
+
}, et = ({
|
|
44
44
|
message: e,
|
|
45
45
|
type: n = "info",
|
|
46
|
-
duration:
|
|
46
|
+
duration: r = 3e3,
|
|
47
47
|
onClose: a
|
|
48
48
|
}) => (L(() => {
|
|
49
|
-
const i = setTimeout(a,
|
|
49
|
+
const i = setTimeout(a, r);
|
|
50
50
|
return () => clearTimeout(i);
|
|
51
|
-
}, [
|
|
51
|
+
}, [r, a]), /* @__PURE__ */ d("div", { className: `ts-toast ts-toast-${n}`, children: [
|
|
52
52
|
/* @__PURE__ */ t("span", { className: "ts-toast-message", children: e }),
|
|
53
53
|
/* @__PURE__ */ t("button", { className: "ts-toast-close", onClick: a, children: "×" })
|
|
54
|
-
] })),
|
|
55
|
-
const [e, n] =
|
|
56
|
-
return { showNotification:
|
|
57
|
-
(
|
|
58
|
-
|
|
54
|
+
] })), tt = () => {
|
|
55
|
+
const [e, n] = C(null), r = te(null);
|
|
56
|
+
return { showNotification: Se(
|
|
57
|
+
(s, l = "info") => {
|
|
58
|
+
r.current !== s && (r.current = s, n({ message: s, type: l }));
|
|
59
59
|
},
|
|
60
60
|
[]
|
|
61
61
|
), NotificationRenderer: () => e ? /* @__PURE__ */ t(
|
|
62
|
-
|
|
62
|
+
et,
|
|
63
63
|
{
|
|
64
64
|
message: e.message,
|
|
65
65
|
type: e.type,
|
|
66
66
|
onClose: () => {
|
|
67
|
-
|
|
67
|
+
r.current = null, n(null);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
) : null };
|
|
71
|
-
},
|
|
71
|
+
}, Oe = He(null), nt = ({
|
|
72
72
|
children: e
|
|
73
73
|
}) => {
|
|
74
|
-
const n =
|
|
75
|
-
return /* @__PURE__ */
|
|
74
|
+
const n = tt();
|
|
75
|
+
return /* @__PURE__ */ d(Oe.Provider, { value: n, children: [
|
|
76
76
|
e,
|
|
77
77
|
/* @__PURE__ */ t(n.NotificationRenderer, {})
|
|
78
78
|
] });
|
|
79
|
-
},
|
|
80
|
-
const e =
|
|
79
|
+
}, ve = () => {
|
|
80
|
+
const e = ke(Oe);
|
|
81
81
|
if (!e)
|
|
82
82
|
throw new Error(
|
|
83
83
|
"useGlobalNotification must be used within NotificationProvider"
|
|
84
84
|
);
|
|
85
85
|
return e;
|
|
86
|
-
},
|
|
86
|
+
}, je = (e = "", n) => ({ get: async (s, l) => {
|
|
87
87
|
try {
|
|
88
|
-
const o = await
|
|
89
|
-
`${e}${
|
|
88
|
+
const o = await we.get(
|
|
89
|
+
`${e}${s}`,
|
|
90
90
|
l ?? n
|
|
91
91
|
);
|
|
92
92
|
if (o.status === 200)
|
|
@@ -94,22 +94,22 @@ const Me = W.createContext(
|
|
|
94
94
|
} catch (o) {
|
|
95
95
|
throw o;
|
|
96
96
|
}
|
|
97
|
-
}, post: async (
|
|
97
|
+
}, post: async (s, l, o) => {
|
|
98
98
|
try {
|
|
99
|
-
const
|
|
100
|
-
`${e}${
|
|
99
|
+
const c = await we.post(
|
|
100
|
+
`${e}${s}`,
|
|
101
101
|
l,
|
|
102
102
|
o ?? n
|
|
103
103
|
);
|
|
104
|
-
if (
|
|
105
|
-
return
|
|
106
|
-
} catch (
|
|
107
|
-
throw
|
|
104
|
+
if (c.status === 200)
|
|
105
|
+
return c.data;
|
|
106
|
+
} catch (c) {
|
|
107
|
+
throw c;
|
|
108
108
|
}
|
|
109
|
-
}, delete: async (
|
|
109
|
+
}, delete: async (s, l) => {
|
|
110
110
|
try {
|
|
111
|
-
const o = await
|
|
112
|
-
`${e}${
|
|
111
|
+
const o = await we.delete(
|
|
112
|
+
`${e}${s}`,
|
|
113
113
|
l ?? n
|
|
114
114
|
);
|
|
115
115
|
if (o.status === 200 || o.status === 204)
|
|
@@ -117,7 +117,7 @@ const Me = W.createContext(
|
|
|
117
117
|
} catch (o) {
|
|
118
118
|
throw o;
|
|
119
119
|
}
|
|
120
|
-
} }),
|
|
120
|
+
} }), qe = G.createContext({
|
|
121
121
|
get: () => {
|
|
122
122
|
throw new Error("HttpClientContext.get not implemented");
|
|
123
123
|
},
|
|
@@ -127,20 +127,20 @@ const Me = W.createContext(
|
|
|
127
127
|
delete: () => {
|
|
128
128
|
throw new Error("HttpClientContext.delete not implemented");
|
|
129
129
|
}
|
|
130
|
-
}),
|
|
131
|
-
const { clientId: n, apiKey:
|
|
130
|
+
}), rt = ({ children: e }) => {
|
|
131
|
+
const { clientId: n, apiKey: r, isAdmin: a, meBaseUrl: i } = V(), s = {
|
|
132
132
|
headers: {
|
|
133
133
|
client_id: n,
|
|
134
|
-
"x-api-key":
|
|
134
|
+
"x-api-key": r,
|
|
135
135
|
"Security-Context": a ? "admin" : "viewer"
|
|
136
136
|
}
|
|
137
|
-
}, { get: l, post: o, delete:
|
|
138
|
-
return /* @__PURE__ */ t(
|
|
139
|
-
},
|
|
140
|
-
const n = new
|
|
141
|
-
return /* @__PURE__ */ t(
|
|
142
|
-
},
|
|
143
|
-
const e =
|
|
137
|
+
}, { get: l, post: o, delete: c } = je(i, s);
|
|
138
|
+
return /* @__PURE__ */ t(qe.Provider, { value: { get: l, post: o, delete: c }, children: e });
|
|
139
|
+
}, st = ({ children: e }) => {
|
|
140
|
+
const n = new Ge();
|
|
141
|
+
return /* @__PURE__ */ t(rt, { children: /* @__PURE__ */ t(We, { client: n, children: e }) });
|
|
142
|
+
}, Y = () => {
|
|
143
|
+
const e = ke(qe);
|
|
144
144
|
if (e)
|
|
145
145
|
return e;
|
|
146
146
|
throw new Error("useHttpClient must be used within a HttpClientProvider");
|
|
@@ -154,56 +154,56 @@ const Me = W.createContext(
|
|
|
154
154
|
markFavourite: "/Template/MarkFavourite/",
|
|
155
155
|
deleteTemplate: "/Template/DeleteTemplate/",
|
|
156
156
|
duplicateTemplate: "/Template/DuplicateTemplate/"
|
|
157
|
-
},
|
|
158
|
-
const e =
|
|
159
|
-
return
|
|
157
|
+
}, at = () => {
|
|
158
|
+
const e = Y(), { enerexIdentifier: n, projectId: r } = V();
|
|
159
|
+
return ge({
|
|
160
160
|
queryKey: ["getTemplatesList"],
|
|
161
161
|
queryFn: async (i) => await e.get(
|
|
162
|
-
`${Q.Template_list}${
|
|
162
|
+
`${Q.Template_list}${r}/${n}`
|
|
163
163
|
),
|
|
164
164
|
refetchOnWindowFocus: !1,
|
|
165
165
|
refetchOnReconnect: !1,
|
|
166
166
|
refetchOnMount: !1
|
|
167
167
|
});
|
|
168
|
-
},
|
|
169
|
-
const e =
|
|
170
|
-
return
|
|
168
|
+
}, it = () => {
|
|
169
|
+
const e = Y(), { enerexIdentifier: n, projectId: r } = V();
|
|
170
|
+
return ge({
|
|
171
171
|
queryKey: ["getTemplateTypes"],
|
|
172
172
|
queryFn: async (i) => await e.get(
|
|
173
|
-
`${Q.TemplateTypes}${n}/${
|
|
173
|
+
`${Q.TemplateTypes}${n}/${r}`
|
|
174
174
|
),
|
|
175
175
|
refetchOnWindowFocus: !1,
|
|
176
176
|
refetchOnReconnect: !1,
|
|
177
177
|
refetchOnMount: !1
|
|
178
178
|
});
|
|
179
|
-
},
|
|
180
|
-
const e =
|
|
181
|
-
return
|
|
179
|
+
}, lt = () => {
|
|
180
|
+
const e = Y(), { enerexIdentifier: n, projectId: r } = V();
|
|
181
|
+
return ce({
|
|
182
182
|
mutationKey: ["getTemplate"],
|
|
183
183
|
mutationFn: async ({ id: i }) => {
|
|
184
184
|
if (i)
|
|
185
185
|
return await e.get(
|
|
186
|
-
`${Q.Template}${n}/${i}/${
|
|
186
|
+
`${Q.Template}${n}/${i}/${r}`
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
|
-
},
|
|
190
|
+
}, ie = ({
|
|
191
191
|
size: e = "md",
|
|
192
192
|
center: n = !1,
|
|
193
|
-
overlay:
|
|
193
|
+
overlay: r = !1
|
|
194
194
|
}) => {
|
|
195
195
|
const a = /* @__PURE__ */ t("div", { className: `ts-loader ts-loader-${e}` });
|
|
196
|
-
return
|
|
197
|
-
},
|
|
198
|
-
const e =
|
|
199
|
-
return
|
|
196
|
+
return r ? /* @__PURE__ */ t("div", { className: "ts-loader-overlay", children: a }) : n ? /* @__PURE__ */ t("div", { className: "ts-loader-center", children: a }) : a;
|
|
197
|
+
}, Ue = () => {
|
|
198
|
+
const e = Y(), { enerexIdentifier: n, projectId: r } = V();
|
|
199
|
+
return ce({
|
|
200
200
|
mutationKey: ["markFavourite"],
|
|
201
201
|
mutationFn: async (i) => await e.post(
|
|
202
|
-
`${Q.markFavourite}${
|
|
202
|
+
`${Q.markFavourite}${r}/${n}`,
|
|
203
203
|
i
|
|
204
204
|
)
|
|
205
205
|
});
|
|
206
|
-
},
|
|
206
|
+
}, Le = (e) => {
|
|
207
207
|
let n = /* @__PURE__ */ t(
|
|
208
208
|
"span",
|
|
209
209
|
{
|
|
@@ -216,8 +216,8 @@ const Me = W.createContext(
|
|
|
216
216
|
version: "1.0",
|
|
217
217
|
id: "Layer_1",
|
|
218
218
|
xmlns: "http://www.w3.org/2000/svg",
|
|
219
|
-
width: "
|
|
220
|
-
height: "
|
|
219
|
+
width: "18px",
|
|
220
|
+
height: "18px",
|
|
221
221
|
viewBox: "0 0 64 64",
|
|
222
222
|
"enable-background": "new 0 0 64 64",
|
|
223
223
|
children: /* @__PURE__ */ t(
|
|
@@ -239,8 +239,8 @@ const Me = W.createContext(
|
|
|
239
239
|
version: "1.0",
|
|
240
240
|
id: "Layer_1",
|
|
241
241
|
xmlns: "http://www.w3.org/2000/svg",
|
|
242
|
-
width: "
|
|
243
|
-
height: "
|
|
242
|
+
width: "18px",
|
|
243
|
+
height: "18px",
|
|
244
244
|
viewBox: "0 0 64 64",
|
|
245
245
|
enableBackground: "new 0 0 64 64",
|
|
246
246
|
children: /* @__PURE__ */ t(
|
|
@@ -260,99 +260,151 @@ const Me = W.createContext(
|
|
|
260
260
|
}
|
|
261
261
|
)), n;
|
|
262
262
|
};
|
|
263
|
-
function
|
|
263
|
+
function Te(e) {
|
|
264
|
+
return e.sort((n, r) => n.name.localeCompare(r.name));
|
|
265
|
+
}
|
|
266
|
+
function ot(e) {
|
|
267
|
+
const n = /* @__PURE__ */ new Map(), r = [];
|
|
268
|
+
e.forEach((s) => n.set(s.id, s));
|
|
269
|
+
let a = e.filter((s) => s.parent_id === 0), i = 0;
|
|
270
|
+
for (; a.length > 0; ) {
|
|
271
|
+
r.push({ level: i, data: a });
|
|
272
|
+
const s = a.map((o) => o.id);
|
|
273
|
+
a = e.filter(
|
|
274
|
+
(o) => s.includes(o.parent_id)
|
|
275
|
+
), i++;
|
|
276
|
+
}
|
|
277
|
+
return r;
|
|
278
|
+
}
|
|
279
|
+
function Ne(e, n) {
|
|
280
|
+
const a = ot(e).find((i) => i.level === n);
|
|
281
|
+
return a ? a.data : [];
|
|
282
|
+
}
|
|
283
|
+
const ct = (e) => {
|
|
284
|
+
if (!e) return "";
|
|
285
|
+
const n = new Date(e);
|
|
286
|
+
if (isNaN(n.getTime())) return "";
|
|
287
|
+
const r = String(n.getMonth() + 1).padStart(2, "0"), a = String(n.getDate()).padStart(2, "0"), i = String(n.getFullYear()).slice(-2);
|
|
288
|
+
return `${r}/${a}/${i}`;
|
|
289
|
+
}, dt = (e) => /* @__PURE__ */ t(
|
|
290
|
+
"svg",
|
|
291
|
+
{
|
|
292
|
+
"aria-hidden": "true",
|
|
293
|
+
focusable: "false",
|
|
294
|
+
role: "img",
|
|
295
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
296
|
+
viewBox: "0 0 128 512",
|
|
297
|
+
height: "11px",
|
|
298
|
+
width: "14px",
|
|
299
|
+
...e,
|
|
300
|
+
children: /* @__PURE__ */ t(
|
|
301
|
+
"path",
|
|
302
|
+
{
|
|
303
|
+
fill: "#6c757d",
|
|
304
|
+
d: "M64 360a56 56 0 1 0 0 112 56 56 0 1 0 0-112zm0-160a56 56 0 1 0 0 112 56 56 0 1 0 0-112zM120 96A56 56 0 1 0 8 96a56 56 0 1 0 112 0z"
|
|
305
|
+
}
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
function ut({
|
|
264
310
|
template: e,
|
|
265
311
|
openActionId: n,
|
|
266
|
-
setOpenActionId:
|
|
312
|
+
setOpenActionId: r,
|
|
267
313
|
onEdit: a,
|
|
268
314
|
onDuplicate: i,
|
|
269
|
-
onRemove:
|
|
315
|
+
onRemove: s,
|
|
270
316
|
onPreview: l,
|
|
271
317
|
onRefresh: o
|
|
272
318
|
}) {
|
|
273
|
-
const { isAdmin:
|
|
319
|
+
const { isAdmin: c } = V(), v = n === e.id, E = te(null), I = te(null), [b, x, u] = e.categoryChain, { mutateAsync: p, isPending: T } = Ue(), { showNotification: h } = ve(), y = x?.key, g = u?.key, R = !c && y === 9, B = c || g !== 2, _ = c || g !== 2;
|
|
274
320
|
L(() => {
|
|
275
|
-
function
|
|
276
|
-
|
|
321
|
+
function S(D) {
|
|
322
|
+
v && E.current && !E.current.contains(D.target) && !I.current?.contains(D.target) && r(null);
|
|
277
323
|
}
|
|
278
|
-
return document.addEventListener("mousedown",
|
|
279
|
-
}, [
|
|
280
|
-
function
|
|
281
|
-
|
|
324
|
+
return document.addEventListener("mousedown", S), () => document.removeEventListener("mousedown", S);
|
|
325
|
+
}, [v, r]), L(() => {
|
|
326
|
+
function S(D) {
|
|
327
|
+
D.key === "Escape" && r(null);
|
|
282
328
|
}
|
|
283
|
-
return
|
|
284
|
-
}, [
|
|
285
|
-
if (!
|
|
286
|
-
const
|
|
287
|
-
|
|
329
|
+
return v && document.addEventListener("keydown", S), () => document.removeEventListener("keydown", S);
|
|
330
|
+
}, [v, r]), L(() => {
|
|
331
|
+
if (!v || !E.current) return;
|
|
332
|
+
const S = Array.from(
|
|
333
|
+
E.current.querySelectorAll('[role="menuitem"]')
|
|
288
334
|
);
|
|
289
|
-
if (!
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
function
|
|
293
|
-
|
|
335
|
+
if (!S.length) return;
|
|
336
|
+
let D = 0;
|
|
337
|
+
S[0].focus();
|
|
338
|
+
function M(w) {
|
|
339
|
+
w.key === "ArrowDown" && (D = (D + 1) % S.length, S[D].focus(), w.preventDefault()), w.key === "ArrowUp" && (D = (D - 1 + S.length) % S.length, S[D].focus(), w.preventDefault());
|
|
294
340
|
}
|
|
295
|
-
return document.addEventListener("keydown",
|
|
296
|
-
}, [
|
|
297
|
-
const
|
|
341
|
+
return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
|
|
342
|
+
}, [v]);
|
|
343
|
+
const A = async () => {
|
|
298
344
|
try {
|
|
299
|
-
await
|
|
300
|
-
categoryId:
|
|
345
|
+
await p({
|
|
346
|
+
categoryId: g?.toString() ?? "",
|
|
301
347
|
templateId: e.id ?? ""
|
|
302
|
-
}), o(),
|
|
348
|
+
}), o(), h(
|
|
303
349
|
`Template "${e?.name}" marked as favourite`,
|
|
304
350
|
"success"
|
|
305
351
|
);
|
|
306
|
-
} catch (
|
|
307
|
-
console.error(
|
|
352
|
+
} catch (S) {
|
|
353
|
+
console.error(S), h(
|
|
308
354
|
"Unable to mark template as favourite. Please try again.",
|
|
309
355
|
"error"
|
|
310
356
|
);
|
|
311
357
|
}
|
|
312
358
|
};
|
|
313
|
-
return /* @__PURE__ */ t(
|
|
314
|
-
/* @__PURE__ */
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/* @__PURE__ */ t("td", { children:
|
|
359
|
+
return /* @__PURE__ */ t(ye, { children: /* @__PURE__ */ d("tr", { className: "ts-table-row", children: [
|
|
360
|
+
/* @__PURE__ */ d("td", { children: [
|
|
361
|
+
" ",
|
|
362
|
+
/* @__PURE__ */ d("div", { className: "ts-name-cell", children: [
|
|
363
|
+
R && /* @__PURE__ */ t(
|
|
364
|
+
"button",
|
|
365
|
+
{
|
|
366
|
+
type: "button",
|
|
367
|
+
className: "ts-fav-btn ts-btn-light",
|
|
368
|
+
disabled: e.is_favourite,
|
|
369
|
+
onClick: A,
|
|
370
|
+
title: "Mark as favourite",
|
|
371
|
+
children: T ? /* @__PURE__ */ t(ie, { size: "sm" }) : e.is_favourite ? /* @__PURE__ */ t(Le, { variant: "filled" }) : /* @__PURE__ */ t(Le, { variant: "outlined" })
|
|
372
|
+
}
|
|
373
|
+
),
|
|
374
|
+
/* @__PURE__ */ t(
|
|
375
|
+
"span",
|
|
376
|
+
{
|
|
377
|
+
className: e.readonly ? "ts-badge default" : "ts-badge custom",
|
|
378
|
+
children: e.readonly ? "Default" : "Custom"
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
] })
|
|
382
|
+
] }),
|
|
383
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ t("span", { className: "ts-template-name", children: e.name }) }) }),
|
|
384
|
+
c && /* @__PURE__ */ t("td", { children: e?.id ?? "" }),
|
|
385
|
+
/* @__PURE__ */ t("td", { children: b?.name ?? "" }),
|
|
386
|
+
/* @__PURE__ */ t("td", { children: x?.name ?? "" }),
|
|
387
|
+
/* @__PURE__ */ t("td", { children: u?.name ?? "" }),
|
|
388
|
+
c && /* @__PURE__ */ t("td", { children: e?.companyName ?? "" }),
|
|
338
389
|
/* @__PURE__ */ t("td", { children: e?.updatedByName ?? "" }),
|
|
339
|
-
/* @__PURE__ */ t("td", {
|
|
390
|
+
/* @__PURE__ */ t("td", { children: ct(e.updatedDateTime) }),
|
|
391
|
+
/* @__PURE__ */ t("td", { className: "ts-actions-cell", children: /* @__PURE__ */ d("div", { className: "ts-actions-wrapper", children: [
|
|
340
392
|
/* @__PURE__ */ t(
|
|
341
393
|
"button",
|
|
342
394
|
{
|
|
343
|
-
ref:
|
|
395
|
+
ref: I,
|
|
344
396
|
className: "ts-actions-btn",
|
|
345
397
|
"aria-haspopup": "true",
|
|
346
|
-
"aria-expanded":
|
|
347
|
-
onClick: () =>
|
|
348
|
-
children:
|
|
398
|
+
"aria-expanded": v,
|
|
399
|
+
onClick: () => r(v ? null : e.id),
|
|
400
|
+
children: /* @__PURE__ */ t(dt, {})
|
|
349
401
|
}
|
|
350
402
|
),
|
|
351
|
-
/* @__PURE__ */
|
|
403
|
+
/* @__PURE__ */ d(
|
|
352
404
|
"div",
|
|
353
405
|
{
|
|
354
|
-
ref:
|
|
355
|
-
className: `ts-actions-menu ${
|
|
406
|
+
ref: E,
|
|
407
|
+
className: `ts-actions-menu ${v ? "open" : ""}`,
|
|
356
408
|
role: "menu",
|
|
357
409
|
children: [
|
|
358
410
|
/* @__PURE__ */ t(
|
|
@@ -362,19 +414,19 @@ function rt({
|
|
|
362
414
|
role: "menuitem",
|
|
363
415
|
className: "ts-menu-item",
|
|
364
416
|
onClick: () => {
|
|
365
|
-
|
|
417
|
+
r(null), l(e);
|
|
366
418
|
},
|
|
367
419
|
children: "Preview"
|
|
368
420
|
}
|
|
369
421
|
),
|
|
370
|
-
|
|
422
|
+
B && /* @__PURE__ */ t(
|
|
371
423
|
"button",
|
|
372
424
|
{
|
|
373
425
|
type: "button",
|
|
374
426
|
role: "menuitem",
|
|
375
427
|
className: "ts-menu-item",
|
|
376
428
|
onClick: () => {
|
|
377
|
-
|
|
429
|
+
r(null), a(e);
|
|
378
430
|
},
|
|
379
431
|
children: "Edit"
|
|
380
432
|
}
|
|
@@ -386,19 +438,19 @@ function rt({
|
|
|
386
438
|
role: "menuitem",
|
|
387
439
|
className: "ts-menu-item",
|
|
388
440
|
onClick: () => {
|
|
389
|
-
|
|
441
|
+
r(null), i(e);
|
|
390
442
|
},
|
|
391
443
|
children: "Duplicate"
|
|
392
444
|
}
|
|
393
445
|
),
|
|
394
|
-
|
|
446
|
+
_ && /* @__PURE__ */ t(
|
|
395
447
|
"button",
|
|
396
448
|
{
|
|
397
449
|
type: "button",
|
|
398
450
|
role: "menuitem",
|
|
399
451
|
className: "ts-menu-item danger",
|
|
400
452
|
onClick: () => {
|
|
401
|
-
|
|
453
|
+
r(null), s(e);
|
|
402
454
|
},
|
|
403
455
|
children: "Remove"
|
|
404
456
|
}
|
|
@@ -409,144 +461,214 @@ function rt({
|
|
|
409
461
|
] }) })
|
|
410
462
|
] }) });
|
|
411
463
|
}
|
|
412
|
-
const
|
|
464
|
+
const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
|
|
465
|
+
"svg",
|
|
466
|
+
{
|
|
467
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
468
|
+
viewBox: "0 0 320 512",
|
|
469
|
+
width: "6.01px",
|
|
470
|
+
height: "9.63px",
|
|
471
|
+
...e,
|
|
472
|
+
children: /* @__PURE__ */ t(
|
|
473
|
+
"path",
|
|
474
|
+
{
|
|
475
|
+
fill: e.fill || "#6c757d",
|
|
476
|
+
d: "M182.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-128 128c-9.2 9.2-11.9 22.9-6.9 34.9s16.6 19.8 29.6 19.8H288c12.9 0 24.6-7.8 29.6-19.8s2.2-25.7-6.9-34.9l-128-128z"
|
|
477
|
+
}
|
|
478
|
+
)
|
|
479
|
+
}
|
|
480
|
+
), ft = (e) => /* @__PURE__ */ t(
|
|
481
|
+
"svg",
|
|
482
|
+
{
|
|
483
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
484
|
+
viewBox: "0 0 320 512",
|
|
485
|
+
width: "6.01px",
|
|
486
|
+
height: "9.63px",
|
|
487
|
+
...e,
|
|
488
|
+
children: /* @__PURE__ */ t(
|
|
489
|
+
"path",
|
|
490
|
+
{
|
|
491
|
+
fill: e.fill || "#6c757d",
|
|
492
|
+
d: "M182.6 470.6c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-9.2-9.2-11.9-22.9-6.9-34.9s16.6-19.8 29.6-19.8H288c12.9 0 24.6 7.8 29.6 19.8s2.2 25.7-6.9 34.9l-128 128z"
|
|
493
|
+
}
|
|
494
|
+
)
|
|
495
|
+
}
|
|
496
|
+
), J = ({
|
|
497
|
+
label: e,
|
|
498
|
+
sortKey: n,
|
|
499
|
+
sortBy: r,
|
|
500
|
+
sortOrder: a,
|
|
501
|
+
onSort: i
|
|
502
|
+
}) => /* @__PURE__ */ t("th", { onClick: () => i(n), className: "ts-sortable", children: /* @__PURE__ */ d("div", { className: "ts-th-sort", children: [
|
|
503
|
+
e,
|
|
504
|
+
/* @__PURE__ */ d("div", { className: "ts-sort-icons", children: [
|
|
505
|
+
/* @__PURE__ */ t(
|
|
506
|
+
pt,
|
|
507
|
+
{
|
|
508
|
+
fill: r === n && a === "asc" ? "#007bff" : "#6c757d",
|
|
509
|
+
className: r === n && a === "asc" ? "active" : ""
|
|
510
|
+
}
|
|
511
|
+
),
|
|
512
|
+
/* @__PURE__ */ t(
|
|
513
|
+
ft,
|
|
514
|
+
{
|
|
515
|
+
style: { marginTop: -9.6 },
|
|
516
|
+
fill: r === n && a === "desc" ? "#007bff" : "#6c757d",
|
|
517
|
+
className: r === n && a === "desc" ? "active" : ""
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
] })
|
|
521
|
+
] }) }), Ce = 5, ht = ({
|
|
413
522
|
page: e,
|
|
414
523
|
pageSize: n,
|
|
415
|
-
totalRecords:
|
|
524
|
+
totalRecords: r,
|
|
416
525
|
onPageChange: a,
|
|
417
526
|
onPageSizeChange: i
|
|
418
527
|
}) => {
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
528
|
+
const s = Math.ceil(r / n), o = s <= Ce ? Array.from({ length: s }, (u, p) => p + 1) : Array.from({ length: Ce }, (u, p) => p + 1), c = s > Ce, v = s, { showNotification: E } = ve(), [I, b] = C(String(e));
|
|
529
|
+
L(() => {
|
|
530
|
+
b(String(e));
|
|
531
|
+
}, [e]);
|
|
532
|
+
const x = () => {
|
|
533
|
+
const u = Number(I);
|
|
534
|
+
if (!u || u < 1 || u > s) {
|
|
535
|
+
E("Page out of range", "error"), b(String(e));
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
a(u);
|
|
539
|
+
};
|
|
540
|
+
return /* @__PURE__ */ d("div", { className: "ts-pagination-bar", children: [
|
|
541
|
+
/* @__PURE__ */ d("div", { className: "ts-page-container", children: [
|
|
542
|
+
/* @__PURE__ */ d("div", { className: "ts-page-size", children: [
|
|
543
|
+
/* @__PURE__ */ t("label", { children: "Display:" }),
|
|
424
544
|
/* @__PURE__ */ t(
|
|
425
545
|
"select",
|
|
426
546
|
{
|
|
427
547
|
value: n,
|
|
428
|
-
onChange: (
|
|
429
|
-
i(Number(
|
|
548
|
+
onChange: (u) => {
|
|
549
|
+
i(Number(u.target.value)), a(1);
|
|
430
550
|
},
|
|
431
|
-
children: [10, 25, 50, 100].map((
|
|
551
|
+
children: [10, 25, 50, 100].map((u) => /* @__PURE__ */ t("option", { value: u, children: u }, u))
|
|
432
552
|
}
|
|
433
553
|
)
|
|
434
554
|
] }),
|
|
435
|
-
/* @__PURE__ */
|
|
555
|
+
/* @__PURE__ */ d("div", { className: "ts-page-info", children: [
|
|
436
556
|
"Page ",
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
557
|
+
/* @__PURE__ */ d("span", { children: [
|
|
558
|
+
e,
|
|
559
|
+
" of ",
|
|
560
|
+
s
|
|
561
|
+
] })
|
|
440
562
|
] }),
|
|
441
|
-
/* @__PURE__ */
|
|
442
|
-
"Go to page:",
|
|
563
|
+
/* @__PURE__ */ d("div", { className: "ts-go-to", children: [
|
|
564
|
+
/* @__PURE__ */ t("span", { children: "Go to page:" }),
|
|
443
565
|
/* @__PURE__ */ t(
|
|
444
566
|
"input",
|
|
445
567
|
{
|
|
446
568
|
type: "number",
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
T >= 1 && T <= r && a(T);
|
|
569
|
+
value: I,
|
|
570
|
+
onChange: (u) => b(u.target.value),
|
|
571
|
+
onBlur: x,
|
|
572
|
+
onKeyDown: (u) => {
|
|
573
|
+
u.key === "Enter" && x();
|
|
453
574
|
}
|
|
454
575
|
}
|
|
455
576
|
)
|
|
456
577
|
] })
|
|
457
578
|
] }),
|
|
458
|
-
/* @__PURE__ */
|
|
459
|
-
"Total:
|
|
460
|
-
|
|
579
|
+
/* @__PURE__ */ d("div", { className: "ts-total", children: [
|
|
580
|
+
/* @__PURE__ */ t("span", { children: "Total:" }),
|
|
581
|
+
" ",
|
|
582
|
+
r
|
|
461
583
|
] }),
|
|
462
|
-
/* @__PURE__ */
|
|
584
|
+
/* @__PURE__ */ d("div", { className: "ts-page-buttons", children: [
|
|
463
585
|
/* @__PURE__ */ t("button", { disabled: e === 1, onClick: () => a(e - 1), children: "‹" }),
|
|
464
|
-
o.map((
|
|
586
|
+
o.map((u) => /* @__PURE__ */ t(
|
|
465
587
|
"button",
|
|
466
588
|
{
|
|
467
|
-
className:
|
|
468
|
-
onClick: () => a(
|
|
469
|
-
children:
|
|
589
|
+
className: u === e ? "active" : "",
|
|
590
|
+
onClick: () => a(u),
|
|
591
|
+
children: u
|
|
470
592
|
},
|
|
471
|
-
|
|
593
|
+
u
|
|
472
594
|
)),
|
|
473
|
-
|
|
474
|
-
|
|
595
|
+
c && /* @__PURE__ */ t("span", { style: { padding: "0 6px" }, children: "…" }),
|
|
596
|
+
c && /* @__PURE__ */ t(
|
|
475
597
|
"button",
|
|
476
598
|
{
|
|
477
|
-
className: e ===
|
|
478
|
-
onClick: () => a(
|
|
479
|
-
children:
|
|
599
|
+
className: e === v ? "active" : "",
|
|
600
|
+
onClick: () => a(v),
|
|
601
|
+
children: v
|
|
480
602
|
}
|
|
481
603
|
),
|
|
482
604
|
/* @__PURE__ */ t(
|
|
483
605
|
"button",
|
|
484
606
|
{
|
|
485
|
-
disabled: e ===
|
|
607
|
+
disabled: e === s,
|
|
486
608
|
onClick: () => a(e + 1),
|
|
487
609
|
children: "›"
|
|
488
610
|
}
|
|
489
611
|
)
|
|
490
612
|
] })
|
|
491
613
|
] });
|
|
492
|
-
},
|
|
614
|
+
}, yt = ({
|
|
493
615
|
show: e,
|
|
494
616
|
variant: n,
|
|
495
|
-
title:
|
|
617
|
+
title: r = "Are you sure?",
|
|
496
618
|
message: a,
|
|
497
619
|
label: i = "Name",
|
|
498
|
-
value:
|
|
620
|
+
value: s = "",
|
|
499
621
|
placeholder: l = "",
|
|
500
622
|
requiredMessage: o = "This field is required",
|
|
501
|
-
externalError:
|
|
502
|
-
externalErrorMessage:
|
|
503
|
-
confirmText:
|
|
504
|
-
cancelText:
|
|
505
|
-
confirmButtonVariant:
|
|
506
|
-
disableConfirm:
|
|
507
|
-
onConfirm:
|
|
508
|
-
onCancel:
|
|
509
|
-
onInputChange:
|
|
623
|
+
externalError: c = !1,
|
|
624
|
+
externalErrorMessage: v = "",
|
|
625
|
+
confirmText: E = "Ok",
|
|
626
|
+
cancelText: I = "Cancel",
|
|
627
|
+
confirmButtonVariant: b = "danger",
|
|
628
|
+
disableConfirm: x = !1,
|
|
629
|
+
onConfirm: u,
|
|
630
|
+
onCancel: p,
|
|
631
|
+
onInputChange: T
|
|
510
632
|
}) => {
|
|
511
|
-
const [
|
|
633
|
+
const [h, y] = C(s), [g, R] = C(!1), B = te(null);
|
|
512
634
|
if (L(() => {
|
|
513
635
|
if (!e) return;
|
|
514
|
-
const
|
|
515
|
-
|
|
636
|
+
const M = (w) => {
|
|
637
|
+
w.key === "Escape" && p();
|
|
516
638
|
};
|
|
517
|
-
return document.addEventListener("keydown",
|
|
518
|
-
}, [e,
|
|
639
|
+
return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
|
|
640
|
+
}, [e, p]), L(() => {
|
|
519
641
|
if (!e) return;
|
|
520
|
-
const
|
|
521
|
-
|
|
642
|
+
const M = (w) => {
|
|
643
|
+
B.current && !B.current.contains(w.target) && p();
|
|
522
644
|
};
|
|
523
|
-
return document.addEventListener("mousedown",
|
|
524
|
-
}, [e,
|
|
645
|
+
return document.addEventListener("mousedown", M), () => document.removeEventListener("mousedown", M);
|
|
646
|
+
}, [e, p]), L(() => {
|
|
525
647
|
if (e)
|
|
526
648
|
return document.body.style.overflow = "hidden", () => {
|
|
527
649
|
document.body.style.overflow = "";
|
|
528
650
|
};
|
|
529
651
|
}, [e]), L(() => {
|
|
530
|
-
e && (
|
|
531
|
-
}, [e,
|
|
532
|
-
|
|
533
|
-
}, [
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
|
|
652
|
+
e && (y(s), R(!1));
|
|
653
|
+
}, [e, s]), L(() => {
|
|
654
|
+
c && R(!0);
|
|
655
|
+
}, [c]), !e) return null;
|
|
656
|
+
const _ = n === "input" && !h.trim(), A = n === "input" && (_ || c), S = _ ? o : c ? v : "", D = () => {
|
|
657
|
+
if (A || x) {
|
|
658
|
+
R(!0);
|
|
537
659
|
return;
|
|
538
660
|
}
|
|
539
|
-
|
|
661
|
+
u(h.trim());
|
|
540
662
|
};
|
|
541
|
-
return /* @__PURE__ */ t("div", { className: "ts-modal-overlay", children: /* @__PURE__ */
|
|
542
|
-
/* @__PURE__ */
|
|
543
|
-
/* @__PURE__ */ t("h4", { className: "ts-modal-title ", children:
|
|
544
|
-
/* @__PURE__ */ t("button", { className: "ts-modal-close", onClick:
|
|
663
|
+
return /* @__PURE__ */ t("div", { className: "ts-modal-overlay", children: /* @__PURE__ */ d("div", { ref: B, className: "ts-modal", children: [
|
|
664
|
+
/* @__PURE__ */ d("div", { className: "ts-modal-header", children: [
|
|
665
|
+
/* @__PURE__ */ t("h4", { className: "ts-modal-title ", children: r }),
|
|
666
|
+
/* @__PURE__ */ t("button", { className: "ts-modal-close", onClick: p, children: "✕" })
|
|
545
667
|
] }),
|
|
546
|
-
/* @__PURE__ */
|
|
668
|
+
/* @__PURE__ */ d("div", { className: "ts-modal-body", children: [
|
|
547
669
|
a && /* @__PURE__ */ t("p", { className: "ts-modal-message", children: a }),
|
|
548
|
-
n === "input" && /* @__PURE__ */
|
|
549
|
-
/* @__PURE__ */
|
|
670
|
+
n === "input" && /* @__PURE__ */ d("div", { className: "ts-form-group", children: [
|
|
671
|
+
/* @__PURE__ */ d("label", { className: "ts-label", children: [
|
|
550
672
|
i,
|
|
551
673
|
/* @__PURE__ */ t("span", { className: "ts-required", children: "*" })
|
|
552
674
|
] }),
|
|
@@ -554,62 +676,62 @@ const st = qe(rt), ve = 5, at = ({
|
|
|
554
676
|
"input",
|
|
555
677
|
{
|
|
556
678
|
type: "text",
|
|
557
|
-
className: `ts-input ${
|
|
679
|
+
className: `ts-input ${g && A ? "ts-input-error" : ""}`,
|
|
558
680
|
placeholder: l,
|
|
559
|
-
value:
|
|
560
|
-
onChange: (
|
|
561
|
-
|
|
681
|
+
value: h,
|
|
682
|
+
onChange: (M) => {
|
|
683
|
+
y(M.target.value), g && R(!1), T?.(M.target.value);
|
|
562
684
|
},
|
|
563
685
|
autoFocus: !0,
|
|
564
686
|
style: { paddingBlock: "0", paddingInline: "0" }
|
|
565
687
|
}
|
|
566
688
|
),
|
|
567
|
-
|
|
689
|
+
g && A && /* @__PURE__ */ t("div", { className: "ts-error-text", children: S })
|
|
568
690
|
] })
|
|
569
691
|
] }),
|
|
570
|
-
/* @__PURE__ */
|
|
692
|
+
/* @__PURE__ */ d("div", { className: "ts-modal-footer", children: [
|
|
571
693
|
/* @__PURE__ */ t(
|
|
572
694
|
"button",
|
|
573
695
|
{
|
|
574
696
|
type: "button",
|
|
575
697
|
className: "ts-btn ts-btn-secondary",
|
|
576
|
-
onClick:
|
|
577
|
-
children:
|
|
698
|
+
onClick: p,
|
|
699
|
+
children: I
|
|
578
700
|
}
|
|
579
701
|
),
|
|
580
702
|
/* @__PURE__ */ t(
|
|
581
703
|
"button",
|
|
582
704
|
{
|
|
583
705
|
type: "button",
|
|
584
|
-
className: `ts-btn ts-btn-${
|
|
585
|
-
onClick:
|
|
586
|
-
disabled:
|
|
587
|
-
children:
|
|
706
|
+
className: `ts-btn ts-btn-${b}`,
|
|
707
|
+
onClick: D,
|
|
708
|
+
disabled: x,
|
|
709
|
+
children: E
|
|
588
710
|
}
|
|
589
711
|
)
|
|
590
712
|
] })
|
|
591
713
|
] }) });
|
|
592
|
-
},
|
|
714
|
+
}, gt = () => /* @__PURE__ */ t(
|
|
593
715
|
"svg",
|
|
594
716
|
{
|
|
595
717
|
xmlns: "http://www.w3.org/2000/svg",
|
|
596
718
|
viewBox: "0 0 512 512",
|
|
597
|
-
width: "
|
|
598
|
-
height: "
|
|
719
|
+
width: "11px",
|
|
720
|
+
height: "11px",
|
|
599
721
|
children: /* @__PURE__ */ t("path", { fill: "#ffffff", d: "M368 208A160 160 0 1 0 48 208a160 160 0 1 0 320 0zM337.1 371.1C301.7 399.2 256.8 416 208 416C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208c0 48.8-16.8 93.7-44.9 129.1L505 471c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L337.1 371.1z" })
|
|
600
722
|
}
|
|
601
|
-
),
|
|
602
|
-
const e =
|
|
603
|
-
return
|
|
723
|
+
), vt = () => {
|
|
724
|
+
const e = Y(), { enerexIdentifier: n, projectId: r, userEmail: a } = V();
|
|
725
|
+
return ce({
|
|
604
726
|
mutationKey: ["duplicateTemplate"],
|
|
605
|
-
mutationFn: async ({ templateId:
|
|
606
|
-
`${Q.duplicateTemplate}${
|
|
727
|
+
mutationFn: async ({ templateId: s, request: l }) => (l.enerexIdentifier = n ?? "", l.projectId = r ?? "", l.updatedBy = a ?? "", await e.post(
|
|
728
|
+
`${Q.duplicateTemplate}${s}`,
|
|
607
729
|
l
|
|
608
730
|
))
|
|
609
731
|
});
|
|
610
|
-
},
|
|
611
|
-
const e =
|
|
612
|
-
return
|
|
732
|
+
}, bt = () => {
|
|
733
|
+
const e = Y();
|
|
734
|
+
return ce({
|
|
613
735
|
mutationKey: ["deleteTemplate"],
|
|
614
736
|
mutationFn: async (n) => {
|
|
615
737
|
await e.delete(
|
|
@@ -617,309 +739,305 @@ const st = qe(rt), ve = 5, at = ({
|
|
|
617
739
|
);
|
|
618
740
|
}
|
|
619
741
|
});
|
|
620
|
-
},
|
|
742
|
+
}, wt = ({
|
|
621
743
|
data: e,
|
|
622
744
|
page: n,
|
|
623
|
-
pageSize:
|
|
745
|
+
pageSize: r
|
|
624
746
|
}) => {
|
|
625
|
-
const a =
|
|
626
|
-
return { pagedData:
|
|
627
|
-
const
|
|
628
|
-
return e.slice(
|
|
629
|
-
}, [e, n,
|
|
630
|
-
},
|
|
747
|
+
const a = ae(() => Math.ceil(e.length / r), [e.length, r]);
|
|
748
|
+
return { pagedData: ae(() => {
|
|
749
|
+
const s = (n - 1) * r, l = n * r;
|
|
750
|
+
return e.slice(s, l);
|
|
751
|
+
}, [e, n, r]), totalPages: a };
|
|
752
|
+
}, Tt = ({
|
|
631
753
|
templates: e,
|
|
632
754
|
templateTypes: n,
|
|
633
|
-
onRefresh:
|
|
755
|
+
onRefresh: r,
|
|
634
756
|
onAdd: a,
|
|
635
757
|
onEdit: i,
|
|
636
|
-
onPreview:
|
|
758
|
+
onPreview: s
|
|
637
759
|
}) => {
|
|
638
|
-
const {
|
|
639
|
-
|
|
640
|
-
}, [
|
|
760
|
+
const { isAdmin: l } = V(), { mutateAsync: o, isPending: c } = vt(), { mutateAsync: v, isPending: E } = bt(), [I, b] = C(""), [x, u] = C(""), [p, T] = C(null), [h, y] = C(e), [g, R] = C(n), [B, _] = C(!1), [A, S] = C("input"), [D, M] = C(!1), [w, ne] = C(null), [U, W] = C("asc"), K = (m) => {
|
|
761
|
+
w === m ? W((N) => N === "asc" ? "desc" : "asc") : (ne(m), W("asc")), ee(1);
|
|
762
|
+
}, [O, re] = C(null);
|
|
641
763
|
L(() => {
|
|
642
|
-
const
|
|
643
|
-
if (
|
|
644
|
-
return Number(
|
|
645
|
-
const
|
|
646
|
-
return
|
|
764
|
+
const m = [...e].sort((N, $) => {
|
|
765
|
+
if (!l && N.is_favourite !== $.is_favourite)
|
|
766
|
+
return Number($.is_favourite) - Number(N.is_favourite);
|
|
767
|
+
const P = new Date($.updatedDateTime).getTime() - new Date(N.updatedDateTime).getTime();
|
|
768
|
+
return P !== 0 ? P : N.readonly !== $.readonly ? Number(N.readonly) - Number($.readonly) : N.name.localeCompare($.name);
|
|
647
769
|
});
|
|
648
|
-
|
|
770
|
+
y(m), ne(null);
|
|
649
771
|
}, [e]), L(() => {
|
|
650
|
-
|
|
772
|
+
R(n.filter((m) => m.id != null));
|
|
651
773
|
}, [n]);
|
|
652
|
-
const
|
|
653
|
-
const
|
|
654
|
-
return
|
|
655
|
-
}, [
|
|
656
|
-
(
|
|
657
|
-
const
|
|
658
|
-
let
|
|
659
|
-
for (;
|
|
660
|
-
|
|
661
|
-
return
|
|
774
|
+
const le = ae(() => {
|
|
775
|
+
const m = /* @__PURE__ */ new Map();
|
|
776
|
+
return g.forEach((N) => m.set(N.id, N)), m;
|
|
777
|
+
}, [g]), de = Se(
|
|
778
|
+
(m) => {
|
|
779
|
+
const N = [], $ = /* @__PURE__ */ new Set();
|
|
780
|
+
let P = le.get(m);
|
|
781
|
+
for (; P && !($.has(P.id) || ($.add(P.id), N.push({ id: P.id, name: P.name, key: P.key }), !P.parent_id)); )
|
|
782
|
+
P = le.get(P.parent_id);
|
|
783
|
+
return N.reverse();
|
|
662
784
|
},
|
|
663
|
-
[
|
|
664
|
-
),
|
|
665
|
-
...
|
|
666
|
-
categoryChain:
|
|
667
|
-
})), [
|
|
785
|
+
[le]
|
|
786
|
+
), Z = ae(() => !h.length || !g.length ? [] : h.map((m) => ({
|
|
787
|
+
...m,
|
|
788
|
+
categoryChain: de(m.type)
|
|
789
|
+
})), [h, g]);
|
|
668
790
|
L(() => {
|
|
669
|
-
const
|
|
670
|
-
|
|
791
|
+
const m = setTimeout(() => {
|
|
792
|
+
u(I), ee(1);
|
|
671
793
|
}, 300);
|
|
672
|
-
return () => clearTimeout(
|
|
673
|
-
}, [
|
|
674
|
-
const [
|
|
675
|
-
const
|
|
676
|
-
return
|
|
677
|
-
const
|
|
678
|
-
(
|
|
794
|
+
return () => clearTimeout(m);
|
|
795
|
+
}, [I]);
|
|
796
|
+
const [se, H] = C(25), [ue, ee] = C(1), me = ae(() => {
|
|
797
|
+
const m = x.trim().toLowerCase();
|
|
798
|
+
return m ? Z.filter((N) => {
|
|
799
|
+
const $ = N.name.toLowerCase().includes(m), P = N.categoryChain?.some(
|
|
800
|
+
(z) => z.name.toLowerCase().includes(m)
|
|
679
801
|
);
|
|
680
|
-
return
|
|
681
|
-
}) :
|
|
682
|
-
}, [
|
|
683
|
-
const
|
|
684
|
-
return
|
|
685
|
-
|
|
686
|
-
|
|
802
|
+
return $ || P;
|
|
803
|
+
}) : Z;
|
|
804
|
+
}, [Z, x]), pe = ae(() => {
|
|
805
|
+
const m = [...me];
|
|
806
|
+
return m.sort((N, $) => {
|
|
807
|
+
if (w === "lastUpdatedOn") {
|
|
808
|
+
const Ve = new Date(N.updatedDateTime).getTime(), Ke = new Date($.updatedDateTime).getTime(), Pe = Ve - Ke;
|
|
809
|
+
return U === "asc" ? Pe : -Pe;
|
|
810
|
+
}
|
|
811
|
+
let P = "", z = "";
|
|
812
|
+
switch (w) {
|
|
687
813
|
case "name":
|
|
688
|
-
|
|
814
|
+
P = N.name, z = $.name;
|
|
689
815
|
break;
|
|
690
816
|
case "category":
|
|
691
|
-
|
|
817
|
+
P = N.categoryChain?.[0]?.name ?? "", z = $.categoryChain?.[0]?.name ?? "";
|
|
692
818
|
break;
|
|
693
819
|
case "type":
|
|
694
|
-
|
|
820
|
+
P = N.categoryChain?.[1]?.name ?? "", z = $.categoryChain?.[1]?.name ?? "";
|
|
695
821
|
break;
|
|
696
822
|
case "subtype":
|
|
697
|
-
|
|
823
|
+
P = N.categoryChain?.[2]?.name ?? "", z = $.categoryChain?.[2]?.name ?? "";
|
|
824
|
+
break;
|
|
825
|
+
case "templateId":
|
|
826
|
+
P = N.id ?? "", z = $.id ?? "";
|
|
827
|
+
break;
|
|
828
|
+
case "companyName":
|
|
829
|
+
P = N.companyName ?? "", z = $.companyName ?? "";
|
|
830
|
+
break;
|
|
831
|
+
case "lastUpdatedBy":
|
|
832
|
+
P = N.updatedByName ?? "", z = $.updatedByName ?? "";
|
|
698
833
|
break;
|
|
699
834
|
}
|
|
700
|
-
const
|
|
835
|
+
const De = P.localeCompare(z, void 0, {
|
|
701
836
|
sensitivity: "base"
|
|
702
837
|
});
|
|
703
|
-
return
|
|
704
|
-
}),
|
|
705
|
-
}, [
|
|
706
|
-
data:
|
|
707
|
-
page:
|
|
708
|
-
pageSize:
|
|
709
|
-
}),
|
|
710
|
-
(
|
|
711
|
-
(
|
|
838
|
+
return U === "asc" ? De : -De;
|
|
839
|
+
}), m;
|
|
840
|
+
}, [me, w, U]), { pagedData: be } = wt({
|
|
841
|
+
data: pe,
|
|
842
|
+
page: ue,
|
|
843
|
+
pageSize: se
|
|
844
|
+
}), f = Se(
|
|
845
|
+
(m) => h.some(
|
|
846
|
+
(N) => N.name.trim().toLowerCase() === m.trim().toLowerCase()
|
|
712
847
|
),
|
|
713
|
-
[
|
|
714
|
-
),
|
|
715
|
-
|
|
716
|
-
},
|
|
717
|
-
|
|
718
|
-
}, { showNotification:
|
|
719
|
-
if (
|
|
848
|
+
[h]
|
|
849
|
+
), k = (m) => {
|
|
850
|
+
re(m), M(!1), S("input"), _(!0);
|
|
851
|
+
}, F = (m) => {
|
|
852
|
+
re(m), S("confirm"), _(!0);
|
|
853
|
+
}, { showNotification: j } = ve(), X = async (m) => {
|
|
854
|
+
if (O)
|
|
720
855
|
try {
|
|
721
|
-
if (
|
|
722
|
-
if (!
|
|
723
|
-
if (
|
|
724
|
-
|
|
856
|
+
if (A === "input") {
|
|
857
|
+
if (!m) return;
|
|
858
|
+
if (f(m)) {
|
|
859
|
+
M(!0);
|
|
725
860
|
return;
|
|
726
861
|
}
|
|
727
|
-
await
|
|
728
|
-
templateId:
|
|
862
|
+
await o({
|
|
863
|
+
templateId: O.id,
|
|
729
864
|
request: {
|
|
730
865
|
projectId: "",
|
|
731
866
|
enerexIdentifier: "",
|
|
732
|
-
newName:
|
|
733
|
-
parent_id:
|
|
867
|
+
newName: m,
|
|
868
|
+
parent_id: O.id ?? null
|
|
734
869
|
}
|
|
735
|
-
}),
|
|
736
|
-
`Template "${
|
|
870
|
+
}), j(
|
|
871
|
+
`Template "${m}" duplicated successfully`,
|
|
737
872
|
"success"
|
|
738
873
|
);
|
|
739
874
|
}
|
|
740
|
-
|
|
741
|
-
`Template "${
|
|
875
|
+
A === "confirm" && (await v(O.id), j(
|
|
876
|
+
`Template "${O.name}" deleted successfully`,
|
|
742
877
|
"success"
|
|
743
|
-
)),
|
|
878
|
+
)), _(!1), re(null), r();
|
|
744
879
|
} catch {
|
|
745
|
-
|
|
746
|
-
|
|
880
|
+
j(
|
|
881
|
+
A === "confirm" ? "Failed to delete template. Please try again." : "Failed to duplicate template. Please try again.",
|
|
747
882
|
"error"
|
|
748
883
|
);
|
|
749
884
|
}
|
|
750
|
-
},
|
|
751
|
-
return /* @__PURE__ */
|
|
752
|
-
(
|
|
753
|
-
/* @__PURE__ */
|
|
754
|
-
/* @__PURE__ */
|
|
885
|
+
}, q = O?.categoryChain?.[2]?.name?.toLowerCase() ?? "this", oe = O?.name?.toLowerCase() ?? "";
|
|
886
|
+
return /* @__PURE__ */ d(ye, { children: [
|
|
887
|
+
(c || E) && /* @__PURE__ */ t(ie, { overlay: !0 }),
|
|
888
|
+
/* @__PURE__ */ d("div", { className: "ts-page", children: [
|
|
889
|
+
/* @__PURE__ */ d("div", { className: "ts-header", children: [
|
|
755
890
|
/* @__PURE__ */ t("h1", { className: "ts-title", children: "Templates" }),
|
|
756
891
|
/* @__PURE__ */ t("button", { className: "ts-btn ts-btn-primary", onClick: a, children: "+ Add Template" })
|
|
757
892
|
] }),
|
|
758
|
-
/* @__PURE__ */ t("div", { className: "ts-search", children: /* @__PURE__ */
|
|
759
|
-
/* @__PURE__ */ t(
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
"button",
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
893
|
+
/* @__PURE__ */ t("div", { className: "ts-search-container", children: /* @__PURE__ */ d("div", { className: "ts-search-container-inner", children: [
|
|
894
|
+
/* @__PURE__ */ t("div", { className: "ts-search", children: /* @__PURE__ */ d("div", { className: "ts-search-box", children: [
|
|
895
|
+
/* @__PURE__ */ t(
|
|
896
|
+
"input",
|
|
897
|
+
{
|
|
898
|
+
type: "text",
|
|
899
|
+
placeholder: "Search...",
|
|
900
|
+
value: I,
|
|
901
|
+
onChange: (m) => b(m.target.value)
|
|
902
|
+
}
|
|
903
|
+
),
|
|
904
|
+
/* @__PURE__ */ t("button", { className: "ts-search-btn", "aria-label": "Search", children: /* @__PURE__ */ t(gt, {}) })
|
|
905
|
+
] }) }),
|
|
906
|
+
/* @__PURE__ */ d("div", { className: "ts-table-wrapper", children: [
|
|
907
|
+
/* @__PURE__ */ d("table", { className: "ts-table", children: [
|
|
908
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ d("tr", { children: [
|
|
909
|
+
/* @__PURE__ */ t("th", { className: "ts-cursor-default" }),
|
|
910
|
+
/* @__PURE__ */ t(
|
|
911
|
+
J,
|
|
912
|
+
{
|
|
913
|
+
label: "Name",
|
|
914
|
+
sortKey: "name",
|
|
915
|
+
sortBy: w,
|
|
916
|
+
sortOrder: U,
|
|
917
|
+
onSort: K
|
|
918
|
+
}
|
|
919
|
+
),
|
|
920
|
+
l && /* @__PURE__ */ t(
|
|
921
|
+
J,
|
|
922
|
+
{
|
|
923
|
+
label: "Template Id",
|
|
924
|
+
sortKey: "templateId",
|
|
925
|
+
sortBy: w,
|
|
926
|
+
sortOrder: U,
|
|
927
|
+
onSort: K
|
|
928
|
+
}
|
|
929
|
+
),
|
|
930
|
+
/* @__PURE__ */ t(
|
|
931
|
+
J,
|
|
932
|
+
{
|
|
933
|
+
label: "Category",
|
|
934
|
+
sortKey: "category",
|
|
935
|
+
sortBy: w,
|
|
936
|
+
sortOrder: U,
|
|
937
|
+
onSort: K
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
/* @__PURE__ */ t(
|
|
941
|
+
J,
|
|
942
|
+
{
|
|
943
|
+
label: "Type",
|
|
944
|
+
sortKey: "type",
|
|
945
|
+
sortBy: w,
|
|
946
|
+
sortOrder: U,
|
|
947
|
+
onSort: K
|
|
948
|
+
}
|
|
949
|
+
),
|
|
950
|
+
/* @__PURE__ */ t(
|
|
951
|
+
J,
|
|
952
|
+
{
|
|
953
|
+
label: "Subtype",
|
|
954
|
+
sortKey: "subtype",
|
|
955
|
+
sortBy: w,
|
|
956
|
+
sortOrder: U,
|
|
957
|
+
onSort: K
|
|
958
|
+
}
|
|
959
|
+
),
|
|
960
|
+
l && /* @__PURE__ */ t(
|
|
961
|
+
J,
|
|
962
|
+
{
|
|
963
|
+
label: "Company Name",
|
|
964
|
+
sortKey: "companyName",
|
|
965
|
+
sortBy: w,
|
|
966
|
+
sortOrder: U,
|
|
967
|
+
onSort: K
|
|
968
|
+
}
|
|
969
|
+
),
|
|
970
|
+
/* @__PURE__ */ t(
|
|
971
|
+
J,
|
|
972
|
+
{
|
|
973
|
+
label: "Last Updated by",
|
|
974
|
+
sortKey: "lastUpdatedBy",
|
|
975
|
+
sortBy: w,
|
|
976
|
+
sortOrder: U,
|
|
977
|
+
onSort: K
|
|
978
|
+
}
|
|
979
|
+
),
|
|
980
|
+
/* @__PURE__ */ t(
|
|
981
|
+
J,
|
|
982
|
+
{
|
|
983
|
+
label: "Last Updated on",
|
|
984
|
+
sortKey: "lastUpdatedOn",
|
|
985
|
+
sortBy: w,
|
|
986
|
+
sortOrder: U,
|
|
987
|
+
onSort: K
|
|
988
|
+
}
|
|
989
|
+
),
|
|
990
|
+
/* @__PURE__ */ t("th", { className: "ts-cursor-default", children: "Actions" })
|
|
800
991
|
] }) }),
|
|
801
|
-
/* @__PURE__ */ t(
|
|
802
|
-
|
|
992
|
+
/* @__PURE__ */ t("tbody", { children: be.map((m) => /* @__PURE__ */ t(
|
|
993
|
+
mt,
|
|
803
994
|
{
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
{
|
|
819
|
-
className: x === "category" && B === "desc" ? "active" : "",
|
|
820
|
-
children: "▼"
|
|
821
|
-
}
|
|
822
|
-
)
|
|
823
|
-
] })
|
|
824
|
-
] })
|
|
825
|
-
}
|
|
826
|
-
),
|
|
827
|
-
/* @__PURE__ */ t("th", { onClick: () => V("type"), className: "ts-sortable", children: /* @__PURE__ */ c("div", { className: "ts-th-sort", children: [
|
|
828
|
-
"Type",
|
|
829
|
-
/* @__PURE__ */ c("span", { className: "ts-sort-icons", children: [
|
|
830
|
-
/* @__PURE__ */ t(
|
|
831
|
-
"span",
|
|
832
|
-
{
|
|
833
|
-
className: x === "type" && B === "asc" ? "active" : "",
|
|
834
|
-
children: "▲"
|
|
835
|
-
}
|
|
836
|
-
),
|
|
837
|
-
/* @__PURE__ */ t(
|
|
838
|
-
"span",
|
|
839
|
-
{
|
|
840
|
-
className: x === "type" && B === "desc" ? "active" : "",
|
|
841
|
-
children: "▼"
|
|
842
|
-
}
|
|
843
|
-
)
|
|
844
|
-
] })
|
|
845
|
-
] }) }),
|
|
846
|
-
/* @__PURE__ */ t(
|
|
847
|
-
"th",
|
|
848
|
-
{
|
|
849
|
-
onClick: () => V("subtype"),
|
|
850
|
-
className: "ts-sortable",
|
|
851
|
-
children: /* @__PURE__ */ c("div", { className: "ts-th-sort", children: [
|
|
852
|
-
"Subtype",
|
|
853
|
-
/* @__PURE__ */ c("span", { className: "ts-sort-icons", children: [
|
|
854
|
-
/* @__PURE__ */ t(
|
|
855
|
-
"span",
|
|
856
|
-
{
|
|
857
|
-
className: x === "subtype" && B === "asc" ? "active" : "",
|
|
858
|
-
children: "▲"
|
|
859
|
-
}
|
|
860
|
-
),
|
|
861
|
-
/* @__PURE__ */ t(
|
|
862
|
-
"span",
|
|
863
|
-
{
|
|
864
|
-
className: x === "subtype" && B === "desc" ? "active" : "",
|
|
865
|
-
children: "▼"
|
|
866
|
-
}
|
|
867
|
-
)
|
|
868
|
-
] })
|
|
869
|
-
] })
|
|
870
|
-
}
|
|
871
|
-
),
|
|
872
|
-
/* @__PURE__ */ t("th", { children: "Updated by" }),
|
|
873
|
-
/* @__PURE__ */ t("th", { className: "align-right", children: "Actions" })
|
|
874
|
-
] }) }),
|
|
875
|
-
/* @__PURE__ */ t("tbody", { children: le.map((u) => /* @__PURE__ */ t(
|
|
876
|
-
st,
|
|
995
|
+
template: m,
|
|
996
|
+
openActionId: p,
|
|
997
|
+
setOpenActionId: T,
|
|
998
|
+
onDuplicate: k,
|
|
999
|
+
onEdit: i,
|
|
1000
|
+
onRemove: F,
|
|
1001
|
+
onPreview: s,
|
|
1002
|
+
onRefresh: r
|
|
1003
|
+
},
|
|
1004
|
+
m.id
|
|
1005
|
+
)) })
|
|
1006
|
+
] }),
|
|
1007
|
+
/* @__PURE__ */ t(
|
|
1008
|
+
ht,
|
|
877
1009
|
{
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
u.id
|
|
888
|
-
)) })
|
|
889
|
-
] }),
|
|
890
|
-
/* @__PURE__ */ t(
|
|
891
|
-
at,
|
|
892
|
-
{
|
|
893
|
-
page: H,
|
|
894
|
-
pageSize: te,
|
|
895
|
-
totalRecords: de.length,
|
|
896
|
-
onPageChange: ie,
|
|
897
|
-
onPageSizeChange: ae
|
|
898
|
-
}
|
|
899
|
-
)
|
|
900
|
-
] })
|
|
1010
|
+
page: ue,
|
|
1011
|
+
pageSize: se,
|
|
1012
|
+
totalRecords: pe.length,
|
|
1013
|
+
onPageChange: ee,
|
|
1014
|
+
onPageSizeChange: H
|
|
1015
|
+
}
|
|
1016
|
+
)
|
|
1017
|
+
] })
|
|
1018
|
+
] }) })
|
|
901
1019
|
] }),
|
|
902
1020
|
/* @__PURE__ */ t(
|
|
903
|
-
|
|
1021
|
+
yt,
|
|
904
1022
|
{
|
|
905
|
-
show:
|
|
906
|
-
variant:
|
|
907
|
-
title:
|
|
908
|
-
message:
|
|
909
|
-
placeholder:
|
|
1023
|
+
show: B,
|
|
1024
|
+
variant: A,
|
|
1025
|
+
title: A === "confirm" ? "Are you sure?" : "Save Template As",
|
|
1026
|
+
message: A === "confirm" ? `Are you sure you want to remove ${q} template "${oe}"?` : "",
|
|
1027
|
+
placeholder: A === "input" ? "New name" : "",
|
|
910
1028
|
label: "New Name",
|
|
911
1029
|
requiredMessage: "Enter a new name",
|
|
912
|
-
externalError:
|
|
1030
|
+
externalError: D,
|
|
913
1031
|
externalErrorMessage: "Template name already exists. Please choose a different name",
|
|
914
|
-
confirmText:
|
|
915
|
-
confirmButtonVariant:
|
|
916
|
-
onConfirm:
|
|
917
|
-
onCancel: () =>
|
|
918
|
-
onInputChange:
|
|
1032
|
+
confirmText: A === "confirm" ? "Ok" : "Save as",
|
|
1033
|
+
confirmButtonVariant: A === "confirm" ? "danger" : "primary",
|
|
1034
|
+
onConfirm: X,
|
|
1035
|
+
onCancel: () => _(!1),
|
|
1036
|
+
onInputChange: A === "input" ? () => M(!1) : void 0
|
|
919
1037
|
}
|
|
920
1038
|
)
|
|
921
1039
|
] });
|
|
922
|
-
},
|
|
1040
|
+
}, he = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
|
|
923
1041
|
<html\r
|
|
924
1042
|
dir="ltr"\r
|
|
925
1043
|
xmlns:o="urn:schemas-microsoft-com:office:office"\r
|
|
@@ -1275,70 +1393,70 @@ const st = qe(rt), ve = 5, at = ({
|
|
|
1275
1393
|
</div>\r
|
|
1276
1394
|
</body>\r
|
|
1277
1395
|
</html>\r
|
|
1278
|
-
`,
|
|
1396
|
+
`, xe = {
|
|
1279
1397
|
EDITOR_SCRIPT_URL: "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",
|
|
1280
1398
|
EDITOR_PLUGIN_ID: "1afdc3161ec7409a8627a1c8561d45f5",
|
|
1281
1399
|
EDITOR_SECRET_KEY: "54ba748ed7e94f2e929555783acb03da"
|
|
1282
|
-
},
|
|
1283
|
-
const n = Array.from(new Set(e.map((a) => a.category))),
|
|
1400
|
+
}, Nt = (e) => {
|
|
1401
|
+
const n = Array.from(new Set(e.map((a) => a.category))), r = [];
|
|
1284
1402
|
return n.forEach((a) => {
|
|
1285
|
-
const i = e.filter((
|
|
1286
|
-
label:
|
|
1287
|
-
value:
|
|
1288
|
-
hint:
|
|
1289
|
-
hidden:
|
|
1403
|
+
const i = e.filter((s) => s.category === a).map((s) => ({
|
|
1404
|
+
label: s.label,
|
|
1405
|
+
value: s.value,
|
|
1406
|
+
hint: s.hint,
|
|
1407
|
+
hidden: s.hidden
|
|
1290
1408
|
}));
|
|
1291
|
-
|
|
1292
|
-
}),
|
|
1293
|
-
},
|
|
1294
|
-
const e =
|
|
1295
|
-
return
|
|
1409
|
+
r.push({ category: a, entries: i });
|
|
1410
|
+
}), r;
|
|
1411
|
+
}, Ct = () => {
|
|
1412
|
+
const e = Y(), { enerexIdentifier: n, projectId: r } = V();
|
|
1413
|
+
return ge({
|
|
1296
1414
|
queryKey: ["getTemplateTags"],
|
|
1297
1415
|
queryFn: async (i) => await e.get(
|
|
1298
|
-
`${Q.MergeTags}${
|
|
1416
|
+
`${Q.MergeTags}${r}/${n}`
|
|
1299
1417
|
)
|
|
1300
1418
|
});
|
|
1301
|
-
},
|
|
1302
|
-
const e =
|
|
1303
|
-
return
|
|
1419
|
+
}, xt = () => {
|
|
1420
|
+
const e = Y(), { enerexIdentifier: n, projectId: r } = V();
|
|
1421
|
+
return ge({
|
|
1304
1422
|
queryKey: ["getExcludeCategory"],
|
|
1305
1423
|
queryFn: async (i) => await e.get(
|
|
1306
|
-
`${Q.ExcludeCategory}${
|
|
1424
|
+
`${Q.ExcludeCategory}${r}/${n}`
|
|
1307
1425
|
)
|
|
1308
1426
|
});
|
|
1309
|
-
},
|
|
1427
|
+
}, Et = ({
|
|
1310
1428
|
templateHTML: e,
|
|
1311
1429
|
className: n = "",
|
|
1312
|
-
loading:
|
|
1430
|
+
loading: r = !1,
|
|
1313
1431
|
onEditorInitialized: a
|
|
1314
1432
|
}) => {
|
|
1315
|
-
const { post: i } =
|
|
1316
|
-
e ?? { html:
|
|
1317
|
-
), { userEmail:
|
|
1433
|
+
const { post: i } = je(), { data: s } = Ct(), { data: l } = xt(), [o, c] = C(
|
|
1434
|
+
e ?? { html: he, css: "" }
|
|
1435
|
+
), { userEmail: v } = V(), E = te(null), I = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", b = "https://plugins.stripo.email/api/v1/auth";
|
|
1318
1436
|
L(() => {
|
|
1319
|
-
(async () => (await
|
|
1320
|
-
}, [
|
|
1321
|
-
async function
|
|
1322
|
-
window.Zone || await new Promise((
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1437
|
+
(async () => (await x(), s && l && await u(xe.EDITOR_SCRIPT_URL)))();
|
|
1438
|
+
}, [s, l]);
|
|
1439
|
+
async function x() {
|
|
1440
|
+
window.Zone || await new Promise((T, h) => {
|
|
1441
|
+
const y = document.createElement("script");
|
|
1442
|
+
y.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
|
|
1443
|
+
const g = document.querySelector("script[nonce]")?.nonce;
|
|
1444
|
+
g && y.setAttribute("nonce", g), y.onload = () => T(), y.onerror = () => h(new Error("Failed to load zone.js")), document.head.appendChild(y);
|
|
1327
1445
|
});
|
|
1328
1446
|
}
|
|
1329
|
-
async function
|
|
1330
|
-
let
|
|
1447
|
+
async function u(T) {
|
|
1448
|
+
let h = document.getElementById(
|
|
1331
1449
|
"UiEditorScript"
|
|
1332
1450
|
);
|
|
1333
|
-
|
|
1334
|
-
await
|
|
1335
|
-
}, document.body.appendChild(
|
|
1336
|
-
(
|
|
1451
|
+
h || (h = document.createElement("script"), h.id = "UiEditorScript", h.src = T, h.onload = async () => {
|
|
1452
|
+
await p();
|
|
1453
|
+
}, document.body.appendChild(h)), await new Promise(
|
|
1454
|
+
(y) => h.addEventListener("load", () => y(), { once: !0 })
|
|
1337
1455
|
);
|
|
1338
1456
|
}
|
|
1339
|
-
const
|
|
1340
|
-
const
|
|
1341
|
-
if (!
|
|
1457
|
+
const p = async () => {
|
|
1458
|
+
const T = E.current;
|
|
1459
|
+
if (!T) {
|
|
1342
1460
|
console.error("Missing #stripoEditorContainer in DOM");
|
|
1343
1461
|
return;
|
|
1344
1462
|
}
|
|
@@ -1346,48 +1464,48 @@ const st = qe(rt), ve = 5, at = ({
|
|
|
1346
1464
|
console.error("UIEditor script not loaded or not exposing initEditor");
|
|
1347
1465
|
return;
|
|
1348
1466
|
}
|
|
1349
|
-
const
|
|
1467
|
+
const h = {
|
|
1350
1468
|
html: o.html,
|
|
1351
1469
|
css: o.css,
|
|
1352
1470
|
modulesExcludedCategories: l ?? [],
|
|
1353
1471
|
forceRecreate: !0,
|
|
1354
1472
|
metadata: {
|
|
1355
|
-
emailId:
|
|
1473
|
+
emailId: v,
|
|
1356
1474
|
userId: "1",
|
|
1357
1475
|
// username: userName,
|
|
1358
|
-
avatarUrl:
|
|
1476
|
+
avatarUrl: I
|
|
1359
1477
|
},
|
|
1360
1478
|
locale: "en",
|
|
1361
|
-
onTokenRefreshRequest: async (
|
|
1362
|
-
const
|
|
1363
|
-
pluginId:
|
|
1364
|
-
secretKey:
|
|
1365
|
-
userId:
|
|
1479
|
+
onTokenRefreshRequest: async (y) => {
|
|
1480
|
+
const g = {
|
|
1481
|
+
pluginId: xe.EDITOR_PLUGIN_ID,
|
|
1482
|
+
secretKey: xe.EDITOR_SECRET_KEY,
|
|
1483
|
+
userId: v,
|
|
1366
1484
|
role: "user"
|
|
1367
|
-
},
|
|
1368
|
-
|
|
1369
|
-
|
|
1485
|
+
}, R = await i(
|
|
1486
|
+
b,
|
|
1487
|
+
g
|
|
1370
1488
|
);
|
|
1371
|
-
|
|
1489
|
+
R?.token && y(R.token);
|
|
1372
1490
|
},
|
|
1373
1491
|
onTemplateLoaded: () => {
|
|
1374
1492
|
a && a(!0);
|
|
1375
1493
|
},
|
|
1376
|
-
mergeTags:
|
|
1494
|
+
mergeTags: Nt(s ?? [])
|
|
1377
1495
|
};
|
|
1378
|
-
for (const [
|
|
1496
|
+
for (const [y, g] of Object.entries({
|
|
1379
1497
|
codeEditorButtonSelector: "#codeEditor",
|
|
1380
1498
|
undoButtonSelector: "#undoButton",
|
|
1381
1499
|
redoButtonSelector: "#redoButton",
|
|
1382
1500
|
mobileViewButtonSelector: "#mobileViewButton",
|
|
1383
1501
|
desktopViewButtonSelector: "#desktopViewButton"
|
|
1384
1502
|
}))
|
|
1385
|
-
|
|
1386
|
-
await window.UIEditor.initEditor(
|
|
1503
|
+
T.ownerDocument && T.getRootNode() instanceof ShadowRoot && T.getRootNode().querySelector(g) && (h[y] = g);
|
|
1504
|
+
await window.UIEditor.initEditor(T, h);
|
|
1387
1505
|
};
|
|
1388
|
-
return /* @__PURE__ */ t("div", { className: "position-relative", children: /* @__PURE__ */
|
|
1389
|
-
|
|
1390
|
-
|
|
1506
|
+
return /* @__PURE__ */ t("div", { className: "position-relative", children: /* @__PURE__ */ d("div", { className: `editor-container ${n}`, children: [
|
|
1507
|
+
r && /* @__PURE__ */ t("div", { className: "loading-overlay", children: /* @__PURE__ */ t(
|
|
1508
|
+
Qe,
|
|
1391
1509
|
{
|
|
1392
1510
|
animation: "border",
|
|
1393
1511
|
style: { width: "11px", height: "11px" },
|
|
@@ -1398,21 +1516,21 @@ const st = qe(rt), ve = 5, at = ({
|
|
|
1398
1516
|
}
|
|
1399
1517
|
) }),
|
|
1400
1518
|
/* @__PURE__ */ t("div", { id: "externalSystemContainer" }),
|
|
1401
|
-
/* @__PURE__ */ t("div", { id: "stripoEditorContainer", ref:
|
|
1519
|
+
/* @__PURE__ */ t("div", { id: "stripoEditorContainer", ref: E })
|
|
1402
1520
|
] }) });
|
|
1403
|
-
},
|
|
1521
|
+
}, Me = ({
|
|
1404
1522
|
label: e,
|
|
1405
1523
|
register: n,
|
|
1406
|
-
validation:
|
|
1524
|
+
validation: r,
|
|
1407
1525
|
required: a = !1,
|
|
1408
1526
|
name: i,
|
|
1409
|
-
error:
|
|
1527
|
+
error: s,
|
|
1410
1528
|
className: l = "",
|
|
1411
1529
|
...o
|
|
1412
1530
|
}) => {
|
|
1413
|
-
const
|
|
1414
|
-
return /* @__PURE__ */
|
|
1415
|
-
e && /* @__PURE__ */
|
|
1531
|
+
const c = !!(s && s[i]);
|
|
1532
|
+
return /* @__PURE__ */ d("div", { className: `ts-form-group ${l}`, children: [
|
|
1533
|
+
e && /* @__PURE__ */ d("label", { className: "ts-form-label", children: [
|
|
1416
1534
|
e,
|
|
1417
1535
|
a && /* @__PURE__ */ t("span", { className: "ts-required", children: "*" })
|
|
1418
1536
|
] }),
|
|
@@ -1423,79 +1541,59 @@ const st = qe(rt), ve = 5, at = ({
|
|
|
1423
1541
|
type: "text",
|
|
1424
1542
|
...o,
|
|
1425
1543
|
...n ? n(i, {
|
|
1426
|
-
...
|
|
1544
|
+
...r
|
|
1427
1545
|
}) : {},
|
|
1428
|
-
className: `ts-input ${
|
|
1429
|
-
"aria-invalid":
|
|
1546
|
+
className: `ts-input ${c ? "ts-input-error" : ""}`,
|
|
1547
|
+
"aria-invalid": c
|
|
1430
1548
|
}
|
|
1431
1549
|
),
|
|
1432
|
-
|
|
1550
|
+
c && /* @__PURE__ */ t("div", { className: "ts-error-text", children: s?.[i]?.message })
|
|
1433
1551
|
] });
|
|
1434
1552
|
};
|
|
1435
|
-
function
|
|
1436
|
-
return e.sort((n, s) => n.name.localeCompare(s.name));
|
|
1437
|
-
}
|
|
1438
|
-
function yt(e) {
|
|
1439
|
-
const n = /* @__PURE__ */ new Map(), s = [];
|
|
1440
|
-
e.forEach((r) => n.set(r.id, r));
|
|
1441
|
-
let a = e.filter((r) => r.parent_id === 0), i = 0;
|
|
1442
|
-
for (; a.length > 0; ) {
|
|
1443
|
-
s.push({ level: i, data: a });
|
|
1444
|
-
const r = a.map((o) => o.id);
|
|
1445
|
-
a = e.filter(
|
|
1446
|
-
(o) => r.includes(o.parent_id)
|
|
1447
|
-
), i++;
|
|
1448
|
-
}
|
|
1449
|
-
return s;
|
|
1450
|
-
}
|
|
1451
|
-
function Te(e, n) {
|
|
1452
|
-
const a = yt(e).find((i) => i.level === n);
|
|
1453
|
-
return a ? a.data : [];
|
|
1454
|
-
}
|
|
1455
|
-
function gt(e) {
|
|
1553
|
+
function St(e) {
|
|
1456
1554
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
1457
1555
|
}
|
|
1458
|
-
var
|
|
1556
|
+
var Ee = { exports: {} };
|
|
1459
1557
|
/*!
|
|
1460
1558
|
Copyright (c) 2018 Jed Watson.
|
|
1461
1559
|
Licensed under the MIT License (MIT), see
|
|
1462
1560
|
http://jedwatson.github.io/classnames
|
|
1463
1561
|
*/
|
|
1464
|
-
var
|
|
1465
|
-
function
|
|
1466
|
-
return
|
|
1562
|
+
var _e;
|
|
1563
|
+
function Lt() {
|
|
1564
|
+
return _e || (_e = 1, function(e) {
|
|
1467
1565
|
(function() {
|
|
1468
1566
|
var n = {}.hasOwnProperty;
|
|
1469
|
-
function
|
|
1470
|
-
for (var
|
|
1567
|
+
function r() {
|
|
1568
|
+
for (var s = "", l = 0; l < arguments.length; l++) {
|
|
1471
1569
|
var o = arguments[l];
|
|
1472
|
-
o && (
|
|
1570
|
+
o && (s = i(s, a(o)));
|
|
1473
1571
|
}
|
|
1474
|
-
return
|
|
1572
|
+
return s;
|
|
1475
1573
|
}
|
|
1476
|
-
function a(
|
|
1477
|
-
if (typeof
|
|
1478
|
-
return
|
|
1479
|
-
if (typeof
|
|
1574
|
+
function a(s) {
|
|
1575
|
+
if (typeof s == "string" || typeof s == "number")
|
|
1576
|
+
return s;
|
|
1577
|
+
if (typeof s != "object")
|
|
1480
1578
|
return "";
|
|
1481
|
-
if (Array.isArray(
|
|
1482
|
-
return
|
|
1483
|
-
if (
|
|
1484
|
-
return
|
|
1579
|
+
if (Array.isArray(s))
|
|
1580
|
+
return r.apply(null, s);
|
|
1581
|
+
if (s.toString !== Object.prototype.toString && !s.toString.toString().includes("[native code]"))
|
|
1582
|
+
return s.toString();
|
|
1485
1583
|
var l = "";
|
|
1486
|
-
for (var o in
|
|
1487
|
-
n.call(
|
|
1584
|
+
for (var o in s)
|
|
1585
|
+
n.call(s, o) && s[o] && (l = i(l, o));
|
|
1488
1586
|
return l;
|
|
1489
1587
|
}
|
|
1490
|
-
function i(
|
|
1491
|
-
return l ?
|
|
1588
|
+
function i(s, l) {
|
|
1589
|
+
return l ? s ? s + " " + l : s + l : s;
|
|
1492
1590
|
}
|
|
1493
|
-
e.exports ? (
|
|
1591
|
+
e.exports ? (r.default = r, e.exports = r) : window.classNames = r;
|
|
1494
1592
|
})();
|
|
1495
|
-
}(
|
|
1593
|
+
}(Ee)), Ee.exports;
|
|
1496
1594
|
}
|
|
1497
|
-
var
|
|
1498
|
-
const
|
|
1595
|
+
var kt = Lt();
|
|
1596
|
+
const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__ */ t("div", { style: { padding: 0, margin: "2px 0" }, children: /* @__PURE__ */ t(
|
|
1499
1597
|
"hr",
|
|
1500
1598
|
{
|
|
1501
1599
|
style: {
|
|
@@ -1505,37 +1603,37 @@ const _e = /* @__PURE__ */ gt(vt), De = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1505
1603
|
margin: 0
|
|
1506
1604
|
}
|
|
1507
1605
|
}
|
|
1508
|
-
) }) : e.data.icon ? /* @__PURE__ */
|
|
1509
|
-
/* @__PURE__ */ t(
|
|
1606
|
+
) }) : e.data.icon ? /* @__PURE__ */ d("div", { className: "d-flex align-items-center", children: [
|
|
1607
|
+
/* @__PURE__ */ t(Ae.Option, { ...e }),
|
|
1510
1608
|
/* @__PURE__ */ t("span", { className: "px-1 template-studio-dropdown-postfix-icon", children: e.data.icon })
|
|
1511
|
-
] }) : /* @__PURE__ */ t(
|
|
1609
|
+
] }) : /* @__PURE__ */ t(Ae.Option, { ...e }), It = ({
|
|
1512
1610
|
name: e = "",
|
|
1513
1611
|
control: n,
|
|
1514
|
-
options:
|
|
1612
|
+
options: r,
|
|
1515
1613
|
multiple: a = !1,
|
|
1516
1614
|
placeholder: i,
|
|
1517
|
-
validation:
|
|
1615
|
+
validation: s,
|
|
1518
1616
|
labelKey: l = "name",
|
|
1519
1617
|
disabled: o,
|
|
1520
|
-
isInvalid:
|
|
1521
|
-
value:
|
|
1522
|
-
onChange:
|
|
1523
|
-
uncontrolled:
|
|
1524
|
-
menuPlacement:
|
|
1525
|
-
closeOnSelect:
|
|
1618
|
+
isInvalid: c,
|
|
1619
|
+
value: v,
|
|
1620
|
+
onChange: E,
|
|
1621
|
+
uncontrolled: I,
|
|
1622
|
+
menuPlacement: b = "auto",
|
|
1623
|
+
closeOnSelect: x = !0
|
|
1526
1624
|
}) => {
|
|
1527
|
-
const
|
|
1528
|
-
control: (
|
|
1529
|
-
...
|
|
1625
|
+
const u = {
|
|
1626
|
+
control: (p) => ({
|
|
1627
|
+
...p,
|
|
1530
1628
|
minHeight: "33px",
|
|
1531
1629
|
// state.isFocused can display different borderColor if you need it
|
|
1532
|
-
borderColor:
|
|
1533
|
-
backgroundImage:
|
|
1630
|
+
borderColor: c ? "var(--bs-form-invalid-border-color) !important" : "var(--ct-input-border-color)",
|
|
1631
|
+
backgroundImage: c ? '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",
|
|
1534
1632
|
backgroundRepeat: "no-repeat",
|
|
1535
1633
|
backgroundPosition: "right calc(0.375em + 0.225rem) center",
|
|
1536
1634
|
backgroundSize: "calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)",
|
|
1537
1635
|
"&:hover": {
|
|
1538
|
-
borderColor:
|
|
1636
|
+
borderColor: c ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
|
|
1539
1637
|
},
|
|
1540
1638
|
"& .react-select__single-value": {
|
|
1541
1639
|
color: "var(--ct-input-color) !important"
|
|
@@ -1547,344 +1645,342 @@ const _e = /* @__PURE__ */ gt(vt), De = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1547
1645
|
display: "none"
|
|
1548
1646
|
}
|
|
1549
1647
|
}),
|
|
1550
|
-
menu: (
|
|
1551
|
-
...
|
|
1648
|
+
menu: (p) => ({
|
|
1649
|
+
...p,
|
|
1552
1650
|
marginTop: 0,
|
|
1553
1651
|
width: "max-content",
|
|
1554
1652
|
minWidth: "100%"
|
|
1555
1653
|
}),
|
|
1556
|
-
menuPortal: (
|
|
1557
|
-
...
|
|
1654
|
+
menuPortal: (p) => ({
|
|
1655
|
+
...p,
|
|
1558
1656
|
zIndex: 1e4
|
|
1559
1657
|
}),
|
|
1560
|
-
multiValueRemove: (
|
|
1561
|
-
...
|
|
1658
|
+
multiValueRemove: (p) => ({
|
|
1659
|
+
...p,
|
|
1562
1660
|
display: o ? "none" : "block"
|
|
1563
1661
|
})
|
|
1564
1662
|
};
|
|
1565
|
-
return
|
|
1566
|
-
|
|
1663
|
+
return I ? /* @__PURE__ */ t(
|
|
1664
|
+
$e,
|
|
1567
1665
|
{
|
|
1568
|
-
components: { Option:
|
|
1569
|
-
isOptionDisabled: (
|
|
1570
|
-
className:
|
|
1571
|
-
"is-invalid":
|
|
1666
|
+
components: { Option: Be },
|
|
1667
|
+
isOptionDisabled: (p) => !!p.isSeparator,
|
|
1668
|
+
className: Re({
|
|
1669
|
+
"is-invalid": c
|
|
1572
1670
|
}),
|
|
1573
|
-
styles:
|
|
1671
|
+
styles: u,
|
|
1574
1672
|
classNamePrefix: "react-select",
|
|
1575
1673
|
isMulti: a,
|
|
1576
|
-
options:
|
|
1577
|
-
onChange:
|
|
1674
|
+
options: r,
|
|
1675
|
+
onChange: E,
|
|
1578
1676
|
placeholder: i,
|
|
1579
1677
|
menuPortalTarget: document.body,
|
|
1580
|
-
value:
|
|
1581
|
-
getOptionLabel: typeof l == "string" ? (
|
|
1582
|
-
getOptionValue: (
|
|
1678
|
+
value: v,
|
|
1679
|
+
getOptionLabel: typeof l == "string" ? (p) => p[l] : l,
|
|
1680
|
+
getOptionValue: (p) => p.id,
|
|
1583
1681
|
isDisabled: o,
|
|
1584
|
-
menuPlacement:
|
|
1585
|
-
closeMenuOnSelect:
|
|
1682
|
+
menuPlacement: b,
|
|
1683
|
+
closeMenuOnSelect: x
|
|
1586
1684
|
}
|
|
1587
1685
|
) : /* @__PURE__ */ t(
|
|
1588
|
-
|
|
1686
|
+
Xe,
|
|
1589
1687
|
{
|
|
1590
1688
|
control: n,
|
|
1591
1689
|
name: e,
|
|
1592
|
-
rules:
|
|
1593
|
-
render: ({ field: { onChange:
|
|
1594
|
-
|
|
1690
|
+
rules: s,
|
|
1691
|
+
render: ({ field: { onChange: p, value: T, onBlur: h } }) => /* @__PURE__ */ t(
|
|
1692
|
+
$e,
|
|
1595
1693
|
{
|
|
1596
|
-
components: { Option:
|
|
1597
|
-
isOptionDisabled: (
|
|
1598
|
-
className:
|
|
1599
|
-
"is-invalid":
|
|
1694
|
+
components: { Option: Be },
|
|
1695
|
+
isOptionDisabled: (y) => !!y.isSeparator,
|
|
1696
|
+
className: Re({
|
|
1697
|
+
"is-invalid": c
|
|
1600
1698
|
}),
|
|
1601
|
-
styles:
|
|
1699
|
+
styles: u,
|
|
1602
1700
|
classNamePrefix: "react-select",
|
|
1603
1701
|
isMulti: a,
|
|
1604
|
-
options:
|
|
1605
|
-
onBlur:
|
|
1606
|
-
onChange:
|
|
1702
|
+
options: r,
|
|
1703
|
+
onBlur: h,
|
|
1704
|
+
onChange: p,
|
|
1607
1705
|
placeholder: i,
|
|
1608
1706
|
menuPortalTarget: document.body,
|
|
1609
|
-
value:
|
|
1610
|
-
getOptionLabel: typeof l == "string" ? (
|
|
1611
|
-
getOptionValue: (
|
|
1707
|
+
value: T,
|
|
1708
|
+
getOptionLabel: typeof l == "string" ? (y) => y[l] : l,
|
|
1709
|
+
getOptionValue: (y) => y.id,
|
|
1612
1710
|
isDisabled: o,
|
|
1613
|
-
menuPlacement:
|
|
1614
|
-
closeMenuOnSelect:
|
|
1711
|
+
menuPlacement: b,
|
|
1712
|
+
closeMenuOnSelect: x
|
|
1615
1713
|
},
|
|
1616
|
-
|
|
1714
|
+
T ? T.id || T.value || JSON.stringify(T) : "reset"
|
|
1617
1715
|
)
|
|
1618
1716
|
}
|
|
1619
1717
|
);
|
|
1620
|
-
},
|
|
1718
|
+
}, fe = ({
|
|
1621
1719
|
label: e,
|
|
1622
1720
|
name: n,
|
|
1623
|
-
validation:
|
|
1721
|
+
validation: r,
|
|
1624
1722
|
control: a,
|
|
1625
1723
|
error: i,
|
|
1626
|
-
options:
|
|
1724
|
+
options: s = [],
|
|
1627
1725
|
required: l = !1,
|
|
1628
1726
|
disabled: o = !1,
|
|
1629
|
-
className:
|
|
1727
|
+
className: c = ""
|
|
1630
1728
|
}) => {
|
|
1631
|
-
const
|
|
1632
|
-
return /* @__PURE__ */
|
|
1633
|
-
e && /* @__PURE__ */
|
|
1729
|
+
const v = !!(i && i[n]);
|
|
1730
|
+
return /* @__PURE__ */ d("div", { className: `ts-form-group ${c}`, children: [
|
|
1731
|
+
e && /* @__PURE__ */ d("label", { className: "ts-form-label", children: [
|
|
1634
1732
|
e,
|
|
1635
1733
|
l && /* @__PURE__ */ t("span", { className: "ts-required", children: "*" })
|
|
1636
1734
|
] }),
|
|
1637
1735
|
/* @__PURE__ */ t(
|
|
1638
|
-
|
|
1736
|
+
It,
|
|
1639
1737
|
{
|
|
1640
1738
|
name: n,
|
|
1641
1739
|
control: a,
|
|
1642
|
-
options:
|
|
1643
|
-
validation:
|
|
1740
|
+
options: s,
|
|
1741
|
+
validation: r,
|
|
1644
1742
|
disabled: o,
|
|
1645
|
-
isInvalid:
|
|
1743
|
+
isInvalid: v
|
|
1646
1744
|
}
|
|
1647
1745
|
),
|
|
1648
|
-
|
|
1746
|
+
v && /* @__PURE__ */ t("div", { className: "ts-error-text", children: i?.[n]?.message })
|
|
1649
1747
|
] });
|
|
1650
|
-
},
|
|
1651
|
-
const e =
|
|
1652
|
-
|
|
1653
|
-
const { enerexIdentifier: n, projectId:
|
|
1654
|
-
return
|
|
1748
|
+
}, Dt = () => {
|
|
1749
|
+
const e = Y();
|
|
1750
|
+
Ye();
|
|
1751
|
+
const { enerexIdentifier: n, projectId: r } = V();
|
|
1752
|
+
return ce({
|
|
1655
1753
|
mutationKey: ["saveTemplate"],
|
|
1656
|
-
mutationFn: async (i) => (i.enerexIdentifier = n ?? "", i.projectId =
|
|
1754
|
+
mutationFn: async (i) => (i.enerexIdentifier = n ?? "", i.projectId = r ?? "", await e.post(
|
|
1657
1755
|
`${Q.SaveTemplate}`,
|
|
1658
1756
|
i
|
|
1659
1757
|
))
|
|
1660
1758
|
});
|
|
1661
|
-
},
|
|
1759
|
+
}, Pt = {
|
|
1662
1760
|
id: "",
|
|
1663
1761
|
name: "New (Blank)"
|
|
1664
|
-
},
|
|
1762
|
+
}, $t = ({
|
|
1665
1763
|
onReset: e,
|
|
1666
1764
|
editorInitialized: n,
|
|
1667
|
-
mode:
|
|
1765
|
+
mode: r,
|
|
1668
1766
|
templateTypes: a,
|
|
1669
1767
|
templateList: i,
|
|
1670
|
-
template:
|
|
1768
|
+
template: s,
|
|
1671
1769
|
onRefresh: l,
|
|
1672
1770
|
closeEditorModal: o
|
|
1673
1771
|
}) => {
|
|
1674
|
-
const { defaultSelector:
|
|
1675
|
-
register:
|
|
1676
|
-
handleSubmit:
|
|
1677
|
-
clearErrors:
|
|
1678
|
-
setValue:
|
|
1679
|
-
control:
|
|
1680
|
-
watch:
|
|
1681
|
-
reset:
|
|
1682
|
-
setError:
|
|
1683
|
-
formState: { errors:
|
|
1684
|
-
} =
|
|
1772
|
+
const { defaultSelector: c, isAdmin: v, userEmail: E } = V(), { mutateAsync: I, isPending: b } = Ue(), {
|
|
1773
|
+
register: x,
|
|
1774
|
+
handleSubmit: u,
|
|
1775
|
+
clearErrors: p,
|
|
1776
|
+
setValue: T,
|
|
1777
|
+
control: h,
|
|
1778
|
+
watch: y,
|
|
1779
|
+
reset: g,
|
|
1780
|
+
setError: R,
|
|
1781
|
+
formState: { errors: B }
|
|
1782
|
+
} = Je({
|
|
1685
1783
|
defaultValues: {
|
|
1686
1784
|
templateName: "",
|
|
1687
1785
|
subTemplateType: void 0,
|
|
1688
1786
|
subTemplateType2: void 0,
|
|
1689
1787
|
subject: "",
|
|
1690
1788
|
templateType: void 0,
|
|
1691
|
-
template:
|
|
1789
|
+
template: Pt
|
|
1692
1790
|
},
|
|
1693
1791
|
mode: "onChange"
|
|
1694
|
-
}), [
|
|
1792
|
+
}), [_, A] = C([]), [S, D] = C(), { mutateAsync: M, isPending: w } = Dt(), [ne, U] = C([]), [W, K] = C([]), [O, re] = C([]), [le, de] = C(!1), Z = te(!1), { showNotification: se } = ve(), H = r === "edit", ue = le || w || b || !n;
|
|
1695
1793
|
L(() => {
|
|
1696
1794
|
if (a) {
|
|
1697
|
-
let f = a.filter((
|
|
1698
|
-
|
|
1795
|
+
let f = a.filter((F) => F.id != null), k = Ne(f, 0);
|
|
1796
|
+
U(Te(k));
|
|
1699
1797
|
}
|
|
1700
1798
|
}, [a]), L(() => {
|
|
1701
|
-
|
|
1702
|
-
}, [
|
|
1703
|
-
if (
|
|
1704
|
-
const f =
|
|
1799
|
+
r === "edit" && !Z.current && de(!0);
|
|
1800
|
+
}, [r]), L(() => {
|
|
1801
|
+
if (r !== "edit" || !s || !n || !a.length || !_.length || Z.current) return;
|
|
1802
|
+
const f = _.find((q) => q.id === s.templateID);
|
|
1705
1803
|
if (!f) return;
|
|
1706
|
-
const
|
|
1707
|
-
|
|
1708
|
-
templateType: X ?
|
|
1709
|
-
subTemplateType: j ?
|
|
1710
|
-
subTemplateType2:
|
|
1804
|
+
const k = a.filter((q) => q.id != null), F = k.find((q) => `${q.id}` == `${f.type}`), j = F ? k.find((q) => `${q.id}` == `${F.parent_id}`) : void 0, X = j ? k.find((q) => `${q.id}` == `${j.parent_id}`) : void 0;
|
|
1805
|
+
g({
|
|
1806
|
+
templateType: X ? ee(X) : void 0,
|
|
1807
|
+
subTemplateType: j ? ee(j) : void 0,
|
|
1808
|
+
subTemplateType2: F ? ee(F) : void 0,
|
|
1711
1809
|
template: f,
|
|
1712
|
-
templateName:
|
|
1713
|
-
subject:
|
|
1714
|
-
}),
|
|
1715
|
-
}, [
|
|
1716
|
-
const
|
|
1810
|
+
templateName: s.name ?? "",
|
|
1811
|
+
subject: s.subject ?? ""
|
|
1812
|
+
}), D(f), Z.current = !0, de(!1);
|
|
1813
|
+
}, [r, s, n, a, _, g]);
|
|
1814
|
+
const ee = (f) => ({
|
|
1717
1815
|
id: String(f.id),
|
|
1718
1816
|
name: f.name,
|
|
1719
1817
|
key: f.key
|
|
1720
1818
|
});
|
|
1721
1819
|
L(() => {
|
|
1722
|
-
i?.sort((f,
|
|
1820
|
+
i?.sort((f, k) => f.readonly !== k.readonly ? (f.readonly ? 0 : 1) - (k.readonly ? 0 : 1) : f.name.localeCompare(k.name)), A(i ?? []);
|
|
1723
1821
|
}, [i]), L(() => {
|
|
1724
|
-
if (!
|
|
1725
|
-
const f =
|
|
1822
|
+
if (!y("templateType")) return;
|
|
1823
|
+
const f = Ne(a, 1);
|
|
1726
1824
|
K(
|
|
1727
|
-
|
|
1728
|
-
f.filter((
|
|
1825
|
+
Te(
|
|
1826
|
+
f.filter((k) => `${k.parent_id}` == `${y("templateType")?.id}`)
|
|
1729
1827
|
)
|
|
1730
|
-
);
|
|
1731
|
-
}, [
|
|
1732
|
-
const f =
|
|
1828
|
+
), T("subTemplateType", void 0);
|
|
1829
|
+
}, [y("templateType"), a]), L(() => {
|
|
1830
|
+
const f = y("subTemplateType");
|
|
1733
1831
|
if (!f) return;
|
|
1734
|
-
const
|
|
1735
|
-
let
|
|
1736
|
-
|
|
1832
|
+
const k = Ne(a, 2);
|
|
1833
|
+
let F = Te(
|
|
1834
|
+
k.filter((j) => `${j.parent_id}` == `${f.id}`)
|
|
1737
1835
|
);
|
|
1738
|
-
|
|
1739
|
-
}, [
|
|
1740
|
-
if (
|
|
1741
|
-
const f =
|
|
1742
|
-
(
|
|
1836
|
+
r !== "edit" && !v && (F = F.filter((j) => j.key !== 2)), re(F);
|
|
1837
|
+
}, [y("subTemplateType"), a, r]), L(() => {
|
|
1838
|
+
if (c && c.type1) {
|
|
1839
|
+
const f = ne?.find(
|
|
1840
|
+
(k) => `${k.id}` === c.type1
|
|
1743
1841
|
);
|
|
1744
|
-
|
|
1842
|
+
T("templateType", f);
|
|
1745
1843
|
}
|
|
1746
|
-
}, [a,
|
|
1747
|
-
if (
|
|
1748
|
-
const f =
|
|
1749
|
-
(
|
|
1844
|
+
}, [a, ne]), L(() => {
|
|
1845
|
+
if (c && c.type2) {
|
|
1846
|
+
const f = W?.find(
|
|
1847
|
+
(k) => `${k.id}` === c.type2
|
|
1750
1848
|
);
|
|
1751
|
-
|
|
1849
|
+
T("subTemplateType", f);
|
|
1752
1850
|
}
|
|
1753
|
-
}, [a,
|
|
1754
|
-
if (
|
|
1755
|
-
const f =
|
|
1756
|
-
(
|
|
1851
|
+
}, [a, W]), L(() => {
|
|
1852
|
+
if (c && c.type3) {
|
|
1853
|
+
const f = O?.find(
|
|
1854
|
+
(k) => `${k.id}` === c.type3
|
|
1757
1855
|
);
|
|
1758
|
-
|
|
1856
|
+
T("subTemplateType2", f);
|
|
1759
1857
|
}
|
|
1760
|
-
}, [a,
|
|
1761
|
-
const
|
|
1858
|
+
}, [a, O]);
|
|
1859
|
+
const me = (f) => {
|
|
1762
1860
|
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
1763
|
-
async (
|
|
1861
|
+
async (k) => {
|
|
1764
1862
|
try {
|
|
1765
|
-
let
|
|
1766
|
-
const X = f.templateName.trim()
|
|
1767
|
-
|
|
1768
|
-
const F = P.find(
|
|
1769
|
-
(R) => R.name === f.templateName.trim()
|
|
1863
|
+
let F = f.template.id, j = "";
|
|
1864
|
+
const X = f.templateName.trim(), q = _.find(
|
|
1865
|
+
(N) => N.name === f.templateName.trim()
|
|
1770
1866
|
);
|
|
1771
|
-
if (
|
|
1772
|
-
|
|
1867
|
+
if (q && q?.id !== f.template.id) {
|
|
1868
|
+
R("templateName", {
|
|
1773
1869
|
type: "validate",
|
|
1774
1870
|
message: "Template name already exists. Please choose a different name."
|
|
1775
1871
|
});
|
|
1776
1872
|
return;
|
|
1777
1873
|
}
|
|
1778
|
-
let
|
|
1779
|
-
|
|
1780
|
-
const
|
|
1874
|
+
let oe = f.templateType.id;
|
|
1875
|
+
O?.length > 0 ? oe = f.subTemplateType2.id : W?.length > 0 && (oe = f.subTemplateType.id);
|
|
1876
|
+
const Ie = {
|
|
1781
1877
|
enerexIdentifier: "",
|
|
1782
1878
|
projectId: "",
|
|
1783
|
-
templateId:
|
|
1784
|
-
templateType:
|
|
1879
|
+
templateId: F,
|
|
1880
|
+
templateType: oe,
|
|
1785
1881
|
name: X,
|
|
1786
|
-
html:
|
|
1787
|
-
css:
|
|
1882
|
+
html: k.html,
|
|
1883
|
+
css: k.css,
|
|
1788
1884
|
subject: f.templateType.id === "2" ? f?.subject ?? "" : "",
|
|
1789
1885
|
parent_id: j,
|
|
1790
|
-
updatedBy:
|
|
1886
|
+
updatedBy: E ?? ""
|
|
1791
1887
|
};
|
|
1792
|
-
if (!await
|
|
1793
|
-
|
|
1888
|
+
if (!await M(Ie)) {
|
|
1889
|
+
se(
|
|
1794
1890
|
"Failed to save template. Please try again.",
|
|
1795
1891
|
"error"
|
|
1796
1892
|
);
|
|
1797
1893
|
return;
|
|
1798
1894
|
}
|
|
1799
|
-
|
|
1895
|
+
se(
|
|
1800
1896
|
H ? `Template "${X}" updated successfully.` : `Template "${X}" created successfully.`,
|
|
1801
1897
|
"success"
|
|
1802
|
-
),
|
|
1803
|
-
} catch (
|
|
1804
|
-
console.error(
|
|
1898
|
+
), p(), l(), o();
|
|
1899
|
+
} catch (F) {
|
|
1900
|
+
console.error(F), se(
|
|
1805
1901
|
"Something went wrong while saving the template.",
|
|
1806
1902
|
"error"
|
|
1807
1903
|
);
|
|
1808
1904
|
}
|
|
1809
1905
|
}
|
|
1810
1906
|
);
|
|
1811
|
-
},
|
|
1812
|
-
return /* @__PURE__ */
|
|
1813
|
-
|
|
1814
|
-
/* @__PURE__ */ t("div", { className: "ts-card", children: /* @__PURE__ */ t("div", { className: "ts-card-body", children: /* @__PURE__ */ t("form", { children: /* @__PURE__ */ t("div", { className: "template-list-container", children: /* @__PURE__ */
|
|
1907
|
+
}, pe = y("templateType"), be = y("subTemplateType");
|
|
1908
|
+
return /* @__PURE__ */ d(ye, { children: [
|
|
1909
|
+
ue && /* @__PURE__ */ t(ie, { overlay: !0 }),
|
|
1910
|
+
/* @__PURE__ */ t("div", { className: "ts-card", children: /* @__PURE__ */ t("div", { className: "ts-card-body", children: /* @__PURE__ */ t("form", { children: /* @__PURE__ */ t("div", { className: "template-list-container", children: /* @__PURE__ */ d("div", { className: "ts-row", children: [
|
|
1815
1911
|
/* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1816
|
-
|
|
1912
|
+
fe,
|
|
1817
1913
|
{
|
|
1818
1914
|
label: "Category",
|
|
1819
|
-
control:
|
|
1820
|
-
error:
|
|
1821
|
-
options:
|
|
1915
|
+
control: h,
|
|
1916
|
+
error: B,
|
|
1917
|
+
options: ne,
|
|
1822
1918
|
required: !0,
|
|
1823
|
-
disabled: H ||
|
|
1919
|
+
disabled: H || w || b || !n,
|
|
1824
1920
|
validation: {
|
|
1825
1921
|
required: {
|
|
1826
1922
|
value: !0,
|
|
1827
1923
|
message: "Select a category"
|
|
1828
1924
|
}
|
|
1829
1925
|
},
|
|
1830
|
-
...
|
|
1926
|
+
...x("templateType")
|
|
1831
1927
|
}
|
|
1832
1928
|
) }),
|
|
1833
|
-
|
|
1834
|
-
|
|
1929
|
+
W && W.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1930
|
+
fe,
|
|
1835
1931
|
{
|
|
1836
1932
|
label: "Type",
|
|
1837
|
-
control:
|
|
1838
|
-
error:
|
|
1839
|
-
options:
|
|
1933
|
+
control: h,
|
|
1934
|
+
error: B,
|
|
1935
|
+
options: W,
|
|
1840
1936
|
required: !0,
|
|
1841
|
-
disabled: H ||
|
|
1937
|
+
disabled: H || w || b || !n,
|
|
1842
1938
|
validation: {
|
|
1843
1939
|
required: {
|
|
1844
1940
|
value: !0,
|
|
1845
1941
|
message: "Select a type"
|
|
1846
1942
|
}
|
|
1847
1943
|
},
|
|
1848
|
-
...
|
|
1944
|
+
...x("subTemplateType")
|
|
1849
1945
|
}
|
|
1850
1946
|
) }),
|
|
1851
|
-
|
|
1852
|
-
|
|
1947
|
+
O && O.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1948
|
+
fe,
|
|
1853
1949
|
{
|
|
1854
1950
|
label: "Sub Type",
|
|
1855
|
-
control:
|
|
1856
|
-
error:
|
|
1857
|
-
options:
|
|
1951
|
+
control: h,
|
|
1952
|
+
error: B,
|
|
1953
|
+
options: O,
|
|
1858
1954
|
required: !0,
|
|
1859
|
-
disabled: H ||
|
|
1955
|
+
disabled: H || w || b || !n,
|
|
1860
1956
|
validation: {
|
|
1861
1957
|
required: {
|
|
1862
1958
|
value: !0,
|
|
1863
1959
|
message: "Select a subtype"
|
|
1864
1960
|
}
|
|
1865
1961
|
},
|
|
1866
|
-
...
|
|
1962
|
+
...x("subTemplateType2")
|
|
1867
1963
|
}
|
|
1868
1964
|
) }),
|
|
1869
1965
|
/* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1870
|
-
|
|
1966
|
+
fe,
|
|
1871
1967
|
{
|
|
1872
1968
|
label: "Template",
|
|
1873
|
-
control:
|
|
1874
|
-
error:
|
|
1875
|
-
disabled: H || !H ||
|
|
1969
|
+
control: h,
|
|
1970
|
+
error: B,
|
|
1971
|
+
disabled: H || !H || w || b || !n,
|
|
1876
1972
|
options: [],
|
|
1877
1973
|
required: !1,
|
|
1878
|
-
...
|
|
1974
|
+
...x("template")
|
|
1879
1975
|
}
|
|
1880
1976
|
) }),
|
|
1881
|
-
/* @__PURE__ */
|
|
1977
|
+
/* @__PURE__ */ d("div", { className: "ts-col ts-template-name-col", children: [
|
|
1882
1978
|
/* @__PURE__ */ t(
|
|
1883
|
-
|
|
1979
|
+
Me,
|
|
1884
1980
|
{
|
|
1885
1981
|
label: "Name",
|
|
1886
|
-
register:
|
|
1887
|
-
error:
|
|
1982
|
+
register: x,
|
|
1983
|
+
error: B,
|
|
1888
1984
|
required: !0,
|
|
1889
1985
|
name: "templateName",
|
|
1890
1986
|
validation: {
|
|
@@ -1895,141 +1991,117 @@ const _e = /* @__PURE__ */ gt(vt), De = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1895
1991
|
}
|
|
1896
1992
|
}
|
|
1897
1993
|
),
|
|
1898
|
-
|
|
1899
|
-
// type="button"
|
|
1900
|
-
// className="template-favourite-btn ts-btn-light"
|
|
1901
|
-
// disabled={
|
|
1902
|
-
// loading3 ||
|
|
1903
|
-
// loading5 ||
|
|
1904
|
-
// (selectedTemplateMeta
|
|
1905
|
-
// ? selectedTemplateMeta?.is_favourite
|
|
1906
|
-
// : false)
|
|
1907
|
-
// }
|
|
1908
|
-
// onClick={handlemarkFavourite}
|
|
1909
|
-
// >
|
|
1910
|
-
// {loading3 || loading5 ? (
|
|
1911
|
-
// <Loader size="sm" />
|
|
1912
|
-
// ) : selectedTemplateMeta ? (
|
|
1913
|
-
// selectedTemplateMeta?.is_favourite ? (
|
|
1914
|
-
// <StarIcon variant="filled" />
|
|
1915
|
-
// ) : (
|
|
1916
|
-
// <StarIcon variant="outlined" />
|
|
1917
|
-
// )
|
|
1918
|
-
// ) : (
|
|
1919
|
-
// <StarIcon variant="outlined" />
|
|
1920
|
-
// )}
|
|
1921
|
-
// </button>
|
|
1922
|
-
/* @__PURE__ */ t("span", { className: "ts-favourite-icon", children: /* @__PURE__ */ t(Ee, { variant: "filled" }) })
|
|
1994
|
+
be?.key?.toString() === "9" && H && !v && S?.is_favourite && /* @__PURE__ */ t("span", { className: "ts-favourite-icon", children: /* @__PURE__ */ t(Le, { variant: "filled" }) })
|
|
1923
1995
|
] }),
|
|
1924
|
-
|
|
1925
|
-
|
|
1996
|
+
pe?.key?.toString() === "12" && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1997
|
+
Me,
|
|
1926
1998
|
{
|
|
1927
1999
|
label: "Subject",
|
|
1928
|
-
register:
|
|
1929
|
-
error:
|
|
2000
|
+
register: x,
|
|
2001
|
+
error: B,
|
|
1930
2002
|
required: !1,
|
|
1931
2003
|
name: "subject"
|
|
1932
2004
|
}
|
|
1933
2005
|
) }),
|
|
1934
|
-
/* @__PURE__ */
|
|
2006
|
+
/* @__PURE__ */ d("div", { className: "ts-col ts-actions btn-padding", children: [
|
|
1935
2007
|
!H && /* @__PURE__ */ t(
|
|
1936
2008
|
"button",
|
|
1937
2009
|
{
|
|
1938
2010
|
type: "button",
|
|
1939
2011
|
className: "ts-btn ts-btn-primary",
|
|
1940
|
-
disabled:
|
|
2012
|
+
disabled: w || b || !n,
|
|
1941
2013
|
onClick: () => {
|
|
1942
|
-
|
|
2014
|
+
D(void 0), g(), K([]), re([]), e();
|
|
1943
2015
|
},
|
|
1944
|
-
children:
|
|
2016
|
+
children: w || b ? /* @__PURE__ */ t(ie, { size: "sm" }) : "Clear"
|
|
1945
2017
|
}
|
|
1946
2018
|
),
|
|
1947
|
-
|
|
2019
|
+
/* @__PURE__ */ t(
|
|
1948
2020
|
"button",
|
|
1949
2021
|
{
|
|
1950
2022
|
type: "button",
|
|
1951
2023
|
className: "ts-btn ts-btn-primary",
|
|
1952
|
-
disabled:
|
|
1953
|
-
onClick:
|
|
1954
|
-
children:
|
|
2024
|
+
disabled: w || b || !n,
|
|
2025
|
+
onClick: u(me),
|
|
2026
|
+
children: w || b ? (
|
|
1955
2027
|
// <span className="ts-spinner" />
|
|
1956
|
-
/* @__PURE__ */ t(
|
|
2028
|
+
/* @__PURE__ */ t(ie, { size: "sm" })
|
|
1957
2029
|
) : "Save"
|
|
1958
2030
|
}
|
|
1959
2031
|
)
|
|
1960
2032
|
] })
|
|
1961
2033
|
] }) }) }) }) })
|
|
1962
2034
|
] });
|
|
1963
|
-
},
|
|
2035
|
+
}, At = (e) => /* @__PURE__ */ t("svg", { xmlns: "http://www.w3.org/2000/svg", height: "20px", width: "20px", viewBox: "0 0 640 640", ...e, children: /* @__PURE__ */ t("path", { fill: "#6c757d", d: "M560 144L240 144L240 176L192 176L192 96L608 96L608 416L496 416L496 368L560 368L560 144zM80 352L80 496L400 496L400 352L80 352zM80 224L448 224L448 544L32 544L32 224L80 224z" }) }), Mt = (e) => /* @__PURE__ */ t("svg", { xmlns: "http://www.w3.org/2000/svg", height: "20px", width: "20px", viewBox: "0 0 640 640", ...e, children: /* @__PURE__ */ t("path", { fill: "#6c757d", d: "M112 288L112 464L528 464L528 288L112 288zM64 128L576 128L576 512L64 512L64 128z" }) }), _t = ({
|
|
1964
2036
|
show: e,
|
|
1965
2037
|
mode: n,
|
|
1966
|
-
template:
|
|
2038
|
+
template: r,
|
|
1967
2039
|
templateTypes: a,
|
|
1968
2040
|
templateList: i,
|
|
1969
|
-
editorInitialized:
|
|
2041
|
+
editorInitialized: s,
|
|
1970
2042
|
previewHtml: l,
|
|
1971
2043
|
onEditorInitialized: o,
|
|
1972
|
-
onClose:
|
|
1973
|
-
onRefresh:
|
|
2044
|
+
onClose: c,
|
|
2045
|
+
onRefresh: v
|
|
1974
2046
|
}) => {
|
|
1975
|
-
const
|
|
2047
|
+
const E = te(null), [I, b] = C(!1);
|
|
1976
2048
|
L(() => {
|
|
1977
|
-
e &&
|
|
1978
|
-
|
|
1979
|
-
|
|
2049
|
+
e && s && window.StripoEditorApi?.actionsApi && (n === "add" ? window.StripoEditorApi.actionsApi.updateHtmlAndCss(he, "", "") : n === "edit" && r && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
2050
|
+
r.html ?? he,
|
|
2051
|
+
r.css ?? "",
|
|
1980
2052
|
""
|
|
1981
2053
|
));
|
|
1982
|
-
}, [e,
|
|
1983
|
-
e ||
|
|
2054
|
+
}, [e, s, n, r]), L(() => {
|
|
2055
|
+
e || b(!1);
|
|
1984
2056
|
}, [e]);
|
|
1985
|
-
const
|
|
1986
|
-
window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
2057
|
+
const x = () => {
|
|
2058
|
+
window.StripoEditorApi.actionsApi.updateHtmlAndCss(he, "", "");
|
|
1987
2059
|
};
|
|
1988
|
-
return e ? /* @__PURE__ */ t("div", { className: "ts-editor-modal-overlay", children: /* @__PURE__ */
|
|
2060
|
+
return e ? /* @__PURE__ */ t("div", { className: "ts-editor-modal-overlay", children: /* @__PURE__ */ d(
|
|
1989
2061
|
"div",
|
|
1990
2062
|
{
|
|
1991
|
-
className: `ts-editor-modal ${
|
|
1992
|
-
ref:
|
|
2063
|
+
className: `ts-editor-modal ${I ? "ts-editor-modal--fullscreen" : ""}`,
|
|
2064
|
+
ref: E,
|
|
1993
2065
|
children: [
|
|
1994
|
-
/* @__PURE__ */
|
|
1995
|
-
/* @__PURE__ */
|
|
2066
|
+
/* @__PURE__ */ d("div", { className: "ts-editor-modal-header", children: [
|
|
2067
|
+
/* @__PURE__ */ d("h3", { className: "ts-modal-title", children: [
|
|
1996
2068
|
n === "add" && "Create Template",
|
|
1997
2069
|
n === "edit" && "Edit Template",
|
|
1998
2070
|
n === "preview" && "Preview Template"
|
|
1999
2071
|
] }),
|
|
2000
|
-
/* @__PURE__ */
|
|
2072
|
+
/* @__PURE__ */ d("div", { className: "ts-editor-header-actions", children: [
|
|
2001
2073
|
/* @__PURE__ */ t(
|
|
2002
2074
|
"button",
|
|
2003
2075
|
{
|
|
2004
2076
|
className: "ts-editor-fullscreen-btn",
|
|
2005
|
-
onClick: () =>
|
|
2077
|
+
onClick: () => b((u) => !u),
|
|
2006
2078
|
"aria-label": "Toggle fullscreen",
|
|
2007
|
-
children:
|
|
2079
|
+
children: I ? /* @__PURE__ */ t(At, { style: { display: "block" } }) : /* @__PURE__ */ t(Mt, { style: { display: "block" } })
|
|
2008
2080
|
}
|
|
2009
2081
|
),
|
|
2010
2082
|
/* @__PURE__ */ t(
|
|
2011
2083
|
"button",
|
|
2012
2084
|
{
|
|
2013
2085
|
className: "ts-editor-close-btn",
|
|
2014
|
-
onClick:
|
|
2086
|
+
onClick: c,
|
|
2015
2087
|
"aria-label": "Close editor",
|
|
2016
2088
|
children: "✕"
|
|
2017
2089
|
}
|
|
2018
2090
|
)
|
|
2019
2091
|
] })
|
|
2020
2092
|
] }),
|
|
2021
|
-
/* @__PURE__ */
|
|
2093
|
+
/* @__PURE__ */ d("div", { className: "ts-editor-modal-body", children: [
|
|
2022
2094
|
n !== "preview" && /* @__PURE__ */ t(
|
|
2023
|
-
|
|
2095
|
+
$t,
|
|
2024
2096
|
{
|
|
2025
2097
|
mode: n,
|
|
2026
|
-
template:
|
|
2098
|
+
template: r,
|
|
2027
2099
|
templateTypes: a,
|
|
2028
2100
|
templateList: i,
|
|
2029
|
-
editorInitialized:
|
|
2030
|
-
onReset:
|
|
2031
|
-
onRefresh:
|
|
2032
|
-
closeEditorModal:
|
|
2101
|
+
editorInitialized: s,
|
|
2102
|
+
onReset: x,
|
|
2103
|
+
onRefresh: v,
|
|
2104
|
+
closeEditorModal: c
|
|
2033
2105
|
}
|
|
2034
2106
|
),
|
|
2035
2107
|
n === "preview" ? /* @__PURE__ */ t("div", { className: "ts-template-preview", children: /* @__PURE__ */ t(
|
|
@@ -2040,7 +2112,7 @@ const _e = /* @__PURE__ */ gt(vt), De = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
2040
2112
|
srcDoc: l ?? ""
|
|
2041
2113
|
}
|
|
2042
2114
|
) }) : /* @__PURE__ */ t(
|
|
2043
|
-
|
|
2115
|
+
Et,
|
|
2044
2116
|
{
|
|
2045
2117
|
onEditorInitialized: o,
|
|
2046
2118
|
loading: !1,
|
|
@@ -2051,61 +2123,61 @@ const _e = /* @__PURE__ */ gt(vt), De = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
2051
2123
|
]
|
|
2052
2124
|
}
|
|
2053
2125
|
) }) : null;
|
|
2054
|
-
},
|
|
2126
|
+
}, Rt = () => {
|
|
2055
2127
|
const {
|
|
2056
2128
|
data: e,
|
|
2057
2129
|
isLoading: n,
|
|
2058
|
-
isFetching:
|
|
2130
|
+
isFetching: r,
|
|
2059
2131
|
refetch: a
|
|
2060
|
-
} =
|
|
2132
|
+
} = at(), {
|
|
2061
2133
|
data: i,
|
|
2062
|
-
isLoading:
|
|
2134
|
+
isLoading: s,
|
|
2063
2135
|
isFetching: l
|
|
2064
|
-
} =
|
|
2065
|
-
|
|
2066
|
-
},
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2069
|
-
},
|
|
2136
|
+
} = it(), { mutateAsync: o, isPending: c } = lt(), [v, E] = C(!1), [I, b] = C("add"), [x, u] = C(!1), [p, T] = C(""), [h, y] = C(), g = () => {
|
|
2137
|
+
b("add"), E(!0);
|
|
2138
|
+
}, R = async (S) => {
|
|
2139
|
+
const D = await o({ id: S.id });
|
|
2140
|
+
y({ ...D }), b("edit"), E(!0);
|
|
2141
|
+
}, B = (S) => {
|
|
2070
2142
|
if (!e || e.length === 0) return;
|
|
2071
|
-
const
|
|
2072
|
-
|
|
2073
|
-
},
|
|
2074
|
-
|
|
2143
|
+
const D = e.find((M) => M.id === S.id);
|
|
2144
|
+
T(D?.html + "<style>" + D?.css + "</style>"), b("preview"), E(!0);
|
|
2145
|
+
}, _ = () => {
|
|
2146
|
+
E(!1), u(!1), document.getElementById("UiEditorScript")?.remove();
|
|
2075
2147
|
};
|
|
2076
|
-
return /* @__PURE__ */
|
|
2077
|
-
(n ||
|
|
2148
|
+
return /* @__PURE__ */ d(ye, { children: [
|
|
2149
|
+
(n || s || r || l || c) && /* @__PURE__ */ t(ie, { overlay: !0 }),
|
|
2078
2150
|
/* @__PURE__ */ t(
|
|
2079
|
-
|
|
2151
|
+
Tt,
|
|
2080
2152
|
{
|
|
2081
2153
|
templates: e ?? [],
|
|
2082
2154
|
templateTypes: i ?? [],
|
|
2083
2155
|
onRefresh: a,
|
|
2084
|
-
onAdd:
|
|
2085
|
-
onEdit:
|
|
2086
|
-
onPreview:
|
|
2156
|
+
onAdd: g,
|
|
2157
|
+
onEdit: R,
|
|
2158
|
+
onPreview: B
|
|
2087
2159
|
}
|
|
2088
2160
|
),
|
|
2089
2161
|
/* @__PURE__ */ t(
|
|
2090
|
-
|
|
2162
|
+
_t,
|
|
2091
2163
|
{
|
|
2092
|
-
show:
|
|
2093
|
-
mode:
|
|
2094
|
-
template:
|
|
2164
|
+
show: v,
|
|
2165
|
+
mode: I,
|
|
2166
|
+
template: h,
|
|
2095
2167
|
templateTypes: i ?? [],
|
|
2096
2168
|
templateList: e ?? [],
|
|
2097
|
-
editorInitialized:
|
|
2098
|
-
onEditorInitialized:
|
|
2099
|
-
onClose:
|
|
2169
|
+
editorInitialized: x,
|
|
2170
|
+
onEditorInitialized: u,
|
|
2171
|
+
onClose: _,
|
|
2100
2172
|
onSaved: () => {
|
|
2101
|
-
|
|
2173
|
+
_(), a();
|
|
2102
2174
|
},
|
|
2103
2175
|
onRefresh: a,
|
|
2104
|
-
previewHtml:
|
|
2176
|
+
previewHtml: p
|
|
2105
2177
|
}
|
|
2106
2178
|
)
|
|
2107
2179
|
] });
|
|
2108
|
-
},
|
|
2180
|
+
}, Kt = ({ config: e }) => /* @__PURE__ */ t(Ze, { configs: e, children: /* @__PURE__ */ t(st, { children: /* @__PURE__ */ t(nt, { children: /* @__PURE__ */ t("div", { className: "root-widget", children: /* @__PURE__ */ t(Rt, {}) }) }) }) });
|
|
2109
2181
|
export {
|
|
2110
|
-
|
|
2182
|
+
Kt as EditorWidget
|
|
2111
2183
|
};
|