@devtable/settings-form 4.1.0 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-caller/request.d.ts +1 -1
- package/dist/global.d.ts +2 -0
- package/dist/settings-form.es.js +839 -288
- package/dist/settings-form.umd.js +20 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(b,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@mantine/core"),require("@mantine/notifications"),require("react"),require("react-hook-form"),require("tabler-icons-react"),require("axios"),require("ahooks"),require("@mantine/modals")):typeof define=="function"&&define.amd?define(["exports","@mantine/core","@mantine/notifications","react","react-hook-form","tabler-icons-react","axios","ahooks","@mantine/modals"],d):(b=typeof globalThis<"u"?globalThis:b||self,d(b["settings-form"]={},b["@mantine/core"],b["@mantine/notifications"],b.React,b["react-hook-form"],b["tabler-icons-react"],b.axios,b.ahooks,b["@mantine/modals"]))})(this,function(b,d,q,Ne,x,se,$e,We,Ue){"use strict";const ue=o=>o&&typeof o=="object"&&"default"in o?o:{default:o},Q=ue(Ne),Me=ue($e),L={baseURL:"http://localhost:31200",getRequest(o){return(s,v,p={})=>{const _={"X-Requested-With":"XMLHttpRequest","Content-Type":p.string?"application/x-www-form-urlencoded":"application/json",...p.headers},l={baseURL:this.baseURL,method:o,url:s,params:o==="GET"?v:p.params,headers:_};return o==="POST"&&(l.data=p.string?JSON.stringify(v):v),Me.default(l).then(m=>m.data).catch(m=>Promise.reject(m))}}},Z={datasource:{list:async()=>await L.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}}),create:async(o,s,v)=>{try{return await L.getRequest("POST")("/datasource/create",{type:o,key:s,config:v})}catch(p){return console.error(p),!1}},delete:async o=>{await L.getRequest("POST")("/datasource/delete",{id:o})}}},M={size:"sm",spacing:"md"};var Y={exports:{}},N={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,22 @@
|
|
|
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 le;function Ye(){if(le)return N;le=1;var o=Q.default,s=Symbol.for("react.element"),v=Symbol.for("react.fragment"),p=Object.prototype.hasOwnProperty,_=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function m(S,R,k){var T,w={},j=null,V=null;k!==void 0&&(j=""+k),R.key!==void 0&&(j=""+R.key),R.ref!==void 0&&(V=R.ref);for(T in R)p.call(R,T)&&!l.hasOwnProperty(T)&&(w[T]=R[T]);if(S&&S.defaultProps)for(T in R=S.defaultProps,R)w[T]===void 0&&(w[T]=R[T]);return{$$typeof:s,type:S,key:j,ref:V,props:w,_owner:_.current}}return N.Fragment=v,N.jsx=m,N.jsxs=m,N}var $={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var ce;function Ve(){return ce||(ce=1,process.env.NODE_ENV!=="production"&&function(){var o=Q.default,s=Symbol.for("react.element"),v=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),S=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),ve=Symbol.iterator,Je="@@iterator";function Xe(e){if(e===null||typeof e!="object")return null;var r=ve&&e[ve]||e[Je];return typeof r=="function"?r:null}var I=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Ke("error",e,t)}}function Ke(e,r,t){{var n=I.ReactDebugCurrentFrame,c=n.getStackAddendum();c!==""&&(r+="%s",t=t.concat([c]));var f=t.map(function(u){return String(u)});f.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,f)}}var Qe=!1,Ze=!1,He=!1,er=!1,rr=!1,he;he=Symbol.for("react.module.reference");function tr(e){return!!(typeof e=="string"||typeof e=="function"||e===p||e===l||rr||e===_||e===k||e===T||er||e===V||Qe||Ze||He||typeof e=="object"&&e!==null&&(e.$$typeof===j||e.$$typeof===w||e.$$typeof===m||e.$$typeof===S||e.$$typeof===R||e.$$typeof===he||e.getModuleId!==void 0))}function nr(e,r,t){var n=e.displayName;if(n)return n;var c=r.displayName||r.name||"";return c!==""?t+"("+c+")":t}function ge(e){return e.displayName||"Context"}function P(e){if(e==null)return null;if(typeof e.tag=="number"&&y("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 p:return"Fragment";case v:return"Portal";case l:return"Profiler";case _:return"StrictMode";case k:return"Suspense";case T:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case S:var r=e;return ge(r)+".Consumer";case m:var t=e;return ge(t._context)+".Provider";case R:return nr(e,e.render,"ForwardRef");case w:var n=e.displayName||null;return n!==null?n:P(e.type)||"Memo";case j:{var c=e,f=c._payload,u=c._init;try{return P(u(f))}catch{return null}}}return null}var A=Object.assign,W=0,me,be,Re,_e,ye,Ee,Se;function Te(){}Te.__reactDisabledLog=!0;function ar(){{if(W===0){me=console.log,be=console.info,Re=console.warn,_e=console.error,ye=console.group,Ee=console.groupCollapsed,Se=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Te,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}W++}}function ir(){{if(W--,W===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},e,{value:me}),info:A({},e,{value:be}),warn:A({},e,{value:Re}),error:A({},e,{value:_e}),group:A({},e,{value:ye}),groupCollapsed:A({},e,{value:Ee}),groupEnd:A({},e,{value:Se})})}W<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var H=I.ReactCurrentDispatcher,ee;function B(e,r,t){{if(ee===void 0)try{throw Error()}catch(c){var n=c.stack.trim().match(/\n( *(at )?)/);ee=n&&n[1]||""}return`
|
|
18
|
+
`+ee+e}}var re=!1,G;{var or=typeof WeakMap=="function"?WeakMap:Map;G=new or}function Ce(e,r){if(!e||re)return"";{var t=G.get(e);if(t!==void 0)return t}var n;re=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var f;f=H.current,H.current=null,ar();try{if(r){var u=function(){throw Error()};if(Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(O){n=O}Reflect.construct(e,[],u)}else{try{u.call()}catch(O){n=O}e.call(u.prototype)}}else{try{throw Error()}catch(O){n=O}e()}}catch(O){if(O&&n&&typeof O.stack=="string"){for(var i=O.stack.split(`
|
|
19
|
+
`),E=n.stack.split(`
|
|
20
|
+
`),h=i.length-1,g=E.length-1;h>=1&&g>=0&&i[h]!==E[g];)g--;for(;h>=1&&g>=0;h--,g--)if(i[h]!==E[g]){if(h!==1||g!==1)do if(h--,g--,g<0||i[h]!==E[g]){var C=`
|
|
21
|
+
`+i[h].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),typeof e=="function"&&G.set(e,C),C}while(h>=1&&g>=0);break}}}finally{re=!1,H.current=f,ir(),Error.prepareStackTrace=c}var z=e?e.displayName||e.name:"",Le=z?B(z):"";return typeof e=="function"&&G.set(e,Le),Le}function sr(e,r,t){return Ce(e,!1)}function ur(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function J(e,r,t){if(e==null)return"";if(typeof e=="function")return Ce(e,ur(e));if(typeof e=="string")return B(e);switch(e){case k:return B("Suspense");case T:return B("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case R:return sr(e.render);case w:return J(e.type,r,t);case j:{var n=e,c=n._payload,f=n._init;try{return J(f(c),r,t)}catch{}}}return""}var X=Object.prototype.hasOwnProperty,we={},Pe=I.ReactDebugCurrentFrame;function K(e){if(e){var r=e._owner,t=J(e.type,e._source,r?r.type:null);Pe.setExtraStackFrame(t)}else Pe.setExtraStackFrame(null)}function lr(e,r,t,n,c){{var f=Function.call.bind(X);for(var u in e)if(f(e,u)){var i=void 0;try{if(typeof e[u]!="function"){var E=Error((n||"React class")+": "+t+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw E.name="Invariant Violation",E}i=e[u](r,u,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(h){i=h}i&&!(i instanceof Error)&&(K(c),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,u,typeof i),K(null)),i instanceof Error&&!(i.message in we)&&(we[i.message]=!0,K(c),y("Failed %s type: %s",t,i.message),K(null))}}}var cr=Array.isArray;function te(e){return cr(e)}function fr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function dr(e){try{return Oe(e),!1}catch{return!0}}function Oe(e){return""+e}function xe(e){if(dr(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",fr(e)),Oe(e)}var U=I.ReactCurrentOwner,pr={key:!0,ref:!0,__self:!0,__source:!0},De,je,ne;ne={};function vr(e){if(X.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function hr(e){if(X.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function gr(e,r){if(typeof e.ref=="string"&&U.current&&r&&U.current.stateNode!==r){var t=P(U.current.type);ne[t]||(y('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',P(U.current.type),e.ref),ne[t]=!0)}}function mr(e,r){{var t=function(){De||(De=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function br(e,r){{var t=function(){je||(je=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var Rr=function(e,r,t,n,c,f,u){var i={$$typeof:s,type:e,key:r,ref:t,props:u,_owner:f};return i._store={},Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i};function _r(e,r,t,n,c){{var f,u={},i=null,E=null;t!==void 0&&(xe(t),i=""+t),hr(r)&&(xe(r.key),i=""+r.key),vr(r)&&(E=r.ref,gr(r,c));for(f in r)X.call(r,f)&&!pr.hasOwnProperty(f)&&(u[f]=r[f]);if(e&&e.defaultProps){var h=e.defaultProps;for(f in h)u[f]===void 0&&(u[f]=h[f])}if(i||E){var g=typeof e=="function"?e.displayName||e.name||"Unknown":e;i&&mr(u,g),E&&br(u,g)}return Rr(e,i,E,c,n,U.current,u)}}var ae=I.ReactCurrentOwner,Ae=I.ReactDebugCurrentFrame;function F(e){if(e){var r=e._owner,t=J(e.type,e._source,r?r.type:null);Ae.setExtraStackFrame(t)}else Ae.setExtraStackFrame(null)}var ie;ie=!1;function oe(e){return typeof e=="object"&&e!==null&&e.$$typeof===s}function ke(){{if(ae.current){var e=P(ae.current.type);if(e)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function yr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
|
|
24
|
+
|
|
25
|
+
Check your code at `+r+":"+t+"."}return""}}var Ie={};function Er(e){{var r=ke();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
26
|
+
|
|
27
|
+
Check the top-level render call using <`+t+">.")}return r}}function Fe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=Er(r);if(Ie[t])return;Ie[t]=!0;var n="";e&&e._owner&&e._owner!==ae.current&&(n=" It was passed a child from "+P(e._owner.type)+"."),F(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),F(null)}}function ze(e,r){{if(typeof e!="object")return;if(te(e))for(var t=0;t<e.length;t++){var n=e[t];oe(n)&&Fe(n,r)}else if(oe(e))e._store&&(e._store.validated=!0);else if(e){var c=Xe(e);if(typeof c=="function"&&c!==e.entries)for(var f=c.call(e),u;!(u=f.next()).done;)oe(u.value)&&Fe(u.value,r)}}}function Sr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===R||r.$$typeof===w))t=r.propTypes;else return;if(t){var n=P(r);lr(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ie){ie=!0;var c=P(r);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",c||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Tr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){F(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),F(null);break}}e.ref!==null&&(F(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),F(null))}}function qe(e,r,t,n,c,f){{var u=tr(e);if(!u){var i="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(i+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var E=yr(c);E?i+=E:i+=ke();var h;e===null?h="null":te(e)?h="array":e!==void 0&&e.$$typeof===s?(h="<"+(P(e.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):h=typeof e,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",h,i)}var g=_r(e,r,t,c,f);if(g==null)return g;if(u){var C=r.children;if(C!==void 0)if(n)if(te(C)){for(var z=0;z<C.length;z++)ze(C[z],e);Object.freeze&&Object.freeze(C)}else y("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 ze(C,e)}return e===p?Tr(g):Sr(g),g}}function Cr(e,r,t){return qe(e,r,t,!0)}function wr(e,r,t){return qe(e,r,t,!1)}var Pr=wr,Or=Cr;$.Fragment=p,$.jsx=Pr,$.jsxs=Or}()),$}(function(o){process.env.NODE_ENV==="production"?o.exports=Ye():o.exports=Ve()})(Y);const fe=Y.exports.Fragment,a=Y.exports.jsx,D=Y.exports.jsxs;function Be({postSubmit:o,styles:s=M}){const{control:v,handleSubmit:p}=x.useForm({defaultValues:{type:"postgresql",key:"",config:{host:"",port:5432,username:"",password:"",database:""}}}),_=async({type:l,key:m,config:S})=>{if(q.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0}),!await Z.datasource.create(l,m,S)){q.updateNotification({id:"for-creating",title:"Failed",message:"Test connection failed with given info",color:"red"});return}q.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),o()};return a(d.Box,{mx:"auto",children:D("form",{onSubmit:p(_),children:[a(x.Controller,{name:"type",control:v,render:({field:l})=>a(d.SegmentedControl,{fullWidth:!0,mb:s.spacing,size:s.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http",disabled:!0}],...l})}),a(x.Controller,{name:"key",control:v,render:({field:l})=>a(d.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Name",placeholder:"A unique name",...l})}),a(d.Divider,{label:"Connection Info",labelPosition:"center"}),D(d.Group,{grow:!0,children:[a(x.Controller,{name:"config.host",control:v,render:({field:l})=>a(d.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Host",sx:{flexGrow:1},...l})}),a(x.Controller,{name:"config.port",control:v,render:({field:l})=>a(d.NumberInput,{mb:s.spacing,size:s.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...l})})]}),a(x.Controller,{name:"config.username",control:v,render:({field:l})=>a(d.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Username",...l})}),a(x.Controller,{name:"config.password",control:v,render:({field:l})=>a(d.PasswordInput,{mb:s.spacing,size:s.size,required:!0,label:"Password",...l})}),a(x.Controller,{name:"config.database",control:v,render:({field:l})=>a(d.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Database",...l})}),a(d.Group,{position:"right",mt:s.spacing,children:a(d.Button,{type:"submit",size:s.size,children:"Save"})})]})})}function de({onSuccess:o,styles:s=M}){const[v,p]=Q.default.useState(!1),_=()=>p(!0),l=()=>p(!1),m=()=>{o(),l()};return D(fe,{children:[a(d.Modal,{overflow:"inside",opened:v,onClose:()=>p(!1),title:"Add a data source",trapFocus:!0,onDragStart:S=>{S.stopPropagation()},children:a(Be,{postSubmit:m,styles:s})}),a(d.Button,{size:s.size,onClick:_,leftIcon:a(se.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function pe({id:o,name:s,onSuccess:v,styles:p=M}){const _=Ue.useModals(),l=async()=>{!o||(q.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await Z.datasource.delete(o),q.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${s}] is deleted`,color:"green"}),v())},m=()=>_.openConfirmModal({title:"Delete this data source?",children:a(d.Text,{size:p.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:l});return a(d.Button,{size:p.size,color:"red",onClick:m,leftIcon:a(se.Trash,{size:20}),children:"Delete"})}function Ge({styles:o=M,config:s}){const{data:v=[],loading:p,refresh:_}=We.useRequest(async()=>{const{data:l}=await Z.datasource.list();return l},{refreshDeps:[]});return L.baseURL!==s.apiBaseURL&&(L.baseURL=s.apiBaseURL),D(fe,{children:[a(d.Group,{pt:o.spacing,position:"right",children:a(de,{onSuccess:_})}),D(d.Box,{mt:o.spacing,sx:{position:"relative"},children:[a(d.LoadingOverlay,{visible:p}),D(d.Table,{horizontalSpacing:o.spacing,verticalSpacing:o.spacing,fontSize:o.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:v.map(({id:l,key:m,type:S})=>D("tr",{children:[a("td",{width:200,children:S}),a("td",{children:m}),a("td",{width:200,children:a(d.Group,{position:"left",children:a(pe,{id:l,name:m,onSuccess:_})})})]},m))})]})]})]})}b.AddDataSource=de,b.DataSourceList=Ge,b.DeleteDataSource=pe,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|