@enerex/template-studio 1.1.40 → 1.1.43
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 +1056 -954
- package/dist/enerex-template-editor.umd.js +13 -13
- 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 +2 -2
- 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,123 +1,123 @@
|
|
|
1
|
-
import { jsx as t, jsxs as d, Fragment 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), [w, 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: w,
|
|
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
|
-
}) => (
|
|
49
|
-
const i = setTimeout(a,
|
|
48
|
+
}) => (L(() => {
|
|
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__ */ d(
|
|
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
|
|
89
|
-
`${e}${
|
|
88
|
+
const o = await we.get(
|
|
89
|
+
`${e}${s}`,
|
|
90
90
|
l ?? n
|
|
91
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
92
|
if (o.status === 200)
|
|
105
93
|
return o.data;
|
|
106
94
|
} catch (o) {
|
|
107
95
|
throw o;
|
|
108
96
|
}
|
|
109
|
-
},
|
|
97
|
+
}, post: async (s, l, o) => {
|
|
110
98
|
try {
|
|
111
|
-
const c = await
|
|
112
|
-
`${e}${
|
|
113
|
-
l
|
|
99
|
+
const c = await we.post(
|
|
100
|
+
`${e}${s}`,
|
|
101
|
+
l,
|
|
102
|
+
o ?? n
|
|
114
103
|
);
|
|
115
|
-
if (c.status === 200
|
|
104
|
+
if (c.status === 200)
|
|
116
105
|
return c.data;
|
|
117
106
|
} catch (c) {
|
|
118
107
|
throw c;
|
|
119
108
|
}
|
|
120
|
-
}
|
|
109
|
+
}, delete: async (s, l) => {
|
|
110
|
+
try {
|
|
111
|
+
const o = await we.delete(
|
|
112
|
+
`${e}${s}`,
|
|
113
|
+
l ?? n
|
|
114
|
+
);
|
|
115
|
+
if (o.status === 200 || o.status === 204)
|
|
116
|
+
return o.data;
|
|
117
|
+
} catch (o) {
|
|
118
|
+
throw o;
|
|
119
|
+
}
|
|
120
|
+
} }), qe = G.createContext({
|
|
121
121
|
get: () => {
|
|
122
122
|
throw new Error("HttpClientContext.get not implemented");
|
|
123
123
|
},
|
|
@@ -127,20 +127,20 @@ const De = 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:
|
|
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,111 +154,257 @@ const De = 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
|
|
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
|
+
mutationKey: ["markFavourite"],
|
|
201
|
+
mutationFn: async (i) => await e.post(
|
|
202
|
+
`${Q.markFavourite}${r}/${n}`,
|
|
203
|
+
i
|
|
204
|
+
)
|
|
205
|
+
});
|
|
206
|
+
}, Le = (e) => {
|
|
207
|
+
let n = /* @__PURE__ */ t(
|
|
208
|
+
"span",
|
|
209
|
+
{
|
|
210
|
+
style: { width: "20px", height: "20px", display: "inline-block" }
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
return e.variant === "filled" ? n = /* @__PURE__ */ t(
|
|
214
|
+
"svg",
|
|
215
|
+
{
|
|
216
|
+
version: "1.0",
|
|
217
|
+
id: "Layer_1",
|
|
218
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
219
|
+
width: "18px",
|
|
220
|
+
height: "18px",
|
|
221
|
+
viewBox: "0 0 64 64",
|
|
222
|
+
"enable-background": "new 0 0 64 64",
|
|
223
|
+
children: /* @__PURE__ */ t(
|
|
224
|
+
"path",
|
|
225
|
+
{
|
|
226
|
+
fill: "#2196F3",
|
|
227
|
+
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
|
|
228
|
+
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
|
|
229
|
+
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
|
|
230
|
+
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
|
|
231
|
+
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
|
|
232
|
+
C63.951,25.771,64.131,24.987,63.893,24.277z`
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
) : e.variant === "outlined" && (n = /* @__PURE__ */ t(
|
|
237
|
+
"svg",
|
|
238
|
+
{
|
|
239
|
+
version: "1.0",
|
|
240
|
+
id: "Layer_1",
|
|
241
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
242
|
+
width: "18px",
|
|
243
|
+
height: "18px",
|
|
244
|
+
viewBox: "0 0 64 64",
|
|
245
|
+
enableBackground: "new 0 0 64 64",
|
|
246
|
+
children: /* @__PURE__ */ t(
|
|
247
|
+
"path",
|
|
248
|
+
{
|
|
249
|
+
fill: e.fill || "rgba(247, 216, 40, 0)",
|
|
250
|
+
stroke: e.stroke || "#000000",
|
|
251
|
+
strokeWidth: e.strokeWidth || "2",
|
|
252
|
+
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
|
|
253
|
+
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
|
|
254
|
+
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
|
|
255
|
+
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
|
|
256
|
+
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
|
|
257
|
+
C63.951,25.771,64.131,24.987,63.893,24.277z`
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
)), n;
|
|
197
262
|
};
|
|
198
|
-
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({
|
|
199
310
|
template: e,
|
|
200
311
|
openActionId: n,
|
|
201
|
-
setOpenActionId:
|
|
312
|
+
setOpenActionId: r,
|
|
202
313
|
onEdit: a,
|
|
203
314
|
onDuplicate: i,
|
|
204
|
-
onRemove:
|
|
205
|
-
onPreview: l
|
|
315
|
+
onRemove: s,
|
|
316
|
+
onPreview: l,
|
|
317
|
+
onRefresh: o
|
|
206
318
|
}) {
|
|
207
|
-
const { isAdmin: c } =
|
|
208
|
-
|
|
209
|
-
function
|
|
210
|
-
|
|
319
|
+
const { isAdmin: c } = V(), v = n === e.id, E = te(null), I = te(null), [b, x, u] = e.categoryChain, { mutateAsync: p, isPending: w } = Ue(), { showNotification: h } = ve(), y = x?.key, g = u?.key, R = !c && y === 9, B = c || g !== 2, _ = c || g !== 2;
|
|
320
|
+
L(() => {
|
|
321
|
+
function S(D) {
|
|
322
|
+
v && E.current && !E.current.contains(D.target) && !I.current?.contains(D.target) && r(null);
|
|
211
323
|
}
|
|
212
|
-
return document.addEventListener("mousedown",
|
|
213
|
-
}, [
|
|
214
|
-
function
|
|
215
|
-
|
|
324
|
+
return document.addEventListener("mousedown", S), () => document.removeEventListener("mousedown", S);
|
|
325
|
+
}, [v, r]), L(() => {
|
|
326
|
+
function S(D) {
|
|
327
|
+
D.key === "Escape" && r(null);
|
|
216
328
|
}
|
|
217
|
-
return
|
|
218
|
-
}, [
|
|
219
|
-
if (!
|
|
220
|
-
const
|
|
221
|
-
|
|
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"]')
|
|
222
334
|
);
|
|
223
|
-
if (!
|
|
224
|
-
let
|
|
225
|
-
|
|
226
|
-
function
|
|
227
|
-
|
|
335
|
+
if (!S.length) return;
|
|
336
|
+
let D = 0;
|
|
337
|
+
S[0].focus();
|
|
338
|
+
function M(T) {
|
|
339
|
+
T.key === "ArrowDown" && (D = (D + 1) % S.length, S[D].focus(), T.preventDefault()), T.key === "ArrowUp" && (D = (D - 1 + S.length) % S.length, S[D].focus(), T.preventDefault());
|
|
228
340
|
}
|
|
229
|
-
return document.addEventListener("keydown",
|
|
230
|
-
}, [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
341
|
+
return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
|
|
342
|
+
}, [v]);
|
|
343
|
+
const A = async () => {
|
|
344
|
+
try {
|
|
345
|
+
await p({
|
|
346
|
+
categoryId: g?.toString() ?? "",
|
|
347
|
+
templateId: e.id ?? ""
|
|
348
|
+
}), o(), h(
|
|
349
|
+
`Template "${e?.name}" marked as favourite`,
|
|
350
|
+
"success"
|
|
351
|
+
);
|
|
352
|
+
} catch (S) {
|
|
353
|
+
console.error(S), h(
|
|
354
|
+
"Unable to mark template as favourite. Please try again.",
|
|
355
|
+
"error"
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
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: w ? /* @__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 ?? "" }),
|
|
244
389
|
/* @__PURE__ */ t("td", { children: e?.updatedByName ?? "" }),
|
|
390
|
+
/* @__PURE__ */ t("td", { children: ct(e.updatedDateTime) }),
|
|
245
391
|
/* @__PURE__ */ t("td", { className: "ts-actions-cell", children: /* @__PURE__ */ d("div", { className: "ts-actions-wrapper", children: [
|
|
246
392
|
/* @__PURE__ */ t(
|
|
247
393
|
"button",
|
|
248
394
|
{
|
|
249
|
-
ref:
|
|
395
|
+
ref: I,
|
|
250
396
|
className: "ts-actions-btn",
|
|
251
397
|
"aria-haspopup": "true",
|
|
252
|
-
"aria-expanded":
|
|
253
|
-
onClick: () =>
|
|
254
|
-
children:
|
|
398
|
+
"aria-expanded": v,
|
|
399
|
+
onClick: () => r(v ? null : e.id),
|
|
400
|
+
children: /* @__PURE__ */ t(dt, {})
|
|
255
401
|
}
|
|
256
402
|
),
|
|
257
403
|
/* @__PURE__ */ d(
|
|
258
404
|
"div",
|
|
259
405
|
{
|
|
260
|
-
ref:
|
|
261
|
-
className: `ts-actions-menu ${
|
|
406
|
+
ref: E,
|
|
407
|
+
className: `ts-actions-menu ${v ? "open" : ""}`,
|
|
262
408
|
role: "menu",
|
|
263
409
|
children: [
|
|
264
410
|
/* @__PURE__ */ t(
|
|
@@ -268,43 +414,43 @@ function nt({
|
|
|
268
414
|
role: "menuitem",
|
|
269
415
|
className: "ts-menu-item",
|
|
270
416
|
onClick: () => {
|
|
271
|
-
|
|
417
|
+
r(null), l(e);
|
|
272
418
|
},
|
|
273
419
|
children: "Preview"
|
|
274
420
|
}
|
|
275
421
|
),
|
|
276
|
-
|
|
422
|
+
B && /* @__PURE__ */ t(
|
|
277
423
|
"button",
|
|
278
424
|
{
|
|
279
425
|
type: "button",
|
|
280
426
|
role: "menuitem",
|
|
281
427
|
className: "ts-menu-item",
|
|
282
428
|
onClick: () => {
|
|
283
|
-
|
|
429
|
+
r(null), a(e);
|
|
284
430
|
},
|
|
285
431
|
children: "Edit"
|
|
286
432
|
}
|
|
287
433
|
),
|
|
288
|
-
|
|
434
|
+
/* @__PURE__ */ t(
|
|
289
435
|
"button",
|
|
290
436
|
{
|
|
291
437
|
type: "button",
|
|
292
438
|
role: "menuitem",
|
|
293
439
|
className: "ts-menu-item",
|
|
294
440
|
onClick: () => {
|
|
295
|
-
|
|
441
|
+
r(null), i(e);
|
|
296
442
|
},
|
|
297
443
|
children: "Duplicate"
|
|
298
444
|
}
|
|
299
445
|
),
|
|
300
|
-
|
|
446
|
+
_ && /* @__PURE__ */ t(
|
|
301
447
|
"button",
|
|
302
448
|
{
|
|
303
449
|
type: "button",
|
|
304
450
|
role: "menuitem",
|
|
305
451
|
className: "ts-menu-item danger",
|
|
306
452
|
onClick: () => {
|
|
307
|
-
|
|
453
|
+
r(null), s(e);
|
|
308
454
|
},
|
|
309
455
|
children: "Remove"
|
|
310
456
|
}
|
|
@@ -315,139 +461,209 @@ function nt({
|
|
|
315
461
|
] }) })
|
|
316
462
|
] }) });
|
|
317
463
|
}
|
|
318
|
-
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 = ({
|
|
319
522
|
page: e,
|
|
320
523
|
pageSize: n,
|
|
321
|
-
totalRecords:
|
|
524
|
+
totalRecords: r,
|
|
322
525
|
onPageChange: a,
|
|
323
526
|
onPageSizeChange: i
|
|
324
527
|
}) => {
|
|
325
|
-
const
|
|
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
|
+
};
|
|
326
540
|
return /* @__PURE__ */ d("div", { className: "ts-pagination-bar", children: [
|
|
327
541
|
/* @__PURE__ */ d("div", { className: "ts-page-container", children: [
|
|
328
542
|
/* @__PURE__ */ d("div", { className: "ts-page-size", children: [
|
|
329
|
-
"Display:",
|
|
543
|
+
/* @__PURE__ */ t("label", { children: "Display:" }),
|
|
330
544
|
/* @__PURE__ */ t(
|
|
331
545
|
"select",
|
|
332
546
|
{
|
|
333
547
|
value: n,
|
|
334
|
-
onChange: (
|
|
335
|
-
i(Number(
|
|
548
|
+
onChange: (u) => {
|
|
549
|
+
i(Number(u.target.value)), a(1);
|
|
336
550
|
},
|
|
337
|
-
children: [10, 25, 50, 100].map((
|
|
551
|
+
children: [10, 25, 50, 100].map((u) => /* @__PURE__ */ t("option", { value: u, children: u }, u))
|
|
338
552
|
}
|
|
339
553
|
)
|
|
340
554
|
] }),
|
|
341
555
|
/* @__PURE__ */ d("div", { className: "ts-page-info", children: [
|
|
342
556
|
"Page ",
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
557
|
+
/* @__PURE__ */ d("span", { children: [
|
|
558
|
+
e,
|
|
559
|
+
" of ",
|
|
560
|
+
s
|
|
561
|
+
] })
|
|
346
562
|
] }),
|
|
347
563
|
/* @__PURE__ */ d("div", { className: "ts-go-to", children: [
|
|
348
|
-
"Go to page:",
|
|
564
|
+
/* @__PURE__ */ t("span", { children: "Go to page:" }),
|
|
349
565
|
/* @__PURE__ */ t(
|
|
350
566
|
"input",
|
|
351
567
|
{
|
|
352
568
|
type: "number",
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
C >= 1 && C <= r && a(C);
|
|
569
|
+
value: I,
|
|
570
|
+
onChange: (u) => b(u.target.value),
|
|
571
|
+
onBlur: x,
|
|
572
|
+
onKeyDown: (u) => {
|
|
573
|
+
u.key === "Enter" && x();
|
|
359
574
|
}
|
|
360
575
|
}
|
|
361
576
|
)
|
|
362
577
|
] })
|
|
363
578
|
] }),
|
|
364
579
|
/* @__PURE__ */ d("div", { className: "ts-total", children: [
|
|
365
|
-
"Total:
|
|
366
|
-
|
|
580
|
+
/* @__PURE__ */ t("span", { children: "Total:" }),
|
|
581
|
+
" ",
|
|
582
|
+
r
|
|
367
583
|
] }),
|
|
368
584
|
/* @__PURE__ */ d("div", { className: "ts-page-buttons", children: [
|
|
369
585
|
/* @__PURE__ */ t("button", { disabled: e === 1, onClick: () => a(e - 1), children: "‹" }),
|
|
370
|
-
|
|
586
|
+
o.map((u) => /* @__PURE__ */ t(
|
|
371
587
|
"button",
|
|
372
588
|
{
|
|
373
|
-
className:
|
|
374
|
-
onClick: () => a(
|
|
375
|
-
children:
|
|
589
|
+
className: u === e ? "active" : "",
|
|
590
|
+
onClick: () => a(u),
|
|
591
|
+
children: u
|
|
376
592
|
},
|
|
377
|
-
|
|
593
|
+
u
|
|
378
594
|
)),
|
|
379
|
-
|
|
380
|
-
|
|
595
|
+
c && /* @__PURE__ */ t("span", { style: { padding: "0 6px" }, children: "…" }),
|
|
596
|
+
c && /* @__PURE__ */ t(
|
|
381
597
|
"button",
|
|
382
598
|
{
|
|
383
|
-
className: e ===
|
|
384
|
-
onClick: () => a(
|
|
385
|
-
children:
|
|
599
|
+
className: e === v ? "active" : "",
|
|
600
|
+
onClick: () => a(v),
|
|
601
|
+
children: v
|
|
386
602
|
}
|
|
387
603
|
),
|
|
388
604
|
/* @__PURE__ */ t(
|
|
389
605
|
"button",
|
|
390
606
|
{
|
|
391
|
-
disabled: e ===
|
|
607
|
+
disabled: e === s,
|
|
392
608
|
onClick: () => a(e + 1),
|
|
393
609
|
children: "›"
|
|
394
610
|
}
|
|
395
611
|
)
|
|
396
612
|
] })
|
|
397
613
|
] });
|
|
398
|
-
},
|
|
614
|
+
}, yt = ({
|
|
399
615
|
show: e,
|
|
400
616
|
variant: n,
|
|
401
|
-
title:
|
|
617
|
+
title: r = "Are you sure?",
|
|
402
618
|
message: a,
|
|
403
619
|
label: i = "Name",
|
|
404
|
-
value:
|
|
620
|
+
value: s = "",
|
|
405
621
|
placeholder: l = "",
|
|
406
|
-
requiredMessage:
|
|
407
|
-
externalError:
|
|
408
|
-
externalErrorMessage:
|
|
409
|
-
confirmText:
|
|
410
|
-
cancelText:
|
|
411
|
-
confirmButtonVariant:
|
|
412
|
-
disableConfirm:
|
|
413
|
-
onConfirm:
|
|
414
|
-
onCancel:
|
|
415
|
-
onInputChange:
|
|
622
|
+
requiredMessage: o = "This field is required",
|
|
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: w
|
|
416
632
|
}) => {
|
|
417
|
-
const [
|
|
418
|
-
if (
|
|
633
|
+
const [h, y] = C(s), [g, R] = C(!1), B = te(null);
|
|
634
|
+
if (L(() => {
|
|
419
635
|
if (!e) return;
|
|
420
|
-
const
|
|
421
|
-
|
|
636
|
+
const M = (T) => {
|
|
637
|
+
T.key === "Escape" && p();
|
|
422
638
|
};
|
|
423
|
-
return document.addEventListener("keydown",
|
|
424
|
-
}, [e,
|
|
639
|
+
return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
|
|
640
|
+
}, [e, p]), L(() => {
|
|
425
641
|
if (!e) return;
|
|
426
|
-
const
|
|
427
|
-
|
|
642
|
+
const M = (T) => {
|
|
643
|
+
B.current && !B.current.contains(T.target) && p();
|
|
428
644
|
};
|
|
429
|
-
return document.addEventListener("mousedown",
|
|
430
|
-
}, [e,
|
|
645
|
+
return document.addEventListener("mousedown", M), () => document.removeEventListener("mousedown", M);
|
|
646
|
+
}, [e, p]), L(() => {
|
|
431
647
|
if (e)
|
|
432
648
|
return document.body.style.overflow = "hidden", () => {
|
|
433
649
|
document.body.style.overflow = "";
|
|
434
650
|
};
|
|
435
|
-
}, [e]),
|
|
436
|
-
e && (
|
|
437
|
-
}, [e,
|
|
438
|
-
|
|
439
|
-
}, [
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
442
|
-
|
|
651
|
+
}, [e]), L(() => {
|
|
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);
|
|
443
659
|
return;
|
|
444
660
|
}
|
|
445
|
-
|
|
661
|
+
u(h.trim());
|
|
446
662
|
};
|
|
447
|
-
return /* @__PURE__ */ t("div", { className: "ts-modal-overlay", children: /* @__PURE__ */ d("div", { ref:
|
|
663
|
+
return /* @__PURE__ */ t("div", { className: "ts-modal-overlay", children: /* @__PURE__ */ d("div", { ref: B, className: "ts-modal", children: [
|
|
448
664
|
/* @__PURE__ */ d("div", { className: "ts-modal-header", children: [
|
|
449
|
-
/* @__PURE__ */ t("h4", { className: "ts-modal-title ", children:
|
|
450
|
-
/* @__PURE__ */ t("button", { className: "ts-modal-close", onClick:
|
|
665
|
+
/* @__PURE__ */ t("h4", { className: "ts-modal-title ", children: r }),
|
|
666
|
+
/* @__PURE__ */ t("button", { className: "ts-modal-close", onClick: p, children: "✕" })
|
|
451
667
|
] }),
|
|
452
668
|
/* @__PURE__ */ d("div", { className: "ts-modal-body", children: [
|
|
453
669
|
a && /* @__PURE__ */ t("p", { className: "ts-modal-message", children: a }),
|
|
@@ -460,17 +676,17 @@ const rt = je(nt), ve = 5, st = ({
|
|
|
460
676
|
"input",
|
|
461
677
|
{
|
|
462
678
|
type: "text",
|
|
463
|
-
className: `ts-input ${
|
|
679
|
+
className: `ts-input ${g && A ? "ts-input-error" : ""}`,
|
|
464
680
|
placeholder: l,
|
|
465
|
-
value:
|
|
466
|
-
onChange: (
|
|
467
|
-
|
|
681
|
+
value: h,
|
|
682
|
+
onChange: (M) => {
|
|
683
|
+
y(M.target.value), g && R(!1), w?.(M.target.value);
|
|
468
684
|
},
|
|
469
685
|
autoFocus: !0,
|
|
470
686
|
style: { paddingBlock: "0", paddingInline: "0" }
|
|
471
687
|
}
|
|
472
688
|
),
|
|
473
|
-
|
|
689
|
+
g && A && /* @__PURE__ */ t("div", { className: "ts-error-text", children: S })
|
|
474
690
|
] })
|
|
475
691
|
] }),
|
|
476
692
|
/* @__PURE__ */ d("div", { className: "ts-modal-footer", children: [
|
|
@@ -479,43 +695,43 @@ const rt = je(nt), ve = 5, st = ({
|
|
|
479
695
|
{
|
|
480
696
|
type: "button",
|
|
481
697
|
className: "ts-btn ts-btn-secondary",
|
|
482
|
-
onClick:
|
|
483
|
-
children:
|
|
698
|
+
onClick: p,
|
|
699
|
+
children: I
|
|
484
700
|
}
|
|
485
701
|
),
|
|
486
702
|
/* @__PURE__ */ t(
|
|
487
703
|
"button",
|
|
488
704
|
{
|
|
489
705
|
type: "button",
|
|
490
|
-
className: `ts-btn ts-btn-${
|
|
491
|
-
onClick:
|
|
492
|
-
disabled:
|
|
493
|
-
children:
|
|
706
|
+
className: `ts-btn ts-btn-${b}`,
|
|
707
|
+
onClick: D,
|
|
708
|
+
disabled: x,
|
|
709
|
+
children: E
|
|
494
710
|
}
|
|
495
711
|
)
|
|
496
712
|
] })
|
|
497
713
|
] }) });
|
|
498
|
-
},
|
|
714
|
+
}, gt = () => /* @__PURE__ */ t(
|
|
499
715
|
"svg",
|
|
500
716
|
{
|
|
501
717
|
xmlns: "http://www.w3.org/2000/svg",
|
|
502
718
|
viewBox: "0 0 512 512",
|
|
503
|
-
width: "
|
|
504
|
-
height: "
|
|
719
|
+
width: "11px",
|
|
720
|
+
height: "11px",
|
|
505
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" })
|
|
506
722
|
}
|
|
507
|
-
),
|
|
508
|
-
const e =
|
|
509
|
-
return
|
|
723
|
+
), vt = () => {
|
|
724
|
+
const e = Y(), { enerexIdentifier: n, projectId: r, userEmail: a } = V();
|
|
725
|
+
return ce({
|
|
510
726
|
mutationKey: ["duplicateTemplate"],
|
|
511
|
-
mutationFn: async ({ templateId:
|
|
512
|
-
`${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}`,
|
|
513
729
|
l
|
|
514
730
|
))
|
|
515
731
|
});
|
|
516
|
-
},
|
|
517
|
-
const e =
|
|
518
|
-
return
|
|
732
|
+
}, bt = () => {
|
|
733
|
+
const e = Y();
|
|
734
|
+
return ce({
|
|
519
735
|
mutationKey: ["deleteTemplate"],
|
|
520
736
|
mutationFn: async (n) => {
|
|
521
737
|
await e.delete(
|
|
@@ -523,306 +739,305 @@ const rt = je(nt), ve = 5, st = ({
|
|
|
523
739
|
);
|
|
524
740
|
}
|
|
525
741
|
});
|
|
526
|
-
},
|
|
742
|
+
}, wt = ({
|
|
527
743
|
data: e,
|
|
528
744
|
page: n,
|
|
529
|
-
pageSize:
|
|
745
|
+
pageSize: r
|
|
530
746
|
}) => {
|
|
531
|
-
const a =
|
|
532
|
-
return { pagedData:
|
|
533
|
-
const
|
|
534
|
-
return e.slice(
|
|
535
|
-
}, [e, n,
|
|
536
|
-
},
|
|
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 = ({
|
|
537
753
|
templates: e,
|
|
538
754
|
templateTypes: n,
|
|
539
|
-
onRefresh:
|
|
755
|
+
onRefresh: r,
|
|
540
756
|
onAdd: a,
|
|
541
757
|
onEdit: i,
|
|
542
|
-
onPreview:
|
|
758
|
+
onPreview: s
|
|
543
759
|
}) => {
|
|
544
|
-
const {
|
|
545
|
-
|
|
546
|
-
}, [
|
|
547
|
-
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
760
|
+
const { isAdmin: l } = V(), { mutateAsync: o, isPending: c } = vt(), { mutateAsync: v, isPending: E } = bt(), [I, b] = C(""), [x, u] = C(""), [p, w] = C(null), [h, y] = C(e), [g, R] = C(n), [B, _] = C(!1), [A, S] = C("input"), [D, M] = C(!1), [T, ne] = C(null), [U, W] = C("asc"), K = (m) => {
|
|
761
|
+
T === m ? W((N) => N === "asc" ? "desc" : "asc") : (ne(m), W("asc")), ee(1);
|
|
762
|
+
}, [O, re] = C(null);
|
|
763
|
+
L(() => {
|
|
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);
|
|
551
769
|
});
|
|
552
|
-
|
|
553
|
-
}, [e]),
|
|
554
|
-
|
|
770
|
+
y(m), ne(null);
|
|
771
|
+
}, [e]), L(() => {
|
|
772
|
+
R(n.filter((m) => m.id != null));
|
|
555
773
|
}, [n]);
|
|
556
|
-
const
|
|
557
|
-
const
|
|
558
|
-
return
|
|
559
|
-
}, [
|
|
560
|
-
(
|
|
561
|
-
const
|
|
562
|
-
let
|
|
563
|
-
for (;
|
|
564
|
-
|
|
565
|
-
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();
|
|
566
784
|
},
|
|
567
|
-
[
|
|
568
|
-
),
|
|
569
|
-
...
|
|
570
|
-
categoryChain:
|
|
571
|
-
})), [
|
|
572
|
-
|
|
573
|
-
const
|
|
574
|
-
|
|
785
|
+
[le]
|
|
786
|
+
), Z = ae(() => !h.length || !g.length ? [] : h.map((m) => ({
|
|
787
|
+
...m,
|
|
788
|
+
categoryChain: de(m.type)
|
|
789
|
+
})), [h, g]);
|
|
790
|
+
L(() => {
|
|
791
|
+
const m = setTimeout(() => {
|
|
792
|
+
u(I), ee(1);
|
|
575
793
|
}, 300);
|
|
576
|
-
return () => clearTimeout(
|
|
577
|
-
}, [
|
|
578
|
-
const [
|
|
579
|
-
const
|
|
580
|
-
return
|
|
581
|
-
const
|
|
582
|
-
(
|
|
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)
|
|
583
801
|
);
|
|
584
|
-
return
|
|
585
|
-
}) :
|
|
586
|
-
}, [
|
|
587
|
-
const
|
|
588
|
-
return
|
|
589
|
-
|
|
590
|
-
|
|
802
|
+
return $ || P;
|
|
803
|
+
}) : Z;
|
|
804
|
+
}, [Z, x]), pe = ae(() => {
|
|
805
|
+
const m = [...me];
|
|
806
|
+
return m.sort((N, $) => {
|
|
807
|
+
if (T === "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 (T) {
|
|
591
813
|
case "name":
|
|
592
|
-
|
|
814
|
+
P = N.name, z = $.name;
|
|
593
815
|
break;
|
|
594
816
|
case "category":
|
|
595
|
-
|
|
817
|
+
P = N.categoryChain?.[0]?.name ?? "", z = $.categoryChain?.[0]?.name ?? "";
|
|
596
818
|
break;
|
|
597
819
|
case "type":
|
|
598
|
-
|
|
820
|
+
P = N.categoryChain?.[1]?.name ?? "", z = $.categoryChain?.[1]?.name ?? "";
|
|
599
821
|
break;
|
|
600
822
|
case "subtype":
|
|
601
|
-
|
|
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 ?? "";
|
|
602
833
|
break;
|
|
603
834
|
}
|
|
604
|
-
const
|
|
835
|
+
const De = P.localeCompare(z, void 0, {
|
|
605
836
|
sensitivity: "base"
|
|
606
837
|
});
|
|
607
|
-
return
|
|
608
|
-
}),
|
|
609
|
-
}, [
|
|
610
|
-
data:
|
|
611
|
-
page:
|
|
612
|
-
pageSize:
|
|
613
|
-
}),
|
|
614
|
-
(
|
|
615
|
-
(
|
|
838
|
+
return U === "asc" ? De : -De;
|
|
839
|
+
}), m;
|
|
840
|
+
}, [me, T, 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()
|
|
616
847
|
),
|
|
617
|
-
[
|
|
618
|
-
),
|
|
619
|
-
|
|
620
|
-
},
|
|
621
|
-
|
|
622
|
-
}, { showNotification:
|
|
623
|
-
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)
|
|
624
855
|
try {
|
|
625
|
-
if (
|
|
626
|
-
if (!
|
|
627
|
-
if (
|
|
628
|
-
|
|
856
|
+
if (A === "input") {
|
|
857
|
+
if (!m) return;
|
|
858
|
+
if (f(m)) {
|
|
859
|
+
M(!0);
|
|
629
860
|
return;
|
|
630
861
|
}
|
|
631
|
-
await
|
|
632
|
-
templateId:
|
|
862
|
+
await o({
|
|
863
|
+
templateId: O.id,
|
|
633
864
|
request: {
|
|
634
865
|
projectId: "",
|
|
635
866
|
enerexIdentifier: "",
|
|
636
|
-
newName:
|
|
637
|
-
parent_id:
|
|
867
|
+
newName: m,
|
|
868
|
+
parent_id: O.id ?? null
|
|
638
869
|
}
|
|
639
|
-
}),
|
|
640
|
-
`Template "${
|
|
870
|
+
}), j(
|
|
871
|
+
`Template "${m}" duplicated successfully`,
|
|
641
872
|
"success"
|
|
642
873
|
);
|
|
643
874
|
}
|
|
644
|
-
|
|
645
|
-
`Template "${
|
|
875
|
+
A === "confirm" && (await v(O.id), j(
|
|
876
|
+
`Template "${O.name}" deleted successfully`,
|
|
646
877
|
"success"
|
|
647
|
-
)),
|
|
878
|
+
)), _(!1), re(null), r();
|
|
648
879
|
} catch {
|
|
649
|
-
|
|
650
|
-
|
|
880
|
+
j(
|
|
881
|
+
A === "confirm" ? "Failed to delete template. Please try again." : "Failed to duplicate template. Please try again.",
|
|
651
882
|
"error"
|
|
652
883
|
);
|
|
653
884
|
}
|
|
654
|
-
}, q =
|
|
655
|
-
return /* @__PURE__ */ d(
|
|
656
|
-
(c ||
|
|
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 }),
|
|
657
888
|
/* @__PURE__ */ d("div", { className: "ts-page", children: [
|
|
658
889
|
/* @__PURE__ */ d("div", { className: "ts-header", children: [
|
|
659
890
|
/* @__PURE__ */ t("h1", { className: "ts-title", children: "Templates" }),
|
|
660
891
|
/* @__PURE__ */ t("button", { className: "ts-btn ts-btn-primary", onClick: a, children: "+ Add Template" })
|
|
661
892
|
] }),
|
|
662
|
-
/* @__PURE__ */ t("div", { className: "ts-search", children: /* @__PURE__ */ d("div", { className: "ts-search-
|
|
663
|
-
/* @__PURE__ */ t(
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
"button",
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
"
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
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: T,
|
|
916
|
+
sortOrder: U,
|
|
917
|
+
onSort: K
|
|
918
|
+
}
|
|
919
|
+
),
|
|
920
|
+
l && /* @__PURE__ */ t(
|
|
921
|
+
J,
|
|
922
|
+
{
|
|
923
|
+
label: "Template Id",
|
|
924
|
+
sortKey: "templateId",
|
|
925
|
+
sortBy: T,
|
|
926
|
+
sortOrder: U,
|
|
927
|
+
onSort: K
|
|
928
|
+
}
|
|
929
|
+
),
|
|
930
|
+
/* @__PURE__ */ t(
|
|
931
|
+
J,
|
|
932
|
+
{
|
|
933
|
+
label: "Category",
|
|
934
|
+
sortKey: "category",
|
|
935
|
+
sortBy: T,
|
|
936
|
+
sortOrder: U,
|
|
937
|
+
onSort: K
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
/* @__PURE__ */ t(
|
|
941
|
+
J,
|
|
942
|
+
{
|
|
943
|
+
label: "Type",
|
|
944
|
+
sortKey: "type",
|
|
945
|
+
sortBy: T,
|
|
946
|
+
sortOrder: U,
|
|
947
|
+
onSort: K
|
|
948
|
+
}
|
|
949
|
+
),
|
|
950
|
+
/* @__PURE__ */ t(
|
|
951
|
+
J,
|
|
952
|
+
{
|
|
953
|
+
label: "Subtype",
|
|
954
|
+
sortKey: "subtype",
|
|
955
|
+
sortBy: T,
|
|
956
|
+
sortOrder: U,
|
|
957
|
+
onSort: K
|
|
958
|
+
}
|
|
959
|
+
),
|
|
960
|
+
l && /* @__PURE__ */ t(
|
|
961
|
+
J,
|
|
962
|
+
{
|
|
963
|
+
label: "Company Name",
|
|
964
|
+
sortKey: "companyName",
|
|
965
|
+
sortBy: T,
|
|
966
|
+
sortOrder: U,
|
|
967
|
+
onSort: K
|
|
968
|
+
}
|
|
969
|
+
),
|
|
970
|
+
/* @__PURE__ */ t(
|
|
971
|
+
J,
|
|
972
|
+
{
|
|
973
|
+
label: "Last Updated by",
|
|
974
|
+
sortKey: "lastUpdatedBy",
|
|
975
|
+
sortBy: T,
|
|
976
|
+
sortOrder: U,
|
|
977
|
+
onSort: K
|
|
978
|
+
}
|
|
979
|
+
),
|
|
980
|
+
/* @__PURE__ */ t(
|
|
981
|
+
J,
|
|
982
|
+
{
|
|
983
|
+
label: "Last Updated on",
|
|
984
|
+
sortKey: "lastUpdatedOn",
|
|
985
|
+
sortBy: T,
|
|
986
|
+
sortOrder: U,
|
|
987
|
+
onSort: K
|
|
988
|
+
}
|
|
989
|
+
),
|
|
990
|
+
/* @__PURE__ */ t("th", { className: "ts-cursor-default", children: "Actions" })
|
|
749
991
|
] }) }),
|
|
750
|
-
/* @__PURE__ */ t(
|
|
751
|
-
|
|
992
|
+
/* @__PURE__ */ t("tbody", { children: be.map((m) => /* @__PURE__ */ t(
|
|
993
|
+
mt,
|
|
752
994
|
{
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
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,
|
|
995
|
+
template: m,
|
|
996
|
+
openActionId: p,
|
|
997
|
+
setOpenActionId: w,
|
|
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,
|
|
781
1009
|
{
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
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
|
-
] })
|
|
1010
|
+
page: ue,
|
|
1011
|
+
pageSize: se,
|
|
1012
|
+
totalRecords: pe.length,
|
|
1013
|
+
onPageChange: ee,
|
|
1014
|
+
onPageSizeChange: H
|
|
1015
|
+
}
|
|
1016
|
+
)
|
|
1017
|
+
] })
|
|
1018
|
+
] }) })
|
|
804
1019
|
] }),
|
|
805
1020
|
/* @__PURE__ */ t(
|
|
806
|
-
|
|
1021
|
+
yt,
|
|
807
1022
|
{
|
|
808
|
-
show:
|
|
809
|
-
variant:
|
|
810
|
-
title:
|
|
811
|
-
message:
|
|
812
|
-
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" : "",
|
|
813
1028
|
label: "New Name",
|
|
814
1029
|
requiredMessage: "Enter a new name",
|
|
815
|
-
externalError:
|
|
1030
|
+
externalError: D,
|
|
816
1031
|
externalErrorMessage: "Template name already exists. Please choose a different name",
|
|
817
|
-
confirmText:
|
|
818
|
-
confirmButtonVariant:
|
|
819
|
-
onConfirm:
|
|
820
|
-
onCancel: () =>
|
|
821
|
-
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
|
|
822
1037
|
}
|
|
823
1038
|
)
|
|
824
1039
|
] });
|
|
825
|
-
},
|
|
1040
|
+
}, he = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
|
|
826
1041
|
<html\r
|
|
827
1042
|
dir="ltr"\r
|
|
828
1043
|
xmlns:o="urn:schemas-microsoft-com:office:office"\r
|
|
@@ -1178,70 +1393,70 @@ const rt = je(nt), ve = 5, st = ({
|
|
|
1178
1393
|
</div>\r
|
|
1179
1394
|
</body>\r
|
|
1180
1395
|
</html>\r
|
|
1181
|
-
`,
|
|
1396
|
+
`, xe = {
|
|
1182
1397
|
EDITOR_SCRIPT_URL: "https://plugins.stripo.email/resources/uieditor/latest/UIEditor.js",
|
|
1183
1398
|
EDITOR_PLUGIN_ID: "1afdc3161ec7409a8627a1c8561d45f5",
|
|
1184
1399
|
EDITOR_SECRET_KEY: "54ba748ed7e94f2e929555783acb03da"
|
|
1185
|
-
},
|
|
1186
|
-
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 = [];
|
|
1187
1402
|
return n.forEach((a) => {
|
|
1188
|
-
const i = e.filter((
|
|
1189
|
-
label:
|
|
1190
|
-
value:
|
|
1191
|
-
hint:
|
|
1192
|
-
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
|
|
1193
1408
|
}));
|
|
1194
|
-
|
|
1195
|
-
}),
|
|
1196
|
-
},
|
|
1197
|
-
const e =
|
|
1198
|
-
return
|
|
1409
|
+
r.push({ category: a, entries: i });
|
|
1410
|
+
}), r;
|
|
1411
|
+
}, Ct = () => {
|
|
1412
|
+
const e = Y(), { enerexIdentifier: n, projectId: r } = V();
|
|
1413
|
+
return ge({
|
|
1199
1414
|
queryKey: ["getTemplateTags"],
|
|
1200
1415
|
queryFn: async (i) => await e.get(
|
|
1201
|
-
`${Q.MergeTags}${
|
|
1416
|
+
`${Q.MergeTags}${r}/${n}`
|
|
1202
1417
|
)
|
|
1203
1418
|
});
|
|
1204
|
-
},
|
|
1205
|
-
const e =
|
|
1206
|
-
return
|
|
1419
|
+
}, xt = () => {
|
|
1420
|
+
const e = Y(), { enerexIdentifier: n, projectId: r } = V();
|
|
1421
|
+
return ge({
|
|
1207
1422
|
queryKey: ["getExcludeCategory"],
|
|
1208
1423
|
queryFn: async (i) => await e.get(
|
|
1209
|
-
`${Q.ExcludeCategory}${
|
|
1424
|
+
`${Q.ExcludeCategory}${r}/${n}`
|
|
1210
1425
|
)
|
|
1211
1426
|
});
|
|
1212
|
-
},
|
|
1427
|
+
}, Et = ({
|
|
1213
1428
|
templateHTML: e,
|
|
1214
1429
|
className: n = "",
|
|
1215
|
-
loading:
|
|
1430
|
+
loading: r = !1,
|
|
1216
1431
|
onEditorInitialized: a
|
|
1217
1432
|
}) => {
|
|
1218
|
-
const { post: i } =
|
|
1219
|
-
e ?? { html:
|
|
1220
|
-
), { userEmail:
|
|
1221
|
-
|
|
1222
|
-
(async () => (await
|
|
1223
|
-
}, [
|
|
1224
|
-
async function
|
|
1225
|
-
window.Zone || await new Promise((
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1228
|
-
const
|
|
1229
|
-
|
|
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";
|
|
1436
|
+
L(() => {
|
|
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((w, 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 = () => w(), y.onerror = () => h(new Error("Failed to load zone.js")), document.head.appendChild(y);
|
|
1230
1445
|
});
|
|
1231
1446
|
}
|
|
1232
|
-
async function
|
|
1233
|
-
let
|
|
1447
|
+
async function u(w) {
|
|
1448
|
+
let h = document.getElementById(
|
|
1234
1449
|
"UiEditorScript"
|
|
1235
1450
|
);
|
|
1236
|
-
|
|
1237
|
-
await
|
|
1238
|
-
}, document.body.appendChild(
|
|
1239
|
-
(
|
|
1451
|
+
h || (h = document.createElement("script"), h.id = "UiEditorScript", h.src = w, h.onload = async () => {
|
|
1452
|
+
await p();
|
|
1453
|
+
}, document.body.appendChild(h)), await new Promise(
|
|
1454
|
+
(y) => h.addEventListener("load", () => y(), { once: !0 })
|
|
1240
1455
|
);
|
|
1241
1456
|
}
|
|
1242
|
-
const
|
|
1243
|
-
const
|
|
1244
|
-
if (!
|
|
1457
|
+
const p = async () => {
|
|
1458
|
+
const w = E.current;
|
|
1459
|
+
if (!w) {
|
|
1245
1460
|
console.error("Missing #stripoEditorContainer in DOM");
|
|
1246
1461
|
return;
|
|
1247
1462
|
}
|
|
@@ -1249,48 +1464,48 @@ const rt = je(nt), ve = 5, st = ({
|
|
|
1249
1464
|
console.error("UIEditor script not loaded or not exposing initEditor");
|
|
1250
1465
|
return;
|
|
1251
1466
|
}
|
|
1252
|
-
const
|
|
1253
|
-
html:
|
|
1254
|
-
css:
|
|
1467
|
+
const h = {
|
|
1468
|
+
html: o.html,
|
|
1469
|
+
css: o.css,
|
|
1255
1470
|
modulesExcludedCategories: l ?? [],
|
|
1256
1471
|
forceRecreate: !0,
|
|
1257
1472
|
metadata: {
|
|
1258
|
-
emailId:
|
|
1473
|
+
emailId: v,
|
|
1259
1474
|
userId: "1",
|
|
1260
1475
|
// username: userName,
|
|
1261
|
-
avatarUrl:
|
|
1476
|
+
avatarUrl: I
|
|
1262
1477
|
},
|
|
1263
1478
|
locale: "en",
|
|
1264
|
-
onTokenRefreshRequest: async (
|
|
1265
|
-
const
|
|
1266
|
-
pluginId:
|
|
1267
|
-
secretKey:
|
|
1268
|
-
userId:
|
|
1479
|
+
onTokenRefreshRequest: async (y) => {
|
|
1480
|
+
const g = {
|
|
1481
|
+
pluginId: xe.EDITOR_PLUGIN_ID,
|
|
1482
|
+
secretKey: xe.EDITOR_SECRET_KEY,
|
|
1483
|
+
userId: v,
|
|
1269
1484
|
role: "user"
|
|
1270
|
-
},
|
|
1271
|
-
|
|
1272
|
-
|
|
1485
|
+
}, R = await i(
|
|
1486
|
+
b,
|
|
1487
|
+
g
|
|
1273
1488
|
);
|
|
1274
|
-
|
|
1489
|
+
R?.token && y(R.token);
|
|
1275
1490
|
},
|
|
1276
1491
|
onTemplateLoaded: () => {
|
|
1277
1492
|
a && a(!0);
|
|
1278
1493
|
},
|
|
1279
|
-
mergeTags:
|
|
1494
|
+
mergeTags: Nt(s ?? [])
|
|
1280
1495
|
};
|
|
1281
|
-
for (const [
|
|
1496
|
+
for (const [y, g] of Object.entries({
|
|
1282
1497
|
codeEditorButtonSelector: "#codeEditor",
|
|
1283
1498
|
undoButtonSelector: "#undoButton",
|
|
1284
1499
|
redoButtonSelector: "#redoButton",
|
|
1285
1500
|
mobileViewButtonSelector: "#mobileViewButton",
|
|
1286
1501
|
desktopViewButtonSelector: "#desktopViewButton"
|
|
1287
1502
|
}))
|
|
1288
|
-
|
|
1289
|
-
await window.UIEditor.initEditor(
|
|
1503
|
+
w.ownerDocument && w.getRootNode() instanceof ShadowRoot && w.getRootNode().querySelector(g) && (h[y] = g);
|
|
1504
|
+
await window.UIEditor.initEditor(w, h);
|
|
1290
1505
|
};
|
|
1291
1506
|
return /* @__PURE__ */ t("div", { className: "position-relative", children: /* @__PURE__ */ d("div", { className: `editor-container ${n}`, children: [
|
|
1292
|
-
|
|
1293
|
-
|
|
1507
|
+
r && /* @__PURE__ */ t("div", { className: "loading-overlay", children: /* @__PURE__ */ t(
|
|
1508
|
+
Qe,
|
|
1294
1509
|
{
|
|
1295
1510
|
animation: "border",
|
|
1296
1511
|
style: { width: "11px", height: "11px" },
|
|
@@ -1301,19 +1516,19 @@ const rt = je(nt), ve = 5, st = ({
|
|
|
1301
1516
|
}
|
|
1302
1517
|
) }),
|
|
1303
1518
|
/* @__PURE__ */ t("div", { id: "externalSystemContainer" }),
|
|
1304
|
-
/* @__PURE__ */ t("div", { id: "stripoEditorContainer", ref:
|
|
1519
|
+
/* @__PURE__ */ t("div", { id: "stripoEditorContainer", ref: E })
|
|
1305
1520
|
] }) });
|
|
1306
|
-
},
|
|
1521
|
+
}, Me = ({
|
|
1307
1522
|
label: e,
|
|
1308
1523
|
register: n,
|
|
1309
|
-
validation:
|
|
1524
|
+
validation: r,
|
|
1310
1525
|
required: a = !1,
|
|
1311
1526
|
name: i,
|
|
1312
|
-
error:
|
|
1527
|
+
error: s,
|
|
1313
1528
|
className: l = "",
|
|
1314
|
-
...
|
|
1529
|
+
...o
|
|
1315
1530
|
}) => {
|
|
1316
|
-
const
|
|
1531
|
+
const c = !!(s && s[i]);
|
|
1317
1532
|
return /* @__PURE__ */ d("div", { className: `ts-form-group ${l}`, children: [
|
|
1318
1533
|
e && /* @__PURE__ */ d("label", { className: "ts-form-label", children: [
|
|
1319
1534
|
e,
|
|
@@ -1324,91 +1539,61 @@ const rt = je(nt), ve = 5, st = ({
|
|
|
1324
1539
|
{
|
|
1325
1540
|
name: i,
|
|
1326
1541
|
type: "text",
|
|
1327
|
-
...
|
|
1542
|
+
...o,
|
|
1328
1543
|
...n ? n(i, {
|
|
1329
|
-
...
|
|
1544
|
+
...r
|
|
1330
1545
|
}) : {},
|
|
1331
|
-
className: `ts-input ${
|
|
1332
|
-
"aria-invalid":
|
|
1546
|
+
className: `ts-input ${c ? "ts-input-error" : ""}`,
|
|
1547
|
+
"aria-invalid": c
|
|
1333
1548
|
}
|
|
1334
1549
|
),
|
|
1335
|
-
|
|
1550
|
+
c && /* @__PURE__ */ t("div", { className: "ts-error-text", children: s?.[i]?.message })
|
|
1336
1551
|
] });
|
|
1337
1552
|
};
|
|
1338
|
-
function
|
|
1339
|
-
return e.sort((n, s) => n.name.localeCompare(s.name));
|
|
1340
|
-
}
|
|
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)
|
|
1350
|
-
), i++;
|
|
1351
|
-
}
|
|
1352
|
-
return s;
|
|
1353
|
-
}
|
|
1354
|
-
function Ne(e, n) {
|
|
1355
|
-
const a = ht(e).find((i) => i.level === n);
|
|
1356
|
-
return a ? a.data : [];
|
|
1357
|
-
}
|
|
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
|
|
1365
|
-
)
|
|
1366
|
-
});
|
|
1367
|
-
};
|
|
1368
|
-
function gt(e) {
|
|
1553
|
+
function St(e) {
|
|
1369
1554
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
1370
1555
|
}
|
|
1371
|
-
var
|
|
1556
|
+
var Ee = { exports: {} };
|
|
1372
1557
|
/*!
|
|
1373
1558
|
Copyright (c) 2018 Jed Watson.
|
|
1374
1559
|
Licensed under the MIT License (MIT), see
|
|
1375
1560
|
http://jedwatson.github.io/classnames
|
|
1376
1561
|
*/
|
|
1377
|
-
var
|
|
1378
|
-
function
|
|
1379
|
-
return
|
|
1562
|
+
var _e;
|
|
1563
|
+
function Lt() {
|
|
1564
|
+
return _e || (_e = 1, function(e) {
|
|
1380
1565
|
(function() {
|
|
1381
1566
|
var n = {}.hasOwnProperty;
|
|
1382
|
-
function
|
|
1383
|
-
for (var
|
|
1384
|
-
var
|
|
1385
|
-
|
|
1567
|
+
function r() {
|
|
1568
|
+
for (var s = "", l = 0; l < arguments.length; l++) {
|
|
1569
|
+
var o = arguments[l];
|
|
1570
|
+
o && (s = i(s, a(o)));
|
|
1386
1571
|
}
|
|
1387
|
-
return
|
|
1572
|
+
return s;
|
|
1388
1573
|
}
|
|
1389
|
-
function a(
|
|
1390
|
-
if (typeof
|
|
1391
|
-
return
|
|
1392
|
-
if (typeof
|
|
1574
|
+
function a(s) {
|
|
1575
|
+
if (typeof s == "string" || typeof s == "number")
|
|
1576
|
+
return s;
|
|
1577
|
+
if (typeof s != "object")
|
|
1393
1578
|
return "";
|
|
1394
|
-
if (Array.isArray(
|
|
1395
|
-
return
|
|
1396
|
-
if (
|
|
1397
|
-
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();
|
|
1398
1583
|
var l = "";
|
|
1399
|
-
for (var
|
|
1400
|
-
n.call(
|
|
1584
|
+
for (var o in s)
|
|
1585
|
+
n.call(s, o) && s[o] && (l = i(l, o));
|
|
1401
1586
|
return l;
|
|
1402
1587
|
}
|
|
1403
|
-
function i(
|
|
1404
|
-
return l ?
|
|
1588
|
+
function i(s, l) {
|
|
1589
|
+
return l ? s ? s + " " + l : s + l : s;
|
|
1405
1590
|
}
|
|
1406
|
-
e.exports ? (
|
|
1591
|
+
e.exports ? (r.default = r, e.exports = r) : window.classNames = r;
|
|
1407
1592
|
})();
|
|
1408
|
-
}(
|
|
1593
|
+
}(Ee)), Ee.exports;
|
|
1409
1594
|
}
|
|
1410
|
-
var
|
|
1411
|
-
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(
|
|
1412
1597
|
"hr",
|
|
1413
1598
|
{
|
|
1414
1599
|
style: {
|
|
@@ -1419,36 +1604,36 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1419
1604
|
}
|
|
1420
1605
|
}
|
|
1421
1606
|
) }) : e.data.icon ? /* @__PURE__ */ d("div", { className: "d-flex align-items-center", children: [
|
|
1422
|
-
/* @__PURE__ */ t(
|
|
1607
|
+
/* @__PURE__ */ t(Ae.Option, { ...e }),
|
|
1423
1608
|
/* @__PURE__ */ t("span", { className: "px-1 template-studio-dropdown-postfix-icon", children: e.data.icon })
|
|
1424
|
-
] }) : /* @__PURE__ */ t(
|
|
1609
|
+
] }) : /* @__PURE__ */ t(Ae.Option, { ...e }), It = ({
|
|
1425
1610
|
name: e = "",
|
|
1426
1611
|
control: n,
|
|
1427
|
-
options:
|
|
1612
|
+
options: r,
|
|
1428
1613
|
multiple: a = !1,
|
|
1429
1614
|
placeholder: i,
|
|
1430
|
-
validation:
|
|
1615
|
+
validation: s,
|
|
1431
1616
|
labelKey: l = "name",
|
|
1432
|
-
disabled:
|
|
1433
|
-
isInvalid:
|
|
1434
|
-
value:
|
|
1435
|
-
onChange:
|
|
1436
|
-
uncontrolled:
|
|
1437
|
-
menuPlacement:
|
|
1438
|
-
closeOnSelect:
|
|
1617
|
+
disabled: o,
|
|
1618
|
+
isInvalid: c,
|
|
1619
|
+
value: v,
|
|
1620
|
+
onChange: E,
|
|
1621
|
+
uncontrolled: I,
|
|
1622
|
+
menuPlacement: b = "auto",
|
|
1623
|
+
closeOnSelect: x = !0
|
|
1439
1624
|
}) => {
|
|
1440
|
-
const
|
|
1441
|
-
control: (
|
|
1442
|
-
...
|
|
1625
|
+
const u = {
|
|
1626
|
+
control: (p) => ({
|
|
1627
|
+
...p,
|
|
1443
1628
|
minHeight: "33px",
|
|
1444
1629
|
// state.isFocused can display different borderColor if you need it
|
|
1445
|
-
borderColor:
|
|
1446
|
-
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",
|
|
1447
1632
|
backgroundRepeat: "no-repeat",
|
|
1448
1633
|
backgroundPosition: "right calc(0.375em + 0.225rem) center",
|
|
1449
1634
|
backgroundSize: "calc(0.75em + 0.45rem) calc(0.75em + 0.45rem)",
|
|
1450
1635
|
"&:hover": {
|
|
1451
|
-
borderColor:
|
|
1636
|
+
borderColor: c ? "var(--bs-form-invalid-border-color)" : "var(--ct-input-border-color)"
|
|
1452
1637
|
},
|
|
1453
1638
|
"& .react-select__single-value": {
|
|
1454
1639
|
color: "var(--ct-input-color) !important"
|
|
@@ -1460,416 +1645,342 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1460
1645
|
display: "none"
|
|
1461
1646
|
}
|
|
1462
1647
|
}),
|
|
1463
|
-
menu: (
|
|
1464
|
-
...
|
|
1648
|
+
menu: (p) => ({
|
|
1649
|
+
...p,
|
|
1465
1650
|
marginTop: 0,
|
|
1466
1651
|
width: "max-content",
|
|
1467
1652
|
minWidth: "100%"
|
|
1468
1653
|
}),
|
|
1469
|
-
menuPortal: (
|
|
1470
|
-
...
|
|
1654
|
+
menuPortal: (p) => ({
|
|
1655
|
+
...p,
|
|
1471
1656
|
zIndex: 1e4
|
|
1472
1657
|
}),
|
|
1473
|
-
multiValueRemove: (
|
|
1474
|
-
...
|
|
1475
|
-
display:
|
|
1658
|
+
multiValueRemove: (p) => ({
|
|
1659
|
+
...p,
|
|
1660
|
+
display: o ? "none" : "block"
|
|
1476
1661
|
})
|
|
1477
1662
|
};
|
|
1478
|
-
return
|
|
1479
|
-
|
|
1663
|
+
return I ? /* @__PURE__ */ t(
|
|
1664
|
+
$e,
|
|
1480
1665
|
{
|
|
1481
|
-
components: { Option:
|
|
1482
|
-
isOptionDisabled: (
|
|
1483
|
-
className:
|
|
1484
|
-
"is-invalid":
|
|
1666
|
+
components: { Option: Be },
|
|
1667
|
+
isOptionDisabled: (p) => !!p.isSeparator,
|
|
1668
|
+
className: Re({
|
|
1669
|
+
"is-invalid": c
|
|
1485
1670
|
}),
|
|
1486
|
-
styles:
|
|
1671
|
+
styles: u,
|
|
1487
1672
|
classNamePrefix: "react-select",
|
|
1488
1673
|
isMulti: a,
|
|
1489
|
-
options:
|
|
1490
|
-
onChange:
|
|
1674
|
+
options: r,
|
|
1675
|
+
onChange: E,
|
|
1491
1676
|
placeholder: i,
|
|
1492
1677
|
menuPortalTarget: document.body,
|
|
1493
|
-
value:
|
|
1494
|
-
getOptionLabel: typeof l == "string" ? (
|
|
1495
|
-
getOptionValue: (
|
|
1496
|
-
isDisabled:
|
|
1497
|
-
menuPlacement:
|
|
1498
|
-
closeMenuOnSelect:
|
|
1678
|
+
value: v,
|
|
1679
|
+
getOptionLabel: typeof l == "string" ? (p) => p[l] : l,
|
|
1680
|
+
getOptionValue: (p) => p.id,
|
|
1681
|
+
isDisabled: o,
|
|
1682
|
+
menuPlacement: b,
|
|
1683
|
+
closeMenuOnSelect: x
|
|
1499
1684
|
}
|
|
1500
1685
|
) : /* @__PURE__ */ t(
|
|
1501
|
-
|
|
1686
|
+
Xe,
|
|
1502
1687
|
{
|
|
1503
1688
|
control: n,
|
|
1504
1689
|
name: e,
|
|
1505
|
-
rules:
|
|
1506
|
-
render: ({ field: { onChange:
|
|
1507
|
-
|
|
1690
|
+
rules: s,
|
|
1691
|
+
render: ({ field: { onChange: p, value: w, onBlur: h } }) => /* @__PURE__ */ t(
|
|
1692
|
+
$e,
|
|
1508
1693
|
{
|
|
1509
|
-
components: { Option:
|
|
1510
|
-
isOptionDisabled: (
|
|
1511
|
-
className:
|
|
1512
|
-
"is-invalid":
|
|
1694
|
+
components: { Option: Be },
|
|
1695
|
+
isOptionDisabled: (y) => !!y.isSeparator,
|
|
1696
|
+
className: Re({
|
|
1697
|
+
"is-invalid": c
|
|
1513
1698
|
}),
|
|
1514
|
-
styles:
|
|
1699
|
+
styles: u,
|
|
1515
1700
|
classNamePrefix: "react-select",
|
|
1516
1701
|
isMulti: a,
|
|
1517
|
-
options:
|
|
1518
|
-
onBlur:
|
|
1519
|
-
onChange:
|
|
1702
|
+
options: r,
|
|
1703
|
+
onBlur: h,
|
|
1704
|
+
onChange: p,
|
|
1520
1705
|
placeholder: i,
|
|
1521
1706
|
menuPortalTarget: document.body,
|
|
1522
|
-
value:
|
|
1523
|
-
getOptionLabel: typeof l == "string" ? (
|
|
1524
|
-
getOptionValue: (
|
|
1525
|
-
isDisabled:
|
|
1526
|
-
menuPlacement:
|
|
1527
|
-
closeMenuOnSelect:
|
|
1707
|
+
value: w,
|
|
1708
|
+
getOptionLabel: typeof l == "string" ? (y) => y[l] : l,
|
|
1709
|
+
getOptionValue: (y) => y.id,
|
|
1710
|
+
isDisabled: o,
|
|
1711
|
+
menuPlacement: b,
|
|
1712
|
+
closeMenuOnSelect: x
|
|
1528
1713
|
},
|
|
1529
|
-
|
|
1714
|
+
w ? w.id || w.value || JSON.stringify(w) : "reset"
|
|
1530
1715
|
)
|
|
1531
1716
|
}
|
|
1532
1717
|
);
|
|
1533
|
-
},
|
|
1718
|
+
}, fe = ({
|
|
1534
1719
|
label: e,
|
|
1535
1720
|
name: n,
|
|
1536
|
-
validation:
|
|
1721
|
+
validation: r,
|
|
1537
1722
|
control: a,
|
|
1538
1723
|
error: i,
|
|
1539
|
-
options:
|
|
1724
|
+
options: s = [],
|
|
1540
1725
|
required: l = !1,
|
|
1541
|
-
disabled:
|
|
1542
|
-
className:
|
|
1726
|
+
disabled: o = !1,
|
|
1727
|
+
className: c = ""
|
|
1543
1728
|
}) => {
|
|
1544
|
-
const
|
|
1545
|
-
return /* @__PURE__ */ d("div", { className: `ts-form-group ${
|
|
1729
|
+
const v = !!(i && i[n]);
|
|
1730
|
+
return /* @__PURE__ */ d("div", { className: `ts-form-group ${c}`, children: [
|
|
1546
1731
|
e && /* @__PURE__ */ d("label", { className: "ts-form-label", children: [
|
|
1547
1732
|
e,
|
|
1548
1733
|
l && /* @__PURE__ */ t("span", { className: "ts-required", children: "*" })
|
|
1549
1734
|
] }),
|
|
1550
1735
|
/* @__PURE__ */ t(
|
|
1551
|
-
|
|
1736
|
+
It,
|
|
1552
1737
|
{
|
|
1553
1738
|
name: n,
|
|
1554
1739
|
control: a,
|
|
1555
|
-
options:
|
|
1556
|
-
validation:
|
|
1557
|
-
disabled:
|
|
1558
|
-
isInvalid:
|
|
1740
|
+
options: s,
|
|
1741
|
+
validation: r,
|
|
1742
|
+
disabled: o,
|
|
1743
|
+
isInvalid: v
|
|
1559
1744
|
}
|
|
1560
1745
|
),
|
|
1561
|
-
|
|
1746
|
+
v && /* @__PURE__ */ t("div", { className: "ts-error-text", children: i?.[n]?.message })
|
|
1562
1747
|
] });
|
|
1563
|
-
},
|
|
1564
|
-
const e =
|
|
1565
|
-
|
|
1566
|
-
const { enerexIdentifier: n, projectId:
|
|
1567
|
-
return
|
|
1748
|
+
}, Dt = () => {
|
|
1749
|
+
const e = Y();
|
|
1750
|
+
Ye();
|
|
1751
|
+
const { enerexIdentifier: n, projectId: r } = V();
|
|
1752
|
+
return ce({
|
|
1568
1753
|
mutationKey: ["saveTemplate"],
|
|
1569
|
-
mutationFn: async (i) => (i.enerexIdentifier = n ?? "", i.projectId =
|
|
1754
|
+
mutationFn: async (i) => (i.enerexIdentifier = n ?? "", i.projectId = r ?? "", await e.post(
|
|
1570
1755
|
`${Q.SaveTemplate}`,
|
|
1571
1756
|
i
|
|
1572
1757
|
))
|
|
1573
1758
|
});
|
|
1574
|
-
},
|
|
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 = {
|
|
1759
|
+
}, Pt = {
|
|
1631
1760
|
id: "",
|
|
1632
1761
|
name: "New (Blank)"
|
|
1633
|
-
},
|
|
1762
|
+
}, $t = ({
|
|
1634
1763
|
onReset: e,
|
|
1635
1764
|
editorInitialized: n,
|
|
1636
|
-
mode:
|
|
1765
|
+
mode: r,
|
|
1637
1766
|
templateTypes: a,
|
|
1638
1767
|
templateList: i,
|
|
1639
|
-
template:
|
|
1768
|
+
template: s,
|
|
1640
1769
|
onRefresh: l,
|
|
1641
|
-
closeEditorModal:
|
|
1770
|
+
closeEditorModal: o
|
|
1642
1771
|
}) => {
|
|
1643
|
-
const { defaultSelector:
|
|
1644
|
-
register:
|
|
1645
|
-
handleSubmit:
|
|
1646
|
-
clearErrors:
|
|
1647
|
-
setValue:
|
|
1648
|
-
control:
|
|
1649
|
-
watch:
|
|
1650
|
-
reset:
|
|
1651
|
-
setError:
|
|
1652
|
-
formState: { errors:
|
|
1653
|
-
} =
|
|
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: w,
|
|
1777
|
+
control: h,
|
|
1778
|
+
watch: y,
|
|
1779
|
+
reset: g,
|
|
1780
|
+
setError: R,
|
|
1781
|
+
formState: { errors: B }
|
|
1782
|
+
} = Je({
|
|
1654
1783
|
defaultValues: {
|
|
1655
1784
|
templateName: "",
|
|
1656
1785
|
subTemplateType: void 0,
|
|
1657
1786
|
subTemplateType2: void 0,
|
|
1658
1787
|
subject: "",
|
|
1659
1788
|
templateType: void 0,
|
|
1660
|
-
template:
|
|
1789
|
+
template: Pt
|
|
1661
1790
|
},
|
|
1662
1791
|
mode: "onChange"
|
|
1663
|
-
}), [
|
|
1664
|
-
|
|
1792
|
+
}), [_, A] = C([]), [S, D] = C(), { mutateAsync: M, isPending: T } = 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 || T || b || !n;
|
|
1793
|
+
L(() => {
|
|
1665
1794
|
if (a) {
|
|
1666
|
-
let
|
|
1667
|
-
|
|
1795
|
+
let f = a.filter((F) => F.id != null), k = Ne(f, 0);
|
|
1796
|
+
U(Te(k));
|
|
1668
1797
|
}
|
|
1669
|
-
}, [a]),
|
|
1670
|
-
|
|
1671
|
-
}, [
|
|
1672
|
-
if (
|
|
1673
|
-
const
|
|
1674
|
-
if (!
|
|
1675
|
-
const
|
|
1676
|
-
|
|
1677
|
-
templateType: X ?
|
|
1678
|
-
subTemplateType:
|
|
1679
|
-
subTemplateType2:
|
|
1680
|
-
template:
|
|
1681
|
-
templateName:
|
|
1682
|
-
subject:
|
|
1683
|
-
}),
|
|
1684
|
-
}, [
|
|
1685
|
-
const
|
|
1686
|
-
id: String(
|
|
1687
|
-
name:
|
|
1688
|
-
key:
|
|
1798
|
+
}, [a]), L(() => {
|
|
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);
|
|
1803
|
+
if (!f) return;
|
|
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,
|
|
1809
|
+
template: f,
|
|
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) => ({
|
|
1815
|
+
id: String(f.id),
|
|
1816
|
+
name: f.name,
|
|
1817
|
+
key: f.key
|
|
1689
1818
|
});
|
|
1690
|
-
|
|
1691
|
-
i?.sort((
|
|
1692
|
-
}, [i]),
|
|
1693
|
-
if (!
|
|
1694
|
-
const
|
|
1695
|
-
|
|
1819
|
+
L(() => {
|
|
1820
|
+
i?.sort((f, k) => f.readonly !== k.readonly ? (f.readonly ? 0 : 1) - (k.readonly ? 0 : 1) : f.name.localeCompare(k.name)), A(i ?? []);
|
|
1821
|
+
}, [i]), L(() => {
|
|
1822
|
+
if (!y("templateType")) return;
|
|
1823
|
+
const f = Ne(a, 1);
|
|
1824
|
+
K(
|
|
1696
1825
|
Te(
|
|
1697
|
-
|
|
1826
|
+
f.filter((k) => `${k.parent_id}` == `${y("templateType")?.id}`)
|
|
1698
1827
|
)
|
|
1828
|
+
), w("subTemplateType", void 0), w("subTemplateType2", void 0);
|
|
1829
|
+
}, [y("templateType"), a]), L(() => {
|
|
1830
|
+
const f = y("subTemplateType");
|
|
1831
|
+
if (!f) return;
|
|
1832
|
+
const k = Ne(a, 2);
|
|
1833
|
+
let F = Te(
|
|
1834
|
+
k.filter((j) => `${j.parent_id}` == `${f.id}`)
|
|
1699
1835
|
);
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
if (
|
|
1703
|
-
|
|
1704
|
-
|
|
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
|
|
1836
|
+
r !== "edit" && !v && (F = F.filter((j) => j.key !== 2)), re(F), w("subTemplateType2", void 0);
|
|
1837
|
+
}, [y("subTemplateType"), a, r]), L(() => {
|
|
1838
|
+
if (c && c.type1) {
|
|
1839
|
+
const f = ne?.find(
|
|
1840
|
+
(k) => `${k.id}` === c.type1
|
|
1712
1841
|
);
|
|
1713
|
-
|
|
1842
|
+
w("templateType", f);
|
|
1714
1843
|
}
|
|
1715
|
-
}, [a,
|
|
1716
|
-
if (
|
|
1717
|
-
const
|
|
1718
|
-
(
|
|
1844
|
+
}, [a, ne]), L(() => {
|
|
1845
|
+
if (c && c.type2) {
|
|
1846
|
+
const f = W?.find(
|
|
1847
|
+
(k) => `${k.id}` === c.type2
|
|
1719
1848
|
);
|
|
1720
|
-
|
|
1849
|
+
w("subTemplateType", f);
|
|
1721
1850
|
}
|
|
1722
|
-
}, [a,
|
|
1723
|
-
if (
|
|
1724
|
-
const
|
|
1725
|
-
(
|
|
1851
|
+
}, [a, W]), L(() => {
|
|
1852
|
+
if (c && c.type3) {
|
|
1853
|
+
const f = O?.find(
|
|
1854
|
+
(k) => `${k.id}` === c.type3
|
|
1726
1855
|
);
|
|
1727
|
-
|
|
1856
|
+
w("subTemplateType2", f);
|
|
1728
1857
|
}
|
|
1729
|
-
}, [a,
|
|
1730
|
-
const
|
|
1858
|
+
}, [a, O]);
|
|
1859
|
+
const me = (f) => {
|
|
1731
1860
|
window.StripoEditorApi.actionsApi.getTemplateData(
|
|
1732
|
-
async (
|
|
1861
|
+
async (k) => {
|
|
1733
1862
|
try {
|
|
1734
|
-
let
|
|
1735
|
-
const X =
|
|
1736
|
-
|
|
1737
|
-
const U = k.find(
|
|
1738
|
-
($) => $.name === u.templateName.trim()
|
|
1863
|
+
let F = f.template.id, j = "";
|
|
1864
|
+
const X = f.templateName.trim(), q = _.find(
|
|
1865
|
+
(N) => N.name === f.templateName.trim()
|
|
1739
1866
|
);
|
|
1740
|
-
if (
|
|
1741
|
-
|
|
1867
|
+
if (q && q?.id !== f.template.id) {
|
|
1868
|
+
R("templateName", {
|
|
1742
1869
|
type: "validate",
|
|
1743
1870
|
message: "Template name already exists. Please choose a different name."
|
|
1744
1871
|
});
|
|
1745
1872
|
return;
|
|
1746
1873
|
}
|
|
1747
|
-
let
|
|
1748
|
-
|
|
1749
|
-
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 = {
|
|
1750
1877
|
enerexIdentifier: "",
|
|
1751
1878
|
projectId: "",
|
|
1752
|
-
templateId:
|
|
1753
|
-
templateType:
|
|
1879
|
+
templateId: F,
|
|
1880
|
+
templateType: oe,
|
|
1754
1881
|
name: X,
|
|
1755
|
-
html:
|
|
1756
|
-
css:
|
|
1757
|
-
subject:
|
|
1758
|
-
parent_id:
|
|
1759
|
-
updatedBy:
|
|
1882
|
+
html: k.html,
|
|
1883
|
+
css: k.css,
|
|
1884
|
+
subject: f.templateType.id === "2" ? f?.subject ?? "" : "",
|
|
1885
|
+
parent_id: j,
|
|
1886
|
+
updatedBy: E ?? ""
|
|
1760
1887
|
};
|
|
1761
|
-
if (!await
|
|
1762
|
-
|
|
1888
|
+
if (!await M(Ie)) {
|
|
1889
|
+
se(
|
|
1763
1890
|
"Failed to save template. Please try again.",
|
|
1764
1891
|
"error"
|
|
1765
1892
|
);
|
|
1766
1893
|
return;
|
|
1767
1894
|
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1895
|
+
se(
|
|
1896
|
+
H ? `Template "${X}" updated successfully.` : `Template "${X}" created successfully.`,
|
|
1770
1897
|
"success"
|
|
1771
|
-
),
|
|
1772
|
-
} catch (
|
|
1773
|
-
console.error(
|
|
1898
|
+
), p(), l(), o();
|
|
1899
|
+
} catch (F) {
|
|
1900
|
+
console.error(F), se(
|
|
1774
1901
|
"Something went wrong while saving the template.",
|
|
1775
1902
|
"error"
|
|
1776
1903
|
);
|
|
1777
1904
|
}
|
|
1778
1905
|
}
|
|
1779
1906
|
);
|
|
1780
|
-
},
|
|
1781
|
-
|
|
1782
|
-
|
|
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
|
-
);
|
|
1795
|
-
}
|
|
1796
|
-
}, le = m("templateType"), ge = m("subTemplateType");
|
|
1797
|
-
return /* @__PURE__ */ d(pe, { children: [
|
|
1798
|
-
ie && /* @__PURE__ */ t(ae, { overlay: !0 }),
|
|
1907
|
+
}, pe = y("templateType"), be = y("subTemplateType");
|
|
1908
|
+
return /* @__PURE__ */ d(ye, { children: [
|
|
1909
|
+
ue && /* @__PURE__ */ t(ie, { overlay: !0 }),
|
|
1799
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: [
|
|
1800
1911
|
/* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1801
|
-
|
|
1912
|
+
fe,
|
|
1802
1913
|
{
|
|
1803
1914
|
label: "Category",
|
|
1804
|
-
control:
|
|
1805
|
-
error:
|
|
1806
|
-
options:
|
|
1915
|
+
control: h,
|
|
1916
|
+
error: B,
|
|
1917
|
+
options: ne,
|
|
1807
1918
|
required: !0,
|
|
1808
|
-
disabled:
|
|
1919
|
+
disabled: H || T || b || !n,
|
|
1809
1920
|
validation: {
|
|
1810
1921
|
required: {
|
|
1811
1922
|
value: !0,
|
|
1812
1923
|
message: "Select a category"
|
|
1813
1924
|
}
|
|
1814
1925
|
},
|
|
1815
|
-
...
|
|
1926
|
+
...x("templateType")
|
|
1816
1927
|
}
|
|
1817
1928
|
) }),
|
|
1818
|
-
|
|
1819
|
-
|
|
1929
|
+
W && W.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1930
|
+
fe,
|
|
1820
1931
|
{
|
|
1821
1932
|
label: "Type",
|
|
1822
|
-
control:
|
|
1823
|
-
error:
|
|
1824
|
-
options:
|
|
1933
|
+
control: h,
|
|
1934
|
+
error: B,
|
|
1935
|
+
options: W,
|
|
1825
1936
|
required: !0,
|
|
1826
|
-
disabled:
|
|
1937
|
+
disabled: H || T || b || !n,
|
|
1827
1938
|
validation: {
|
|
1828
1939
|
required: {
|
|
1829
1940
|
value: !0,
|
|
1830
1941
|
message: "Select a type"
|
|
1831
1942
|
}
|
|
1832
1943
|
},
|
|
1833
|
-
...
|
|
1944
|
+
...x("subTemplateType")
|
|
1834
1945
|
}
|
|
1835
1946
|
) }),
|
|
1836
|
-
|
|
1837
|
-
|
|
1947
|
+
O && O.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1948
|
+
fe,
|
|
1838
1949
|
{
|
|
1839
1950
|
label: "Sub Type",
|
|
1840
|
-
control:
|
|
1841
|
-
error:
|
|
1842
|
-
options:
|
|
1951
|
+
control: h,
|
|
1952
|
+
error: B,
|
|
1953
|
+
options: O,
|
|
1843
1954
|
required: !0,
|
|
1844
|
-
disabled:
|
|
1955
|
+
disabled: H || T || b || !n,
|
|
1845
1956
|
validation: {
|
|
1846
1957
|
required: {
|
|
1847
1958
|
value: !0,
|
|
1848
1959
|
message: "Select a subtype"
|
|
1849
1960
|
}
|
|
1850
1961
|
},
|
|
1851
|
-
...
|
|
1962
|
+
...x("subTemplateType2")
|
|
1852
1963
|
}
|
|
1853
1964
|
) }),
|
|
1854
1965
|
/* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1855
|
-
|
|
1966
|
+
fe,
|
|
1856
1967
|
{
|
|
1857
1968
|
label: "Template",
|
|
1858
|
-
control:
|
|
1859
|
-
error:
|
|
1860
|
-
disabled:
|
|
1969
|
+
control: h,
|
|
1970
|
+
error: B,
|
|
1971
|
+
disabled: H || !H || T || b || !n,
|
|
1861
1972
|
options: [],
|
|
1862
1973
|
required: !1,
|
|
1863
|
-
...
|
|
1974
|
+
...x("template")
|
|
1864
1975
|
}
|
|
1865
1976
|
) }),
|
|
1866
1977
|
/* @__PURE__ */ d("div", { className: "ts-col ts-template-name-col", children: [
|
|
1867
1978
|
/* @__PURE__ */ t(
|
|
1868
|
-
|
|
1979
|
+
Me,
|
|
1869
1980
|
{
|
|
1870
1981
|
label: "Name",
|
|
1871
|
-
register:
|
|
1872
|
-
error:
|
|
1982
|
+
register: x,
|
|
1983
|
+
error: B,
|
|
1873
1984
|
required: !0,
|
|
1874
1985
|
name: "templateName",
|
|
1875
1986
|
validation: {
|
|
@@ -1880,86 +1991,77 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1880
1991
|
}
|
|
1881
1992
|
}
|
|
1882
1993
|
),
|
|
1883
|
-
|
|
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
|
-
)
|
|
1994
|
+
be?.key?.toString() === "9" && H && !v && S?.is_favourite && /* @__PURE__ */ t("span", { className: "ts-favourite-icon", children: /* @__PURE__ */ t(Le, { variant: "filled" }) })
|
|
1893
1995
|
] }),
|
|
1894
|
-
|
|
1895
|
-
|
|
1996
|
+
pe?.key?.toString() === "12" && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
|
|
1997
|
+
Me,
|
|
1896
1998
|
{
|
|
1897
1999
|
label: "Subject",
|
|
1898
|
-
register:
|
|
1899
|
-
error:
|
|
2000
|
+
register: x,
|
|
2001
|
+
error: B,
|
|
1900
2002
|
required: !1,
|
|
1901
2003
|
name: "subject"
|
|
1902
2004
|
}
|
|
1903
2005
|
) }),
|
|
1904
2006
|
/* @__PURE__ */ d("div", { className: "ts-col ts-actions btn-padding", children: [
|
|
1905
|
-
!
|
|
2007
|
+
!H && /* @__PURE__ */ t(
|
|
1906
2008
|
"button",
|
|
1907
2009
|
{
|
|
1908
2010
|
type: "button",
|
|
1909
2011
|
className: "ts-btn ts-btn-primary",
|
|
1910
|
-
disabled:
|
|
2012
|
+
disabled: T || b || !n,
|
|
1911
2013
|
onClick: () => {
|
|
1912
|
-
|
|
2014
|
+
D(void 0), g(), K([]), re([]), e();
|
|
1913
2015
|
},
|
|
1914
|
-
children:
|
|
2016
|
+
children: T || b ? /* @__PURE__ */ t(ie, { size: "sm" }) : "Clear"
|
|
1915
2017
|
}
|
|
1916
2018
|
),
|
|
1917
|
-
|
|
2019
|
+
/* @__PURE__ */ t(
|
|
1918
2020
|
"button",
|
|
1919
2021
|
{
|
|
1920
2022
|
type: "button",
|
|
1921
2023
|
className: "ts-btn ts-btn-primary",
|
|
1922
|
-
disabled:
|
|
1923
|
-
onClick:
|
|
1924
|
-
children:
|
|
2024
|
+
disabled: T || b || !n,
|
|
2025
|
+
onClick: u(me),
|
|
2026
|
+
children: T || b ? (
|
|
1925
2027
|
// <span className="ts-spinner" />
|
|
1926
|
-
/* @__PURE__ */ t(
|
|
2028
|
+
/* @__PURE__ */ t(ie, { size: "sm" })
|
|
1927
2029
|
) : "Save"
|
|
1928
2030
|
}
|
|
1929
2031
|
)
|
|
1930
2032
|
] })
|
|
1931
2033
|
] }) }) }) }) })
|
|
1932
2034
|
] });
|
|
1933
|
-
},
|
|
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 = ({
|
|
1934
2036
|
show: e,
|
|
1935
2037
|
mode: n,
|
|
1936
|
-
template:
|
|
2038
|
+
template: r,
|
|
1937
2039
|
templateTypes: a,
|
|
1938
2040
|
templateList: i,
|
|
1939
|
-
editorInitialized:
|
|
2041
|
+
editorInitialized: s,
|
|
1940
2042
|
previewHtml: l,
|
|
1941
|
-
onEditorInitialized:
|
|
1942
|
-
onClose:
|
|
1943
|
-
onRefresh:
|
|
2043
|
+
onEditorInitialized: o,
|
|
2044
|
+
onClose: c,
|
|
2045
|
+
onRefresh: v
|
|
1944
2046
|
}) => {
|
|
1945
|
-
const
|
|
1946
|
-
|
|
1947
|
-
e &&
|
|
1948
|
-
|
|
1949
|
-
|
|
2047
|
+
const E = te(null), [I, b] = C(!1);
|
|
2048
|
+
L(() => {
|
|
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 ?? "",
|
|
1950
2052
|
""
|
|
1951
2053
|
));
|
|
1952
|
-
}, [e,
|
|
1953
|
-
e ||
|
|
2054
|
+
}, [e, s, n, r]), L(() => {
|
|
2055
|
+
e || b(!1);
|
|
1954
2056
|
}, [e]);
|
|
1955
|
-
const
|
|
1956
|
-
window.StripoEditorApi.actionsApi.updateHtmlAndCss(
|
|
2057
|
+
const x = () => {
|
|
2058
|
+
window.StripoEditorApi.actionsApi.updateHtmlAndCss(he, "", "");
|
|
1957
2059
|
};
|
|
1958
2060
|
return e ? /* @__PURE__ */ t("div", { className: "ts-editor-modal-overlay", children: /* @__PURE__ */ d(
|
|
1959
2061
|
"div",
|
|
1960
2062
|
{
|
|
1961
|
-
className: `ts-editor-modal ${
|
|
1962
|
-
ref:
|
|
2063
|
+
className: `ts-editor-modal ${I ? "ts-editor-modal--fullscreen" : ""}`,
|
|
2064
|
+
ref: E,
|
|
1963
2065
|
children: [
|
|
1964
2066
|
/* @__PURE__ */ d("div", { className: "ts-editor-modal-header", children: [
|
|
1965
2067
|
/* @__PURE__ */ d("h3", { className: "ts-modal-title", children: [
|
|
@@ -1972,16 +2074,16 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1972
2074
|
"button",
|
|
1973
2075
|
{
|
|
1974
2076
|
className: "ts-editor-fullscreen-btn",
|
|
1975
|
-
onClick: () =>
|
|
2077
|
+
onClick: () => b((u) => !u),
|
|
1976
2078
|
"aria-label": "Toggle fullscreen",
|
|
1977
|
-
children:
|
|
2079
|
+
children: I ? /* @__PURE__ */ t(At, { style: { display: "block" } }) : /* @__PURE__ */ t(Mt, { style: { display: "block" } })
|
|
1978
2080
|
}
|
|
1979
2081
|
),
|
|
1980
2082
|
/* @__PURE__ */ t(
|
|
1981
2083
|
"button",
|
|
1982
2084
|
{
|
|
1983
2085
|
className: "ts-editor-close-btn",
|
|
1984
|
-
onClick:
|
|
2086
|
+
onClick: c,
|
|
1985
2087
|
"aria-label": "Close editor",
|
|
1986
2088
|
children: "✕"
|
|
1987
2089
|
}
|
|
@@ -1990,16 +2092,16 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
1990
2092
|
] }),
|
|
1991
2093
|
/* @__PURE__ */ d("div", { className: "ts-editor-modal-body", children: [
|
|
1992
2094
|
n !== "preview" && /* @__PURE__ */ t(
|
|
1993
|
-
|
|
2095
|
+
$t,
|
|
1994
2096
|
{
|
|
1995
2097
|
mode: n,
|
|
1996
|
-
template:
|
|
2098
|
+
template: r,
|
|
1997
2099
|
templateTypes: a,
|
|
1998
2100
|
templateList: i,
|
|
1999
|
-
editorInitialized:
|
|
2000
|
-
onReset:
|
|
2001
|
-
onRefresh:
|
|
2002
|
-
closeEditorModal:
|
|
2101
|
+
editorInitialized: s,
|
|
2102
|
+
onReset: x,
|
|
2103
|
+
onRefresh: v,
|
|
2104
|
+
closeEditorModal: c
|
|
2003
2105
|
}
|
|
2004
2106
|
),
|
|
2005
2107
|
n === "preview" ? /* @__PURE__ */ t("div", { className: "ts-template-preview", children: /* @__PURE__ */ t(
|
|
@@ -2010,9 +2112,9 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
2010
2112
|
srcDoc: l ?? ""
|
|
2011
2113
|
}
|
|
2012
2114
|
) }) : /* @__PURE__ */ t(
|
|
2013
|
-
|
|
2115
|
+
Et,
|
|
2014
2116
|
{
|
|
2015
|
-
onEditorInitialized:
|
|
2117
|
+
onEditorInitialized: o,
|
|
2016
2118
|
loading: !1,
|
|
2017
2119
|
className: "editor-container"
|
|
2018
2120
|
}
|
|
@@ -2021,61 +2123,61 @@ const Ae = /* @__PURE__ */ gt(vt), _e = (e) => e.data.isSeparator ? /* @__PURE__
|
|
|
2021
2123
|
]
|
|
2022
2124
|
}
|
|
2023
2125
|
) }) : null;
|
|
2024
|
-
},
|
|
2126
|
+
}, Rt = () => {
|
|
2025
2127
|
const {
|
|
2026
2128
|
data: e,
|
|
2027
2129
|
isLoading: n,
|
|
2028
|
-
isFetching:
|
|
2130
|
+
isFetching: r,
|
|
2029
2131
|
refetch: a
|
|
2030
|
-
} =
|
|
2132
|
+
} = at(), {
|
|
2031
2133
|
data: i,
|
|
2032
|
-
isLoading:
|
|
2134
|
+
isLoading: s,
|
|
2033
2135
|
isFetching: l
|
|
2034
|
-
} =
|
|
2035
|
-
|
|
2036
|
-
},
|
|
2037
|
-
const
|
|
2038
|
-
|
|
2039
|
-
},
|
|
2136
|
+
} = it(), { mutateAsync: o, isPending: c } = lt(), [v, E] = C(!1), [I, b] = C("add"), [x, u] = C(!1), [p, w] = 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) => {
|
|
2040
2142
|
if (!e || e.length === 0) return;
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2043
|
-
},
|
|
2044
|
-
|
|
2143
|
+
const D = e.find((M) => M.id === S.id);
|
|
2144
|
+
w(D?.html + "<style>" + D?.css + "</style>"), b("preview"), E(!0);
|
|
2145
|
+
}, _ = () => {
|
|
2146
|
+
E(!1), u(!1), document.getElementById("UiEditorScript")?.remove();
|
|
2045
2147
|
};
|
|
2046
|
-
return /* @__PURE__ */ d(
|
|
2047
|
-
(n ||
|
|
2148
|
+
return /* @__PURE__ */ d(ye, { children: [
|
|
2149
|
+
(n || s || r || l || c) && /* @__PURE__ */ t(ie, { overlay: !0 }),
|
|
2048
2150
|
/* @__PURE__ */ t(
|
|
2049
|
-
|
|
2151
|
+
Tt,
|
|
2050
2152
|
{
|
|
2051
2153
|
templates: e ?? [],
|
|
2052
2154
|
templateTypes: i ?? [],
|
|
2053
2155
|
onRefresh: a,
|
|
2054
|
-
onAdd:
|
|
2055
|
-
onEdit:
|
|
2056
|
-
onPreview:
|
|
2156
|
+
onAdd: g,
|
|
2157
|
+
onEdit: R,
|
|
2158
|
+
onPreview: B
|
|
2057
2159
|
}
|
|
2058
2160
|
),
|
|
2059
2161
|
/* @__PURE__ */ t(
|
|
2060
|
-
|
|
2162
|
+
_t,
|
|
2061
2163
|
{
|
|
2062
|
-
show:
|
|
2063
|
-
mode:
|
|
2064
|
-
template:
|
|
2164
|
+
show: v,
|
|
2165
|
+
mode: I,
|
|
2166
|
+
template: h,
|
|
2065
2167
|
templateTypes: i ?? [],
|
|
2066
2168
|
templateList: e ?? [],
|
|
2067
|
-
editorInitialized:
|
|
2068
|
-
onEditorInitialized:
|
|
2069
|
-
onClose:
|
|
2169
|
+
editorInitialized: x,
|
|
2170
|
+
onEditorInitialized: u,
|
|
2171
|
+
onClose: _,
|
|
2070
2172
|
onSaved: () => {
|
|
2071
|
-
|
|
2173
|
+
_(), a();
|
|
2072
2174
|
},
|
|
2073
2175
|
onRefresh: a,
|
|
2074
|
-
previewHtml:
|
|
2176
|
+
previewHtml: p
|
|
2075
2177
|
}
|
|
2076
2178
|
)
|
|
2077
2179
|
] });
|
|
2078
|
-
},
|
|
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, {}) }) }) }) });
|
|
2079
2181
|
export {
|
|
2080
|
-
|
|
2182
|
+
Kt as EditorWidget
|
|
2081
2183
|
};
|