@artibet/react-mui-components 3.7.46 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/index.js CHANGED
@@ -1 +1 @@
1
- import e from"react";import{Typography as t,Alert as n,Box as r,Button as o,Stack as i,Popover as l,Divider as a,MenuItem as c,ListItemIcon as s,Tooltip as u,IconButton as m,Menu as d,Paper as p,Dialog as f,Zoom as v,DialogTitle as g,DialogContent as x,DialogContentText as h,DialogActions as b,CircularProgress as E,Chip as y}from"@mui/material";import{Done as C,Close as w,DescriptionOutlined as k,CalendarToday as S,Update as z}from"@mui/icons-material";import{format as O,parseISO as j}from"date-fns";import{el as I}from"date-fns/locale";import{ImArrowLeft as B}from"react-icons/im";import P from"@mui/icons-material/Menu";import"react-hook-form";import"@hookform/resolvers/yup";import"yup";import"react-color";import"axios";import"react-number-format";import"@mui/x-date-pickers/AdapterDateFnsV3";import"@mui/x-date-pickers/LocalizationProvider";import"@mui/x-date-pickers";import"date-fns/locale/el";import A from"@mui/icons-material/WarningAmberRounded";import R from"@mui/icons-material/ErrorOutlineRounded";import W from"@mui/icons-material/CheckCircleOutlineRounded";var T=function(n){var r=n.label,o=void 0===r?"":r,i=n.color,l=void 0===i?"white":i,a=n.backgroundColor,c=void 0===a?"#888888":a,s=n.paddingX,u=void 0===s?"10px":s,m=n.paddingY,d=void 0===m?"5px":m,p=n.borderRadius,f=void 0===p?"10px":p,v=n.fontSize,g=void 0===v?"14px":v,x=n.width,h={text:{display:"inline-block",textAlign:"center",backgroundColor:c,paddingX:u,paddingY:d,borderRadius:f,width:void 0===x?"auto":x,color:l,fontSize:g}};return e.createElement(t,{sx:h.text},o)},F=function(t){var r=t.errors,o=t.marginBottom,i=void 0===o?3:o;return 0===Object.keys(r).length?null:e.createElement(e.Fragment,null,Object.keys(r).map((function(t,o){return e.createElement(n,{sx:{marginBottom:i},key:o,severity:"error"},r[t])})))},D=function(t){var n=t.on,r=t.showOn,o=void 0===r||r,i=t.showOff,l=void 0===i||i,a=t.size,c=void 0===a?24:a;return Boolean(n)?o?e.createElement(C,{color:"success",sx:{fontSize:c}}):null:l?e.createElement(w,{color:"error",sx:{fontSize:c}}):null},M=function(t){var n=t.status,r=t.showYes,o=void 0===r||r,i=t.showNo,l=void 0===i||i,a=t.width,c=void 0===a?80:a;return Boolean(n)?o&&e.createElement(T,{label:"ΝΑΙ",backgroundColor:"green",fontSize:"12px",paddingX:"5px",width:c}):l&&e.createElement(T,{label:"ΟΧΙ",backgroundColor:"red",fontSize:"12px",paddingX:"5px",width:c})},H=function(e){return e?O(j(e,{locale:I}),"dd/MM/yyyy, HH:mm"):""},N=function(t){var n,o,i=t.amount,l=t.align,a=void 0===l?"left":l;return e.createElement(r,{sx:{textAlign:a}},null==(o=n=i)||""===o?"":new Intl.NumberFormat("el-GR",{style:"currency",currency:"EUR"}).format(n))},L=function(n){var l=n.position,a=void 0===l?"top":l,c=n.label,s=void 0===c?"ΕΠΙΣΤΡΟΦΗ":c;return e.createElement(r,{sx:{marginBottom:1}},"bottom"===a&&e.createElement("hr",null),e.createElement(r,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement(o,{color:"warning",onClick:function(){return history.back()}},e.createElement(i,{direction:"row",spacing:1,sx:{alignItems:"center"}},e.createElement(B,null),e.createElement(t,null,s)))),"top"===a&&e.createElement("hr",null))};function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function X(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U(){return U=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},U.apply(null,arguments)}function Y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(n),!0).forEach((function(t){X(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function q(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,l,a=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=n.return&&(l=n.return(),Object(l)!==l))return}finally{if(s)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return V(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?V(e,t):void 0}}(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.")}()}var G=function(n){var l=n.title,a=n.titlePosition,c=void 0===a?"right":a,s=n.showReturnButton,u=void 0===s||s,m=n.returnButtonLabel,d=void 0===m?"ΕΠΙΣΤΡΟΦΗ":m,p=n.onReturn,f=void 0===p?null:p,v=n.titleProps,g=void 0===v?{}:v,x=n.returnButtonProps,h=void 0===x?{}:x,b=e.createElement(o,U({color:"warning",onClick:f?f():function(){return history.back()}},h),e.createElement(i,{direction:"row",spacing:1,sx:{alignItems:"center"}},e.createElement(B,null),e.createElement(t,null,d))),E=e.createElement(t,U({variant:"h6"},g),l),y="space-between";return u||(y="left"===c?"flex-start":"flex-end"),e.createElement(e.Fragment,null,e.createElement(r,{sx:{display:"flex",justifyContent:{justifyContent:y},alignItems:"center"}},"left"===c&&E,u&&b,"right"===c&&E),e.createElement("hr",null))},$=function(t){var n=t.popup,r=t.children,o=t.verticalAnchor,i=void 0===o?"bottom":o,a=t.horizontalAnchor,c=void 0===a?"left":a,s=t.verticalTransform,u=void 0===s?"top":s,m=t.horizontalTransform,d=void 0===m?"left":m,p=q(e.useState(null),2),f=p[0],v=p[1],g=Boolean(f),x=function(){v(null)},h=r?e.cloneElement(r,{onMouseEnter:function(e){v(e.currentTarget)},onMouseLeave:x}):null;return e.createElement(e.Fragment,null,h,e.createElement(l,{id:"mouse-over-popup",sx:{pointerEvents:"none"},open:g,anchorEl:f,anchorOrigin:{vertical:i,horizontal:c},transformOrigin:{vertical:u,horizontal:d},onClose:x,disableRestoreFocus:!0},n))},J=function(t){var n=t.option,r=t.onClose;return n.hidden?null:n.divider?e.createElement(a,null):e.createElement(c,{onClick:function(e){e.stopPropagation(),n.onClick&&(r(e),n.onClick())}},n.icon&&e.createElement(s,null,n.icon),n.label)},K=function(t){var n=t.tooltip,o=void 0===n?"Επιλογές":n,i=t.menuIcon,l=void 0===i?e.createElement(P,null):i,a=t.options,c=void 0===a?[]:a,s=q(e.useState(null),2),p=s[0],f=s[1],v=Boolean(p),g=function(e){e.stopPropagation(),f(null)};return c&&0!==c.length&&c.some((function(e){return!e.hidden}))?e.createElement(e.Fragment,null,e.createElement(r,{sx:{display:"flex",alignItems:"center",textAlign:"center"}},e.createElement(u,{title:o},e.createElement(m,{onClick:function(e){e.stopPropagation(),f(e.currentTarget)},size:"small"},l))),e.createElement(d,{anchorEl:p,open:v,onClose:g,onClick:g,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"}},c.map((function(t,n){return e.createElement(J,{key:n,option:t,onClose:g})})))):null},Q=function(t){var n=t.icon,o=t.title,i=void 0===o?"":o,l=t.subtitle,a=void 0===l?"":l,c=t.backgroundColor,s=void 0===c?"white":c,u=t.elevation,m=void 0===u?2:u,d=t.iconBackgroundColor,f=void 0===d?"gray":d,v=t.iconColor,g=void 0===v?"white":v,x=t.width,h=void 0===x?"100%":x,b=t.onClick,E=void 0===b?null:b,y={paper:{backgroundColor:s,width:h,cursor:E?"pointer":"default"},wrapperBox:{display:"flex",flexDirection:"row",justifyContent:"start",alignItems:"start",gap:2},iconBox:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",color:g,backgroundColor:f,padding:0,margin:0,width:"72px",height:"72px",fontSize:"48px"},contentBox:{display:"flex",paddingRight:"15px",flexDirection:"column"}};return e.createElement(p,{elevation:m,sx:y.paper,square:!0,onClick:function(){E&&E()}},e.createElement(r,{sx:y.wrapperBox},e.createElement(r,{sx:y.iconBox},n),e.createElement(r,{sx:y.contentBox},e.createElement(r,null,i),e.createElement(r,null,a))))},Z=function(t){var n=t.url,r=t.tooltip,o=void 0===r?null:r,i=t.size,l=void 0===i?"36px":i,a=t.activeColor,c=void 0===a?"green":a,s=t.inactiveColor,m=void 0===s?"red":s;return o?e.createElement(u,{title:o},n?e.createElement("a",{href:n,target:"_blank"},e.createElement(k,{sx:{fontSize:l,color:c}})):e.createElement(k,{sx:{fontSize:l,color:m}})):e.createElement(e.Fragment,null,n?e.createElement("a",{href:n,target:"_blank"},e.createElement(k,{sx:{fontSize:{size:l},color:c}})):e.createElement(k,{sx:{fontSize:{size:l},color:{inactiveColor:m}}}))};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".chrome-picker {\r\n -webkit-box-shadow: none !important;\r\n -moz-box-shadow: none !important;\r\n box-shadow: none !important;\r\n}");var ee=function(t){var n=t.open,i=t.title,l=t.message,a=t.onConfirm,c=t.onCancel,s=t.confirmText,u=void 0===s?"ΕΠΙΒΕΒΑΙΩΣΗ":s,m=t.cancelText,d=void 0===m?"ΑΚΥΡΩΣΗ":m,p=t.isLoading,y=void 0!==p&&p,C=t.type,w=void 0===C?"warning":C,k={warning:{color:"warning.main",icon:e.createElement(A,{sx:{fontSize:40}})},error:{color:"error.main",icon:e.createElement(R,{sx:{fontSize:40}})},success:{color:"success.main",icon:e.createElement(W,{sx:{fontSize:40}})}}[w]||{color:"primary.main",icon:null};return e.createElement(f,{open:n,onClose:function(e,t){"backdropClick"!==t&&c()},slots:{transition:v},slotProps:{backdrop:{sx:{backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(4px)"}},paper:{sx:{borderRadius:4,padding:1,maxWidth:400,textAlign:"center",backgroundImage:"none"}}}},e.createElement(r,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:3}},e.createElement(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:70,height:70,bgcolor:"".concat(k.color,"20"),color:k.color,borderRadius:"50%",mb:2}},k.icon),e.createElement(g,{sx:{fontWeight:800,fontSize:"1.35rem",pt:0,pb:1}},i)),e.createElement(x,null,e.createElement(h,{sx:{color:"text.secondary",fontWeight:500,lineHeight:1.6}},l)),e.createElement(b,{sx:{justifyContent:"center",gap:2,px:3,pb:3,mt:1}},e.createElement(o,{fullWidth:!0,variant:"text",color:"inherit",onClick:c,sx:{borderRadius:3,fontWeight:700,color:"text.disabled"}},d),e.createElement(o,{fullWidth:!0,variant:"contained",disableElevation:!0,color:"error"===w?"error":"primary",onClick:a,sx:{borderRadius:3,fontWeight:700,py:1}},y?e.createElement(E,{size:20,sx:{color:"inherit"}}):u)))},te=function(t){var n=t.activationElement,o=t.onUpload,i=t.replace,l=void 0!==i&&i,a=t.replaceTitle,c=void 0===a?"Επιβεβαίωση Τροποποίησης Αρχείου":a,s=t.replaceMessage,u=void 0===s?"Το προηγούμενο αρχείο θα διαγραφεί οριστικά. Να γίνει η τροποποίηση;":s,m=q(e.useState(!1),2),d=m[0],p=m[1],f=e.useRef(null),v=function(){p(!1),f.current.value=null,f.current.click()};return e.createElement(e.Fragment,null,e.createElement(r,{onClick:function(){l?p(!0):v()}},n),e.createElement("input",{type:"file",ref:f,style:{display:"none"},onChange:function(e){var t;(t=e.target.files[0])&&o(t)}}),l&&e.createElement(ee,{open:d,onConfirm:v,onCancel:function(){return p(!1)},title:c,message:u}))},ne=function(t){var n=t.label,r=t.isActive,o=void 0!==r&&r,i=t.activeBgColor,l=void 0===i?"success.main":i,a=t.inactiveBgColor,c=void 0===a?"":a,s=t.activeVariant,u=void 0===s?"filled":s,m=t.inactiveVariant,d=void 0===m?"outlined":m,p=t.activeColor,f=void 0===p?"#ffffff":p,v=t.inactiveColor,g=void 0===v?"text.secondary":v;return e.createElement(y,{label:n,variant:o?u:d,size:"small",sx:_(_(_({fontWeight:600,minWidth:80},o&&{bgcolor:l,color:f}),!o&&{color:g,bgcolor:c,borderColor:"divider",opacity:.7}),{},{"& .MuiChip-label":{px:1}})})},re=function(n){var o=n.title,l=n.titleVariant,c=void 0===l?"h5":l,s=n.titleFontWeight,u=void 0===s?800:s,m=n.titleColor,d=void 0===m?"text.primary":m,p=n.wrapperStyle,f=void 0===p?{}:p,v=n.titleChip,g=void 0===v?null:v,x=n.createdAt,h=void 0===x?null:x,b=n.updatedAt,E=void 0===b?null:b,y=n.globalActions,C=void 0===y?null:y;return e.createElement(r,{sx:_({},f)},e.createElement(i,{direction:{xs:"column",md:"row"},sx:{mt:2},spacing:3,alignItems:{xs:"flex-start",md:"center"},justifyContent:"space-between"},e.createElement(i,{direction:"row",spacing:3,alignItems:"center"},e.createElement(r,null,e.createElement(i,{direction:"row",spacing:1.5,alignItems:"center",flexWrap:"wrap",sx:{mb:.5}},e.createElement(t,{variant:c,sx:{fontWeight:u,color:d}},o),g),e.createElement(i,{direction:"row",spacing:2,alignItems:"center",divider:e.createElement(r,{sx:{width:4,height:4,borderRadius:"50%",bgcolor:"text.disabled",opacity:.5}})},(h||E)&&e.createElement(i,{direction:"row",spacing:1.5,alignItems:"center",sx:{display:"flex"}},h&&e.createElement(r,{sx:{display:"flex",alignItems:"center",gap:.5}},e.createElement(S,{sx:{fontSize:14,color:"text.disabled"}}),e.createElement(t,{variant:"caption",color:"text.secondary",sx:{lineHeight:1,display:"flex",alignItems:"center"}},H(h))),h&&E&&e.createElement(r,{component:"span",sx:{color:"divider",fontSize:14}},"•"),E&&e.createElement(r,{sx:{display:"flex",alignItems:"center",gap:.5}},e.createElement(z,{sx:{fontSize:14,color:"text.disabled"}}),e.createElement(t,{variant:"caption",color:"text.secondary",sx:{lineHeight:1,display:"flex",alignItems:"center"}},H(E))))))),e.createElement(r,{sx:{alignSelf:{xs:"flex-end",md:"center"}}},C)),e.createElement(a,{sx:{mt:2,opacity:1}}))};export{N as Currency,Z as DocumentIconLink,L as GoBack,Q as IconCard,$ as MouseOverPopup,T as MyChip,re as PageHeader,G as PageTitle,K as PopupMenu,F as ShowErrors,ne as StatusChip,D as StatusIcon,te as UploadFile,M as YesNoChip};
1
+ import e from"react";import{Typography as t,Alert as n,Box as r,Button as o,Stack as i,Popover as l,Divider as a,MenuItem as c,ListItemIcon as s,Tooltip as u,IconButton as m,Menu as d,Paper as p,Dialog as f,Zoom as v,DialogTitle as g,DialogContent as x,DialogContentText as h,DialogActions as b,CircularProgress as E,Chip as y}from"@mui/material";import{Done as C,Close as w,DescriptionOutlined as k,CalendarToday as S,Update as z}from"@mui/icons-material";import{format as O,parseISO as j}from"date-fns";import{el as I}from"date-fns/locale";import{ImArrowLeft as B}from"react-icons/im";import P from"@mui/icons-material/Menu";import"react-hook-form";import"@hookform/resolvers/yup";import"yup";import"react-color";import"axios";import"react-number-format";import"@mui/x-date-pickers/AdapterDateFnsV3";import"@mui/x-date-pickers/LocalizationProvider";import"@mui/x-date-pickers";import"date-fns/locale/el";import A from"@mui/icons-material/WarningAmberRounded";import R from"@mui/icons-material/ErrorOutlineRounded";import W from"@mui/icons-material/CheckCircleOutlineRounded";var T=function(n){var r=n.label,o=void 0===r?"":r,i=n.color,l=void 0===i?"white":i,a=n.backgroundColor,c=void 0===a?"#888888":a,s=n.paddingX,u=void 0===s?"10px":s,m=n.paddingY,d=void 0===m?"5px":m,p=n.borderRadius,f=void 0===p?"10px":p,v=n.fontSize,g=void 0===v?"14px":v,x=n.width,h={text:{display:"inline-block",textAlign:"center",backgroundColor:c,paddingX:u,paddingY:d,borderRadius:f,width:void 0===x?"auto":x,color:l,fontSize:g}};return e.createElement(t,{sx:h.text},o)},F=function(t){var r=t.errors,o=t.marginBottom,i=void 0===o?3:o;return r?0===Object.keys(r).length?null:e.createElement(e.Fragment,null,Object.keys(r).map((function(t,o){return e.createElement(n,{sx:{marginBottom:i},key:o,severity:"error"},r[t])}))):null},D=function(t){var n=t.on,r=t.showOn,o=void 0===r||r,i=t.showOff,l=void 0===i||i,a=t.size,c=void 0===a?24:a;return Boolean(n)?o?e.createElement(C,{color:"success",sx:{fontSize:c}}):null:l?e.createElement(w,{color:"error",sx:{fontSize:c}}):null},M=function(t){var n=t.status,r=t.showYes,o=void 0===r||r,i=t.showNo,l=void 0===i||i,a=t.width,c=void 0===a?80:a;return Boolean(n)?o&&e.createElement(T,{label:"ΝΑΙ",backgroundColor:"green",fontSize:"12px",paddingX:"5px",width:c}):l&&e.createElement(T,{label:"ΟΧΙ",backgroundColor:"red",fontSize:"12px",paddingX:"5px",width:c})},H=function(e){return e?O(j(e,{locale:I}),"dd/MM/yyyy, HH:mm"):""},N=function(t){var n,o,i=t.amount,l=t.align,a=void 0===l?"left":l;return e.createElement(r,{sx:{textAlign:a}},null==(o=n=i)||""===o?"":new Intl.NumberFormat("el-GR",{style:"currency",currency:"EUR"}).format(n))},L=function(n){var l=n.position,a=void 0===l?"top":l,c=n.label,s=void 0===c?"ΕΠΙΣΤΡΟΦΗ":c;return e.createElement(r,{sx:{marginBottom:1}},"bottom"===a&&e.createElement("hr",null),e.createElement(r,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement(o,{color:"warning",onClick:function(){return history.back()}},e.createElement(i,{direction:"row",spacing:1,sx:{alignItems:"center"}},e.createElement(B,null),e.createElement(t,null,s)))),"top"===a&&e.createElement("hr",null))};function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function X(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U(){return U=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},U.apply(null,arguments)}function Y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(n),!0).forEach((function(t){X(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function q(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,l,a=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=n.return&&(l=n.return(),Object(l)!==l))return}finally{if(s)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return V(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?V(e,t):void 0}}(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.")}()}var G=function(n){var l=n.title,a=n.titlePosition,c=void 0===a?"right":a,s=n.showReturnButton,u=void 0===s||s,m=n.returnButtonLabel,d=void 0===m?"ΕΠΙΣΤΡΟΦΗ":m,p=n.onReturn,f=void 0===p?null:p,v=n.titleProps,g=void 0===v?{}:v,x=n.returnButtonProps,h=void 0===x?{}:x,b=e.createElement(o,U({color:"warning",onClick:f?f():function(){return history.back()}},h),e.createElement(i,{direction:"row",spacing:1,sx:{alignItems:"center"}},e.createElement(B,null),e.createElement(t,null,d))),E=e.createElement(t,U({variant:"h6"},g),l),y="space-between";return u||(y="left"===c?"flex-start":"flex-end"),e.createElement(e.Fragment,null,e.createElement(r,{sx:{display:"flex",justifyContent:{justifyContent:y},alignItems:"center"}},"left"===c&&E,u&&b,"right"===c&&E),e.createElement("hr",null))},$=function(t){var n=t.popup,r=t.children,o=t.verticalAnchor,i=void 0===o?"bottom":o,a=t.horizontalAnchor,c=void 0===a?"left":a,s=t.verticalTransform,u=void 0===s?"top":s,m=t.horizontalTransform,d=void 0===m?"left":m,p=q(e.useState(null),2),f=p[0],v=p[1],g=Boolean(f),x=function(){v(null)},h=r?e.cloneElement(r,{onMouseEnter:function(e){v(e.currentTarget)},onMouseLeave:x}):null;return e.createElement(e.Fragment,null,h,e.createElement(l,{id:"mouse-over-popup",sx:{pointerEvents:"none"},open:g,anchorEl:f,anchorOrigin:{vertical:i,horizontal:c},transformOrigin:{vertical:u,horizontal:d},onClose:x,disableRestoreFocus:!0},n))},J=function(t){var n=t.option,r=t.onClose;return n.hidden?null:n.divider?e.createElement(a,null):e.createElement(c,{onClick:function(e){e.stopPropagation(),n.onClick&&(r(e),n.onClick())}},n.icon&&e.createElement(s,null,n.icon),n.label)},K=function(t){var n=t.tooltip,o=void 0===n?"Επιλογές":n,i=t.menuIcon,l=void 0===i?e.createElement(P,null):i,a=t.options,c=void 0===a?[]:a,s=q(e.useState(null),2),p=s[0],f=s[1],v=Boolean(p),g=function(e){e.stopPropagation(),f(null)};return c&&0!==c.length&&c.some((function(e){return!e.hidden}))?e.createElement(e.Fragment,null,e.createElement(r,{sx:{display:"flex",alignItems:"center",textAlign:"center"}},e.createElement(u,{title:o},e.createElement(m,{onClick:function(e){e.stopPropagation(),f(e.currentTarget)},size:"small"},l))),e.createElement(d,{anchorEl:p,open:v,onClose:g,onClick:g,transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"}},c.map((function(t,n){return e.createElement(J,{key:n,option:t,onClose:g})})))):null},Q=function(t){var n=t.icon,o=t.title,i=void 0===o?"":o,l=t.subtitle,a=void 0===l?"":l,c=t.backgroundColor,s=void 0===c?"white":c,u=t.elevation,m=void 0===u?2:u,d=t.iconBackgroundColor,f=void 0===d?"gray":d,v=t.iconColor,g=void 0===v?"white":v,x=t.width,h=void 0===x?"100%":x,b=t.onClick,E=void 0===b?null:b,y={paper:{backgroundColor:s,width:h,cursor:E?"pointer":"default"},wrapperBox:{display:"flex",flexDirection:"row",justifyContent:"start",alignItems:"start",gap:2},iconBox:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",color:g,backgroundColor:f,padding:0,margin:0,width:"72px",height:"72px",fontSize:"48px"},contentBox:{display:"flex",paddingRight:"15px",flexDirection:"column"}};return e.createElement(p,{elevation:m,sx:y.paper,square:!0,onClick:function(){E&&E()}},e.createElement(r,{sx:y.wrapperBox},e.createElement(r,{sx:y.iconBox},n),e.createElement(r,{sx:y.contentBox},e.createElement(r,null,i),e.createElement(r,null,a))))},Z=function(t){var n=t.url,r=t.tooltip,o=void 0===r?null:r,i=t.size,l=void 0===i?"36px":i,a=t.activeColor,c=void 0===a?"green":a,s=t.inactiveColor,m=void 0===s?"red":s;return o?e.createElement(u,{title:o},n?e.createElement("a",{href:n,target:"_blank"},e.createElement(k,{sx:{fontSize:l,color:c}})):e.createElement(k,{sx:{fontSize:l,color:m}})):e.createElement(e.Fragment,null,n?e.createElement("a",{href:n,target:"_blank"},e.createElement(k,{sx:{fontSize:{size:l},color:c}})):e.createElement(k,{sx:{fontSize:{size:l},color:{inactiveColor:m}}}))};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".chrome-picker {\r\n -webkit-box-shadow: none !important;\r\n -moz-box-shadow: none !important;\r\n box-shadow: none !important;\r\n}");var ee=function(t){var n=t.open,i=t.title,l=t.message,a=t.onConfirm,c=t.onCancel,s=t.confirmText,u=void 0===s?"ΕΠΙΒΕΒΑΙΩΣΗ":s,m=t.cancelText,d=void 0===m?"ΑΚΥΡΩΣΗ":m,p=t.isLoading,y=void 0!==p&&p,C=t.type,w=void 0===C?"warning":C,k={warning:{color:"warning.main",icon:e.createElement(A,{sx:{fontSize:40}})},error:{color:"error.main",icon:e.createElement(R,{sx:{fontSize:40}})},success:{color:"success.main",icon:e.createElement(W,{sx:{fontSize:40}})}}[w]||{color:"primary.main",icon:null};return e.createElement(f,{open:n,onClose:function(e,t){"backdropClick"!==t&&c()},slots:{transition:v},slotProps:{backdrop:{sx:{backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(4px)"}},paper:{sx:{borderRadius:4,padding:1,maxWidth:400,textAlign:"center",backgroundImage:"none"}}}},e.createElement(r,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:3}},e.createElement(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:70,height:70,bgcolor:"".concat(k.color,"20"),color:k.color,borderRadius:"50%",mb:2}},k.icon),e.createElement(g,{sx:{fontWeight:800,fontSize:"1.35rem",pt:0,pb:1}},i)),e.createElement(x,null,e.createElement(h,{sx:{color:"text.secondary",fontWeight:500,lineHeight:1.6}},l)),e.createElement(b,{sx:{justifyContent:"center",gap:2,px:3,pb:3,mt:1}},e.createElement(o,{fullWidth:!0,variant:"text",color:"inherit",onClick:c,sx:{borderRadius:3,fontWeight:700,color:"text.disabled"}},d),e.createElement(o,{fullWidth:!0,variant:"contained",disableElevation:!0,color:"error"===w?"error":"primary",onClick:a,sx:{borderRadius:3,fontWeight:700,py:1}},y?e.createElement(E,{size:20,sx:{color:"inherit"}}):u)))},te=function(t){var n=t.activationElement,o=t.onUpload,i=t.replace,l=void 0!==i&&i,a=t.replaceTitle,c=void 0===a?"Επιβεβαίωση Τροποποίησης Αρχείου":a,s=t.replaceMessage,u=void 0===s?"Το προηγούμενο αρχείο θα διαγραφεί οριστικά. Να γίνει η τροποποίηση;":s,m=q(e.useState(!1),2),d=m[0],p=m[1],f=e.useRef(null),v=function(){p(!1),f.current.value=null,f.current.click()};return e.createElement(e.Fragment,null,e.createElement(r,{onClick:function(){l?p(!0):v()}},n),e.createElement("input",{type:"file",ref:f,style:{display:"none"},onChange:function(e){var t;(t=e.target.files[0])&&o(t)}}),l&&e.createElement(ee,{open:d,onConfirm:v,onCancel:function(){return p(!1)},title:c,message:u}))},ne=function(t){var n=t.label,r=t.isActive,o=void 0!==r&&r,i=t.activeBgColor,l=void 0===i?"success.main":i,a=t.inactiveBgColor,c=void 0===a?"":a,s=t.activeVariant,u=void 0===s?"filled":s,m=t.inactiveVariant,d=void 0===m?"outlined":m,p=t.activeColor,f=void 0===p?"#ffffff":p,v=t.inactiveColor,g=void 0===v?"text.secondary":v;return e.createElement(y,{label:n,variant:o?u:d,size:"small",sx:_(_(_({fontWeight:600,minWidth:80},o&&{bgcolor:l,color:f}),!o&&{color:g,bgcolor:c,borderColor:"divider",opacity:.7}),{},{"& .MuiChip-label":{px:1}})})},re=function(n){var o=n.title,l=n.titleVariant,c=void 0===l?"h5":l,s=n.titleFontWeight,u=void 0===s?800:s,m=n.titleColor,d=void 0===m?"text.primary":m,p=n.wrapperStyle,f=void 0===p?{}:p,v=n.titleChip,g=void 0===v?null:v,x=n.createdAt,h=void 0===x?null:x,b=n.updatedAt,E=void 0===b?null:b,y=n.globalActions,C=void 0===y?null:y;return e.createElement(r,{sx:_({},f)},e.createElement(i,{direction:{xs:"column",md:"row"},sx:{mt:2},spacing:3,alignItems:{xs:"flex-start",md:"center"},justifyContent:"space-between"},e.createElement(i,{direction:"row",spacing:3,alignItems:"center"},e.createElement(r,null,e.createElement(i,{direction:"row",spacing:1.5,alignItems:"center",flexWrap:"wrap",sx:{mb:.5}},e.createElement(t,{variant:c,sx:{fontWeight:u,color:d}},o),g),e.createElement(i,{direction:"row",spacing:2,alignItems:"center",divider:e.createElement(r,{sx:{width:4,height:4,borderRadius:"50%",bgcolor:"text.disabled",opacity:.5}})},(h||E)&&e.createElement(i,{direction:"row",spacing:1.5,alignItems:"center",sx:{display:"flex"}},h&&e.createElement(r,{sx:{display:"flex",alignItems:"center",gap:.5}},e.createElement(S,{sx:{fontSize:14,color:"text.disabled"}}),e.createElement(t,{variant:"caption",color:"text.secondary",sx:{lineHeight:1,display:"flex",alignItems:"center"}},H(h))),h&&E&&e.createElement(r,{component:"span",sx:{color:"divider",fontSize:14}},"•"),E&&e.createElement(r,{sx:{display:"flex",alignItems:"center",gap:.5}},e.createElement(z,{sx:{fontSize:14,color:"text.disabled"}}),e.createElement(t,{variant:"caption",color:"text.secondary",sx:{lineHeight:1,display:"flex",alignItems:"center"}},H(E))))))),e.createElement(r,{sx:{alignSelf:{xs:"flex-end",md:"center"}}},C)),e.createElement(a,{sx:{mt:2,opacity:1}}))};export{N as Currency,Z as DocumentIconLink,L as GoBack,Q as IconCard,$ as MouseOverPopup,T as MyChip,re as PageHeader,G as PageTitle,K as PopupMenu,F as ShowErrors,ne as StatusChip,D as StatusIcon,te as UploadFile,M as YesNoChip};
package/hooks/index.js CHANGED
@@ -1 +1 @@
1
- import r from"react";import n from"nprogress";function e(r,n){(null==n||n>r.length)&&(n=r.length);for(var e=0,t=Array(n);e<n;e++)t[e]=r[e];return t}function t(r,n){return function(r){if(Array.isArray(r))return r}(r)||function(r,n){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var t,o,i,s,a=[],p=!0,d=!1;try{if(i=(e=e.call(r)).next,0===n);else for(;!(p=(t=i.call(e)).done)&&(a.push(t.value),a.length!==n);p=!0);}catch(r){d=!0,o=r}finally{try{if(!p&&null!=e.return&&(s=e.return(),Object(s)!==s))return}finally{if(d)throw o}}return a}}(r,n)||function(r,n){if(r){if("string"==typeof r)return e(r,n);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?e(r,n):void 0}}(r,n)||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(r,n){void 0===n&&(n={});var e=n.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===e&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=r:o.appendChild(document.createTextNode(r))}}("#nprogress {\r\n pointer-events: none;\r\n}\r\n\r\n#nprogress .bar {\r\n background: #29d;\r\n position: fixed;\r\n z-index: 99999;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 4px;\r\n}\r\n\r\n/* Fancy blur effect */\r\n#nprogress .peg {\r\n display: block;\r\n position: absolute;\r\n right: 0px;\r\n width: 100px;\r\n height: 100%;\r\n box-shadow: 0 0 10px #29d, 0 0 5px #29d;\r\n opacity: 1.0;\r\n -webkit-transform: rotate(3deg) translate(0px, -4px);\r\n -ms-transform: rotate(3deg) translate(0px, -4px);\r\n transform: rotate(3deg) translate(0px, -4px);\r\n}\r\n\r\n/* Remove these to get rid of the spinner */\r\n#nprogress .spinner {\r\n display: block;\r\n position: fixed;\r\n z-index: 1031;\r\n top: 15px;\r\n right: 15px;\r\n}\r\n\r\n#nprogress .spinner-icon {\r\n width: 18px;\r\n height: 18px;\r\n box-sizing: border-box;\r\n border: solid 2px transparent;\r\n border-top-color: #29d;\r\n border-left-color: #29d;\r\n border-radius: 50%;\r\n -webkit-animation: nprogress-spinner 400ms linear infinite;\r\n animation: nprogress-spinner 400ms linear infinite;\r\n}\r\n\r\n.nprogress-custom-parent {\r\n overflow: hidden;\r\n position: relative;\r\n}\r\n\r\n.nprogress-custom-parent #nprogress .spinner,\r\n.nprogress-custom-parent #nprogress .bar {\r\n position: absolute;\r\n}\r\n\r\n@-webkit-keyframes nprogress-spinner {\r\n 0% {\r\n -webkit-transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n -webkit-transform: rotate(360deg);\r\n }\r\n}\r\n\r\n@keyframes nprogress-spinner {\r\n 0% {\r\n transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n transform: rotate(360deg);\r\n }\r\n}");var o=function(){var e=t(r.useState(!1),2),o=e[0],i=e[1];return{loader:o,startLoader:function(){i(!0),n.start()},stopLoader:function(){i(!1),n.done()}}};export{o as useLoader};
1
+ import r,{useState as n,useCallback as e}from"react";import t from"nprogress";import{router as o}from"@inertiajs/react";function i(r,n){(null==n||n>r.length)&&(n=r.length);for(var e=0,t=Array(n);e<n;e++)t[e]=r[e];return t}function s(r,n,e){return(n=function(r){var n=function(r,n){if("object"!=typeof r||!r)return r;var e=r[Symbol.toPrimitive];if(void 0!==e){var t=e.call(r,n);if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(r)}(r,"string");return"symbol"==typeof n?n:n+""}(n))in r?Object.defineProperty(r,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[n]=e,r}function a(r,n){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable}))),e.push.apply(e,t)}return e}function u(r){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?a(Object(e),!0).forEach((function(n){s(r,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):a(Object(e)).forEach((function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(e,n))}))}return r}function c(r,n){return function(r){if(Array.isArray(r))return r}(r)||function(r,n){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var t,o,i,s,a=[],u=!0,c=!1;try{if(i=(e=e.call(r)).next,0===n);else for(;!(u=(t=i.call(e)).done)&&(a.push(t.value),a.length!==n);u=!0);}catch(r){c=!0,o=r}finally{try{if(!u&&null!=e.return&&(s=e.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}(r,n)||function(r,n){if(r){if("string"==typeof r)return i(r,n);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?i(r,n):void 0}}(r,n)||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(r,n){void 0===n&&(n={});var e=n.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===e&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=r:o.appendChild(document.createTextNode(r))}}("#nprogress {\r\n pointer-events: none;\r\n}\r\n\r\n#nprogress .bar {\r\n background: #29d;\r\n position: fixed;\r\n z-index: 99999;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 4px;\r\n}\r\n\r\n/* Fancy blur effect */\r\n#nprogress .peg {\r\n display: block;\r\n position: absolute;\r\n right: 0px;\r\n width: 100px;\r\n height: 100%;\r\n box-shadow: 0 0 10px #29d, 0 0 5px #29d;\r\n opacity: 1.0;\r\n -webkit-transform: rotate(3deg) translate(0px, -4px);\r\n -ms-transform: rotate(3deg) translate(0px, -4px);\r\n transform: rotate(3deg) translate(0px, -4px);\r\n}\r\n\r\n/* Remove these to get rid of the spinner */\r\n#nprogress .spinner {\r\n display: block;\r\n position: fixed;\r\n z-index: 1031;\r\n top: 15px;\r\n right: 15px;\r\n}\r\n\r\n#nprogress .spinner-icon {\r\n width: 18px;\r\n height: 18px;\r\n box-sizing: border-box;\r\n border: solid 2px transparent;\r\n border-top-color: #29d;\r\n border-left-color: #29d;\r\n border-radius: 50%;\r\n -webkit-animation: nprogress-spinner 400ms linear infinite;\r\n animation: nprogress-spinner 400ms linear infinite;\r\n}\r\n\r\n.nprogress-custom-parent {\r\n overflow: hidden;\r\n position: relative;\r\n}\r\n\r\n.nprogress-custom-parent #nprogress .spinner,\r\n.nprogress-custom-parent #nprogress .bar {\r\n position: absolute;\r\n}\r\n\r\n@-webkit-keyframes nprogress-spinner {\r\n 0% {\r\n -webkit-transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n -webkit-transform: rotate(360deg);\r\n }\r\n}\r\n\r\n@keyframes nprogress-spinner {\r\n 0% {\r\n transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n transform: rotate(360deg);\r\n }\r\n}");var p=function(){var n=c(r.useState(!1),2),e=n[0],o=n[1];return{loader:e,startLoader:function(){o(!0),t.start()},stopLoader:function(){o(!1),t.done()}}},l=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=c(n(!1),2),i=t[0],s=t[1],a=c(n(r),2),p=a[0],l=a[1],f=c(n(!1),2),d=f[0],g=f[1],b=e((function(){l(null),s(!0)}),[]),m=e((function(r){l(r),s(!0)}),[]),y=e((function(){d||(s(!1),l(null))}),[d]);return{isOpen:i,data:p,processing:d,create:b,edit:m,close:y,submit:function(r,n,e){var t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{preserveScroll:!0};g(!0),o[r](n,e,u(u({},t),{},{onFinish:function(){return g(!1)},onSuccess:function(){return y()}}))},isEdit:!!p}},f=function(){var r=c(n(!1),2),t=r[0],i=r[1],s=c(n(null),2),a=s[0],p=s[1],l=c(n(!1),2),f=l[0],d=l[1],g=e((function(){p(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null),i(!0)}),[]),b=e((function(){f||(i(!1),p(null))}),[f]);return{isOpen:t,data:a,processing:f,open:g,close:b,execute:function(r,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{preserveScroll:!0};d(!0),o[r](n,u(u({},e),{},{onSuccess:function(){return b()},onFinish:function(){return d(!1)}}))}}};export{f as useConfirm,p as useLoader,l as useModalForm};
@@ -1 +1 @@
1
- import r,{useState as t,useEffect as e}from"react";import{Alert as n,Snackbar as o,Slide as a,Box as i,Typography as l}from"@mui/material";import{usePage as c}from"@inertiajs/react";var u=function(t){var e=t.errors,o=t.marginBottom,a=void 0===o?3:o;return 0===Object.keys(e).length?null:r.createElement(r.Fragment,null,Object.keys(e).map((function(t,o){return r.createElement(n,{sx:{marginBottom:a},key:o,severity:"error"},e[t])})))},s=function(){var t=c().props,e=t.flash,o=t.errors;return r.createElement(r.Fragment,null,r.createElement(u,{errors:o}),Object.keys(e).map((function(t,o){return e[t]?r.createElement(n,{sx:{marginBottom:3},key:o,severity:t},e[t]):null})))};function f(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function m(){return m=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)({}).hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},m.apply(null,arguments)}function p(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(e=e.call(r)).next,0===t);else for(;!(c=(n=a.call(e)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(r){u=!0,o=r}finally{try{if(!c&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(r,t)||function(r,t){if(r){if("string"==typeof r)return f(r,t);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?f(r,t):void 0}}(r,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.")}()}var d=function(u){var s=u.defaultDirection,f=void 0===s?"left":s,d=c().props.flash,y=p(t(!1),2),v=y[0],b=y[1],g=p(t(""),2),h=g[0],x=g[1],E=p(t("success"),2),w=E[0],j=E[1],O=p(t(f),2),k=O[0],A=O[1];e((function(){var r=d.success?"success":d.error?"error":d.warning?"warning":d.info?"info":null;r&&d[r]&&(A("error"===r?"down":"left"),x(d[r]),j(r),b(!0))}),[d.id]);var S=function(r,t){"clickaway"!==t&&b(!1)};return r.createElement(o,{open:v,autoHideDuration:5e3,onClose:S,anchorOrigin:{vertical:"top",horizontal:"right"},slots:{transition:function(t){return r.createElement(a,m({},t,{direction:k}))}},slotProps:{root:{sx:{mt:"down"===k?0:6}}}},r.createElement(n,{onClose:S,severity:w,variant:"filled",sx:{width:"100%",minWidth:"320px",borderRadius:"16px",backdropFilter:"blur(12px)",backgroundColor:function(r){return"".concat(r.palette[w].main,"E6")},boxShadow:function(r){return"0 12px 32px ".concat(r.palette[w].main,"33")},border:"1px solid rgba(255,255,255,0.1)"}},r.createElement(i,null,r.createElement(l,{variant:"body2",sx:{fontWeight:500}},h))))};export{s as FlashMessages,d as ToastMessages};
1
+ import r,{useState as t,useEffect as e}from"react";import{Alert as n,Snackbar as o,Slide as a,Box as i,Typography as l}from"@mui/material";import{usePage as c}from"@inertiajs/react";var u=function(t){var e=t.errors,o=t.marginBottom,a=void 0===o?3:o;return e?0===Object.keys(e).length?null:r.createElement(r.Fragment,null,Object.keys(e).map((function(t,o){return r.createElement(n,{sx:{marginBottom:a},key:o,severity:"error"},e[t])}))):null},s=function(){var t=c().props,e=t.flash,o=t.errors;return r.createElement(r.Fragment,null,r.createElement(u,{errors:o}),Object.keys(e).map((function(t,o){return e[t]?r.createElement(n,{sx:{marginBottom:3},key:o,severity:t},e[t]):null})))};function f(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function m(){return m=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)({}).hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},m.apply(null,arguments)}function p(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,o,a,i,l=[],c=!0,u=!1;try{if(a=(e=e.call(r)).next,0===t);else for(;!(c=(n=a.call(e)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(r){u=!0,o=r}finally{try{if(!c&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(r,t)||function(r,t){if(r){if("string"==typeof r)return f(r,t);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?f(r,t):void 0}}(r,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.")}()}var d=function(u){var s=u.defaultDirection,f=void 0===s?"left":s,d=c().props.flash,y=p(t(!1),2),v=y[0],b=y[1],g=p(t(""),2),h=g[0],x=g[1],E=p(t("success"),2),w=E[0],j=E[1],O=p(t(f),2),k=O[0],A=O[1];e((function(){var r=d.success?"success":d.error?"error":d.warning?"warning":d.info?"info":null;r&&d[r]&&(A("error"===r?"down":"left"),x(d[r]),j(r),b(!0))}),[d.id]);var S=function(r,t){"clickaway"!==t&&b(!1)};return r.createElement(o,{open:v,autoHideDuration:5e3,onClose:S,anchorOrigin:{vertical:"top",horizontal:"right"},slots:{transition:function(t){return r.createElement(a,m({},t,{direction:k}))}},slotProps:{root:{sx:{mt:"down"===k?0:6}}}},r.createElement(n,{onClose:S,severity:w,variant:"filled",sx:{width:"100%",minWidth:"320px",borderRadius:"16px",backdropFilter:"blur(12px)",backgroundColor:function(r){return"".concat(r.palette[w].main,"E6")},boxShadow:function(r){return"0 12px 32px ".concat(r.palette[w].main,"33")},border:"1px solid rgba(255,255,255,0.1)"}},r.createElement(i,null,r.createElement(l,{variant:"body2",sx:{fontWeight:500}},h))))};export{s as FlashMessages,d as ToastMessages};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artibet/react-mui-components",
3
- "version": "3.7.46",
3
+ "version": "3.8.0",
4
4
  "description": "Various react components build with mui library",
5
5
  "main": "./core/index.js",
6
6
  "scripts": {
package/tables/index.js CHANGED
@@ -1 +1 @@
1
- import{TextField as e,InputAdornment as t,IconButton as n,Typography as r,Tooltip as o,Button as l,Box as i,Select as a,MenuItem as c,Autocomplete as u,TableRow as s,TableCell as f,TableFooter as d,TableContainer as m,Table as p,TableHead as g,TableBody as v,TablePagination as b}from"@mui/material";import h from"react";import{MdClear as y,MdOutlineAdd as C}from"react-icons/md";import"date-fns";import"date-fns/locale";import E from"nprogress";import{TiArrowSortedDown as w,TiArrowSortedUp as S,TiArrowUnsorted as x}from"react-icons/ti";import F from"react-input-mask";import k from"axios";function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function P(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I(){return I=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(null,arguments)}function A(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?A(Object(n),!0).forEach((function(t){P(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l,i,a=[],c=!0,u=!1;try{if(l=(n=n.call(e)).next,0===t);else for(;!(c=(r=l.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}(e,t)||K(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 T(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||K(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function K(e,t){if(e){if("string"==typeof e)return O(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}var R=function(r){var o=r.initialValue,l=r.onChange,i=r.placeholder,a=void 0===i?"":i,c=r.activeColor,u=void 0===c?"#D4F7F4":c,s=r.inactiveColor,f=void 0===s?"white":s,d=r.clearIcon,m=void 0===d||d,p=z(h.useState(o),2),g=p[0],v=p[1];h.useEffect((function(){v(o)}),[o]);return h.createElement(e,{sx:{backgroundColor:g?u:f},placeholder:a,value:g||"",fullWidth:!0,onChange:function(e){v(e.target.value),l(e.target.value)},size:"small",InputProps:{endAdornment:m&&h.createElement(t,{position:"end",disablePointerEvents:!g},h.createElement(n,{onClick:function(){return l("")}},g?h.createElement(y,null):h.createElement(y,{color:"#cccccc"})))}})},D=h.createContext(),B=function(e,t){var n;return function(){for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];n&&clearTimeout(n),n=setTimeout((function(){e.apply(void 0,o)}),t)}},N=function(){var e=h.useContext(D),t=e.state,n=e.props,r=e.api;return n.enableGlobalFilter?h.createElement(R,{initialValue:t.globalFilter,onChange:B(r.handleGlobalFilterChange,300),placeholder:n.globalFilterPlaceholder}):null};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("#nprogress {\r\n pointer-events: none;\r\n}\r\n\r\n#nprogress .bar {\r\n background: #29d;\r\n position: fixed;\r\n z-index: 99999;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 4px;\r\n}\r\n\r\n/* Fancy blur effect */\r\n#nprogress .peg {\r\n display: block;\r\n position: absolute;\r\n right: 0px;\r\n width: 100px;\r\n height: 100%;\r\n box-shadow: 0 0 10px #29d, 0 0 5px #29d;\r\n opacity: 1.0;\r\n -webkit-transform: rotate(3deg) translate(0px, -4px);\r\n -ms-transform: rotate(3deg) translate(0px, -4px);\r\n transform: rotate(3deg) translate(0px, -4px);\r\n}\r\n\r\n/* Remove these to get rid of the spinner */\r\n#nprogress .spinner {\r\n display: block;\r\n position: fixed;\r\n z-index: 1031;\r\n top: 15px;\r\n right: 15px;\r\n}\r\n\r\n#nprogress .spinner-icon {\r\n width: 18px;\r\n height: 18px;\r\n box-sizing: border-box;\r\n border: solid 2px transparent;\r\n border-top-color: #29d;\r\n border-left-color: #29d;\r\n border-radius: 50%;\r\n -webkit-animation: nprogress-spinner 400ms linear infinite;\r\n animation: nprogress-spinner 400ms linear infinite;\r\n}\r\n\r\n.nprogress-custom-parent {\r\n overflow: hidden;\r\n position: relative;\r\n}\r\n\r\n.nprogress-custom-parent #nprogress .spinner,\r\n.nprogress-custom-parent #nprogress .bar {\r\n position: absolute;\r\n}\r\n\r\n@-webkit-keyframes nprogress-spinner {\r\n 0% {\r\n -webkit-transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n -webkit-transform: rotate(360deg);\r\n }\r\n}\r\n\r\n@keyframes nprogress-spinner {\r\n 0% {\r\n transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n transform: rotate(360deg);\r\n }\r\n}");var V=function(){var e=h.useContext(D).props;return h.createElement(r,{variant:"h5",sx:e.titleStyle},e.title)},L=function(){var e=h.useContext(D).props;if(!e.enableCreateRow)return null;return h.createElement(o,{title:e.createButtonTooltip,arrow:!0,placement:"top"},h.createElement(l,{variant:e.createButtonVariant,onClick:function(t){t.currentTarget.blur(),e.onCreateRow(t)}},h.createElement(C,{size:24})))},M=function(){var e=h.useContext(D).props;return e.globalActions?h.createElement(h.Fragment,null,e.globalActions.map((function(e,t){return h.createElement(i,{key:t},e)}))):null},J=function(e){var t,n=e.column;h.useContext(D).props;var r=h.useContext(D).api;return h.createElement(h.Fragment,null,h.createElement(i,{sx:{dispaly:"flex",flexDirection:"column",justifyContent:"start",alignItems:"start"}},h.createElement(i,{sx:{display:"flex",flexDirection:"row",gap:.5,aligntItems:"center",cursor:n.enableSorting?"pointer":"default",justifyContent:"right"===n.align?"end":"center"===n.align?"center":"start"},onClick:n.enableSorting?function(e){return r.toggleSorting(e,n)}:null},h.createElement(i,null,n.label),h.createElement(i,null,n.enableSorting?null!==(t={asc:h.createElement(S,{size:20}),desc:h.createElement(w,{size:20})}[r.getSortingStatus(n)])&&void 0!==t?t:h.createElement(x,{size:20,color:"#cccccc"}):null))))},W=function(r){var o=r.initialValue,l=r.mask,i=void 0===l?"999999":l,a=r.onChange,c=r.placeholder,u=void 0===c?"":c,s=r.activeColor,f=void 0===s?"#D4F7F4":s,d=r.inactiveColor,m=void 0===d?"white":d,p=r.clearIcon,g=void 0===p||p,v=z(h.useState(o),2),b=v[0],C=v[1];h.useEffect((function(){C(o)}),[o]);return h.createElement(F,{mask:i,value:b,onChange:function(e){C((function(t){return t===e.target.value?t:(a(e.target.value),e.target.value)}))},maskChar:""},(function(){return h.createElement(e,{sx:{backgroundColor:b?f:m},placeholder:u,fullWidth:!0,size:"small",InputProps:{endAdornment:g&&h.createElement(t,{position:"end",disablePointerEvents:!b},h.createElement(n,{onClick:function(){return a("")}},b?h.createElement(y,null):h.createElement(y,{color:"#cccccc"})))}})}))},G=function(e){var r=e.value,o=e.options,l=e.onChange,i=e.valueKey,u=void 0===i?"id":i,s=e.labelKey,f=void 0===s?"label":s,d=e.placeholder,m=void 0===d?"":d,p=e.activeColor,g=void 0===p?"#D4F7F4":p,v=e.inactiveColor,b=void 0===v?"white":v,C=e.clearIcon,E=void 0===C||C,w=z(h.useState(-1),2),S=w[0],x=w[1];h.useEffect((function(){x(null===r||""===r?-1:r)}),[r]);return h.createElement(a,{sx:{backgroundColor:-1!==S?g:b,color:-1==S?"#cccccc":""},value:S,fullWidth:!0,onChange:function(e){var t=e.target.value;l(-1!==t?t:"")},size:"small",endAdornment:E&&h.createElement(t,{position:"end",disablePointerEvents:null===r},h.createElement(n,{onClick:function(){return l("")}},-1!==S?h.createElement(y,null):h.createElement(y,{color:"#cccccc"})))},h.createElement(c,{value:-1},m),o.map((function(e){return h.createElement(c,{key:e[u],value:e[u]},e[f])})))},_=["value","options","valueKey","labelKey","onChange","placeholder","activeColor","inactiveColor"],U=function(t){var n=t.value,r=t.options,o=void 0===r?[]:r,l=t.valueKey,i=void 0===l?"id":l;t.labelKey;var a=t.onChange,c=t.placeholder,s=void 0===c?"":c,f=t.activeColor,d=void 0===f?"#D4F7F4":f,m=t.inactiveColor,p=void 0===m?"white":m,g=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(t,_),v=z(h.useState(null),2),b=v[0],y=v[1];return h.useEffect((function(){y(o.find((function(e){return e[i]===n}))||null)}),[n]),h.createElement(u,{value:b,onChange:function(e,t){return a(t?t[i]:null)},options:o,isOptionEqualToValue:function(e,t){return e[i]===t[i]},noOptionsText:"Δεν υπάρχουν επιλογές",size:"small",renderInput:function(t){return h.createElement(e,I({variant:"outlined",fullWidth:!0,placeholder:s,sx:{backgroundColor:null!==b?d:p,color:-1==b?"#cccccc":""},size:"small"},t,g))}})},q=function(e){var t=e.column,n=h.useContext(D),r=n.api,o=n.props,l=r.getColumnFilter(t);return"text"===t.filterType?h.createElement(R,{activeColor:o.filterActiveColor,inactiveColor:o.filterInactiveColor,initialValue:l,onChange:B((function(e){return r.handleColumnFilterChange(t,e)}),300),placeholder:t.filterPlaceholder}):"integer"===t.filterType?h.createElement(W,{activeColor:o.filterActiveColor,inactiveColor:o.filterInactiveColor,initialValue:l,mask:t.filterMask,onChange:B((function(e){return r.handleColumnFilterChange(t,e)}),300),placeholder:t.filterPlaceholder}):"autocomplete"===t.filterType?h.createElement(U,{activeColor:o.filterActiveColor,inactiveColor:o.filterInactiveColor,value:l,valueKey:t.filterValueKey,labelKey:t.filterLabelKey,onChange:function(e){return r.handleColumnFilterChange(t,e)},placeholder:t.filterPlaceholder,options:t.filterOptions}):"select"===t.filterType?h.createElement(G,{activeColor:o.filterActiveColor,inactiveColor:o.filterInactiveColor,value:l,onChange:function(e){return r.handleColumnFilterChange(t,e)},placeholder:t.filterPlaceholder,options:t.filterOptions}):null},Q=function(){var e=h.useContext(D),t=e.props,n=e.state;return h.createElement(h.Fragment,null,h.createElement(s,null,n.columns.map((function(e){return h.createElement(f,{key:e.id,width:e.width,sx:{minWidth:e.minWidth}},h.createElement(J,{column:e}))})),t.rowActions.length>0&&h.createElement(f,null)),t.enableColumnFilters&&h.createElement(s,null,n.columns.map((function(e){return h.createElement(f,{key:e.id},e.enableFilter?h.createElement(q,{column:e}):null)})),t.rowActions.length>0&&h.createElement(f,null)))},H=function(e){var t=e.row,n=h.useContext(D).props;return n.rowActions?h.createElement(f,null,h.createElement(i,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"}},n.rowActions.map((function(e,n){return h.createElement(i,{key:n},e(t))})))):null},$=function(e){var t=e.row,n=h.useContext(D),r=n.props,o=n.state,l=z(h.useState({}),2),i=l[0],a=l[1],c=z(h.useState({}),2),u=c[0],d=c[1];return h.useEffect((function(){r.rowStyle&&a(r.rowStyle(t)),r.cellStyle&&d(r.cellStyle(t))}),[t]),h.createElement(s,{hover:r.rowsClickable,sx:j({cursor:r.rowsClickable?"pointer":"default"},i),onClick:function(){return r.onRowClick&&r.onRowClick(t)}},o.columns.map((function(e){return h.createElement(f,{key:e.id,sx:j(j({},u),{},{textAlign:e.align})},e.render?e.render(t):t[e.id])})),r.rowActions.length>0&&h.createElement(H,{row:t}))},X={id:"",label:"",enableSorting:!0,enableFilter:!0,filterType:"text",filterValueKey:"id",filterLabelKey:"label",filterMark:"999999",filterPlaceholder:"Αναζήτηση",filterOptions:[],style:null,width:"",minWidth:"",align:"left",render:null},Y=function(){var e,t,n=h.useContext(D).state;return null!==(e=n.data)&&void 0!==e&&e.footer&&0!=Object.keys(null===(t=n.data)||void 0===t?void 0:t.footer).length?h.createElement(d,null,h.createElement(s,null,null==n?void 0:n.columns.map((function(e){var t;return h.createElement(f,{key:e.id,align:"right",sx:{fontWeight:"bold",fontSize:14}},null===(t=n.data)||void 0===t?void 0:t.footer[e.id])})))):null},Z={data:[],page:0,page_size:10,total:0},ee=h.forwardRef((function(e,t){var n=e.title,r=e.titleStyle,o=void 0===r?{}:r,l=e.rowStyle,a=void 0===l?null:l,c=e.cellStyle,u=void 0===c?null:c,s=e.tableSize,f=void 0===s?"medium":s,d=e.columns,y=e.dataUrl,C=e.rowKey,w=void 0===C?"id":C,S=e.hasQueryParams,x=void 0!==S&&S,F=e.enableGlobalFilter,O=void 0!==F&&F,P=e.enableColumnFilters,I=void 0!==P&&P,A=e.globalFilterPlaceholder,K=void 0===A?"Καθολική Αναζήτηση":A,R=e.enableCreateRow,B=void 0!==R&&R,J=e.createButtonVariant,W=void 0===J?"contained":J,G=e.createButtonTooltip,_=void 0===G?"Νέα Εγγραφή":G,U=e.onCreateRow,q=void 0===U?null:U,H=e.rowsClickable,ee=void 0!==H&&H,te=e.onRowClick,ne=void 0===te?null:te,re=e.globalActions,oe=void 0===re?[]:re,le=e.rowActions,ie=void 0===le?[]:le,ae=e.keepState,ce=void 0===ae||ae,ue=e.stateKey,se=void 0===ue?null:ue,fe=e.filterActiveColor,de=void 0===fe?"#D4F7F4":fe,me=e.filterInactiveColor,pe=void 0===me?"white":me,ge=e.defaultSorting,ve=void 0===ge?[]:ge,be=e.initialPageSize,he=void 0===be?10:be,ye=e.rowsPerPageLabel,Ce=void 0===ye?"Εγγραφές ανά σελίδα":ye,Ee=e.fromLabel,we=void 0===Ee?"από":Ee,Se=e.toLabel,xe=void 0===Se?"έως":Se,Fe=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".pageIndex")}),[]),ke=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".pageSize")}),[]),Oe=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".sorting")}),[]),Pe=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".globalFilter")}),[]),Ie=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".columnFilters")}),[]),Ae=h.useMemo((function(){return d.map((function(e){return j(j({},X),e)}))})),je=z(h.useState(Z),2),ze=je[0],Te=je[1],Ke=z(h.useState(Oe&&JSON.parse(sessionStorage.getItem(Oe))||ve),2),Re=Ke[0],De=Ke[1],Be=z(h.useState(Pe&&sessionStorage.getItem(Pe)||""),2),Ne=Be[0],Ve=Be[1],Le=z(h.useState(Ie&&JSON.parse(sessionStorage.getItem(Ie))||[]),2),Me=Le[0],Je=Le[1],We=z(h.useState(Fe&&parseInt(sessionStorage.getItem(Fe))||0),2),Ge=We[0],_e=We[1],Ue=z(h.useState(ke&&parseInt(sessionStorage.getItem(ke))||he),2),qe=Ue[0],Qe=Ue[1],He=function(){var e=z(h.useState(!1),2),t=e[0],n=e[1];return{loader:t,startLoader:function(){n(!0),E.start()},stopLoader:function(){n(!1),E.done()}}}(),$e=He.startLoader,Xe=He.stopLoader,Ye=function(e,t,n,r,o){$e();var l=x?"&":"?";k.get("".concat(y).concat(l,"page=").concat(e+1,"&pageSize=").concat(t,"&sorting=").concat(JSON.stringify(n),"&globalFilter=").concat(r,"&columnFilters=").concat(JSON.stringify(o))).then((function(e){Te(e.data),Xe()})).catch((function(e){console.log(e.message),Xe()}))};h.useImperativeHandle(t,(function(){return{updateRow:function(e){Te((function(t){var n=t.data.map((function(t){return t.id===e.id?e:t}));return j(j({},t),{},{data:n})}))},refresh:function(){return Ye(Ge,qe,Re,Ne,Me)},globalFilter:function(){return Ne},columnFilters:function(){return Me},sorting:function(){return Re},queryParams:function(){return"sorting=".concat(JSON.stringify(Re),"&globalFilter=").concat(Ne,"&columnFilters=").concat(JSON.stringify(Me))}}}));var Ze={props:{title:n,titleStyle:o,rowStyle:a,cellStyle:u,tableSize:f,columns:d,dataUrl:y,hasQueryParams:x,enableGlobalFilter:O,enableColumnFilters:I,globalFilterPlaceholder:K,enableCreateRow:B,createButtonVariant:W,createButtonTooltip:_,onCreateRow:q,rowsClickable:ee,onRowClick:ne,globalActions:oe,rowActions:ie,keepState:ce,stateKey:se,filterActiveColor:de,filterInactiveColor:pe,defaultSorting:ve},state:{data:ze,columns:Ae,setData:Te,sorting:Re,setSorting:De,globalFilter:Ne,setGlobalFilter:Ve,columnFilters:Me,setColumnFilters:Je,pageIndex:Ge,setPageIndex:_e,pageSize:qe,setPageSize:Qe},api:{toggleSorting:function(e,t){De((function(n){var r=n.find((function(e){return e.id===t.id})),o=[];r?o=!r.desc?e.altKey?[].concat(T(n.filter((function(e){return e.id!==t.id}))),[{id:t.id,desc:!0}]):[{id:t.id,desc:!0}]:e.altKey?T(n.filter((function(e){return e.id!==t.id}))):[]:o=e.altKey?[].concat(T(n),[{id:t.id,desc:!1}]):[{id:t.id,desc:!1}];return _e(0),Ye(0,qe,o,Ne,Me),o}))},getSortingStatus:function(e){var t=Re.find((function(t){return t.id===e.id}));return t?t.desc?"desc":"asc":null},handleGlobalFilterChange:function(e){Ve(e),_e(0),Ye(0,qe,Re,e,Me)},getColumnFilter:function(e){var t=Me.find((function(t){return t.id===e.id}));return t?t.value:""},handleColumnFilterChange:function(e,t){Je((function(n){var r=[];return r=n.find((function(t){return t.id===e.id}))?t?[].concat(T(n.filter((function(t){return t.id!==e.id}))),[{id:e.id,value:t}]):T(n.filter((function(t){return t.id!==e.id}))):[].concat(T(n),[{id:e.id,value:t}]),_e(0),Ye(0,qe,Re,Ne,r),r}))}}};return h.useEffect((function(){Ye(Ge,qe,Re,Ne,Me)}),[]),h.useEffect((function(){Fe&&sessionStorage.setItem(Fe,Ge)}),[Ge]),h.useEffect((function(){ke&&sessionStorage.setItem(ke,qe)}),[qe]),h.useEffect((function(){Oe&&sessionStorage.setItem(Oe,JSON.stringify(Re))}),[Re]),h.useEffect((function(){Pe&&sessionStorage.setItem(Pe,Ne)}),[Ne]),h.useEffect((function(){Ie&&sessionStorage.setItem(Ie,JSON.stringify(Me))}),[Me]),h.createElement(h.Fragment,null,h.createElement(D.Provider,{value:Ze},h.createElement(i,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},justifyContent:{xs:"top",md:"space-between"},alignItems:{xs:"left",md:"center"},marginBottom:1}},h.createElement(V,null),h.createElement(i,{sx:{display:"flex",gap:2,justifyContent:"end",alignItems:"center",marginTop:{xs:2,md:0}}},h.createElement(N,null),h.createElement(L,null),h.createElement(M,null))),h.createElement(m,null,h.createElement(p,{size:f},h.createElement(g,null,h.createElement(Q,null)),h.createElement(v,null,ze.data.map((function(e,t){return h.createElement($,{key:"__index__"===w?t:e[w],row:e})}))),h.createElement(Y,{footer:null==ze?void 0:ze.footer})))),h.createElement(b,{sx:{marginTop:1,overflow:"hidden"},component:"div",showFirstButton:!0,showLastButton:!0,count:parseInt(ze.total),page:0!=ze.page?ze.page-1:0,rowsPerPage:ze.page_size,onPageChange:function(e,t){return _e(n=t),void Ye(n,qe,Re,Ne,Me);var n},onRowsPerPageChange:function(e){return t=e.target.value,Qe(t),_e(0),void Ye(0,t,Re,Ne,Me);var t},labelDisplayedRows:function(e){return"".concat(e.from," ").concat(xe," ").concat(e.to," ").concat(we," ").concat(e.count)},labelRowsPerPage:Ce}))}));export{ee as ServerSideTable};
1
+ import{TextField as e,InputAdornment as t,IconButton as n,Typography as r,Tooltip as o,Button as l,Box as i,Select as a,MenuItem as c,Autocomplete as u,TableRow as s,TableCell as f,TableFooter as d,TableContainer as m,Table as p,TableHead as g,TableBody as v,TablePagination as b}from"@mui/material";import h from"react";import{MdClear as y,MdOutlineAdd as C}from"react-icons/md";import"date-fns";import"date-fns/locale";import E from"nprogress";import"@inertiajs/react";import{TiArrowSortedDown as w,TiArrowSortedUp as S,TiArrowUnsorted as x}from"react-icons/ti";import F from"react-input-mask";import k from"axios";function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function P(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I(){return I=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(null,arguments)}function A(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?A(Object(n),!0).forEach((function(t){P(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l,i,a=[],c=!0,u=!1;try{if(l=(n=n.call(e)).next,0===t);else for(;!(c=(r=l.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}(e,t)||K(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 T(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||K(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function K(e,t){if(e){if("string"==typeof e)return O(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}var R=function(r){var o=r.initialValue,l=r.onChange,i=r.placeholder,a=void 0===i?"":i,c=r.activeColor,u=void 0===c?"#D4F7F4":c,s=r.inactiveColor,f=void 0===s?"white":s,d=r.clearIcon,m=void 0===d||d,p=z(h.useState(o),2),g=p[0],v=p[1];h.useEffect((function(){v(o)}),[o]);return h.createElement(e,{sx:{backgroundColor:g?u:f},placeholder:a,value:g||"",fullWidth:!0,onChange:function(e){v(e.target.value),l(e.target.value)},size:"small",InputProps:{endAdornment:m&&h.createElement(t,{position:"end",disablePointerEvents:!g},h.createElement(n,{onClick:function(){return l("")}},g?h.createElement(y,null):h.createElement(y,{color:"#cccccc"})))}})},D=h.createContext(),B=function(e,t){var n;return function(){for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];n&&clearTimeout(n),n=setTimeout((function(){e.apply(void 0,o)}),t)}},N=function(){var e=h.useContext(D),t=e.state,n=e.props,r=e.api;return n.enableGlobalFilter?h.createElement(R,{initialValue:t.globalFilter,onChange:B(r.handleGlobalFilterChange,300),placeholder:n.globalFilterPlaceholder}):null};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}("#nprogress {\r\n pointer-events: none;\r\n}\r\n\r\n#nprogress .bar {\r\n background: #29d;\r\n position: fixed;\r\n z-index: 99999;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 4px;\r\n}\r\n\r\n/* Fancy blur effect */\r\n#nprogress .peg {\r\n display: block;\r\n position: absolute;\r\n right: 0px;\r\n width: 100px;\r\n height: 100%;\r\n box-shadow: 0 0 10px #29d, 0 0 5px #29d;\r\n opacity: 1.0;\r\n -webkit-transform: rotate(3deg) translate(0px, -4px);\r\n -ms-transform: rotate(3deg) translate(0px, -4px);\r\n transform: rotate(3deg) translate(0px, -4px);\r\n}\r\n\r\n/* Remove these to get rid of the spinner */\r\n#nprogress .spinner {\r\n display: block;\r\n position: fixed;\r\n z-index: 1031;\r\n top: 15px;\r\n right: 15px;\r\n}\r\n\r\n#nprogress .spinner-icon {\r\n width: 18px;\r\n height: 18px;\r\n box-sizing: border-box;\r\n border: solid 2px transparent;\r\n border-top-color: #29d;\r\n border-left-color: #29d;\r\n border-radius: 50%;\r\n -webkit-animation: nprogress-spinner 400ms linear infinite;\r\n animation: nprogress-spinner 400ms linear infinite;\r\n}\r\n\r\n.nprogress-custom-parent {\r\n overflow: hidden;\r\n position: relative;\r\n}\r\n\r\n.nprogress-custom-parent #nprogress .spinner,\r\n.nprogress-custom-parent #nprogress .bar {\r\n position: absolute;\r\n}\r\n\r\n@-webkit-keyframes nprogress-spinner {\r\n 0% {\r\n -webkit-transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n -webkit-transform: rotate(360deg);\r\n }\r\n}\r\n\r\n@keyframes nprogress-spinner {\r\n 0% {\r\n transform: rotate(0deg);\r\n }\r\n\r\n 100% {\r\n transform: rotate(360deg);\r\n }\r\n}");var V=function(){var e=h.useContext(D).props;return h.createElement(r,{variant:"h5",sx:e.titleStyle},e.title)},L=function(){var e=h.useContext(D).props;if(!e.enableCreateRow)return null;return h.createElement(o,{title:e.createButtonTooltip,arrow:!0,placement:"top"},h.createElement(l,{variant:e.createButtonVariant,onClick:function(t){t.currentTarget.blur(),e.onCreateRow(t)}},h.createElement(C,{size:24})))},M=function(){var e=h.useContext(D).props;return e.globalActions?h.createElement(h.Fragment,null,e.globalActions.map((function(e,t){return h.createElement(i,{key:t},e)}))):null},J=function(e){var t,n=e.column;h.useContext(D).props;var r=h.useContext(D).api;return h.createElement(h.Fragment,null,h.createElement(i,{sx:{dispaly:"flex",flexDirection:"column",justifyContent:"start",alignItems:"start"}},h.createElement(i,{sx:{display:"flex",flexDirection:"row",gap:.5,aligntItems:"center",cursor:n.enableSorting?"pointer":"default",justifyContent:"right"===n.align?"end":"center"===n.align?"center":"start"},onClick:n.enableSorting?function(e){return r.toggleSorting(e,n)}:null},h.createElement(i,null,n.label),h.createElement(i,null,n.enableSorting?null!==(t={asc:h.createElement(S,{size:20}),desc:h.createElement(w,{size:20})}[r.getSortingStatus(n)])&&void 0!==t?t:h.createElement(x,{size:20,color:"#cccccc"}):null))))},W=function(r){var o=r.initialValue,l=r.mask,i=void 0===l?"999999":l,a=r.onChange,c=r.placeholder,u=void 0===c?"":c,s=r.activeColor,f=void 0===s?"#D4F7F4":s,d=r.inactiveColor,m=void 0===d?"white":d,p=r.clearIcon,g=void 0===p||p,v=z(h.useState(o),2),b=v[0],C=v[1];h.useEffect((function(){C(o)}),[o]);return h.createElement(F,{mask:i,value:b,onChange:function(e){C((function(t){return t===e.target.value?t:(a(e.target.value),e.target.value)}))},maskChar:""},(function(){return h.createElement(e,{sx:{backgroundColor:b?f:m},placeholder:u,fullWidth:!0,size:"small",InputProps:{endAdornment:g&&h.createElement(t,{position:"end",disablePointerEvents:!b},h.createElement(n,{onClick:function(){return a("")}},b?h.createElement(y,null):h.createElement(y,{color:"#cccccc"})))}})}))},G=function(e){var r=e.value,o=e.options,l=e.onChange,i=e.valueKey,u=void 0===i?"id":i,s=e.labelKey,f=void 0===s?"label":s,d=e.placeholder,m=void 0===d?"":d,p=e.activeColor,g=void 0===p?"#D4F7F4":p,v=e.inactiveColor,b=void 0===v?"white":v,C=e.clearIcon,E=void 0===C||C,w=z(h.useState(-1),2),S=w[0],x=w[1];h.useEffect((function(){x(null===r||""===r?-1:r)}),[r]);return h.createElement(a,{sx:{backgroundColor:-1!==S?g:b,color:-1==S?"#cccccc":""},value:S,fullWidth:!0,onChange:function(e){var t=e.target.value;l(-1!==t?t:"")},size:"small",endAdornment:E&&h.createElement(t,{position:"end",disablePointerEvents:null===r},h.createElement(n,{onClick:function(){return l("")}},-1!==S?h.createElement(y,null):h.createElement(y,{color:"#cccccc"})))},h.createElement(c,{value:-1},m),o.map((function(e){return h.createElement(c,{key:e[u],value:e[u]},e[f])})))},_=["value","options","valueKey","labelKey","onChange","placeholder","activeColor","inactiveColor"],U=function(t){var n=t.value,r=t.options,o=void 0===r?[]:r,l=t.valueKey,i=void 0===l?"id":l;t.labelKey;var a=t.onChange,c=t.placeholder,s=void 0===c?"":c,f=t.activeColor,d=void 0===f?"#D4F7F4":f,m=t.inactiveColor,p=void 0===m?"white":m,g=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(t,_),v=z(h.useState(null),2),b=v[0],y=v[1];return h.useEffect((function(){y(o.find((function(e){return e[i]===n}))||null)}),[n]),h.createElement(u,{value:b,onChange:function(e,t){return a(t?t[i]:null)},options:o,isOptionEqualToValue:function(e,t){return e[i]===t[i]},noOptionsText:"Δεν υπάρχουν επιλογές",size:"small",renderInput:function(t){return h.createElement(e,I({variant:"outlined",fullWidth:!0,placeholder:s,sx:{backgroundColor:null!==b?d:p,color:-1==b?"#cccccc":""},size:"small"},t,g))}})},q=function(e){var t=e.column,n=h.useContext(D),r=n.api,o=n.props,l=r.getColumnFilter(t);return"text"===t.filterType?h.createElement(R,{activeColor:o.filterActiveColor,inactiveColor:o.filterInactiveColor,initialValue:l,onChange:B((function(e){return r.handleColumnFilterChange(t,e)}),300),placeholder:t.filterPlaceholder}):"integer"===t.filterType?h.createElement(W,{activeColor:o.filterActiveColor,inactiveColor:o.filterInactiveColor,initialValue:l,mask:t.filterMask,onChange:B((function(e){return r.handleColumnFilterChange(t,e)}),300),placeholder:t.filterPlaceholder}):"autocomplete"===t.filterType?h.createElement(U,{activeColor:o.filterActiveColor,inactiveColor:o.filterInactiveColor,value:l,valueKey:t.filterValueKey,labelKey:t.filterLabelKey,onChange:function(e){return r.handleColumnFilterChange(t,e)},placeholder:t.filterPlaceholder,options:t.filterOptions}):"select"===t.filterType?h.createElement(G,{activeColor:o.filterActiveColor,inactiveColor:o.filterInactiveColor,value:l,onChange:function(e){return r.handleColumnFilterChange(t,e)},placeholder:t.filterPlaceholder,options:t.filterOptions}):null},Q=function(){var e=h.useContext(D),t=e.props,n=e.state;return h.createElement(h.Fragment,null,h.createElement(s,null,n.columns.map((function(e){return h.createElement(f,{key:e.id,width:e.width,sx:{minWidth:e.minWidth}},h.createElement(J,{column:e}))})),t.rowActions.length>0&&h.createElement(f,null)),t.enableColumnFilters&&h.createElement(s,null,n.columns.map((function(e){return h.createElement(f,{key:e.id},e.enableFilter?h.createElement(q,{column:e}):null)})),t.rowActions.length>0&&h.createElement(f,null)))},H=function(e){var t=e.row,n=h.useContext(D).props;return n.rowActions?h.createElement(f,null,h.createElement(i,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"}},n.rowActions.map((function(e,n){return h.createElement(i,{key:n},e(t))})))):null},$=function(e){var t=e.row,n=h.useContext(D),r=n.props,o=n.state,l=z(h.useState({}),2),i=l[0],a=l[1],c=z(h.useState({}),2),u=c[0],d=c[1];return h.useEffect((function(){r.rowStyle&&a(r.rowStyle(t)),r.cellStyle&&d(r.cellStyle(t))}),[t]),h.createElement(s,{hover:r.rowsClickable,sx:j({cursor:r.rowsClickable?"pointer":"default"},i),onClick:function(){return r.onRowClick&&r.onRowClick(t)}},o.columns.map((function(e){return h.createElement(f,{key:e.id,sx:j(j({},u),{},{textAlign:e.align})},e.render?e.render(t):t[e.id])})),r.rowActions.length>0&&h.createElement(H,{row:t}))},X={id:"",label:"",enableSorting:!0,enableFilter:!0,filterType:"text",filterValueKey:"id",filterLabelKey:"label",filterMark:"999999",filterPlaceholder:"Αναζήτηση",filterOptions:[],style:null,width:"",minWidth:"",align:"left",render:null},Y=function(){var e,t,n=h.useContext(D).state;return null!==(e=n.data)&&void 0!==e&&e.footer&&0!=Object.keys(null===(t=n.data)||void 0===t?void 0:t.footer).length?h.createElement(d,null,h.createElement(s,null,null==n?void 0:n.columns.map((function(e){var t;return h.createElement(f,{key:e.id,align:"right",sx:{fontWeight:"bold",fontSize:14}},null===(t=n.data)||void 0===t?void 0:t.footer[e.id])})))):null},Z={data:[],page:0,page_size:10,total:0},ee=h.forwardRef((function(e,t){var n=e.title,r=e.titleStyle,o=void 0===r?{}:r,l=e.rowStyle,a=void 0===l?null:l,c=e.cellStyle,u=void 0===c?null:c,s=e.tableSize,f=void 0===s?"medium":s,d=e.columns,y=e.dataUrl,C=e.rowKey,w=void 0===C?"id":C,S=e.hasQueryParams,x=void 0!==S&&S,F=e.enableGlobalFilter,O=void 0!==F&&F,P=e.enableColumnFilters,I=void 0!==P&&P,A=e.globalFilterPlaceholder,K=void 0===A?"Καθολική Αναζήτηση":A,R=e.enableCreateRow,B=void 0!==R&&R,J=e.createButtonVariant,W=void 0===J?"contained":J,G=e.createButtonTooltip,_=void 0===G?"Νέα Εγγραφή":G,U=e.onCreateRow,q=void 0===U?null:U,H=e.rowsClickable,ee=void 0!==H&&H,te=e.onRowClick,ne=void 0===te?null:te,re=e.globalActions,oe=void 0===re?[]:re,le=e.rowActions,ie=void 0===le?[]:le,ae=e.keepState,ce=void 0===ae||ae,ue=e.stateKey,se=void 0===ue?null:ue,fe=e.filterActiveColor,de=void 0===fe?"#D4F7F4":fe,me=e.filterInactiveColor,pe=void 0===me?"white":me,ge=e.defaultSorting,ve=void 0===ge?[]:ge,be=e.initialPageSize,he=void 0===be?10:be,ye=e.rowsPerPageLabel,Ce=void 0===ye?"Εγγραφές ανά σελίδα":ye,Ee=e.fromLabel,we=void 0===Ee?"από":Ee,Se=e.toLabel,xe=void 0===Se?"έως":Se,Fe=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".pageIndex")}),[]),ke=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".pageSize")}),[]),Oe=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".sorting")}),[]),Pe=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".globalFilter")}),[]),Ie=h.useMemo((function(){return!(!ce||!se)&&"".concat(se,".columnFilters")}),[]),Ae=h.useMemo((function(){return d.map((function(e){return j(j({},X),e)}))})),je=z(h.useState(Z),2),ze=je[0],Te=je[1],Ke=z(h.useState(Oe&&JSON.parse(sessionStorage.getItem(Oe))||ve),2),Re=Ke[0],De=Ke[1],Be=z(h.useState(Pe&&sessionStorage.getItem(Pe)||""),2),Ne=Be[0],Ve=Be[1],Le=z(h.useState(Ie&&JSON.parse(sessionStorage.getItem(Ie))||[]),2),Me=Le[0],Je=Le[1],We=z(h.useState(Fe&&parseInt(sessionStorage.getItem(Fe))||0),2),Ge=We[0],_e=We[1],Ue=z(h.useState(ke&&parseInt(sessionStorage.getItem(ke))||he),2),qe=Ue[0],Qe=Ue[1],He=function(){var e=z(h.useState(!1),2),t=e[0],n=e[1];return{loader:t,startLoader:function(){n(!0),E.start()},stopLoader:function(){n(!1),E.done()}}}(),$e=He.startLoader,Xe=He.stopLoader,Ye=function(e,t,n,r,o){$e();var l=x?"&":"?";k.get("".concat(y).concat(l,"page=").concat(e+1,"&pageSize=").concat(t,"&sorting=").concat(JSON.stringify(n),"&globalFilter=").concat(r,"&columnFilters=").concat(JSON.stringify(o))).then((function(e){Te(e.data),Xe()})).catch((function(e){console.log(e.message),Xe()}))};h.useImperativeHandle(t,(function(){return{updateRow:function(e){Te((function(t){var n=t.data.map((function(t){return t.id===e.id?e:t}));return j(j({},t),{},{data:n})}))},refresh:function(){return Ye(Ge,qe,Re,Ne,Me)},globalFilter:function(){return Ne},columnFilters:function(){return Me},sorting:function(){return Re},queryParams:function(){return"sorting=".concat(JSON.stringify(Re),"&globalFilter=").concat(Ne,"&columnFilters=").concat(JSON.stringify(Me))}}}));var Ze={props:{title:n,titleStyle:o,rowStyle:a,cellStyle:u,tableSize:f,columns:d,dataUrl:y,hasQueryParams:x,enableGlobalFilter:O,enableColumnFilters:I,globalFilterPlaceholder:K,enableCreateRow:B,createButtonVariant:W,createButtonTooltip:_,onCreateRow:q,rowsClickable:ee,onRowClick:ne,globalActions:oe,rowActions:ie,keepState:ce,stateKey:se,filterActiveColor:de,filterInactiveColor:pe,defaultSorting:ve},state:{data:ze,columns:Ae,setData:Te,sorting:Re,setSorting:De,globalFilter:Ne,setGlobalFilter:Ve,columnFilters:Me,setColumnFilters:Je,pageIndex:Ge,setPageIndex:_e,pageSize:qe,setPageSize:Qe},api:{toggleSorting:function(e,t){De((function(n){var r=n.find((function(e){return e.id===t.id})),o=[];r?o=!r.desc?e.altKey?[].concat(T(n.filter((function(e){return e.id!==t.id}))),[{id:t.id,desc:!0}]):[{id:t.id,desc:!0}]:e.altKey?T(n.filter((function(e){return e.id!==t.id}))):[]:o=e.altKey?[].concat(T(n),[{id:t.id,desc:!1}]):[{id:t.id,desc:!1}];return _e(0),Ye(0,qe,o,Ne,Me),o}))},getSortingStatus:function(e){var t=Re.find((function(t){return t.id===e.id}));return t?t.desc?"desc":"asc":null},handleGlobalFilterChange:function(e){Ve(e),_e(0),Ye(0,qe,Re,e,Me)},getColumnFilter:function(e){var t=Me.find((function(t){return t.id===e.id}));return t?t.value:""},handleColumnFilterChange:function(e,t){Je((function(n){var r=[];return r=n.find((function(t){return t.id===e.id}))?t?[].concat(T(n.filter((function(t){return t.id!==e.id}))),[{id:e.id,value:t}]):T(n.filter((function(t){return t.id!==e.id}))):[].concat(T(n),[{id:e.id,value:t}]),_e(0),Ye(0,qe,Re,Ne,r),r}))}}};return h.useEffect((function(){Ye(Ge,qe,Re,Ne,Me)}),[]),h.useEffect((function(){Fe&&sessionStorage.setItem(Fe,Ge)}),[Ge]),h.useEffect((function(){ke&&sessionStorage.setItem(ke,qe)}),[qe]),h.useEffect((function(){Oe&&sessionStorage.setItem(Oe,JSON.stringify(Re))}),[Re]),h.useEffect((function(){Pe&&sessionStorage.setItem(Pe,Ne)}),[Ne]),h.useEffect((function(){Ie&&sessionStorage.setItem(Ie,JSON.stringify(Me))}),[Me]),h.createElement(h.Fragment,null,h.createElement(D.Provider,{value:Ze},h.createElement(i,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},justifyContent:{xs:"top",md:"space-between"},alignItems:{xs:"left",md:"center"},marginBottom:1}},h.createElement(V,null),h.createElement(i,{sx:{display:"flex",gap:2,justifyContent:"end",alignItems:"center",marginTop:{xs:2,md:0}}},h.createElement(N,null),h.createElement(L,null),h.createElement(M,null))),h.createElement(m,null,h.createElement(p,{size:f},h.createElement(g,null,h.createElement(Q,null)),h.createElement(v,null,ze.data.map((function(e,t){return h.createElement($,{key:"__index__"===w?t:e[w],row:e})}))),h.createElement(Y,{footer:null==ze?void 0:ze.footer})))),h.createElement(b,{sx:{marginTop:1,overflow:"hidden"},component:"div",showFirstButton:!0,showLastButton:!0,count:parseInt(ze.total),page:0!=ze.page?ze.page-1:0,rowsPerPage:ze.page_size,onPageChange:function(e,t){return _e(n=t),void Ye(n,qe,Re,Ne,Me);var n},onRowsPerPageChange:function(e){return t=e.target.value,Qe(t),_e(0),void Ye(0,t,Re,Ne,Me);var t},labelDisplayedRows:function(e){return"".concat(e.from," ").concat(xe," ").concat(e.to," ").concat(we," ").concat(e.count)},labelRowsPerPage:Ce}))}));export{ee as ServerSideTable};