@artibet/react-mui-components 2.15.4 → 2.16.1

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 r,FormControlLabel as t,Switch as n,Typography as o,Stack as a,Box as i,Popover as l,Autocomplete as u,Chip as d,InputAdornment as c,IconButton as s,FormControl as f,FormLabel as v,RadioGroup as m,Radio as h}from"@mui/material";import p from"react";import{Controller as g}from"react-hook-form";import{ChromePicker as b}from"react-color";import"date-fns";import"date-fns/locale";import y from"axios";import x from"react-number-format";import{AdapterDateFns as E}from"@mui/x-date-pickers/AdapterDateFns";import{LocalizationProvider as w}from"@mui/x-date-pickers/LocalizationProvider";import{DateTimePicker as q,DatePicker as O,TimePicker as L}from"@mui/x-date-pickers";import C from"date-fns/locale/el";import{Clear as S}from"@mui/icons-material";function T(){T=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function d(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{d({},"")}catch(e){d=function(e,r,t){return e[r]=t}}function c(e,r,t,n){var a=r&&r.prototype instanceof g?r:g,i=Object.create(a.prototype),l=new j(n||[]);return o(i,"_invoke",{value:C(e,t,l)}),i}function s(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=c;var f="suspendedStart",v="suspendedYield",m="executing",h="completed",p={};function g(){}function b(){}function y(){}var x={};d(x,i,(function(){return this}));var E=Object.getPrototypeOf,w=E&&E(E(P([])));w&&w!==t&&n.call(w,i)&&(x=w);var q=y.prototype=g.prototype=Object.create(x);function O(e){["next","throw","return"].forEach((function(r){d(e,r,(function(e){return this._invoke(r,e)}))}))}function L(e,r){function t(o,a,i,l){var u=s(e[o],e,a);if("throw"!==u.type){var d=u.arg,c=d.value;return c&&"object"==typeof c&&n.call(c,"__await")?r.resolve(c.__await).then((function(e){t("next",e,i,l)}),(function(e){t("throw",e,i,l)})):r.resolve(c).then((function(e){d.value=e,i(d)}),(function(e){return t("throw",e,i,l)}))}l(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return a=a?a.then(o,o):o()}})}function C(r,t,n){var o=f;return function(a,i){if(o===m)throw new Error("Generator is already running");if(o===h){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var l=n.delegate;if(l){var u=S(l,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=m;var d=s(r,t,n);if("normal"===d.type){if(o=n.done?h:v,d.arg===p)continue;return{value:d.arg,done:n.done}}"throw"===d.type&&(o=h,n.method="throw",n.arg=d.arg)}}}function S(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,S(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var a=s(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,p;var i=a.arg;return i?i.done?(t[r.resultName]=i.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,p):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function B(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function k(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(B,this),this.reset(!0)}function P(r){if(r||""===r){var t=r[i];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return a.next=a}}throw new TypeError(typeof r+" is not iterable")}return b.prototype=y,o(q,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:b,configurable:!0}),b.displayName=d(y,u,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,d(e,u,"GeneratorFunction")),e.prototype=Object.create(q),e},r.awrap=function(e){return{__await:e}},O(L.prototype),d(L.prototype,l,(function(){return this})),r.AsyncIterator=L,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new L(c(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(q),d(q,u,"Generator"),d(q,i,(function(){return this})),d(q,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=P,j.prototype={constructor:j,reset:function(r){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(k),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return l.type="throw",l.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],l=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),d=n.call(i,"finallyLoc");if(u&&d){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!d)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(i)},complete:function(e,r){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&&r&&(this.next=r),p},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),k(t),p}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;k(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:P(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),p}},r}function B(e,r,t,n,o,a,i){try{var l=e[a](i),u=l.value}catch(e){return void t(e)}l.done?r(u):Promise.resolve(u).then(n,o)}function k(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){B(a,n,o,i,l,"next",e)}function l(e){B(a,n,o,i,l,"throw",e)}i(void 0)}))}}function j(){return j=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},j.apply(this,arguments)}function P(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function F(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,l=[],u=!0,d=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=a.call(t)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(e){d=!0,o=e}finally{try{if(!u&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(d)throw o}}return l}}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return V(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return V(e,r)}(e,r)||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 V(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var I=["form","name","label","maxLength","required","disabled","autofocus"],W=function(r){var t=r.form,n=r.name,o=r.label,a=r.maxLength,i=void 0===a?255:a,l=r.required,u=void 0!==l&&l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,I),m=t.control,h=t.formState.errors;return p.createElement(g,{name:n,control:m,rules:{required:u,disabled:c},render:function(r){var t,a,l=r.field,d=l.onChange,s=l.onBlur,m=l.value;return p.createElement(e,j({required:u,label:o,value:m,onChange:d,onBlur:s,error:Boolean(null===(t=h[n])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(a=h[n])||void 0===a?void 0:a.message,variant:"outlined",disabled:c,autoFocus:f,inputProps:{maxLength:i}},v))}})},A=["form","name","label","required","disabled","autofocus"],_=function(r){var t=r.form,n=r.name,o=void 0===n?"password":n,a=r.label,i=void 0===a?"Κωδικός Πρόσβασης":a,l=r.required,u=void 0===l||l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,A),m=t.control,h=t.formState.errors;return p.createElement(g,{name:o,control:m,rules:{required:u,disabled:c},render:function(r){var t,n,a=r.field,l=a.onChange,d=a.onBlur,s=a.value;return p.createElement(e,j({required:u,label:i,value:s,onChange:l,onBlur:d,error:Boolean(null===(t=h[o])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(n=h[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:c,autoFocus:f,type:"password"},v))}})},K=["form","name","label","required","disabled","autofocus"],N=function(r){var t=r.form,n=r.name,o=void 0===n?"email":n,a=r.label,i=void 0===a?"E-mail":a,l=r.required,u=void 0===l||l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,K),m=t.control,h=t.formState.errors;return p.createElement(g,{name:o,control:m,rules:{required:u,disabled:c},render:function(r){var t,n,a=r.field,l=a.onChange,d=a.onBlur,s=a.value;return p.createElement(e,j({required:u,label:i,value:s,onChange:l,onBlur:d,error:Boolean(null===(t=h[o])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(n=h[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:c,autoFocus:f},v))}})},z=["form","name","label","disabled"],G=function(e){var o=e.form,a=e.name,i=e.label,l=e.disabled,u=void 0!==l&&l,d=P(e,z),c=o.control;return p.createElement(g,{name:a,control:c,rules:{disabled:u},render:function(e){var l=e.field;l.onChange,l.onBlur;var u=l.value;return p.createElement(r,d,p.createElement(t,{control:p.createElement(n,{checked:Boolean(u),onChange:function(e){return o.setValue(a,e.target.checked)},inputProps:{"aria-label":i}}),label:i}))}})},Y=function(e){var r=e.label,t=void 0===r?"":r,n=e.color,a=void 0===n?"white":n,i=e.backgroundColor,l=void 0===i?"#888888":i,u=e.paddingX,d=void 0===u?"10px":u,c=e.paddingY,s=void 0===c?"5px":c,f=e.borderRadius,v=void 0===f?"10px":f,m=e.fontSize,h=void 0===m?"14px":m,g=e.width,b={text:{display:"inline-block",textAlign:"center",backgroundColor:l,paddingX:d,paddingY:s,borderRadius:v,width:void 0===g?"auto":g,color:a,fontSize:h}};return p.createElement(o,{sx:b.text},t)},M=["form","name","label","selectionWidth","pickerWidth","selectionTextColor","paddingY","paddingX","required","disabled"],R=function(e){var r=e.form,t=e.name,n=void 0===t?"color":t,u=e.label,d=void 0===u?"Επιλογή Χρώματος":u,c=e.selectionWidth,s=void 0===c?70:c,f=e.pickerWidth,v=void 0===f?350:f,m=e.selectionTextColor,h=void 0===m?"white":m,y=e.paddingY,x=void 0===y?"10px":y,E=e.paddingX,w=void 0===E?"10px":E,q=e.required,O=void 0!==q&&q,L=e.disabled,C=void 0!==L&&L,S=P(e,M),T=F(p.useState(null),2),B=T[0],k=T[1],V=Boolean(B),I=V?"color-picker":void 0,W=r.control;return p.createElement(g,{name:n,control:W,rules:{disabled:C},render:function(e){var r=e.field,t=r.onChange;r.onBlur;var n=r.value;return p.createElement(a,j({gap:1},S),p.createElement(o,null,"".concat(d," ").concat(O?"*":"")),p.createElement(i,{sx:{display:"flex"}},p.createElement(i,{"aria-describedby":I,sx:{cursor:"pointer"},onClick:function(e){return k(e.currentTarget)}},p.createElement(Y,{color:h,backgroundColor:n,paddingY:x,paddingX:w,width:s,label:n}))),p.createElement(l,{sx:{marginTop:"10px"},id:I,open:V,anchorEl:B,onClose:function(){return k(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"}},p.createElement(i,null,p.createElement(b,{width:v,color:n,onChange:function(e){return t(e.hex)}}))))}})},X=["form","name","label","required","disabled","options","valueKey","labelKey","maxLength","autofocus","noOptionsText"],D=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,d=void 0!==l&&l,c=r.options,s=void 0===c?[]:c,f=r.valueKey,v=void 0===f?"id":f,m=r.labelKey,h=void 0===m?"label":m,b=r.maxLength,y=void 0===b?255:b,x=r.autofocus,E=void 0!==x&&x,w=r.noOptionsText,q=void 0===w?"Δεν υπάρχουν επιλογές":w,O=P(r,X),L=F(p.useState(null),2),C=L[0],S=L[1],T=t.watch(n);p.useEffect((function(){S(s.find((function(e){return e[v]===T}))||null)}),[T]);var B=t.control,k=t.formState.errors;return p.createElement(g,{name:n,control:B,rules:{required:i,disabled:d},render:function(r){var t=r.field,a=t.onChange,l=t.onBlur;return t.value,p.createElement(u,{value:C,required:i,onChange:function(e,r){return a(r?r[v]:null)},options:s,isOptionEqualToValue:function(e,r){return e[v]===r[v]},noOptionsText:q,getOptionLabel:function(e){return e[h]},renderInput:function(r){var t,a;return p.createElement(e,j({label:o,required:i,disabled:d,autoFocus:E,inputProps:{maxLength:y},error:Boolean(null===(t=k[n])||void 0===t?void 0:t.message),onBlur:l,variant:"outlined",fullWidth:!0,helperText:null===(a=k[n])||void 0===a?void 0:a.message},r,O))}})}})},H=["form","name","label","required","disabled","options","valueKey","labelKey","maxLength","autofocus","noOptionsText"],U=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,c=void 0!==l&&l,s=r.options,f=void 0===s?[]:s,v=r.valueKey,m=void 0===v?"id":v,h=r.labelKey,b=void 0===h?"label":h,y=r.maxLength,x=void 0===y?255:y,E=r.autofocus,w=void 0!==E&&E,q=r.noOptionsText,O=void 0===q?"Δεν υπάρχουν επιλογές":q,L=P(r,H),C=F(p.useState([]),2),S=C[0],T=C[1],B=t.watch(n);p.useEffect((function(){T(f.filter((function(e){return function(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"id";return Boolean(r.find((function(r){return r[t]===e[t]})))}(e,B)})))}),[B]);var k=t.control,V=t.formState.errors;return p.createElement(g,{name:n,control:k,rules:{required:i,disabled:c},render:function(r){var t=r.field,a=t.onChange,l=t.onBlur;return t.value,p.createElement(u,{multiple:!0,value:S,required:i,onChange:function(e,r){return a(r)},options:f,isOptionEqualToValue:function(e,r){return e[m]===r[m]},noOptionsText:O,renderTags:function(e,r){return e.map((function(e,t){return p.createElement(d,j({variant:"outlined",label:e[b],size:"small"},r({index:t})))}))},renderInput:function(r){var t,a;return p.createElement(e,j({label:o,required:i,disabled:c,autoFocus:w,inputProps:{maxLength:x},error:Boolean(null===(t=V[n])||void 0===t?void 0:t.message),onBlur:l,variant:"outlined",fullWidth:!0,helperText:null===(a=V[n])||void 0===a?void 0:a.message},r,L))}})}})},$=["form","name","label","optionsUrl","renderOption","valueKey","labelKey","minChars","required","disabled","maxLength","autofocus","loadingText","noOptionsText","placeholder","size"],J=function(r){var t,n=r.form,o=r.name,a=r.label,i=r.optionsUrl,l=r.renderOption,d=void 0===l?null:l,c=r.valueKey,s=void 0===c?"id":c,f=r.labelKey,v=void 0===f?"label":f,m=r.minChars,h=void 0===m?2:m,b=r.required,x=void 0!==b&&b,E=r.disabled,w=void 0!==E&&E,q=r.maxLength,O=void 0===q?255:q,L=r.autofocus,C=void 0!==L&&L,S=r.loadingText,B=void 0===S?"Ανάκτηση...":S,V=r.noOptionsText,I=void 0===V?"Δεν υπάρχουν επιλογές":V,W=r.placeholder,A=void 0===W?"":W,_=r.size,K=void 0===_?"medium":_,N=P(r,$),z=F(p.useState(null),2),G=z[0],Y=z[1],M=F(p.useState([]),2),R=M[0],X=M[1],D=F(p.useState(!1),2),H=D[0],U=D[1],J=F(p.useState(""),2),Q=J[0],Z=J[1],ee=n.watch(o),re=n.control,te=n.formState;n.setValue,n.getValues;var ne=te.errors;p.useState((function(){if(0===R.length&&ee){var e;!function(){(e=e||k(T().mark((function e(){var r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return U(!0),e.next=3,y.get("".concat(i,"?id=").concat(ee));case 3:r=e.sent,X(r.data),Y(r.data.find((function(e){return e[s]===ee}))||null),U(!1);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}()}}),[]),p.useEffect((function(){Y(R.find((function(e){return e[s]===ee}))||null)}),[ee]),p.useEffect((function(){ae()}),[Q]);var oe=function(e,r){Z(r)},ae=function(){return(t=t||k(T().mark((function e(){var r;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Q.length<h)){e.next=4;break}return X([]),U(!1),e.abrupt("return");case 4:return U(!0),e.next=7,y.get("".concat(i,"?token=").concat(Q));case 7:r=e.sent,X(r.data),U(!1);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)};return p.createElement(g,{name:o,control:re,rules:{required:x,disabled:w},render:function(r){var t,n,i,l=r.field,c=l.onChange,f=l.onBlur;return l.value,p.createElement(u,{value:G,options:R,onInputChange:(t=oe,n=300,function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];i&&clearTimeout(i),i=setTimeout((function(){t.apply(void 0,r)}),n)}),onChange:function(e,r){return c(r?r[s]:null)},isOptionEqualToValue:function(e,r){return e[s]===r[s]},getOptionLabel:function(e){return e[v]},filterOptions:function(e){return e},noOptionsText:I,loadingText:B,loading:H,required:x,size:K,renderInput:function(r){var t,n;return p.createElement(e,j({label:a,required:x,disabled:w,autoFocus:C,placeholder:A,inputProps:{maxLength:O},error:Boolean(null===(t=ne[o])||void 0===t?void 0:t.message),onBlur:f,variant:"outlined",fullWidth:!0,helperText:null===(n=ne[o])||void 0===n?void 0:n.message,size:K},r,N))},renderOption:function(e,r,t){return d?d(e,r,t):p.createElement("li",j({},e,{key:r[s]}),r[v])}})}})},Q=["form","name","label","rows","required","disabled","autofocus"],Z=function(r){var t=r.form,n=r.name,o=r.label,a=r.rows,i=void 0===a?5:a,l=r.required,u=void 0!==l&&l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,Q),m=t.control,h=t.formState.errors;return p.createElement(g,{name:n,control:m,rules:{required:u,disabled:c},render:function(r){var t,a,l=r.field,d=l.onChange,s=l.onBlur,m=l.value;return p.createElement(e,j({required:u,label:o,value:m,multiline:!0,minRows:i,maxRows:i,onChange:d,onBlur:s,error:Boolean(null===(t=h[n])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(a=h[n])||void 0===a?void 0:a.message,variant:"outlined",disabled:c,autoFocus:f},v))}})},ee=["form","name","label","required","disabled","autofocus"],re=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l;r.autofocus;var d=P(r,ee),c=t.control,s=t.formState.errors,f=function(e,r){""===e.value?t.setValue(n,null):t.setValue(n,e.floatValue)};return p.createElement(g,{name:n,control:c,rules:{required:i,disabled:u},render:function(r){var t,a,l=r.field;l.onChange,l.onBlur;var c=l.value;return p.createElement(x,j({customInput:e,variant:"outlined",label:o,required:i,disabled:u,value:c,thousandSeparator:".",decimalSeparator:",",decimalScale:2,fixedDecimalScale:!0,allowNegative:!1,onValueChange:f,error:Boolean(null===(t=s[n])||void 0===t?void 0:t.message),helperText:null===(a=s[n])||void 0===a?void 0:a.message,fullWidth:!0},d))}})},te=["form","name","label","required","disabled","autofocus"],ne=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l;r.autofocus;var d=P(r,te),c=t.control,s=t.formState.errors;return p.createElement(g,{name:n,control:c,rules:{required:i,disabled:u},render:function(r){var t=r.field,a=t.onChange;t.onBlur;var l=t.value;return p.createElement(w,{dateAdapter:E,adapterLocale:C},p.createElement(q,{label:o,inputFormat:"dd/MM/yyyy HH:mm",value:l,onChange:a,disabled:u,renderInput:function(r){var t,o;return p.createElement(e,j({},r,{required:i,error:Boolean(null===(t=s[n])||void 0===t?void 0:t.message),helperText:null===(o=s[n])||void 0===o?void 0:o.message,variant:"outlined",fullWidth:!0},d))}}))}})},oe=["form","name","label","required","disabled","autofocus"],ae=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l;r.autofocus;var d=P(r,oe),c=t.control,s=t.formState.errors;return p.createElement(g,{name:n,control:c,rules:{required:i,disabled:u},render:function(r){var t=r.field,a=t.onChange;t.onBlur;var l=t.value;return p.createElement(w,{dateAdapter:E,adapterLocale:C},p.createElement(O,{label:o,inputFormat:"dd/MM/yyyy",value:l,onChange:a,disabled:u,renderInput:function(r){var t,o;return p.createElement(e,j({},r,{required:i,error:Boolean(null===(t=s[n])||void 0===t?void 0:t.message),helperText:null===(o=s[n])||void 0===o?void 0:o.message,variant:"outlined",fullWidth:!0},d))}}))}})},ie=["form","name","label","allowNegative","required","disabled","autofocus"],le=function(r){var t=r.form,n=r.name,o=r.label,a=r.allowNegative,i=void 0!==a&&a,l=r.required,u=void 0!==l&&l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,ie),m=t.control,h=t.formState.errors,b=function(e,r){""===e.value?t.setValue(n,null):t.setValue(n,e.floatValue)};return p.createElement(g,{name:n,control:m,rules:{required:u,disabled:c},render:function(r){var t,a,l=r.field;l.onChange,l.onBlur;var d=l.value;return p.createElement(x,j({customInput:e,variant:"outlined",label:o,required:u,disabled:c,value:d,thousandSeparator:!1,decimalSeparator:",",decimalScale:0,fixedDecimalScale:!0,allowNegative:i,onValueChange:b,error:Boolean(null===(t=h[n])||void 0===t?void 0:t.message),helperText:null===(a=h[n])||void 0===a?void 0:a.message,fullWidth:!0,autoFocus:f},v))}})},ue=["form","name","label","required","disabled"],de=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l,d=P(r,ue),f=F(p.useState(),2),v=f[0],m=f[1],h=p.useRef(null),b=t.control,y=t.formState.errors,x=function(){h.current.value=null,h.current.click()};return p.createElement(p.Fragment,null,p.createElement(g,{name:n,control:b,rules:{required:i,disabled:u},render:function(r){var a,l,f=r.field;return f.onChange,f.onBlur,f.value,p.createElement(e,j({sx:{input:{cursor:"pointer"}},onClick:x,required:i,label:o,value:v?v.name:"",error:Boolean(null===(a=y[n])||void 0===a?void 0:a.message),fullWidth:!0,helperText:null===(l=y[n])||void 0===l?void 0:l.message,variant:"outlined",disabled:u,InputProps:{endAdornment:v&&p.createElement(c,{position:"end"},p.createElement(s,{onClick:function(e){return function(e){e.stopPropagation(),m(null),t.setValue(n,null)}(e)}},p.createElement(S,null))),readOnly:!0}},d))}}),p.createElement("input",{type:"file",ref:h,style:{display:"none"},onChange:function(e){return function(e){m(e),t.setValue(n,e,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})}(e.currentTarget.files[0])}}))},ce=["form","name","label","required","disabled","autofocus"],se=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l;r.autofocus;var d=P(r,ce),c=t.control,s=t.formState.errors;return p.createElement(g,{name:n,control:c,rules:{required:i,disabled:u},render:function(r){var t=r.field,a=t.onChange;t.onBlur;var l=t.value;return p.createElement(w,{dateAdapter:E,adapterLocale:C},p.createElement(L,{label:o,inputFormat:"HH:mm",value:l,onChange:a,disabled:u,renderInput:function(r){var t,o;return p.createElement(e,j({},r,{required:i,error:Boolean(null===(t=s[n])||void 0===t?void 0:t.message),helperText:null===(o=s[n])||void 0===o?void 0:o.message,variant:"outlined",fullWidth:!0},d))}}))}})},fe=["form","name","label","options","disabled","direction"],ve=function(e){var r=e.form,n=e.name,o=e.label,a=e.options,i=e.disabled,l=void 0!==i&&i,u=e.direction,d=void 0===u?"vertical":u,c=P(e,fe),s=r.control;return p.createElement(g,{name:n,control:s,rules:{disabled:l},render:function(e){var i=e.field;i.onChange,i.onBlur;var l=i.value;return p.createElement(f,c,p.createElement(v,null,o),p.createElement(m,{row:"horizontal"===d,value:l,onChange:function(e){return r.setValue(n,e.target.value)}},a.map((function(e){return p.createElement(t,{key:e.id,value:e.id,control:p.createElement(h,null),label:e.label})}))))}})};export{J as MyAutocompleteApiField,D as MyAutocompleteField,U as MyAutocompleteMultiField,R as MyColorPickerField,re as MyCurrencyField,ae as MyDateField,ne as MyDatetimeField,N as MyEmailField,le as MyIntegerField,Z as MyNotesField,_ as MyPasswordField,ve as MyRadioField,G as MySwitchField,W as MyTextField,se as MyTimeField,de as MyUploadField};
1
+ import{TextField as e,FormGroup as r,FormControlLabel as t,Switch as n,Typography as o,Stack as a,Box as i,Popover as l,Autocomplete as u,Chip as d,InputAdornment as c,IconButton as s,FormControl as f,FormLabel as v,RadioGroup as m,Radio as h,Checkbox as p}from"@mui/material";import g from"react";import{Controller as b}from"react-hook-form";import{ChromePicker as y}from"react-color";import"date-fns";import"date-fns/locale";import x from"axios";import E from"react-number-format";import{AdapterDateFns as w}from"@mui/x-date-pickers/AdapterDateFns";import{LocalizationProvider as q}from"@mui/x-date-pickers/LocalizationProvider";import{DateTimePicker as O,DatePicker as C,TimePicker as L}from"@mui/x-date-pickers";import S from"date-fns/locale/el";import{Clear as T}from"@mui/icons-material";function B(){B=function(){return r};var e,r={},t=Object.prototype,n=t.hasOwnProperty,o=Object.defineProperty||function(e,r,t){e[r]=t.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function d(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{d({},"")}catch(e){d=function(e,r,t){return e[r]=t}}function c(e,r,t,n){var a=r&&r.prototype instanceof g?r:g,i=Object.create(a.prototype),l=new j(n||[]);return o(i,"_invoke",{value:L(e,t,l)}),i}function s(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}r.wrap=c;var f="suspendedStart",v="suspendedYield",m="executing",h="completed",p={};function g(){}function b(){}function y(){}var x={};d(x,i,(function(){return this}));var E=Object.getPrototypeOf,w=E&&E(E(V([])));w&&w!==t&&n.call(w,i)&&(x=w);var q=y.prototype=g.prototype=Object.create(x);function O(e){["next","throw","return"].forEach((function(r){d(e,r,(function(e){return this._invoke(r,e)}))}))}function C(e,r){function t(o,a,i,l){var u=s(e[o],e,a);if("throw"!==u.type){var d=u.arg,c=d.value;return c&&"object"==typeof c&&n.call(c,"__await")?r.resolve(c.__await).then((function(e){t("next",e,i,l)}),(function(e){t("throw",e,i,l)})):r.resolve(c).then((function(e){d.value=e,i(d)}),(function(e){return t("throw",e,i,l)}))}l(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new r((function(r,o){t(e,n,r,o)}))}return a=a?a.then(o,o):o()}})}function L(r,t,n){var o=f;return function(a,i){if(o===m)throw new Error("Generator is already running");if(o===h){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var l=n.delegate;if(l){var u=S(l,n);if(u){if(u===p)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=m;var d=s(r,t,n);if("normal"===d.type){if(o=n.done?h:v,d.arg===p)continue;return{value:d.arg,done:n.done}}"throw"===d.type&&(o=h,n.method="throw",n.arg=d.arg)}}}function S(r,t){var n=t.method,o=r.iterator[n];if(o===e)return t.delegate=null,"throw"===n&&r.iterator.return&&(t.method="return",t.arg=e,S(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var a=s(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,p;var i=a.arg;return i?i.done?(t[r.resultName]=i.value,t.next=r.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,p):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function T(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function k(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function V(r){if(r||""===r){var t=r[i];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function t(){for(;++o<r.length;)if(n.call(r,o))return t.value=r[o],t.done=!1,t;return t.value=e,t.done=!0,t};return a.next=a}}throw new TypeError(typeof r+" is not iterable")}return b.prototype=y,o(q,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:b,configurable:!0}),b.displayName=d(y,u,"GeneratorFunction"),r.isGeneratorFunction=function(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,d(e,u,"GeneratorFunction")),e.prototype=Object.create(q),e},r.awrap=function(e){return{__await:e}},O(C.prototype),d(C.prototype,l,(function(){return this})),r.AsyncIterator=C,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new C(c(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(q),d(q,u,"Generator"),d(q,i,(function(){return this})),d(q,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var r=Object(e),t=[];for(var n in r)t.push(n);return t.reverse(),function e(){for(;t.length;){var n=t.pop();if(n in r)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=V,j.prototype={constructor:j,reset:function(r){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(k),!r)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var t=this;function o(n,o){return l.type="throw",l.arg=r,t.next=n,o&&(t.method="next",t.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],l=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),d=n.call(i,"finallyLoc");if(u&&d){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!d)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var o=this.tryEntries[t];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(i)},complete:function(e,r){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&&r&&(this.next=r),p},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),k(t),p}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;k(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,t,n){return this.delegate={iterator:V(r),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=e),p}},r}function k(e,r,t,n,o,a,i){try{var l=e[a](i),u=l.value}catch(e){return void t(e)}l.done?r(u):Promise.resolve(u).then(n,o)}function j(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){k(a,n,o,i,l,"next",e)}function l(e){k(a,n,o,i,l,"throw",e)}i(void 0)}))}}function V(){return V=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},V.apply(this,arguments)}function P(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function F(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,l=[],u=!0,d=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=a.call(t)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(e){d=!0,o=e}finally{try{if(!u&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(d)throw o}}return l}}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return I(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,r)}(e,r)||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 I(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var W=["form","name","label","maxLength","required","disabled","autofocus"],A=function(r){var t=r.form,n=r.name,o=r.label,a=r.maxLength,i=void 0===a?255:a,l=r.required,u=void 0!==l&&l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,W),m=t.control,h=t.formState.errors;return g.createElement(b,{name:n,control:m,rules:{required:u,disabled:c},render:function(r){var t,a,l=r.field,d=l.onChange,s=l.onBlur,m=l.value;return g.createElement(e,V({required:u,label:o,value:m,onChange:d,onBlur:s,error:Boolean(null===(t=h[n])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(a=h[n])||void 0===a?void 0:a.message,variant:"outlined",disabled:c,autoFocus:f,inputProps:{maxLength:i}},v))}})},_=["form","name","label","required","disabled","autofocus"],K=function(r){var t=r.form,n=r.name,o=void 0===n?"password":n,a=r.label,i=void 0===a?"Κωδικός Πρόσβασης":a,l=r.required,u=void 0===l||l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,_),m=t.control,h=t.formState.errors;return g.createElement(b,{name:o,control:m,rules:{required:u,disabled:c},render:function(r){var t,n,a=r.field,l=a.onChange,d=a.onBlur,s=a.value;return g.createElement(e,V({required:u,label:i,value:s,onChange:l,onBlur:d,error:Boolean(null===(t=h[o])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(n=h[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:c,autoFocus:f,type:"password"},v))}})},N=["form","name","label","required","disabled","autofocus"],z=function(r){var t=r.form,n=r.name,o=void 0===n?"email":n,a=r.label,i=void 0===a?"E-mail":a,l=r.required,u=void 0===l||l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,N),m=t.control,h=t.formState.errors;return g.createElement(b,{name:o,control:m,rules:{required:u,disabled:c},render:function(r){var t,n,a=r.field,l=a.onChange,d=a.onBlur,s=a.value;return g.createElement(e,V({required:u,label:i,value:s,onChange:l,onBlur:d,error:Boolean(null===(t=h[o])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(n=h[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:c,autoFocus:f},v))}})},G=["form","name","label","disabled"],Y=function(e){var o=e.form,a=e.name,i=e.label,l=e.disabled,u=void 0!==l&&l,d=P(e,G),c=o.control;return g.createElement(b,{name:a,control:c,rules:{disabled:u},render:function(e){var l=e.field;l.onChange,l.onBlur;var u=l.value;return g.createElement(r,d,g.createElement(t,{control:g.createElement(n,{checked:Boolean(u),onChange:function(e){return o.setValue(a,e.target.checked)},inputProps:{"aria-label":i}}),label:i}))}})},M=function(e){var r=e.label,t=void 0===r?"":r,n=e.color,a=void 0===n?"white":n,i=e.backgroundColor,l=void 0===i?"#888888":i,u=e.paddingX,d=void 0===u?"10px":u,c=e.paddingY,s=void 0===c?"5px":c,f=e.borderRadius,v=void 0===f?"10px":f,m=e.fontSize,h=void 0===m?"14px":m,p=e.width,b={text:{display:"inline-block",textAlign:"center",backgroundColor:l,paddingX:d,paddingY:s,borderRadius:v,width:void 0===p?"auto":p,color:a,fontSize:h}};return g.createElement(o,{sx:b.text},t)},R=["form","name","label","selectionWidth","pickerWidth","selectionTextColor","paddingY","paddingX","required","disabled"],X=function(e){var r=e.form,t=e.name,n=void 0===t?"color":t,u=e.label,d=void 0===u?"Επιλογή Χρώματος":u,c=e.selectionWidth,s=void 0===c?70:c,f=e.pickerWidth,v=void 0===f?350:f,m=e.selectionTextColor,h=void 0===m?"white":m,p=e.paddingY,x=void 0===p?"10px":p,E=e.paddingX,w=void 0===E?"10px":E,q=e.required,O=void 0!==q&&q,C=e.disabled,L=void 0!==C&&C,S=P(e,R),T=F(g.useState(null),2),B=T[0],k=T[1],j=Boolean(B),I=j?"color-picker":void 0,W=r.control;return g.createElement(b,{name:n,control:W,rules:{disabled:L},render:function(e){var r=e.field,t=r.onChange;r.onBlur;var n=r.value;return g.createElement(a,V({gap:1},S),g.createElement(o,null,"".concat(d," ").concat(O?"*":"")),g.createElement(i,{sx:{display:"flex"}},g.createElement(i,{"aria-describedby":I,sx:{cursor:"pointer"},onClick:function(e){return k(e.currentTarget)}},g.createElement(M,{color:h,backgroundColor:n,paddingY:x,paddingX:w,width:s,label:n}))),g.createElement(l,{sx:{marginTop:"10px"},id:I,open:j,anchorEl:B,onClose:function(){return k(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"}},g.createElement(i,null,g.createElement(y,{width:v,color:n,onChange:function(e){return t(e.hex)}}))))}})},D=["form","name","label","required","disabled","options","valueKey","labelKey","maxLength","autofocus","noOptionsText"],H=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,d=void 0!==l&&l,c=r.options,s=void 0===c?[]:c,f=r.valueKey,v=void 0===f?"id":f,m=r.labelKey,h=void 0===m?"label":m,p=r.maxLength,y=void 0===p?255:p,x=r.autofocus,E=void 0!==x&&x,w=r.noOptionsText,q=void 0===w?"Δεν υπάρχουν επιλογές":w,O=P(r,D),C=F(g.useState(null),2),L=C[0],S=C[1],T=t.watch(n);g.useEffect((function(){S(s.find((function(e){return e[v]===T}))||null)}),[T]);var B=t.control,k=t.formState.errors;return g.createElement(b,{name:n,control:B,rules:{required:i,disabled:d},render:function(r){var t=r.field,a=t.onChange,l=t.onBlur;return t.value,g.createElement(u,{value:L,required:i,onChange:function(e,r){return a(r?r[v]:null)},options:s,isOptionEqualToValue:function(e,r){return e[v]===r[v]},noOptionsText:q,getOptionLabel:function(e){return e[h]},renderInput:function(r){var t,a;return g.createElement(e,V({label:o,required:i,disabled:d,autoFocus:E,inputProps:{maxLength:y},error:Boolean(null===(t=k[n])||void 0===t?void 0:t.message),onBlur:l,variant:"outlined",fullWidth:!0,helperText:null===(a=k[n])||void 0===a?void 0:a.message},r,O))}})}})},U=["form","name","label","required","disabled","options","valueKey","labelKey","maxLength","autofocus","noOptionsText"],$=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,c=void 0!==l&&l,s=r.options,f=void 0===s?[]:s,v=r.valueKey,m=void 0===v?"id":v,h=r.labelKey,p=void 0===h?"label":h,y=r.maxLength,x=void 0===y?255:y,E=r.autofocus,w=void 0!==E&&E,q=r.noOptionsText,O=void 0===q?"Δεν υπάρχουν επιλογές":q,C=P(r,U),L=F(g.useState([]),2),S=L[0],T=L[1],B=t.watch(n);g.useEffect((function(){T(f.filter((function(e){return function(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"id";return Boolean(r.find((function(r){return r[t]===e[t]})))}(e,B)})))}),[B]);var k=t.control,j=t.formState.errors;return g.createElement(b,{name:n,control:k,rules:{required:i,disabled:c},render:function(r){var t=r.field,a=t.onChange,l=t.onBlur;return t.value,g.createElement(u,{multiple:!0,value:S,required:i,onChange:function(e,r){return a(r)},options:f,isOptionEqualToValue:function(e,r){return e[m]===r[m]},noOptionsText:O,renderTags:function(e,r){return e.map((function(e,t){return g.createElement(d,V({variant:"outlined",label:e[p],size:"small"},r({index:t})))}))},renderInput:function(r){var t,a;return g.createElement(e,V({label:o,required:i,disabled:c,autoFocus:w,inputProps:{maxLength:x},error:Boolean(null===(t=j[n])||void 0===t?void 0:t.message),onBlur:l,variant:"outlined",fullWidth:!0,helperText:null===(a=j[n])||void 0===a?void 0:a.message},r,C))}})}})},J=["form","name","label","optionsUrl","renderOption","valueKey","labelKey","minChars","required","disabled","maxLength","autofocus","loadingText","noOptionsText","placeholder","size","onChange"],Q=function(r){var t,n=r.form,o=r.name,a=r.label,i=r.optionsUrl,l=r.renderOption,d=void 0===l?null:l,c=r.valueKey,s=void 0===c?"id":c,f=r.labelKey,v=void 0===f?"label":f,m=r.minChars,h=void 0===m?2:m,p=r.required,y=void 0!==p&&p,E=r.disabled,w=void 0!==E&&E,q=r.maxLength,O=void 0===q?255:q,C=r.autofocus,L=void 0!==C&&C,S=r.loadingText,T=void 0===S?"Ανάκτηση...":S,k=r.noOptionsText,I=void 0===k?"Δεν υπάρχουν επιλογές":k,W=r.placeholder,A=void 0===W?"":W,_=r.size,K=void 0===_?"medium":_,N=r.onChange,z=void 0===N?null:N,G=P(r,J),Y=F(g.useState(null),2),M=Y[0],R=Y[1],X=F(g.useState([]),2),D=X[0],H=X[1],U=F(g.useState(!1),2),$=U[0],Q=U[1],Z=F(g.useState(""),2),ee=Z[0],re=Z[1],te=n.control,ne=n.formState.errors;n.watch(o),g.useState((function(){if(n.getValues(o)){var e;!function(){(e=e||j(B().mark((function e(){var r;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Q(!0),e.next=3,x.get("".concat(i,"?id=").concat(n.getValues(o)));case 3:r=e.sent,H(r.data),R(r.data.find((function(e){return e[s]===n.getValues(o)}))||null),Q(!1);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}()}}),[]);var oe=function(e,r){re(r),M&&M.label!==r&&(n.setValue(o,null),R(null)),ae()},ae=function(){return(t=t||j(B().mark((function e(){var r,t;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.getValues(o)){e.next=9;break}return Q(!0),e.next=4,x.get("".concat(i,"?id=").concat(n.getValues(o)));case 4:r=e.sent,H(r.data),Q(!1),e.next=16;break;case 9:if(!(ee.length>=h)){e.next=16;break}return Q(!0),e.next=13,x.get("".concat(i,"?token=").concat(ee));case 13:t=e.sent,H(t.data),Q(!1);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)};return g.createElement(b,{name:o,control:te,rules:{required:y,disabled:w},render:function(r){var t,n,i,l=r.field,c=l.onChange,f=l.onBlur;return l.value,g.createElement(u,{value:M,options:D,onInputChange:(t=oe,n=300,function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];i&&clearTimeout(i),i=setTimeout((function(){t.apply(void 0,r)}),n)}),onChange:function(e,r){R(r),c(r?r[s]:null),z&&z(r?r[s]:null)},isOptionEqualToValue:function(e,r){return e[s]===r[s]},getOptionLabel:function(e){return e[v]},filterOptions:function(e){return e},noOptionsText:I,loadingText:T,loading:$,required:y,size:K,renderInput:function(r){var t,n;return g.createElement(e,V({label:a,required:y,disabled:w,autoFocus:L,placeholder:A,inputProps:{maxLength:O},error:Boolean(null===(t=ne[o])||void 0===t?void 0:t.message),onBlur:f,variant:"outlined",fullWidth:!0,helperText:null===(n=ne[o])||void 0===n?void 0:n.message,size:K},r,G))},renderOption:function(e,r,t){return d?d(e,r,t):g.createElement("li",V({},e,{key:r[s]}),r[v])}})}})},Z=["form","name","label","rows","required","disabled","autofocus"],ee=function(r){var t=r.form,n=r.name,o=r.label,a=r.rows,i=void 0===a?5:a,l=r.required,u=void 0!==l&&l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,Z),m=t.control,h=t.formState.errors;return g.createElement(b,{name:n,control:m,rules:{required:u,disabled:c},render:function(r){var t,a,l=r.field,d=l.onChange,s=l.onBlur,m=l.value;return g.createElement(e,V({required:u,label:o,value:m,multiline:!0,minRows:i,maxRows:i,onChange:d,onBlur:s,error:Boolean(null===(t=h[n])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(a=h[n])||void 0===a?void 0:a.message,variant:"outlined",disabled:c,autoFocus:f},v))}})},re=["form","name","label","required","disabled","autofocus"],te=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l;r.autofocus;var d=P(r,re),c=t.control,s=t.formState.errors,f=function(e,r){""===e.value?t.setValue(n,null):t.setValue(n,e.floatValue)};return g.createElement(b,{name:n,control:c,rules:{required:i,disabled:u},render:function(r){var t,a,l=r.field;l.onChange,l.onBlur;var c=l.value;return g.createElement(E,V({customInput:e,variant:"outlined",label:o,required:i,disabled:u,value:c,thousandSeparator:".",decimalSeparator:",",decimalScale:2,fixedDecimalScale:!0,allowNegative:!1,onValueChange:f,error:Boolean(null===(t=s[n])||void 0===t?void 0:t.message),helperText:null===(a=s[n])||void 0===a?void 0:a.message,fullWidth:!0},d))}})},ne=["form","name","label","required","disabled","autofocus"],oe=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l;r.autofocus;var d=P(r,ne),c=t.control,s=t.formState.errors;return g.createElement(b,{name:n,control:c,rules:{required:i,disabled:u},render:function(r){var t=r.field,a=t.onChange;t.onBlur;var l=t.value;return g.createElement(q,{dateAdapter:w,adapterLocale:S},g.createElement(O,{label:o,inputFormat:"dd/MM/yyyy HH:mm",value:l,onChange:a,disabled:u,renderInput:function(r){var t,o;return g.createElement(e,V({},r,{required:i,error:Boolean(null===(t=s[n])||void 0===t?void 0:t.message),helperText:null===(o=s[n])||void 0===o?void 0:o.message,variant:"outlined",fullWidth:!0},d))}}))}})},ae=["form","name","label","required","disabled","autofocus"],ie=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l;r.autofocus;var d=P(r,ae),c=t.control,s=t.formState.errors;return g.createElement(b,{name:n,control:c,rules:{required:i,disabled:u},render:function(r){var t=r.field,a=t.onChange;t.onBlur;var l=t.value;return g.createElement(q,{dateAdapter:w,adapterLocale:S},g.createElement(C,{label:o,inputFormat:"dd/MM/yyyy",value:l,onChange:a,disabled:u,renderInput:function(r){var t,o;return g.createElement(e,V({},r,{required:i,error:Boolean(null===(t=s[n])||void 0===t?void 0:t.message),helperText:null===(o=s[n])||void 0===o?void 0:o.message,variant:"outlined",fullWidth:!0},d))}}))}})},le=["form","name","label","allowNegative","required","disabled","autofocus"],ue=function(r){var t=r.form,n=r.name,o=r.label,a=r.allowNegative,i=void 0!==a&&a,l=r.required,u=void 0!==l&&l,d=r.disabled,c=void 0!==d&&d,s=r.autofocus,f=void 0!==s&&s,v=P(r,le),m=t.control,h=t.formState.errors,p=function(e,r){""===e.value?t.setValue(n,null):t.setValue(n,e.floatValue)};return g.createElement(b,{name:n,control:m,rules:{required:u,disabled:c},render:function(r){var t,a,l=r.field;l.onChange,l.onBlur;var d=l.value;return g.createElement(E,V({customInput:e,variant:"outlined",label:o,required:u,disabled:c,value:d,thousandSeparator:!1,decimalSeparator:",",decimalScale:0,fixedDecimalScale:!0,allowNegative:i,onValueChange:p,error:Boolean(null===(t=h[n])||void 0===t?void 0:t.message),helperText:null===(a=h[n])||void 0===a?void 0:a.message,fullWidth:!0,autoFocus:f},v))}})},de=["form","name","label","required","disabled"],ce=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l,d=P(r,de),f=F(g.useState(),2),v=f[0],m=f[1],h=g.useRef(null),p=t.control,y=t.formState.errors,x=function(){h.current.value=null,h.current.click()};return g.createElement(g.Fragment,null,g.createElement(b,{name:n,control:p,rules:{required:i,disabled:u},render:function(r){var a,l,f=r.field;return f.onChange,f.onBlur,f.value,g.createElement(e,V({sx:{input:{cursor:"pointer"}},onClick:x,required:i,label:o,value:v?v.name:"",error:Boolean(null===(a=y[n])||void 0===a?void 0:a.message),fullWidth:!0,helperText:null===(l=y[n])||void 0===l?void 0:l.message,variant:"outlined",disabled:u,InputProps:{endAdornment:v&&g.createElement(c,{position:"end"},g.createElement(s,{onClick:function(e){return function(e){e.stopPropagation(),m(null),t.setValue(n,null)}(e)}},g.createElement(T,null))),readOnly:!0}},d))}}),g.createElement("input",{type:"file",ref:h,style:{display:"none"},onChange:function(e){return function(e){m(e),t.setValue(n,e,{shouldValidate:!0,shouldDirty:!0,shouldTouch:!0})}(e.currentTarget.files[0])}}))},se=["form","name","label","required","disabled","autofocus"],fe=function(r){var t=r.form,n=r.name,o=r.label,a=r.required,i=void 0!==a&&a,l=r.disabled,u=void 0!==l&&l;r.autofocus;var d=P(r,se),c=t.control,s=t.formState.errors;return g.createElement(b,{name:n,control:c,rules:{required:i,disabled:u},render:function(r){var t=r.field,a=t.onChange;t.onBlur;var l=t.value;return g.createElement(q,{dateAdapter:w,adapterLocale:S},g.createElement(L,{label:o,inputFormat:"HH:mm",value:l,onChange:a,disabled:u,renderInput:function(r){var t,o;return g.createElement(e,V({},r,{required:i,error:Boolean(null===(t=s[n])||void 0===t?void 0:t.message),helperText:null===(o=s[n])||void 0===o?void 0:o.message,variant:"outlined",fullWidth:!0},d))}}))}})},ve=["form","name","label","options","disabled","direction"],me=function(e){var r=e.form,n=e.name,o=e.label,a=e.options,i=e.disabled,l=void 0!==i&&i,u=e.direction,d=void 0===u?"vertical":u,c=P(e,ve),s=r.control;return g.createElement(b,{name:n,control:s,rules:{disabled:l},render:function(e){var i=e.field;i.onChange,i.onBlur;var l=i.value;return g.createElement(f,c,g.createElement(v,null,o),g.createElement(m,{row:"horizontal"===d,value:l,onChange:function(e){return r.setValue(n,e.target.value)}},a.map((function(e){return g.createElement(t,{key:e.id,value:e.id,control:g.createElement(h,null),label:e.label})}))))}})},he=["form","name","label","disabled"],pe=function(e){var r=e.form,n=e.name,o=e.label,a=e.disabled,i=void 0!==a&&a,l=P(e,he),u=r.control;return g.createElement(b,{name:n,control:u,rules:{disabled:i},render:function(e){var a=e.field;a.onChange,a.onBlur;var u=a.value;return g.createElement(t,V({control:g.createElement(p,{checked:u,onChange:function(e){return r.setValue(n,e.target.checked)},disabled:i}),label:o},l))}})};export{Q as MyAutocompleteApiField,H as MyAutocompleteField,$ as MyAutocompleteMultiField,pe as MyCheckboxField,X as MyColorPickerField,te as MyCurrencyField,ie as MyDateField,oe as MyDatetimeField,z as MyEmailField,ue as MyIntegerField,ee as MyNotesField,K as MyPasswordField,me as MyRadioField,Y as MySwitchField,A as MyTextField,fe as MyTimeField,ce as MyUploadField};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artibet/react-mui-components",
3
- "version": "2.15.4",
3
+ "version": "2.16.1",
4
4
  "description": "Various react components build with mui library",
5
5
  "main": "./core/index.js",
6
6
  "scripts": {