@devtable/settings-form 4.1.0 → 4.1.2

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 { showNotification as ze, updateNotification as ae } from "@mantine/notifications";
3
+ import oe from "react";
4
+ import { useForm as Pr, Controller as j } from "react-hook-form";
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 E = {
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
+ }, u = {
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: E
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" && (u.data = d.string ? JSON.stringify(v) : v), jr(u).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,624 @@ 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, E = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, u = { key: !0, ref: !0, __self: !0, __source: !0 };
71
+ function m(_, h, D) {
72
+ var y, T = {}, O = null, q = null;
73
+ D !== void 0 && (O = "" + D), h.key !== void 0 && (O = "" + h.key), h.ref !== void 0 && (q = h.ref);
74
+ for (y in h)
75
+ d.call(h, y) && !u.hasOwnProperty(y) && (T[y] = h[y]);
76
+ if (_ && _.defaultProps)
77
+ for (y in h = _.defaultProps, h)
78
+ T[y] === void 0 && (T[y] = h[y]);
79
+ return { $$typeof: o, type: _, key: O, ref: q, props: T, _owner: E.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"), E = Symbol.for("react.strict_mode"), u = Symbol.for("react.profiler"), m = Symbol.for("react.provider"), _ = Symbol.for("react.context"), h = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), y = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), O = 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 b(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 === u || Ve || e === E || e === D || e === y || Me || e === q || Ne || Ue || Ye || typeof e == "object" && e !== null && (e.$$typeof === O || e.$$typeof === T || e.$$typeof === m || e.$$typeof === _ || e.$$typeof === h || 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" && b("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 u:
149
+ return "Profiler";
150
+ case E:
151
+ return "StrictMode";
152
+ case D:
153
+ return "Suspense";
154
+ case y:
155
+ return "SuspenseList";
156
+ }
157
+ if (typeof e == "object")
158
+ switch (e.$$typeof) {
159
+ case _:
160
+ var r = e;
161
+ return le(r) + ".Consumer";
162
+ case m:
163
+ var t = e;
164
+ return le(t._context) + ".Provider";
165
+ case h:
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 O: {
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 x = 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: x({}, e, {
218
+ value: fe
219
+ }),
220
+ info: x({}, e, {
221
+ value: de
222
+ }),
223
+ warn: x({}, e, {
224
+ value: ve
225
+ }),
226
+ error: x({}, e, {
227
+ value: pe
228
+ }),
229
+ group: x({}, e, {
230
+ value: ge
231
+ }),
232
+ groupCollapsed: x({}, e, {
233
+ value: me
234
+ }),
235
+ groupEnd: x({}, e, {
236
+ value: he
237
+ })
238
+ });
239
+ }
240
+ I < 0 && b("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
+ `), R = n.stack.split(`
312
+ `), p = i.length - 1, g = R.length - 1; p >= 1 && g >= 0 && i[p] !== R[g]; )
313
+ g--;
314
+ for (; p >= 1 && g >= 0; p--, g--)
315
+ if (i[p] !== R[g]) {
316
+ if (p !== 1 || g !== 1)
317
+ do
318
+ if (p--, g--, g < 0 || i[p] !== R[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 D:
349
+ return N("Suspense");
350
+ case y:
351
+ return N("SuspenseList");
352
+ }
353
+ if (typeof e == "object")
354
+ switch (e.$$typeof) {
355
+ case h:
356
+ return Ke(e.render);
357
+ case T:
358
+ return Y(e.type, r, t);
359
+ case O: {
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 R = 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 R.name = "Invariant Violation", R;
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), b("%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), b("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 b("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] || (b('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, b("%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, b("%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, R = null;
500
+ t !== void 0 && (Se(t), i = "" + t), ir(r) && (Se(r.key), i = "" + r.key), ar(r) && (R = 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 || R) {
509
+ var g = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
510
+ i && sr(s, g), R && ur(s, g);
511
+ }
512
+ return cr(e, i, R, 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), b('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 === h || 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
+ b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", c || "Unknown");
615
+ }
616
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && b("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), b("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), b("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 R = fr(c);
638
+ R ? i += R : 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, b("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
+ b("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, P = H.exports.jsxs;
675
+ function zr({
676
+ postSubmit: l,
677
+ styles: o = J
107
678
  }) {
108
679
  const {
109
- control,
110
- handleSubmit,
111
- formState: {
112
- errors,
113
- isValidating,
114
- isValid
115
- }
116
- } = useForm({
680
+ control: v,
681
+ handleSubmit: d
682
+ } = Pr({
117
683
  defaultValues: {
118
684
  type: "postgresql",
119
685
  key: "",
@@ -126,48 +692,44 @@ function AddDataSourceForm({
126
692
  }
127
693
  }
128
694
  });
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, {
695
+ return /* @__PURE__ */ a(Ie, {
159
696
  mx: "auto",
160
- children: /* @__PURE__ */ jsxs("form", {
161
- onSubmit: handleSubmit(addDataSource),
162
- children: [/* @__PURE__ */ jsx(Controller, {
697
+ children: /* @__PURE__ */ P("form", {
698
+ onSubmit: d(async ({
699
+ type: u,
700
+ key: m,
701
+ config: _
702
+ }) => {
703
+ if (ze({
704
+ id: "for-creating",
705
+ title: "Pending",
706
+ message: "Adding data source...",
707
+ loading: !0
708
+ }), !await se.datasource.create(u, m, _)) {
709
+ ae({
710
+ id: "for-creating",
711
+ title: "Failed",
712
+ message: "Test connection failed with given info",
713
+ color: "red"
714
+ });
715
+ return;
716
+ }
717
+ ae({
718
+ id: "for-creating",
719
+ title: "Successful",
720
+ message: "Data source is added",
721
+ color: "green"
722
+ }), l();
723
+ }),
724
+ children: [/* @__PURE__ */ a(j, {
163
725
  name: "type",
164
- control,
726
+ control: v,
165
727
  render: ({
166
- field
167
- }) => /* @__PURE__ */ jsx(SegmentedControl, {
168
- fullWidth: true,
169
- mb: styles.spacing,
170
- size: styles.size,
728
+ field: u
729
+ }) => /* @__PURE__ */ a(Er, {
730
+ fullWidth: !0,
731
+ mb: o.spacing,
732
+ size: o.size,
171
733
  data: [{
172
734
  label: "PostgreSQL",
173
735
  value: "postgresql"
@@ -177,173 +739,161 @@ function AddDataSourceForm({
177
739
  }, {
178
740
  label: "HTTP",
179
741
  value: "http",
180
- disabled: true
742
+ disabled: !0
181
743
  }],
182
- ...field
744
+ ...u
183
745
  })
184
- }), /* @__PURE__ */ jsx(Controller, {
746
+ }), /* @__PURE__ */ a(j, {
185
747
  name: "key",
186
- control,
748
+ control: v,
187
749
  render: ({
188
- field
189
- }) => /* @__PURE__ */ jsx(TextInput, {
190
- mb: styles.spacing,
191
- size: styles.size,
192
- required: true,
750
+ field: u
751
+ }) => /* @__PURE__ */ a(B, {
752
+ mb: o.spacing,
753
+ size: o.size,
754
+ required: !0,
193
755
  label: "Name",
194
756
  placeholder: "A unique name",
195
- ...field
757
+ ...u
196
758
  })
197
- }), /* @__PURE__ */ jsx(Divider, {
759
+ }), /* @__PURE__ */ a(_r, {
198
760
  label: "Connection Info",
199
761
  labelPosition: "center"
200
- }), /* @__PURE__ */ jsxs(Group, {
201
- grow: true,
202
- children: [/* @__PURE__ */ jsx(Controller, {
762
+ }), /* @__PURE__ */ P(G, {
763
+ grow: !0,
764
+ children: [/* @__PURE__ */ a(j, {
203
765
  name: "config.host",
204
- control,
766
+ control: v,
205
767
  render: ({
206
- field
207
- }) => /* @__PURE__ */ jsx(TextInput, {
208
- mb: styles.spacing,
209
- size: styles.size,
210
- required: true,
768
+ field: u
769
+ }) => /* @__PURE__ */ a(B, {
770
+ mb: o.spacing,
771
+ size: o.size,
772
+ required: !0,
211
773
  label: "Host",
212
774
  sx: {
213
775
  flexGrow: 1
214
776
  },
215
- ...field
777
+ ...u
216
778
  })
217
- }), /* @__PURE__ */ jsx(Controller, {
779
+ }), /* @__PURE__ */ a(j, {
218
780
  name: "config.port",
219
- control,
781
+ control: v,
220
782
  render: ({
221
- field
222
- }) => /* @__PURE__ */ jsx(NumberInput, {
223
- mb: styles.spacing,
224
- size: styles.size,
225
- required: true,
783
+ field: u
784
+ }) => /* @__PURE__ */ a(yr, {
785
+ mb: o.spacing,
786
+ size: o.size,
787
+ required: !0,
226
788
  label: "Port",
227
- hideControls: true,
789
+ hideControls: !0,
228
790
  sx: {
229
791
  width: "8em"
230
792
  },
231
- ...field
793
+ ...u
232
794
  })
233
795
  })]
234
- }), /* @__PURE__ */ jsx(Controller, {
796
+ }), /* @__PURE__ */ a(j, {
235
797
  name: "config.username",
236
- control,
798
+ control: v,
237
799
  render: ({
238
- field
239
- }) => /* @__PURE__ */ jsx(TextInput, {
240
- mb: styles.spacing,
241
- size: styles.size,
242
- required: true,
800
+ field: u
801
+ }) => /* @__PURE__ */ a(B, {
802
+ mb: o.spacing,
803
+ size: o.size,
804
+ required: !0,
243
805
  label: "Username",
244
- ...field
806
+ ...u
245
807
  })
246
- }), /* @__PURE__ */ jsx(Controller, {
808
+ }), /* @__PURE__ */ a(j, {
247
809
  name: "config.password",
248
- control,
810
+ control: v,
249
811
  render: ({
250
- field
251
- }) => /* @__PURE__ */ jsx(PasswordInput, {
252
- mb: styles.spacing,
253
- size: styles.size,
254
- required: true,
812
+ field: u
813
+ }) => /* @__PURE__ */ a(Sr, {
814
+ mb: o.spacing,
815
+ size: o.size,
816
+ required: !0,
255
817
  label: "Password",
256
- ...field
818
+ ...u
257
819
  })
258
- }), /* @__PURE__ */ jsx(Controller, {
820
+ }), /* @__PURE__ */ a(j, {
259
821
  name: "config.database",
260
- control,
822
+ control: v,
261
823
  render: ({
262
- field
263
- }) => /* @__PURE__ */ jsx(TextInput, {
264
- mb: styles.spacing,
265
- size: styles.size,
266
- required: true,
824
+ field: u
825
+ }) => /* @__PURE__ */ a(B, {
826
+ mb: o.spacing,
827
+ size: o.size,
828
+ required: !0,
267
829
  label: "Database",
268
- ...field
830
+ ...u
269
831
  })
270
- }), /* @__PURE__ */ jsx(Group, {
832
+ }), /* @__PURE__ */ a(G, {
271
833
  position: "right",
272
- mt: styles.spacing,
273
- children: /* @__PURE__ */ jsx(Button, {
834
+ mt: o.spacing,
835
+ children: /* @__PURE__ */ a(ie, {
274
836
  type: "submit",
275
- size: styles.size,
837
+ size: o.size,
276
838
  children: "Save"
277
839
  })
278
840
  })]
279
841
  })
280
842
  });
281
843
  }
282
- function AddDataSource({
283
- onSuccess,
284
- styles = defaultStyles
844
+ function Lr({
845
+ onSuccess: l,
846
+ styles: o = J
285
847
  }) {
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, {
848
+ const [v, d] = oe.useState(!1), E = () => d(!0), u = () => d(!1);
849
+ return /* @__PURE__ */ P(Le, {
850
+ children: [/* @__PURE__ */ a(Rr, {
295
851
  overflow: "inside",
296
- opened,
297
- onClose: () => setOpened(false),
852
+ opened: v,
853
+ onClose: () => d(!1),
298
854
  title: "Add a data source",
299
- trapFocus: true,
300
- onDragStart: (e) => {
301
- e.stopPropagation();
855
+ trapFocus: !0,
856
+ onDragStart: (_) => {
857
+ _.stopPropagation();
302
858
  },
303
- children: /* @__PURE__ */ jsx(AddDataSourceForm, {
304
- postSubmit,
305
- styles
859
+ children: /* @__PURE__ */ a(zr, {
860
+ postSubmit: () => {
861
+ l(), u();
862
+ },
863
+ styles: o
306
864
  })
307
- }), /* @__PURE__ */ jsx(Button, {
308
- size: styles.size,
309
- onClick: open,
310
- leftIcon: /* @__PURE__ */ jsx(PlaylistAdd, {
865
+ }), /* @__PURE__ */ a(ie, {
866
+ size: o.size,
867
+ onClick: E,
868
+ leftIcon: /* @__PURE__ */ a(Or, {
311
869
  size: 20
312
870
  }),
313
871
  children: "Add a Data Source"
314
872
  })]
315
873
  });
316
874
  }
317
- function DeleteDataSource({
318
- id,
319
- name,
320
- onSuccess,
321
- styles = defaultStyles
875
+ function Wr({
876
+ id: l,
877
+ name: o,
878
+ onSuccess: v,
879
+ styles: d = J
322
880
  }) {
323
- const modals = useModals();
324
- const doDelete = async () => {
325
- if (!id) {
326
- return;
327
- }
328
- showNotification({
881
+ const E = kr(), u = async () => {
882
+ !l || (ze({
329
883
  id: "for-deleting",
330
884
  title: "Pending",
331
885
  message: "Deleting data source...",
332
- loading: true
333
- });
334
- await APICaller.datasource.delete(id);
335
- updateNotification({
886
+ loading: !0
887
+ }), await se.datasource.delete(l), ae({
336
888
  id: "for-deleting",
337
889
  title: "Successful",
338
- message: `Data source [${name}] is deleted`,
890
+ message: `Data source [${o}] is deleted`,
339
891
  color: "green"
340
- });
341
- onSuccess();
342
- };
343
- const confirmAndDelete = () => modals.openConfirmModal({
892
+ }), v());
893
+ }, m = () => E.openConfirmModal({
344
894
  title: "Delete this data source?",
345
- children: /* @__PURE__ */ jsx(Text, {
346
- size: styles.size,
895
+ children: /* @__PURE__ */ a(Tr, {
896
+ size: d.size,
347
897
  children: "This action won't affect your database."
348
898
  }),
349
899
  labels: {
@@ -351,92 +901,93 @@ function DeleteDataSource({
351
901
  cancel: "Cancel"
352
902
  },
353
903
  onCancel: () => console.log("Cancel"),
354
- onConfirm: doDelete
904
+ onConfirm: u
355
905
  });
356
- return /* @__PURE__ */ jsx(Button, {
357
- size: styles.size,
906
+ return /* @__PURE__ */ a(ie, {
907
+ size: d.size,
358
908
  color: "red",
359
- onClick: confirmAndDelete,
360
- leftIcon: /* @__PURE__ */ jsx(Trash, {
909
+ onClick: m,
910
+ leftIcon: /* @__PURE__ */ a(xr, {
361
911
  size: 20
362
912
  }),
363
913
  children: "Delete"
364
914
  });
365
915
  }
366
- function DataSourceList({
367
- styles = defaultStyles,
368
- config
916
+ function Gr({
917
+ styles: l = J,
918
+ config: o
369
919
  }) {
370
920
  const {
371
- data = [],
372
- loading,
373
- refresh
374
- } = useRequest(async () => {
921
+ data: v = [],
922
+ loading: d,
923
+ refresh: E
924
+ } = Dr(async () => {
375
925
  const {
376
- data: data2
377
- } = await APICaller.datasource.list();
378
- return data2;
926
+ data: u
927
+ } = await se.datasource.list();
928
+ return u;
379
929
  }, {
380
930
  refreshDeps: []
381
931
  });
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,
932
+ return $.baseURL !== o.apiBaseURL && ($.baseURL = o.apiBaseURL), /* @__PURE__ */ P(Le, {
933
+ children: [/* @__PURE__ */ a(G, {
934
+ pt: l.spacing,
388
935
  position: "right",
389
- children: /* @__PURE__ */ jsx(AddDataSource, {
390
- onSuccess: refresh
936
+ children: /* @__PURE__ */ a(Lr, {
937
+ onSuccess: E
391
938
  })
392
- }), /* @__PURE__ */ jsxs(Box, {
393
- mt: styles.spacing,
939
+ }), /* @__PURE__ */ P(Ie, {
940
+ mt: l.spacing,
394
941
  sx: {
395
942
  position: "relative"
396
943
  },
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", {
944
+ children: [/* @__PURE__ */ a(wr, {
945
+ visible: d
946
+ }), /* @__PURE__ */ P(Cr, {
947
+ horizontalSpacing: l.spacing,
948
+ verticalSpacing: l.spacing,
949
+ fontSize: l.size,
950
+ highlightOnHover: !0,
951
+ children: [/* @__PURE__ */ a("thead", {
952
+ children: /* @__PURE__ */ P("tr", {
953
+ children: [/* @__PURE__ */ a("th", {
407
954
  children: "Type"
408
- }), /* @__PURE__ */ jsx("th", {
955
+ }), /* @__PURE__ */ a("th", {
409
956
  children: "Name"
410
- }), /* @__PURE__ */ jsx("th", {
957
+ }), /* @__PURE__ */ a("th", {
411
958
  children: "Action"
412
959
  })]
413
960
  })
414
- }), /* @__PURE__ */ jsx("tbody", {
415
- children: data.map(({
416
- id,
417
- key,
418
- type
419
- }) => /* @__PURE__ */ jsxs("tr", {
420
- children: [/* @__PURE__ */ jsx("td", {
961
+ }), /* @__PURE__ */ a("tbody", {
962
+ children: v.map(({
963
+ id: u,
964
+ key: m,
965
+ type: _
966
+ }) => /* @__PURE__ */ P("tr", {
967
+ children: [/* @__PURE__ */ a("td", {
421
968
  width: 200,
422
- children: type
423
- }), /* @__PURE__ */ jsx("td", {
424
- children: key
425
- }), /* @__PURE__ */ jsx("td", {
969
+ children: _
970
+ }), /* @__PURE__ */ a("td", {
971
+ children: m
972
+ }), /* @__PURE__ */ a("td", {
426
973
  width: 200,
427
- children: /* @__PURE__ */ jsx(Group, {
974
+ children: /* @__PURE__ */ a(G, {
428
975
  position: "left",
429
- children: /* @__PURE__ */ jsx(DeleteDataSource, {
430
- id,
431
- name: key,
432
- onSuccess: refresh
976
+ children: /* @__PURE__ */ a(Wr, {
977
+ id: u,
978
+ name: m,
979
+ onSuccess: E
433
980
  })
434
981
  })
435
982
  })]
436
- }, key))
983
+ }, m))
437
984
  })]
438
985
  })]
439
986
  })]
440
987
  });
441
988
  }
442
- export { AddDataSource, DataSourceList, DeleteDataSource };
989
+ export {
990
+ Lr as AddDataSource,
991
+ Gr as DataSourceList,
992
+ Wr as DeleteDataSource
993
+ };