@artibet/react-mui-components 2.4.2 → 2.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- import{TextField as e,FormGroup as t,FormControlLabel as r,Switch as n,Typography as o,Stack as i,Box as a,Popover as l,Autocomplete as u}from"@mui/material";import c from"react";import{Controller as d}from"react-hook-form";import{ChromePicker as s}from"react-color";import f from"axios";import"date-fns";import"date-fns/locale";function v(){v=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",l=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var i=t&&t.prototype instanceof y?t:y,a=Object.create(i.prototype),l=new B(n||[]);return o(a,"_invoke",{value:q(e,r,l)}),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function y(){}function b(){}function x(){}var w={};c(w,a,(function(){return this}));var E=Object.getPrototypeOf,O=E&&E(E(P([])));O&&O!==r&&n.call(O,a)&&(w=O);var L=x.prototype=y.prototype=Object.create(w);function T(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,i,a,l){var u=s(e[o],e,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,l)}),(function(e){r("throw",e,a,l)})):t.resolve(d).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,l)}))}l(u.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function q(t,r,n){var o=f;return function(i,a){if(o===p)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var l=n.delegate;if(l){var u=j(l,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var c=s(t,r,n);if("normal"===c.type){if(o=n.done?m:h,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=m,n.method="throw",n.arg=c.arg)}}}function j(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,j(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=s(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function B(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function P(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=x,o(L,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:b,configurable:!0}),b.displayName=c(x,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,c(e,u,"GeneratorFunction")),e.prototype=Object.create(L),e},t.awrap=function(e){return{__await:e}},T(S.prototype),c(S.prototype,l,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new S(d(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(L),c(L,u,"Generator"),c(L,a,(function(){return this})),c(L,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=P,B.prototype={constructor:B,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(C),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return l.type="throw",l.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],l=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:P(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function h(e,t,r,n,o,i,a){try{var l=e[i](a),u=l.value}catch(e){return void r(e)}l.done?t(u):Promise.resolve(u).then(n,o)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){h(i,n,o,a,l,"next",e)}function l(e){h(i,n,o,a,l,"throw",e)}a(void 0)}))}}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},m.apply(this,arguments)}function g(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return b(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var x=["form","name","label","maxLength","required","disabled","autofocus"],w=function(t){var r=t.form,n=t.name,o=t.label,i=t.maxLength,a=void 0===i?255:i,l=t.required,u=void 0!==l&&l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,p=g(t,x),y=r.control,b=r.formState.errors;return c.createElement(d,{name:n,control:y,rules:{required:u,disabled:f},render:function(t){var r,i,l=t.field,d=l.onChange,s=l.onBlur,v=l.value;return c.createElement(e,m({required:u,label:o,value:v,onChange:d,onBlur:s,error:Boolean(null===(r=b[n])||void 0===r?void 0:r.message),fullWidth:!0,helperText:null===(i=b[n])||void 0===i?void 0:i.message,variant:"outlined",disabled:f,autoFocus:h,inputProps:{maxLength:a}},p))}})},E=["form","name","label","required","disabled","autofocus"],O=function(t){var r=t.form,n=t.name,o=void 0===n?"password":n,i=t.label,a=void 0===i?"Κωδικός Πρόσβασης":i,l=t.required,u=void 0===l||l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,p=g(t,E),y=r.control,b=r.formState.errors;return c.createElement(d,{name:o,control:y,rules:{required:u,disabled:f},render:function(t){var r,n,i=t.field,l=i.onChange,d=i.onBlur,s=i.value;return c.createElement(e,m({required:u,label:a,value:s,onChange:l,onBlur:d,error:Boolean(null===(r=b[o])||void 0===r?void 0:r.message),fullWidth:!0,helperText:null===(n=b[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:f,autoFocus:h,type:"password"},p))}})},L=["form","name","label","required","disabled","autofocus"],T=function(t){var r=t.form,n=t.name,o=void 0===n?"email":n,i=t.label,a=void 0===i?"E-mail":i,l=t.required,u=void 0===l||l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,p=g(t,L),y=r.control,b=r.formState.errors;return c.createElement(d,{name:o,control:y,rules:{required:u,disabled:f},render:function(t){var r,n,i=t.field,l=i.onChange,d=i.onBlur,s=i.value;return c.createElement(e,m({required:u,label:a,value:s,onChange:l,onBlur:d,error:Boolean(null===(r=b[o])||void 0===r?void 0:r.message),fullWidth:!0,helperText:null===(n=b[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:f,autoFocus:h},p))}})},S=["form","name","label","disabled"],q=function(e){var o=e.form,i=e.name,a=e.label,l=e.disabled,u=void 0!==l&&l,s=g(e,S),f=o.control;return c.createElement(d,{name:i,control:f,rules:{disabled:u},render:function(e){var l=e.field;l.onChange,l.onBlur;var u=l.value;return c.createElement(t,s,c.createElement(r,{control:c.createElement(n,{checked:Boolean(u),onChange:function(e){return o.setValue(i,e.target.checked)},inputProps:{"aria-label":a}}),label:a}))}})},j=function(e){var t=e.label,r=void 0===t?"":t,n=e.color,i=void 0===n?"white":n,a=e.backgroundColor,l=void 0===a?"#888888":a,u=e.paddingX,d=void 0===u?"10px":u,s=e.paddingY,f=void 0===s?"5px":s,v=e.borderRadius,h=void 0===v?"10px":v,p=e.fontSize,m=void 0===p?"14px":p,g=e.width,y={text:{display:"inline-block",textAlign:"center",backgroundColor:l,paddingX:d,paddingY:f,borderRadius:h,width:void 0===g?"auto":g,color:i,fontSize:m}};return c.createElement(o,{sx:y.text},r)},k=["form","name","label","selectionWidth","pickerWidth","selectionTextColor","paddingY","paddingX","required","disabled"],C=function(e){var t=e.form,r=e.name,n=void 0===r?"color":r,u=e.label,f=void 0===u?"Επιλογή Χρώματος":u,v=e.selectionWidth,h=void 0===v?70:v,p=e.pickerWidth,b=void 0===p?350:p,x=e.selectionTextColor,w=void 0===x?"white":x,E=e.paddingY,O=void 0===E?"10px":E,L=e.paddingX,T=void 0===L?"10px":L,S=e.required,q=void 0!==S&&S,C=e.disabled,B=void 0!==C&&C,P=g(e,k),_=y(c.useState(null),2),A=_[0],F=_[1],I=Boolean(A),W=I?"color-picker":void 0,G=t.control;return c.createElement(d,{name:n,control:G,rules:{disabled:B},render:function(e){var t=e.field,r=t.onChange;t.onBlur;var n=t.value;return c.createElement(i,m({gap:1},P),c.createElement(o,null,"".concat(f," ").concat(q?"*":"")),c.createElement(a,{sx:{display:"flex"}},c.createElement(a,{"aria-describedby":W,sx:{cursor:"pointer"},onClick:function(e){return F(e.currentTarget)}},c.createElement(j,{color:w,backgroundColor:n,paddingY:O,paddingX:T,width:h,label:n}))),c.createElement(l,{sx:{marginTop:"10px"},id:W,open:I,anchorEl:A,onClose:function(){return F(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"}},c.createElement(a,null,c.createElement(s,{width:b,color:n,onChange:function(e){return r(e.hex)}}))))}})},B=["form","name","label","required","disabled","options","valueKey","labelKey","maxLength","autofocus","noOptionsText"],P=function(t){var r=t.form,n=t.name,o=t.label,i=t.required,a=void 0!==i&&i,l=t.disabled,s=void 0!==l&&l,f=t.options,v=void 0===f?[]:f,h=t.valueKey,p=void 0===h?"id":h;t.labelKey;var b=t.maxLength,x=void 0===b?255:b,w=t.autofocus,E=void 0!==w&&w,O=t.noOptionsText,L=void 0===O?"Δεν υπάρχουν επιλογές":O,T=g(t,B),S=y(c.useState(null),2),q=S[0],j=S[1],k=r.watch(n);c.useEffect((function(){j(v.find((function(e){return e[p]===k}))||null)}),[k]);var C=r.control,P=r.formState.errors;return c.createElement(d,{name:n,control:C,rules:{required:a,disabled:s},render:function(t){var r=t.field,i=r.onChange,l=r.onBlur;return r.value,c.createElement(u,{value:q,required:a,onChange:function(e,t){return i(t?t[p]:null)},options:v,isOptionEqualToValue:function(e,t){return e[p]===t[p]},noOptionsText:L,renderInput:function(t){var r,i;return c.createElement(e,m({label:o,required:a,disabled:s,autoFocus:E,inputProps:{maxLength:x},error:Boolean(null===(r=P[n])||void 0===r?void 0:r.message),onBlur:l,variant:"outlined",fullWidth:!0,helperText:null===(i=P[n])||void 0===i?void 0:i.message},t,T))}})}})},_=["form","name","label","optionsUrl","valueKey","labelKey","minChars","required","disabled","maxLength","autofocus","loadingText","noOptionsText","placeholder","size"],A=function(t){var r=t.form,n=t.name,o=t.label,i=t.optionsUrl,a=t.valueKey,l=void 0===a?"id":a,s=t.labelKey,h=void 0===s?"label":s,b=t.minChars,x=void 0===b?2:b,w=t.required,E=void 0!==w&&w,O=t.disabled,L=void 0!==O&&O,T=t.maxLength,S=void 0===T?255:T,q=t.autofocus,j=void 0!==q&&q,k=t.loadingText,C=void 0===k?"Ανάκτηση...":k,B=t.noOptionsText,P=void 0===B?"Δεν υπάρχουν επιλογές":B,A=t.placeholder,F=void 0===A?"":A,I=t.size,W=void 0===I?"medium":I,G=g(t,_),K=y(c.useState(null),2),N=K[0],z=K[1],Y=y(c.useState([]),2),V=Y[0],X=Y[1],U=y(c.useState(!1),2),R=U[0],M=U[1],$=y(c.useState(""),2),D=$[0],H=$[1],J=r.watch(n),Q=r.control,Z=r.formState;r.setValue,r.getValues;var ee=Z.errors;c.useState((function(){if(console.log(V.length,J),0===V.length&&J){var e=function(){var e=p(v().mark((function e(){var t;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return M(!0),e.next=3,f.get("".concat(i,"?id=").concat(J));case 3:t=e.sent,X(t.data),z(t.data.find((function(e){return e[l]===J}))||null),M(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}}),[]),c.useEffect((function(){z(V.find((function(e){return e[l]===J}))||null)}),[J]),c.useEffect((function(){re()}),[D]);var te=function(e,t){H(t)},re=function(){var e=p(v().mark((function e(){var t;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(D.length<x)){e.next=4;break}return X([]),M(!1),e.abrupt("return");case 4:return M(!0),e.next=7,f.get("".concat(i,"?token=").concat(D));case 7:t=e.sent,X(t.data),M(!1);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return c.createElement(d,{name:n,control:Q,rules:{required:E,disabled:L},render:function(t){var r,i,a,d=t.field,s=d.onChange,f=d.onBlur;return d.value,c.createElement(u,{value:N,options:V,onInputChange:(r=te,i=300,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];a&&clearTimeout(a),a=setTimeout((function(){r.apply(void 0,t)}),i)}),onChange:function(e,t){return s(t?t[l]:null)},isOptionEqualToValue:function(e,t){return e[l]===t[l]},getOptionLabel:function(e){return e[h]},filterOptions:function(e){return e},noOptionsText:P,loadingText:C,loading:R,required:E,size:W,renderInput:function(t){var r,i;return c.createElement(e,m({label:o,required:E,disabled:L,autoFocus:j,placeholder:F,inputProps:{maxLength:S},error:Boolean(null===(r=ee[n])||void 0===r?void 0:r.message),onBlur:f,variant:"outlined",fullWidth:!0,helperText:null===(i=ee[n])||void 0===i?void 0:i.message,size:W},t,G))},renderOption:function(e,t,r){return c.createElement("li",m({},e,{key:t[l]}),t[h])}})}})};export{A as MyAutocompleteApiField,P as MyAutocompleteField,C as MyColorPickerField,T as MyEmailField,O as MyPasswordField,q as MySwitchField,w as MyTextField};
1
+ import{TextField as e,FormGroup as t,FormControlLabel as r,Switch as n,Typography as o,Stack as i,Box as a,Popover as l,Autocomplete as u}from"@mui/material";import c from"react";import{Controller as d}from"react-hook-form";import{ChromePicker as s}from"react-color";import f from"axios";import"date-fns";import"date-fns/locale";function v(){v=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",l=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var i=t&&t.prototype instanceof y?t:y,a=Object.create(i.prototype),l=new B(n||[]);return o(a,"_invoke",{value:q(e,r,l)}),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function y(){}function b(){}function x(){}var w={};c(w,a,(function(){return this}));var E=Object.getPrototypeOf,O=E&&E(E(P([])));O&&O!==r&&n.call(O,a)&&(w=O);var L=x.prototype=y.prototype=Object.create(w);function T(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,i,a,l){var u=s(e[o],e,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,l)}),(function(e){r("throw",e,a,l)})):t.resolve(d).then((function(e){c.value=e,a(c)}),(function(e){return r("throw",e,a,l)}))}l(u.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function q(t,r,n){var o=f;return function(i,a){if(o===p)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var l=n.delegate;if(l){var u=j(l,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var c=s(t,r,n);if("normal"===c.type){if(o=n.done?m:h,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=m,n.method="throw",n.arg=c.arg)}}}function j(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,j(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=s(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function B(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function P(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=x,o(L,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:b,configurable:!0}),b.displayName=c(x,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,c(e,u,"GeneratorFunction")),e.prototype=Object.create(L),e},t.awrap=function(e){return{__await:e}},T(S.prototype),c(S.prototype,l,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new S(d(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},T(L),c(L,u,"Generator"),c(L,a,(function(){return this})),c(L,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=P,B.prototype={constructor:B,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(C),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return l.type="throw",l.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],l=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),C(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:P(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function h(e,t,r,n,o,i,a){try{var l=e[i](a),u=l.value}catch(e){return void r(e)}l.done?t(u):Promise.resolve(u).then(n,o)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){h(i,n,o,a,l,"next",e)}function l(e){h(i,n,o,a,l,"throw",e)}a(void 0)}))}}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},m.apply(this,arguments)}function g(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return b(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var x=["form","name","label","maxLength","required","disabled","autofocus"],w=function(t){var r=t.form,n=t.name,o=t.label,i=t.maxLength,a=void 0===i?255:i,l=t.required,u=void 0!==l&&l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,p=g(t,x),y=r.control,b=r.formState.errors;return c.createElement(d,{name:n,control:y,rules:{required:u,disabled:f},render:function(t){var r,i,l=t.field,d=l.onChange,s=l.onBlur,v=l.value;return c.createElement(e,m({required:u,label:o,value:v,onChange:d,onBlur:s,error:Boolean(null===(r=b[n])||void 0===r?void 0:r.message),fullWidth:!0,helperText:null===(i=b[n])||void 0===i?void 0:i.message,variant:"outlined",disabled:f,autoFocus:h,inputProps:{maxLength:a}},p))}})},E=["form","name","label","required","disabled","autofocus"],O=function(t){var r=t.form,n=t.name,o=void 0===n?"password":n,i=t.label,a=void 0===i?"Κωδικός Πρόσβασης":i,l=t.required,u=void 0===l||l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,p=g(t,E),y=r.control,b=r.formState.errors;return c.createElement(d,{name:o,control:y,rules:{required:u,disabled:f},render:function(t){var r,n,i=t.field,l=i.onChange,d=i.onBlur,s=i.value;return c.createElement(e,m({required:u,label:a,value:s,onChange:l,onBlur:d,error:Boolean(null===(r=b[o])||void 0===r?void 0:r.message),fullWidth:!0,helperText:null===(n=b[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:f,autoFocus:h,type:"password"},p))}})},L=["form","name","label","required","disabled","autofocus"],T=function(t){var r=t.form,n=t.name,o=void 0===n?"email":n,i=t.label,a=void 0===i?"E-mail":i,l=t.required,u=void 0===l||l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,p=g(t,L),y=r.control,b=r.formState.errors;return c.createElement(d,{name:o,control:y,rules:{required:u,disabled:f},render:function(t){var r,n,i=t.field,l=i.onChange,d=i.onBlur,s=i.value;return c.createElement(e,m({required:u,label:a,value:s,onChange:l,onBlur:d,error:Boolean(null===(r=b[o])||void 0===r?void 0:r.message),fullWidth:!0,helperText:null===(n=b[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:f,autoFocus:h},p))}})},S=["form","name","label","disabled"],q=function(e){var o=e.form,i=e.name,a=e.label,l=e.disabled,u=void 0!==l&&l,s=g(e,S),f=o.control;return c.createElement(d,{name:i,control:f,rules:{disabled:u},render:function(e){var l=e.field;l.onChange,l.onBlur;var u=l.value;return c.createElement(t,s,c.createElement(r,{control:c.createElement(n,{checked:Boolean(u),onChange:function(e){return o.setValue(i,e.target.checked)},inputProps:{"aria-label":a}}),label:a}))}})},j=function(e){var t=e.label,r=void 0===t?"":t,n=e.color,i=void 0===n?"white":n,a=e.backgroundColor,l=void 0===a?"#888888":a,u=e.paddingX,d=void 0===u?"10px":u,s=e.paddingY,f=void 0===s?"5px":s,v=e.borderRadius,h=void 0===v?"10px":v,p=e.fontSize,m=void 0===p?"14px":p,g=e.width,y={text:{display:"inline-block",textAlign:"center",backgroundColor:l,paddingX:d,paddingY:f,borderRadius:h,width:void 0===g?"auto":g,color:i,fontSize:m}};return c.createElement(o,{sx:y.text},r)},k=["form","name","label","selectionWidth","pickerWidth","selectionTextColor","paddingY","paddingX","required","disabled"],C=function(e){var t=e.form,r=e.name,n=void 0===r?"color":r,u=e.label,f=void 0===u?"Επιλογή Χρώματος":u,v=e.selectionWidth,h=void 0===v?70:v,p=e.pickerWidth,b=void 0===p?350:p,x=e.selectionTextColor,w=void 0===x?"white":x,E=e.paddingY,O=void 0===E?"10px":E,L=e.paddingX,T=void 0===L?"10px":L,S=e.required,q=void 0!==S&&S,C=e.disabled,B=void 0!==C&&C,P=g(e,k),_=y(c.useState(null),2),A=_[0],F=_[1],I=Boolean(A),W=I?"color-picker":void 0,G=t.control;return c.createElement(d,{name:n,control:G,rules:{disabled:B},render:function(e){var t=e.field,r=t.onChange;t.onBlur;var n=t.value;return c.createElement(i,m({gap:1},P),c.createElement(o,null,"".concat(f," ").concat(q?"*":"")),c.createElement(a,{sx:{display:"flex"}},c.createElement(a,{"aria-describedby":W,sx:{cursor:"pointer"},onClick:function(e){return F(e.currentTarget)}},c.createElement(j,{color:w,backgroundColor:n,paddingY:O,paddingX:T,width:h,label:n}))),c.createElement(l,{sx:{marginTop:"10px"},id:W,open:I,anchorEl:A,onClose:function(){return F(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"}},c.createElement(a,null,c.createElement(s,{width:b,color:n,onChange:function(e){return r(e.hex)}}))))}})},B=["form","name","label","required","disabled","options","valueKey","labelKey","maxLength","autofocus","noOptionsText"],P=function(t){var r=t.form,n=t.name,o=t.label,i=t.required,a=void 0!==i&&i,l=t.disabled,s=void 0!==l&&l,f=t.options,v=void 0===f?[]:f,h=t.valueKey,p=void 0===h?"id":h;t.labelKey;var b=t.maxLength,x=void 0===b?255:b,w=t.autofocus,E=void 0!==w&&w,O=t.noOptionsText,L=void 0===O?"Δεν υπάρχουν επιλογές":O,T=g(t,B),S=y(c.useState(null),2),q=S[0],j=S[1],k=r.watch(n);c.useEffect((function(){j(v.find((function(e){return e[p]===k}))||null)}),[k]);var C=r.control,P=r.formState.errors;return c.createElement(d,{name:n,control:C,rules:{required:a,disabled:s},render:function(t){var r=t.field,i=r.onChange,l=r.onBlur;return r.value,c.createElement(u,{value:q,required:a,onChange:function(e,t){return i(t?t[p]:null)},options:v,isOptionEqualToValue:function(e,t){return e[p]===t[p]},noOptionsText:L,renderInput:function(t){var r,i;return c.createElement(e,m({label:o,required:a,disabled:s,autoFocus:E,inputProps:{maxLength:x},error:Boolean(null===(r=P[n])||void 0===r?void 0:r.message),onBlur:l,variant:"outlined",fullWidth:!0,helperText:null===(i=P[n])||void 0===i?void 0:i.message},t,T))}})}})},_=["form","name","label","optionsUrl","renderOption","valueKey","labelKey","minChars","required","disabled","maxLength","autofocus","loadingText","noOptionsText","placeholder","size"],A=function(t){var r=t.form,n=t.name,o=t.label,i=t.optionsUrl,a=t.renderOption,l=void 0===a?null:a,s=t.valueKey,h=void 0===s?"id":s,b=t.labelKey,x=void 0===b?"label":b,w=t.minChars,E=void 0===w?2:w,O=t.required,L=void 0!==O&&O,T=t.disabled,S=void 0!==T&&T,q=t.maxLength,j=void 0===q?255:q,k=t.autofocus,C=void 0!==k&&k,B=t.loadingText,P=void 0===B?"Ανάκτηση...":B,A=t.noOptionsText,F=void 0===A?"Δεν υπάρχουν επιλογές":A,I=t.placeholder,W=void 0===I?"":I,G=t.size,K=void 0===G?"medium":G,N=g(t,_),z=y(c.useState(null),2),Y=z[0],V=z[1],X=y(c.useState([]),2),U=X[0],R=X[1],M=y(c.useState(!1),2),$=M[0],D=M[1],H=y(c.useState(""),2),J=H[0],Q=H[1],Z=r.watch(n),ee=r.control,te=r.formState;r.setValue,r.getValues;var re=te.errors;c.useState((function(){if(console.log(U.length,Z),0===U.length&&Z){var e=function(){var e=p(v().mark((function e(){var t;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return D(!0),e.next=3,f.get("".concat(i,"?id=").concat(Z));case 3:t=e.sent,R(t.data),V(t.data.find((function(e){return e[h]===Z}))||null),D(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}}),[]),c.useEffect((function(){V(U.find((function(e){return e[h]===Z}))||null)}),[Z]),c.useEffect((function(){oe()}),[J]);var ne=function(e,t){Q(t)},oe=function(){var e=p(v().mark((function e(){var t;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(J.length<E)){e.next=4;break}return R([]),D(!1),e.abrupt("return");case 4:return D(!0),e.next=7,f.get("".concat(i,"?token=").concat(J));case 7:t=e.sent,R(t.data),D(!1);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return c.createElement(d,{name:n,control:ee,rules:{required:L,disabled:S},render:function(t){var r,i,a,d=t.field,s=d.onChange,f=d.onBlur;return d.value,c.createElement(u,{value:Y,options:U,onInputChange:(r=ne,i=300,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];a&&clearTimeout(a),a=setTimeout((function(){r.apply(void 0,t)}),i)}),onChange:function(e,t){return s(t?t[h]:null)},isOptionEqualToValue:function(e,t){return e[h]===t[h]},getOptionLabel:function(e){return e[x]},filterOptions:function(e){return e},noOptionsText:F,loadingText:P,loading:$,required:L,size:K,renderInput:function(t){var r,i;return c.createElement(e,m({label:o,required:L,disabled:S,autoFocus:C,placeholder:W,inputProps:{maxLength:j},error:Boolean(null===(r=re[n])||void 0===r?void 0:r.message),onBlur:f,variant:"outlined",fullWidth:!0,helperText:null===(i=re[n])||void 0===i?void 0:i.message,size:K},t,N))},renderOption:function(e,t,r){return l?l(e,t,r):c.createElement("li",m({},e,{key:t[h]}),t[x])}})}})};export{A as MyAutocompleteApiField,P as MyAutocompleteField,C as MyColorPickerField,T as MyEmailField,O as MyPasswordField,q as MySwitchField,w as MyTextField};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artibet/react-mui-components",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "description": "Various react components build with mui library",
5
5
  "main": "./core/index.js",
6
6
  "scripts": {