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