@devtable/settings-form 8.57.1 → 8.58.0

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.
@@ -1,49 +1,684 @@
1
- import { Box as v, TextInput as z, Divider as V, Group as w, NumberInput as ie, PasswordInput as F, Button as b, Modal as R, Stack as B, Alert as oe, SegmentedControl as ae, useMantineTheme as se, Tooltip as ce, Text as L, LoadingOverlay as H, Table as $, Select as le, Switch as de } from "@mantine/core";
2
- import { showNotification as _, updateNotification as S } from "@mantine/notifications";
3
- import * as O from "react";
4
- import E, { useEffect as G, forwardRef as J, useState as ee, useMemo as te } from "react";
5
- import { Recycle as ue, AlertCircle as pe, PlaylistAdd as Q, Trash as W, Edit as ge } from "tabler-icons-react";
6
- import me from "axios";
7
- import he from "crypto-js";
8
- import fe from "lodash";
9
- import { useForm as q, Controller as m } from "react-hook-form";
10
- import * as X from "../../node_modules/react/jsx-runtime.js";
11
- import { useBoolean as be, useRequest as T } from "ahooks";
12
- import we, { loader as N } from "@monaco-editor/react";
13
- import { useModals as j, closeAllModals as Se } from "@mantine/modals";
14
- function ze(t) {
1
+ import * as Z from "react";
2
+ import H, { useEffect as Te, forwardRef as ze, useState as lr, useMemo as ur } from "react";
3
+ import { Box as I, TextInput as D, Divider as Oe, Group as z, NumberInput as Wr, PasswordInput as de, Button as T, Modal as ne, Stack as Ae, Alert as Yr, SegmentedControl as Br, useMantineTheme as Kr, Tooltip as Gr, Text as ue, LoadingOverlay as xe, Table as ke, Select as Hr, Switch as Jr } from "@mantine/core";
4
+ import { showNotification as V, updateNotification as x } from "@mantine/notifications";
5
+ import { Recycle as Xr, AlertCircle as Qr, PlaylistAdd as De, Trash as je, Edit as Zr } from "tabler-icons-react";
6
+ import et from "axios";
7
+ import rt from "crypto-js";
8
+ import tt from "lodash";
9
+ import { useForm as J, Controller as R } from "react-hook-form";
10
+ import { useBoolean as nt, useRequest as G } from "ahooks";
11
+ import at, { loader as Ee } from "@monaco-editor/react";
12
+ import { useModals as fe, closeAllModals as it } from "@mantine/modals";
13
+ var te = {}, ot = {
14
+ get exports() {
15
+ return te;
16
+ },
17
+ set exports(t) {
18
+ te = t;
19
+ }
20
+ }, ee = {};
21
+ /**
22
+ * @license React
23
+ * react-jsx-runtime.production.min.js
24
+ *
25
+ * Copyright (c) Facebook, Inc. and its affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
30
+ var or;
31
+ function st() {
32
+ if (or)
33
+ return ee;
34
+ or = 1;
35
+ var t = H, n = Symbol.for("react.element"), i = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, l = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
36
+ function c(d, p, b) {
37
+ var f, h = {}, _ = null, k = null;
38
+ b !== void 0 && (_ = "" + b), p.key !== void 0 && (_ = "" + p.key), p.ref !== void 0 && (k = p.ref);
39
+ for (f in p)
40
+ o.call(p, f) && !s.hasOwnProperty(f) && (h[f] = p[f]);
41
+ if (d && d.defaultProps)
42
+ for (f in p = d.defaultProps, p)
43
+ h[f] === void 0 && (h[f] = p[f]);
44
+ return { $$typeof: n, type: d, key: _, ref: k, props: h, _owner: l.current };
45
+ }
46
+ return ee.Fragment = i, ee.jsx = c, ee.jsxs = c, ee;
47
+ }
48
+ var re = {};
49
+ /**
50
+ * @license React
51
+ * react-jsx-runtime.development.js
52
+ *
53
+ * Copyright (c) Facebook, Inc. and its affiliates.
54
+ *
55
+ * This source code is licensed under the MIT license found in the
56
+ * LICENSE file in the root directory of this source tree.
57
+ */
58
+ var sr;
59
+ function ct() {
60
+ return sr || (sr = 1, process.env.NODE_ENV !== "production" && function() {
61
+ var t = H, n = Symbol.for("react.element"), i = Symbol.for("react.portal"), o = Symbol.for("react.fragment"), l = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), c = Symbol.for("react.provider"), d = Symbol.for("react.context"), p = Symbol.for("react.forward_ref"), b = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), _ = Symbol.for("react.lazy"), k = Symbol.for("react.offscreen"), q = Symbol.iterator, he = "@@iterator";
62
+ function me(e) {
63
+ if (e === null || typeof e != "object")
64
+ return null;
65
+ var a = q && e[q] || e[he];
66
+ return typeof a == "function" ? a : null;
67
+ }
68
+ var U = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
69
+ function O(e) {
70
+ {
71
+ for (var a = arguments.length, u = new Array(a > 1 ? a - 1 : 0), g = 1; g < a; g++)
72
+ u[g - 1] = arguments[g];
73
+ dr("error", e, u);
74
+ }
75
+ }
76
+ function dr(e, a, u) {
77
+ {
78
+ var g = U.ReactDebugCurrentFrame, S = g.getStackAddendum();
79
+ S !== "" && (a += "%s", u = u.concat([S]));
80
+ var y = u.map(function(w) {
81
+ return String(w);
82
+ });
83
+ y.unshift("Warning: " + a), Function.prototype.apply.call(console[e], console, y);
84
+ }
85
+ }
86
+ var fr = !1, pr = !1, gr = !1, hr = !1, mr = !1, Fe;
87
+ Fe = Symbol.for("react.module.reference");
88
+ function vr(e) {
89
+ return !!(typeof e == "string" || typeof e == "function" || e === o || e === s || mr || e === l || e === b || e === f || hr || e === k || fr || pr || gr || typeof e == "object" && e !== null && (e.$$typeof === _ || e.$$typeof === h || e.$$typeof === c || e.$$typeof === d || e.$$typeof === p || // This needs to include all possible module reference object
90
+ // types supported by any Flight configuration anywhere since
91
+ // we don't know which Flight build this will end up being used
92
+ // with.
93
+ e.$$typeof === Fe || e.getModuleId !== void 0));
94
+ }
95
+ function br(e, a, u) {
96
+ var g = e.displayName;
97
+ if (g)
98
+ return g;
99
+ var S = a.displayName || a.name || "";
100
+ return S !== "" ? u + "(" + S + ")" : u;
101
+ }
102
+ function qe(e) {
103
+ return e.displayName || "Context";
104
+ }
105
+ function L(e) {
106
+ if (e == null)
107
+ return null;
108
+ if (typeof e.tag == "number" && O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
109
+ return e.displayName || e.name || null;
110
+ if (typeof e == "string")
111
+ return e;
112
+ switch (e) {
113
+ case o:
114
+ return "Fragment";
115
+ case i:
116
+ return "Portal";
117
+ case s:
118
+ return "Profiler";
119
+ case l:
120
+ return "StrictMode";
121
+ case b:
122
+ return "Suspense";
123
+ case f:
124
+ return "SuspenseList";
125
+ }
126
+ if (typeof e == "object")
127
+ switch (e.$$typeof) {
128
+ case d:
129
+ var a = e;
130
+ return qe(a) + ".Consumer";
131
+ case c:
132
+ var u = e;
133
+ return qe(u._context) + ".Provider";
134
+ case p:
135
+ return br(e, e.render, "ForwardRef");
136
+ case h:
137
+ var g = e.displayName || null;
138
+ return g !== null ? g : L(e.type) || "Memo";
139
+ case _: {
140
+ var S = e, y = S._payload, w = S._init;
141
+ try {
142
+ return L(w(y));
143
+ } catch {
144
+ return null;
145
+ }
146
+ }
147
+ }
148
+ return null;
149
+ }
150
+ var W = Object.assign, X = 0, Le, Me, Ne, Ue, Ve, $e, We;
151
+ function Ye() {
152
+ }
153
+ Ye.__reactDisabledLog = !0;
154
+ function wr() {
155
+ {
156
+ if (X === 0) {
157
+ Le = console.log, Me = console.info, Ne = console.warn, Ue = console.error, Ve = console.group, $e = console.groupCollapsed, We = console.groupEnd;
158
+ var e = {
159
+ configurable: !0,
160
+ enumerable: !0,
161
+ value: Ye,
162
+ writable: !0
163
+ };
164
+ Object.defineProperties(console, {
165
+ info: e,
166
+ log: e,
167
+ warn: e,
168
+ error: e,
169
+ group: e,
170
+ groupCollapsed: e,
171
+ groupEnd: e
172
+ });
173
+ }
174
+ X++;
175
+ }
176
+ }
177
+ function Sr() {
178
+ {
179
+ if (X--, X === 0) {
180
+ var e = {
181
+ configurable: !0,
182
+ enumerable: !0,
183
+ writable: !0
184
+ };
185
+ Object.defineProperties(console, {
186
+ log: W({}, e, {
187
+ value: Le
188
+ }),
189
+ info: W({}, e, {
190
+ value: Me
191
+ }),
192
+ warn: W({}, e, {
193
+ value: Ne
194
+ }),
195
+ error: W({}, e, {
196
+ value: Ue
197
+ }),
198
+ group: W({}, e, {
199
+ value: Ve
200
+ }),
201
+ groupCollapsed: W({}, e, {
202
+ value: $e
203
+ }),
204
+ groupEnd: W({}, e, {
205
+ value: We
206
+ })
207
+ });
208
+ }
209
+ X < 0 && O("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
210
+ }
211
+ }
212
+ var ve = U.ReactCurrentDispatcher, be;
213
+ function ae(e, a, u) {
214
+ {
215
+ if (be === void 0)
216
+ try {
217
+ throw Error();
218
+ } catch (S) {
219
+ var g = S.stack.trim().match(/\n( *(at )?)/);
220
+ be = g && g[1] || "";
221
+ }
222
+ return `
223
+ ` + be + e;
224
+ }
225
+ }
226
+ var we = !1, ie;
227
+ {
228
+ var _r = typeof WeakMap == "function" ? WeakMap : Map;
229
+ ie = new _r();
230
+ }
231
+ function Be(e, a) {
232
+ if (!e || we)
233
+ return "";
234
+ {
235
+ var u = ie.get(e);
236
+ if (u !== void 0)
237
+ return u;
238
+ }
239
+ var g;
240
+ we = !0;
241
+ var S = Error.prepareStackTrace;
242
+ Error.prepareStackTrace = void 0;
243
+ var y;
244
+ y = ve.current, ve.current = null, wr();
245
+ try {
246
+ if (a) {
247
+ var w = function() {
248
+ throw Error();
249
+ };
250
+ if (Object.defineProperty(w.prototype, "props", {
251
+ set: function() {
252
+ throw Error();
253
+ }
254
+ }), typeof Reflect == "object" && Reflect.construct) {
255
+ try {
256
+ Reflect.construct(w, []);
257
+ } catch (M) {
258
+ g = M;
259
+ }
260
+ Reflect.construct(e, [], w);
261
+ } else {
262
+ try {
263
+ w.call();
264
+ } catch (M) {
265
+ g = M;
266
+ }
267
+ e.call(w.prototype);
268
+ }
269
+ } else {
270
+ try {
271
+ throw Error();
272
+ } catch (M) {
273
+ g = M;
274
+ }
275
+ e();
276
+ }
277
+ } catch (M) {
278
+ if (M && g && typeof M.stack == "string") {
279
+ for (var m = M.stack.split(`
280
+ `), A = g.stack.split(`
281
+ `), P = m.length - 1, E = A.length - 1; P >= 1 && E >= 0 && m[P] !== A[E]; )
282
+ E--;
283
+ for (; P >= 1 && E >= 0; P--, E--)
284
+ if (m[P] !== A[E]) {
285
+ if (P !== 1 || E !== 1)
286
+ do
287
+ if (P--, E--, E < 0 || m[P] !== A[E]) {
288
+ var F = `
289
+ ` + m[P].replace(" at new ", " at ");
290
+ return e.displayName && F.includes("<anonymous>") && (F = F.replace("<anonymous>", e.displayName)), typeof e == "function" && ie.set(e, F), F;
291
+ }
292
+ while (P >= 1 && E >= 0);
293
+ break;
294
+ }
295
+ }
296
+ } finally {
297
+ we = !1, ve.current = y, Sr(), Error.prepareStackTrace = S;
298
+ }
299
+ var K = e ? e.displayName || e.name : "", ir = K ? ae(K) : "";
300
+ return typeof e == "function" && ie.set(e, ir), ir;
301
+ }
302
+ function yr(e, a, u) {
303
+ return Be(e, !1);
304
+ }
305
+ function Rr(e) {
306
+ var a = e.prototype;
307
+ return !!(a && a.isReactComponent);
308
+ }
309
+ function oe(e, a, u) {
310
+ if (e == null)
311
+ return "";
312
+ if (typeof e == "function")
313
+ return Be(e, Rr(e));
314
+ if (typeof e == "string")
315
+ return ae(e);
316
+ switch (e) {
317
+ case b:
318
+ return ae("Suspense");
319
+ case f:
320
+ return ae("SuspenseList");
321
+ }
322
+ if (typeof e == "object")
323
+ switch (e.$$typeof) {
324
+ case p:
325
+ return yr(e.render);
326
+ case h:
327
+ return oe(e.type, a, u);
328
+ case _: {
329
+ var g = e, S = g._payload, y = g._init;
330
+ try {
331
+ return oe(y(S), a, u);
332
+ } catch {
333
+ }
334
+ }
335
+ }
336
+ return "";
337
+ }
338
+ var se = Object.prototype.hasOwnProperty, Ke = {}, Ge = U.ReactDebugCurrentFrame;
339
+ function ce(e) {
340
+ if (e) {
341
+ var a = e._owner, u = oe(e.type, e._source, a ? a.type : null);
342
+ Ge.setExtraStackFrame(u);
343
+ } else
344
+ Ge.setExtraStackFrame(null);
345
+ }
346
+ function Pr(e, a, u, g, S) {
347
+ {
348
+ var y = Function.call.bind(se);
349
+ for (var w in e)
350
+ if (y(e, w)) {
351
+ var m = void 0;
352
+ try {
353
+ if (typeof e[w] != "function") {
354
+ var A = Error((g || "React class") + ": " + u + " type `" + w + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[w] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
355
+ throw A.name = "Invariant Violation", A;
356
+ }
357
+ m = e[w](a, w, g, u, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
358
+ } catch (P) {
359
+ m = P;
360
+ }
361
+ m && !(m instanceof Error) && (ce(S), O("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", g || "React class", u, w, typeof m), ce(null)), m instanceof Error && !(m.message in Ke) && (Ke[m.message] = !0, ce(S), O("Failed %s type: %s", u, m.message), ce(null));
362
+ }
363
+ }
364
+ }
365
+ var Er = Array.isArray;
366
+ function Se(e) {
367
+ return Er(e);
368
+ }
369
+ function Cr(e) {
370
+ {
371
+ var a = typeof Symbol == "function" && Symbol.toStringTag, u = a && e[Symbol.toStringTag] || e.constructor.name || "Object";
372
+ return u;
373
+ }
374
+ }
375
+ function Tr(e) {
376
+ try {
377
+ return He(e), !1;
378
+ } catch {
379
+ return !0;
380
+ }
381
+ }
382
+ function He(e) {
383
+ return "" + e;
384
+ }
385
+ function Je(e) {
386
+ if (Tr(e))
387
+ return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Cr(e)), He(e);
388
+ }
389
+ var Q = U.ReactCurrentOwner, zr = {
390
+ key: !0,
391
+ ref: !0,
392
+ __self: !0,
393
+ __source: !0
394
+ }, Xe, Qe, _e;
395
+ _e = {};
396
+ function Or(e) {
397
+ if (se.call(e, "ref")) {
398
+ var a = Object.getOwnPropertyDescriptor(e, "ref").get;
399
+ if (a && a.isReactWarning)
400
+ return !1;
401
+ }
402
+ return e.ref !== void 0;
403
+ }
404
+ function Ar(e) {
405
+ if (se.call(e, "key")) {
406
+ var a = Object.getOwnPropertyDescriptor(e, "key").get;
407
+ if (a && a.isReactWarning)
408
+ return !1;
409
+ }
410
+ return e.key !== void 0;
411
+ }
412
+ function xr(e, a) {
413
+ if (typeof e.ref == "string" && Q.current && a && Q.current.stateNode !== a) {
414
+ var u = L(Q.current.type);
415
+ _e[u] || (O('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', L(Q.current.type), e.ref), _e[u] = !0);
416
+ }
417
+ }
418
+ function kr(e, a) {
419
+ {
420
+ var u = function() {
421
+ Xe || (Xe = !0, O("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
422
+ };
423
+ u.isReactWarning = !0, Object.defineProperty(e, "key", {
424
+ get: u,
425
+ configurable: !0
426
+ });
427
+ }
428
+ }
429
+ function Dr(e, a) {
430
+ {
431
+ var u = function() {
432
+ Qe || (Qe = !0, O("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
433
+ };
434
+ u.isReactWarning = !0, Object.defineProperty(e, "ref", {
435
+ get: u,
436
+ configurable: !0
437
+ });
438
+ }
439
+ }
440
+ var jr = function(e, a, u, g, S, y, w) {
441
+ var m = {
442
+ // This tag allows us to uniquely identify this as a React Element
443
+ $$typeof: n,
444
+ // Built-in properties that belong on the element
445
+ type: e,
446
+ key: a,
447
+ ref: u,
448
+ props: w,
449
+ // Record the component responsible for creating this element.
450
+ _owner: y
451
+ };
452
+ return m._store = {}, Object.defineProperty(m._store, "validated", {
453
+ configurable: !1,
454
+ enumerable: !1,
455
+ writable: !0,
456
+ value: !1
457
+ }), Object.defineProperty(m, "_self", {
458
+ configurable: !1,
459
+ enumerable: !1,
460
+ writable: !1,
461
+ value: g
462
+ }), Object.defineProperty(m, "_source", {
463
+ configurable: !1,
464
+ enumerable: !1,
465
+ writable: !1,
466
+ value: S
467
+ }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
468
+ };
469
+ function Ir(e, a, u, g, S) {
470
+ {
471
+ var y, w = {}, m = null, A = null;
472
+ u !== void 0 && (Je(u), m = "" + u), Ar(a) && (Je(a.key), m = "" + a.key), Or(a) && (A = a.ref, xr(a, S));
473
+ for (y in a)
474
+ se.call(a, y) && !zr.hasOwnProperty(y) && (w[y] = a[y]);
475
+ if (e && e.defaultProps) {
476
+ var P = e.defaultProps;
477
+ for (y in P)
478
+ w[y] === void 0 && (w[y] = P[y]);
479
+ }
480
+ if (m || A) {
481
+ var E = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
482
+ m && kr(w, E), A && Dr(w, E);
483
+ }
484
+ return jr(e, m, A, S, g, Q.current, w);
485
+ }
486
+ }
487
+ var ye = U.ReactCurrentOwner, Ze = U.ReactDebugCurrentFrame;
488
+ function B(e) {
489
+ if (e) {
490
+ var a = e._owner, u = oe(e.type, e._source, a ? a.type : null);
491
+ Ze.setExtraStackFrame(u);
492
+ } else
493
+ Ze.setExtraStackFrame(null);
494
+ }
495
+ var Re;
496
+ Re = !1;
497
+ function Pe(e) {
498
+ return typeof e == "object" && e !== null && e.$$typeof === n;
499
+ }
500
+ function er() {
501
+ {
502
+ if (ye.current) {
503
+ var e = L(ye.current.type);
504
+ if (e)
505
+ return `
506
+
507
+ Check the render method of \`` + e + "`.";
508
+ }
509
+ return "";
510
+ }
511
+ }
512
+ function Fr(e) {
513
+ {
514
+ if (e !== void 0) {
515
+ var a = e.fileName.replace(/^.*[\\\/]/, ""), u = e.lineNumber;
516
+ return `
517
+
518
+ Check your code at ` + a + ":" + u + ".";
519
+ }
520
+ return "";
521
+ }
522
+ }
523
+ var rr = {};
524
+ function qr(e) {
525
+ {
526
+ var a = er();
527
+ if (!a) {
528
+ var u = typeof e == "string" ? e : e.displayName || e.name;
529
+ u && (a = `
530
+
531
+ Check the top-level render call using <` + u + ">.");
532
+ }
533
+ return a;
534
+ }
535
+ }
536
+ function tr(e, a) {
537
+ {
538
+ if (!e._store || e._store.validated || e.key != null)
539
+ return;
540
+ e._store.validated = !0;
541
+ var u = qr(a);
542
+ if (rr[u])
543
+ return;
544
+ rr[u] = !0;
545
+ var g = "";
546
+ e && e._owner && e._owner !== ye.current && (g = " It was passed a child from " + L(e._owner.type) + "."), B(e), O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', u, g), B(null);
547
+ }
548
+ }
549
+ function nr(e, a) {
550
+ {
551
+ if (typeof e != "object")
552
+ return;
553
+ if (Se(e))
554
+ for (var u = 0; u < e.length; u++) {
555
+ var g = e[u];
556
+ Pe(g) && tr(g, a);
557
+ }
558
+ else if (Pe(e))
559
+ e._store && (e._store.validated = !0);
560
+ else if (e) {
561
+ var S = me(e);
562
+ if (typeof S == "function" && S !== e.entries)
563
+ for (var y = S.call(e), w; !(w = y.next()).done; )
564
+ Pe(w.value) && tr(w.value, a);
565
+ }
566
+ }
567
+ }
568
+ function Lr(e) {
569
+ {
570
+ var a = e.type;
571
+ if (a == null || typeof a == "string")
572
+ return;
573
+ var u;
574
+ if (typeof a == "function")
575
+ u = a.propTypes;
576
+ else if (typeof a == "object" && (a.$$typeof === p || // Note: Memo only checks outer props here.
577
+ // Inner props are checked in the reconciler.
578
+ a.$$typeof === h))
579
+ u = a.propTypes;
580
+ else
581
+ return;
582
+ if (u) {
583
+ var g = L(a);
584
+ Pr(u, e.props, "prop", g, e);
585
+ } else if (a.PropTypes !== void 0 && !Re) {
586
+ Re = !0;
587
+ var S = L(a);
588
+ O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", S || "Unknown");
589
+ }
590
+ typeof a.getDefaultProps == "function" && !a.getDefaultProps.isReactClassApproved && O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
591
+ }
592
+ }
593
+ function Mr(e) {
594
+ {
595
+ for (var a = Object.keys(e.props), u = 0; u < a.length; u++) {
596
+ var g = a[u];
597
+ if (g !== "children" && g !== "key") {
598
+ B(e), O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", g), B(null);
599
+ break;
600
+ }
601
+ }
602
+ e.ref !== null && (B(e), O("Invalid attribute `ref` supplied to `React.Fragment`."), B(null));
603
+ }
604
+ }
605
+ function ar(e, a, u, g, S, y) {
606
+ {
607
+ var w = vr(e);
608
+ if (!w) {
609
+ var m = "";
610
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (m += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
611
+ var A = Fr(S);
612
+ A ? m += A : m += er();
613
+ var P;
614
+ e === null ? P = "null" : Se(e) ? P = "array" : e !== void 0 && e.$$typeof === n ? (P = "<" + (L(e.type) || "Unknown") + " />", m = " Did you accidentally export a JSX literal instead of a component?") : P = typeof e, O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", P, m);
615
+ }
616
+ var E = Ir(e, a, u, S, y);
617
+ if (E == null)
618
+ return E;
619
+ if (w) {
620
+ var F = a.children;
621
+ if (F !== void 0)
622
+ if (g)
623
+ if (Se(F)) {
624
+ for (var K = 0; K < F.length; K++)
625
+ nr(F[K], e);
626
+ Object.freeze && Object.freeze(F);
627
+ } else
628
+ O("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
629
+ else
630
+ nr(F, e);
631
+ }
632
+ return e === o ? Mr(E) : Lr(E), E;
633
+ }
634
+ }
635
+ function Nr(e, a, u) {
636
+ return ar(e, a, u, !0);
637
+ }
638
+ function Ur(e, a, u) {
639
+ return ar(e, a, u, !1);
640
+ }
641
+ var Vr = Ur, $r = Nr;
642
+ re.Fragment = o, re.jsx = Vr, re.jsxs = $r;
643
+ }()), re;
644
+ }
645
+ (function(t) {
646
+ process.env.NODE_ENV === "production" ? t.exports = st() : t.exports = ct();
647
+ })(ot);
648
+ const N = te.Fragment, r = te.jsx, v = te.jsxs;
649
+ function lt(t) {
15
650
  t = t || {};
16
- const n = Object.keys(t).sort(), r = [];
17
- for (let i = 0; i < n.length; i++) {
18
- const s = n[i];
19
- if (s != "authentication" && t[s])
20
- r.push(n[i] + "=" + (typeof t[s] == "object" ? JSON.stringify(t[s]) : t[s]));
651
+ const n = Object.keys(t).sort(), i = [];
652
+ for (let o = 0; o < n.length; o++) {
653
+ const l = n[o];
654
+ if (l != "authentication" && t[l])
655
+ i.push(n[o] + "=" + (typeof t[l] == "object" ? JSON.stringify(t[l]) : t[l]));
21
656
  else {
22
- const o = Object.keys(t[s]).sort();
23
- for (let a = 0; a < o.length; a++) {
24
- const c = o[a];
25
- c != "sign" && t[s][c] && r.push(o[a] + "=" + (typeof t[s][c] == "object" ? JSON.stringify(t[s][c]) : t[s][c]));
657
+ const s = Object.keys(t[l]).sort();
658
+ for (let c = 0; c < s.length; c++) {
659
+ const d = s[c];
660
+ d != "sign" && t[l][d] && i.push(s[c] + "=" + (typeof t[l][d] == "object" ? JSON.stringify(t[l][d]) : t[l][d]));
26
661
  }
27
662
  }
28
663
  }
29
- return r.sort().join("&");
664
+ return i.sort().join("&");
30
665
  }
31
- function Pe(t, n) {
32
- let r = ze(t);
33
- return r += "&key=" + n, he.MD5(r).toString().toUpperCase();
666
+ function ut(t, n) {
667
+ let i = lt(t);
668
+ return i += "&key=" + n, rt.MD5(i).toString().toUpperCase();
34
669
  }
35
- const f = {
670
+ const C = {
36
671
  baseURL: "http://localhost:31200",
37
672
  app_id: "",
38
673
  app_secret: "",
39
674
  getAuthentication(t) {
40
675
  if (!this.app_id || !this.app_secret)
41
676
  return;
42
- const n = new Date().getTime().toString();
677
+ const n = (/* @__PURE__ */ new Date()).getTime().toString();
43
678
  return {
44
679
  app_id: this.app_id,
45
680
  nonce_str: n,
46
- sign: Pe({
681
+ sign: ut({
47
682
  app_id: this.app_id,
48
683
  nonce_str: n,
49
684
  ...t
@@ -51,35 +686,35 @@ const f = {
51
686
  };
52
687
  },
53
688
  getRequest(t) {
54
- return (n, r, i = {}) => {
55
- const s = window.localStorage.getItem("token"), o = {
689
+ return (n, i, o = {}) => {
690
+ const l = window.localStorage.getItem("token"), s = {
56
691
  "X-Requested-With": "XMLHttpRequest",
57
- "Content-Type": i.string ? "application/x-www-form-urlencoded" : "application/json",
58
- authorization: s ? `bearer ${s}` : "",
59
- ...i.headers
60
- }, a = {
692
+ "Content-Type": o.string ? "application/x-www-form-urlencoded" : "application/json",
693
+ authorization: l ? `bearer ${l}` : "",
694
+ ...o.headers
695
+ }, c = {
61
696
  baseURL: this.baseURL,
62
697
  method: t,
63
698
  url: n,
64
- params: t === "GET" ? r : i.params,
65
- headers: o
699
+ params: t === "GET" ? i : o.params,
700
+ headers: s
66
701
  };
67
- return ["POST", "PUT"].includes(t) && (a.data = i.string ? JSON.stringify(r) : r, a.data.authentication = this.getAuthentication(a.data)), me(a).then((c) => c.data).catch((c) => fe.has(c, "response.data.detail.message") ? Promise.reject(new Error(c.response.data.detail.message)) : Promise.reject(c));
702
+ return ["POST", "PUT"].includes(t) && (c.data = o.string ? JSON.stringify(i) : i, c.data.authentication = this.getAuthentication(c.data)), et(c).then((d) => d.data).catch((d) => tt.has(d, "response.data.detail.message") ? Promise.reject(new Error(d.response.data.detail.message)) : Promise.reject(d));
68
703
  };
69
704
  }
70
705
  };
71
- function M(t) {
72
- f.baseURL !== t.apiBaseURL && (f.baseURL = t.apiBaseURL), t.app_id && (f.app_id = t.app_id), t.app_secret && (f.app_secret = t.app_secret);
706
+ function pe(t) {
707
+ C.baseURL !== t.apiBaseURL && (C.baseURL = t.apiBaseURL), t.app_id && (C.app_id = t.app_id), t.app_secret && (C.app_secret = t.app_secret);
73
708
  }
74
- const ve = {
709
+ const dt = {
75
710
  login: async (t, n) => {
76
- const r = {
711
+ const i = {
77
712
  name: t,
78
713
  password: n
79
714
  };
80
- return await f.getRequest("POST")("/account/login", r);
715
+ return await C.getRequest("POST")("/account/login", i);
81
716
  },
82
- list: async () => await f.getRequest("POST")("/account/list", {
717
+ list: async () => await C.getRequest("POST")("/account/list", {
83
718
  filter: {},
84
719
  sort: [{
85
720
  field: "name",
@@ -90,36 +725,45 @@ const ve = {
90
725
  pagesize: 100
91
726
  }
92
727
  }),
93
- get: async () => await f.getRequest("GET")("/account/get", {}),
728
+ /**
729
+ * get current account
730
+ */
731
+ get: async () => await C.getRequest("GET")("/account/get", {}),
732
+ /**
733
+ * update current account
734
+ */
94
735
  update: async (t, n) => {
95
- const r = {
736
+ const i = {
96
737
  name: t,
97
738
  email: n
98
739
  };
99
- return await f.getRequest("PUT")("/account/update", r);
740
+ return await C.getRequest("PUT")("/account/update", i);
100
741
  },
742
+ /**
743
+ * change current account's password
744
+ */
101
745
  changepassword: async (t, n) => {
102
- const r = {
746
+ const i = {
103
747
  old_password: t,
104
748
  new_password: n
105
749
  };
106
- return await f.getRequest("POST")("/account/changepassword", r);
750
+ return await C.getRequest("POST")("/account/changepassword", i);
107
751
  },
108
- create: async (t, n, r, i) => await f.getRequest("POST")("/account/create", {
752
+ create: async (t, n, i, o) => await C.getRequest("POST")("/account/create", {
109
753
  name: t,
110
754
  email: n,
111
- password: r,
112
- role_id: i
755
+ password: i,
756
+ role_id: o
113
757
  }),
114
- edit: async (t) => (t.reset_password || (t.new_password = void 0), await f.getRequest("PUT")("/account/edit", t)),
758
+ edit: async (t) => (t.reset_password || (t.new_password = void 0), await C.getRequest("PUT")("/account/edit", t)),
115
759
  delete: async (t) => {
116
- if (!!t)
117
- return f.getRequest("POST")("/account/delete", {
760
+ if (t)
761
+ return C.getRequest("POST")("/account/delete", {
118
762
  id: t
119
763
  });
120
764
  }
121
- }, Ae = {
122
- list: async () => await f.getRequest("POST")("/api/key/list", {
765
+ }, ft = {
766
+ list: async () => await C.getRequest("POST")("/api/key/list", {
123
767
  filter: {
124
768
  search: ""
125
769
  },
@@ -132,18 +776,18 @@ const ve = {
132
776
  pagesize: 100
133
777
  }
134
778
  }),
135
- create: async (t, n) => f.getRequest("POST")("/api/key/create", {
779
+ create: async (t, n) => C.getRequest("POST")("/api/key/create", {
136
780
  name: t,
137
781
  role_id: n
138
782
  }),
139
783
  delete: async (t) => {
140
- if (!!t)
141
- return f.getRequest("POST")("/api/key/delete", {
784
+ if (t)
785
+ return C.getRequest("POST")("/api/key/delete", {
142
786
  id: t
143
787
  });
144
788
  }
145
- }, Ce = {
146
- list: async () => await f.getRequest("POST")("/datasource/list", {
789
+ }, pt = {
790
+ list: async () => await C.getRequest("POST")("/datasource/list", {
147
791
  filter: {},
148
792
  sort: [{
149
793
  field: "create_time",
@@ -154,42 +798,42 @@ const ve = {
154
798
  pagesize: 100
155
799
  }
156
800
  }),
157
- create: async (t, n, r) => await f.getRequest("POST")("/datasource/create", {
801
+ create: async (t, n, i) => await C.getRequest("POST")("/datasource/create", {
158
802
  type: t,
159
803
  key: n,
160
- config: r
804
+ config: i
161
805
  }),
162
806
  delete: async (t) => {
163
- await f.getRequest("POST")("/datasource/delete", {
807
+ await C.getRequest("POST")("/datasource/delete", {
164
808
  id: t
165
809
  });
166
810
  }
167
- }, _e = {
168
- list: async () => await f.getRequest("GET")("/role/list", {})
169
- }, P = {
170
- datasource: Ce,
171
- account: ve,
172
- role: _e,
173
- api_key: Ae
174
- }, D = {
811
+ }, gt = {
812
+ list: async () => await C.getRequest("GET")("/role/list", {})
813
+ }, j = {
814
+ datasource: pt,
815
+ account: dt,
816
+ role: gt,
817
+ api_key: ft
818
+ }, Y = {
175
819
  size: "sm",
176
820
  spacing: "md",
177
821
  button: {
178
822
  size: "xs"
179
823
  }
180
- }, C = X.Fragment, e = X.jsx, d = X.jsxs;
181
- function ye({
824
+ };
825
+ function ht({
182
826
  submit: t,
183
- styles: n = D,
184
- type: r
827
+ styles: n = Y,
828
+ type: i
185
829
  }) {
186
830
  const {
187
- control: i,
188
- setValue: s,
189
- handleSubmit: o
190
- } = q({
831
+ control: o,
832
+ setValue: l,
833
+ handleSubmit: s
834
+ } = J({
191
835
  defaultValues: {
192
- type: r,
836
+ type: i,
193
837
  key: "",
194
838
  config: {
195
839
  host: "",
@@ -200,322 +844,150 @@ function ye({
200
844
  }
201
845
  }
202
846
  });
203
- return G(() => {
204
- s("type", r);
205
- }, [s, r]), /* @__PURE__ */ e(v, {
206
- mx: "auto",
207
- children: /* @__PURE__ */ d("form", {
208
- onSubmit: o(t),
209
- children: [/* @__PURE__ */ e(m, {
210
- name: "key",
211
- control: i,
212
- render: ({
213
- field: a
214
- }) => /* @__PURE__ */ e(z, {
215
- mb: n.spacing,
216
- size: n.size,
217
- required: !0,
218
- label: "Name",
219
- placeholder: "A unique name",
220
- ...a
221
- })
222
- }), /* @__PURE__ */ e(V, {
223
- label: "Connection Info",
224
- labelPosition: "center"
225
- }), /* @__PURE__ */ d(w, {
226
- grow: !0,
227
- children: [/* @__PURE__ */ e(m, {
228
- name: "config.host",
229
- control: i,
230
- render: ({
231
- field: a
232
- }) => /* @__PURE__ */ e(z, {
233
- mb: n.spacing,
234
- size: n.size,
235
- required: !0,
236
- label: "Host",
237
- sx: {
238
- flexGrow: 1
239
- },
240
- ...a
241
- })
242
- }), /* @__PURE__ */ e(m, {
243
- name: "config.port",
244
- control: i,
245
- render: ({
246
- field: a
247
- }) => /* @__PURE__ */ e(ie, {
248
- mb: n.spacing,
249
- size: n.size,
250
- required: !0,
251
- label: "Port",
252
- hideControls: !0,
253
- sx: {
254
- width: "8em"
255
- },
256
- ...a
257
- })
258
- })]
259
- }), /* @__PURE__ */ e(m, {
260
- name: "config.username",
261
- control: i,
262
- render: ({
263
- field: a
264
- }) => /* @__PURE__ */ e(z, {
265
- mb: n.spacing,
266
- size: n.size,
267
- required: !0,
268
- label: "Username",
269
- ...a
270
- })
271
- }), /* @__PURE__ */ e(m, {
272
- name: "config.password",
273
- control: i,
274
- render: ({
275
- field: a
276
- }) => /* @__PURE__ */ e(F, {
277
- mb: n.spacing,
278
- size: n.size,
279
- required: !0,
280
- label: "Password",
281
- ...a
282
- })
283
- }), /* @__PURE__ */ e(m, {
284
- name: "config.database",
285
- control: i,
286
- render: ({
287
- field: a
288
- }) => /* @__PURE__ */ e(z, {
289
- mb: n.spacing,
290
- size: n.size,
291
- required: !0,
292
- label: "Database",
293
- ...a
294
- })
295
- }), /* @__PURE__ */ e(w, {
296
- position: "right",
297
- mt: n.spacing,
298
- children: /* @__PURE__ */ e(b, {
299
- type: "submit",
300
- size: n.button.size,
301
- children: "Save"
302
- })
303
- })]
304
- })
305
- });
847
+ return Te(() => {
848
+ l("type", i);
849
+ }, [l, i]), /* @__PURE__ */ r(I, { mx: "auto", children: /* @__PURE__ */ v("form", { onSubmit: s(t), children: [
850
+ /* @__PURE__ */ r(R, { name: "key", control: o, render: ({
851
+ field: c
852
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Name", placeholder: "A unique name", ...c }) }),
853
+ /* @__PURE__ */ r(Oe, { label: "Connection Info", labelPosition: "center" }),
854
+ /* @__PURE__ */ v(z, { grow: !0, children: [
855
+ /* @__PURE__ */ r(R, { name: "config.host", control: o, render: ({
856
+ field: c
857
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Host", sx: {
858
+ flexGrow: 1
859
+ }, ...c }) }),
860
+ /* @__PURE__ */ r(R, { name: "config.port", control: o, render: ({
861
+ field: c
862
+ }) => /* @__PURE__ */ r(Wr, { mb: n.spacing, size: n.size, required: !0, label: "Port", hideControls: !0, sx: {
863
+ width: "8em"
864
+ }, ...c }) })
865
+ ] }),
866
+ /* @__PURE__ */ r(R, { name: "config.username", control: o, render: ({
867
+ field: c
868
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Username", ...c }) }),
869
+ /* @__PURE__ */ r(R, { name: "config.password", control: o, render: ({
870
+ field: c
871
+ }) => /* @__PURE__ */ r(de, { mb: n.spacing, size: n.size, required: !0, label: "Password", ...c }) }),
872
+ /* @__PURE__ */ r(R, { name: "config.database", control: o, render: ({
873
+ field: c
874
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Database", ...c }) }),
875
+ /* @__PURE__ */ r(z, { position: "right", mt: n.spacing, children: /* @__PURE__ */ r(T, { type: "submit", size: n.button.size, children: "Save" }) })
876
+ ] }) });
306
877
  }
307
- const ke = ({
878
+ const mt = ({
308
879
  value: t,
309
880
  onChange: n
310
- }) => /* @__PURE__ */ e(v, {
311
- sx: {
312
- position: "relative"
313
- },
314
- children: /* @__PURE__ */ e(we, {
315
- height: "500px",
316
- defaultLanguage: "javascript",
317
- value: t,
318
- onChange: (i) => {
319
- !i || n(i);
320
- },
321
- theme: "vs-dark",
322
- options: {
323
- minimap: {
324
- enabled: !1
325
- }
326
- }
327
- })
328
- }), Z = J(({
881
+ }) => /* @__PURE__ */ r(I, { sx: {
882
+ position: "relative"
883
+ }, children: /* @__PURE__ */ r(at, { height: "500px", defaultLanguage: "javascript", value: t, onChange: (o) => {
884
+ o && n(o);
885
+ }, theme: "vs-dark", options: {
886
+ minimap: {
887
+ enabled: !1
888
+ }
889
+ } }) }), cr = ze(({
329
890
  value: t,
330
891
  onChange: n,
331
- label: r,
332
- modalTitle: i,
333
- defaultValue: s,
334
- styles: o
335
- }, a) => {
336
- const [c, {
892
+ label: i,
893
+ modalTitle: o,
894
+ defaultValue: l,
895
+ styles: s
896
+ }, c) => {
897
+ const [d, {
337
898
  setTrue: p,
338
- setFalse: g
339
- }] = be(), [h, u] = ee(t), l = () => {
340
- g(), n(h);
341
- }, A = () => {
342
- g(), u(t);
899
+ setFalse: b
900
+ }] = nt(), [f, h] = lr(t), _ = () => {
901
+ b(), n(f);
343
902
  }, k = () => {
344
- u(s);
903
+ b(), h(t);
904
+ }, q = () => {
905
+ h(l);
345
906
  };
346
- return G(() => {
347
- u(t);
348
- }, [t]), /* @__PURE__ */ d(C, {
349
- children: [/* @__PURE__ */ e(b, {
350
- variant: "filled",
351
- size: o.button.size,
352
- onClick: p,
353
- sx: {
354
- flexGrow: 1
355
- },
356
- children: r
357
- }), /* @__PURE__ */ e(R, {
358
- size: 800,
359
- title: i,
360
- opened: c,
361
- onClose: g,
362
- closeOnClickOutside: !1,
363
- withCloseButton: !1,
364
- children: c && /* @__PURE__ */ d(B, {
365
- children: [/* @__PURE__ */ e(ke, {
366
- value: h,
367
- onChange: u
368
- }), /* @__PURE__ */ d(w, {
369
- position: "apart",
370
- children: [/* @__PURE__ */ e(b, {
371
- onClick: k,
372
- color: "red",
373
- leftIcon: /* @__PURE__ */ e(ue, {
374
- size: 20
375
- }),
376
- children: "Rest"
377
- }), /* @__PURE__ */ d(w, {
378
- position: "right",
379
- children: [/* @__PURE__ */ e(b, {
380
- onClick: A,
381
- variant: "subtle",
382
- children: "Cancel"
383
- }), /* @__PURE__ */ e(b, {
384
- onClick: l,
385
- children: "OK"
386
- })]
387
- })]
388
- })]
389
- })
390
- })]
391
- });
392
- }), I = {
907
+ return Te(() => {
908
+ h(t);
909
+ }, [t]), /* @__PURE__ */ v(N, { children: [
910
+ /* @__PURE__ */ r(T, { variant: "filled", size: s.button.size, onClick: p, sx: {
911
+ flexGrow: 1
912
+ }, children: i }),
913
+ /* @__PURE__ */ r(ne, { size: 800, title: o, opened: d, onClose: b, closeOnClickOutside: !1, withCloseButton: !1, children: d && /* @__PURE__ */ v(Ae, { children: [
914
+ /* @__PURE__ */ r(mt, { value: f, onChange: h }),
915
+ /* @__PURE__ */ v(z, { position: "apart", children: [
916
+ /* @__PURE__ */ r(T, { onClick: q, color: "red", leftIcon: /* @__PURE__ */ r(Xr, { size: 20 }), children: "Rest" }),
917
+ /* @__PURE__ */ v(z, { position: "right", children: [
918
+ /* @__PURE__ */ r(T, { onClick: k, variant: "subtle", children: "Cancel" }),
919
+ /* @__PURE__ */ r(T, { onClick: _, children: "OK" })
920
+ ] })
921
+ ] })
922
+ ] }) })
923
+ ] });
924
+ }), le = {
393
925
  pre: ["function pre_process({ method, url, params, headers, data }, utils) {", " // your code goes here", " return { method, url, params, headers, data }", "}"].join(`
394
926
  `),
395
927
  post: ["function post_process(res, utils) {", " // your code goes here", " return data", "}"].join(`
396
928
  `)
397
929
  };
398
- function De({
930
+ function vt({
399
931
  submit: t,
400
- styles: n = D
932
+ styles: n = Y
401
933
  }) {
402
934
  const {
403
- control: r,
404
- setValue: i,
405
- handleSubmit: s
406
- } = q({
935
+ control: i,
936
+ setValue: o,
937
+ handleSubmit: l
938
+ } = J({
407
939
  defaultValues: {
408
940
  type: "http",
409
941
  key: "",
410
942
  config: {
411
943
  host: "",
412
944
  processing: {
413
- pre: I.pre,
414
- post: I.post
945
+ pre: le.pre,
946
+ post: le.post
415
947
  }
416
948
  }
417
949
  }
418
950
  });
419
- return /* @__PURE__ */ e(v, {
420
- mx: "auto",
421
- children: /* @__PURE__ */ d("form", {
422
- onSubmit: s(t),
423
- children: [/* @__PURE__ */ e(m, {
424
- name: "key",
425
- control: r,
426
- render: ({
427
- field: o
428
- }) => /* @__PURE__ */ e(z, {
429
- mb: n.spacing,
430
- size: n.size,
431
- required: !0,
432
- label: "Name",
433
- placeholder: "A unique name",
434
- ...o
435
- })
436
- }), /* @__PURE__ */ e(V, {
437
- label: "Connection Info",
438
- labelPosition: "center"
439
- }), /* @__PURE__ */ e(m, {
440
- name: "config.host",
441
- control: r,
442
- render: ({
443
- field: o
444
- }) => /* @__PURE__ */ e(z, {
445
- mb: n.spacing,
446
- size: n.size,
447
- required: !0,
448
- label: "Base URL",
449
- sx: {
450
- flexGrow: 1
451
- },
452
- ...o
453
- })
454
- }), /* @__PURE__ */ d(w, {
455
- grow: !0,
456
- children: [/* @__PURE__ */ e(m, {
457
- name: "config.processing.pre",
458
- control: r,
459
- render: ({
460
- field: o
461
- }) => /* @__PURE__ */ e(Z, {
462
- label: "Pre Processing",
463
- modalTitle: "This function will run before sending the request (for scenarios like encryption)",
464
- defaultValue: I.pre,
465
- ...o,
466
- styles: n
467
- })
468
- }), /* @__PURE__ */ e(m, {
469
- name: "config.processing.post",
470
- control: r,
471
- render: ({
472
- field: o
473
- }) => /* @__PURE__ */ e(Z, {
474
- label: "Post Processing",
475
- modalTitle: "This function will run after sending the request (for scenarios like decryption)",
476
- defaultValue: I.post,
477
- ...o,
478
- styles: n
479
- })
480
- })]
481
- }), /* @__PURE__ */ e(w, {
482
- position: "right",
483
- mt: n.spacing,
484
- children: /* @__PURE__ */ e(b, {
485
- type: "submit",
486
- size: n.button.size,
487
- children: "Save"
488
- })
489
- })]
490
- })
491
- });
951
+ return /* @__PURE__ */ r(I, { mx: "auto", children: /* @__PURE__ */ v("form", { onSubmit: l(t), children: [
952
+ /* @__PURE__ */ r(R, { name: "key", control: i, render: ({
953
+ field: s
954
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Name", placeholder: "A unique name", ...s }) }),
955
+ /* @__PURE__ */ r(Oe, { label: "Connection Info", labelPosition: "center" }),
956
+ /* @__PURE__ */ r(R, { name: "config.host", control: i, render: ({
957
+ field: s
958
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Base URL", sx: {
959
+ flexGrow: 1
960
+ }, ...s }) }),
961
+ /* @__PURE__ */ v(z, { grow: !0, children: [
962
+ /* @__PURE__ */ r(R, { name: "config.processing.pre", control: i, render: ({
963
+ field: s
964
+ }) => /* @__PURE__ */ r(cr, { label: "Pre Processing", modalTitle: "This function will run before sending the request (for scenarios like encryption)", defaultValue: le.pre, ...s, styles: n }) }),
965
+ /* @__PURE__ */ r(R, { name: "config.processing.post", control: i, render: ({
966
+ field: s
967
+ }) => /* @__PURE__ */ r(cr, { label: "Post Processing", modalTitle: "This function will run after sending the request (for scenarios like decryption)", defaultValue: le.post, ...s, styles: n }) })
968
+ ] }),
969
+ /* @__PURE__ */ r(z, { position: "right", mt: n.spacing, children: /* @__PURE__ */ r(T, { type: "submit", size: n.button.size, children: "Save" }) })
970
+ ] }) });
492
971
  }
493
- function Te({
494
- styles: t = D
972
+ function bt({
973
+ styles: t = Y
495
974
  }) {
496
- return /* @__PURE__ */ e(v, {
497
- mx: "auto",
498
- children: /* @__PURE__ */ d(oe, {
499
- mt: t.spacing,
500
- icon: /* @__PURE__ */ e(pe, {
501
- size: 16
502
- }),
503
- children: ["Only ", /* @__PURE__ */ e("b", {
504
- children: "SELECT"
505
- }), " privilege is needed."]
506
- })
507
- });
975
+ return /* @__PURE__ */ r(I, { mx: "auto", children: /* @__PURE__ */ v(Yr, { mt: t.spacing, icon: /* @__PURE__ */ r(Qr, { size: 16 }), children: [
976
+ "Only ",
977
+ /* @__PURE__ */ r("b", { children: "SELECT" }),
978
+ " privilege is needed."
979
+ ] }) });
508
980
  }
509
- function qe({
981
+ function wt({
510
982
  postSubmit: t,
511
- styles: n = D
983
+ styles: n = Y
512
984
  }) {
513
- const [r, i] = ee("postgresql"), s = async ({
514
- type: c,
985
+ const [i, o] = lr("postgresql"), l = async ({
986
+ type: d,
515
987
  key: p,
516
- config: g
988
+ config: b
517
989
  }) => {
518
- _({
990
+ V({
519
991
  id: "for-creating",
520
992
  title: "Pending",
521
993
  message: "Adding data source...",
@@ -523,1202 +995,783 @@ function qe({
523
995
  });
524
996
  try {
525
997
  console.log({
526
- type: c,
998
+ type: d,
527
999
  key: p,
528
- config: g
529
- }), await P.datasource.create(c, p, g), S({
1000
+ config: b
1001
+ }), await j.datasource.create(d, p, b), x({
530
1002
  id: "for-creating",
531
1003
  title: "Successful",
532
1004
  message: "Data source is added",
533
1005
  color: "green"
534
1006
  }), t();
535
- } catch (h) {
536
- S({
1007
+ } catch (f) {
1008
+ x({
537
1009
  id: "for-creating",
538
1010
  title: "Failed",
539
- message: h.message,
1011
+ message: f.message,
540
1012
  color: "red"
541
1013
  });
542
1014
  }
543
- }, o = r === "postgresql" || r === "mysql", a = r === "http";
544
- return /* @__PURE__ */ d(v, {
545
- mx: "auto",
546
- children: [/* @__PURE__ */ e(ae, {
547
- fullWidth: !0,
548
- mb: n.spacing,
549
- size: n.size,
550
- data: [{
551
- label: "PostgreSQL",
552
- value: "postgresql"
553
- }, {
554
- label: "MySQL",
555
- value: "mysql"
556
- }, {
557
- label: "HTTP",
558
- value: "http"
559
- }],
560
- value: r,
561
- onChange: (c) => i(c)
562
- }), o && /* @__PURE__ */ e(Te, {
563
- styles: n
564
- }), o && /* @__PURE__ */ e(ye, {
565
- submit: s,
566
- styles: n,
567
- type: r
568
- }), a && /* @__PURE__ */ e(De, {
569
- submit: s,
570
- styles: n
571
- })]
572
- });
1015
+ }, s = i === "postgresql" || i === "mysql", c = i === "http";
1016
+ return /* @__PURE__ */ v(I, { mx: "auto", children: [
1017
+ /* @__PURE__ */ r(Br, { fullWidth: !0, mb: n.spacing, size: n.size, data: [{
1018
+ label: "PostgreSQL",
1019
+ value: "postgresql"
1020
+ }, {
1021
+ label: "MySQL",
1022
+ value: "mysql"
1023
+ }, {
1024
+ label: "HTTP",
1025
+ value: "http"
1026
+ }], value: i, onChange: (d) => o(d) }),
1027
+ s && /* @__PURE__ */ r(bt, { styles: n }),
1028
+ s && /* @__PURE__ */ r(ht, { submit: l, styles: n, type: i }),
1029
+ c && /* @__PURE__ */ r(vt, { submit: l, styles: n })
1030
+ ] });
573
1031
  }
574
- function xe({
1032
+ function St({
575
1033
  onSuccess: t,
576
- styles: n = D
1034
+ styles: n = Y
577
1035
  }) {
578
- const [r, i] = E.useState(!1), s = () => i(!0), o = () => i(!1);
579
- return /* @__PURE__ */ d(C, {
580
- children: [/* @__PURE__ */ e(R, {
581
- overflow: "inside",
582
- opened: r,
583
- onClose: () => i(!1),
584
- title: "Add a data source",
585
- trapFocus: !0,
586
- onDragStart: (c) => {
587
- c.stopPropagation();
588
- },
589
- children: /* @__PURE__ */ e(qe, {
590
- postSubmit: () => {
591
- t(), o();
592
- },
593
- styles: n
594
- })
595
- }), /* @__PURE__ */ e(b, {
596
- size: n.button.size,
597
- onClick: s,
598
- leftIcon: /* @__PURE__ */ e(Q, {
599
- size: 20
600
- }),
601
- children: "Add a Data Source"
602
- })]
603
- });
1036
+ const [i, o] = H.useState(!1), l = () => o(!0), s = () => o(!1);
1037
+ return /* @__PURE__ */ v(N, { children: [
1038
+ /* @__PURE__ */ r(ne, { overflow: "inside", opened: i, onClose: () => o(!1), title: "Add a data source", trapFocus: !0, onDragStart: (d) => {
1039
+ d.stopPropagation();
1040
+ }, children: /* @__PURE__ */ r(wt, { postSubmit: () => {
1041
+ t(), s();
1042
+ }, styles: n }) }),
1043
+ /* @__PURE__ */ r(T, { size: n.button.size, onClick: l, leftIcon: /* @__PURE__ */ r(De, { size: 20 }), children: "Add a Data Source" })
1044
+ ] });
604
1045
  }
605
- const Oe = (t) => t.replace(/([^:])(\/\/+)/g, "$1/");
606
- function Re(t) {
607
- G(() => {
608
- if (N.__getMonacoInstance())
1046
+ const _t = (t) => t.replace(/([^:])(\/\/+)/g, "$1/");
1047
+ function yt(t) {
1048
+ Te(() => {
1049
+ if (Ee.__getMonacoInstance())
609
1050
  return;
610
1051
  console.log("loading monaco for @devtable/settings-form");
611
- const r = Oe(t);
612
- N.config({
1052
+ const i = _t(t);
1053
+ Ee.config({
613
1054
  paths: {
614
- vs: r
1055
+ vs: i
615
1056
  }
616
- }), N.init().then((i) => console.log("monaco instance:", i));
1057
+ }), Ee.init().then((o) => console.log("monaco instance:", o));
617
1058
  }, []);
618
1059
  }
619
- function K() {
620
- return K = Object.assign ? Object.assign.bind() : function(t) {
1060
+ function Ce() {
1061
+ return Ce = Object.assign ? Object.assign.bind() : function(t) {
621
1062
  for (var n = 1; n < arguments.length; n++) {
622
- var r = arguments[n];
623
- for (var i in r)
624
- Object.prototype.hasOwnProperty.call(r, i) && (t[i] = r[i]);
1063
+ var i = arguments[n];
1064
+ for (var o in i)
1065
+ Object.prototype.hasOwnProperty.call(i, o) && (t[o] = i[o]);
625
1066
  }
626
1067
  return t;
627
- }, K.apply(this, arguments);
1068
+ }, Ce.apply(this, arguments);
628
1069
  }
629
- function Ie(t, n) {
1070
+ function Rt(t, n) {
630
1071
  if (t == null)
631
1072
  return {};
632
- var r, i, s = function(a, c) {
633
- if (a == null)
1073
+ var i, o, l = function(c, d) {
1074
+ if (c == null)
634
1075
  return {};
635
- var p, g, h = {}, u = Object.keys(a);
636
- for (g = 0; g < u.length; g++)
637
- p = u[g], c.indexOf(p) >= 0 || (h[p] = a[p]);
638
- return h;
1076
+ var p, b, f = {}, h = Object.keys(c);
1077
+ for (b = 0; b < h.length; b++)
1078
+ p = h[b], d.indexOf(p) >= 0 || (f[p] = c[p]);
1079
+ return f;
639
1080
  }(t, n);
640
1081
  if (Object.getOwnPropertySymbols) {
641
- var o = Object.getOwnPropertySymbols(t);
642
- for (i = 0; i < o.length; i++)
643
- r = o[i], n.indexOf(r) >= 0 || Object.prototype.propertyIsEnumerable.call(t, r) && (s[r] = t[r]);
1082
+ var s = Object.getOwnPropertySymbols(t);
1083
+ for (o = 0; o < s.length; o++)
1084
+ i = s[o], n.indexOf(i) >= 0 || Object.prototype.propertyIsEnumerable.call(t, i) && (l[i] = t[i]);
644
1085
  }
645
- return s;
1086
+ return l;
646
1087
  }
647
- var Le = ["size", "color", "stroke"];
648
- function Fe(t) {
649
- var n = t.size, r = n === void 0 ? 24 : n, i = t.color, s = i === void 0 ? "currentColor" : i, o = t.stroke, a = o === void 0 ? 2 : o, c = Ie(t, Le);
650
- return O.createElement("svg", K({ xmlns: "http://www.w3.org/2000/svg", className: "icon icon-tabler icon-tabler-lock", width: r, height: r, viewBox: "0 0 24 24", strokeWidth: a, stroke: s, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, c), O.createElement("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), O.createElement("rect", { x: 5, y: 11, width: 14, height: 10, rx: 2 }), O.createElement("circle", { cx: 12, cy: 16, r: 1 }), O.createElement("path", { d: "M8 11v-4a4 4 0 0 1 8 0v4" }));
1088
+ var Pt = ["size", "color", "stroke"];
1089
+ function Et(t) {
1090
+ var n = t.size, i = n === void 0 ? 24 : n, o = t.color, l = o === void 0 ? "currentColor" : o, s = t.stroke, c = s === void 0 ? 2 : s, d = Rt(t, Pt);
1091
+ return Z.createElement("svg", Ce({ xmlns: "http://www.w3.org/2000/svg", className: "icon icon-tabler icon-tabler-lock", width: i, height: i, viewBox: "0 0 24 24", strokeWidth: c, stroke: l, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, d), Z.createElement("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), Z.createElement("rect", { x: 5, y: 11, width: 14, height: 10, rx: 2 }), Z.createElement("circle", { cx: 12, cy: 16, r: 1 }), Z.createElement("path", { d: "M8 11v-4a4 4 0 0 1 8 0v4" }));
651
1092
  }
652
- function Ee({
1093
+ function Ct({
653
1094
  id: t,
654
1095
  name: n,
655
- isProtected: r,
656
- onSuccess: i,
657
- styles: s = D
1096
+ isProtected: i,
1097
+ onSuccess: o,
1098
+ styles: l = Y
658
1099
  }) {
659
- const o = j(), a = async () => {
660
- !t || (_({
1100
+ const s = fe(), c = async () => {
1101
+ t && (V({
661
1102
  id: "for-deleting",
662
1103
  title: "Pending",
663
1104
  message: "Deleting data source...",
664
1105
  loading: !0
665
- }), await P.datasource.delete(t), S({
1106
+ }), await j.datasource.delete(t), x({
666
1107
  id: "for-deleting",
667
1108
  title: "Successful",
668
1109
  message: `Data source [${n}] is deleted`,
669
1110
  color: "green"
670
- }), i());
671
- }, c = () => o.openConfirmModal({
1111
+ }), o());
1112
+ }, d = () => s.openConfirmModal({
672
1113
  title: "Delete this data source?",
673
- children: /* @__PURE__ */ e(L, {
674
- size: s.size,
675
- children: "This action won't affect your database."
676
- }),
1114
+ children: /* @__PURE__ */ r(ue, { size: l.size, children: "This action won't affect your database." }),
677
1115
  labels: {
678
1116
  confirm: "Confirm",
679
1117
  cancel: "Cancel"
680
1118
  },
681
1119
  onCancel: () => console.log("Cancel"),
682
- onConfirm: a
683
- }), p = se();
684
- return r ? /* @__PURE__ */ e(ce, {
685
- withArrow: !0,
686
- events: {
687
- hover: !0,
688
- touch: !1,
689
- focus: !1
690
- },
691
- label: "This is a preset datasource, it can not be deleted",
692
- children: /* @__PURE__ */ e("span", {
693
- children: /* @__PURE__ */ e(Fe, {
694
- size: 16,
695
- color: p.colors.gray[7]
696
- })
697
- })
698
- }) : /* @__PURE__ */ e(b, {
699
- size: s.button.size,
700
- color: "red",
701
- onClick: c,
702
- leftIcon: /* @__PURE__ */ e(W, {
703
- size: 20
704
- }),
705
- children: "Delete"
706
- });
1120
+ onConfirm: c
1121
+ }), p = Kr();
1122
+ return i ? /* @__PURE__ */ r(Gr, { withArrow: !0, events: {
1123
+ hover: !0,
1124
+ touch: !1,
1125
+ focus: !1
1126
+ }, label: "This is a preset datasource, it can not be deleted", children: /* @__PURE__ */ r("span", { children: /* @__PURE__ */ r(Et, { size: 16, color: p.colors.gray[7] }) }) }) : /* @__PURE__ */ r(T, { size: l.button.size, color: "red", onClick: d, leftIcon: /* @__PURE__ */ r(je, { size: 20 }), children: "Delete" });
707
1127
  }
708
- function ot({
709
- styles: t = D,
1128
+ function Gt({
1129
+ styles: t = Y,
710
1130
  config: n
711
1131
  }) {
712
- Re(n.monacoPath), M(n);
1132
+ yt(n.monacoPath), pe(n);
713
1133
  const {
714
- data: r = [],
715
- loading: i,
716
- refresh: s
717
- } = T(async () => {
1134
+ data: i = [],
1135
+ loading: o,
1136
+ refresh: l
1137
+ } = G(async () => {
718
1138
  const {
719
- data: o
720
- } = await P.datasource.list();
721
- return o;
1139
+ data: s
1140
+ } = await j.datasource.list();
1141
+ return s;
722
1142
  }, {
723
1143
  refreshDeps: []
724
1144
  });
725
- return /* @__PURE__ */ d(C, {
726
- children: [/* @__PURE__ */ e(w, {
727
- pt: t.spacing,
728
- position: "right",
729
- children: /* @__PURE__ */ e(xe, {
730
- onSuccess: s
731
- })
732
- }), /* @__PURE__ */ d(v, {
733
- mt: t.spacing,
734
- sx: {
735
- position: "relative"
736
- },
737
- children: [/* @__PURE__ */ e(H, {
738
- visible: i
739
- }), /* @__PURE__ */ d($, {
740
- horizontalSpacing: t.spacing,
741
- verticalSpacing: t.spacing,
742
- fontSize: t.size,
743
- highlightOnHover: !0,
744
- children: [/* @__PURE__ */ e("thead", {
745
- children: /* @__PURE__ */ d("tr", {
746
- children: [/* @__PURE__ */ e("th", {
747
- children: "Type"
748
- }), /* @__PURE__ */ e("th", {
749
- children: "Name"
750
- }), /* @__PURE__ */ e("th", {
751
- children: "Action"
752
- })]
753
- })
754
- }), /* @__PURE__ */ e("tbody", {
755
- children: r.map(({
756
- id: o,
757
- key: a,
758
- type: c,
759
- is_preset: p
760
- }) => /* @__PURE__ */ d("tr", {
761
- children: [/* @__PURE__ */ e("td", {
762
- width: 200,
763
- children: c
764
- }), /* @__PURE__ */ e("td", {
765
- children: a
766
- }), /* @__PURE__ */ e("td", {
767
- width: 200,
768
- children: /* @__PURE__ */ e(w, {
769
- position: "left",
770
- children: /* @__PURE__ */ e(Ee, {
771
- isProtected: p,
772
- id: o,
773
- name: a,
774
- onSuccess: s
775
- })
776
- })
777
- })]
778
- }, a))
779
- })]
780
- })]
781
- })]
782
- });
1145
+ return /* @__PURE__ */ v(N, { children: [
1146
+ /* @__PURE__ */ r(z, { pt: t.spacing, position: "right", children: /* @__PURE__ */ r(St, { onSuccess: l }) }),
1147
+ /* @__PURE__ */ v(I, { mt: t.spacing, sx: {
1148
+ position: "relative"
1149
+ }, children: [
1150
+ /* @__PURE__ */ r(xe, { visible: o }),
1151
+ /* @__PURE__ */ v(ke, { horizontalSpacing: t.spacing, verticalSpacing: t.spacing, fontSize: t.size, highlightOnHover: !0, children: [
1152
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ v("tr", { children: [
1153
+ /* @__PURE__ */ r("th", { children: "Type" }),
1154
+ /* @__PURE__ */ r("th", { children: "Name" }),
1155
+ /* @__PURE__ */ r("th", { children: "Action" })
1156
+ ] }) }),
1157
+ /* @__PURE__ */ r("tbody", { children: i.map(({
1158
+ id: s,
1159
+ key: c,
1160
+ type: d,
1161
+ is_preset: p
1162
+ }) => /* @__PURE__ */ v("tr", { children: [
1163
+ /* @__PURE__ */ r("td", { width: 200, children: d }),
1164
+ /* @__PURE__ */ r("td", { children: c }),
1165
+ /* @__PURE__ */ r("td", { width: 200, children: /* @__PURE__ */ r(z, { position: "left", children: /* @__PURE__ */ r(Ct, { isProtected: p, id: s, name: c, onSuccess: l }) }) })
1166
+ ] }, c)) })
1167
+ ] })
1168
+ ] })
1169
+ ] });
783
1170
  }
784
- const je = J(({
1171
+ const Tt = ze(({
785
1172
  label: t,
786
1173
  value: n,
787
- description: r,
788
- ...i
789
- }, s) => /* @__PURE__ */ d(B, {
790
- spacing: 2,
791
- ref: s,
792
- ...i,
793
- children: [/* @__PURE__ */ e(L, {
794
- size: "sm",
795
- children: t
796
- }), /* @__PURE__ */ e(L, {
797
- size: "xs",
798
- color: "dimmed",
799
- className: "role-description",
800
- children: r
801
- })]
802
- })), Y = J(({
1174
+ description: i,
1175
+ ...o
1176
+ }, l) => /* @__PURE__ */ v(Ae, { spacing: 2, ref: l, ...o, children: [
1177
+ /* @__PURE__ */ r(ue, { size: "sm", children: t }),
1178
+ /* @__PURE__ */ r(ue, { size: "xs", color: "dimmed", className: "role-description", children: i })
1179
+ ] })), Ie = ze(({
803
1180
  styles: t,
804
1181
  value: n,
805
- onChange: r
806
- }, i) => {
1182
+ onChange: i
1183
+ }, o) => {
807
1184
  const {
808
- data: s = [],
809
- loading: o
810
- } = T(async () => (await P.role.list()).map((c) => ({
811
- label: c.name,
812
- value: c.id,
813
- description: c.description,
814
- disabled: c.id === 50
1185
+ data: l = [],
1186
+ loading: s
1187
+ } = G(async () => (await j.role.list()).map((d) => ({
1188
+ label: d.name,
1189
+ value: d.id,
1190
+ description: d.description,
1191
+ disabled: d.id === 50
1192
+ // SUPERADMIN
815
1193
  })), {
816
1194
  refreshDeps: []
817
1195
  });
818
- return /* @__PURE__ */ e(le, {
819
- ref: i,
820
- mb: t.spacing,
821
- size: t.size,
822
- required: !0,
823
- label: "Role",
824
- itemComponent: je,
825
- data: s,
826
- disabled: o,
827
- styles: () => ({
828
- item: {
829
- "&[data-selected]": {
830
- "&, &:hover": {
831
- ".role-description": {
832
- color: "rgba(255,255,255,.8)"
1196
+ return /* @__PURE__ */ r(
1197
+ Hr,
1198
+ {
1199
+ ref: o,
1200
+ mb: t.spacing,
1201
+ size: t.size,
1202
+ required: !0,
1203
+ label: "Role",
1204
+ itemComponent: Tt,
1205
+ data: l,
1206
+ disabled: s,
1207
+ styles: () => ({
1208
+ item: {
1209
+ "&[data-selected]": {
1210
+ "&, &:hover": {
1211
+ ".role-description": {
1212
+ color: "rgba(255,255,255,.8)"
1213
+ }
833
1214
  }
834
1215
  }
835
1216
  }
836
- }
837
- }),
838
- value: n,
839
- onChange: r
840
- });
841
- }), y = {
1217
+ }),
1218
+ value: n,
1219
+ onChange: i
1220
+ }
1221
+ );
1222
+ }), $ = {
842
1223
  size: "sm",
843
1224
  spacing: "md",
844
1225
  button: {
845
1226
  size: "xs"
846
1227
  }
847
1228
  };
848
- function Me({
1229
+ function zt({
849
1230
  postSubmit: t,
850
- styles: n = y,
851
- initialRoleID: r
1231
+ styles: n = $,
1232
+ initialRoleID: i
852
1233
  }) {
853
1234
  const {
854
- control: i,
855
- handleSubmit: s
856
- } = q({
1235
+ control: o,
1236
+ handleSubmit: l
1237
+ } = J({
857
1238
  defaultValues: {
858
1239
  name: "",
859
1240
  email: "",
860
- role_id: r,
1241
+ role_id: i,
861
1242
  password: ""
862
1243
  }
863
1244
  });
864
- return /* @__PURE__ */ e(v, {
865
- mx: "auto",
866
- children: /* @__PURE__ */ d("form", {
867
- onSubmit: s(async ({
868
- name: a,
869
- email: c,
870
- password: p,
871
- role_id: g
872
- }) => {
873
- try {
874
- _({
875
- id: "for-creating",
876
- title: "Pending",
877
- message: "Adding account...",
878
- loading: !0
879
- }), await P.account.create(a, c, p, g), S({
880
- id: "for-creating",
881
- title: "Successful",
882
- message: "Account is added",
883
- color: "green"
884
- }), t();
885
- } catch (h) {
886
- S({
887
- id: "for-creating",
888
- title: "Failed",
889
- message: h.message,
890
- color: "red"
891
- });
892
- }
893
- }),
894
- children: [/* @__PURE__ */ e(m, {
895
- name: "name",
896
- control: i,
897
- render: ({
898
- field: a
899
- }) => /* @__PURE__ */ e(z, {
900
- mb: n.spacing,
901
- size: n.size,
902
- required: !0,
903
- label: "Username",
904
- ...a
905
- })
906
- }), /* @__PURE__ */ e(m, {
907
- name: "email",
908
- control: i,
909
- render: ({
910
- field: a
911
- }) => /* @__PURE__ */ e(z, {
912
- mb: n.spacing,
913
- size: n.size,
914
- required: !0,
915
- label: "Email",
916
- ...a
917
- })
918
- }), /* @__PURE__ */ e(m, {
919
- name: "password",
920
- control: i,
921
- render: ({
922
- field: a
923
- }) => /* @__PURE__ */ e(F, {
924
- mb: n.spacing,
925
- size: n.size,
926
- required: !0,
927
- label: "Password",
928
- description: "Password must be at least 8 characters long",
929
- ...a
930
- })
931
- }), /* @__PURE__ */ e(m, {
932
- name: "role_id",
933
- control: i,
934
- render: ({
935
- field: a
936
- }) => /* @__PURE__ */ e(Y, {
937
- styles: n,
938
- ...a
939
- })
940
- }), /* @__PURE__ */ e(w, {
941
- position: "right",
942
- mt: n.spacing,
943
- children: /* @__PURE__ */ e(b, {
944
- type: "submit",
945
- size: n.button.size,
946
- children: "Save"
947
- })
948
- })]
949
- })
950
- });
1245
+ return /* @__PURE__ */ r(I, { mx: "auto", children: /* @__PURE__ */ v("form", { onSubmit: l(async ({
1246
+ name: c,
1247
+ email: d,
1248
+ password: p,
1249
+ role_id: b
1250
+ }) => {
1251
+ try {
1252
+ V({
1253
+ id: "for-creating",
1254
+ title: "Pending",
1255
+ message: "Adding account...",
1256
+ loading: !0
1257
+ }), await j.account.create(c, d, p, b), x({
1258
+ id: "for-creating",
1259
+ title: "Successful",
1260
+ message: "Account is added",
1261
+ color: "green"
1262
+ }), t();
1263
+ } catch (f) {
1264
+ x({
1265
+ id: "for-creating",
1266
+ title: "Failed",
1267
+ message: f.message,
1268
+ color: "red"
1269
+ });
1270
+ }
1271
+ }), children: [
1272
+ /* @__PURE__ */ r(R, { name: "name", control: o, render: ({
1273
+ field: c
1274
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Username", ...c }) }),
1275
+ /* @__PURE__ */ r(R, { name: "email", control: o, render: ({
1276
+ field: c
1277
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Email", ...c }) }),
1278
+ /* @__PURE__ */ r(R, { name: "password", control: o, render: ({
1279
+ field: c
1280
+ }) => /* @__PURE__ */ r(de, { mb: n.spacing, size: n.size, required: !0, label: "Password", description: "Password must be at least 8 characters long", ...c }) }),
1281
+ /* @__PURE__ */ r(R, { name: "role_id", control: o, render: ({
1282
+ field: c
1283
+ }) => /* @__PURE__ */ r(Ie, { styles: n, ...c }) }),
1284
+ /* @__PURE__ */ r(z, { position: "right", mt: n.spacing, children: /* @__PURE__ */ r(T, { type: "submit", size: n.button.size, children: "Save" }) })
1285
+ ] }) });
951
1286
  }
952
- function Ue({
1287
+ function Ot({
953
1288
  onSuccess: t,
954
- styles: n = y,
955
- initialRoleID: r
1289
+ styles: n = $,
1290
+ initialRoleID: i
956
1291
  }) {
957
- const [i, s] = E.useState(!1), o = () => s(!0), a = () => s(!1);
958
- return /* @__PURE__ */ d(C, {
959
- children: [/* @__PURE__ */ e(R, {
960
- overflow: "inside",
961
- opened: i,
962
- onClose: () => s(!1),
963
- title: "Add an Account",
964
- trapFocus: !0,
965
- onDragStart: (p) => {
966
- p.stopPropagation();
967
- },
968
- children: /* @__PURE__ */ e(Me, {
969
- postSubmit: () => {
970
- t(), a();
971
- },
972
- styles: n,
973
- initialRoleID: r
974
- })
975
- }), /* @__PURE__ */ e(b, {
976
- size: n.button.size,
977
- onClick: o,
978
- leftIcon: /* @__PURE__ */ e(Q, {
979
- size: 20
980
- }),
981
- children: "Add an Account"
982
- })]
983
- });
1292
+ const [o, l] = H.useState(!1), s = () => l(!0), c = () => l(!1);
1293
+ return /* @__PURE__ */ v(N, { children: [
1294
+ /* @__PURE__ */ r(ne, { overflow: "inside", opened: o, onClose: () => l(!1), title: "Add an Account", trapFocus: !0, onDragStart: (p) => {
1295
+ p.stopPropagation();
1296
+ }, children: /* @__PURE__ */ r(zt, { postSubmit: () => {
1297
+ t(), c();
1298
+ }, styles: n, initialRoleID: i }) }),
1299
+ /* @__PURE__ */ r(T, { size: n.button.size, onClick: s, leftIcon: /* @__PURE__ */ r(De, { size: 20 }), children: "Add an Account" })
1300
+ ] });
984
1301
  }
985
- function Ne({
1302
+ function At({
986
1303
  id: t,
987
1304
  name: n,
988
- onSuccess: r,
989
- styles: i = y
1305
+ onSuccess: i,
1306
+ styles: o = $
990
1307
  }) {
991
- const s = j(), o = async () => {
992
- if (!!t) {
993
- _({
1308
+ const l = fe(), s = async () => {
1309
+ if (t) {
1310
+ V({
994
1311
  id: "for-deleting",
995
1312
  title: "Pending",
996
1313
  message: "Deleting account...",
997
1314
  loading: !0
998
1315
  });
999
1316
  try {
1000
- await P.account.delete(t), S({
1317
+ await j.account.delete(t), x({
1001
1318
  id: "for-deleting",
1002
1319
  title: "Successful",
1003
1320
  message: `Account [${n}] is deleted`,
1004
1321
  color: "green"
1005
- }), r();
1006
- } catch (c) {
1007
- S({
1322
+ }), i();
1323
+ } catch (d) {
1324
+ x({
1008
1325
  id: "for-deleting",
1009
1326
  title: "Failed",
1010
- message: c.message,
1327
+ message: d.message,
1011
1328
  color: "red"
1012
1329
  });
1013
1330
  }
1014
1331
  }
1015
- }, a = () => s.openConfirmModal({
1332
+ }, c = () => l.openConfirmModal({
1016
1333
  title: "Delete this account?",
1017
1334
  labels: {
1018
1335
  confirm: "Confirm",
1019
1336
  cancel: "Cancel"
1020
1337
  },
1021
1338
  onCancel: () => console.log("Cancel"),
1022
- onConfirm: o
1023
- });
1024
- return /* @__PURE__ */ e(b, {
1025
- size: i.button.size,
1026
- color: "red",
1027
- onClick: a,
1028
- leftIcon: /* @__PURE__ */ e(W, {
1029
- size: 20
1030
- }),
1031
- children: "Delete"
1339
+ onConfirm: s
1032
1340
  });
1341
+ return /* @__PURE__ */ r(T, { size: o.button.size, color: "red", onClick: c, leftIcon: /* @__PURE__ */ r(je, { size: 20 }), children: "Delete" });
1033
1342
  }
1034
- function Ke({
1343
+ function xt({
1035
1344
  id: t,
1036
1345
  name: n,
1037
- email: r,
1038
- role_id: i,
1039
- postSubmit: s,
1040
- styles: o = y
1346
+ email: i,
1347
+ role_id: o,
1348
+ postSubmit: l,
1349
+ styles: s = $
1041
1350
  }) {
1042
1351
  const {
1043
- control: a,
1044
- handleSubmit: c,
1352
+ control: c,
1353
+ handleSubmit: d,
1045
1354
  watch: p
1046
- } = q({
1355
+ } = J({
1047
1356
  defaultValues: {
1048
1357
  name: n,
1049
- email: r,
1050
- role_id: i,
1358
+ email: i,
1359
+ role_id: o,
1051
1360
  reset_password: !1,
1052
1361
  new_password: ""
1053
1362
  }
1054
- }), g = async ({
1055
- name: l,
1056
- email: A,
1057
- role_id: k,
1058
- reset_password: x,
1059
- new_password: ne
1363
+ }), b = async ({
1364
+ name: _,
1365
+ email: k,
1366
+ role_id: q,
1367
+ reset_password: he,
1368
+ new_password: me
1060
1369
  }) => {
1061
1370
  try {
1062
- _({
1371
+ V({
1063
1372
  id: "for-updating",
1064
1373
  title: "Pending",
1065
1374
  message: "Updating account...",
1066
1375
  loading: !0
1067
- }), await P.account.edit({
1376
+ }), await j.account.edit({
1068
1377
  id: t,
1069
- name: l,
1070
- email: A,
1071
- role_id: k,
1072
- reset_password: x,
1073
- new_password: ne
1074
- }), S({
1378
+ name: _,
1379
+ email: k,
1380
+ role_id: q,
1381
+ reset_password: he,
1382
+ new_password: me
1383
+ }), x({
1075
1384
  id: "for-updating",
1076
1385
  title: "Successful",
1077
1386
  message: "Account is updated",
1078
1387
  color: "green"
1079
- }), s();
1080
- } catch (re) {
1081
- S({
1388
+ }), l();
1389
+ } catch (U) {
1390
+ x({
1082
1391
  id: "for-updating",
1083
1392
  title: "Failed",
1084
- message: re.message,
1393
+ message: U.message,
1085
1394
  color: "red"
1086
1395
  });
1087
1396
  }
1088
- }, [h, u] = p(["reset_password", "new_password"]);
1089
- return /* @__PURE__ */ e(v, {
1090
- mx: "auto",
1091
- children: /* @__PURE__ */ d("form", {
1092
- onSubmit: c(g),
1093
- children: [/* @__PURE__ */ e(m, {
1094
- name: "name",
1095
- control: a,
1096
- render: ({
1097
- field: l
1098
- }) => /* @__PURE__ */ e(z, {
1099
- mb: o.spacing,
1100
- size: o.size,
1101
- required: !0,
1102
- label: "Username",
1103
- ...l
1104
- })
1105
- }), /* @__PURE__ */ e(m, {
1106
- name: "email",
1107
- control: a,
1108
- render: ({
1109
- field: l
1110
- }) => /* @__PURE__ */ e(z, {
1111
- mb: o.spacing,
1112
- size: o.size,
1113
- required: !0,
1114
- label: "Email",
1115
- ...l
1116
- })
1117
- }), /* @__PURE__ */ e(m, {
1118
- name: "role_id",
1119
- control: a,
1120
- render: ({
1121
- field: l
1122
- }) => /* @__PURE__ */ e(Y, {
1123
- styles: o,
1124
- ...l
1125
- })
1126
- }), /* @__PURE__ */ e(V, {
1127
- my: 20,
1128
- variant: "dashed",
1129
- label: "",
1130
- labelPosition: "center"
1131
- }), /* @__PURE__ */ e(m, {
1132
- name: "reset_password",
1133
- control: a,
1134
- render: ({
1135
- field: l
1136
- }) => /* @__PURE__ */ e(de, {
1137
- mb: o.spacing,
1138
- size: o.size,
1139
- label: "Reset password",
1140
- checked: l.value,
1141
- onChange: (A) => l.onChange(A.currentTarget.checked),
1142
- styles: {
1143
- label: {
1144
- verticalAlign: "middle"
1145
- }
1146
- }
1147
- })
1148
- }), h && /* @__PURE__ */ e(m, {
1397
+ }, [f, h] = p(["reset_password", "new_password"]);
1398
+ return /* @__PURE__ */ r(I, { mx: "auto", children: /* @__PURE__ */ v("form", { onSubmit: d(b), children: [
1399
+ /* @__PURE__ */ r(R, { name: "name", control: c, render: ({
1400
+ field: _
1401
+ }) => /* @__PURE__ */ r(D, { mb: s.spacing, size: s.size, required: !0, label: "Username", ..._ }) }),
1402
+ /* @__PURE__ */ r(R, { name: "email", control: c, render: ({
1403
+ field: _
1404
+ }) => /* @__PURE__ */ r(D, { mb: s.spacing, size: s.size, required: !0, label: "Email", ..._ }) }),
1405
+ /* @__PURE__ */ r(R, { name: "role_id", control: c, render: ({
1406
+ field: _
1407
+ }) => /* @__PURE__ */ r(Ie, { styles: s, ..._ }) }),
1408
+ /* @__PURE__ */ r(Oe, { my: 20, variant: "dashed", label: "", labelPosition: "center" }),
1409
+ /* @__PURE__ */ r(R, { name: "reset_password", control: c, render: ({
1410
+ field: _
1411
+ }) => /* @__PURE__ */ r(Jr, { mb: s.spacing, size: s.size, label: "Reset password", checked: _.value, onChange: (k) => _.onChange(k.currentTarget.checked), styles: {
1412
+ label: {
1413
+ verticalAlign: "middle"
1414
+ }
1415
+ } }) }),
1416
+ f && /* @__PURE__ */ r(
1417
+ R,
1418
+ {
1149
1419
  name: "new_password",
1150
- control: a,
1420
+ control: c,
1151
1421
  render: ({
1152
- field: l
1153
- }) => /* @__PURE__ */ e(F, {
1154
- autoComplete: "off",
1155
- mb: o.spacing,
1156
- size: o.size,
1157
- required: !0,
1158
- description: "Password must be at least 8 characters long",
1159
- label: "New Password",
1160
- ...l
1161
- })
1162
- }), /* @__PURE__ */ e(w, {
1163
- position: "right",
1164
- mt: o.spacing,
1165
- children: /* @__PURE__ */ e(b, {
1166
- type: "submit",
1167
- size: o.button.size,
1168
- children: "Submit"
1169
- })
1170
- })]
1171
- })
1172
- });
1422
+ field: _
1423
+ }) => /* @__PURE__ */ r(de, { autoComplete: "off", mb: s.spacing, size: s.size, required: !0, description: "Password must be at least 8 characters long", label: "New Password", ..._ })
1424
+ }
1425
+ ),
1426
+ /* @__PURE__ */ r(z, { position: "right", mt: s.spacing, children: /* @__PURE__ */ r(T, { type: "submit", size: s.button.size, children: "Submit" }) })
1427
+ ] }) });
1173
1428
  }
1174
- function Ve({
1429
+ function kt({
1175
1430
  account: t,
1176
1431
  onSuccess: n,
1177
- styles: r = y
1432
+ styles: i = $
1178
1433
  }) {
1179
- const [i, s] = E.useState(!1), o = () => s(!0), a = () => s(!1), c = () => {
1180
- n(), a();
1434
+ const [o, l] = H.useState(!1), s = () => l(!0), c = () => l(!1), d = () => {
1435
+ n(), c();
1181
1436
  };
1182
- return /* @__PURE__ */ d(C, {
1183
- children: [/* @__PURE__ */ e(R, {
1184
- overflow: "inside",
1185
- opened: i,
1186
- onClose: () => s(!1),
1187
- title: `Editing ${t.name}`,
1188
- trapFocus: !0,
1189
- onDragStart: (p) => {
1190
- p.stopPropagation();
1191
- },
1192
- children: /* @__PURE__ */ e(Ke, {
1193
- ...t,
1194
- postSubmit: c,
1195
- styles: r
1196
- })
1197
- }), /* @__PURE__ */ e(b, {
1198
- size: r.button.size,
1199
- onClick: o,
1200
- leftIcon: /* @__PURE__ */ e(ge, {
1201
- size: 20
1202
- }),
1203
- children: "Edit"
1204
- })]
1205
- });
1437
+ return /* @__PURE__ */ v(N, { children: [
1438
+ /* @__PURE__ */ r(ne, { overflow: "inside", opened: o, onClose: () => l(!1), title: `Editing ${t.name}`, trapFocus: !0, onDragStart: (p) => {
1439
+ p.stopPropagation();
1440
+ }, children: /* @__PURE__ */ r(xt, { ...t, postSubmit: d, styles: i }) }),
1441
+ /* @__PURE__ */ r(T, { size: i.button.size, onClick: s, leftIcon: /* @__PURE__ */ r(Zr, { size: 20 }), children: "Edit" })
1442
+ ] });
1206
1443
  }
1207
- function at({
1208
- styles: t = y,
1444
+ function Ht({
1445
+ styles: t = $,
1209
1446
  config: n
1210
1447
  }) {
1211
- var g, h;
1212
- M(n);
1448
+ var b;
1449
+ pe(n);
1213
1450
  const {
1214
- data: r = [],
1215
- loading: i,
1216
- refresh: s
1217
- } = T(async () => {
1451
+ data: i = [],
1452
+ loading: o,
1453
+ refresh: l
1454
+ } = G(async () => {
1218
1455
  const {
1219
- data: u
1220
- } = await P.account.list();
1221
- return u;
1456
+ data: f
1457
+ } = await j.account.list();
1458
+ return f;
1222
1459
  }, {
1223
1460
  refreshDeps: []
1224
1461
  }), {
1225
- data: o = [],
1226
- loading: a
1227
- } = T(async () => (await P.role.list()).map((l) => ({
1228
- label: l.name,
1229
- value: l.id,
1230
- description: l.description,
1231
- disabled: l.id === 50
1462
+ data: s = [],
1463
+ loading: c
1464
+ } = G(async () => (await j.role.list()).map((h) => ({
1465
+ label: h.name,
1466
+ value: h.id,
1467
+ description: h.description,
1468
+ disabled: h.id === 50
1469
+ // SUPERADMIN
1232
1470
  })), {
1233
1471
  refreshDeps: []
1234
- }), c = te(() => o.reduce((u, l) => (u.set(l.value, l.label), u), /* @__PURE__ */ new Map()), [o]), p = (u) => {
1235
- var l;
1236
- return (l = c.get(u)) != null ? l : u;
1237
- };
1238
- return /* @__PURE__ */ d(C, {
1239
- children: [/* @__PURE__ */ e(w, {
1240
- pt: t.spacing,
1241
- position: "right",
1242
- children: /* @__PURE__ */ e(Ue, {
1243
- onSuccess: s,
1244
- initialRoleID: (h = (g = o == null ? void 0 : o[0]) == null ? void 0 : g.value) != null ? h : 0
1245
- })
1246
- }), /* @__PURE__ */ d(v, {
1247
- mt: t.spacing,
1248
- sx: {
1249
- position: "relative"
1250
- },
1251
- children: [/* @__PURE__ */ e(H, {
1252
- visible: i || a
1253
- }), /* @__PURE__ */ d($, {
1254
- horizontalSpacing: t.spacing,
1255
- verticalSpacing: t.spacing,
1256
- fontSize: t.size,
1257
- highlightOnHover: !0,
1258
- children: [/* @__PURE__ */ e("thead", {
1259
- children: /* @__PURE__ */ d("tr", {
1260
- children: [/* @__PURE__ */ e("th", {
1261
- children: "Username"
1262
- }), /* @__PURE__ */ e("th", {
1263
- children: "Email"
1264
- }), /* @__PURE__ */ e("th", {
1265
- children: "Role"
1266
- }), /* @__PURE__ */ e("th", {
1267
- children: "Action"
1268
- })]
1269
- })
1270
- }), /* @__PURE__ */ e("tbody", {
1271
- children: r.map((u) => {
1272
- const {
1273
- id: l,
1274
- name: A,
1275
- email: k,
1276
- role_id: x
1277
- } = u;
1278
- return /* @__PURE__ */ d("tr", {
1279
- children: [/* @__PURE__ */ e("td", {
1280
- width: 200,
1281
- children: A
1282
- }), /* @__PURE__ */ e("td", {
1283
- width: 200,
1284
- children: k
1285
- }), /* @__PURE__ */ e("td", {
1286
- width: 200,
1287
- children: p(x)
1288
- }), /* @__PURE__ */ e("td", {
1289
- width: 200,
1290
- children: /* @__PURE__ */ d(w, {
1291
- position: "left",
1292
- children: [/* @__PURE__ */ e(Ve, {
1293
- account: u,
1294
- onSuccess: s
1295
- }), /* @__PURE__ */ e(Ne, {
1296
- id: l,
1297
- name: A,
1298
- onSuccess: s
1299
- })]
1300
- })
1301
- })]
1302
- }, l);
1303
- })
1304
- })]
1305
- })]
1306
- })]
1307
- });
1472
+ }), d = ur(() => s.reduce((f, h) => (f.set(h.value, h.label), f), /* @__PURE__ */ new Map()), [s]), p = (f) => d.get(f) ?? f;
1473
+ return /* @__PURE__ */ v(N, { children: [
1474
+ /* @__PURE__ */ r(z, { pt: t.spacing, position: "right", children: /* @__PURE__ */ r(Ot, { onSuccess: l, initialRoleID: ((b = s == null ? void 0 : s[0]) == null ? void 0 : b.value) ?? 0 }) }),
1475
+ /* @__PURE__ */ v(I, { mt: t.spacing, sx: {
1476
+ position: "relative"
1477
+ }, children: [
1478
+ /* @__PURE__ */ r(xe, { visible: o || c }),
1479
+ /* @__PURE__ */ v(ke, { horizontalSpacing: t.spacing, verticalSpacing: t.spacing, fontSize: t.size, highlightOnHover: !0, children: [
1480
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ v("tr", { children: [
1481
+ /* @__PURE__ */ r("th", { children: "Username" }),
1482
+ /* @__PURE__ */ r("th", { children: "Email" }),
1483
+ /* @__PURE__ */ r("th", { children: "Role" }),
1484
+ /* @__PURE__ */ r("th", { children: "Action" })
1485
+ ] }) }),
1486
+ /* @__PURE__ */ r("tbody", { children: i.map((f) => {
1487
+ const {
1488
+ id: h,
1489
+ name: _,
1490
+ email: k,
1491
+ role_id: q
1492
+ } = f;
1493
+ return /* @__PURE__ */ v("tr", { children: [
1494
+ /* @__PURE__ */ r("td", { width: 200, children: _ }),
1495
+ /* @__PURE__ */ r("td", { width: 200, children: k }),
1496
+ /* @__PURE__ */ r("td", { width: 200, children: p(q) }),
1497
+ /* @__PURE__ */ r("td", { width: 200, children: /* @__PURE__ */ v(z, { position: "left", children: [
1498
+ /* @__PURE__ */ r(kt, { account: f, onSuccess: l }),
1499
+ /* @__PURE__ */ r(At, { id: h, name: _, onSuccess: l })
1500
+ ] }) })
1501
+ ] }, h);
1502
+ }) })
1503
+ ] })
1504
+ ] })
1505
+ ] });
1308
1506
  }
1309
- function Be({
1507
+ function Dt({
1310
1508
  postSubmit: t,
1311
- styles: n = y
1509
+ styles: n = $
1312
1510
  }) {
1313
1511
  const {
1314
- control: r,
1315
- handleSubmit: i
1316
- } = q({
1512
+ control: i,
1513
+ handleSubmit: o
1514
+ } = J({
1317
1515
  defaultValues: {
1318
1516
  name: "",
1319
1517
  password: ""
1320
1518
  }
1321
1519
  });
1322
- return /* @__PURE__ */ e(v, {
1323
- mx: "auto",
1324
- children: /* @__PURE__ */ d("form", {
1325
- onSubmit: i(async ({
1326
- name: o,
1327
- password: a
1328
- }) => {
1329
- try {
1330
- _({
1331
- id: "for-login",
1332
- title: "Pending",
1333
- message: "Loggin in...",
1334
- loading: !0
1335
- });
1336
- const c = await P.account.login(o, a);
1337
- window.localStorage.setItem("token", c.token), S({
1338
- id: "for-login",
1339
- title: "Successful",
1340
- message: "Logged in",
1341
- color: "green"
1342
- }), t(c);
1343
- } catch (c) {
1344
- S({
1345
- id: "for-login",
1346
- title: "Login Failed",
1347
- message: c.message,
1348
- color: "red"
1349
- });
1350
- }
1351
- }),
1352
- children: [/* @__PURE__ */ e(m, {
1353
- name: "name",
1354
- control: r,
1355
- render: ({
1356
- field: o
1357
- }) => /* @__PURE__ */ e(z, {
1358
- mb: n.spacing,
1359
- size: n.size,
1360
- required: !0,
1361
- label: "Username",
1362
- ...o
1363
- })
1364
- }), /* @__PURE__ */ e(m, {
1365
- name: "password",
1366
- control: r,
1367
- render: ({
1368
- field: o
1369
- }) => /* @__PURE__ */ e(F, {
1370
- mb: n.spacing,
1371
- size: n.size,
1372
- required: !0,
1373
- label: "Password",
1374
- ...o
1375
- })
1376
- }), /* @__PURE__ */ e(w, {
1377
- position: "right",
1378
- mt: n.spacing,
1379
- children: /* @__PURE__ */ e(b, {
1380
- type: "submit",
1381
- size: n.button.size,
1382
- children: "Submit"
1383
- })
1384
- })]
1385
- })
1386
- });
1520
+ return /* @__PURE__ */ r(I, { mx: "auto", children: /* @__PURE__ */ v("form", { onSubmit: o(async ({
1521
+ name: s,
1522
+ password: c
1523
+ }) => {
1524
+ try {
1525
+ V({
1526
+ id: "for-login",
1527
+ title: "Pending",
1528
+ message: "Loggin in...",
1529
+ loading: !0
1530
+ });
1531
+ const d = await j.account.login(s, c);
1532
+ window.localStorage.setItem("token", d.token), x({
1533
+ id: "for-login",
1534
+ title: "Successful",
1535
+ message: "Logged in",
1536
+ color: "green"
1537
+ }), t(d);
1538
+ } catch (d) {
1539
+ x({
1540
+ id: "for-login",
1541
+ title: "Login Failed",
1542
+ message: d.message,
1543
+ color: "red"
1544
+ });
1545
+ }
1546
+ }), children: [
1547
+ /* @__PURE__ */ r(R, { name: "name", control: i, render: ({
1548
+ field: s
1549
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Username", ...s }) }),
1550
+ /* @__PURE__ */ r(R, { name: "password", control: i, render: ({
1551
+ field: s
1552
+ }) => /* @__PURE__ */ r(de, { mb: n.spacing, size: n.size, required: !0, label: "Password", ...s }) }),
1553
+ /* @__PURE__ */ r(z, { position: "right", mt: n.spacing, children: /* @__PURE__ */ r(T, { type: "submit", size: n.button.size, children: "Submit" }) })
1554
+ ] }) });
1387
1555
  }
1388
- function st({
1389
- styles: t = y,
1556
+ function Jt({
1557
+ styles: t = $,
1390
1558
  config: n,
1391
- onSuccess: r
1559
+ onSuccess: i
1392
1560
  }) {
1393
- return M(n), /* @__PURE__ */ e(C, {
1394
- children: /* @__PURE__ */ e(v, {
1395
- mt: t.spacing,
1396
- sx: {
1397
- position: "relative"
1398
- },
1399
- children: /* @__PURE__ */ e(Be, {
1400
- styles: t,
1401
- postSubmit: r
1402
- })
1403
- })
1404
- });
1561
+ return pe(n), /* @__PURE__ */ r(N, { children: /* @__PURE__ */ r(I, { mt: t.spacing, sx: {
1562
+ position: "relative"
1563
+ }, children: /* @__PURE__ */ r(Dt, { styles: t, postSubmit: i }) }) });
1405
1564
  }
1406
- const U = {
1565
+ const ge = {
1407
1566
  size: "sm",
1408
1567
  spacing: "md",
1409
1568
  button: {
1410
1569
  size: "xs"
1411
1570
  }
1412
1571
  };
1413
- function He({
1572
+ function jt({
1414
1573
  postSubmit: t,
1415
- styles: n = U,
1416
- initialRoleID: r
1574
+ styles: n = ge,
1575
+ initialRoleID: i
1417
1576
  }) {
1418
1577
  const {
1419
- control: i,
1420
- handleSubmit: s
1421
- } = q({
1578
+ control: o,
1579
+ handleSubmit: l
1580
+ } = J({
1422
1581
  defaultValues: {
1423
1582
  name: "",
1424
- role_id: r
1583
+ role_id: i
1425
1584
  }
1426
1585
  });
1427
- return /* @__PURE__ */ e(v, {
1428
- mx: "auto",
1429
- children: /* @__PURE__ */ d("form", {
1430
- onSubmit: s(async ({
1431
- name: a,
1432
- role_id: c
1433
- }) => {
1434
- try {
1435
- _({
1436
- id: "for-creating",
1437
- title: "Pending",
1438
- message: "Adding API Key...",
1439
- loading: !0
1440
- });
1441
- const {
1442
- app_id: p,
1443
- app_secret: g
1444
- } = await P.api_key.create(a, c);
1445
- S({
1446
- id: "for-creating",
1447
- title: "Successful",
1448
- message: "API Key is added",
1449
- color: "green"
1450
- }), t(p, g);
1451
- } catch (p) {
1452
- S({
1453
- id: "for-creating",
1454
- title: "Failed",
1455
- message: p.message,
1456
- color: "red"
1457
- });
1458
- }
1459
- }),
1460
- children: [/* @__PURE__ */ e(m, {
1461
- name: "name",
1462
- control: i,
1463
- render: ({
1464
- field: a
1465
- }) => /* @__PURE__ */ e(z, {
1466
- mb: n.spacing,
1467
- size: n.size,
1468
- required: !0,
1469
- label: "Name",
1470
- ...a
1471
- })
1472
- }), /* @__PURE__ */ e(m, {
1473
- name: "role_id",
1474
- control: i,
1475
- render: ({
1476
- field: a
1477
- }) => /* @__PURE__ */ e(Y, {
1478
- styles: n,
1479
- ...a
1480
- })
1481
- }), /* @__PURE__ */ e(w, {
1482
- position: "right",
1483
- mt: n.spacing,
1484
- children: /* @__PURE__ */ e(b, {
1485
- type: "submit",
1486
- size: n.button.size,
1487
- children: "Save"
1488
- })
1489
- })]
1490
- })
1491
- });
1586
+ return /* @__PURE__ */ r(I, { mx: "auto", children: /* @__PURE__ */ v("form", { onSubmit: l(async ({
1587
+ name: c,
1588
+ role_id: d
1589
+ }) => {
1590
+ try {
1591
+ V({
1592
+ id: "for-creating",
1593
+ title: "Pending",
1594
+ message: "Adding API Key...",
1595
+ loading: !0
1596
+ });
1597
+ const {
1598
+ app_id: p,
1599
+ app_secret: b
1600
+ } = await j.api_key.create(c, d);
1601
+ x({
1602
+ id: "for-creating",
1603
+ title: "Successful",
1604
+ message: "API Key is added",
1605
+ color: "green"
1606
+ }), t(p, b);
1607
+ } catch (p) {
1608
+ x({
1609
+ id: "for-creating",
1610
+ title: "Failed",
1611
+ message: p.message,
1612
+ color: "red"
1613
+ });
1614
+ }
1615
+ }), children: [
1616
+ /* @__PURE__ */ r(R, { name: "name", control: o, render: ({
1617
+ field: c
1618
+ }) => /* @__PURE__ */ r(D, { mb: n.spacing, size: n.size, required: !0, label: "Name", ...c }) }),
1619
+ /* @__PURE__ */ r(R, { name: "role_id", control: o, render: ({
1620
+ field: c
1621
+ }) => /* @__PURE__ */ r(Ie, { styles: n, ...c }) }),
1622
+ /* @__PURE__ */ r(z, { position: "right", mt: n.spacing, children: /* @__PURE__ */ r(T, { type: "submit", size: n.button.size, children: "Save" }) })
1623
+ ] }) });
1492
1624
  }
1493
- function $e({
1625
+ function It({
1494
1626
  onSuccess: t,
1495
- styles: n = U,
1496
- initialRoleID: r
1627
+ styles: n = ge,
1628
+ initialRoleID: i
1497
1629
  }) {
1498
- const i = j(), [s, o] = E.useState(!1), a = () => o(!0), c = () => o(!1);
1499
- return /* @__PURE__ */ d(C, {
1500
- children: [/* @__PURE__ */ e(R, {
1501
- overflow: "inside",
1502
- opened: s,
1503
- onClose: () => o(!1),
1504
- title: "Add an API Key",
1505
- trapFocus: !0,
1506
- onDragStart: (g) => {
1507
- g.stopPropagation();
1508
- },
1509
- children: /* @__PURE__ */ e(He, {
1510
- postSubmit: (g, h) => {
1511
- c(), i.openModal({
1512
- title: "API Key is generated",
1513
- children: /* @__PURE__ */ d(B, {
1514
- children: [/* @__PURE__ */ e(L, {
1515
- color: "dimmed",
1516
- children: "Make sure you save it - you won't be able to access it again."
1517
- }), /* @__PURE__ */ e(z, {
1518
- defaultValue: g,
1519
- disabled: !0,
1520
- label: "APP ID",
1521
- styles: {
1522
- input: {
1523
- cursor: "text !important"
1524
- }
1525
- }
1526
- }), /* @__PURE__ */ e(z, {
1527
- defaultValue: h,
1528
- disabled: !0,
1529
- label: "APP Secret",
1530
- styles: {
1531
- input: {
1532
- cursor: "text !important"
1533
- }
1534
- }
1535
- }), /* @__PURE__ */ e(b, {
1536
- size: "sm",
1537
- onClick: () => {
1538
- Se();
1539
- },
1540
- children: "I've saved this API Key"
1541
- })]
1542
- }),
1543
- onClose: () => {
1544
- t();
1630
+ const o = fe(), [l, s] = H.useState(!1), c = () => s(!0), d = () => s(!1);
1631
+ return /* @__PURE__ */ v(N, { children: [
1632
+ /* @__PURE__ */ r(ne, { overflow: "inside", opened: l, onClose: () => s(!1), title: "Add an API Key", trapFocus: !0, onDragStart: (b) => {
1633
+ b.stopPropagation();
1634
+ }, children: /* @__PURE__ */ r(jt, { postSubmit: (b, f) => {
1635
+ d(), o.openModal({
1636
+ title: "API Key is generated",
1637
+ children: /* @__PURE__ */ v(Ae, { children: [
1638
+ /* @__PURE__ */ r(ue, { color: "dimmed", children: "Make sure you save it - you won't be able to access it again." }),
1639
+ /* @__PURE__ */ r(D, { defaultValue: b, disabled: !0, label: "APP ID", styles: {
1640
+ input: {
1641
+ cursor: "text !important"
1545
1642
  }
1546
- });
1547
- },
1548
- styles: n,
1549
- initialRoleID: r
1550
- })
1551
- }), /* @__PURE__ */ e(b, {
1552
- size: n.button.size,
1553
- onClick: a,
1554
- leftIcon: /* @__PURE__ */ e(Q, {
1555
- size: 20
1556
- }),
1557
- children: "Add an API Key"
1558
- })]
1559
- });
1643
+ } }),
1644
+ /* @__PURE__ */ r(D, { defaultValue: f, disabled: !0, label: "APP Secret", styles: {
1645
+ input: {
1646
+ cursor: "text !important"
1647
+ }
1648
+ } }),
1649
+ /* @__PURE__ */ r(T, { size: "sm", onClick: () => {
1650
+ it();
1651
+ }, children: "I've saved this API Key" })
1652
+ ] }),
1653
+ onClose: () => {
1654
+ t();
1655
+ }
1656
+ });
1657
+ }, styles: n, initialRoleID: i }) }),
1658
+ /* @__PURE__ */ r(T, { size: n.button.size, onClick: c, leftIcon: /* @__PURE__ */ r(De, { size: 20 }), children: "Add an API Key" })
1659
+ ] });
1560
1660
  }
1561
- function Ge({
1661
+ function Ft({
1562
1662
  id: t,
1563
1663
  name: n,
1564
- onSuccess: r,
1565
- styles: i = U
1664
+ onSuccess: i,
1665
+ styles: o = ge
1566
1666
  }) {
1567
- const s = j(), o = async () => {
1568
- if (!!t) {
1569
- _({
1667
+ const l = fe(), s = async () => {
1668
+ if (t) {
1669
+ V({
1570
1670
  id: "for-deleting",
1571
1671
  title: "Pending",
1572
1672
  message: "Deleting API Key...",
1573
1673
  loading: !0
1574
1674
  });
1575
1675
  try {
1576
- await P.api_key.delete(t), S({
1676
+ await j.api_key.delete(t), x({
1577
1677
  id: "for-deleting",
1578
1678
  title: "Successful",
1579
1679
  message: `API Key [${n}] is deleted`,
1580
1680
  color: "green"
1581
- }), r();
1582
- } catch (c) {
1583
- S({
1681
+ }), i();
1682
+ } catch (d) {
1683
+ x({
1584
1684
  id: "for-deleting",
1585
1685
  title: "Failed",
1586
- message: c.message,
1686
+ message: d.message,
1587
1687
  color: "red"
1588
1688
  });
1589
1689
  }
1590
1690
  }
1591
- }, a = () => s.openConfirmModal({
1691
+ }, c = () => l.openConfirmModal({
1592
1692
  title: "Delete this api-key?",
1593
1693
  labels: {
1594
1694
  confirm: "Confirm",
1595
1695
  cancel: "Cancel"
1596
1696
  },
1597
1697
  onCancel: () => console.log("Cancel"),
1598
- onConfirm: o
1599
- });
1600
- return /* @__PURE__ */ e(b, {
1601
- size: i.button.size,
1602
- color: "red",
1603
- onClick: a,
1604
- leftIcon: /* @__PURE__ */ e(W, {
1605
- size: 20
1606
- }),
1607
- children: "Delete"
1698
+ onConfirm: s
1608
1699
  });
1700
+ return /* @__PURE__ */ r(T, { size: o.button.size, color: "red", onClick: c, leftIcon: /* @__PURE__ */ r(je, { size: 20 }), children: "Delete" });
1609
1701
  }
1610
- function ct({
1611
- styles: t = U,
1702
+ function Xt({
1703
+ styles: t = ge,
1612
1704
  config: n
1613
1705
  }) {
1614
- var g, h;
1615
- M(n);
1706
+ var b;
1707
+ pe(n);
1616
1708
  const {
1617
- data: r = [],
1618
- loading: i,
1619
- refresh: s
1620
- } = T(async () => {
1709
+ data: i = [],
1710
+ loading: o,
1711
+ refresh: l
1712
+ } = G(async () => {
1621
1713
  const {
1622
- data: u
1623
- } = await P.api_key.list();
1624
- return u;
1714
+ data: f
1715
+ } = await j.api_key.list();
1716
+ return f;
1625
1717
  }, {
1626
1718
  refreshDeps: []
1627
1719
  }), {
1628
- data: o = [],
1629
- loading: a
1630
- } = T(async () => (await P.role.list()).map((l) => ({
1631
- label: l.name,
1632
- value: l.id,
1633
- description: l.description,
1634
- disabled: l.id === 50
1720
+ data: s = [],
1721
+ loading: c
1722
+ } = G(async () => (await j.role.list()).map((h) => ({
1723
+ label: h.name,
1724
+ value: h.id,
1725
+ description: h.description,
1726
+ disabled: h.id === 50
1727
+ // SUPERADMIN
1635
1728
  })), {
1636
1729
  refreshDeps: []
1637
- }), c = te(() => o.reduce((u, l) => (u.set(l.value, l.label), u), /* @__PURE__ */ new Map()), [o]), p = (u) => {
1638
- var l;
1639
- return (l = c.get(u)) != null ? l : u;
1640
- };
1641
- return /* @__PURE__ */ d(C, {
1642
- children: [/* @__PURE__ */ e(w, {
1643
- pt: t.spacing,
1644
- position: "right",
1645
- children: /* @__PURE__ */ e($e, {
1646
- onSuccess: s,
1647
- initialRoleID: (h = (g = o == null ? void 0 : o[0]) == null ? void 0 : g.value) != null ? h : 0
1648
- })
1649
- }), /* @__PURE__ */ d(v, {
1650
- mt: t.spacing,
1651
- sx: {
1652
- position: "relative"
1653
- },
1654
- children: [/* @__PURE__ */ e(H, {
1655
- visible: i || a
1656
- }), /* @__PURE__ */ d($, {
1657
- horizontalSpacing: t.spacing,
1658
- verticalSpacing: t.spacing,
1659
- fontSize: t.size,
1660
- highlightOnHover: !0,
1661
- children: [/* @__PURE__ */ e("thead", {
1662
- children: /* @__PURE__ */ d("tr", {
1663
- children: [/* @__PURE__ */ e("th", {
1664
- children: "Name"
1665
- }), /* @__PURE__ */ e("th", {
1666
- children: "APP ID"
1667
- }), /* @__PURE__ */ e("th", {
1668
- children: "Role"
1669
- }), /* @__PURE__ */ e("th", {
1670
- children: "Action"
1671
- })]
1672
- })
1673
- }), /* @__PURE__ */ e("tbody", {
1674
- children: r.map((u) => {
1675
- const {
1676
- id: l,
1677
- name: A,
1678
- app_id: k,
1679
- role_id: x
1680
- } = u;
1681
- return /* @__PURE__ */ d("tr", {
1682
- children: [/* @__PURE__ */ e("td", {
1683
- width: 200,
1684
- children: A
1685
- }), /* @__PURE__ */ e("td", {
1686
- width: 200,
1687
- children: k
1688
- }), /* @__PURE__ */ e("td", {
1689
- width: 200,
1690
- children: p(x)
1691
- }), /* @__PURE__ */ e("td", {
1692
- width: 200,
1693
- children: /* @__PURE__ */ e(w, {
1694
- position: "left",
1695
- children: /* @__PURE__ */ e(Ge, {
1696
- id: l,
1697
- name: A,
1698
- onSuccess: s
1699
- })
1700
- })
1701
- })]
1702
- }, l);
1703
- })
1704
- })]
1705
- })]
1706
- })]
1707
- });
1730
+ }), d = ur(() => s.reduce((f, h) => (f.set(h.value, h.label), f), /* @__PURE__ */ new Map()), [s]), p = (f) => d.get(f) ?? f;
1731
+ return /* @__PURE__ */ v(N, { children: [
1732
+ /* @__PURE__ */ r(z, { pt: t.spacing, position: "right", children: /* @__PURE__ */ r(It, { onSuccess: l, initialRoleID: ((b = s == null ? void 0 : s[0]) == null ? void 0 : b.value) ?? 0 }) }),
1733
+ /* @__PURE__ */ v(I, { mt: t.spacing, sx: {
1734
+ position: "relative"
1735
+ }, children: [
1736
+ /* @__PURE__ */ r(xe, { visible: o || c }),
1737
+ /* @__PURE__ */ v(ke, { horizontalSpacing: t.spacing, verticalSpacing: t.spacing, fontSize: t.size, highlightOnHover: !0, children: [
1738
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ v("tr", { children: [
1739
+ /* @__PURE__ */ r("th", { children: "Name" }),
1740
+ /* @__PURE__ */ r("th", { children: "APP ID" }),
1741
+ /* @__PURE__ */ r("th", { children: "Role" }),
1742
+ /* @__PURE__ */ r("th", { children: "Action" })
1743
+ ] }) }),
1744
+ /* @__PURE__ */ r("tbody", { children: i.map((f) => {
1745
+ const {
1746
+ id: h,
1747
+ name: _,
1748
+ app_id: k,
1749
+ role_id: q
1750
+ } = f;
1751
+ return /* @__PURE__ */ v("tr", { children: [
1752
+ /* @__PURE__ */ r("td", { width: 200, children: _ }),
1753
+ /* @__PURE__ */ r("td", { width: 200, children: k }),
1754
+ /* @__PURE__ */ r("td", { width: 200, children: p(q) }),
1755
+ /* @__PURE__ */ r("td", { width: 200, children: /* @__PURE__ */ r(z, { position: "left", children: /* @__PURE__ */ r(Ft, { id: h, name: _, onSuccess: l }) }) })
1756
+ ] }, h);
1757
+ }) })
1758
+ ] })
1759
+ ] })
1760
+ ] });
1708
1761
  }
1709
- const lt = () => import("./package.5579293f.mjs").then(({
1762
+ const Qt = () => import("./package-580f3090.mjs").then(({
1710
1763
  version: t
1711
1764
  }) => (console.log(`[@devtable/dashboard] version: ${t}`), t));
1712
1765
  export {
1713
- ct as APIKeyList,
1714
- at as AccountList,
1715
- $e as AddAPIKey,
1716
- Ue as AddAccount,
1717
- xe as AddDataSource,
1718
- ot as DataSourceList,
1719
- Ge as DeleteAPIKey,
1720
- Ne as DeleteAccount,
1721
- Ee as DeleteDataSource,
1722
- st as Login,
1723
- lt as getVersion
1766
+ Xt as APIKeyList,
1767
+ Ht as AccountList,
1768
+ It as AddAPIKey,
1769
+ Ot as AddAccount,
1770
+ St as AddDataSource,
1771
+ Gt as DataSourceList,
1772
+ Ft as DeleteAPIKey,
1773
+ At as DeleteAccount,
1774
+ Ct as DeleteDataSource,
1775
+ Jt as Login,
1776
+ Qt as getVersion
1724
1777
  };