@devtable/settings-form 8.13.2 → 8.13.5
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(P,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("@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","@mantine/modals"],o):(P=typeof globalThis<"u"?globalThis:P||self,o(P["settings-form"]={},P["@mantine/core"],P["@mantine/notifications"],P.React,P["tabler-icons-react"],P.axios,P["crypto-js"],P._,P["react-hook-form"],P.ahooks,P["@monaco-editor/react"],P["@mantine/modals"]))})(this,function(P,o,T,I,B,mt,vt,bt,C,U,re,X){"use strict";const Q=t=>t&&typeof t=="object"&&"default"in t?t:{default:t};function wt(t){if(t&&t.__esModule)return t;const r=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(r,i,s.get?s:{enumerable:!0,get:()=>t[i]})}}return r.default=t,Object.freeze(r)}const G=Q(I),Z=wt(I),yt=Q(mt),_t=Q(vt),St=Q(bt),Ct=Q(re);function Pt(t){t=t||{};const r=Object.keys(t).sort(),i=[];for(let s=0;s<r.length;s++){const u=r[s];if(u!="authentication"&&t[u])i.push(r[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 Rt(t,r){let i=Pt(t);return i+="&key="+r,_t.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 r=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:r,sign:Rt({app_id:this.app_id,nonce_str:r,...t},this.app_secret)}},getRequest(t){return(r,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:r,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)),yt.default(c).then(f=>f.data).catch(f=>St.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,r,i)=>await O.getRequest("POST")("/datasource/create",{type:t,key:r,config:i}),delete:async t=>{await O.getRequest("POST")("/datasource/delete",{id:t})}},account:{login:async(t,r)=>{const i={name:t,password:r};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,r)=>{const i={name:t,email:r};return await O.getRequest("PUT")("/account/update",i)},changepassword:async(t,r)=>{const i={old_password:t,new_password:r};return await O.getRequest("POST")("/account/changepassword",i)},create:async(t,r,i,s)=>await O.getRequest("POST")("/account/create",{name:t,email:r,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,r)=>O.getRequest("POST")("/api/key/create",{name:t,role_id:r}),delete:async t=>{if(!!t)return O.getRequest("POST")("/api/key/delete",{id:t})}}},Y={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 Pe;function Tt(){if(Pe)return H;Pe=1;var t=G.default,r=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 _,m={},p=null,z=null;w!==void 0&&(p=""+w),g.key!==void 0&&(p=""+g.key),g.ref!==void 0&&(z=g.ref);for(_ in g)s.call(g,_)&&!l.hasOwnProperty(_)&&(m[_]=g[_]);if(f&&f.defaultProps)for(_ in g=f.defaultProps,g)m[_]===void 0&&(m[_]=g[_]);return{$$typeof:r,type:f,key:p,ref:z,props:m,_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 Re;function Et(){return Re||(Re=1,process.env.NODE_ENV!=="production"&&function(){var t=G.default,r=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"),_=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),z=Symbol.for("react.offscreen"),q=Symbol.iterator,V="@@iterator";function he(e){if(e===null||typeof e!="object")return null;var a=q&&e[q]||e[V];return typeof a=="function"?a:null}var $=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function A(e){{for(var a=arguments.length,d=new Array(a>1?a-1:0),h=1;h<a;h++)d[h-1]=arguments[h];Kt("error",e,d)}}function Kt(e,a,d){{var h=$.ReactDebugCurrentFrame,S=h.getStackAddendum();S!==""&&(a+="%s",d=d.concat([S]));var R=d.map(function(y){return String(y)});R.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,R)}}var Jt=!1,Xt=!1,Qt=!1,Zt=!1,Ht=!1,Ge;Ge=Symbol.for("react.module.reference");function en(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===l||Ht||e===u||e===w||e===_||Zt||e===z||Jt||Xt||Qt||typeof e=="object"&&e!==null&&(e.$$typeof===p||e.$$typeof===m||e.$$typeof===c||e.$$typeof===f||e.$$typeof===g||e.$$typeof===Ge||e.getModuleId!==void 0))}function tn(e,a,d){var h=e.displayName;if(h)return h;var S=a.displayName||a.name||"";return S!==""?d+"("+S+")":d}function Ye(e){return e.displayName||"Context"}function L(e){if(e==null)return null;if(typeof e.tag=="number"&&A("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 _:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var a=e;return Ye(a)+".Consumer";case c:var d=e;return Ye(d._context)+".Provider";case g:return tn(e,e.render,"ForwardRef");case m:var h=e.displayName||null;return h!==null?h:L(e.type)||"Memo";case p:{var S=e,R=S._payload,y=S._init;try{return L(y(R))}catch{return null}}}return null}var W=Object.assign,te=0,Ke,Je,Xe,Qe,Ze,He,et;function tt(){}tt.__reactDisabledLog=!0;function nn(){{if(te===0){Ke=console.log,Je=console.info,Xe=console.warn,Qe=console.error,Ze=console.group,He=console.groupCollapsed,et=console.groupEnd;var e={configurable:!0,enumerable:!0,value:tt,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}te++}}function rn(){{if(te--,te===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},e,{value:Ke}),info:W({},e,{value:Je}),warn:W({},e,{value:Xe}),error:W({},e,{value:Qe}),group:W({},e,{value:Ze}),groupCollapsed:W({},e,{value:He}),groupEnd:W({},e,{value:et})})}te<0&&A("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var me=$.ReactCurrentDispatcher,ve;function le(e,a,d){{if(ve===void 0)try{throw Error()}catch(S){var h=S.stack.trim().match(/\n( *(at )?)/);ve=h&&h[1]||""}return`
|
|
18
|
+
`+ve+e}}var be=!1,ce;{var an=typeof WeakMap=="function"?WeakMap:Map;ce=new an}function nt(e,a){if(!e||be)return"";{var d=ce.get(e);if(d!==void 0)return d}var h;be=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var R;R=me.current,me.current=null,nn();try{if(a){var y=function(){throw Error()};if(Object.defineProperty(y.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(y,[])}catch(M){h=M}Reflect.construct(e,[],y)}else{try{y.call()}catch(M){h=M}e.call(y.prototype)}}else{try{throw Error()}catch(M){h=M}e()}}catch(M){if(M&&h&&typeof M.stack=="string"){for(var v=M.stack.split(`
|
|
19
|
+
`),D=h.stack.split(`
|
|
20
|
+
`),E=v.length-1,x=D.length-1;E>=1&&x>=0&&v[E]!==D[x];)x--;for(;E>=1&&x>=0;E--,x--)if(v[E]!==D[x]){if(E!==1||x!==1)do if(E--,x--,x<0||v[E]!==D[x]){var k=`
|
|
21
|
+
`+v[E].replace(" at new "," at ");return e.displayName&&k.includes("<anonymous>")&&(k=k.replace("<anonymous>",e.displayName)),typeof e=="function"&&ce.set(e,k),k}while(E>=1&&x>=0);break}}}finally{be=!1,me.current=R,rn(),Error.prepareStackTrace=S}var J=e?e.displayName||e.name:"",ht=J?le(J):"";return typeof e=="function"&&ce.set(e,ht),ht}function on(e,a,d){return nt(e,!1)}function sn(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,sn(e));if(typeof e=="string")return le(e);switch(e){case w:return le("Suspense");case _:return le("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case g:return on(e.render);case m:return ue(e.type,a,d);case p:{var h=e,S=h._payload,R=h._init;try{return ue(R(S),a,d)}catch{}}}return""}var de=Object.prototype.hasOwnProperty,rt={},it=$.ReactDebugCurrentFrame;function fe(e){if(e){var a=e._owner,d=ue(e.type,e._source,a?a.type:null);it.setExtraStackFrame(d)}else it.setExtraStackFrame(null)}function ln(e,a,d,h,S){{var R=Function.call.bind(de);for(var y in e)if(R(e,y)){var v=void 0;try{if(typeof e[y]!="function"){var D=Error((h||"React class")+": "+d+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw D.name="Invariant Violation",D}v=e[y](a,y,h,d,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){v=E}v&&!(v instanceof Error)&&(fe(S),A("%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).",h||"React class",d,y,typeof v),fe(null)),v instanceof Error&&!(v.message in rt)&&(rt[v.message]=!0,fe(S),A("Failed %s type: %s",d,v.message),fe(null))}}}var cn=Array.isArray;function we(e){return cn(e)}function un(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,d=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return d}}function dn(e){try{return at(e),!1}catch{return!0}}function at(e){return""+e}function ot(e){if(dn(e))return A("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",un(e)),at(e)}var ne=$.ReactCurrentOwner,fn={key:!0,ref:!0,__self:!0,__source:!0},st,lt,ye;ye={};function pn(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 gn(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 hn(e,a){if(typeof e.ref=="string"&&ne.current&&a&&ne.current.stateNode!==a){var d=L(ne.current.type);ye[d]||(A('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',L(ne.current.type),e.ref),ye[d]=!0)}}function mn(e,a){{var d=function(){st||(st=!0,A("%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 vn(e,a){{var d=function(){lt||(lt=!0,A("%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 bn=function(e,a,d,h,S,R,y){var v={$$typeof:r,type:e,key:a,ref:d,props:y,_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:h}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function wn(e,a,d,h,S){{var R,y={},v=null,D=null;d!==void 0&&(ot(d),v=""+d),gn(a)&&(ot(a.key),v=""+a.key),pn(a)&&(D=a.ref,hn(a,S));for(R in a)de.call(a,R)&&!fn.hasOwnProperty(R)&&(y[R]=a[R]);if(e&&e.defaultProps){var E=e.defaultProps;for(R in E)y[R]===void 0&&(y[R]=E[R])}if(v||D){var x=typeof e=="function"?e.displayName||e.name||"Unknown":e;v&&mn(y,x),D&&vn(y,x)}return bn(e,v,D,S,h,ne.current,y)}}var _e=$.ReactCurrentOwner,ct=$.ReactDebugCurrentFrame;function K(e){if(e){var a=e._owner,d=ue(e.type,e._source,a?a.type:null);ct.setExtraStackFrame(d)}else ct.setExtraStackFrame(null)}var Se;Se=!1;function Ce(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function ut(){{if(_e.current){var e=L(_e.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function yn(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 dt={};function _n(e){{var a=ut();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 ft(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var d=_n(a);if(dt[d])return;dt[d]=!0;var h="";e&&e._owner&&e._owner!==_e.current&&(h=" It was passed a child from "+L(e._owner.type)+"."),K(e),A('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',d,h),K(null)}}function pt(e,a){{if(typeof e!="object")return;if(we(e))for(var d=0;d<e.length;d++){var h=e[d];Ce(h)&&ft(h,a)}else if(Ce(e))e._store&&(e._store.validated=!0);else if(e){var S=he(e);if(typeof S=="function"&&S!==e.entries)for(var R=S.call(e),y;!(y=R.next()).done;)Ce(y.value)&&ft(y.value,a)}}}function Sn(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===m))d=a.propTypes;else return;if(d){var h=L(a);ln(d,e.props,"prop",h,e)}else if(a.PropTypes!==void 0&&!Se){Se=!0;var S=L(a);A("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",S||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&A("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Cn(e){{for(var a=Object.keys(e.props),d=0;d<a.length;d++){var h=a[d];if(h!=="children"&&h!=="key"){K(e),A("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",h),K(null);break}}e.ref!==null&&(K(e),A("Invalid attribute `ref` supplied to `React.Fragment`."),K(null))}}function gt(e,a,d,h,S,R){{var y=en(e);if(!y){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 D=yn(S);D?v+=D:v+=ut();var E;e===null?E="null":we(e)?E="array":e!==void 0&&e.$$typeof===r?(E="<"+(L(e.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,A("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,v)}var x=wn(e,a,d,S,R);if(x==null)return x;if(y){var k=a.children;if(k!==void 0)if(h)if(we(k)){for(var J=0;J<k.length;J++)pt(k[J],e);Object.freeze&&Object.freeze(k)}else A("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else pt(k,e)}return e===s?Cn(x):Sn(x),x}}function Pn(e,a,d){return gt(e,a,d,!0)}function Rn(e,a,d){return gt(e,a,d,!1)}var Tn=Rn,En=Pn;ee.Fragment=s,ee.jsx=Tn,ee.jsxs=En}()),ee}(function(t){process.env.NODE_ENV==="production"?t.exports=Tt():t.exports=Et()})(ae);const N=ae.exports.Fragment,n=ae.exports.jsx,b=ae.exports.jsxs;function xt({submit:t,styles:r=Y,type:i}){const{control:s,setValue:u,handleSubmit:l}=C.useForm({defaultValues:{type:i,key:"",config:{host:"",port:5432,username:"",password:"",database:""}}});return I.useEffect(()=>{u("type",i)},[u,i]),n(o.Box,{mx:"auto",children:b("form",{onSubmit:l(t),children:[n(C.Controller,{name:"key",control:s,render:({field:c})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Name",placeholder:"A unique name",...c})}),n(o.Divider,{label:"Connection Info",labelPosition:"center"}),b(o.Group,{grow:!0,children:[n(C.Controller,{name:"config.host",control:s,render:({field:c})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Host",sx:{flexGrow:1},...c})}),n(C.Controller,{name:"config.port",control:s,render:({field:c})=>n(o.NumberInput,{mb:r.spacing,size:r.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...c})})]}),n(C.Controller,{name:"config.username",control:s,render:({field:c})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Username",...c})}),n(C.Controller,{name:"config.password",control:s,render:({field:c})=>n(o.PasswordInput,{mb:r.spacing,size:r.size,required:!0,label:"Password",...c})}),n(C.Controller,{name:"config.database",control:s,render:({field:c})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Database",...c})}),n(o.Group,{position:"right",mt:r.spacing,children:n(o.Button,{type:"submit",size:r.button.size,children:"Save"})})]})})}self.MonacoEnvironment={getWorker:function(t,r){const i=(s,u)=>new Worker(self.MonacoEnvironment.getWorker(s),{name:u,type:"module"});switch(r){case"typescript":case"javascript":return i("/monaco-editor/min/vs/language/typescript/ts.worker?worker",r);default:return i("/monaco-editor/min/vs/editor/editor.worker?worker",r)}}};function Ot(){re.loader.__getMonacoInstance()||(console.log("loading monaco"),re.loader.config({paths:{vs:"/assets/monaco-editor/min/vs"}}),re.loader.init().then(r=>console.log("here is the monaco instance:",r)))}Ot();const zt=({value:t,onChange:r})=>{const i=s=>{!s||r(s)};return n(o.Box,{sx:{position:"relative"},children:n(Ct.default,{height:"500px",defaultLanguage:"javascript",value:t,onChange:i,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Te=I.forwardRef(({value:t,onChange:r,label:i,modalTitle:s,defaultValue:u,styles:l},c)=>{const[f,{setTrue:g,setFalse:w}]=U.useBoolean(),[_,m]=I.useState(t),p=()=>{w(),r(_)},z=()=>{w(),m(t)},q=()=>{m(u)};return I.useEffect(()=>{m(t)},[t]),b(N,{children:[n(o.Button,{variant:"filled",size:l.button.size,onClick:g,sx:{flexGrow:1},children:i}),n(o.Modal,{size:800,title:s,opened:f,onClose:w,closeOnClickOutside:!1,withCloseButton:!1,children:f&&b(o.Stack,{children:[n(zt,{value:_,onChange:m}),b(o.Group,{position:"apart",children:[n(o.Button,{onClick:q,color:"red",leftIcon:n(B.Recycle,{size:20}),children:"Rest"}),b(o.Group,{position:"right",children:[n(o.Button,{onClick:z,variant:"subtle",children:"Cancel"}),n(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 At({submit:t,styles:r=Y}){const{control:i,setValue:s,handleSubmit:u}=C.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:oe.pre,post:oe.post}}}});return n(o.Box,{mx:"auto",children:b("form",{onSubmit:u(t),children:[n(C.Controller,{name:"key",control:i,render:({field:l})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Name",placeholder:"A unique name",...l})}),n(o.Divider,{label:"Connection Info",labelPosition:"center"}),n(C.Controller,{name:"config.host",control:i,render:({field:l})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Base URL",sx:{flexGrow:1},...l})}),b(o.Group,{grow:!0,children:[n(C.Controller,{name:"config.processing.pre",control:i,render:({field:l})=>n(Te,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:oe.pre,...l,styles:r})}),n(C.Controller,{name:"config.processing.post",control:i,render:({field:l})=>n(Te,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:oe.post,...l,styles:r})})]}),n(o.Group,{position:"right",mt:r.spacing,children:n(o.Button,{type:"submit",size:r.button.size,children:"Save"})})]})})}function Dt({postSubmit:t,styles:r=Y}){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(_){T.updateNotification({id:"for-creating",title:"Failed",message:_.message,color:"red"})}},l=i==="postgresql"||i==="mysql",c=i==="http";return b(o.Box,{mx:"auto",children:[n(o.SegmentedControl,{fullWidth:!0,mb:r.spacing,size:r.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:i,onChange:f=>s(f)}),l&&n(xt,{submit:u,styles:r,type:i}),c&&n(At,{submit:u,styles:r})]})}function Ee({onSuccess:t,styles:r=Y}){const[i,s]=G.default.useState(!1),u=()=>s(!0),l=()=>s(!1),c=()=>{t(),l()};return b(N,{children:[n(o.Modal,{overflow:"inside",opened:i,onClose:()=>s(!1),title:"Add a data source",trapFocus:!0,onDragStart:f=>{f.stopPropagation()},children:n(Dt,{postSubmit:c,styles:r})}),n(o.Button,{size:r.button.size,onClick:u,leftIcon:n(B.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function pe(){return pe=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var i=arguments[r];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},pe.apply(this,arguments)}function jt(t,r){if(t==null)return{};var i,s,u=function(c,f){if(c==null)return{};var g,w,_={},m=Object.keys(c);for(w=0;w<m.length;w++)g=m[w],f.indexOf(g)>=0||(_[g]=c[g]);return _}(t,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(s=0;s<l.length;s++)i=l[s],r.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(u[i]=t[i])}return u}var kt=["size","color","stroke"];function It(t){var r=t.size,i=r===void 0?24:r,s=t.color,u=s===void 0?"currentColor":s,l=t.stroke,c=l===void 0?2:l,f=jt(t,kt);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 xe({id:t,name:r,isProtected:i,onSuccess:s,styles:u=Y}){const l=X.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 [${r}] is deleted`,color:"green"}),s())},f=()=>l.openConfirmModal({title:"Delete this data source?",children:n(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?n(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:n("span",{children:n(It,{size:16,color:g.colors.gray[7]})})}):n(o.Button,{size:u.button.size,color:"red",onClick:f,leftIcon:n(B.Trash,{size:20}),children:"Delete"})}function qt({styles:t=Y,config:r}){ie(r);const{data:i=[],loading:s,refresh:u}=U.useRequest(async()=>{const{data:l}=await j.datasource.list();return l},{refreshDeps:[]});return b(N,{children:[n(o.Group,{pt:t.spacing,position:"right",children:n(Ee,{onSuccess:u})}),b(o.Box,{mt:t.spacing,sx:{position:"relative"},children:[n(o.LoadingOverlay,{visible:s}),b(o.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[n("thead",{children:b("tr",{children:[n("th",{children:"Type"}),n("th",{children:"Name"}),n("th",{children:"Action"})]})}),n("tbody",{children:i.map(({id:l,key:c,type:f,is_preset:g})=>b("tr",{children:[n("td",{width:200,children:f}),n("td",{children:c}),n("td",{width:200,children:n(o.Group,{position:"left",children:n(xe,{isProtected:g,id:l,name:c,onSuccess:u})})})]},c))})]})]})]})}const Nt=I.forwardRef(({label:t,value:r,description:i,...s},u)=>b(o.Stack,{spacing:2,ref:u,...s,children:[n(o.Text,{size:"sm",children:t}),n(o.Text,{size:"xs",color:"dimmed",className:"role-description",children:i})]})),ge=I.forwardRef(({styles:t,value:r,onChange:i},s)=>{const{data:u=[],loading:l}=U.useRequest(async()=>(await j.role.list()).map(f=>({label:f.name,value:f.id,description:f.description,disabled:f.id===50})),{refreshDeps:[]});return n(o.Select,{ref:s,mb:t.spacing,size:t.size,required:!0,label:"Role",itemComponent:Nt,data:u,disabled:l,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:r,onChange:i})}),F={size:"sm",spacing:"md",button:{size:"xs"}};function Lt({postSubmit:t,styles:r=F,initialRoleID:i}){const{control:s,handleSubmit:u}=C.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(_){T.updateNotification({id:"for-creating",title:"Failed",message:_.message,color:"red"})}};return n(o.Box,{mx:"auto",children:b("form",{onSubmit:u(l),children:[n(C.Controller,{name:"name",control:s,render:({field:c})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Username",...c})}),n(C.Controller,{name:"email",control:s,render:({field:c})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Email",...c})}),n(C.Controller,{name:"password",control:s,render:({field:c})=>n(o.PasswordInput,{mb:r.spacing,size:r.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),n(C.Controller,{name:"role_id",control:s,render:({field:c})=>n(ge,{styles:r,...c})}),n(o.Group,{position:"right",mt:r.spacing,children:n(o.Button,{type:"submit",size:r.button.size,children:"Save"})})]})})}function Oe({onSuccess:t,styles:r=F,initialRoleID:i}){const[s,u]=G.default.useState(!1),l=()=>u(!0),c=()=>u(!1),f=()=>{t(),c()};return b(N,{children:[n(o.Modal,{overflow:"inside",opened:s,onClose:()=>u(!1),title:"Add an Account",trapFocus:!0,onDragStart:g=>{g.stopPropagation()},children:n(Lt,{postSubmit:f,styles:r,initialRoleID:i})}),n(o.Button,{size:r.button.size,onClick:l,leftIcon:n(B.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function ze({id:t,name:r,onSuccess:i,styles:s=F}){const u=X.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 [${r}] 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 n(o.Button,{size:s.button.size,color:"red",onClick:c,leftIcon:n(B.Trash,{size:20}),children:"Delete"})}function Mt({id:t,name:r,email:i,role_id:s,postSubmit:u,styles:l=F}){const{control:c,handleSubmit:f,watch:g}=C.useForm({defaultValues:{name:r,email:i,role_id:s,reset_password:!1,new_password:""}}),w=async({name:p,email:z,role_id:q,reset_password:V,new_password:he})=>{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:q,reset_password:V,new_password:he}),T.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),u()}catch($){T.updateNotification({id:"for-updating",title:"Failed",message:$.message,color:"red"})}},[_,m]=g(["reset_password","new_password"]);return n(o.Box,{mx:"auto",children:b("form",{onSubmit:f(w),children:[n(C.Controller,{name:"name",control:c,render:({field:p})=>n(o.TextInput,{mb:l.spacing,size:l.size,required:!0,label:"Username",...p})}),n(C.Controller,{name:"email",control:c,render:({field:p})=>n(o.TextInput,{mb:l.spacing,size:l.size,required:!0,label:"Email",...p})}),n(C.Controller,{name:"role_id",control:c,render:({field:p})=>n(ge,{styles:l,...p})}),n(o.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),n(C.Controller,{name:"reset_password",control:c,render:({field:p})=>n(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"}}})}),_&&n(C.Controller,{name:"new_password",control:c,render:({field:p})=>n(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})}),n(o.Group,{position:"right",mt:l.spacing,children:n(o.Button,{type:"submit",size:l.button.size,children:"Submit"})})]})})}function Bt({account:t,onSuccess:r,styles:i=F}){const[s,u]=G.default.useState(!1),l=()=>u(!0),c=()=>u(!1),f=()=>{r(),c()};return b(N,{children:[n(o.Modal,{overflow:"inside",opened:s,onClose:()=>u(!1),title:`Editing ${t.name}`,trapFocus:!0,onDragStart:g=>{g.stopPropagation()},children:n(Mt,{...t,postSubmit:f,styles:i})}),n(o.Button,{size:i.button.size,onClick:l,leftIcon:n(B.Edit,{size:20}),children:"Edit"})]})}function Ft({styles:t=F,config:r}){var w,_;ie(r);const{data:i=[],loading:s,refresh:u}=U.useRequest(async()=>{const{data:m}=await j.account.list();return m},{refreshDeps:[]}),{data:l=[],loading:c}=U.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((m,p)=>(m.set(p.value,p.label),m),new Map),[l]),g=m=>{var p;return(p=f.get(m))!=null?p:m};return b(N,{children:[n(o.Group,{pt:t.spacing,position:"right",children:n(Oe,{onSuccess:u,initialRoleID:(_=(w=l==null?void 0:l[0])==null?void 0:w.value)!=null?_:0})}),b(o.Box,{mt:t.spacing,sx:{position:"relative"},children:[n(o.LoadingOverlay,{visible:s||c}),b(o.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[n("thead",{children:b("tr",{children:[n("th",{children:"Username"}),n("th",{children:"Email"}),n("th",{children:"Role"}),n("th",{children:"Action"})]})}),n("tbody",{children:i.map(m=>{const{id:p,name:z,email:q,role_id:V}=m;return b("tr",{children:[n("td",{width:200,children:z}),n("td",{width:200,children:q}),n("td",{width:200,children:g(V)}),n("td",{width:200,children:b(o.Group,{position:"left",children:[n(Bt,{account:m,onSuccess:u}),n(ze,{id:p,name:z,onSuccess:u})]})})]},p)})})]})]})]})}function $t({postSubmit:t,styles:r=F}){const{control:i,handleSubmit:s}=C.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 n(o.Box,{mx:"auto",children:b("form",{onSubmit:s(u),children:[n(C.Controller,{name:"name",control:i,render:({field:l})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Username",...l})}),n(C.Controller,{name:"password",control:i,render:({field:l})=>n(o.PasswordInput,{mb:r.spacing,size:r.size,required:!0,label:"Password",...l})}),n(o.Group,{position:"right",mt:r.spacing,children:n(o.Button,{type:"submit",size:r.button.size,children:"Submit"})})]})})}function Ut({styles:t=F,config:r,onSuccess:i}){return ie(r),n(N,{children:n(o.Box,{mt:t.spacing,sx:{position:"relative"},children:n($t,{styles:t,postSubmit:i})})})}const se={size:"sm",spacing:"md",button:{size:"xs"}};function Vt({postSubmit:t,styles:r=se,initialRoleID:i}){const{control:s,handleSubmit:u}=C.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 n(o.Box,{mx:"auto",children:b("form",{onSubmit:u(l),children:[n(C.Controller,{name:"name",control:s,render:({field:c})=>n(o.TextInput,{mb:r.spacing,size:r.size,required:!0,label:"Name",...c})}),n(C.Controller,{name:"role_id",control:s,render:({field:c})=>n(ge,{styles:r,...c})}),n(o.Group,{position:"right",mt:r.spacing,children:n(o.Button,{type:"submit",size:r.button.size,children:"Save"})})]})})}function Ae({onSuccess:t,styles:r=se,initialRoleID:i}){const s=X.useModals(),[u,l]=G.default.useState(!1),c=()=>l(!0),f=()=>l(!1),g=(w,_)=>{f(),s.openModal({title:"API Key is generated",children:b(o.Stack,{children:[n(o.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),n(o.TextInput,{defaultValue:w,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),n(o.TextInput,{defaultValue:_,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),n(o.Button,{size:"sm",onClick:()=>{X.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{t()}})};return b(N,{children:[n(o.Modal,{overflow:"inside",opened:u,onClose:()=>l(!1),title:"Add an API Key",trapFocus:!0,onDragStart:w=>{w.stopPropagation()},children:n(Vt,{postSubmit:g,styles:r,initialRoleID:i})}),n(o.Button,{size:r.button.size,onClick:c,leftIcon:n(B.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function De({id:t,name:r,onSuccess:i,styles:s=se}){const u=X.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 [${r}] 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 n(o.Button,{size:s.button.size,color:"red",onClick:c,leftIcon:n(B.Trash,{size:20}),children:"Delete"})}function Wt({styles:t=se,config:r}){var w,_;ie(r);const{data:i=[],loading:s,refresh:u}=U.useRequest(async()=>{const{data:m}=await j.api_key.list();return m},{refreshDeps:[]}),{data:l=[],loading:c}=U.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((m,p)=>(m.set(p.value,p.label),m),new Map),[l]),g=m=>{var p;return(p=f.get(m))!=null?p:m};return b(N,{children:[n(o.Group,{pt:t.spacing,position:"right",children:n(Ae,{onSuccess:u,initialRoleID:(_=(w=l==null?void 0:l[0])==null?void 0:w.value)!=null?_:0})}),b(o.Box,{mt:t.spacing,sx:{position:"relative"},children:[n(o.LoadingOverlay,{visible:s||c}),b(o.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[n("thead",{children:b("tr",{children:[n("th",{children:"Name"}),n("th",{children:"APP ID"}),n("th",{children:"Role"}),n("th",{children:"Action"})]})}),n("tbody",{children:i.map(m=>{const{id:p,name:z,app_id:q,role_id:V}=m;return b("tr",{children:[n("td",{width:200,children:z}),n("td",{width:200,children:q}),n("td",{width:200,children:g(V)}),n("td",{width:200,children:n(o.Group,{position:"left",children:n(De,{id:p,name:z,onSuccess:u})})})]},p)})})]})]})]})}const Gt=()=>Promise.resolve().then(()=>Yt).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t)),je="@devtable/settings-form",ke="8.13.5",Ie="Apache-2.0",qe={access:"public",registry:"https://registry.npmjs.org/"},Ne=["dist"],Le="./dist/settings-form.umd.js",Me="./dist/settings-form.es.js",Be="./dist/index.d.ts",Fe={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},$e={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},Ue={"@monaco-editor/react":"4.4.6","monaco-editor":"0.36.0"},Ve={"@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","vite-plugin-static-copy":"0.13.1"},We={"@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"},Yt=Object.freeze(Object.defineProperty({__proto__:null,name:je,version:ke,license:Ie,publishConfig:qe,files:Ne,main:Le,module:Me,types:Be,exports:Fe,scripts:$e,dependencies:Ue,devDependencies:Ve,peerDependencies:We,default:{name:je,version:ke,license:Ie,publishConfig:qe,files:Ne,main:Le,module:Me,types:Be,exports:Fe,scripts:$e,dependencies:Ue,devDependencies:Ve,peerDependencies:We}},Symbol.toStringTag,{value:"Module"}));P.APIKeyList=Wt,P.AccountList=Ft,P.AddAPIKey=Ae,P.AddAccount=Oe,P.AddDataSource=Ee,P.DataSourceList=qt,P.DeleteAPIKey=De,P.DeleteAccount=ze,P.DeleteDataSource=xe,P.Login=Ut,P.getVersion=Gt,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devtable/settings-form",
|
|
3
|
-
"version": "8.13.
|
|
3
|
+
"version": "8.13.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"@types/react-dom": "^18.0.0",
|
|
39
39
|
"@types/react-grid-layout": "^1.3.2",
|
|
40
40
|
"rollup-plugin-visualizer": "5.6.0",
|
|
41
|
-
"typescript": "^4.6.3"
|
|
41
|
+
"typescript": "^4.6.3",
|
|
42
|
+
"vite-plugin-static-copy": "0.13.1"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@emotion/react": "11.10.0",
|