@devtable/settings-form 6.47.0 → 7.1.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.
- package/dist/api-caller/datasource.d.ts +2 -2
- package/dist/api-caller/datasource.typed.d.ts +10 -2
- package/dist/api-caller/index.d.ts +1 -1
- package/dist/datasource/add-data-source/components/function-string-field/function-string-editor.d.ts +7 -0
- package/dist/datasource/add-data-source/components/function-string-field/index.d.ts +12 -0
- package/dist/datasource/add-data-source/forms/database.d.ts +15 -0
- package/dist/datasource/add-data-source/forms/http.d.ts +18 -0
- package/dist/datasource/{add-data-source.d.ts → add-data-source/index.d.ts} +1 -1
- package/dist/datasource/add-data-source/types.d.ts +6 -0
- package/dist/global.d.ts +2 -0
- package/dist/{package.fda35c32.mjs → package.a4467417.mjs} +1 -1
- package/dist/settings-form.es.js +2769 -1158
- package/dist/settings-form.umd.js +41 -10
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(J,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@mantine/core"),require("@mantine/notifications"),require("react"),require("tabler-icons-react"),require("axios"),require("crypto-js"),require("lodash"),require("react-hook-form"),require("ahooks"),require("@mantine/modals")):typeof define=="function"&&define.amd?define(["exports","@mantine/core","@mantine/notifications","react","tabler-icons-react","axios","crypto-js","lodash","react-hook-form","ahooks","@mantine/modals"],f):(J=typeof globalThis<"u"?globalThis:J||self,f(J["settings-form"]={},J["@mantine/core"],J["@mantine/notifications"],J.React,J["tabler-icons-react"],J.axios,J["crypto-js"],J._,J["react-hook-form"],J.ahooks,J["@mantine/modals"]))})(this,function(J,f,ee,O,Te,xr,_r,Cr,Y,Re,Ie){"use strict";const Ue=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function jr(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const _e=Ue(O),De=jr(O),Ar=Ue(xr),Mr=Ue(_r),Ir=Ue(Cr);function Dr(e){e=e||{};const t=Object.keys(e).sort(),r=[];for(let i=0;i<t.length;i++){const s=t[i];if(s!="authentication"&&e[s])r.push(t[i]+"="+(typeof e[s]=="object"?JSON.stringify(e[s]):e[s]));else{const o=Object.keys(e[s]).sort();for(let c=0;c<o.length;c++){const u=o[c];u!="sign"&&e[s][u]&&r.push(o[c]+"="+(typeof e[s][u]=="object"?JSON.stringify(e[s][u]):e[s][u]))}}}return r.sort().join("&")}function zr(e,t){let r=Dr(e);return r+="&key="+t,Mr.default.MD5(r).toString().toUpperCase()}const ae={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:zr({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e){return(t,r,i={})=>{const s=window.localStorage.getItem("token"),o={"X-Requested-With":"XMLHttpRequest","Content-Type":i.string?"application/x-www-form-urlencoded":"application/json",authorization:s?`bearer ${s}`:"",...i.headers},c={baseURL:this.baseURL,method:e,url:t,params:e==="GET"?r:i.params,headers:o};return["POST","PUT"].includes(e)&&(c.data=i.string?JSON.stringify(r):r,c.data.authentication=this.getAuthentication(c.data)),Ar.default(c).then(u=>u.data).catch(u=>Ir.default.has(u,"response.data.detail.message")?Promise.reject(new Error(u.response.data.detail.message)):Promise.reject(u))}}};function Be(e){ae.baseURL!==e.apiBaseURL&&(ae.baseURL=e.apiBaseURL),e.app_id&&(ae.app_id=e.app_id),e.app_secret&&(ae.app_secret=e.app_secret)}const de={datasource:{list:async()=>await ae.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}}),create:async(e,t,r)=>await ae.getRequest("POST")("/datasource/create",{type:e,key:t,config:r}),delete:async e=>{await ae.getRequest("POST")("/datasource/delete",{id:e})}},account:{login:async(e,t)=>{const r={name:e,password:t};return await ae.getRequest("POST")("/account/login",r)},list:async()=>await ae.getRequest("POST")("/account/list",{filter:{search:""},sort:{field:"name",order:"ASC"},pagination:{page:1,pagesize:100}}),get:async()=>await ae.getRequest("GET")("/account/get",{}),update:async(e,t)=>{const r={name:e,email:t};return await ae.getRequest("PUT")("/account/update",r)},changepassword:async(e,t)=>{const r={old_password:e,new_password:t};return await ae.getRequest("POST")("/account/changepassword",r)},create:async(e,t,r,i)=>await ae.getRequest("POST")("/account/create",{name:e,email:t,password:r,role_id:i}),edit:async e=>(e.reset_password||(e.new_password=void 0),await ae.getRequest("PUT")("/account/edit",e)),delete:async e=>{if(!!e)return ae.getRequest("POST")("/account/delete",{id:e})}},role:{list:async()=>await ae.getRequest("GET")("/role/list",{})},api_key:{list:async()=>await ae.getRequest("POST")("/api/key/list",{filter:{search:""},sort:{field:"name",order:"ASC"},pagination:{page:1,pagesize:100}}),create:async(e,t)=>ae.getRequest("POST")("/api/key/create",{name:e,role_id:t}),delete:async e=>{if(!!e)return ae.getRequest("POST")("/api/key/delete",{id:e})}}},Ce={size:"sm",spacing:"md",button:{size:"xs"}};var We={exports:{}},ze={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var bt;function qr(){if(bt)return ze;bt=1;var e=_e.default,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(u,p,m){var w,v={},y=null,j=null;m!==void 0&&(y=""+m),p.key!==void 0&&(y=""+p.key),p.ref!==void 0&&(j=p.ref);for(w in p)i.call(p,w)&&!o.hasOwnProperty(w)&&(v[w]=p[w]);if(u&&u.defaultProps)for(w in p=u.defaultProps,p)v[w]===void 0&&(v[w]=p[w]);return{$$typeof:t,type:u,key:y,ref:j,props:v,_owner:s.current}}return ze.Fragment=r,ze.jsx=c,ze.jsxs=c,ze}var qe={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,14 +14,45 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var wt;function kr(){return wt||(wt=1,process.env.NODE_ENV!=="production"&&function(){var e=_e.default,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),V=Symbol.iterator,k="@@iterator";function H(n){if(n===null||typeof n!="object")return null;var d=V&&n[V]||n[k];return typeof d=="function"?d:null}var Q=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function $(n){{for(var d=arguments.length,b=new Array(d>1?d-1:0),E=1;E<d;E++)b[E-1]=arguments[E];Z("error",n,b)}}function Z(n,d,b){{var E=Q.ReactDebugCurrentFrame,U=E.getStackAddendum();U!==""&&(d+="%s",b=b.concat([U]));var K=b.map(function(L){return String(L)});K.unshift("Warning: "+d),Function.prototype.apply.call(console[n],console,K)}}var G=!1,g=!1,te=!1,ie=!1,ye=!1,re;re=Symbol.for("react.module.reference");function F(n){return!!(typeof n=="string"||typeof n=="function"||n===i||n===o||ye||n===s||n===m||n===w||ie||n===j||G||g||te||typeof n=="object"&&n!==null&&(n.$$typeof===y||n.$$typeof===v||n.$$typeof===c||n.$$typeof===u||n.$$typeof===p||n.$$typeof===re||n.getModuleId!==void 0))}function pe(n,d,b){var E=n.displayName;if(E)return E;var U=d.displayName||d.name||"";return U!==""?b+"("+U+")":b}function me(n){return n.displayName||"Context"}function ce(n){if(n==null)return null;if(typeof n.tag=="number"&&$("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case i:return"Fragment";case r:return"Portal";case o:return"Profiler";case s:return"StrictMode";case m:return"Suspense";case w:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case u:var d=n;return me(d)+".Consumer";case c:var b=n;return me(b._context)+".Provider";case p:return pe(n,n.render,"ForwardRef");case v:var E=n.displayName||null;return E!==null?E:ce(n.type)||"Memo";case y:{var U=n,K=U._payload,L=U._init;try{return ce(L(K))}catch{return null}}}return null}var q=Object.assign,X=0,se,fe,be,Pe,l,h,P;function R(){}R.__reactDisabledLog=!0;function x(){{if(X===0){se=console.log,fe=console.info,be=console.warn,Pe=console.error,l=console.group,h=console.groupCollapsed,P=console.groupEnd;var n={configurable:!0,enumerable:!0,value:R,writable:!0};Object.defineProperties(console,{info:n,log:n,warn:n,error:n,group:n,groupCollapsed:n,groupEnd:n})}X++}}function A(){{if(X--,X===0){var n={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:q({},n,{value:se}),info:q({},n,{value:fe}),warn:q({},n,{value:be}),error:q({},n,{value:Pe}),group:q({},n,{value:l}),groupCollapsed:q({},n,{value:h}),groupEnd:q({},n,{value:P})})}X<0&&$("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var _=Q.ReactCurrentDispatcher,C;function M(n,d,b){{if(C===void 0)try{throw Error()}catch(U){var E=U.stack.trim().match(/\n( *(at )?)/);C=E&&E[1]||""}return`
|
|
18
|
+
`+C+n}}var N=!1,I;{var ue=typeof WeakMap=="function"?WeakMap:Map;I=new ue}function S(n,d){if(!n||N)return"";{var b=I.get(n);if(b!==void 0)return b}var E;N=!0;var U=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var K;K=_.current,_.current=null,x();try{if(d){var L=function(){throw Error()};if(Object.defineProperty(L.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(L,[])}catch(Se){E=Se}Reflect.construct(n,[],L)}else{try{L.call()}catch(Se){E=Se}n.call(L.prototype)}}else{try{throw Error()}catch(Se){E=Se}n()}}catch(Se){if(Se&&E&&typeof Se.stack=="string"){for(var z=Se.stack.split(`
|
|
19
|
+
`),le=E.stack.split(`
|
|
20
|
+
`),ne=z.length-1,oe=le.length-1;ne>=1&&oe>=0&&z[ne]!==le[oe];)oe--;for(;ne>=1&&oe>=0;ne--,oe--)if(z[ne]!==le[oe]){if(ne!==1||oe!==1)do if(ne--,oe--,oe<0||z[ne]!==le[oe]){var he=`
|
|
21
|
+
`+z[ne].replace(" at new "," at ");return n.displayName&&he.includes("<anonymous>")&&(he=he.replace("<anonymous>",n.displayName)),typeof n=="function"&&I.set(n,he),he}while(ne>=1&&oe>=0);break}}}finally{N=!1,_.current=K,A(),Error.prepareStackTrace=U}var Me=n?n.displayName||n.name:"",Rr=Me?M(Me):"";return typeof n=="function"&&I.set(n,Rr),Rr}function ge(n,d,b){return S(n,!1)}function je(n){var d=n.prototype;return!!(d&&d.isReactComponent)}function xe(n,d,b){if(n==null)return"";if(typeof n=="function")return S(n,je(n));if(typeof n=="string")return M(n);switch(n){case m:return M("Suspense");case w:return M("SuspenseList")}if(typeof n=="object")switch(n.$$typeof){case p:return ge(n.render);case v:return xe(n.type,d,b);case y:{var E=n,U=E._payload,K=E._init;try{return xe(K(U),d,b)}catch{}}}return""}var Ze=Object.prototype.hasOwnProperty,gr={},hr=Q.ReactDebugCurrentFrame;function He(n){if(n){var d=n._owner,b=xe(n.type,n._source,d?d.type:null);hr.setExtraStackFrame(b)}else hr.setExtraStackFrame(null)}function oi(n,d,b,E,U){{var K=Function.call.bind(Ze);for(var L in n)if(K(n,L)){var z=void 0;try{if(typeof n[L]!="function"){var le=Error((E||"React class")+": "+b+" type `"+L+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[L]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}z=n[L](d,L,E,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ne){z=ne}z&&!(z instanceof Error)&&(He(U),$("%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).",E||"React class",b,L,typeof z),He(null)),z instanceof Error&&!(z.message in gr)&&(gr[z.message]=!0,He(U),$("Failed %s type: %s",b,z.message),He(null))}}}var ai=Array.isArray;function gt(n){return ai(n)}function si(n){{var d=typeof Symbol=="function"&&Symbol.toStringTag,b=d&&n[Symbol.toStringTag]||n.constructor.name||"Object";return b}}function ci(n){try{return vr(n),!1}catch{return!0}}function vr(n){return""+n}function mr(n){if(ci(n))return $("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",si(n)),vr(n)}var Fe=Q.ReactCurrentOwner,ui={key:!0,ref:!0,__self:!0,__source:!0},yr,br,ht;ht={};function li(n){if(Ze.call(n,"ref")){var d=Object.getOwnPropertyDescriptor(n,"ref").get;if(d&&d.isReactWarning)return!1}return n.ref!==void 0}function di(n){if(Ze.call(n,"key")){var d=Object.getOwnPropertyDescriptor(n,"key").get;if(d&&d.isReactWarning)return!1}return n.key!==void 0}function fi(n,d){if(typeof n.ref=="string"&&Fe.current&&d&&Fe.current.stateNode!==d){var b=ce(Fe.current.type);ht[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',ce(Fe.current.type),n.ref),ht[b]=!0)}}function pi(n,d){{var b=function(){yr||(yr=!0,$("%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)",d))};b.isReactWarning=!0,Object.defineProperty(n,"key",{get:b,configurable:!0})}}function gi(n,d){{var b=function(){br||(br=!0,$("%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)",d))};b.isReactWarning=!0,Object.defineProperty(n,"ref",{get:b,configurable:!0})}}var hi=function(n,d,b,E,U,K,L){var z={$$typeof:t,type:n,key:d,ref:b,props:L,_owner:K};return z._store={},Object.defineProperty(z._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(z,"_self",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.defineProperty(z,"_source",{configurable:!1,enumerable:!1,writable:!1,value:U}),Object.freeze&&(Object.freeze(z.props),Object.freeze(z)),z};function vi(n,d,b,E,U){{var K,L={},z=null,le=null;b!==void 0&&(mr(b),z=""+b),di(d)&&(mr(d.key),z=""+d.key),li(d)&&(le=d.ref,fi(d,U));for(K in d)Ze.call(d,K)&&!ui.hasOwnProperty(K)&&(L[K]=d[K]);if(n&&n.defaultProps){var ne=n.defaultProps;for(K in ne)L[K]===void 0&&(L[K]=ne[K])}if(z||le){var oe=typeof n=="function"?n.displayName||n.name||"Unknown":n;z&&pi(L,oe),le&&gi(L,oe)}return hi(n,z,le,U,E,Fe.current,L)}}var vt=Q.ReactCurrentOwner,wr=Q.ReactDebugCurrentFrame;function Ae(n){if(n){var d=n._owner,b=xe(n.type,n._source,d?d.type:null);wr.setExtraStackFrame(b)}else wr.setExtraStackFrame(null)}var mt;mt=!1;function yt(n){return typeof n=="object"&&n!==null&&n.$$typeof===t}function Sr(){{if(vt.current){var n=ce(vt.current.type);if(n)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+
|
|
23
|
+
Check the render method of \``+n+"`."}return""}}function mi(n){{if(n!==void 0){var d=n.fileName.replace(/^.*[\\\/]/,""),b=n.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+
|
|
25
|
+
Check your code at `+d+":"+b+"."}return""}}var Tr={};function yi(n){{var d=Sr();if(!d){var b=typeof n=="string"?n:n.displayName||n.name;b&&(d=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+c+">.")}return a}}function ct(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=fr(a);if(lt[c])return;lt[c]=!0;var g="";e&&e._owner&&e._owner!==ye.current&&(g=" It was passed a child from "+k(e._owner.type)+"."),G(e),A('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,g),G(null)}}function ut(e,a){{if(typeof e!="object")return;if(ve(e))for(var c=0;c<e.length;c++){var g=e[c];_e(g)&&ct(g,a)}else if(_e(e))e._store&&(e._store.validated=!0);else if(e){var y=pe(e);if(typeof y=="function"&&y!==e.entries)for(var P=y.call(e),b;!(b=P.next()).done;)_e(b.value)&&ct(b.value,a)}}}function pr(e){{var a=e.type;if(a==null||typeof a=="string")return;var c;if(typeof a=="function")c=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===h||a.$$typeof===m))c=a.propTypes;else return;if(c){var g=k(a);Ht(c,e.props,"prop",g,e)}else if(a.PropTypes!==void 0&&!we){we=!0;var y=k(a);A("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&A("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function gr(e){{for(var a=Object.keys(e.props),c=0;c<a.length;c++){var g=a[c];if(g!=="children"&&g!=="key"){G(e),A("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),G(null);break}}e.ref!==null&&(G(e),A("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}function dt(e,a,c,g,y,P){{var b=Yt(e);if(!b){var v="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(v+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var z=dr(y);z?v+=z:v+=st();var E;e===null?E="null":ve(e)?E="array":e!==void 0&&e.$$typeof===n?(E="<"+(k(e.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,A("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,v)}var x=ur(e,a,c,y,P);if(x==null)return x;if(b){var I=a.children;if(I!==void 0)if(g)if(ve(I)){for(var K=0;K<I.length;K++)ut(I[K],e);Object.freeze&&Object.freeze(I)}else A("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ut(I,e)}return e===l?gr(x):pr(x),x}}function hr(e,a,c){return dt(e,a,c,!0)}function mr(e,a,c){return dt(e,a,c,!1)}var vr=mr,br=hr;Z.Fragment=l,Z.jsx=vr,Z.jsxs=br}()),Z}(function(t){process.env.NODE_ENV==="production"?t.exports=St():t.exports=Pt()})(ae);const N=ae.exports.Fragment,r=ae.exports.jsx,w=ae.exports.jsxs;function Rt({postSubmit:t,styles:n=ne}){const{control:o,handleSubmit:l}=C.useForm({defaultValues:{type:"postgresql",key:"",config:{host:"",port:5432,username:"",password:"",database:""}}}),d=async({type:i,key:u,config:f})=>{T.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{await D.datasource.create(i,u,f),T.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),t()}catch(h){T.updateNotification({id:"for-creating",title:"Failed",message:h.message,color:"red"})}};return r(s.Box,{mx:"auto",children:w("form",{onSubmit:l(d),children:[r(C.Controller,{name:"type",control:o,render:({field:i})=>r(s.SegmentedControl,{fullWidth:!0,mb:n.spacing,size:n.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http",disabled:!0}],...i})}),r(C.Controller,{name:"key",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",placeholder:"A unique name",...i})}),r(s.Divider,{label:"Connection Info",labelPosition:"center"}),w(s.Group,{grow:!0,children:[r(C.Controller,{name:"config.host",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Host",sx:{flexGrow:1},...i})}),r(C.Controller,{name:"config.port",control:o,render:({field:i})=>r(s.NumberInput,{mb:n.spacing,size:n.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...i})})]}),r(C.Controller,{name:"config.username",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),r(C.Controller,{name:"config.password",control:o,render:({field:i})=>r(s.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),r(C.Controller,{name:"config.database",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Database",...i})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Re({onSuccess:t,styles:n=ne}){const[o,l]=Y.default.useState(!1),d=()=>l(!0),i=()=>l(!1),u=()=>{t(),i()};return w(N,{children:[r(s.Modal,{overflow:"inside",opened:o,onClose:()=>l(!1),title:"Add a data source",trapFocus:!0,onDragStart:f=>{f.stopPropagation()},children:r(Rt,{postSubmit:u,styles:n})}),r(s.Button,{size:n.button.size,onClick:d,leftIcon:r(F.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function de(){return de=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(t[l]=o[l])}return t},de.apply(this,arguments)}function Ct(t,n){if(t==null)return{};var o,l,d=function(u,f){if(u==null)return{};var h,S,_={},m=Object.keys(u);for(S=0;S<m.length;S++)h=m[S],f.indexOf(h)>=0||(_[h]=u[h]);return _}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(l=0;l<i.length;l++)o=i[l],n.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(d[o]=t[o])}return d}var Tt=["size","color","stroke"];function Et(t){var n=t.size,o=n===void 0?24:n,l=t.color,d=l===void 0?"currentColor":l,i=t.stroke,u=i===void 0?2:i,f=Ct(t,Tt);return X.createElement("svg",de({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-lock",width:o,height:o,viewBox:"0 0 24 24",strokeWidth:u,stroke:d,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),X.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),X.createElement("rect",{x:5,y:11,width:14,height:10,rx:2}),X.createElement("circle",{cx:12,cy:16,r:1}),X.createElement("path",{d:"M8 11v-4a4 4 0 0 1 8 0v4"}))}function Ce({id:t,name:n,isProtected:o,onSuccess:l,styles:d=ne}){const i=J.useModals(),u=async()=>{!t||(T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await D.datasource.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${n}] is deleted`,color:"green"}),l())},f=()=>i.openConfirmModal({title:"Delete this data source?",children:r(s.Text,{size:d.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:u}),h=s.useMantineTheme();return o?r(s.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:r("span",{children:r(Et,{size:16,color:h.colors.gray[7]})})}):r(s.Button,{size:d.button.size,color:"red",onClick:f,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function xt({styles:t=ne,config:n}){re(n);const{data:o=[],loading:l,refresh:d}=V.useRequest(async()=>{const{data:i}=await D.datasource.list();return i},{refreshDeps:[]});return w(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(Re,{onSuccess:d})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("tr",{children:[r("th",{children:"Type"}),r("th",{children:"Name"}),r("th",{children:"Action"})]})}),r("tbody",{children:o.map(({id:i,key:u,type:f,is_preset:h})=>w("tr",{children:[r("td",{width:200,children:f}),r("td",{children:u}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Ce,{isProtected:h,id:i,name:u,onSuccess:d})})})]},u))})]})]})]})}const Ot=W.forwardRef(({label:t,value:n,description:o,...l},d)=>w(s.Stack,{spacing:2,ref:d,...l,children:[r(s.Text,{size:"sm",children:t}),r(s.Text,{size:"xs",color:"dimmed",className:"role-description",children:o})]})),fe=W.forwardRef(({styles:t,value:n,onChange:o},l)=>{const{data:d=[],loading:i}=V.useRequest(async()=>(await D.role.list()).map(f=>({label:f.name,value:f.id,description:f.description,disabled:f.id===50})),{refreshDeps:[]});return r(s.Select,{ref:l,mb:t.spacing,size:t.size,required:!0,label:"Role",itemComponent:Ot,data:d,disabled:i,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:n,onChange:o})}),L={size:"sm",spacing:"md",button:{size:"xs"}};function At({postSubmit:t,styles:n=L,initialRoleID:o}){const{control:l,handleSubmit:d}=C.useForm({defaultValues:{name:"",email:"",role_id:o,password:""}}),i=async({name:u,email:f,password:h,role_id:S})=>{try{T.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await D.account.create(u,f,h,S),T.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),t()}catch(_){T.updateNotification({id:"for-creating",title:"Failed",message:_.message,color:"red"})}};return r(s.Box,{mx:"auto",children:w("form",{onSubmit:d(i),children:[r(C.Controller,{name:"name",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...u})}),r(C.Controller,{name:"email",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Email",...u})}),r(C.Controller,{name:"password",control:l,render:({field:u})=>r(s.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...u})}),r(C.Controller,{name:"role_id",control:l,render:({field:u})=>r(fe,{styles:n,...u})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Te({onSuccess:t,styles:n=L,initialRoleID:o}){const[l,d]=Y.default.useState(!1),i=()=>d(!0),u=()=>d(!1),f=()=>{t(),u()};return w(N,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>d(!1),title:"Add an Account",trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:r(At,{postSubmit:f,styles:n,initialRoleID:o})}),r(s.Button,{size:n.button.size,onClick:i,leftIcon:r(F.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Ee({id:t,name:n,onSuccess:o,styles:l=L}){const d=J.useModals(),i=async()=>{if(!!t){T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await D.account.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${n}] is deleted`,color:"green"}),o()}catch(f){T.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},u=()=>d.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return r(s.Button,{size:l.button.size,color:"red",onClick:u,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function zt({id:t,name:n,email:o,role_id:l,postSubmit:d,styles:i=L}){const{control:u,handleSubmit:f,watch:h}=C.useForm({defaultValues:{name:n,email:o,role_id:l,reset_password:!1,new_password:""}}),S=async({name:p,email:j,role_id:M,reset_password:B,new_password:pe})=>{try{T.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await D.account.edit({id:t,name:p,email:j,role_id:M,reset_password:B,new_password:pe}),T.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),d()}catch($){T.updateNotification({id:"for-updating",title:"Failed",message:$.message,color:"red"})}},[_,m]=h(["reset_password","new_password"]);return r(s.Box,{mx:"auto",children:w("form",{onSubmit:f(S),children:[r(C.Controller,{name:"name",control:u,render:({field:p})=>r(s.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Username",...p})}),r(C.Controller,{name:"email",control:u,render:({field:p})=>r(s.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Email",...p})}),r(C.Controller,{name:"role_id",control:u,render:({field:p})=>r(fe,{styles:i,...p})}),r(s.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),r(C.Controller,{name:"reset_password",control:u,render:({field:p})=>r(s.Switch,{mb:i.spacing,size:i.size,label:"Reset password",checked:p.value,onChange:j=>p.onChange(j.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),_&&r(C.Controller,{name:"new_password",control:u,render:({field:p})=>r(s.PasswordInput,{autoComplete:"off",mb:i.spacing,size:i.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...p})}),r(s.Group,{position:"right",mt:i.spacing,children:r(s.Button,{type:"submit",size:i.button.size,children:"Submit"})})]})})}function Dt({account:t,onSuccess:n,styles:o=L}){const[l,d]=Y.default.useState(!1),i=()=>d(!0),u=()=>d(!1),f=()=>{n(),u()};return w(N,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>d(!1),title:`Editing ${t.name}`,trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:r(zt,{...t,postSubmit:f,styles:o})}),r(s.Button,{size:o.button.size,onClick:i,leftIcon:r(F.Edit,{size:20}),children:"Edit"})]})}function jt({styles:t=L,config:n}){var S,_;re(n);const{data:o=[],loading:l,refresh:d}=V.useRequest(async()=>{const{data:m}=await D.account.list();return m},{refreshDeps:[]}),{data:i=[],loading:u}=V.useRequest(async()=>(await D.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=W.useMemo(()=>i.reduce((m,p)=>(m.set(p.value,p.label),m),new Map),[i]),h=m=>{var p;return(p=f.get(m))!=null?p:m};return w(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(Te,{onSuccess:d,initialRoleID:(_=(S=i==null?void 0:i[0])==null?void 0:S.value)!=null?_:0})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||u}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("tr",{children:[r("th",{children:"Username"}),r("th",{children:"Email"}),r("th",{children:"Role"}),r("th",{children:"Action"})]})}),r("tbody",{children:o.map(m=>{const{id:p,name:j,email:M,role_id:B}=m;return w("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:M}),r("td",{width:200,children:h(B)}),r("td",{width:200,children:w(s.Group,{position:"left",children:[r(Dt,{account:m,onSuccess:d}),r(Ee,{id:p,name:j,onSuccess:d})]})})]},p)})})]})]})]})}function It({postSubmit:t,styles:n=L}){const{control:o,handleSubmit:l}=C.useForm({defaultValues:{name:"",password:""}}),d=async({name:i,password:u})=>{try{T.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const f=await D.account.login(i,u);window.localStorage.setItem("token",f.token),T.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),t(f)}catch(f){T.updateNotification({id:"for-login",title:"Login Failed",message:f.message,color:"red"})}};return r(s.Box,{mx:"auto",children:w("form",{onSubmit:l(d),children:[r(C.Controller,{name:"name",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),r(C.Controller,{name:"password",control:o,render:({field:i})=>r(s.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Submit"})})]})})}function kt({styles:t=L,config:n,onSuccess:o}){return re(n),r(N,{children:r(s.Box,{mt:t.spacing,sx:{position:"relative"},children:r(It,{styles:t,postSubmit:o})})})}const ie={size:"sm",spacing:"md",button:{size:"xs"}};function qt({postSubmit:t,styles:n=ie,initialRoleID:o}){const{control:l,handleSubmit:d}=C.useForm({defaultValues:{name:"",role_id:o}}),i=async({name:u,role_id:f})=>{try{T.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:h,app_secret:S}=await D.api_key.create(u,f);T.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),t(h,S)}catch(h){T.updateNotification({id:"for-creating",title:"Failed",message:h.message,color:"red"})}};return r(s.Box,{mx:"auto",children:w("form",{onSubmit:d(i),children:[r(C.Controller,{name:"name",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",...u})}),r(C.Controller,{name:"role_id",control:l,render:({field:u})=>r(fe,{styles:n,...u})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function xe({onSuccess:t,styles:n=ie,initialRoleID:o}){const l=J.useModals(),[d,i]=Y.default.useState(!1),u=()=>i(!0),f=()=>i(!1),h=(S,_)=>{f(),l.openModal({title:"API Key is generated",children:w(s.Stack,{children:[r(s.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),r(s.TextInput,{defaultValue:S,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),r(s.TextInput,{defaultValue:_,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),r(s.Button,{size:"sm",onClick:()=>{J.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{t()}})};return w(N,{children:[r(s.Modal,{overflow:"inside",opened:d,onClose:()=>i(!1),title:"Add an API Key",trapFocus:!0,onDragStart:S=>{S.stopPropagation()},children:r(qt,{postSubmit:h,styles:n,initialRoleID:o})}),r(s.Button,{size:n.button.size,onClick:u,leftIcon:r(F.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function Oe({id:t,name:n,onSuccess:o,styles:l=ie}){const d=J.useModals(),i=async()=>{if(!!t){T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await D.api_key.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${n}] is deleted`,color:"green"}),o()}catch(f){T.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},u=()=>d.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return r(s.Button,{size:l.button.size,color:"red",onClick:u,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function Nt({styles:t=ie,config:n}){var S,_;re(n);const{data:o=[],loading:l,refresh:d}=V.useRequest(async()=>{const{data:m}=await D.api_key.list();return m},{refreshDeps:[]}),{data:i=[],loading:u}=V.useRequest(async()=>(await D.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=W.useMemo(()=>i.reduce((m,p)=>(m.set(p.value,p.label),m),new Map),[i]),h=m=>{var p;return(p=f.get(m))!=null?p:m};return w(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(xe,{onSuccess:d,initialRoleID:(_=(S=i==null?void 0:i[0])==null?void 0:S.value)!=null?_:0})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||u}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("tr",{children:[r("th",{children:"Name"}),r("th",{children:"APP ID"}),r("th",{children:"Role"}),r("th",{children:"Action"})]})}),r("tbody",{children:o.map(m=>{const{id:p,name:j,app_id:M,role_id:B}=m;return w("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:M}),r("td",{width:200,children:h(B)}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Oe,{id:p,name:j,onSuccess:d})})})]},p)})})]})]})]})}const Lt=()=>Promise.resolve().then(()=>Mt).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t)),Ae="@devtable/settings-form",ze="6.46.0",De="Apache-2.0",je={access:"public",registry:"https://registry.npmjs.org/"},Ie=["dist"],ke="./dist/settings-form.umd.js",qe="./dist/settings-form.es.js",Ne="./dist/index.d.ts",Le={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Me={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},$e={},Fe={"@types/crypto-js":"v4.1.1","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2","rollup-plugin-visualizer":"5.6.0",typescript:"^4.6.3"},Be={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5",ahooks:"^3.3.11",axios:"^0.27.2","crypto-js":"^4.1.1",lodash:"^4.17.21",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-hook-form":"^7.31.2","tabler-icons-react":"^1.48.0"},Mt=Object.freeze(Object.defineProperty({__proto__:null,name:Ae,version:ze,license:De,publishConfig:je,files:Ie,main:ke,module:qe,types:Ne,exports:Le,scripts:Me,dependencies:$e,devDependencies:Fe,peerDependencies:Be,default:{name:Ae,version:ze,license:De,publishConfig:je,files:Ie,main:ke,module:qe,types:Ne,exports:Le,scripts:Me,dependencies:$e,devDependencies:Fe,peerDependencies:Be}},Symbol.toStringTag,{value:"Module"}));R.APIKeyList=Nt,R.AccountList=jt,R.AddAPIKey=xe,R.AddAccount=Te,R.AddDataSource=Re,R.DataSourceList=xt,R.DeleteAPIKey=Oe,R.DeleteAccount=Ee,R.DeleteDataSource=Ce,R.Login=kt,R.getVersion=Lt,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
27
|
+
Check the top-level render call using <`+b+">.")}return d}}function Er(n,d){{if(!n._store||n._store.validated||n.key!=null)return;n._store.validated=!0;var b=yi(d);if(Tr[b])return;Tr[b]=!0;var E="";n&&n._owner&&n._owner!==vt.current&&(E=" It was passed a child from "+ce(n._owner.type)+"."),Ae(n),$('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,E),Ae(null)}}function Or(n,d){{if(typeof n!="object")return;if(gt(n))for(var b=0;b<n.length;b++){var E=n[b];yt(E)&&Er(E,d)}else if(yt(n))n._store&&(n._store.validated=!0);else if(n){var U=H(n);if(typeof U=="function"&&U!==n.entries)for(var K=U.call(n),L;!(L=K.next()).done;)yt(L.value)&&Er(L.value,d)}}}function bi(n){{var d=n.type;if(d==null||typeof d=="string")return;var b;if(typeof d=="function")b=d.propTypes;else if(typeof d=="object"&&(d.$$typeof===p||d.$$typeof===v))b=d.propTypes;else return;if(b){var E=ce(d);oi(b,n.props,"prop",E,n)}else if(d.PropTypes!==void 0&&!mt){mt=!0;var U=ce(d);$("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",U||"Unknown")}typeof d.getDefaultProps=="function"&&!d.getDefaultProps.isReactClassApproved&&$("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function wi(n){{for(var d=Object.keys(n.props),b=0;b<d.length;b++){var E=d[b];if(E!=="children"&&E!=="key"){Ae(n),$("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",E),Ae(null);break}}n.ref!==null&&(Ae(n),$("Invalid attribute `ref` supplied to `React.Fragment`."),Ae(null))}}function Pr(n,d,b,E,U,K){{var L=F(n);if(!L){var z="";(n===void 0||typeof n=="object"&&n!==null&&Object.keys(n).length===0)&&(z+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var le=mi(U);le?z+=le:z+=Sr();var ne;n===null?ne="null":gt(n)?ne="array":n!==void 0&&n.$$typeof===t?(ne="<"+(ce(n.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):ne=typeof n,$("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ne,z)}var oe=vi(n,d,b,U,K);if(oe==null)return oe;if(L){var he=d.children;if(he!==void 0)if(E)if(gt(he)){for(var Me=0;Me<he.length;Me++)Or(he[Me],n);Object.freeze&&Object.freeze(he)}else $("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Or(he,n)}return n===i?wi(oe):bi(oe),oe}}function Si(n,d,b){return Pr(n,d,b,!0)}function Ti(n,d,b){return Pr(n,d,b,!1)}var Ei=Ti,Oi=Si;qe.Fragment=i,qe.jsx=Ei,qe.jsxs=Oi}()),qe}(function(e){process.env.NODE_ENV==="production"?e.exports=qr():e.exports=kr()})(We);const we=We.exports.Fragment,a=We.exports.jsx,D=We.exports.jsxs;function $r({submit:e,styles:t=Ce,type:r}){const{control:i,setValue:s,handleSubmit:o}=Y.useForm({defaultValues:{type:r,key:"",config:{host:"",port:5432,username:"",password:"",database:""}}});return O.useEffect(()=>{s("type",r)},[s,r]),a(f.Box,{mx:"auto",children:D("form",{onSubmit:o(e),children:[a(Y.Controller,{name:"key",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...c})}),a(f.Divider,{label:"Connection Info",labelPosition:"center"}),D(f.Group,{grow:!0,children:[a(Y.Controller,{name:"config.host",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Host",sx:{flexGrow:1},...c})}),a(Y.Controller,{name:"config.port",control:i,render:({field:c})=>a(f.NumberInput,{mb:t.spacing,size:t.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...c})})]}),a(Y.Controller,{name:"config.username",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...c})}),a(Y.Controller,{name:"config.password",control:i,render:({field:c})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...c})}),a(Y.Controller,{name:"config.database",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Database",...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Lr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function St(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function Tt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?St(Object(r),!0).forEach(function(i){Lr(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):St(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Nr(e,t){if(e==null)return{};var r={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(t.indexOf(s)>=0)&&(r[s]=e[s]);return r}function Fr(e,t){if(e==null)return{};var r=Nr(e,t),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(t.indexOf(i)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,i)||(r[i]=e[i]))}return r}function Ur(e,t){return Br(e)||Wr(e,t)||Yr(e,t)||Vr()}function Br(e){if(Array.isArray(e))return e}function Wr(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var r=[],i=!0,s=!1,o=void 0;try{for(var c=e[Symbol.iterator](),u;!(i=(u=c.next()).done)&&(r.push(u.value),!(t&&r.length===t));i=!0);}catch(p){s=!0,o=p}finally{try{!i&&c.return!=null&&c.return()}finally{if(s)throw o}}return r}}function Yr(e,t){if(!!e){if(typeof e=="string")return Et(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Et(e,t)}}function Et(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function Vr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
28
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Gr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ot(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function Pt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ot(Object(r),!0).forEach(function(i){Gr(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ot(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Kr(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(i){return t.reduceRight(function(s,o){return o(s)},i)}}function ke(e){return function t(){for(var r=this,i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];return s.length>=e.length?e.apply(this,s):function(){for(var c=arguments.length,u=new Array(c),p=0;p<c;p++)u[p]=arguments[p];return t.apply(r,[].concat(s,u))}}}function Ye(e){return{}.toString.call(e).includes("Object")}function Jr(e){return!Object.keys(e).length}function $e(e){return typeof e=="function"}function Xr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Qr(e,t){return Ye(t)||Ee("changeType"),Object.keys(t).some(function(r){return!Xr(e,r)})&&Ee("changeField"),t}function Zr(e){$e(e)||Ee("selectorType")}function Hr(e){$e(e)||Ye(e)||Ee("handlerType"),Ye(e)&&Object.values(e).some(function(t){return!$e(t)})&&Ee("handlersType")}function en(e){e||Ee("initialIsRequired"),Ye(e)||Ee("initialType"),Jr(e)&&Ee("initialContent")}function tn(e,t){throw new Error(e[t]||e.default)}var rn={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ee=ke(tn)(rn),Ve={changes:Qr,selector:Zr,handler:Hr,initial:en};function nn(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ve.initial(e),Ve.handler(t);var r={current:e},i=ke(sn)(r,t),s=ke(an)(r),o=ke(Ve.changes)(e),c=ke(on)(r);function u(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(w){return w};return Ve.selector(m),m(r.current)}function p(m){Kr(i,s,o,c)(m)}return[u,p]}function on(e,t){return $e(t)?t(e.current):t}function an(e,t){return e.current=Pt(Pt({},e.current),t),t}function sn(e,t,r){return $e(t)?t(e.current):Object.keys(r).forEach(function(i){var s;return(s=t[i])===null||s===void 0?void 0:s.call(t,e.current[i])}),r}var cn={create:nn},un={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs"}};function ln(e){return function t(){for(var r=this,i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];return s.length>=e.length?e.apply(this,s):function(){for(var c=arguments.length,u=new Array(c),p=0;p<c;p++)u[p]=arguments[p];return t.apply(r,[].concat(s,u))}}}function dn(e){return{}.toString.call(e).includes("Object")}function fn(e){return e||xt("configIsRequired"),dn(e)||xt("configType"),e.urls?(pn(),{paths:{vs:e.urls.monacoBase}}):e}function pn(){console.warn(Rt.deprecation)}function gn(e,t){throw new Error(e[t]||e.default)}var Rt={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
29
|
+
You are using deprecated way of configuration.
|
|
30
|
+
|
|
31
|
+
Instead of using
|
|
32
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
33
|
+
use
|
|
34
|
+
monaco.config({ paths: { vs: '...' } })
|
|
35
|
+
|
|
36
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
37
|
+
`},xt=ln(gn)(Rt),hn={config:fn},vn=function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return function(s){return r.reduceRight(function(o,c){return c(o)},s)}};function _t(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],_t(e[r],t[r]))}),Tt(Tt({},e),t)}var mn={type:"cancelation",msg:"operation is manually canceled"};function et(e){var t=!1,r=new Promise(function(i,s){e.then(function(o){return t?s(mn):i(o)}),e.catch(s)});return r.cancel=function(){return t=!0},r}var yn=cn.create({config:un,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ct=Ur(yn,2),Le=Ct[0],Ge=Ct[1];function bn(e){var t=hn.config(e),r=t.monaco,i=Fr(t,["monaco"]);Ge(function(s){return{config:_t(s.config,i),monaco:r}})}function wn(){var e=Le(function(t){var r=t.monaco,i=t.isInitialized,s=t.resolve;return{monaco:r,isInitialized:i,resolve:s}});if(!e.isInitialized){if(Ge({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),et(tt);if(window.monaco&&window.monaco.editor)return jt(window.monaco),e.resolve(window.monaco),et(tt);vn(Sn,En)(On)}return et(tt)}function Sn(e){return document.body.appendChild(e)}function Tn(e){var t=document.createElement("script");return e&&(t.src=e),t}function En(e){var t=Le(function(i){var s=i.config,o=i.reject;return{config:s,reject:o}}),r=Tn("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function On(){var e=Le(function(r){var i=r.config,s=r.resolve,o=r.reject;return{config:i,resolve:s,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){jt(r),e.resolve(r)},function(r){e.reject(r)})}function jt(e){Le().monaco||Ge({monaco:e})}function Pn(){return Le(function(e){var t=e.monaco;return t})}var tt=new Promise(function(e,t){return Ge({resolve:e,reject:t})}),At={config:bn,init:wn,__getMonacoInstance:Pn},T={exports:{}},rt={exports:{}},B={};/** @license React v16.13.1
|
|
38
|
+
* react-is.production.min.js
|
|
39
|
+
*
|
|
40
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the MIT license found in the
|
|
43
|
+
* LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/var Mt;function Rn(){if(Mt)return B;Mt=1;var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,o=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,u=e?Symbol.for("react.context"):60110,p=e?Symbol.for("react.async_mode"):60111,m=e?Symbol.for("react.concurrent_mode"):60111,w=e?Symbol.for("react.forward_ref"):60112,v=e?Symbol.for("react.suspense"):60113,y=e?Symbol.for("react.suspense_list"):60120,j=e?Symbol.for("react.memo"):60115,V=e?Symbol.for("react.lazy"):60116,k=e?Symbol.for("react.block"):60121,H=e?Symbol.for("react.fundamental"):60117,Q=e?Symbol.for("react.responder"):60118,$=e?Symbol.for("react.scope"):60119;function Z(g){if(typeof g=="object"&&g!==null){var te=g.$$typeof;switch(te){case t:switch(g=g.type,g){case p:case m:case i:case o:case s:case v:return g;default:switch(g=g&&g.$$typeof,g){case u:case w:case V:case j:case c:return g;default:return te}}case r:return te}}}function G(g){return Z(g)===m}return B.AsyncMode=p,B.ConcurrentMode=m,B.ContextConsumer=u,B.ContextProvider=c,B.Element=t,B.ForwardRef=w,B.Fragment=i,B.Lazy=V,B.Memo=j,B.Portal=r,B.Profiler=o,B.StrictMode=s,B.Suspense=v,B.isAsyncMode=function(g){return G(g)||Z(g)===p},B.isConcurrentMode=G,B.isContextConsumer=function(g){return Z(g)===u},B.isContextProvider=function(g){return Z(g)===c},B.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===t},B.isForwardRef=function(g){return Z(g)===w},B.isFragment=function(g){return Z(g)===i},B.isLazy=function(g){return Z(g)===V},B.isMemo=function(g){return Z(g)===j},B.isPortal=function(g){return Z(g)===r},B.isProfiler=function(g){return Z(g)===o},B.isStrictMode=function(g){return Z(g)===s},B.isSuspense=function(g){return Z(g)===v},B.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===i||g===m||g===o||g===s||g===v||g===y||typeof g=="object"&&g!==null&&(g.$$typeof===V||g.$$typeof===j||g.$$typeof===c||g.$$typeof===u||g.$$typeof===w||g.$$typeof===H||g.$$typeof===Q||g.$$typeof===$||g.$$typeof===k)},B.typeOf=Z,B}var W={};/** @license React v16.13.1
|
|
45
|
+
* react-is.development.js
|
|
46
|
+
*
|
|
47
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the MIT license found in the
|
|
50
|
+
* LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/var It;function xn(){return It||(It=1,process.env.NODE_ENV!=="production"&&function(){var e=typeof Symbol=="function"&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,o=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,u=e?Symbol.for("react.context"):60110,p=e?Symbol.for("react.async_mode"):60111,m=e?Symbol.for("react.concurrent_mode"):60111,w=e?Symbol.for("react.forward_ref"):60112,v=e?Symbol.for("react.suspense"):60113,y=e?Symbol.for("react.suspense_list"):60120,j=e?Symbol.for("react.memo"):60115,V=e?Symbol.for("react.lazy"):60116,k=e?Symbol.for("react.block"):60121,H=e?Symbol.for("react.fundamental"):60117,Q=e?Symbol.for("react.responder"):60118,$=e?Symbol.for("react.scope"):60119;function Z(S){return typeof S=="string"||typeof S=="function"||S===i||S===m||S===o||S===s||S===v||S===y||typeof S=="object"&&S!==null&&(S.$$typeof===V||S.$$typeof===j||S.$$typeof===c||S.$$typeof===u||S.$$typeof===w||S.$$typeof===H||S.$$typeof===Q||S.$$typeof===$||S.$$typeof===k)}function G(S){if(typeof S=="object"&&S!==null){var ge=S.$$typeof;switch(ge){case t:var je=S.type;switch(je){case p:case m:case i:case o:case s:case v:return je;default:var xe=je&&je.$$typeof;switch(xe){case u:case w:case V:case j:case c:return xe;default:return ge}}case r:return ge}}}var g=p,te=m,ie=u,ye=c,re=t,F=w,pe=i,me=V,ce=j,q=r,X=o,se=s,fe=v,be=!1;function Pe(S){return be||(be=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),l(S)||G(S)===p}function l(S){return G(S)===m}function h(S){return G(S)===u}function P(S){return G(S)===c}function R(S){return typeof S=="object"&&S!==null&&S.$$typeof===t}function x(S){return G(S)===w}function A(S){return G(S)===i}function _(S){return G(S)===V}function C(S){return G(S)===j}function M(S){return G(S)===r}function N(S){return G(S)===o}function I(S){return G(S)===s}function ue(S){return G(S)===v}W.AsyncMode=g,W.ConcurrentMode=te,W.ContextConsumer=ie,W.ContextProvider=ye,W.Element=re,W.ForwardRef=F,W.Fragment=pe,W.Lazy=me,W.Memo=ce,W.Portal=q,W.Profiler=X,W.StrictMode=se,W.Suspense=fe,W.isAsyncMode=Pe,W.isConcurrentMode=l,W.isContextConsumer=h,W.isContextProvider=P,W.isElement=R,W.isForwardRef=x,W.isFragment=A,W.isLazy=_,W.isMemo=C,W.isPortal=M,W.isProfiler=N,W.isStrictMode=I,W.isSuspense=ue,W.isValidElementType=Z,W.typeOf=G}()),W}var Dt;function zt(){return Dt||(Dt=1,function(e){process.env.NODE_ENV==="production"?e.exports=Rn():e.exports=xn()}(rt)),rt.exports}/*
|
|
52
|
+
object-assign
|
|
53
|
+
(c) Sindre Sorhus
|
|
54
|
+
@license MIT
|
|
55
|
+
*/var nt,qt;function _n(){if(qt)return nt;qt=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function i(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function s(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var c={},u=0;u<10;u++)c["_"+String.fromCharCode(u)]=u;var p=Object.getOwnPropertyNames(c).map(function(w){return c[w]});if(p.join("")!=="0123456789")return!1;var m={};return"abcdefghijklmnopqrst".split("").forEach(function(w){m[w]=w}),Object.keys(Object.assign({},m)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return nt=s()?Object.assign:function(o,c){for(var u,p=i(o),m,w=1;w<arguments.length;w++){u=Object(arguments[w]);for(var v in u)t.call(u,v)&&(p[v]=u[v]);if(e){m=e(u);for(var y=0;y<m.length;y++)r.call(u,m[y])&&(p[m[y]]=u[m[y]])}}return p},nt}var it,kt;function ot(){if(kt)return it;kt=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return it=e,it}var at,$t;function Lt(){return $t||($t=1,at=Function.call.bind(Object.prototype.hasOwnProperty)),at}var st,Nt;function Cn(){if(Nt)return st;Nt=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=ot(),r={},i=Lt();e=function(o){var c="Warning: "+o;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(o,c,u,p,m){if(process.env.NODE_ENV!=="production"){for(var w in o)if(i(o,w)){var v;try{if(typeof o[w]!="function"){var y=Error((p||"React class")+": "+u+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw y.name="Invariant Violation",y}v=o[w](c,w,p,u,null,t)}catch(V){v=V}if(v&&!(v instanceof Error)&&e((p||"React class")+": type specification of "+u+" `"+w+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof v+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),v instanceof Error&&!(v.message in r)){r[v.message]=!0;var j=m?m():"";e("Failed "+u+" type: "+v.message+(j!=null?j:""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(r={})},st=s,st}var ct,Ft;function jn(){if(Ft)return ct;Ft=1;var e=zt(),t=_n(),r=ot(),i=Lt(),s=Cn(),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(u){var p="Warning: "+u;typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}});function c(){return null}return ct=function(u,p){var m=typeof Symbol=="function"&&Symbol.iterator,w="@@iterator";function v(l){var h=l&&(m&&l[m]||l[w]);if(typeof h=="function")return h}var y="<<anonymous>>",j={array:Q("array"),bigint:Q("bigint"),bool:Q("boolean"),func:Q("function"),number:Q("number"),object:Q("object"),string:Q("string"),symbol:Q("symbol"),any:$(),arrayOf:Z,element:G(),elementType:g(),instanceOf:te,node:F(),objectOf:ye,oneOf:ie,oneOfType:re,shape:me,exact:ce};function V(l,h){return l===h?l!==0||1/l===1/h:l!==l&&h!==h}function k(l,h){this.message=l,this.data=h&&typeof h=="object"?h:{},this.stack=""}k.prototype=Error.prototype;function H(l){if(process.env.NODE_ENV!=="production")var h={},P=0;function R(A,_,C,M,N,I,ue){if(M=M||y,I=I||C,ue!==r){if(p){var S=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw S.name="Invariant Violation",S}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ge=M+":"+C;!h[ge]&&P<3&&(o("You are manually calling a React.PropTypes validation function for the `"+I+"` prop on `"+M+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),h[ge]=!0,P++)}}return _[C]==null?A?_[C]===null?new k("The "+N+" `"+I+"` is marked as required "+("in `"+M+"`, but its value is `null`.")):new k("The "+N+" `"+I+"` is marked as required in "+("`"+M+"`, but its value is `undefined`.")):null:l(_,C,M,N,I)}var x=R.bind(null,!1);return x.isRequired=R.bind(null,!0),x}function Q(l){function h(P,R,x,A,_,C){var M=P[R],N=se(M);if(N!==l){var I=fe(M);return new k("Invalid "+A+" `"+_+"` of type "+("`"+I+"` supplied to `"+x+"`, expected ")+("`"+l+"`."),{expectedType:l})}return null}return H(h)}function $(){return H(c)}function Z(l){function h(P,R,x,A,_){if(typeof l!="function")return new k("Property `"+_+"` of component `"+x+"` has invalid PropType notation inside arrayOf.");var C=P[R];if(!Array.isArray(C)){var M=se(C);return new k("Invalid "+A+" `"+_+"` of type "+("`"+M+"` supplied to `"+x+"`, expected an array."))}for(var N=0;N<C.length;N++){var I=l(C,N,x,A,_+"["+N+"]",r);if(I instanceof Error)return I}return null}return H(h)}function G(){function l(h,P,R,x,A){var _=h[P];if(!u(_)){var C=se(_);return new k("Invalid "+x+" `"+A+"` of type "+("`"+C+"` supplied to `"+R+"`, expected a single ReactElement."))}return null}return H(l)}function g(){function l(h,P,R,x,A){var _=h[P];if(!e.isValidElementType(_)){var C=se(_);return new k("Invalid "+x+" `"+A+"` of type "+("`"+C+"` supplied to `"+R+"`, expected a single ReactElement type."))}return null}return H(l)}function te(l){function h(P,R,x,A,_){if(!(P[R]instanceof l)){var C=l.name||y,M=Pe(P[R]);return new k("Invalid "+A+" `"+_+"` of type "+("`"+M+"` supplied to `"+x+"`, expected ")+("instance of `"+C+"`."))}return null}return H(h)}function ie(l){if(!Array.isArray(l))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):o("Invalid argument supplied to oneOf, expected an array.")),c;function h(P,R,x,A,_){for(var C=P[R],M=0;M<l.length;M++)if(V(C,l[M]))return null;var N=JSON.stringify(l,function(ue,S){var ge=fe(S);return ge==="symbol"?String(S):S});return new k("Invalid "+A+" `"+_+"` of value `"+String(C)+"` "+("supplied to `"+x+"`, expected one of "+N+"."))}return H(h)}function ye(l){function h(P,R,x,A,_){if(typeof l!="function")return new k("Property `"+_+"` of component `"+x+"` has invalid PropType notation inside objectOf.");var C=P[R],M=se(C);if(M!=="object")return new k("Invalid "+A+" `"+_+"` of type "+("`"+M+"` supplied to `"+x+"`, expected an object."));for(var N in C)if(i(C,N)){var I=l(C,N,x,A,_+"."+N,r);if(I instanceof Error)return I}return null}return H(h)}function re(l){if(!Array.isArray(l))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var h=0;h<l.length;h++){var P=l[h];if(typeof P!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+be(P)+" at index "+h+"."),c}function R(x,A,_,C,M){for(var N=[],I=0;I<l.length;I++){var ue=l[I],S=ue(x,A,_,C,M,r);if(S==null)return null;S.data&&i(S.data,"expectedType")&&N.push(S.data.expectedType)}var ge=N.length>0?", expected one of type ["+N.join(", ")+"]":"";return new k("Invalid "+C+" `"+M+"` supplied to "+("`"+_+"`"+ge+"."))}return H(R)}function F(){function l(h,P,R,x,A){return q(h[P])?null:new k("Invalid "+x+" `"+A+"` supplied to "+("`"+R+"`, expected a ReactNode."))}return H(l)}function pe(l,h,P,R,x){return new k((l||"React class")+": "+h+" type `"+P+"."+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+x+"`.")}function me(l){function h(P,R,x,A,_){var C=P[R],M=se(C);if(M!=="object")return new k("Invalid "+A+" `"+_+"` of type `"+M+"` "+("supplied to `"+x+"`, expected `object`."));for(var N in l){var I=l[N];if(typeof I!="function")return pe(x,A,_,N,fe(I));var ue=I(C,N,x,A,_+"."+N,r);if(ue)return ue}return null}return H(h)}function ce(l){function h(P,R,x,A,_){var C=P[R],M=se(C);if(M!=="object")return new k("Invalid "+A+" `"+_+"` of type `"+M+"` "+("supplied to `"+x+"`, expected `object`."));var N=t({},P[R],l);for(var I in N){var ue=l[I];if(i(l,I)&&typeof ue!="function")return pe(x,A,_,I,fe(ue));if(!ue)return new k("Invalid "+A+" `"+_+"` key `"+I+"` supplied to `"+x+"`.\nBad object: "+JSON.stringify(P[R],null," ")+`
|
|
56
|
+
Valid keys: `+JSON.stringify(Object.keys(l),null," "));var S=ue(C,I,x,A,_+"."+I,r);if(S)return S}return null}return H(h)}function q(l){switch(typeof l){case"number":case"string":case"undefined":return!0;case"boolean":return!l;case"object":if(Array.isArray(l))return l.every(q);if(l===null||u(l))return!0;var h=v(l);if(h){var P=h.call(l),R;if(h!==l.entries){for(;!(R=P.next()).done;)if(!q(R.value))return!1}else for(;!(R=P.next()).done;){var x=R.value;if(x&&!q(x[1]))return!1}}else return!1;return!0;default:return!1}}function X(l,h){return l==="symbol"?!0:h?h["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&h instanceof Symbol:!1}function se(l){var h=typeof l;return Array.isArray(l)?"array":l instanceof RegExp?"object":X(h,l)?"symbol":h}function fe(l){if(typeof l>"u"||l===null)return""+l;var h=se(l);if(h==="object"){if(l instanceof Date)return"date";if(l instanceof RegExp)return"regexp"}return h}function be(l){var h=fe(l);switch(h){case"array":case"object":return"an "+h;case"boolean":case"date":case"regexp":return"a "+h;default:return h}}function Pe(l){return!l.constructor||!l.constructor.name?y:l.constructor.name}return j.checkPropTypes=s,j.resetWarningCache=s.resetWarningCache,j.PropTypes=j,j},ct}var ut,Ut;function An(){if(Ut)return ut;Ut=1;var e=ot();function t(){}function r(){}return r.resetWarningCache=t,ut=function(){function i(c,u,p,m,w,v){if(v!==e){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}i.isRequired=i;function s(){return i}var o={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:r,resetWarningCache:t};return o.PropTypes=o,o},ut}if(process.env.NODE_ENV!=="production"){var Mn=zt(),In=!0;T.exports=jn()(Mn.isElement,In)}else T.exports=An()();const Dn={display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"};function zn({content:e}){return a("div",{style:Dn,children:e})}const lt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}};function Bt({width:e,height:t,isEditorReady:r,loading:i,_ref:s,className:o,wrapperProps:c}){return D("section",{style:{...lt.wrapper,width:e,height:t},...c,children:[!r&&a(zn,{content:i}),a("div",{ref:s,style:{...lt.fullWidth,...!r&<.hide},className:o})]})}Bt.propTypes={width:T.exports.oneOfType([T.exports.number,T.exports.string]).isRequired,height:T.exports.oneOfType([T.exports.number,T.exports.string]).isRequired,loading:T.exports.oneOfType([T.exports.element,T.exports.string]).isRequired,isEditorReady:T.exports.bool.isRequired,className:T.exports.string,wrapperProps:T.exports.object};var Wt=O.memo(Bt);function Yt(e){O.useEffect(e,[])}function ve(e,t,r=!0){const i=O.useRef(!0);O.useEffect(i.current||!r?()=>{i.current=!1}:e,t)}function Ne(){}function Ke(e,t,r,i){return qn(e,i)||kn(e,t,r,i)}function qn(e,t){return e.editor.getModel(Vt(e,t))}function kn(e,t,r,i){return e.editor.createModel(t,r,i&&Vt(e,i))}function Vt(e,t){return e.Uri.parse(t)}function $n(e){return e===void 0}function Gt({original:e,modified:t,language:r,originalLanguage:i,modifiedLanguage:s,originalModelPath:o,modifiedModelPath:c,keepCurrentOriginalModel:u,keepCurrentModifiedModel:p,theme:m,loading:w,options:v,height:y,width:j,className:V,wrapperProps:k,beforeMount:H,onMount:Q}){const[$,Z]=O.useState(!1),[G,g]=O.useState(!0),te=O.useRef(null),ie=O.useRef(null),ye=O.useRef(null),re=O.useRef(Q),F=O.useRef(H);Yt(()=>{const q=At.init();return q.then(X=>(ie.current=X)&&g(!1)).catch(X=>(X==null?void 0:X.type)!=="cancelation"&&console.error("Monaco initialization: error:",X)),()=>te.current?ce():q.cancel()}),ve(()=>{const q=te.current.getModifiedEditor();q.getOption(ie.current.editor.EditorOption.readOnly)?q.setValue(t):t!==q.getValue()&&(q.executeEdits("",[{range:q.getModel().getFullModelRange(),text:t,forceMoveMarkers:!0}]),q.pushUndoStop())},[t],$),ve(()=>{te.current.getModel().original.setValue(e)},[e],$),ve(()=>{const{original:q,modified:X}=te.current.getModel();ie.current.editor.setModelLanguage(q,i||r),ie.current.editor.setModelLanguage(X,s||r)},[r,i,s],$),ve(()=>{ie.current.editor.setTheme(m)},[m],$),ve(()=>{te.current.updateOptions(v)},[v],$);const pe=O.useCallback(()=>{F.current(ie.current);const q=Ke(ie.current,e,i||r,o),X=Ke(ie.current,t,s||r,c);te.current.setModel({original:q,modified:X})},[r,t,s,e,i,o,c]),me=O.useCallback(()=>{te.current=ie.current.editor.createDiffEditor(ye.current,{automaticLayout:!0,...v}),pe(),ie.current.editor.setTheme(m),Z(!0)},[v,m,pe]);O.useEffect(()=>{$&&re.current(te.current,ie.current)},[$]),O.useEffect(()=>{!G&&!$&&me()},[G,$,me]);function ce(){const q=te.current.getModel();if(!u){var X;(X=q.original)===null||X===void 0||X.dispose()}if(!p){var se;(se=q.modified)===null||se===void 0||se.dispose()}te.current.dispose()}return a(Wt,{width:j,height:y,isEditorReady:$,loading:w,_ref:ye,className:V,wrapperProps:k})}Gt.propTypes={original:T.exports.string,modified:T.exports.string,language:T.exports.string,originalLanguage:T.exports.string,modifiedLanguage:T.exports.string,originalModelPath:T.exports.string,modifiedModelPath:T.exports.string,keepCurrentOriginalModel:T.exports.bool,keepCurrentModifiedModel:T.exports.bool,theme:T.exports.string,loading:T.exports.oneOfType([T.exports.element,T.exports.string]),options:T.exports.object,width:T.exports.oneOfType([T.exports.number,T.exports.string]),height:T.exports.oneOfType([T.exports.number,T.exports.string]),className:T.exports.string,wrapperProps:T.exports.object,beforeMount:T.exports.func,onMount:T.exports.func},Gt.defaultProps={theme:"light",loading:"Loading...",options:{},keepCurrentOriginalModel:!1,keepCurrentModifiedModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:Ne,onMount:Ne};function Ln(e){const t=O.useRef();return O.useEffect(()=>{t.current=e},[e]),t.current}const Je=new Map;function dt({defaultValue:e,defaultLanguage:t,defaultPath:r,value:i,language:s,path:o,theme:c,line:u,loading:p,options:m,overrideServices:w,saveViewState:v,keepCurrentModel:y,width:j,height:V,className:k,wrapperProps:H,beforeMount:Q,onMount:$,onChange:Z,onValidate:G}){const[g,te]=O.useState(!1),[ie,ye]=O.useState(!0),re=O.useRef(null),F=O.useRef(null),pe=O.useRef(null),me=O.useRef($),ce=O.useRef(Q),q=O.useRef(null),X=O.useRef(i),se=Ln(o),fe=O.useRef(!1);Yt(()=>{const l=At.init();return l.then(h=>(re.current=h)&&ye(!1)).catch(h=>(h==null?void 0:h.type)!=="cancelation"&&console.error("Monaco initialization: error:",h)),()=>F.current?Pe():l.cancel()}),ve(()=>{const l=Ke(re.current,e||i,t||s,o);l!==F.current.getModel()&&(v&&Je.set(se,F.current.saveViewState()),F.current.setModel(l),v&&F.current.restoreViewState(Je.get(o)))},[o],g),ve(()=>{F.current.updateOptions(m)},[m],g),ve(()=>{F.current.getOption(re.current.editor.EditorOption.readOnly)?F.current.setValue(i):i!==F.current.getValue()&&(F.current.executeEdits("",[{range:F.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),F.current.pushUndoStop())},[i],g),ve(()=>{re.current.editor.setModelLanguage(F.current.getModel(),s)},[s],g),ve(()=>{$n(u)||F.current.revealLine(u)},[u],g),ve(()=>{re.current.editor.setTheme(c)},[c],g);const be=O.useCallback(()=>{if(!fe.current){ce.current(re.current);const l=o||r,h=Ke(re.current,i||e,t||s,l);F.current=re.current.editor.create(pe.current,{model:h,automaticLayout:!0,...m},w),v&&F.current.restoreViewState(Je.get(l)),re.current.editor.setTheme(c),te(!0),fe.current=!0}},[e,t,r,i,s,o,m,w,v,c]);O.useEffect(()=>{g&&me.current(F.current,re.current)},[g]),O.useEffect(()=>{!ie&&!g&&be()},[ie,g,be]),X.current=i,O.useEffect(()=>{if(g&&Z){var l,h;(l=q.current)===null||l===void 0||l.dispose(),q.current=(h=F.current)===null||h===void 0?void 0:h.onDidChangeModelContent(P=>{Z(F.current.getValue(),P)})}},[g,Z]),O.useEffect(()=>{if(g){const l=re.current.editor.onDidChangeMarkers(h=>{var P;const R=(P=F.current.getModel())===null||P===void 0?void 0:P.uri;if(R&&h.find(A=>A.path===R.path)){const A=re.current.editor.getModelMarkers({resource:R});G==null||G(A)}});return()=>{l==null||l.dispose()}}},[g,G]);function Pe(){var l;if((l=q.current)===null||l===void 0||l.dispose(),y)v&&Je.set(o,F.current.saveViewState());else{var h;(h=F.current.getModel())===null||h===void 0||h.dispose()}F.current.dispose()}return a(Wt,{width:j,height:V,isEditorReady:g,loading:p,_ref:pe,className:k,wrapperProps:H})}dt.propTypes={defaultValue:T.exports.string,defaultPath:T.exports.string,defaultLanguage:T.exports.string,value:T.exports.string,language:T.exports.string,path:T.exports.string,theme:T.exports.string,line:T.exports.number,loading:T.exports.oneOfType([T.exports.element,T.exports.string]),options:T.exports.object,overrideServices:T.exports.object,saveViewState:T.exports.bool,keepCurrentModel:T.exports.bool,width:T.exports.oneOfType([T.exports.number,T.exports.string]),height:T.exports.oneOfType([T.exports.number,T.exports.string]),className:T.exports.string,wrapperProps:T.exports.object,beforeMount:T.exports.func,onMount:T.exports.func,onChange:T.exports.func,onValidate:T.exports.func},dt.defaultProps={theme:"light",loading:"Loading...",options:{},overrideServices:{},saveViewState:!0,keepCurrentModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:Ne,onMount:Ne,onValidate:Ne};var Nn=O.memo(dt);const Fn=({value:e,onChange:t})=>{const r=i=>{!i||t(i)};return a(f.Box,{sx:{position:"relative"},children:a(Nn,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Kt=O.forwardRef(({value:e,onChange:t,label:r,modalTitle:i,defaultValue:s,styles:o},c)=>{const[u,{setTrue:p,setFalse:m}]=Re.useBoolean(),[w,v]=O.useState(e),y=()=>{m(),t(w)},j=()=>{m(),v(e)},V=()=>{v(s)};return O.useEffect(()=>{v(e)},[e]),D(we,{children:[a(f.Button,{variant:"filled",size:o.button.size,onClick:p,sx:{flexGrow:1},children:r}),a(f.Modal,{size:800,title:i,opened:u,onClose:m,closeOnClickOutside:!1,withCloseButton:!1,children:u&&D(f.Stack,{children:[a(Fn,{value:w,onChange:v}),D(f.Group,{position:"apart",children:[a(f.Button,{onClick:V,color:"red",leftIcon:a(Te.Recycle,{size:20}),children:"Rest"}),D(f.Group,{position:"right",children:[a(f.Button,{onClick:j,variant:"subtle",children:"Cancel"}),a(f.Button,{onClick:y,children:"OK"})]})]})]})})]})}),Xe={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
|
|
57
|
+
`),post:["function post_process(res, utils) {"," // your code goes here"," return data","}"].join(`
|
|
58
|
+
`)};function Un({submit:e,styles:t=Ce}){const{control:r,setValue:i,handleSubmit:s}=Y.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:Xe.pre,post:Xe.post}}}});return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(e),children:[a(Y.Controller,{name:"key",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...o})}),a(f.Divider,{label:"Connection Info",labelPosition:"center"}),a(Y.Controller,{name:"config.host",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Base URL",sx:{flexGrow:1},...o})}),D(f.Group,{grow:!0,children:[a(Y.Controller,{name:"config.processing.pre",control:r,render:({field:o})=>a(Kt,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:Xe.pre,...o,styles:t})}),a(Y.Controller,{name:"config.processing.post",control:r,render:({field:o})=>a(Kt,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:Xe.post,...o,styles:t})})]}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Bn({postSubmit:e,styles:t=Ce}){const[r,i]=O.useState("postgresql"),s=async({type:u,key:p,config:m})=>{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{console.log({type:u,key:p,config:m}),await de.datasource.create(u,p,m),ee.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),e()}catch(w){ee.updateNotification({id:"for-creating",title:"Failed",message:w.message,color:"red"})}},o=r==="postgresql"||r==="mysql",c=r==="http";return D(f.Box,{mx:"auto",children:[a(f.SegmentedControl,{fullWidth:!0,mb:t.spacing,size:t.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:r,onChange:u=>i(u)}),o&&a($r,{submit:s,styles:t,type:r}),c&&a(Un,{submit:s,styles:t})]})}function Jt({onSuccess:e,styles:t=Ce}){const[r,i]=_e.default.useState(!1),s=()=>i(!0),o=()=>i(!1),c=()=>{e(),o()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:r,onClose:()=>i(!1),title:"Add a data source",trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:a(Bn,{postSubmit:c,styles:t})}),a(f.Button,{size:t.button.size,onClick:s,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function ft(){return ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ft.apply(this,arguments)}function Wn(e,t){if(e==null)return{};var r,i,s=function(c,u){if(c==null)return{};var p,m,w={},v=Object.keys(c);for(m=0;m<v.length;m++)p=v[m],u.indexOf(p)>=0||(w[p]=c[p]);return w}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}var Yn=["size","color","stroke"];function Vn(e){var t=e.size,r=t===void 0?24:t,i=e.color,s=i===void 0?"currentColor":i,o=e.stroke,c=o===void 0?2:o,u=Wn(e,Yn);return De.createElement("svg",ft({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-lock",width:r,height:r,viewBox:"0 0 24 24",strokeWidth:c,stroke:s,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},u),De.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),De.createElement("rect",{x:5,y:11,width:14,height:10,rx:2}),De.createElement("circle",{cx:12,cy:16,r:1}),De.createElement("path",{d:"M8 11v-4a4 4 0 0 1 8 0v4"}))}function Xt({id:e,name:t,isProtected:r,onSuccess:i,styles:s=Ce}){const o=Ie.useModals(),c=async()=>{!e||(ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await de.datasource.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${t}] is deleted`,color:"green"}),i())},u=()=>o.openConfirmModal({title:"Delete this data source?",children:a(f.Text,{size:s.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:c}),p=f.useMantineTheme();return r?a(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:a("span",{children:a(Vn,{size:16,color:p.colors.gray[7]})})}):a(f.Button,{size:s.button.size,color:"red",onClick:u,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function Gn({styles:e=Ce,config:t}){Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:o}=await de.datasource.list();return o},{refreshDeps:[]});return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Jt,{onSuccess:s})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Type"}),a("th",{children:"Name"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(({id:o,key:c,type:u,is_preset:p})=>D("tr",{children:[a("td",{width:200,children:u}),a("td",{children:c}),a("td",{width:200,children:a(f.Group,{position:"left",children:a(Xt,{isProtected:p,id:o,name:c,onSuccess:s})})})]},c))})]})]})]})}const Kn=O.forwardRef(({label:e,value:t,description:r,...i},s)=>D(f.Stack,{spacing:2,ref:s,...i,children:[a(f.Text,{size:"sm",children:e}),a(f.Text,{size:"xs",color:"dimmed",className:"role-description",children:r})]})),pt=O.forwardRef(({styles:e,value:t,onChange:r},i)=>{const{data:s=[],loading:o}=Re.useRequest(async()=>(await de.role.list()).map(u=>({label:u.name,value:u.id,description:u.description,disabled:u.id===50})),{refreshDeps:[]});return a(f.Select,{ref:i,mb:e.spacing,size:e.size,required:!0,label:"Role",itemComponent:Kn,data:s,disabled:o,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:t,onChange:r})}),Oe={size:"sm",spacing:"md",button:{size:"xs"}};function Jn({postSubmit:e,styles:t=Oe,initialRoleID:r}){const{control:i,handleSubmit:s}=Y.useForm({defaultValues:{name:"",email:"",role_id:r,password:""}}),o=async({name:c,email:u,password:p,role_id:m})=>{try{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await de.account.create(c,u,p,m),ee.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),e()}catch(w){ee.updateNotification({id:"for-creating",title:"Failed",message:w.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(o),children:[a(Y.Controller,{name:"name",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...c})}),a(Y.Controller,{name:"email",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Email",...c})}),a(Y.Controller,{name:"password",control:i,render:({field:c})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),a(Y.Controller,{name:"role_id",control:i,render:({field:c})=>a(pt,{styles:t,...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Qt({onSuccess:e,styles:t=Oe,initialRoleID:r}){const[i,s]=_e.default.useState(!1),o=()=>s(!0),c=()=>s(!1),u=()=>{e(),c()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:i,onClose:()=>s(!1),title:"Add an Account",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a(Jn,{postSubmit:u,styles:t,initialRoleID:r})}),a(f.Button,{size:t.button.size,onClick:o,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Zt({id:e,name:t,onSuccess:r,styles:i=Oe}){const s=Ie.useModals(),o=async()=>{if(!!e){ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await de.account.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${t}] is deleted`,color:"green"}),r()}catch(u){ee.updateNotification({id:"for-deleting",title:"Failed",message:u.message,color:"red"})}}},c=()=>s.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:o});return a(f.Button,{size:i.button.size,color:"red",onClick:c,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function Xn({id:e,name:t,email:r,role_id:i,postSubmit:s,styles:o=Oe}){const{control:c,handleSubmit:u,watch:p}=Y.useForm({defaultValues:{name:t,email:r,role_id:i,reset_password:!1,new_password:""}}),m=async({name:y,email:j,role_id:V,reset_password:k,new_password:H})=>{try{ee.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await de.account.edit({id:e,name:y,email:j,role_id:V,reset_password:k,new_password:H}),ee.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),s()}catch(Q){ee.updateNotification({id:"for-updating",title:"Failed",message:Q.message,color:"red"})}},[w,v]=p(["reset_password","new_password"]);return a(f.Box,{mx:"auto",children:D("form",{onSubmit:u(m),children:[a(Y.Controller,{name:"name",control:c,render:({field:y})=>a(f.TextInput,{mb:o.spacing,size:o.size,required:!0,label:"Username",...y})}),a(Y.Controller,{name:"email",control:c,render:({field:y})=>a(f.TextInput,{mb:o.spacing,size:o.size,required:!0,label:"Email",...y})}),a(Y.Controller,{name:"role_id",control:c,render:({field:y})=>a(pt,{styles:o,...y})}),a(f.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),a(Y.Controller,{name:"reset_password",control:c,render:({field:y})=>a(f.Switch,{mb:o.spacing,size:o.size,label:"Reset password",checked:y.value,onChange:j=>y.onChange(j.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),w&&a(Y.Controller,{name:"new_password",control:c,render:({field:y})=>a(f.PasswordInput,{autoComplete:"off",mb:o.spacing,size:o.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...y})}),a(f.Group,{position:"right",mt:o.spacing,children:a(f.Button,{type:"submit",size:o.button.size,children:"Submit"})})]})})}function Qn({account:e,onSuccess:t,styles:r=Oe}){const[i,s]=_e.default.useState(!1),o=()=>s(!0),c=()=>s(!1),u=()=>{t(),c()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:i,onClose:()=>s(!1),title:`Editing ${e.name}`,trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a(Xn,{...e,postSubmit:u,styles:r})}),a(f.Button,{size:r.button.size,onClick:o,leftIcon:a(Te.Edit,{size:20}),children:"Edit"})]})}function Zn({styles:e=Oe,config:t}){var m,w;Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:v}=await de.account.list();return v},{refreshDeps:[]}),{data:o=[],loading:c}=Re.useRequest(async()=>(await de.role.list()).map(y=>({label:y.name,value:y.id,description:y.description,disabled:y.id===50})),{refreshDeps:[]}),u=O.useMemo(()=>o.reduce((v,y)=>(v.set(y.value,y.label),v),new Map),[o]),p=v=>{var y;return(y=u.get(v))!=null?y:v};return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Qt,{onSuccess:s,initialRoleID:(w=(m=o==null?void 0:o[0])==null?void 0:m.value)!=null?w:0})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i||c}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Username"}),a("th",{children:"Email"}),a("th",{children:"Role"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(v=>{const{id:y,name:j,email:V,role_id:k}=v;return D("tr",{children:[a("td",{width:200,children:j}),a("td",{width:200,children:V}),a("td",{width:200,children:p(k)}),a("td",{width:200,children:D(f.Group,{position:"left",children:[a(Qn,{account:v,onSuccess:s}),a(Zt,{id:y,name:j,onSuccess:s})]})})]},y)})})]})]})]})}function Hn({postSubmit:e,styles:t=Oe}){const{control:r,handleSubmit:i}=Y.useForm({defaultValues:{name:"",password:""}}),s=async({name:o,password:c})=>{try{ee.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const u=await de.account.login(o,c);window.localStorage.setItem("token",u.token),ee.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),e(u)}catch(u){ee.updateNotification({id:"for-login",title:"Login Failed",message:u.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:i(s),children:[a(Y.Controller,{name:"name",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...o})}),a(Y.Controller,{name:"password",control:r,render:({field:o})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...o})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Submit"})})]})})}function ei({styles:e=Oe,config:t,onSuccess:r}){return Be(t),a(we,{children:a(f.Box,{mt:e.spacing,sx:{position:"relative"},children:a(Hn,{styles:e,postSubmit:r})})})}const Qe={size:"sm",spacing:"md",button:{size:"xs"}};function ti({postSubmit:e,styles:t=Qe,initialRoleID:r}){const{control:i,handleSubmit:s}=Y.useForm({defaultValues:{name:"",role_id:r}}),o=async({name:c,role_id:u})=>{try{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:p,app_secret:m}=await de.api_key.create(c,u);ee.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),e(p,m)}catch(p){ee.updateNotification({id:"for-creating",title:"Failed",message:p.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(o),children:[a(Y.Controller,{name:"name",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...c})}),a(Y.Controller,{name:"role_id",control:i,render:({field:c})=>a(pt,{styles:t,...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Ht({onSuccess:e,styles:t=Qe,initialRoleID:r}){const i=Ie.useModals(),[s,o]=_e.default.useState(!1),c=()=>o(!0),u=()=>o(!1),p=(m,w)=>{u(),i.openModal({title:"API Key is generated",children:D(f.Stack,{children:[a(f.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),a(f.TextInput,{defaultValue:m,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),a(f.TextInput,{defaultValue:w,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),a(f.Button,{size:"sm",onClick:()=>{Ie.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{e()}})};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:s,onClose:()=>o(!1),title:"Add an API Key",trapFocus:!0,onDragStart:m=>{m.stopPropagation()},children:a(ti,{postSubmit:p,styles:t,initialRoleID:r})}),a(f.Button,{size:t.button.size,onClick:c,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function er({id:e,name:t,onSuccess:r,styles:i=Qe}){const s=Ie.useModals(),o=async()=>{if(!!e){ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await de.api_key.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${t}] is deleted`,color:"green"}),r()}catch(u){ee.updateNotification({id:"for-deleting",title:"Failed",message:u.message,color:"red"})}}},c=()=>s.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:o});return a(f.Button,{size:i.button.size,color:"red",onClick:c,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function ri({styles:e=Qe,config:t}){var m,w;Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:v}=await de.api_key.list();return v},{refreshDeps:[]}),{data:o=[],loading:c}=Re.useRequest(async()=>(await de.role.list()).map(y=>({label:y.name,value:y.id,description:y.description,disabled:y.id===50})),{refreshDeps:[]}),u=O.useMemo(()=>o.reduce((v,y)=>(v.set(y.value,y.label),v),new Map),[o]),p=v=>{var y;return(y=u.get(v))!=null?y:v};return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Ht,{onSuccess:s,initialRoleID:(w=(m=o==null?void 0:o[0])==null?void 0:m.value)!=null?w:0})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i||c}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Name"}),a("th",{children:"APP ID"}),a("th",{children:"Role"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(v=>{const{id:y,name:j,app_id:V,role_id:k}=v;return D("tr",{children:[a("td",{width:200,children:j}),a("td",{width:200,children:V}),a("td",{width:200,children:p(k)}),a("td",{width:200,children:a(f.Group,{position:"left",children:a(er,{id:y,name:j,onSuccess:s})})})]},y)})})]})]})]})}const ni=()=>Promise.resolve().then(()=>ii).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e)),tr="@devtable/settings-form",rr="7.1.0",nr="Apache-2.0",ir={access:"public",registry:"https://registry.npmjs.org/"},or=["dist"],ar="./dist/settings-form.umd.js",sr="./dist/settings-form.es.js",cr="./dist/index.d.ts",ur={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},lr={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},dr={},fr={"@types/crypto-js":"v4.1.1","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2","rollup-plugin-visualizer":"5.6.0",typescript:"^4.6.3"},pr={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5",ahooks:"^3.3.11",axios:"^0.27.2","crypto-js":"^4.1.1",lodash:"^4.17.21",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-hook-form":"^7.31.2","tabler-icons-react":"^1.48.0"},ii=Object.freeze(Object.defineProperty({__proto__:null,name:tr,version:rr,license:nr,publishConfig:ir,files:or,main:ar,module:sr,types:cr,exports:ur,scripts:lr,dependencies:dr,devDependencies:fr,peerDependencies:pr,default:{name:tr,version:rr,license:nr,publishConfig:ir,files:or,main:ar,module:sr,types:cr,exports:ur,scripts:lr,dependencies:dr,devDependencies:fr,peerDependencies:pr}},Symbol.toStringTag,{value:"Module"}));J.APIKeyList=ri,J.AccountList=Zn,J.AddAPIKey=Ht,J.AddAccount=Qt,J.AddDataSource=Jt,J.DataSourceList=Gn,J.DeleteAPIKey=er,J.DeleteAccount=Zt,J.DeleteDataSource=Xt,J.Login=ei,J.getVersion=ni,Object.defineProperties(J,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|