@devtable/settings-form 4.1.0 → 4.1.1

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,75 +1,58 @@
1
- import { Modal, Button, Box, SegmentedControl, TextInput, Divider, Group, NumberInput, PasswordInput, Text, LoadingOverlay, Table } from "@mantine/core";
2
- import { useForm, Controller } from "react-hook-form";
3
- import { showNotification, updateNotification } from "@mantine/notifications";
4
- import require$$0 from "react";
5
- import { PlaylistAdd, Trash } from "tabler-icons-react";
6
- import axios from "axios";
7
- import { useRequest } from "ahooks";
8
- import { useModals } from "@mantine/modals";
9
- const APIClient = {
1
+ import { Modal as Rr, Button as ie, Box as Ie, SegmentedControl as Er, TextInput as B, Divider as _r, Group as G, NumberInput as yr, PasswordInput as Sr, Text as Tr, LoadingOverlay as wr, Table as Cr } from "@mantine/core";
2
+ import { useForm as Pr, Controller as D } from "react-hook-form";
3
+ import { showNotification as ze, updateNotification as ae } from "@mantine/notifications";
4
+ import oe from "react";
5
+ import { PlaylistAdd as Or, Trash as xr } from "tabler-icons-react";
6
+ import jr from "axios";
7
+ import { useRequest as Dr } from "ahooks";
8
+ import { useModals as kr } from "@mantine/modals";
9
+ const $ = {
10
10
  baseURL: "http://localhost:31200",
11
- getRequest(method) {
12
- return (url, data, options = {}) => {
13
- const headers = {
11
+ getRequest(l) {
12
+ return (o, v, d = {}) => {
13
+ const _ = {
14
14
  "X-Requested-With": "XMLHttpRequest",
15
- "Content-Type": options.string ? "application/x-www-form-urlencoded" : "application/json",
16
- ...options.headers
17
- };
18
- const conf = {
15
+ "Content-Type": d.string ? "application/x-www-form-urlencoded" : "application/json",
16
+ ...d.headers
17
+ }, h = {
19
18
  baseURL: this.baseURL,
20
- method,
21
- url,
22
- params: method === "GET" ? data : options.params,
23
- headers
19
+ method: l,
20
+ url: o,
21
+ params: l === "GET" ? v : d.params,
22
+ headers: _
24
23
  };
25
- if (method === "POST") {
26
- conf.data = options.string ? JSON.stringify(data) : data;
27
- }
28
- return axios(conf).then((res) => {
29
- return res.data;
30
- }).catch((err) => {
31
- return Promise.reject(err);
32
- });
24
+ return l === "POST" && (h.data = d.string ? JSON.stringify(v) : v), jr(h).then((m) => m.data).catch((m) => Promise.reject(m));
33
25
  };
34
26
  }
35
- };
36
- const datasource = {
37
- list: async () => {
38
- const res = await APIClient.getRequest("POST")("/datasource/list", {
39
- filter: {},
40
- sort: {
41
- field: "create_time",
42
- order: "ASC"
43
- },
44
- pagination: {
45
- page: 1,
46
- pagesize: 100
47
- }
48
- });
49
- return res;
50
- },
51
- create: async (type, key, config) => {
27
+ }, Ar = {
28
+ list: async () => await $.getRequest("POST")("/datasource/list", {
29
+ filter: {},
30
+ sort: {
31
+ field: "create_time",
32
+ order: "ASC"
33
+ },
34
+ pagination: {
35
+ page: 1,
36
+ pagesize: 100
37
+ }
38
+ }),
39
+ create: async (l, o, v) => {
52
40
  try {
53
- const res = await APIClient.getRequest("POST")("/datasource/create", { type, key, config });
54
- return res;
55
- } catch (error) {
56
- console.error(error);
57
- return false;
41
+ return await $.getRequest("POST")("/datasource/create", { type: l, key: o, config: v });
42
+ } catch (d) {
43
+ return console.error(d), !1;
58
44
  }
59
45
  },
60
- delete: async (id) => {
61
- await APIClient.getRequest("POST")("/datasource/delete", { id });
46
+ delete: async (l) => {
47
+ await $.getRequest("POST")("/datasource/delete", { id: l });
62
48
  }
63
- };
64
- const APICaller = {
65
- datasource
66
- };
67
- const defaultStyles = {
49
+ }, se = {
50
+ datasource: Ar
51
+ }, J = {
68
52
  size: "sm",
69
53
  spacing: "md"
70
54
  };
71
- var jsxRuntime = { exports: {} };
72
- var reactJsxRuntime_production_min = {};
55
+ var H = { exports: {} }, L = {};
73
56
  /**
74
57
  * @license React
75
58
  * react-jsx-runtime.production.min.js
@@ -79,41 +62,629 @@ var reactJsxRuntime_production_min = {};
79
62
  * This source code is licensed under the MIT license found in the
80
63
  * LICENSE file in the root directory of this source tree.
81
64
  */
82
- var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
83
- function q(c, a, g) {
84
- var b, d = {}, e = null, h = null;
85
- void 0 !== g && (e = "" + g);
86
- void 0 !== a.key && (e = "" + a.key);
87
- void 0 !== a.ref && (h = a.ref);
88
- for (b in a)
89
- m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
90
- if (c && c.defaultProps)
91
- for (b in a = c.defaultProps, a)
92
- void 0 === d[b] && (d[b] = a[b]);
93
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
65
+ var Ae;
66
+ function Fr() {
67
+ if (Ae)
68
+ return L;
69
+ Ae = 1;
70
+ var l = oe, o = Symbol.for("react.element"), v = Symbol.for("react.fragment"), d = Object.prototype.hasOwnProperty, _ = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, h = { key: !0, ref: !0, __self: !0, __source: !0 };
71
+ function m(y, u, P) {
72
+ var b, T = {}, x = null, q = null;
73
+ P !== void 0 && (x = "" + P), u.key !== void 0 && (x = "" + u.key), u.ref !== void 0 && (q = u.ref);
74
+ for (b in u)
75
+ d.call(u, b) && !h.hasOwnProperty(b) && (T[b] = u[b]);
76
+ if (y && y.defaultProps)
77
+ for (b in u = y.defaultProps, u)
78
+ T[b] === void 0 && (T[b] = u[b]);
79
+ return { $$typeof: o, type: y, key: x, ref: q, props: T, _owner: _.current };
80
+ }
81
+ return L.Fragment = v, L.jsx = m, L.jsxs = m, L;
94
82
  }
95
- reactJsxRuntime_production_min.Fragment = l;
96
- reactJsxRuntime_production_min.jsx = q;
97
- reactJsxRuntime_production_min.jsxs = q;
98
- {
99
- jsxRuntime.exports = reactJsxRuntime_production_min;
83
+ var W = {};
84
+ /**
85
+ * @license React
86
+ * react-jsx-runtime.development.js
87
+ *
88
+ * Copyright (c) Facebook, Inc. and its affiliates.
89
+ *
90
+ * This source code is licensed under the MIT license found in the
91
+ * LICENSE file in the root directory of this source tree.
92
+ */
93
+ var Fe;
94
+ function Ir() {
95
+ return Fe || (Fe = 1, process.env.NODE_ENV !== "production" && function() {
96
+ var l = oe, o = Symbol.for("react.element"), v = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), _ = Symbol.for("react.strict_mode"), h = Symbol.for("react.profiler"), m = Symbol.for("react.provider"), y = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), b = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), q = Symbol.for("react.offscreen"), ue = Symbol.iterator, We = "@@iterator";
97
+ function $e(e) {
98
+ if (e === null || typeof e != "object")
99
+ return null;
100
+ var r = ue && e[ue] || e[We];
101
+ return typeof r == "function" ? r : null;
102
+ }
103
+ var k = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
104
+ function R(e) {
105
+ {
106
+ for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
107
+ t[n - 1] = arguments[n];
108
+ qe("error", e, t);
109
+ }
110
+ }
111
+ function qe(e, r, t) {
112
+ {
113
+ var n = k.ReactDebugCurrentFrame, c = n.getStackAddendum();
114
+ c !== "" && (r += "%s", t = t.concat([c]));
115
+ var f = t.map(function(s) {
116
+ return String(s);
117
+ });
118
+ f.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, f);
119
+ }
120
+ }
121
+ var Ne = !1, Ue = !1, Ye = !1, Me = !1, Ve = !1, ce;
122
+ ce = Symbol.for("react.module.reference");
123
+ function Be(e) {
124
+ return !!(typeof e == "string" || typeof e == "function" || e === d || e === h || Ve || e === _ || e === P || e === b || Me || e === q || Ne || Ue || Ye || typeof e == "object" && e !== null && (e.$$typeof === x || e.$$typeof === T || e.$$typeof === m || e.$$typeof === y || e.$$typeof === u || e.$$typeof === ce || e.getModuleId !== void 0));
125
+ }
126
+ function Ge(e, r, t) {
127
+ var n = e.displayName;
128
+ if (n)
129
+ return n;
130
+ var c = r.displayName || r.name || "";
131
+ return c !== "" ? t + "(" + c + ")" : t;
132
+ }
133
+ function le(e) {
134
+ return e.displayName || "Context";
135
+ }
136
+ function w(e) {
137
+ if (e == null)
138
+ return null;
139
+ if (typeof e.tag == "number" && R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
140
+ return e.displayName || e.name || null;
141
+ if (typeof e == "string")
142
+ return e;
143
+ switch (e) {
144
+ case d:
145
+ return "Fragment";
146
+ case v:
147
+ return "Portal";
148
+ case h:
149
+ return "Profiler";
150
+ case _:
151
+ return "StrictMode";
152
+ case P:
153
+ return "Suspense";
154
+ case b:
155
+ return "SuspenseList";
156
+ }
157
+ if (typeof e == "object")
158
+ switch (e.$$typeof) {
159
+ case y:
160
+ var r = e;
161
+ return le(r) + ".Consumer";
162
+ case m:
163
+ var t = e;
164
+ return le(t._context) + ".Provider";
165
+ case u:
166
+ return Ge(e, e.render, "ForwardRef");
167
+ case T:
168
+ var n = e.displayName || null;
169
+ return n !== null ? n : w(e.type) || "Memo";
170
+ case x: {
171
+ var c = e, f = c._payload, s = c._init;
172
+ try {
173
+ return w(s(f));
174
+ } catch {
175
+ return null;
176
+ }
177
+ }
178
+ }
179
+ return null;
180
+ }
181
+ var j = Object.assign, I = 0, fe, de, ve, pe, ge, me, he;
182
+ function be() {
183
+ }
184
+ be.__reactDisabledLog = !0;
185
+ function Je() {
186
+ {
187
+ if (I === 0) {
188
+ fe = console.log, de = console.info, ve = console.warn, pe = console.error, ge = console.group, me = console.groupCollapsed, he = console.groupEnd;
189
+ var e = {
190
+ configurable: !0,
191
+ enumerable: !0,
192
+ value: be,
193
+ writable: !0
194
+ };
195
+ Object.defineProperties(console, {
196
+ info: e,
197
+ log: e,
198
+ warn: e,
199
+ error: e,
200
+ group: e,
201
+ groupCollapsed: e,
202
+ groupEnd: e
203
+ });
204
+ }
205
+ I++;
206
+ }
207
+ }
208
+ function He() {
209
+ {
210
+ if (I--, I === 0) {
211
+ var e = {
212
+ configurable: !0,
213
+ enumerable: !0,
214
+ writable: !0
215
+ };
216
+ Object.defineProperties(console, {
217
+ log: j({}, e, {
218
+ value: fe
219
+ }),
220
+ info: j({}, e, {
221
+ value: de
222
+ }),
223
+ warn: j({}, e, {
224
+ value: ve
225
+ }),
226
+ error: j({}, e, {
227
+ value: pe
228
+ }),
229
+ group: j({}, e, {
230
+ value: ge
231
+ }),
232
+ groupCollapsed: j({}, e, {
233
+ value: me
234
+ }),
235
+ groupEnd: j({}, e, {
236
+ value: he
237
+ })
238
+ });
239
+ }
240
+ I < 0 && R("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
241
+ }
242
+ }
243
+ var X = k.ReactCurrentDispatcher, K;
244
+ function N(e, r, t) {
245
+ {
246
+ if (K === void 0)
247
+ try {
248
+ throw Error();
249
+ } catch (c) {
250
+ var n = c.stack.trim().match(/\n( *(at )?)/);
251
+ K = n && n[1] || "";
252
+ }
253
+ return `
254
+ ` + K + e;
255
+ }
256
+ }
257
+ var Q = !1, U;
258
+ {
259
+ var Xe = typeof WeakMap == "function" ? WeakMap : Map;
260
+ U = new Xe();
261
+ }
262
+ function Re(e, r) {
263
+ if (!e || Q)
264
+ return "";
265
+ {
266
+ var t = U.get(e);
267
+ if (t !== void 0)
268
+ return t;
269
+ }
270
+ var n;
271
+ Q = !0;
272
+ var c = Error.prepareStackTrace;
273
+ Error.prepareStackTrace = void 0;
274
+ var f;
275
+ f = X.current, X.current = null, Je();
276
+ try {
277
+ if (r) {
278
+ var s = function() {
279
+ throw Error();
280
+ };
281
+ if (Object.defineProperty(s.prototype, "props", {
282
+ set: function() {
283
+ throw Error();
284
+ }
285
+ }), typeof Reflect == "object" && Reflect.construct) {
286
+ try {
287
+ Reflect.construct(s, []);
288
+ } catch (C) {
289
+ n = C;
290
+ }
291
+ Reflect.construct(e, [], s);
292
+ } else {
293
+ try {
294
+ s.call();
295
+ } catch (C) {
296
+ n = C;
297
+ }
298
+ e.call(s.prototype);
299
+ }
300
+ } else {
301
+ try {
302
+ throw Error();
303
+ } catch (C) {
304
+ n = C;
305
+ }
306
+ e();
307
+ }
308
+ } catch (C) {
309
+ if (C && n && typeof C.stack == "string") {
310
+ for (var i = C.stack.split(`
311
+ `), E = n.stack.split(`
312
+ `), p = i.length - 1, g = E.length - 1; p >= 1 && g >= 0 && i[p] !== E[g]; )
313
+ g--;
314
+ for (; p >= 1 && g >= 0; p--, g--)
315
+ if (i[p] !== E[g]) {
316
+ if (p !== 1 || g !== 1)
317
+ do
318
+ if (p--, g--, g < 0 || i[p] !== E[g]) {
319
+ var S = `
320
+ ` + i[p].replace(" at new ", " at ");
321
+ return e.displayName && S.includes("<anonymous>") && (S = S.replace("<anonymous>", e.displayName)), typeof e == "function" && U.set(e, S), S;
322
+ }
323
+ while (p >= 1 && g >= 0);
324
+ break;
325
+ }
326
+ }
327
+ } finally {
328
+ Q = !1, X.current = f, He(), Error.prepareStackTrace = c;
329
+ }
330
+ var F = e ? e.displayName || e.name : "", ke = F ? N(F) : "";
331
+ return typeof e == "function" && U.set(e, ke), ke;
332
+ }
333
+ function Ke(e, r, t) {
334
+ return Re(e, !1);
335
+ }
336
+ function Qe(e) {
337
+ var r = e.prototype;
338
+ return !!(r && r.isReactComponent);
339
+ }
340
+ function Y(e, r, t) {
341
+ if (e == null)
342
+ return "";
343
+ if (typeof e == "function")
344
+ return Re(e, Qe(e));
345
+ if (typeof e == "string")
346
+ return N(e);
347
+ switch (e) {
348
+ case P:
349
+ return N("Suspense");
350
+ case b:
351
+ return N("SuspenseList");
352
+ }
353
+ if (typeof e == "object")
354
+ switch (e.$$typeof) {
355
+ case u:
356
+ return Ke(e.render);
357
+ case T:
358
+ return Y(e.type, r, t);
359
+ case x: {
360
+ var n = e, c = n._payload, f = n._init;
361
+ try {
362
+ return Y(f(c), r, t);
363
+ } catch {
364
+ }
365
+ }
366
+ }
367
+ return "";
368
+ }
369
+ var M = Object.prototype.hasOwnProperty, Ee = {}, _e = k.ReactDebugCurrentFrame;
370
+ function V(e) {
371
+ if (e) {
372
+ var r = e._owner, t = Y(e.type, e._source, r ? r.type : null);
373
+ _e.setExtraStackFrame(t);
374
+ } else
375
+ _e.setExtraStackFrame(null);
376
+ }
377
+ function Ze(e, r, t, n, c) {
378
+ {
379
+ var f = Function.call.bind(M);
380
+ for (var s in e)
381
+ if (f(e, s)) {
382
+ var i = void 0;
383
+ try {
384
+ if (typeof e[s] != "function") {
385
+ var E = Error((n || "React class") + ": " + t + " type `" + s + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[s] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
386
+ throw E.name = "Invariant Violation", E;
387
+ }
388
+ i = e[s](r, s, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
389
+ } catch (p) {
390
+ i = p;
391
+ }
392
+ i && !(i instanceof Error) && (V(c), R("%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).", n || "React class", t, s, typeof i), V(null)), i instanceof Error && !(i.message in Ee) && (Ee[i.message] = !0, V(c), R("Failed %s type: %s", t, i.message), V(null));
393
+ }
394
+ }
395
+ }
396
+ var er = Array.isArray;
397
+ function Z(e) {
398
+ return er(e);
399
+ }
400
+ function rr(e) {
401
+ {
402
+ var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
403
+ return t;
404
+ }
405
+ }
406
+ function tr(e) {
407
+ try {
408
+ return ye(e), !1;
409
+ } catch {
410
+ return !0;
411
+ }
412
+ }
413
+ function ye(e) {
414
+ return "" + e;
415
+ }
416
+ function Se(e) {
417
+ if (tr(e))
418
+ return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", rr(e)), ye(e);
419
+ }
420
+ var z = k.ReactCurrentOwner, nr = {
421
+ key: !0,
422
+ ref: !0,
423
+ __self: !0,
424
+ __source: !0
425
+ }, Te, we, ee;
426
+ ee = {};
427
+ function ar(e) {
428
+ if (M.call(e, "ref")) {
429
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
430
+ if (r && r.isReactWarning)
431
+ return !1;
432
+ }
433
+ return e.ref !== void 0;
434
+ }
435
+ function ir(e) {
436
+ if (M.call(e, "key")) {
437
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
438
+ if (r && r.isReactWarning)
439
+ return !1;
440
+ }
441
+ return e.key !== void 0;
442
+ }
443
+ function or(e, r) {
444
+ if (typeof e.ref == "string" && z.current && r && z.current.stateNode !== r) {
445
+ var t = w(z.current.type);
446
+ ee[t] || (R('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', w(z.current.type), e.ref), ee[t] = !0);
447
+ }
448
+ }
449
+ function sr(e, r) {
450
+ {
451
+ var t = function() {
452
+ Te || (Te = !0, R("%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)", r));
453
+ };
454
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
455
+ get: t,
456
+ configurable: !0
457
+ });
458
+ }
459
+ }
460
+ function ur(e, r) {
461
+ {
462
+ var t = function() {
463
+ we || (we = !0, R("%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)", r));
464
+ };
465
+ t.isReactWarning = !0, Object.defineProperty(e, "ref", {
466
+ get: t,
467
+ configurable: !0
468
+ });
469
+ }
470
+ }
471
+ var cr = function(e, r, t, n, c, f, s) {
472
+ var i = {
473
+ $$typeof: o,
474
+ type: e,
475
+ key: r,
476
+ ref: t,
477
+ props: s,
478
+ _owner: f
479
+ };
480
+ return i._store = {}, Object.defineProperty(i._store, "validated", {
481
+ configurable: !1,
482
+ enumerable: !1,
483
+ writable: !0,
484
+ value: !1
485
+ }), Object.defineProperty(i, "_self", {
486
+ configurable: !1,
487
+ enumerable: !1,
488
+ writable: !1,
489
+ value: n
490
+ }), Object.defineProperty(i, "_source", {
491
+ configurable: !1,
492
+ enumerable: !1,
493
+ writable: !1,
494
+ value: c
495
+ }), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i;
496
+ };
497
+ function lr(e, r, t, n, c) {
498
+ {
499
+ var f, s = {}, i = null, E = null;
500
+ t !== void 0 && (Se(t), i = "" + t), ir(r) && (Se(r.key), i = "" + r.key), ar(r) && (E = r.ref, or(r, c));
501
+ for (f in r)
502
+ M.call(r, f) && !nr.hasOwnProperty(f) && (s[f] = r[f]);
503
+ if (e && e.defaultProps) {
504
+ var p = e.defaultProps;
505
+ for (f in p)
506
+ s[f] === void 0 && (s[f] = p[f]);
507
+ }
508
+ if (i || E) {
509
+ var g = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
510
+ i && sr(s, g), E && ur(s, g);
511
+ }
512
+ return cr(e, i, E, c, n, z.current, s);
513
+ }
514
+ }
515
+ var re = k.ReactCurrentOwner, Ce = k.ReactDebugCurrentFrame;
516
+ function A(e) {
517
+ if (e) {
518
+ var r = e._owner, t = Y(e.type, e._source, r ? r.type : null);
519
+ Ce.setExtraStackFrame(t);
520
+ } else
521
+ Ce.setExtraStackFrame(null);
522
+ }
523
+ var te;
524
+ te = !1;
525
+ function ne(e) {
526
+ return typeof e == "object" && e !== null && e.$$typeof === o;
527
+ }
528
+ function Pe() {
529
+ {
530
+ if (re.current) {
531
+ var e = w(re.current.type);
532
+ if (e)
533
+ return `
534
+
535
+ Check the render method of \`` + e + "`.";
536
+ }
537
+ return "";
538
+ }
539
+ }
540
+ function fr(e) {
541
+ {
542
+ if (e !== void 0) {
543
+ var r = e.fileName.replace(/^.*[\\\/]/, ""), t = e.lineNumber;
544
+ return `
545
+
546
+ Check your code at ` + r + ":" + t + ".";
547
+ }
548
+ return "";
549
+ }
550
+ }
551
+ var Oe = {};
552
+ function dr(e) {
553
+ {
554
+ var r = Pe();
555
+ if (!r) {
556
+ var t = typeof e == "string" ? e : e.displayName || e.name;
557
+ t && (r = `
558
+
559
+ Check the top-level render call using <` + t + ">.");
560
+ }
561
+ return r;
562
+ }
563
+ }
564
+ function xe(e, r) {
565
+ {
566
+ if (!e._store || e._store.validated || e.key != null)
567
+ return;
568
+ e._store.validated = !0;
569
+ var t = dr(r);
570
+ if (Oe[t])
571
+ return;
572
+ Oe[t] = !0;
573
+ var n = "";
574
+ e && e._owner && e._owner !== re.current && (n = " It was passed a child from " + w(e._owner.type) + "."), A(e), R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), A(null);
575
+ }
576
+ }
577
+ function je(e, r) {
578
+ {
579
+ if (typeof e != "object")
580
+ return;
581
+ if (Z(e))
582
+ for (var t = 0; t < e.length; t++) {
583
+ var n = e[t];
584
+ ne(n) && xe(n, r);
585
+ }
586
+ else if (ne(e))
587
+ e._store && (e._store.validated = !0);
588
+ else if (e) {
589
+ var c = $e(e);
590
+ if (typeof c == "function" && c !== e.entries)
591
+ for (var f = c.call(e), s; !(s = f.next()).done; )
592
+ ne(s.value) && xe(s.value, r);
593
+ }
594
+ }
595
+ }
596
+ function vr(e) {
597
+ {
598
+ var r = e.type;
599
+ if (r == null || typeof r == "string")
600
+ return;
601
+ var t;
602
+ if (typeof r == "function")
603
+ t = r.propTypes;
604
+ else if (typeof r == "object" && (r.$$typeof === u || r.$$typeof === T))
605
+ t = r.propTypes;
606
+ else
607
+ return;
608
+ if (t) {
609
+ var n = w(r);
610
+ Ze(t, e.props, "prop", n, e);
611
+ } else if (r.PropTypes !== void 0 && !te) {
612
+ te = !0;
613
+ var c = w(r);
614
+ R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", c || "Unknown");
615
+ }
616
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
617
+ }
618
+ }
619
+ function pr(e) {
620
+ {
621
+ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
622
+ var n = r[t];
623
+ if (n !== "children" && n !== "key") {
624
+ A(e), R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), A(null);
625
+ break;
626
+ }
627
+ }
628
+ e.ref !== null && (A(e), R("Invalid attribute `ref` supplied to `React.Fragment`."), A(null));
629
+ }
630
+ }
631
+ function De(e, r, t, n, c, f) {
632
+ {
633
+ var s = Be(e);
634
+ if (!s) {
635
+ var i = "";
636
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (i += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
637
+ var E = fr(c);
638
+ E ? i += E : i += Pe();
639
+ var p;
640
+ e === null ? p = "null" : Z(e) ? p = "array" : e !== void 0 && e.$$typeof === o ? (p = "<" + (w(e.type) || "Unknown") + " />", i = " Did you accidentally export a JSX literal instead of a component?") : p = typeof e, R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", p, i);
641
+ }
642
+ var g = lr(e, r, t, c, f);
643
+ if (g == null)
644
+ return g;
645
+ if (s) {
646
+ var S = r.children;
647
+ if (S !== void 0)
648
+ if (n)
649
+ if (Z(S)) {
650
+ for (var F = 0; F < S.length; F++)
651
+ je(S[F], e);
652
+ Object.freeze && Object.freeze(S);
653
+ } else
654
+ R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
655
+ else
656
+ je(S, e);
657
+ }
658
+ return e === d ? pr(g) : vr(g), g;
659
+ }
660
+ }
661
+ function gr(e, r, t) {
662
+ return De(e, r, t, !0);
663
+ }
664
+ function mr(e, r, t) {
665
+ return De(e, r, t, !1);
666
+ }
667
+ var hr = mr, br = gr;
668
+ W.Fragment = d, W.jsx = hr, W.jsxs = br;
669
+ }()), W;
100
670
  }
101
- const jsx = jsxRuntime.exports.jsx;
102
- const jsxs = jsxRuntime.exports.jsxs;
103
- const Fragment = jsxRuntime.exports.Fragment;
104
- function AddDataSourceForm({
105
- postSubmit,
106
- styles = defaultStyles
671
+ (function(l) {
672
+ process.env.NODE_ENV === "production" ? l.exports = Fr() : l.exports = Ir();
673
+ })(H);
674
+ const Le = H.exports.Fragment, a = H.exports.jsx, O = H.exports.jsxs;
675
+ function zr({
676
+ postSubmit: l,
677
+ styles: o = J
107
678
  }) {
108
679
  const {
109
- control,
110
- handleSubmit,
680
+ control: v,
681
+ handleSubmit: d,
111
682
  formState: {
112
- errors,
113
- isValidating,
114
- isValid
683
+ errors: _,
684
+ isValidating: h,
685
+ isValid: m
115
686
  }
116
- } = useForm({
687
+ } = Pr({
117
688
  defaultValues: {
118
689
  type: "postgresql",
119
690
  key: "",
@@ -126,48 +697,44 @@ function AddDataSourceForm({
126
697
  }
127
698
  }
128
699
  });
129
- const addDataSource = async ({
130
- type,
131
- key,
132
- config
133
- }) => {
134
- showNotification({
135
- id: "for-creating",
136
- title: "Pending",
137
- message: "Adding data source...",
138
- loading: true
139
- });
140
- const result = await APICaller.datasource.create(type, key, config);
141
- if (!result) {
142
- updateNotification({
143
- id: "for-creating",
144
- title: "Failed",
145
- message: "Test connection failed with given info",
146
- color: "red"
147
- });
148
- return;
149
- }
150
- updateNotification({
151
- id: "for-creating",
152
- title: "Successful",
153
- message: "Data source is added",
154
- color: "green"
155
- });
156
- postSubmit();
157
- };
158
- return /* @__PURE__ */ jsx(Box, {
700
+ return /* @__PURE__ */ a(Ie, {
159
701
  mx: "auto",
160
- children: /* @__PURE__ */ jsxs("form", {
161
- onSubmit: handleSubmit(addDataSource),
162
- children: [/* @__PURE__ */ jsx(Controller, {
702
+ children: /* @__PURE__ */ O("form", {
703
+ onSubmit: d(async ({
704
+ type: u,
705
+ key: P,
706
+ config: b
707
+ }) => {
708
+ if (ze({
709
+ id: "for-creating",
710
+ title: "Pending",
711
+ message: "Adding data source...",
712
+ loading: !0
713
+ }), !await se.datasource.create(u, P, b)) {
714
+ ae({
715
+ id: "for-creating",
716
+ title: "Failed",
717
+ message: "Test connection failed with given info",
718
+ color: "red"
719
+ });
720
+ return;
721
+ }
722
+ ae({
723
+ id: "for-creating",
724
+ title: "Successful",
725
+ message: "Data source is added",
726
+ color: "green"
727
+ }), l();
728
+ }),
729
+ children: [/* @__PURE__ */ a(D, {
163
730
  name: "type",
164
- control,
731
+ control: v,
165
732
  render: ({
166
- field
167
- }) => /* @__PURE__ */ jsx(SegmentedControl, {
168
- fullWidth: true,
169
- mb: styles.spacing,
170
- size: styles.size,
733
+ field: u
734
+ }) => /* @__PURE__ */ a(Er, {
735
+ fullWidth: !0,
736
+ mb: o.spacing,
737
+ size: o.size,
171
738
  data: [{
172
739
  label: "PostgreSQL",
173
740
  value: "postgresql"
@@ -177,173 +744,161 @@ function AddDataSourceForm({
177
744
  }, {
178
745
  label: "HTTP",
179
746
  value: "http",
180
- disabled: true
747
+ disabled: !0
181
748
  }],
182
- ...field
749
+ ...u
183
750
  })
184
- }), /* @__PURE__ */ jsx(Controller, {
751
+ }), /* @__PURE__ */ a(D, {
185
752
  name: "key",
186
- control,
753
+ control: v,
187
754
  render: ({
188
- field
189
- }) => /* @__PURE__ */ jsx(TextInput, {
190
- mb: styles.spacing,
191
- size: styles.size,
192
- required: true,
755
+ field: u
756
+ }) => /* @__PURE__ */ a(B, {
757
+ mb: o.spacing,
758
+ size: o.size,
759
+ required: !0,
193
760
  label: "Name",
194
761
  placeholder: "A unique name",
195
- ...field
762
+ ...u
196
763
  })
197
- }), /* @__PURE__ */ jsx(Divider, {
764
+ }), /* @__PURE__ */ a(_r, {
198
765
  label: "Connection Info",
199
766
  labelPosition: "center"
200
- }), /* @__PURE__ */ jsxs(Group, {
201
- grow: true,
202
- children: [/* @__PURE__ */ jsx(Controller, {
767
+ }), /* @__PURE__ */ O(G, {
768
+ grow: !0,
769
+ children: [/* @__PURE__ */ a(D, {
203
770
  name: "config.host",
204
- control,
771
+ control: v,
205
772
  render: ({
206
- field
207
- }) => /* @__PURE__ */ jsx(TextInput, {
208
- mb: styles.spacing,
209
- size: styles.size,
210
- required: true,
773
+ field: u
774
+ }) => /* @__PURE__ */ a(B, {
775
+ mb: o.spacing,
776
+ size: o.size,
777
+ required: !0,
211
778
  label: "Host",
212
779
  sx: {
213
780
  flexGrow: 1
214
781
  },
215
- ...field
782
+ ...u
216
783
  })
217
- }), /* @__PURE__ */ jsx(Controller, {
784
+ }), /* @__PURE__ */ a(D, {
218
785
  name: "config.port",
219
- control,
786
+ control: v,
220
787
  render: ({
221
- field
222
- }) => /* @__PURE__ */ jsx(NumberInput, {
223
- mb: styles.spacing,
224
- size: styles.size,
225
- required: true,
788
+ field: u
789
+ }) => /* @__PURE__ */ a(yr, {
790
+ mb: o.spacing,
791
+ size: o.size,
792
+ required: !0,
226
793
  label: "Port",
227
- hideControls: true,
794
+ hideControls: !0,
228
795
  sx: {
229
796
  width: "8em"
230
797
  },
231
- ...field
798
+ ...u
232
799
  })
233
800
  })]
234
- }), /* @__PURE__ */ jsx(Controller, {
801
+ }), /* @__PURE__ */ a(D, {
235
802
  name: "config.username",
236
- control,
803
+ control: v,
237
804
  render: ({
238
- field
239
- }) => /* @__PURE__ */ jsx(TextInput, {
240
- mb: styles.spacing,
241
- size: styles.size,
242
- required: true,
805
+ field: u
806
+ }) => /* @__PURE__ */ a(B, {
807
+ mb: o.spacing,
808
+ size: o.size,
809
+ required: !0,
243
810
  label: "Username",
244
- ...field
811
+ ...u
245
812
  })
246
- }), /* @__PURE__ */ jsx(Controller, {
813
+ }), /* @__PURE__ */ a(D, {
247
814
  name: "config.password",
248
- control,
815
+ control: v,
249
816
  render: ({
250
- field
251
- }) => /* @__PURE__ */ jsx(PasswordInput, {
252
- mb: styles.spacing,
253
- size: styles.size,
254
- required: true,
817
+ field: u
818
+ }) => /* @__PURE__ */ a(Sr, {
819
+ mb: o.spacing,
820
+ size: o.size,
821
+ required: !0,
255
822
  label: "Password",
256
- ...field
823
+ ...u
257
824
  })
258
- }), /* @__PURE__ */ jsx(Controller, {
825
+ }), /* @__PURE__ */ a(D, {
259
826
  name: "config.database",
260
- control,
827
+ control: v,
261
828
  render: ({
262
- field
263
- }) => /* @__PURE__ */ jsx(TextInput, {
264
- mb: styles.spacing,
265
- size: styles.size,
266
- required: true,
829
+ field: u
830
+ }) => /* @__PURE__ */ a(B, {
831
+ mb: o.spacing,
832
+ size: o.size,
833
+ required: !0,
267
834
  label: "Database",
268
- ...field
835
+ ...u
269
836
  })
270
- }), /* @__PURE__ */ jsx(Group, {
837
+ }), /* @__PURE__ */ a(G, {
271
838
  position: "right",
272
- mt: styles.spacing,
273
- children: /* @__PURE__ */ jsx(Button, {
839
+ mt: o.spacing,
840
+ children: /* @__PURE__ */ a(ie, {
274
841
  type: "submit",
275
- size: styles.size,
842
+ size: o.size,
276
843
  children: "Save"
277
844
  })
278
845
  })]
279
846
  })
280
847
  });
281
848
  }
282
- function AddDataSource({
283
- onSuccess,
284
- styles = defaultStyles
849
+ function Lr({
850
+ onSuccess: l,
851
+ styles: o = J
285
852
  }) {
286
- const [opened, setOpened] = require$$0.useState(false);
287
- const open = () => setOpened(true);
288
- const close = () => setOpened(false);
289
- const postSubmit = () => {
290
- onSuccess();
291
- close();
292
- };
293
- return /* @__PURE__ */ jsxs(Fragment, {
294
- children: [/* @__PURE__ */ jsx(Modal, {
853
+ const [v, d] = oe.useState(!1), _ = () => d(!0), h = () => d(!1);
854
+ return /* @__PURE__ */ O(Le, {
855
+ children: [/* @__PURE__ */ a(Rr, {
295
856
  overflow: "inside",
296
- opened,
297
- onClose: () => setOpened(false),
857
+ opened: v,
858
+ onClose: () => d(!1),
298
859
  title: "Add a data source",
299
- trapFocus: true,
300
- onDragStart: (e) => {
301
- e.stopPropagation();
860
+ trapFocus: !0,
861
+ onDragStart: (y) => {
862
+ y.stopPropagation();
302
863
  },
303
- children: /* @__PURE__ */ jsx(AddDataSourceForm, {
304
- postSubmit,
305
- styles
864
+ children: /* @__PURE__ */ a(zr, {
865
+ postSubmit: () => {
866
+ l(), h();
867
+ },
868
+ styles: o
306
869
  })
307
- }), /* @__PURE__ */ jsx(Button, {
308
- size: styles.size,
309
- onClick: open,
310
- leftIcon: /* @__PURE__ */ jsx(PlaylistAdd, {
870
+ }), /* @__PURE__ */ a(ie, {
871
+ size: o.size,
872
+ onClick: _,
873
+ leftIcon: /* @__PURE__ */ a(Or, {
311
874
  size: 20
312
875
  }),
313
876
  children: "Add a Data Source"
314
877
  })]
315
878
  });
316
879
  }
317
- function DeleteDataSource({
318
- id,
319
- name,
320
- onSuccess,
321
- styles = defaultStyles
880
+ function Wr({
881
+ id: l,
882
+ name: o,
883
+ onSuccess: v,
884
+ styles: d = J
322
885
  }) {
323
- const modals = useModals();
324
- const doDelete = async () => {
325
- if (!id) {
326
- return;
327
- }
328
- showNotification({
886
+ const _ = kr(), h = async () => {
887
+ !l || (ze({
329
888
  id: "for-deleting",
330
889
  title: "Pending",
331
890
  message: "Deleting data source...",
332
- loading: true
333
- });
334
- await APICaller.datasource.delete(id);
335
- updateNotification({
891
+ loading: !0
892
+ }), await se.datasource.delete(l), ae({
336
893
  id: "for-deleting",
337
894
  title: "Successful",
338
- message: `Data source [${name}] is deleted`,
895
+ message: `Data source [${o}] is deleted`,
339
896
  color: "green"
340
- });
341
- onSuccess();
342
- };
343
- const confirmAndDelete = () => modals.openConfirmModal({
897
+ }), v());
898
+ }, m = () => _.openConfirmModal({
344
899
  title: "Delete this data source?",
345
- children: /* @__PURE__ */ jsx(Text, {
346
- size: styles.size,
900
+ children: /* @__PURE__ */ a(Tr, {
901
+ size: d.size,
347
902
  children: "This action won't affect your database."
348
903
  }),
349
904
  labels: {
@@ -351,92 +906,93 @@ function DeleteDataSource({
351
906
  cancel: "Cancel"
352
907
  },
353
908
  onCancel: () => console.log("Cancel"),
354
- onConfirm: doDelete
909
+ onConfirm: h
355
910
  });
356
- return /* @__PURE__ */ jsx(Button, {
357
- size: styles.size,
911
+ return /* @__PURE__ */ a(ie, {
912
+ size: d.size,
358
913
  color: "red",
359
- onClick: confirmAndDelete,
360
- leftIcon: /* @__PURE__ */ jsx(Trash, {
914
+ onClick: m,
915
+ leftIcon: /* @__PURE__ */ a(xr, {
361
916
  size: 20
362
917
  }),
363
918
  children: "Delete"
364
919
  });
365
920
  }
366
- function DataSourceList({
367
- styles = defaultStyles,
368
- config
921
+ function Gr({
922
+ styles: l = J,
923
+ config: o
369
924
  }) {
370
925
  const {
371
- data = [],
372
- loading,
373
- refresh
374
- } = useRequest(async () => {
926
+ data: v = [],
927
+ loading: d,
928
+ refresh: _
929
+ } = Dr(async () => {
375
930
  const {
376
- data: data2
377
- } = await APICaller.datasource.list();
378
- return data2;
931
+ data: h
932
+ } = await se.datasource.list();
933
+ return h;
379
934
  }, {
380
935
  refreshDeps: []
381
936
  });
382
- if (APIClient.baseURL !== config.apiBaseURL) {
383
- APIClient.baseURL = config.apiBaseURL;
384
- }
385
- return /* @__PURE__ */ jsxs(Fragment, {
386
- children: [/* @__PURE__ */ jsx(Group, {
387
- pt: styles.spacing,
937
+ return $.baseURL !== o.apiBaseURL && ($.baseURL = o.apiBaseURL), /* @__PURE__ */ O(Le, {
938
+ children: [/* @__PURE__ */ a(G, {
939
+ pt: l.spacing,
388
940
  position: "right",
389
- children: /* @__PURE__ */ jsx(AddDataSource, {
390
- onSuccess: refresh
941
+ children: /* @__PURE__ */ a(Lr, {
942
+ onSuccess: _
391
943
  })
392
- }), /* @__PURE__ */ jsxs(Box, {
393
- mt: styles.spacing,
944
+ }), /* @__PURE__ */ O(Ie, {
945
+ mt: l.spacing,
394
946
  sx: {
395
947
  position: "relative"
396
948
  },
397
- children: [/* @__PURE__ */ jsx(LoadingOverlay, {
398
- visible: loading
399
- }), /* @__PURE__ */ jsxs(Table, {
400
- horizontalSpacing: styles.spacing,
401
- verticalSpacing: styles.spacing,
402
- fontSize: styles.size,
403
- highlightOnHover: true,
404
- children: [/* @__PURE__ */ jsx("thead", {
405
- children: /* @__PURE__ */ jsxs("tr", {
406
- children: [/* @__PURE__ */ jsx("th", {
949
+ children: [/* @__PURE__ */ a(wr, {
950
+ visible: d
951
+ }), /* @__PURE__ */ O(Cr, {
952
+ horizontalSpacing: l.spacing,
953
+ verticalSpacing: l.spacing,
954
+ fontSize: l.size,
955
+ highlightOnHover: !0,
956
+ children: [/* @__PURE__ */ a("thead", {
957
+ children: /* @__PURE__ */ O("tr", {
958
+ children: [/* @__PURE__ */ a("th", {
407
959
  children: "Type"
408
- }), /* @__PURE__ */ jsx("th", {
960
+ }), /* @__PURE__ */ a("th", {
409
961
  children: "Name"
410
- }), /* @__PURE__ */ jsx("th", {
962
+ }), /* @__PURE__ */ a("th", {
411
963
  children: "Action"
412
964
  })]
413
965
  })
414
- }), /* @__PURE__ */ jsx("tbody", {
415
- children: data.map(({
416
- id,
417
- key,
418
- type
419
- }) => /* @__PURE__ */ jsxs("tr", {
420
- children: [/* @__PURE__ */ jsx("td", {
966
+ }), /* @__PURE__ */ a("tbody", {
967
+ children: v.map(({
968
+ id: h,
969
+ key: m,
970
+ type: y
971
+ }) => /* @__PURE__ */ O("tr", {
972
+ children: [/* @__PURE__ */ a("td", {
421
973
  width: 200,
422
- children: type
423
- }), /* @__PURE__ */ jsx("td", {
424
- children: key
425
- }), /* @__PURE__ */ jsx("td", {
974
+ children: y
975
+ }), /* @__PURE__ */ a("td", {
976
+ children: m
977
+ }), /* @__PURE__ */ a("td", {
426
978
  width: 200,
427
- children: /* @__PURE__ */ jsx(Group, {
979
+ children: /* @__PURE__ */ a(G, {
428
980
  position: "left",
429
- children: /* @__PURE__ */ jsx(DeleteDataSource, {
430
- id,
431
- name: key,
432
- onSuccess: refresh
981
+ children: /* @__PURE__ */ a(Wr, {
982
+ id: h,
983
+ name: m,
984
+ onSuccess: _
433
985
  })
434
986
  })
435
987
  })]
436
- }, key))
988
+ }, m))
437
989
  })]
438
990
  })]
439
991
  })]
440
992
  });
441
993
  }
442
- export { AddDataSource, DataSourceList, DeleteDataSource };
994
+ export {
995
+ Lr as AddDataSource,
996
+ Gr as DataSourceList,
997
+ Wr as DeleteDataSource
998
+ };