@artibet/react-mui-components 2.4.9 → 2.4.11

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}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";import v from"react-number-format";function h(){h=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 c(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}try{c({},"")}catch(e){c=function(e,r,t){return e[r]=t}}function d(e,r,t,n){var a=r&&r.prototype instanceof y?r:y,i=Object.create(a.prototype),l=new B(n||[]);return o(i,"_invoke",{value:T(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=d;var f="suspendedStart",v="suspendedYield",m="executing",p="completed",g={};function y(){}function b(){}function x(){}var w={};c(w,i,(function(){return this}));var E=Object.getPrototypeOf,O=E&&E(E(P([])));O&&O!==t&&n.call(O,i)&&(w=O);var L=x.prototype=y.prototype=Object.create(w);function q(e){["next","throw","return"].forEach((function(r){c(e,r,(function(e){return this._invoke(r,e)}))}))}function S(e,r){function t(o,a,i,l){var u=s(e[o],e,a);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?r.resolve(d.__await).then((function(e){t("next",e,i,l)}),(function(e){t("throw",e,i,l)})):r.resolve(d).then((function(e){c.value=e,i(c)}),(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 T(r,t,n){var o=f;return function(a,i){if(o===m)throw new Error("Generator is already running");if(o===p){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=C(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=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=m;var c=s(r,t,n);if("normal"===c.type){if(o=n.done?p:v,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=p,n.method="throw",n.arg=c.arg)}}}function C(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,C(r,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=s(o,r.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,g;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,g):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g)}function j(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 B(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,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=x,o(L,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:b,configurable:!0}),b.displayName=c(x,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,x):(e.__proto__=x,c(e,u,"GeneratorFunction")),e.prototype=Object.create(L),e},r.awrap=function(e){return{__await:e}},q(S.prototype),c(S.prototype,l,(function(){return this})),r.AsyncIterator=S,r.async=function(e,t,n,o,a){void 0===a&&(a=Promise);var i=new S(d(e,t,n,o),a);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},q(L),c(L,u,"Generator"),c(L,i,(function(){return this})),c(L,"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,B.prototype={constructor:B,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"),c=n.call(i,"finallyLoc");if(u&&c){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(!c)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,g):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),g},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),g}},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),g}},r}function m(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 p(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function i(e){m(a,n,o,i,l,"next",e)}function l(e){m(a,n,o,i,l,"throw",e)}i(void 0)}))}}function g(){return g=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},g.apply(this,arguments)}function y(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 b(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,c=!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){c=!0,o=e}finally{try{if(!u&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return x(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 x(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 x(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"],E=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,s=r.disabled,f=void 0!==s&&s,v=r.autofocus,h=void 0!==v&&v,m=y(r,w),p=t.control,b=t.formState.errors;return c.createElement(d,{name:n,control:p,rules:{required:u,disabled:f},render:function(r){var t,a,l=r.field,d=l.onChange,s=l.onBlur,v=l.value;return c.createElement(e,g({required:u,label:o,value:v,onChange:d,onBlur:s,error:Boolean(null===(t=b[n])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(a=b[n])||void 0===a?void 0:a.message,variant:"outlined",disabled:f,autoFocus:h,inputProps:{maxLength:i}},m))}})},O=["form","name","label","required","disabled","autofocus"],L=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,s=r.disabled,f=void 0!==s&&s,v=r.autofocus,h=void 0!==v&&v,m=y(r,O),p=t.control,b=t.formState.errors;return c.createElement(d,{name:o,control:p,rules:{required:u,disabled:f},render:function(r){var t,n,a=r.field,l=a.onChange,d=a.onBlur,s=a.value;return c.createElement(e,g({required:u,label:i,value:s,onChange:l,onBlur:d,error:Boolean(null===(t=b[o])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(n=b[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:f,autoFocus:h,type:"password"},m))}})},q=["form","name","label","required","disabled","autofocus"],S=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,s=r.disabled,f=void 0!==s&&s,v=r.autofocus,h=void 0!==v&&v,m=y(r,q),p=t.control,b=t.formState.errors;return c.createElement(d,{name:o,control:p,rules:{required:u,disabled:f},render:function(r){var t,n,a=r.field,l=a.onChange,d=a.onBlur,s=a.value;return c.createElement(e,g({required:u,label:i,value:s,onChange:l,onBlur:d,error:Boolean(null===(t=b[o])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(n=b[o])||void 0===n?void 0:n.message,variant:"outlined",disabled:f,autoFocus:h},m))}})},T=["form","name","label","disabled"],C=function(e){var o=e.form,a=e.name,i=e.label,l=e.disabled,u=void 0!==l&&l,s=y(e,T),f=o.control;return c.createElement(d,{name:a,control:f,rules:{disabled:u},render:function(e){var l=e.field;l.onChange,l.onBlur;var u=l.value;return c.createElement(r,s,c.createElement(t,{control:c.createElement(n,{checked:Boolean(u),onChange:function(e){return o.setValue(a,e.target.checked)},inputProps:{"aria-label":i}}),label:i}))}})},j=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,s=e.paddingY,f=void 0===s?"5px":s,v=e.borderRadius,h=void 0===v?"10px":v,m=e.fontSize,p=void 0===m?"14px":m,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:a,fontSize:p}};return c.createElement(o,{sx:y.text},t)},k=["form","name","label","selectionWidth","pickerWidth","selectionTextColor","paddingY","paddingX","required","disabled"],B=function(e){var r=e.form,t=e.name,n=void 0===t?"color":t,u=e.label,f=void 0===u?"Επιλογή Χρώματος":u,v=e.selectionWidth,h=void 0===v?70:v,m=e.pickerWidth,p=void 0===m?350:m,x=e.selectionTextColor,w=void 0===x?"white":x,E=e.paddingY,O=void 0===E?"10px":E,L=e.paddingX,q=void 0===L?"10px":L,S=e.required,T=void 0!==S&&S,C=e.disabled,B=void 0!==C&&C,P=y(e,k),_=b(c.useState(null),2),F=_[0],I=_[1],A=Boolean(F),W=A?"color-picker":void 0,N=r.control;return c.createElement(d,{name:n,control:N,rules:{disabled:B},render:function(e){var r=e.field,t=r.onChange;r.onBlur;var n=r.value;return c.createElement(a,g({gap:1},P),c.createElement(o,null,"".concat(f," ").concat(T?"*":"")),c.createElement(i,{sx:{display:"flex"}},c.createElement(i,{"aria-describedby":W,sx:{cursor:"pointer"},onClick:function(e){return I(e.currentTarget)}},c.createElement(j,{color:w,backgroundColor:n,paddingY:O,paddingX:q,width:h,label:n}))),c.createElement(l,{sx:{marginTop:"10px"},id:W,open:A,anchorEl:F,onClose:function(){return I(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"}},c.createElement(i,null,c.createElement(s,{width:p,color:n,onChange:function(e){return t(e.hex)}}))))}})},P=["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,s=void 0!==l&&l,f=r.options,v=void 0===f?[]:f,h=r.valueKey,m=void 0===h?"id":h;r.labelKey;var p=r.maxLength,x=void 0===p?255:p,w=r.autofocus,E=void 0!==w&&w,O=r.noOptionsText,L=void 0===O?"Δεν υπάρχουν επιλογές":O,q=y(r,P),S=b(c.useState(null),2),T=S[0],C=S[1],j=t.watch(n);c.useEffect((function(){C(v.find((function(e){return e[m]===j}))||null)}),[j]);var k=t.control,B=t.formState.errors;return c.createElement(d,{name:n,control:k,rules:{required:i,disabled:s},render:function(r){var t=r.field,a=t.onChange,l=t.onBlur;return t.value,c.createElement(u,{value:T,required:i,onChange:function(e,r){return a(r?r[m]:null)},options:v,isOptionEqualToValue:function(e,r){return e[m]===r[m]},noOptionsText:L,renderInput:function(r){var t,a;return c.createElement(e,g({label:o,required:i,disabled:s,autoFocus:E,inputProps:{maxLength:x},error:Boolean(null===(t=B[n])||void 0===t?void 0:t.message),onBlur:l,variant:"outlined",fullWidth:!0,helperText:null===(a=B[n])||void 0===a?void 0:a.message},r,q))}})}})},F=["form","name","label","optionsUrl","renderOption","valueKey","labelKey","minChars","required","disabled","maxLength","autofocus","loadingText","noOptionsText","placeholder","size"],I=function(r){var t,n=r.form,o=r.name,a=r.label,i=r.optionsUrl,l=r.renderOption,s=void 0===l?null:l,v=r.valueKey,m=void 0===v?"id":v,x=r.labelKey,w=void 0===x?"label":x,E=r.minChars,O=void 0===E?2:E,L=r.required,q=void 0!==L&&L,S=r.disabled,T=void 0!==S&&S,C=r.maxLength,j=void 0===C?255:C,k=r.autofocus,B=void 0!==k&&k,P=r.loadingText,_=void 0===P?"Ανάκτηση...":P,I=r.noOptionsText,A=void 0===I?"Δεν υπάρχουν επιλογές":I,W=r.placeholder,N=void 0===W?"":W,G=r.size,K=void 0===G?"medium":G,z=y(r,F),Y=b(c.useState(null),2),V=Y[0],X=Y[1],R=b(c.useState([]),2),U=R[0],D=R[1],M=b(c.useState(!1),2),$=M[0],H=M[1],J=b(c.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;c.useState((function(){if(0===U.length&&ee){var e;!function(){(e=e||p(h().mark((function e(){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return H(!0),e.next=3,f.get("".concat(i,"?id=").concat(ee));case 3:r=e.sent,D(r.data),X(r.data.find((function(e){return e[m]===ee}))||null),H(!1);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}()}}),[]),c.useEffect((function(){X(U.find((function(e){return e[m]===ee}))||null)}),[ee]),c.useEffect((function(){ae()}),[Q]);var oe=function(e,r){Z(r)},ae=function(){return(t=t||p(h().mark((function e(){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Q.length<O)){e.next=4;break}return D([]),H(!1),e.abrupt("return");case 4:return H(!0),e.next=7,f.get("".concat(i,"?token=").concat(Q));case 7:r=e.sent,D(r.data),H(!1);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)};return c.createElement(d,{name:o,control:re,rules:{required:q,disabled:T},render:function(r){var t,n,i,l=r.field,d=l.onChange,f=l.onBlur;return l.value,c.createElement(u,{value:V,options:U,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 d(r?r[m]:null)},isOptionEqualToValue:function(e,r){return e[m]===r[m]},getOptionLabel:function(e){return e[w]},filterOptions:function(e){return e},noOptionsText:A,loadingText:_,loading:$,required:q,size:K,renderInput:function(r){var t,n;return c.createElement(e,g({label:a,required:q,disabled:T,autoFocus:B,placeholder:N,inputProps:{maxLength:j},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,z))},renderOption:function(e,r,t){return s?s(e,r,t):c.createElement("li",g({},e,{key:r[m]}),r[w])}})}})},A=["form","name","label","rows","required","disabled","autofocus"],W=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,s=r.disabled,f=void 0!==s&&s,v=r.autofocus,h=void 0!==v&&v,m=y(r,A),p=t.control,b=t.formState.errors;return c.createElement(d,{name:n,control:p,rules:{required:u,disabled:f},render:function(r){var t,a,l=r.field,d=l.onChange,s=l.onBlur,v=l.value;return c.createElement(e,g({required:u,label:o,value:v,multiline:!0,minRows:i,maxRows:i,onChange:d,onBlur:s,error:Boolean(null===(t=b[n])||void 0===t?void 0:t.message),fullWidth:!0,helperText:null===(a=b[n])||void 0===a?void 0:a.message,variant:"outlined",disabled:f,autoFocus:h},m))}})},N=["form","name","label","required","disabled","autofocus"],G=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 s=y(r,N),f=t.control,h=t.formState.errors;return c.createElement(d,{name:n,control:f,rules:{required:i,disabled:u},render:function(r){var t,a,l=r.field,d=l.onChange;l.onBlur;var f=l.value;return c.createElement(v,g({customInput:e,variant:"outlined",label:o,required:i,disabled:u,value:f,thousandSeparator:".",decimalSeparator:",",decimalScale:2,fixedDecimalScale:!0,allowNegative:!1,onChange:d,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},s))}})};export{I as MyAutocompleteApiField,_ as MyAutocompleteField,B as MyColorPickerField,G as MyCurrencyField,S as MyEmailField,W as MyNotesField,L as MyPasswordField,C as MySwitchField,E as MyTextField};
1
+ import{TextField as e,FormGroup as t,FormControlLabel as r,Switch as n,Typography as o,Stack as a,Box as i,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";import v from"react-number-format";function h(){h=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",u=a.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 a=t&&t.prototype instanceof y?t:y,i=Object.create(a.prototype),l=new B(n||[]);return o(i,"_invoke",{value:T(e,r,l)}),i}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",v="suspendedYield",m="executing",p="completed",g={};function y(){}function b(){}function x(){}var w={};c(w,i,(function(){return this}));var E=Object.getPrototypeOf,O=E&&E(E(P([])));O&&O!==r&&n.call(O,i)&&(w=O);var L=x.prototype=y.prototype=Object.create(w);function q(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,a,i,l){var u=s(e[o],e,a);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,i,l)}),(function(e){r("throw",e,i,l)})):t.resolve(d).then((function(e){c.value=e,i(c)}),(function(e){return r("throw",e,i,l)}))}l(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function T(t,r,n){var o=f;return function(a,i){if(o===m)throw new Error("Generator is already running");if(o===p){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=C(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=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=m;var c=s(t,r,n);if("normal"===c.type){if(o=n.done?p:v,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=p,n.method="throw",n.arg=c.arg)}}}function C(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,C(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=s(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,g;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function j(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function B(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function P(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=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 a.next=a}}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}},q(S.prototype),c(S.prototype,l,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new S(d(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},q(L),c(L,u,"Generator"),c(L,i,(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(k),!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 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"),c=n.call(i,"finallyLoc");if(u&&c){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(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.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 a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(i)},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),k(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;k(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 m(e,t,r,n,o,a,i){try{var l=e[a](i),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 a=e.apply(t,r);function i(e){m(a,n,o,i,l,"next",e)}function l(e){m(a,n,o,i,l,"throw",e)}i(void 0)}))}}function g(){return g=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},g.apply(this,arguments)}function y(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function b(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,a,i,l=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.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&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return x(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 x(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 x(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 w=["form","name","label","maxLength","required","disabled","autofocus"],E=function(t){var r=t.form,n=t.name,o=t.label,a=t.maxLength,i=void 0===a?255:a,l=t.required,u=void 0!==l&&l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,m=y(t,w),p=r.control,b=r.formState.errors;return c.createElement(d,{name:n,control:p,rules:{required:u,disabled:f},render:function(t){var r,a,l=t.field,d=l.onChange,s=l.onBlur,v=l.value;return c.createElement(e,g({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===(a=b[n])||void 0===a?void 0:a.message,variant:"outlined",disabled:f,autoFocus:h,inputProps:{maxLength:i}},m))}})},O=["form","name","label","required","disabled","autofocus"],L=function(t){var r=t.form,n=t.name,o=void 0===n?"password":n,a=t.label,i=void 0===a?"Κωδικός Πρόσβασης":a,l=t.required,u=void 0===l||l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,m=y(t,O),p=r.control,b=r.formState.errors;return c.createElement(d,{name:o,control:p,rules:{required:u,disabled:f},render:function(t){var r,n,a=t.field,l=a.onChange,d=a.onBlur,s=a.value;return c.createElement(e,g({required:u,label:i,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"},m))}})},q=["form","name","label","required","disabled","autofocus"],S=function(t){var r=t.form,n=t.name,o=void 0===n?"email":n,a=t.label,i=void 0===a?"E-mail":a,l=t.required,u=void 0===l||l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,m=y(t,q),p=r.control,b=r.formState.errors;return c.createElement(d,{name:o,control:p,rules:{required:u,disabled:f},render:function(t){var r,n,a=t.field,l=a.onChange,d=a.onBlur,s=a.value;return c.createElement(e,g({required:u,label:i,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},m))}})},T=["form","name","label","disabled"],C=function(e){var o=e.form,a=e.name,i=e.label,l=e.disabled,u=void 0!==l&&l,s=y(e,T),f=o.control;return c.createElement(d,{name:a,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(a,e.target.checked)},inputProps:{"aria-label":i}}),label:i}))}})},j=function(e){var t=e.label,r=void 0===t?"":t,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,s=e.paddingY,f=void 0===s?"5px":s,v=e.borderRadius,h=void 0===v?"10px":v,m=e.fontSize,p=void 0===m?"14px":m,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:a,fontSize:p}};return c.createElement(o,{sx:y.text},r)},k=["form","name","label","selectionWidth","pickerWidth","selectionTextColor","paddingY","paddingX","required","disabled"],B=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,m=e.pickerWidth,p=void 0===m?350:m,x=e.selectionTextColor,w=void 0===x?"white":x,E=e.paddingY,O=void 0===E?"10px":E,L=e.paddingX,q=void 0===L?"10px":L,S=e.required,T=void 0!==S&&S,C=e.disabled,B=void 0!==C&&C,P=y(e,k),_=b(c.useState(null),2),F=_[0],I=_[1],A=Boolean(F),W=A?"color-picker":void 0,N=t.control;return c.createElement(d,{name:n,control:N,rules:{disabled:B},render:function(e){var t=e.field,r=t.onChange;t.onBlur;var n=t.value;return c.createElement(a,g({gap:1},P),c.createElement(o,null,"".concat(f," ").concat(T?"*":"")),c.createElement(i,{sx:{display:"flex"}},c.createElement(i,{"aria-describedby":W,sx:{cursor:"pointer"},onClick:function(e){return I(e.currentTarget)}},c.createElement(j,{color:w,backgroundColor:n,paddingY:O,paddingX:q,width:h,label:n}))),c.createElement(l,{sx:{marginTop:"10px"},id:W,open:A,anchorEl:F,onClose:function(){return I(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"}},c.createElement(i,null,c.createElement(s,{width:p,color:n,onChange:function(e){return r(e.hex)}}))))}})},P=["form","name","label","required","disabled","options","valueKey","labelKey","maxLength","autofocus","noOptionsText"],_=function(t){var r=t.form,n=t.name,o=t.label,a=t.required,i=void 0!==a&&a,l=t.disabled,s=void 0!==l&&l,f=t.options,v=void 0===f?[]:f,h=t.valueKey,m=void 0===h?"id":h;t.labelKey;var p=t.maxLength,x=void 0===p?255:p,w=t.autofocus,E=void 0!==w&&w,O=t.noOptionsText,L=void 0===O?"Δεν υπάρχουν επιλογές":O,q=y(t,P),S=b(c.useState(null),2),T=S[0],C=S[1],j=r.watch(n);c.useEffect((function(){C(v.find((function(e){return e[m]===j}))||null)}),[j]);var k=r.control,B=r.formState.errors;return c.createElement(d,{name:n,control:k,rules:{required:i,disabled:s},render:function(t){var r=t.field,a=r.onChange,l=r.onBlur;return r.value,c.createElement(u,{value:T,required:i,onChange:function(e,t){return a(t?t[m]:null)},options:v,isOptionEqualToValue:function(e,t){return e[m]===t[m]},noOptionsText:L,renderInput:function(t){var r,a;return c.createElement(e,g({label:o,required:i,disabled:s,autoFocus:E,inputProps:{maxLength:x},error:Boolean(null===(r=B[n])||void 0===r?void 0:r.message),onBlur:l,variant:"outlined",fullWidth:!0,helperText:null===(a=B[n])||void 0===a?void 0:a.message},t,q))}})}})},F=["form","name","label","optionsUrl","renderOption","valueKey","labelKey","minChars","required","disabled","maxLength","autofocus","loadingText","noOptionsText","placeholder","size"],I=function(t){var r,n=t.form,o=t.name,a=t.label,i=t.optionsUrl,l=t.renderOption,s=void 0===l?null:l,v=t.valueKey,m=void 0===v?"id":v,x=t.labelKey,w=void 0===x?"label":x,E=t.minChars,O=void 0===E?2:E,L=t.required,q=void 0!==L&&L,S=t.disabled,T=void 0!==S&&S,C=t.maxLength,j=void 0===C?255:C,k=t.autofocus,B=void 0!==k&&k,P=t.loadingText,_=void 0===P?"Ανάκτηση...":P,I=t.noOptionsText,A=void 0===I?"Δεν υπάρχουν επιλογές":I,W=t.placeholder,N=void 0===W?"":W,V=t.size,G=void 0===V?"medium":V,K=y(t,F),z=b(c.useState(null),2),Y=z[0],X=z[1],R=b(c.useState([]),2),U=R[0],D=R[1],M=b(c.useState(!1),2),$=M[0],H=M[1],J=b(c.useState(""),2),Q=J[0],Z=J[1],ee=n.watch(o),te=n.control,re=n.formState;n.setValue,n.getValues;var ne=re.errors;c.useState((function(){if(0===U.length&&ee){var e;!function(){(e=e||p(h().mark((function e(){var t;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return H(!0),e.next=3,f.get("".concat(i,"?id=").concat(ee));case 3:t=e.sent,D(t.data),X(t.data.find((function(e){return e[m]===ee}))||null),H(!1);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}()}}),[]),c.useEffect((function(){X(U.find((function(e){return e[m]===ee}))||null)}),[ee]),c.useEffect((function(){ae()}),[Q]);var oe=function(e,t){Z(t)},ae=function(){return(r=r||p(h().mark((function e(){var t;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Q.length<O)){e.next=4;break}return D([]),H(!1),e.abrupt("return");case 4:return H(!0),e.next=7,f.get("".concat(i,"?token=").concat(Q));case 7:t=e.sent,D(t.data),H(!1);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)};return c.createElement(d,{name:o,control:te,rules:{required:q,disabled:T},render:function(t){var r,n,i,l=t.field,d=l.onChange,f=l.onBlur;return l.value,c.createElement(u,{value:Y,options:U,onInputChange:(r=oe,n=300,function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];i&&clearTimeout(i),i=setTimeout((function(){r.apply(void 0,t)}),n)}),onChange:function(e,t){return d(t?t[m]:null)},isOptionEqualToValue:function(e,t){return e[m]===t[m]},getOptionLabel:function(e){return e[w]},filterOptions:function(e){return e},noOptionsText:A,loadingText:_,loading:$,required:q,size:G,renderInput:function(t){var r,n;return c.createElement(e,g({label:a,required:q,disabled:T,autoFocus:B,placeholder:N,inputProps:{maxLength:j},error:Boolean(null===(r=ne[o])||void 0===r?void 0:r.message),onBlur:f,variant:"outlined",fullWidth:!0,helperText:null===(n=ne[o])||void 0===n?void 0:n.message,size:G},t,K))},renderOption:function(e,t,r){return s?s(e,t,r):c.createElement("li",g({},e,{key:t[m]}),t[w])}})}})},A=["form","name","label","rows","required","disabled","autofocus"],W=function(t){var r=t.form,n=t.name,o=t.label,a=t.rows,i=void 0===a?5:a,l=t.required,u=void 0!==l&&l,s=t.disabled,f=void 0!==s&&s,v=t.autofocus,h=void 0!==v&&v,m=y(t,A),p=r.control,b=r.formState.errors;return c.createElement(d,{name:n,control:p,rules:{required:u,disabled:f},render:function(t){var r,a,l=t.field,d=l.onChange,s=l.onBlur,v=l.value;return c.createElement(e,g({required:u,label:o,value:v,multiline:!0,minRows:i,maxRows:i,onChange:d,onBlur:s,error:Boolean(null===(r=b[n])||void 0===r?void 0:r.message),fullWidth:!0,helperText:null===(a=b[n])||void 0===a?void 0:a.message,variant:"outlined",disabled:f,autoFocus:h},m))}})},N=["form","name","label","required","disabled","autofocus"],V=function(t){var r=t.form,n=t.name,o=t.label,a=t.required,i=void 0!==a&&a,l=t.disabled,u=void 0!==l&&l;t.autofocus;var s=y(t,N),f=r.control,h=r.formState.errors,m=function(e,t){""===e.value?r.setValue(n,null):r.setValue(n,e.floatValue)};return c.createElement(d,{name:n,control:f,rules:{required:i,disabled:u},render:function(t){var r,a,l=t.field;l.onChange,l.onBlur;var d=l.value;return c.createElement(v,g({customInput:e,variant:"outlined",label:o,required:i,disabled:u,value:d,thousandSeparator:".",decimalSeparator:",",decimalScale:2,fixedDecimalScale:!0,allowNegative:!1,onValueChange:m,error:Boolean(null===(r=h[n])||void 0===r?void 0:r.message),helperText:null===(a=h[n])||void 0===a?void 0:a.message},s))}})};export{I as MyAutocompleteApiField,_ as MyAutocompleteField,B as MyColorPickerField,V as MyCurrencyField,S as MyEmailField,W as MyNotesField,L as MyPasswordField,C as MySwitchField,E as MyTextField};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artibet/react-mui-components",
3
- "version": "2.4.9",
3
+ "version": "2.4.11",
4
4
  "description": "Various react components build with mui library",
5
5
  "main": "./core/index.js",
6
6
  "scripts": {