@devtable/settings-form 7.20.3 → 7.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const e = "@devtable/settings-form", s = "7.20.3", t = "Apache-2.0", i = {
1
+ const e = "@devtable/settings-form", s = "7.21.0", t = "Apache-2.0", i = {
2
2
  access: "public",
3
3
  registry: "https://registry.npmjs.org/"
4
4
  }, n = [
@@ -3703,7 +3703,7 @@ function Ko({
3703
3703
  })]
3704
3704
  });
3705
3705
  }
3706
- const Ho = () => import("./package.5aa7e026.mjs").then(({ version: e }) => (console.log(`[@devtable/dashboard] version: ${e}`), e));
3706
+ const Ho = () => import("./package.e3bf28e3.mjs").then(({ version: e }) => (console.log(`[@devtable/dashboard] version: ${e}`), e));
3707
3707
  export {
3708
3708
  Ko as APIKeyList,
3709
3709
  Vo as AccountList,
@@ -55,4 +55,4 @@ object-assign
55
55
  */var nt,qt;function _n(){if(qt)return nt;qt=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function i(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function s(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var c={},u=0;u<10;u++)c["_"+String.fromCharCode(u)]=u;var p=Object.getOwnPropertyNames(c).map(function(w){return c[w]});if(p.join("")!=="0123456789")return!1;var m={};return"abcdefghijklmnopqrst".split("").forEach(function(w){m[w]=w}),Object.keys(Object.assign({},m)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return nt=s()?Object.assign:function(o,c){for(var u,p=i(o),m,w=1;w<arguments.length;w++){u=Object(arguments[w]);for(var v in u)t.call(u,v)&&(p[v]=u[v]);if(e){m=e(u);for(var y=0;y<m.length;y++)r.call(u,m[y])&&(p[m[y]]=u[m[y]])}}return p},nt}var it,kt;function ot(){if(kt)return it;kt=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return it=e,it}var at,$t;function Lt(){return $t||($t=1,at=Function.call.bind(Object.prototype.hasOwnProperty)),at}var st,Nt;function Cn(){if(Nt)return st;Nt=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var t=ot(),r={},i=Lt();e=function(o){var c="Warning: "+o;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}}}function s(o,c,u,p,m){if(process.env.NODE_ENV!=="production"){for(var w in o)if(i(o,w)){var v;try{if(typeof o[w]!="function"){var y=Error((p||"React class")+": "+u+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw y.name="Invariant Violation",y}v=o[w](c,w,p,u,null,t)}catch(V){v=V}if(v&&!(v instanceof Error)&&e((p||"React class")+": type specification of "+u+" `"+w+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof v+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),v instanceof Error&&!(v.message in r)){r[v.message]=!0;var j=m?m():"";e("Failed "+u+" type: "+v.message+(j!=null?j:""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(r={})},st=s,st}var ct,Ft;function jn(){if(Ft)return ct;Ft=1;var e=zt(),t=_n(),r=ot(),i=Lt(),s=Cn(),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(u){var p="Warning: "+u;typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}});function c(){return null}return ct=function(u,p){var m=typeof Symbol=="function"&&Symbol.iterator,w="@@iterator";function v(l){var h=l&&(m&&l[m]||l[w]);if(typeof h=="function")return h}var y="<<anonymous>>",j={array:Q("array"),bigint:Q("bigint"),bool:Q("boolean"),func:Q("function"),number:Q("number"),object:Q("object"),string:Q("string"),symbol:Q("symbol"),any:$(),arrayOf:Z,element:G(),elementType:g(),instanceOf:te,node:F(),objectOf:ye,oneOf:ie,oneOfType:re,shape:me,exact:ce};function V(l,h){return l===h?l!==0||1/l===1/h:l!==l&&h!==h}function k(l,h){this.message=l,this.data=h&&typeof h=="object"?h:{},this.stack=""}k.prototype=Error.prototype;function H(l){if(process.env.NODE_ENV!=="production")var h={},P=0;function R(A,_,C,M,N,I,ue){if(M=M||y,I=I||C,ue!==r){if(p){var S=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw S.name="Invariant Violation",S}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var ge=M+":"+C;!h[ge]&&P<3&&(o("You are manually calling a React.PropTypes validation function for the `"+I+"` prop on `"+M+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),h[ge]=!0,P++)}}return _[C]==null?A?_[C]===null?new k("The "+N+" `"+I+"` is marked as required "+("in `"+M+"`, but its value is `null`.")):new k("The "+N+" `"+I+"` is marked as required in "+("`"+M+"`, but its value is `undefined`.")):null:l(_,C,M,N,I)}var x=R.bind(null,!1);return x.isRequired=R.bind(null,!0),x}function Q(l){function h(P,R,x,A,_,C){var M=P[R],N=se(M);if(N!==l){var I=fe(M);return new k("Invalid "+A+" `"+_+"` of type "+("`"+I+"` supplied to `"+x+"`, expected ")+("`"+l+"`."),{expectedType:l})}return null}return H(h)}function $(){return H(c)}function Z(l){function h(P,R,x,A,_){if(typeof l!="function")return new k("Property `"+_+"` of component `"+x+"` has invalid PropType notation inside arrayOf.");var C=P[R];if(!Array.isArray(C)){var M=se(C);return new k("Invalid "+A+" `"+_+"` of type "+("`"+M+"` supplied to `"+x+"`, expected an array."))}for(var N=0;N<C.length;N++){var I=l(C,N,x,A,_+"["+N+"]",r);if(I instanceof Error)return I}return null}return H(h)}function G(){function l(h,P,R,x,A){var _=h[P];if(!u(_)){var C=se(_);return new k("Invalid "+x+" `"+A+"` of type "+("`"+C+"` supplied to `"+R+"`, expected a single ReactElement."))}return null}return H(l)}function g(){function l(h,P,R,x,A){var _=h[P];if(!e.isValidElementType(_)){var C=se(_);return new k("Invalid "+x+" `"+A+"` of type "+("`"+C+"` supplied to `"+R+"`, expected a single ReactElement type."))}return null}return H(l)}function te(l){function h(P,R,x,A,_){if(!(P[R]instanceof l)){var C=l.name||y,M=Pe(P[R]);return new k("Invalid "+A+" `"+_+"` of type "+("`"+M+"` supplied to `"+x+"`, expected ")+("instance of `"+C+"`."))}return null}return H(h)}function ie(l){if(!Array.isArray(l))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):o("Invalid argument supplied to oneOf, expected an array.")),c;function h(P,R,x,A,_){for(var C=P[R],M=0;M<l.length;M++)if(V(C,l[M]))return null;var N=JSON.stringify(l,function(ue,S){var ge=fe(S);return ge==="symbol"?String(S):S});return new k("Invalid "+A+" `"+_+"` of value `"+String(C)+"` "+("supplied to `"+x+"`, expected one of "+N+"."))}return H(h)}function ye(l){function h(P,R,x,A,_){if(typeof l!="function")return new k("Property `"+_+"` of component `"+x+"` has invalid PropType notation inside objectOf.");var C=P[R],M=se(C);if(M!=="object")return new k("Invalid "+A+" `"+_+"` of type "+("`"+M+"` supplied to `"+x+"`, expected an object."));for(var N in C)if(i(C,N)){var I=l(C,N,x,A,_+"."+N,r);if(I instanceof Error)return I}return null}return H(h)}function re(l){if(!Array.isArray(l))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),c;for(var h=0;h<l.length;h++){var P=l[h];if(typeof P!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+be(P)+" at index "+h+"."),c}function R(x,A,_,C,M){for(var N=[],I=0;I<l.length;I++){var ue=l[I],S=ue(x,A,_,C,M,r);if(S==null)return null;S.data&&i(S.data,"expectedType")&&N.push(S.data.expectedType)}var ge=N.length>0?", expected one of type ["+N.join(", ")+"]":"";return new k("Invalid "+C+" `"+M+"` supplied to "+("`"+_+"`"+ge+"."))}return H(R)}function F(){function l(h,P,R,x,A){return q(h[P])?null:new k("Invalid "+x+" `"+A+"` supplied to "+("`"+R+"`, expected a ReactNode."))}return H(l)}function pe(l,h,P,R,x){return new k((l||"React class")+": "+h+" type `"+P+"."+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+x+"`.")}function me(l){function h(P,R,x,A,_){var C=P[R],M=se(C);if(M!=="object")return new k("Invalid "+A+" `"+_+"` of type `"+M+"` "+("supplied to `"+x+"`, expected `object`."));for(var N in l){var I=l[N];if(typeof I!="function")return pe(x,A,_,N,fe(I));var ue=I(C,N,x,A,_+"."+N,r);if(ue)return ue}return null}return H(h)}function ce(l){function h(P,R,x,A,_){var C=P[R],M=se(C);if(M!=="object")return new k("Invalid "+A+" `"+_+"` of type `"+M+"` "+("supplied to `"+x+"`, expected `object`."));var N=t({},P[R],l);for(var I in N){var ue=l[I];if(i(l,I)&&typeof ue!="function")return pe(x,A,_,I,fe(ue));if(!ue)return new k("Invalid "+A+" `"+_+"` key `"+I+"` supplied to `"+x+"`.\nBad object: "+JSON.stringify(P[R],null," ")+`
56
56
  Valid keys: `+JSON.stringify(Object.keys(l),null," "));var S=ue(C,I,x,A,_+"."+I,r);if(S)return S}return null}return H(h)}function q(l){switch(typeof l){case"number":case"string":case"undefined":return!0;case"boolean":return!l;case"object":if(Array.isArray(l))return l.every(q);if(l===null||u(l))return!0;var h=v(l);if(h){var P=h.call(l),R;if(h!==l.entries){for(;!(R=P.next()).done;)if(!q(R.value))return!1}else for(;!(R=P.next()).done;){var x=R.value;if(x&&!q(x[1]))return!1}}else return!1;return!0;default:return!1}}function X(l,h){return l==="symbol"?!0:h?h["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&h instanceof Symbol:!1}function se(l){var h=typeof l;return Array.isArray(l)?"array":l instanceof RegExp?"object":X(h,l)?"symbol":h}function fe(l){if(typeof l>"u"||l===null)return""+l;var h=se(l);if(h==="object"){if(l instanceof Date)return"date";if(l instanceof RegExp)return"regexp"}return h}function be(l){var h=fe(l);switch(h){case"array":case"object":return"an "+h;case"boolean":case"date":case"regexp":return"a "+h;default:return h}}function Pe(l){return!l.constructor||!l.constructor.name?y:l.constructor.name}return j.checkPropTypes=s,j.resetWarningCache=s.resetWarningCache,j.PropTypes=j,j},ct}var ut,Ut;function An(){if(Ut)return ut;Ut=1;var e=ot();function t(){}function r(){}return r.resetWarningCache=t,ut=function(){function i(c,u,p,m,w,v){if(v!==e){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}i.isRequired=i;function s(){return i}var o={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:r,resetWarningCache:t};return o.PropTypes=o,o},ut}if(process.env.NODE_ENV!=="production"){var Mn=zt(),In=!0;T.exports=jn()(Mn.isElement,In)}else T.exports=An()();const Dn={display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"};function zn({content:e}){return a("div",{style:Dn,children:e})}const lt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}};function Bt({width:e,height:t,isEditorReady:r,loading:i,_ref:s,className:o,wrapperProps:c}){return D("section",{style:{...lt.wrapper,width:e,height:t},...c,children:[!r&&a(zn,{content:i}),a("div",{ref:s,style:{...lt.fullWidth,...!r&&lt.hide},className:o})]})}Bt.propTypes={width:T.exports.oneOfType([T.exports.number,T.exports.string]).isRequired,height:T.exports.oneOfType([T.exports.number,T.exports.string]).isRequired,loading:T.exports.oneOfType([T.exports.element,T.exports.string]).isRequired,isEditorReady:T.exports.bool.isRequired,className:T.exports.string,wrapperProps:T.exports.object};var Wt=O.memo(Bt);function Yt(e){O.useEffect(e,[])}function ve(e,t,r=!0){const i=O.useRef(!0);O.useEffect(i.current||!r?()=>{i.current=!1}:e,t)}function Ne(){}function Ke(e,t,r,i){return qn(e,i)||kn(e,t,r,i)}function qn(e,t){return e.editor.getModel(Vt(e,t))}function kn(e,t,r,i){return e.editor.createModel(t,r,i&&Vt(e,i))}function Vt(e,t){return e.Uri.parse(t)}function $n(e){return e===void 0}function Gt({original:e,modified:t,language:r,originalLanguage:i,modifiedLanguage:s,originalModelPath:o,modifiedModelPath:c,keepCurrentOriginalModel:u,keepCurrentModifiedModel:p,theme:m,loading:w,options:v,height:y,width:j,className:V,wrapperProps:k,beforeMount:H,onMount:Q}){const[$,Z]=O.useState(!1),[G,g]=O.useState(!0),te=O.useRef(null),ie=O.useRef(null),ye=O.useRef(null),re=O.useRef(Q),F=O.useRef(H);Yt(()=>{const q=At.init();return q.then(X=>(ie.current=X)&&g(!1)).catch(X=>(X==null?void 0:X.type)!=="cancelation"&&console.error("Monaco initialization: error:",X)),()=>te.current?ce():q.cancel()}),ve(()=>{const q=te.current.getModifiedEditor();q.getOption(ie.current.editor.EditorOption.readOnly)?q.setValue(t):t!==q.getValue()&&(q.executeEdits("",[{range:q.getModel().getFullModelRange(),text:t,forceMoveMarkers:!0}]),q.pushUndoStop())},[t],$),ve(()=>{te.current.getModel().original.setValue(e)},[e],$),ve(()=>{const{original:q,modified:X}=te.current.getModel();ie.current.editor.setModelLanguage(q,i||r),ie.current.editor.setModelLanguage(X,s||r)},[r,i,s],$),ve(()=>{ie.current.editor.setTheme(m)},[m],$),ve(()=>{te.current.updateOptions(v)},[v],$);const pe=O.useCallback(()=>{F.current(ie.current);const q=Ke(ie.current,e,i||r,o),X=Ke(ie.current,t,s||r,c);te.current.setModel({original:q,modified:X})},[r,t,s,e,i,o,c]),me=O.useCallback(()=>{te.current=ie.current.editor.createDiffEditor(ye.current,{automaticLayout:!0,...v}),pe(),ie.current.editor.setTheme(m),Z(!0)},[v,m,pe]);O.useEffect(()=>{$&&re.current(te.current,ie.current)},[$]),O.useEffect(()=>{!G&&!$&&me()},[G,$,me]);function ce(){const q=te.current.getModel();if(!u){var X;(X=q.original)===null||X===void 0||X.dispose()}if(!p){var se;(se=q.modified)===null||se===void 0||se.dispose()}te.current.dispose()}return a(Wt,{width:j,height:y,isEditorReady:$,loading:w,_ref:ye,className:V,wrapperProps:k})}Gt.propTypes={original:T.exports.string,modified:T.exports.string,language:T.exports.string,originalLanguage:T.exports.string,modifiedLanguage:T.exports.string,originalModelPath:T.exports.string,modifiedModelPath:T.exports.string,keepCurrentOriginalModel:T.exports.bool,keepCurrentModifiedModel:T.exports.bool,theme:T.exports.string,loading:T.exports.oneOfType([T.exports.element,T.exports.string]),options:T.exports.object,width:T.exports.oneOfType([T.exports.number,T.exports.string]),height:T.exports.oneOfType([T.exports.number,T.exports.string]),className:T.exports.string,wrapperProps:T.exports.object,beforeMount:T.exports.func,onMount:T.exports.func},Gt.defaultProps={theme:"light",loading:"Loading...",options:{},keepCurrentOriginalModel:!1,keepCurrentModifiedModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:Ne,onMount:Ne};function Ln(e){const t=O.useRef();return O.useEffect(()=>{t.current=e},[e]),t.current}const Je=new Map;function dt({defaultValue:e,defaultLanguage:t,defaultPath:r,value:i,language:s,path:o,theme:c,line:u,loading:p,options:m,overrideServices:w,saveViewState:v,keepCurrentModel:y,width:j,height:V,className:k,wrapperProps:H,beforeMount:Q,onMount:$,onChange:Z,onValidate:G}){const[g,te]=O.useState(!1),[ie,ye]=O.useState(!0),re=O.useRef(null),F=O.useRef(null),pe=O.useRef(null),me=O.useRef($),ce=O.useRef(Q),q=O.useRef(null),X=O.useRef(i),se=Ln(o),fe=O.useRef(!1);Yt(()=>{const l=At.init();return l.then(h=>(re.current=h)&&ye(!1)).catch(h=>(h==null?void 0:h.type)!=="cancelation"&&console.error("Monaco initialization: error:",h)),()=>F.current?Pe():l.cancel()}),ve(()=>{const l=Ke(re.current,e||i,t||s,o);l!==F.current.getModel()&&(v&&Je.set(se,F.current.saveViewState()),F.current.setModel(l),v&&F.current.restoreViewState(Je.get(o)))},[o],g),ve(()=>{F.current.updateOptions(m)},[m],g),ve(()=>{F.current.getOption(re.current.editor.EditorOption.readOnly)?F.current.setValue(i):i!==F.current.getValue()&&(F.current.executeEdits("",[{range:F.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),F.current.pushUndoStop())},[i],g),ve(()=>{re.current.editor.setModelLanguage(F.current.getModel(),s)},[s],g),ve(()=>{$n(u)||F.current.revealLine(u)},[u],g),ve(()=>{re.current.editor.setTheme(c)},[c],g);const be=O.useCallback(()=>{if(!fe.current){ce.current(re.current);const l=o||r,h=Ke(re.current,i||e,t||s,l);F.current=re.current.editor.create(pe.current,{model:h,automaticLayout:!0,...m},w),v&&F.current.restoreViewState(Je.get(l)),re.current.editor.setTheme(c),te(!0),fe.current=!0}},[e,t,r,i,s,o,m,w,v,c]);O.useEffect(()=>{g&&me.current(F.current,re.current)},[g]),O.useEffect(()=>{!ie&&!g&&be()},[ie,g,be]),X.current=i,O.useEffect(()=>{if(g&&Z){var l,h;(l=q.current)===null||l===void 0||l.dispose(),q.current=(h=F.current)===null||h===void 0?void 0:h.onDidChangeModelContent(P=>{Z(F.current.getValue(),P)})}},[g,Z]),O.useEffect(()=>{if(g){const l=re.current.editor.onDidChangeMarkers(h=>{var P;const R=(P=F.current.getModel())===null||P===void 0?void 0:P.uri;if(R&&h.find(A=>A.path===R.path)){const A=re.current.editor.getModelMarkers({resource:R});G==null||G(A)}});return()=>{l==null||l.dispose()}}},[g,G]);function Pe(){var l;if((l=q.current)===null||l===void 0||l.dispose(),y)v&&Je.set(o,F.current.saveViewState());else{var h;(h=F.current.getModel())===null||h===void 0||h.dispose()}F.current.dispose()}return a(Wt,{width:j,height:V,isEditorReady:g,loading:p,_ref:pe,className:k,wrapperProps:H})}dt.propTypes={defaultValue:T.exports.string,defaultPath:T.exports.string,defaultLanguage:T.exports.string,value:T.exports.string,language:T.exports.string,path:T.exports.string,theme:T.exports.string,line:T.exports.number,loading:T.exports.oneOfType([T.exports.element,T.exports.string]),options:T.exports.object,overrideServices:T.exports.object,saveViewState:T.exports.bool,keepCurrentModel:T.exports.bool,width:T.exports.oneOfType([T.exports.number,T.exports.string]),height:T.exports.oneOfType([T.exports.number,T.exports.string]),className:T.exports.string,wrapperProps:T.exports.object,beforeMount:T.exports.func,onMount:T.exports.func,onChange:T.exports.func,onValidate:T.exports.func},dt.defaultProps={theme:"light",loading:"Loading...",options:{},overrideServices:{},saveViewState:!0,keepCurrentModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:Ne,onMount:Ne,onValidate:Ne};var Nn=O.memo(dt);const Fn=({value:e,onChange:t})=>{const r=i=>{!i||t(i)};return a(f.Box,{sx:{position:"relative"},children:a(Nn,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Kt=O.forwardRef(({value:e,onChange:t,label:r,modalTitle:i,defaultValue:s,styles:o},c)=>{const[u,{setTrue:p,setFalse:m}]=Re.useBoolean(),[w,v]=O.useState(e),y=()=>{m(),t(w)},j=()=>{m(),v(e)},V=()=>{v(s)};return O.useEffect(()=>{v(e)},[e]),D(we,{children:[a(f.Button,{variant:"filled",size:o.button.size,onClick:p,sx:{flexGrow:1},children:r}),a(f.Modal,{size:800,title:i,opened:u,onClose:m,closeOnClickOutside:!1,withCloseButton:!1,children:u&&D(f.Stack,{children:[a(Fn,{value:w,onChange:v}),D(f.Group,{position:"apart",children:[a(f.Button,{onClick:V,color:"red",leftIcon:a(Te.Recycle,{size:20}),children:"Rest"}),D(f.Group,{position:"right",children:[a(f.Button,{onClick:j,variant:"subtle",children:"Cancel"}),a(f.Button,{onClick:y,children:"OK"})]})]})]})})]})}),Xe={pre:["function pre_process({ method, url, params, headers, data }, utils) {"," // your code goes here"," return { method, url, params, headers, data }","}"].join(`
57
57
  `),post:["function post_process(res, utils) {"," // your code goes here"," return data","}"].join(`
58
- `)};function Un({submit:e,styles:t=Ce}){const{control:r,setValue:i,handleSubmit:s}=Y.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:Xe.pre,post:Xe.post}}}});return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(e),children:[a(Y.Controller,{name:"key",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...o})}),a(f.Divider,{label:"Connection Info",labelPosition:"center"}),a(Y.Controller,{name:"config.host",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Base URL",sx:{flexGrow:1},...o})}),D(f.Group,{grow:!0,children:[a(Y.Controller,{name:"config.processing.pre",control:r,render:({field:o})=>a(Kt,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:Xe.pre,...o,styles:t})}),a(Y.Controller,{name:"config.processing.post",control:r,render:({field:o})=>a(Kt,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:Xe.post,...o,styles:t})})]}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Bn({postSubmit:e,styles:t=Ce}){const[r,i]=O.useState("postgresql"),s=async({type:u,key:p,config:m})=>{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{console.log({type:u,key:p,config:m}),await de.datasource.create(u,p,m),ee.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),e()}catch(w){ee.updateNotification({id:"for-creating",title:"Failed",message:w.message,color:"red"})}},o=r==="postgresql"||r==="mysql",c=r==="http";return D(f.Box,{mx:"auto",children:[a(f.SegmentedControl,{fullWidth:!0,mb:t.spacing,size:t.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:r,onChange:u=>i(u)}),o&&a($r,{submit:s,styles:t,type:r}),c&&a(Un,{submit:s,styles:t})]})}function Jt({onSuccess:e,styles:t=Ce}){const[r,i]=_e.default.useState(!1),s=()=>i(!0),o=()=>i(!1),c=()=>{e(),o()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:r,onClose:()=>i(!1),title:"Add a data source",trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:a(Bn,{postSubmit:c,styles:t})}),a(f.Button,{size:t.button.size,onClick:s,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function ft(){return ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ft.apply(this,arguments)}function Wn(e,t){if(e==null)return{};var r,i,s=function(c,u){if(c==null)return{};var p,m,w={},v=Object.keys(c);for(m=0;m<v.length;m++)p=v[m],u.indexOf(p)>=0||(w[p]=c[p]);return w}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}var Yn=["size","color","stroke"];function Vn(e){var t=e.size,r=t===void 0?24:t,i=e.color,s=i===void 0?"currentColor":i,o=e.stroke,c=o===void 0?2:o,u=Wn(e,Yn);return De.createElement("svg",ft({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-lock",width:r,height:r,viewBox:"0 0 24 24",strokeWidth:c,stroke:s,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},u),De.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),De.createElement("rect",{x:5,y:11,width:14,height:10,rx:2}),De.createElement("circle",{cx:12,cy:16,r:1}),De.createElement("path",{d:"M8 11v-4a4 4 0 0 1 8 0v4"}))}function Xt({id:e,name:t,isProtected:r,onSuccess:i,styles:s=Ce}){const o=Ie.useModals(),c=async()=>{!e||(ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await de.datasource.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${t}] is deleted`,color:"green"}),i())},u=()=>o.openConfirmModal({title:"Delete this data source?",children:a(f.Text,{size:s.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:c}),p=f.useMantineTheme();return r?a(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:a("span",{children:a(Vn,{size:16,color:p.colors.gray[7]})})}):a(f.Button,{size:s.button.size,color:"red",onClick:u,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function Gn({styles:e=Ce,config:t}){Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:o}=await de.datasource.list();return o},{refreshDeps:[]});return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Jt,{onSuccess:s})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Type"}),a("th",{children:"Name"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(({id:o,key:c,type:u,is_preset:p})=>D("tr",{children:[a("td",{width:200,children:u}),a("td",{children:c}),a("td",{width:200,children:a(f.Group,{position:"left",children:a(Xt,{isProtected:p,id:o,name:c,onSuccess:s})})})]},c))})]})]})]})}const Kn=O.forwardRef(({label:e,value:t,description:r,...i},s)=>D(f.Stack,{spacing:2,ref:s,...i,children:[a(f.Text,{size:"sm",children:e}),a(f.Text,{size:"xs",color:"dimmed",className:"role-description",children:r})]})),pt=O.forwardRef(({styles:e,value:t,onChange:r},i)=>{const{data:s=[],loading:o}=Re.useRequest(async()=>(await de.role.list()).map(u=>({label:u.name,value:u.id,description:u.description,disabled:u.id===50})),{refreshDeps:[]});return a(f.Select,{ref:i,mb:e.spacing,size:e.size,required:!0,label:"Role",itemComponent:Kn,data:s,disabled:o,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:t,onChange:r})}),Oe={size:"sm",spacing:"md",button:{size:"xs"}};function Jn({postSubmit:e,styles:t=Oe,initialRoleID:r}){const{control:i,handleSubmit:s}=Y.useForm({defaultValues:{name:"",email:"",role_id:r,password:""}}),o=async({name:c,email:u,password:p,role_id:m})=>{try{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await de.account.create(c,u,p,m),ee.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),e()}catch(w){ee.updateNotification({id:"for-creating",title:"Failed",message:w.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(o),children:[a(Y.Controller,{name:"name",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...c})}),a(Y.Controller,{name:"email",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Email",...c})}),a(Y.Controller,{name:"password",control:i,render:({field:c})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),a(Y.Controller,{name:"role_id",control:i,render:({field:c})=>a(pt,{styles:t,...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Qt({onSuccess:e,styles:t=Oe,initialRoleID:r}){const[i,s]=_e.default.useState(!1),o=()=>s(!0),c=()=>s(!1),u=()=>{e(),c()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:i,onClose:()=>s(!1),title:"Add an Account",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a(Jn,{postSubmit:u,styles:t,initialRoleID:r})}),a(f.Button,{size:t.button.size,onClick:o,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Zt({id:e,name:t,onSuccess:r,styles:i=Oe}){const s=Ie.useModals(),o=async()=>{if(!!e){ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await de.account.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${t}] is deleted`,color:"green"}),r()}catch(u){ee.updateNotification({id:"for-deleting",title:"Failed",message:u.message,color:"red"})}}},c=()=>s.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:o});return a(f.Button,{size:i.button.size,color:"red",onClick:c,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function Xn({id:e,name:t,email:r,role_id:i,postSubmit:s,styles:o=Oe}){const{control:c,handleSubmit:u,watch:p}=Y.useForm({defaultValues:{name:t,email:r,role_id:i,reset_password:!1,new_password:""}}),m=async({name:y,email:j,role_id:V,reset_password:k,new_password:H})=>{try{ee.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await de.account.edit({id:e,name:y,email:j,role_id:V,reset_password:k,new_password:H}),ee.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),s()}catch(Q){ee.updateNotification({id:"for-updating",title:"Failed",message:Q.message,color:"red"})}},[w,v]=p(["reset_password","new_password"]);return a(f.Box,{mx:"auto",children:D("form",{onSubmit:u(m),children:[a(Y.Controller,{name:"name",control:c,render:({field:y})=>a(f.TextInput,{mb:o.spacing,size:o.size,required:!0,label:"Username",...y})}),a(Y.Controller,{name:"email",control:c,render:({field:y})=>a(f.TextInput,{mb:o.spacing,size:o.size,required:!0,label:"Email",...y})}),a(Y.Controller,{name:"role_id",control:c,render:({field:y})=>a(pt,{styles:o,...y})}),a(f.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),a(Y.Controller,{name:"reset_password",control:c,render:({field:y})=>a(f.Switch,{mb:o.spacing,size:o.size,label:"Reset password",checked:y.value,onChange:j=>y.onChange(j.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),w&&a(Y.Controller,{name:"new_password",control:c,render:({field:y})=>a(f.PasswordInput,{autoComplete:"off",mb:o.spacing,size:o.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...y})}),a(f.Group,{position:"right",mt:o.spacing,children:a(f.Button,{type:"submit",size:o.button.size,children:"Submit"})})]})})}function Qn({account:e,onSuccess:t,styles:r=Oe}){const[i,s]=_e.default.useState(!1),o=()=>s(!0),c=()=>s(!1),u=()=>{t(),c()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:i,onClose:()=>s(!1),title:`Editing ${e.name}`,trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a(Xn,{...e,postSubmit:u,styles:r})}),a(f.Button,{size:r.button.size,onClick:o,leftIcon:a(Te.Edit,{size:20}),children:"Edit"})]})}function Zn({styles:e=Oe,config:t}){var m,w;Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:v}=await de.account.list();return v},{refreshDeps:[]}),{data:o=[],loading:c}=Re.useRequest(async()=>(await de.role.list()).map(y=>({label:y.name,value:y.id,description:y.description,disabled:y.id===50})),{refreshDeps:[]}),u=O.useMemo(()=>o.reduce((v,y)=>(v.set(y.value,y.label),v),new Map),[o]),p=v=>{var y;return(y=u.get(v))!=null?y:v};return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Qt,{onSuccess:s,initialRoleID:(w=(m=o==null?void 0:o[0])==null?void 0:m.value)!=null?w:0})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i||c}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Username"}),a("th",{children:"Email"}),a("th",{children:"Role"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(v=>{const{id:y,name:j,email:V,role_id:k}=v;return D("tr",{children:[a("td",{width:200,children:j}),a("td",{width:200,children:V}),a("td",{width:200,children:p(k)}),a("td",{width:200,children:D(f.Group,{position:"left",children:[a(Qn,{account:v,onSuccess:s}),a(Zt,{id:y,name:j,onSuccess:s})]})})]},y)})})]})]})]})}function Hn({postSubmit:e,styles:t=Oe}){const{control:r,handleSubmit:i}=Y.useForm({defaultValues:{name:"",password:""}}),s=async({name:o,password:c})=>{try{ee.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const u=await de.account.login(o,c);window.localStorage.setItem("token",u.token),ee.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),e(u)}catch(u){ee.updateNotification({id:"for-login",title:"Login Failed",message:u.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:i(s),children:[a(Y.Controller,{name:"name",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...o})}),a(Y.Controller,{name:"password",control:r,render:({field:o})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...o})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Submit"})})]})})}function ei({styles:e=Oe,config:t,onSuccess:r}){return Be(t),a(we,{children:a(f.Box,{mt:e.spacing,sx:{position:"relative"},children:a(Hn,{styles:e,postSubmit:r})})})}const Qe={size:"sm",spacing:"md",button:{size:"xs"}};function ti({postSubmit:e,styles:t=Qe,initialRoleID:r}){const{control:i,handleSubmit:s}=Y.useForm({defaultValues:{name:"",role_id:r}}),o=async({name:c,role_id:u})=>{try{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:p,app_secret:m}=await de.api_key.create(c,u);ee.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),e(p,m)}catch(p){ee.updateNotification({id:"for-creating",title:"Failed",message:p.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(o),children:[a(Y.Controller,{name:"name",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...c})}),a(Y.Controller,{name:"role_id",control:i,render:({field:c})=>a(pt,{styles:t,...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Ht({onSuccess:e,styles:t=Qe,initialRoleID:r}){const i=Ie.useModals(),[s,o]=_e.default.useState(!1),c=()=>o(!0),u=()=>o(!1),p=(m,w)=>{u(),i.openModal({title:"API Key is generated",children:D(f.Stack,{children:[a(f.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),a(f.TextInput,{defaultValue:m,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),a(f.TextInput,{defaultValue:w,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),a(f.Button,{size:"sm",onClick:()=>{Ie.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{e()}})};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:s,onClose:()=>o(!1),title:"Add an API Key",trapFocus:!0,onDragStart:m=>{m.stopPropagation()},children:a(ti,{postSubmit:p,styles:t,initialRoleID:r})}),a(f.Button,{size:t.button.size,onClick:c,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function er({id:e,name:t,onSuccess:r,styles:i=Qe}){const s=Ie.useModals(),o=async()=>{if(!!e){ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await de.api_key.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${t}] is deleted`,color:"green"}),r()}catch(u){ee.updateNotification({id:"for-deleting",title:"Failed",message:u.message,color:"red"})}}},c=()=>s.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:o});return a(f.Button,{size:i.button.size,color:"red",onClick:c,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function ri({styles:e=Qe,config:t}){var m,w;Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:v}=await de.api_key.list();return v},{refreshDeps:[]}),{data:o=[],loading:c}=Re.useRequest(async()=>(await de.role.list()).map(y=>({label:y.name,value:y.id,description:y.description,disabled:y.id===50})),{refreshDeps:[]}),u=O.useMemo(()=>o.reduce((v,y)=>(v.set(y.value,y.label),v),new Map),[o]),p=v=>{var y;return(y=u.get(v))!=null?y:v};return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Ht,{onSuccess:s,initialRoleID:(w=(m=o==null?void 0:o[0])==null?void 0:m.value)!=null?w:0})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i||c}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Name"}),a("th",{children:"APP ID"}),a("th",{children:"Role"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(v=>{const{id:y,name:j,app_id:V,role_id:k}=v;return D("tr",{children:[a("td",{width:200,children:j}),a("td",{width:200,children:V}),a("td",{width:200,children:p(k)}),a("td",{width:200,children:a(f.Group,{position:"left",children:a(er,{id:y,name:j,onSuccess:s})})})]},y)})})]})]})]})}const ni=()=>Promise.resolve().then(()=>ii).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e)),tr="@devtable/settings-form",rr="7.20.3",nr="Apache-2.0",ir={access:"public",registry:"https://registry.npmjs.org/"},or=["dist"],ar="./dist/settings-form.umd.js",sr="./dist/settings-form.es.js",cr="./dist/index.d.ts",ur={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},lr={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},dr={},fr={"@types/crypto-js":"v4.1.1","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2","rollup-plugin-visualizer":"5.6.0",typescript:"^4.6.3"},pr={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5",ahooks:"^3.3.11",axios:"^0.27.2","crypto-js":"^4.1.1",lodash:"^4.17.21",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-hook-form":"^7.31.2","tabler-icons-react":"^1.48.0"},ii=Object.freeze(Object.defineProperty({__proto__:null,name:tr,version:rr,license:nr,publishConfig:ir,files:or,main:ar,module:sr,types:cr,exports:ur,scripts:lr,dependencies:dr,devDependencies:fr,peerDependencies:pr,default:{name:tr,version:rr,license:nr,publishConfig:ir,files:or,main:ar,module:sr,types:cr,exports:ur,scripts:lr,dependencies:dr,devDependencies:fr,peerDependencies:pr}},Symbol.toStringTag,{value:"Module"}));J.APIKeyList=ri,J.AccountList=Zn,J.AddAPIKey=Ht,J.AddAccount=Qt,J.AddDataSource=Jt,J.DataSourceList=Gn,J.DeleteAPIKey=er,J.DeleteAccount=Zt,J.DeleteDataSource=Xt,J.Login=ei,J.getVersion=ni,Object.defineProperties(J,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
58
+ `)};function Un({submit:e,styles:t=Ce}){const{control:r,setValue:i,handleSubmit:s}=Y.useForm({defaultValues:{type:"http",key:"",config:{host:"",processing:{pre:Xe.pre,post:Xe.post}}}});return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(e),children:[a(Y.Controller,{name:"key",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",placeholder:"A unique name",...o})}),a(f.Divider,{label:"Connection Info",labelPosition:"center"}),a(Y.Controller,{name:"config.host",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Base URL",sx:{flexGrow:1},...o})}),D(f.Group,{grow:!0,children:[a(Y.Controller,{name:"config.processing.pre",control:r,render:({field:o})=>a(Kt,{label:"Pre Processing",modalTitle:"This function will run before sending the request (for scenarios like encryption)",defaultValue:Xe.pre,...o,styles:t})}),a(Y.Controller,{name:"config.processing.post",control:r,render:({field:o})=>a(Kt,{label:"Post Processing",modalTitle:"This function will run after sending the request (for scenarios like decryption)",defaultValue:Xe.post,...o,styles:t})})]}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Bn({postSubmit:e,styles:t=Ce}){const[r,i]=O.useState("postgresql"),s=async({type:u,key:p,config:m})=>{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{console.log({type:u,key:p,config:m}),await de.datasource.create(u,p,m),ee.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),e()}catch(w){ee.updateNotification({id:"for-creating",title:"Failed",message:w.message,color:"red"})}},o=r==="postgresql"||r==="mysql",c=r==="http";return D(f.Box,{mx:"auto",children:[a(f.SegmentedControl,{fullWidth:!0,mb:t.spacing,size:t.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http"}],value:r,onChange:u=>i(u)}),o&&a($r,{submit:s,styles:t,type:r}),c&&a(Un,{submit:s,styles:t})]})}function Jt({onSuccess:e,styles:t=Ce}){const[r,i]=_e.default.useState(!1),s=()=>i(!0),o=()=>i(!1),c=()=>{e(),o()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:r,onClose:()=>i(!1),title:"Add a data source",trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:a(Bn,{postSubmit:c,styles:t})}),a(f.Button,{size:t.button.size,onClick:s,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function ft(){return ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ft.apply(this,arguments)}function Wn(e,t){if(e==null)return{};var r,i,s=function(c,u){if(c==null)return{};var p,m,w={},v=Object.keys(c);for(m=0;m<v.length;m++)p=v[m],u.indexOf(p)>=0||(w[p]=c[p]);return w}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}var Yn=["size","color","stroke"];function Vn(e){var t=e.size,r=t===void 0?24:t,i=e.color,s=i===void 0?"currentColor":i,o=e.stroke,c=o===void 0?2:o,u=Wn(e,Yn);return De.createElement("svg",ft({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-lock",width:r,height:r,viewBox:"0 0 24 24",strokeWidth:c,stroke:s,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},u),De.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),De.createElement("rect",{x:5,y:11,width:14,height:10,rx:2}),De.createElement("circle",{cx:12,cy:16,r:1}),De.createElement("path",{d:"M8 11v-4a4 4 0 0 1 8 0v4"}))}function Xt({id:e,name:t,isProtected:r,onSuccess:i,styles:s=Ce}){const o=Ie.useModals(),c=async()=>{!e||(ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await de.datasource.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${t}] is deleted`,color:"green"}),i())},u=()=>o.openConfirmModal({title:"Delete this data source?",children:a(f.Text,{size:s.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:c}),p=f.useMantineTheme();return r?a(f.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:a("span",{children:a(Vn,{size:16,color:p.colors.gray[7]})})}):a(f.Button,{size:s.button.size,color:"red",onClick:u,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function Gn({styles:e=Ce,config:t}){Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:o}=await de.datasource.list();return o},{refreshDeps:[]});return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Jt,{onSuccess:s})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Type"}),a("th",{children:"Name"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(({id:o,key:c,type:u,is_preset:p})=>D("tr",{children:[a("td",{width:200,children:u}),a("td",{children:c}),a("td",{width:200,children:a(f.Group,{position:"left",children:a(Xt,{isProtected:p,id:o,name:c,onSuccess:s})})})]},c))})]})]})]})}const Kn=O.forwardRef(({label:e,value:t,description:r,...i},s)=>D(f.Stack,{spacing:2,ref:s,...i,children:[a(f.Text,{size:"sm",children:e}),a(f.Text,{size:"xs",color:"dimmed",className:"role-description",children:r})]})),pt=O.forwardRef(({styles:e,value:t,onChange:r},i)=>{const{data:s=[],loading:o}=Re.useRequest(async()=>(await de.role.list()).map(u=>({label:u.name,value:u.id,description:u.description,disabled:u.id===50})),{refreshDeps:[]});return a(f.Select,{ref:i,mb:e.spacing,size:e.size,required:!0,label:"Role",itemComponent:Kn,data:s,disabled:o,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:t,onChange:r})}),Oe={size:"sm",spacing:"md",button:{size:"xs"}};function Jn({postSubmit:e,styles:t=Oe,initialRoleID:r}){const{control:i,handleSubmit:s}=Y.useForm({defaultValues:{name:"",email:"",role_id:r,password:""}}),o=async({name:c,email:u,password:p,role_id:m})=>{try{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await de.account.create(c,u,p,m),ee.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),e()}catch(w){ee.updateNotification({id:"for-creating",title:"Failed",message:w.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(o),children:[a(Y.Controller,{name:"name",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...c})}),a(Y.Controller,{name:"email",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Email",...c})}),a(Y.Controller,{name:"password",control:i,render:({field:c})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),a(Y.Controller,{name:"role_id",control:i,render:({field:c})=>a(pt,{styles:t,...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Qt({onSuccess:e,styles:t=Oe,initialRoleID:r}){const[i,s]=_e.default.useState(!1),o=()=>s(!0),c=()=>s(!1),u=()=>{e(),c()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:i,onClose:()=>s(!1),title:"Add an Account",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a(Jn,{postSubmit:u,styles:t,initialRoleID:r})}),a(f.Button,{size:t.button.size,onClick:o,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Zt({id:e,name:t,onSuccess:r,styles:i=Oe}){const s=Ie.useModals(),o=async()=>{if(!!e){ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await de.account.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${t}] is deleted`,color:"green"}),r()}catch(u){ee.updateNotification({id:"for-deleting",title:"Failed",message:u.message,color:"red"})}}},c=()=>s.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:o});return a(f.Button,{size:i.button.size,color:"red",onClick:c,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function Xn({id:e,name:t,email:r,role_id:i,postSubmit:s,styles:o=Oe}){const{control:c,handleSubmit:u,watch:p}=Y.useForm({defaultValues:{name:t,email:r,role_id:i,reset_password:!1,new_password:""}}),m=async({name:y,email:j,role_id:V,reset_password:k,new_password:H})=>{try{ee.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await de.account.edit({id:e,name:y,email:j,role_id:V,reset_password:k,new_password:H}),ee.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),s()}catch(Q){ee.updateNotification({id:"for-updating",title:"Failed",message:Q.message,color:"red"})}},[w,v]=p(["reset_password","new_password"]);return a(f.Box,{mx:"auto",children:D("form",{onSubmit:u(m),children:[a(Y.Controller,{name:"name",control:c,render:({field:y})=>a(f.TextInput,{mb:o.spacing,size:o.size,required:!0,label:"Username",...y})}),a(Y.Controller,{name:"email",control:c,render:({field:y})=>a(f.TextInput,{mb:o.spacing,size:o.size,required:!0,label:"Email",...y})}),a(Y.Controller,{name:"role_id",control:c,render:({field:y})=>a(pt,{styles:o,...y})}),a(f.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),a(Y.Controller,{name:"reset_password",control:c,render:({field:y})=>a(f.Switch,{mb:o.spacing,size:o.size,label:"Reset password",checked:y.value,onChange:j=>y.onChange(j.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),w&&a(Y.Controller,{name:"new_password",control:c,render:({field:y})=>a(f.PasswordInput,{autoComplete:"off",mb:o.spacing,size:o.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...y})}),a(f.Group,{position:"right",mt:o.spacing,children:a(f.Button,{type:"submit",size:o.button.size,children:"Submit"})})]})})}function Qn({account:e,onSuccess:t,styles:r=Oe}){const[i,s]=_e.default.useState(!1),o=()=>s(!0),c=()=>s(!1),u=()=>{t(),c()};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:i,onClose:()=>s(!1),title:`Editing ${e.name}`,trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:a(Xn,{...e,postSubmit:u,styles:r})}),a(f.Button,{size:r.button.size,onClick:o,leftIcon:a(Te.Edit,{size:20}),children:"Edit"})]})}function Zn({styles:e=Oe,config:t}){var m,w;Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:v}=await de.account.list();return v},{refreshDeps:[]}),{data:o=[],loading:c}=Re.useRequest(async()=>(await de.role.list()).map(y=>({label:y.name,value:y.id,description:y.description,disabled:y.id===50})),{refreshDeps:[]}),u=O.useMemo(()=>o.reduce((v,y)=>(v.set(y.value,y.label),v),new Map),[o]),p=v=>{var y;return(y=u.get(v))!=null?y:v};return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Qt,{onSuccess:s,initialRoleID:(w=(m=o==null?void 0:o[0])==null?void 0:m.value)!=null?w:0})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i||c}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Username"}),a("th",{children:"Email"}),a("th",{children:"Role"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(v=>{const{id:y,name:j,email:V,role_id:k}=v;return D("tr",{children:[a("td",{width:200,children:j}),a("td",{width:200,children:V}),a("td",{width:200,children:p(k)}),a("td",{width:200,children:D(f.Group,{position:"left",children:[a(Qn,{account:v,onSuccess:s}),a(Zt,{id:y,name:j,onSuccess:s})]})})]},y)})})]})]})]})}function Hn({postSubmit:e,styles:t=Oe}){const{control:r,handleSubmit:i}=Y.useForm({defaultValues:{name:"",password:""}}),s=async({name:o,password:c})=>{try{ee.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const u=await de.account.login(o,c);window.localStorage.setItem("token",u.token),ee.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),e(u)}catch(u){ee.updateNotification({id:"for-login",title:"Login Failed",message:u.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:i(s),children:[a(Y.Controller,{name:"name",control:r,render:({field:o})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Username",...o})}),a(Y.Controller,{name:"password",control:r,render:({field:o})=>a(f.PasswordInput,{mb:t.spacing,size:t.size,required:!0,label:"Password",...o})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Submit"})})]})})}function ei({styles:e=Oe,config:t,onSuccess:r}){return Be(t),a(we,{children:a(f.Box,{mt:e.spacing,sx:{position:"relative"},children:a(Hn,{styles:e,postSubmit:r})})})}const Qe={size:"sm",spacing:"md",button:{size:"xs"}};function ti({postSubmit:e,styles:t=Qe,initialRoleID:r}){const{control:i,handleSubmit:s}=Y.useForm({defaultValues:{name:"",role_id:r}}),o=async({name:c,role_id:u})=>{try{ee.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:p,app_secret:m}=await de.api_key.create(c,u);ee.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),e(p,m)}catch(p){ee.updateNotification({id:"for-creating",title:"Failed",message:p.message,color:"red"})}};return a(f.Box,{mx:"auto",children:D("form",{onSubmit:s(o),children:[a(Y.Controller,{name:"name",control:i,render:({field:c})=>a(f.TextInput,{mb:t.spacing,size:t.size,required:!0,label:"Name",...c})}),a(Y.Controller,{name:"role_id",control:i,render:({field:c})=>a(pt,{styles:t,...c})}),a(f.Group,{position:"right",mt:t.spacing,children:a(f.Button,{type:"submit",size:t.button.size,children:"Save"})})]})})}function Ht({onSuccess:e,styles:t=Qe,initialRoleID:r}){const i=Ie.useModals(),[s,o]=_e.default.useState(!1),c=()=>o(!0),u=()=>o(!1),p=(m,w)=>{u(),i.openModal({title:"API Key is generated",children:D(f.Stack,{children:[a(f.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),a(f.TextInput,{defaultValue:m,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),a(f.TextInput,{defaultValue:w,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),a(f.Button,{size:"sm",onClick:()=>{Ie.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{e()}})};return D(we,{children:[a(f.Modal,{overflow:"inside",opened:s,onClose:()=>o(!1),title:"Add an API Key",trapFocus:!0,onDragStart:m=>{m.stopPropagation()},children:a(ti,{postSubmit:p,styles:t,initialRoleID:r})}),a(f.Button,{size:t.button.size,onClick:c,leftIcon:a(Te.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function er({id:e,name:t,onSuccess:r,styles:i=Qe}){const s=Ie.useModals(),o=async()=>{if(!!e){ee.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await de.api_key.delete(e),ee.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${t}] is deleted`,color:"green"}),r()}catch(u){ee.updateNotification({id:"for-deleting",title:"Failed",message:u.message,color:"red"})}}},c=()=>s.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:o});return a(f.Button,{size:i.button.size,color:"red",onClick:c,leftIcon:a(Te.Trash,{size:20}),children:"Delete"})}function ri({styles:e=Qe,config:t}){var m,w;Be(t);const{data:r=[],loading:i,refresh:s}=Re.useRequest(async()=>{const{data:v}=await de.api_key.list();return v},{refreshDeps:[]}),{data:o=[],loading:c}=Re.useRequest(async()=>(await de.role.list()).map(y=>({label:y.name,value:y.id,description:y.description,disabled:y.id===50})),{refreshDeps:[]}),u=O.useMemo(()=>o.reduce((v,y)=>(v.set(y.value,y.label),v),new Map),[o]),p=v=>{var y;return(y=u.get(v))!=null?y:v};return D(we,{children:[a(f.Group,{pt:e.spacing,position:"right",children:a(Ht,{onSuccess:s,initialRoleID:(w=(m=o==null?void 0:o[0])==null?void 0:m.value)!=null?w:0})}),D(f.Box,{mt:e.spacing,sx:{position:"relative"},children:[a(f.LoadingOverlay,{visible:i||c}),D(f.Table,{horizontalSpacing:e.spacing,verticalSpacing:e.spacing,fontSize:e.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Name"}),a("th",{children:"APP ID"}),a("th",{children:"Role"}),a("th",{children:"Action"})]})}),a("tbody",{children:r.map(v=>{const{id:y,name:j,app_id:V,role_id:k}=v;return D("tr",{children:[a("td",{width:200,children:j}),a("td",{width:200,children:V}),a("td",{width:200,children:p(k)}),a("td",{width:200,children:a(f.Group,{position:"left",children:a(er,{id:y,name:j,onSuccess:s})})})]},y)})})]})]})]})}const ni=()=>Promise.resolve().then(()=>ii).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e)),tr="@devtable/settings-form",rr="7.21.0",nr="Apache-2.0",ir={access:"public",registry:"https://registry.npmjs.org/"},or=["dist"],ar="./dist/settings-form.umd.js",sr="./dist/settings-form.es.js",cr="./dist/index.d.ts",ur={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},lr={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},dr={},fr={"@types/crypto-js":"v4.1.1","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2","rollup-plugin-visualizer":"5.6.0",typescript:"^4.6.3"},pr={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5",ahooks:"^3.3.11",axios:"^0.27.2","crypto-js":"^4.1.1",lodash:"^4.17.21",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-hook-form":"^7.31.2","tabler-icons-react":"^1.48.0"},ii=Object.freeze(Object.defineProperty({__proto__:null,name:tr,version:rr,license:nr,publishConfig:ir,files:or,main:ar,module:sr,types:cr,exports:ur,scripts:lr,dependencies:dr,devDependencies:fr,peerDependencies:pr,default:{name:tr,version:rr,license:nr,publishConfig:ir,files:or,main:ar,module:sr,types:cr,exports:ur,scripts:lr,dependencies:dr,devDependencies:fr,peerDependencies:pr}},Symbol.toStringTag,{value:"Module"}));J.APIKeyList=ri,J.AccountList=Zn,J.AddAPIKey=Ht,J.AddAccount=Qt,J.AddDataSource=Jt,J.DataSourceList=Gn,J.DeleteAPIKey=er,J.DeleteAccount=Zt,J.DeleteDataSource=Xt,J.Login=ei,J.getVersion=ni,Object.defineProperties(J,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/settings-form",
3
- "version": "7.20.3",
3
+ "version": "7.21.0",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",