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