moorr-react-mui 0.2.113 → 0.2.115

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.
Files changed (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1 +1 @@
1
- import e,{useEffect as t,createContext as n,useContext as o,useState as l,useRef as r,useCallback as i}from"react";import{utils as a}from"moorr-common";import s from"@material-ui/core/MenuItem";import{makeStyles as c,createStyles as d,withStyles as u,StylesProvider as m}from"@material-ui/core/styles";import h from"@material-ui/core/TextField";import{StylesProvider as g,Modal as p,Backdrop as f,Fade as v}from"@material-ui/core";import{createGenerateClassName as E,StylesProvider as y}from"@material-ui/styles";import{v4 as b}from"uuid";import w,{Responsive as C}from"react-grid-layout";import N from"@mui/material/Accordion";import T from"@mui/material/AccordionSummary";import x from"@mui/material/AccordionDetails";import P from"@mui/icons-material/ExpandMore";import M from"react-dom";import{Slide as k}from"@mui/material";import{toast as F}from"react-toastify";import A from"@mui/icons-material/Cancel";import I from"@mui/icons-material/Close";const L=({type:n,label:o})=>(t((()=>(console.log(`Message from moorr-react-mui: ${a.hello()}`),()=>{console.log(`Message from moorr-react-mui: ${a.bye()}`)})),[]),n||(n="button"),e.createElement("button",{type:n,className:"moorr-button"},e.createElement("span",null,o))),B=e=>({root:{"&:hover:not($disabled):not($focused):not($error) $notchedOutline":{},"&$checked":{color:"var(--primary-color)"},"& .vldt-MuiSelect-select.vldt-MuiSelect-select":{color:"var(--grey-color-2)"}},disabled:{},focused:{},error:{},notchedOutline:{},checked:{},notchedOutlineMBRequired:{flex:3,borderColor:"blue",borderWidth:2},fieldSetMBRequired:{"& fieldset":{flex:3,borderColor:"blue",borderWidth:2}},fieldSetErrorField:{"& fieldset":{borderColor:"var(--error-color)"}},blue:{color:"blue"}});c(B);const S=c((()=>d({root:{overflow:"hidden",display:"flex",alignItems:"center","&.start":{flexDirection:"row"},"&.top":{flexDirection:"column"},"& .Mui-disabled":{backgroundColor:"var(--grey-color-3)",cursor:"not-allowed",borderRadius:"4px"}},label:{flex:2},field:{flex:3},required:{color:"red"},menuItem:{color:"var(--grey-color-2)","&:hover":{backgroundColor:"var(--primary-color-scale-25)",color:"var(--grey-color-2)"}},menuItemSelected:{color:"var(--grey-color-2)"},mandatory:{border:"red 2px solid",borderRadius:"4px"}})));var G=u(B)((({handleChange:t,value:n,disabled:o=!1,name:l,className:r,classes:i,size:a,menuItemLabel:c,options:d,labelPlacement:u="start",label:m,required:g=!1,isMBRequiredField:p,fullWidth:f,selectIconComponent:v})=>{const{root:E,focused:y,error:b,notchedOutline:w,notchedOutlineMBRequired:C}=i,N=S();let T;return v&&(T={IconComponent:v}),e.createElement(h,{fullWidth:!1!==f,id:"outlined-basic",variant:"outlined",value:n,onChange:t,disabled:o,name:l,className:[r].join(" "),InputProps:{classes:{root:E,focused:y,error:b,notchedOutline:!p||n&&0!==(null==n?void 0:n.length)?!g||n&&0!==(null==n?void 0:n.length)?w:N.mandatory:C}},color:"primary",size:a||"small",select:!0,SelectProps:T,defaultValue:""},e.createElement(s,{value:"",disabled:!0},e.createElement("em",null,c)),d&&d.map(((t,n)=>"-separator-"===t?e.createElement(s,{key:`separator-${n}`,value:"",disabled:!0},e.createElement("em",null,"-----------")):e.createElement(s,{key:`menu-item-${n}-${t.value||t}`,value:t.value||t},t.label||t))))}));const $={};function D(e,t){e&&t&&($[e]=t)}const H=({className:t,icon:n,width:o,height:l,fill:r,stroke:i,accent:s,dropShadow:c})=>{if(a.isNullOrUndefined(n))return null;const d=$[n]||null;return d?e.createElement(d,{className:t,fill:r,width:o,height:l,stroke:i,accent:s,dropShadow:c}):null},O={};var _=({stylePrefix:t,children:n})=>{let o;if(t)o=O[t]?O[t]:O[t]=E({seed:t});else{const e=`MoorrStylesProvider-${b()}-`;o=E({seed:e})}return e.createElement(y,{generateClassName:o,injectFirst:!0},e.createElement(g,{generateClassName:o,injectFirst:!0},e.createElement(m,{generateClassName:o},n)))};const W=n({});function U(){return o(W)}const z={};function R(e,t){e&&t&&(z[e]=t)}const j=({graphingTile:t,graphingTileIndex:n})=>{var o;if(!(null===(o=null==t?void 0:t.tile)||void 0===o?void 0:o.tileType))return null;const l=z[t.tile.tileType]||null;return l?e.createElement(l,{graphingTile:t,graphingTileIndex:n}):null},q=[20,20],V={lg:600,sm:0},Z={lg:8,sm:2},K=({tilePrefix:n,responsive:o,columns:i,containerPadding:a,referenceMargin:s,referenceWidth:c,graphingTiles:d})=>{const[u,m]=l(null),[h,g]=l(null),[p,f]=l(null),[v,E]=l(null),y=r(null),b=()=>{const e=(null==y?void 0:y.current)?(null==y?void 0:y.current).getBoundingClientRect().width:null;E(e);const t=P(e);m(t)};let N;const T=e=>{b(),clearTimeout(N),N=setTimeout((()=>{b()}),300)};t((()=>{b()}),[y]),t((()=>(window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)})),[]),t((()=>{if(o){if(!Array.isArray(d)||0===d.length)return void f({lg:[]});f({lg:d.map(((e,t)=>({x:e.x,y:e.y,w:isNaN(e.w)?1:e.w,h:isNaN(e.h)?1:e.h,i:`${n?n+"_":""}tile_${t}`})))})}else{if(!Array.isArray(d)||0===d.length)return void g([]);g(d.map(((e,t)=>({x:e.x,y:e.y,w:isNaN(e.w)?1:e.w,h:isNaN(e.h)?1:e.h,i:`${n?n+"_":""}tile_${t}`,static:!0}))))}}),[d]);const x=()=>null==d?void 0:d.map(((t,o)=>{if(!t.tile||!t.visible)return null;let l="graphing-tile-container";!1!==t.border&&(l+=" bordered"),t.autoHeight&&(l+=" auto-height");const r=`${n?n+"_":""}tile_${o}`;return e.createElement("div",{className:l,key:r},e.createElement(j,{graphingTile:t,graphingTileIndex:o}))})),P=e=>{if(!s||isNaN(s)||s<=0||!c||isNaN(c)||c<=0||null==e)return q;const t=e/c*s;return[t,t]};return e.createElement("div",{ref:y,className:"graphing-tiles-container"},(()=>{if(!v||!u)return null;if(!1!==o){if(!p)return null;const t=[a||0,0];return e.createElement(C,{width:v,breakpoints:V,cols:i||Z,rowHeight:1,layouts:p,containerPadding:t,margin:u,isDraggable:!1},x())}return h?e.createElement(w,{width:v,cols:9,rowHeight:50,margin:u,isDraggable:!1,layout:h},x()):null})())},J={};function Q(e,t){J[e]=t}function X(e){const t=J[null==e?void 0:e.tileType];return t?new t(e):null}function Y(e){const t=[];return e.forEach((e=>{const n=X(e);n&&t.push(n)})),t}class ee{constructor(e){this.x=e.x,this.y=e.y,this.w=e.w,this.h=e.h,this.border=!0===e.border,this.background=e.background||null,this.autoHeight=!0===e.autoHeight,this.tile=X(e.tile),this.visible=!1!==e.visible}getBackground(){return this.background||"#FFFFFF"}}class te{constructor(e){this.title=e.title||"",this.infoIconUrl=e.infoUrl,this.infoIconHref=e.infoHref,this.responsive=!1!==e.responsive,this.columns=e.columns||{lg:8,sm:2},this.containerPadding=e.containerPadding||0,this.referenceMargin=e.referenceMargin||null,this.referenceWidth=e.referenceWidth||null,this.tiles=[],Array.isArray(e.tiles)&&e.tiles.forEach((e=>{this.tiles.push(new ee(e))}))}}const ne={};function oe(e,t){ne[e]=t}function le(e){const t=ne[null==e?void 0:e.controlType];return t?new t(e):null}function re(e){const t=[];return e.forEach((e=>{const n=le(e);n&&t.push(n)})),t}class ie{constructor(e){this.controlType=e.controlType,this.dataKey=e.dataKey}}class ae extends ie{constructor(e){super(e),this.inputLabel=e.inputLabel||"",this.readOnly=!0===e.readOnly,this.readOnlyBorderless=!0===e.readOnlyBorderless,this.hasAsAtDate=!1===e.hasAsAtDate||!0===e.hasAsAtDate?e.hasAsAtDate:null,this.staticAsAtDate=!0===e.staticAsAtDate,this.validationSchemaPath=(a.isArray(e.validationSchemaPath)?e.validationSchemaPath:[]).filter((e=>a.isString(e))),this.validationErrorMessages=e.validationErrorMessages||{}}}class se{constructor(e){this.border=e.border,this.background=e.background||null,this.control=le(e.control)}getBackground(e){return this.background||(null==e?void 0:e.background)||"#FFFFFF"}}class ce{constructor(e){this.id=e.id||"",this.title=e.title||"",this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new se(e))})),this.add=!0===e.add}}class de{constructor(e){this.tileType=e.tileType}}class ue extends de{constructor(e){super(e),this.control=new se(e.control)}}class me extends de{constructor(e){super(e),this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new se(e))}))}}class he extends de{constructor(e){super(e),a.isArray(e.formGroups)&&e.formGroups.length>0?this.formGroups=e.formGroups.map((e=>new ce(e))):this.formGroups=[]}}Q("form-groups-tile",he);class ge extends me{constructor(e){super(e),this.controlsPerPage=e.controlsPerPage,(isNaN(this.controlsPerPage)||this.controlsPerPage<=1)&&(this.controlsPerPage=1)}}Q("horizontal-tile",ge);class pe extends me{constructor(e){super(e),this.states={};for(const t in e.states){const n=e.states[t];n&&(this.states[t]=new te(n))}}}Q("selectable-states-tile",pe);class fe extends de{constructor(e){super(e),this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new se(e))}))}}Q("simple-form-tile",fe);class ve extends ue{constructor(e){super(e)}}Q("single-tile",ve);class Ee extends me{constructor(e){super(e)}}Q("vertical-tile",Ee);const ye=({})=>{const{settings:n}=U(),[o,r]=l(null),[i,s]=l(!1);t((()=>{setTimeout((()=>{window.dispatchEvent(new Event("resize")),setTimeout((()=>{s(!0)}),300)}),300)}),[]),t((()=>{r(n?new te(n):null)}),[n]);const c=()=>(null==n?void 0:n.infoIconUrl)&&n.infoIconHref?e.createElement("a",{className:"information-anchor",href:n.infoIconHref,target:"_blank"},e.createElement("img",{alt:null==n?void 0:n.title,src:null==n?void 0:n.infoIconUrl})):null;if(!o)return null;let d="graphing-grid-container";return i&&(d+=" in"),e.createElement(e.Fragment,null,e.createElement("div",{className:d},a.isNullOrUndefined(null==n?void 0:n.title)?null:e.createElement(e.Fragment,null,e.createElement("h2",{className:"graphing-grid-title"},null==n?void 0:n.title,c()),e.createElement("hr",{className:"graphing-grid-hr"})),e.createElement(K,{graphingTiles:o.tiles,responsive:o.responsive,columns:o.columns,containerPadding:o.containerPadding,referenceMargin:o.referenceMargin,referenceWidth:o.referenceWidth})))},be={};function we(e,t){e&&t&&(be[e]=t)}const Ce=({graphingTile:t,graphingTileIndex:n,graphingTileControl:o,ControlProps:l})=>{var r;if(!(null===(r=null==o?void 0:o.control)||void 0===r?void 0:r.controlType))return null;const i=be[o.control.controlType]||null;return i?e.createElement(i,Object.assign({graphingTile:t,graphingTileIndex:n,graphingTileControl:o},l)):null},Ne=({graphingTile:t,graphingTileIndex:n,graphingTileControls:o,ControlProps:l})=>{var r,i;let a="graphing-tile-controls-container";return(null===(r=null==t?void 0:t.tile)||void 0===r?void 0:r.tileType)&&(a+=" "+(null===(i=null==t?void 0:t.tile)||void 0===i?void 0:i.tileType)),e.createElement("div",{className:a},null==o?void 0:o.map(((o,r)=>{var i,a;if(!o.control)return null;let s="graphing-tile-control-container";(null===(i=o.control)||void 0===i?void 0:i.controlType)&&(s+=" "+(null===(a=o.control)||void 0===a?void 0:a.controlType)),!1!==o.border&&(s+=" bordered");const c=`control_${n}_${r}`;return e.createElement("div",{className:s,key:c},e.createElement(Ce,{graphingTile:t,graphingTileIndex:n,graphingTileControl:o,ControlProps:l}))})))};function Te(e,t,n,o){return new(n||(n=Promise))((function(l,r){function i(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?l(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}s((o=o.apply(e,t||[])).next())}))}const xe=({graphingTile:n,graphingTileIndex:o})=>{const s=null==n?void 0:n.tile;if(!s)return null;const c=U();return e.createElement("div",{className:"form-groups-tile-component"},!a.isArray(s.formGroups)||s.formGroups.length<0?null:s.formGroups.map(((s,d)=>{const u=r(null),[m,h]=l("normal"),[g,p]=l("form-group-container");t((()=>{b()}),[g,m]);const[f,v]=l(0),[E,y]=l(!0);t((()=>{if(E){const e=u.current;a.isNullOrUndefined(e)?v(0):setTimeout((()=>{v(e.scrollHeight)}),10)}else v(0)}),[E]);const b=e=>{if(E){const e=u.current;a.isNullOrUndefined(e)?v(0):setTimeout((()=>{v(Math.max(e.clientHeight,e.scrollHeight))}),10)}else v(0)},w=i((()=>!0!==s.add||a.isFunction(c.formGroupHasAddMode)&&!c.formGroupHasAddMode(s.id)?null:e.createElement("button",{type:"button",className:"form-group-tile-add-button",onClick:C,disabled:"add"==m},e.createElement(H,{icon:"add-icon",stroke:"#ffffff"}))),[m,c.formGroupHasAddMode]);i((()=>"add"===m?null:e.createElement("svg",{viewBox:"0 0 11 8",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M5.89844 1.1626L10.4688 5.70947C10.6797 5.94385 10.6797 6.29541 10.4688 6.50635L9.92969 7.04541C9.71875 7.25635 9.36719 7.25635 9.13281 7.04541L5.5 3.43603L1.89063 7.04541C1.65625 7.25635 1.30469 7.25635 1.09375 7.04541L0.554688 6.50635C0.34375 6.29541 0.34375 5.94385 0.554688 5.70947L5.125 1.1626C5.33594 0.95166 5.6875 0.95166 5.89844 1.1626Z",fill:"#333333"}))),[m]);const C=e=>{e.stopPropagation(),h("add"),y(!0)},M=e=>Te(void 0,void 0,void 0,(function*(){a.isFunction(null==c?void 0:c.handleFormGroupCancel)&&(yield Promise.all([null==c?void 0:c.handleFormGroupCancel({formGroup:s})])),h("normal")})),[k,F]=l(!1),A=e=>Te(void 0,void 0,void 0,(function*(){if(a.isFunction(null==c?void 0:c.handleFormGroupSave))try{F(!0);const[e]=yield Promise.all([null==c?void 0:c.handleFormGroupSave({formGroup:s})]);if(!1===e)return}finally{F(!1)}h("normal")}));let I="form-group-container";return a.isFunction(c.isFormGroupVisible)&&(c.isFormGroupVisible(s.id)||(I+=" hidden")),I!==g&&p(I),e.createElement(N,{key:`${s.id}-{${d}}`,className:I,expanded:E,onChange:e=>{"add"!==m&&y((e=>!e))},TransitionProps:{unmountOnExit:!0}},e.createElement(T,{className:"form-group-title",expandIcon:"add"!==m?e.createElement(P,null):null},e.createElement("span",{className:"form-group-title-text"},s.title),w()),e.createElement("hr",null),e.createElement(x,{className:"form-group-components"},(()=>{if("add"===m){let t;return a.isFunction(c.renderFormGroup)&&(t=c.renderFormGroup(s,"add")),e.createElement(e.Fragment,null,t,e.createElement("hr",null),e.createElement("div",{className:"form-group-add-mode-buttons"},e.createElement("button",{className:"cancel-button",disabled:k,onClick:M},"Cancel"),e.createElement("button",{className:"save-button",disabled:k,onClick:A},"Create")))}{const t=s.controls;let l;return a.isFunction(c.renderFormGroup)&&(l=c.renderFormGroup(s,"normal"),!a.isNullOrUndefined(l))?l:e.createElement(Ne,{graphingTile:n,graphingTileIndex:o,graphingTileControls:t,ControlProps:{onUIChange:b}})}})()))})))};R("form-groups-tile",xe);const Pe=({graphingTile:n,graphingTileIndex:o})=>{const r=null==n?void 0:n.tile;if(!r)return null;const[i,a]=l(null),[s,c]=l(0),[d,u]=l(0),[m,h]=l(null),[g,p]=l(null),[f,v]=l(null),[E,y]=l([]);t((()=>{let e=[];const t=Math.ceil(r.controls.length/r.controlsPerPage);if(t>0)for(let n=0;n<t;n++){const t={pageIndex:n,controls:[]};for(let e=0;e<r.controlsPerPage;e++){const o=n*r.controlsPerPage+e;if(o>=r.controls.length)break;t.controls.push(r.controls[o])}e.push(t)}c(t),u(0),h(null),p(null),v(null),y(e)}),r.controls);const b=e=>{let t=e-1;t<0&&(t=s-1),p(t)},w=e=>{e.stopPropagation(),b(d),v(null),h(null)},C=e=>{e.stopPropagation()},N=e=>{e.stopPropagation()},T=e=>{if(e.stopPropagation(),null!==i)return;const t=d;let n=d-1;n<0&&(n=s-1),h(t),u(n),p(null),v(t);const o=setTimeout((()=>{b(n),v(null),h(null),setTimeout((function(){a(null)}),300)}),300);a(o)},x=e=>{let t=e+1;t>=s&&(t=0),v(t)},P=e=>{e.stopPropagation(),p(null),x(d),h(null)},M=e=>{e.stopPropagation()},k=e=>{e.stopPropagation()},F=e=>{if(e.stopPropagation(),null!==i)return;const t=d;let n=d+1;n>=s&&(n=0),h(t),u(n),p(t),v(null);const o=setTimeout((()=>{p(null),x(n),h(null),setTimeout((function(){a(null)}),300)}),300);a(o)},A={background:n.getBackground()};return e.createElement("div",{className:"horizontal-tile-component",style:A},e.createElement("div",{className:"horizontal-tile-pages-container"},E.map(((t,l)=>{let r="horizontal-tile-page-container";return l===d?r+=" active":l===g?r+=" navigating-from-left":l===f&&(r+=" navigating-from-right"),l===m&&(r+=" previous"),e.createElement("div",{className:r},e.createElement(Ne,{graphingTile:n,graphingTileIndex:o,graphingTileControls:t.controls}))})),e.createElement("div",{className:"horizontal-tile-page-container background",style:A}),s<=1?null:e.createElement(e.Fragment,null,e.createElement("button",{type:"button",className:"navigate-button navigate-left-button",onMouseEnter:w,onMouseLeave:C,onMouseDown:N,onClick:T},e.createElement("svg",{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M7.40991 10.643L2.82991 6.05298L7.40991 1.46298L5.99991 0.0529785L-8.80003e-05 6.05298L5.99991 12.053L7.40991 10.643Z",fill:"#828282"}))),e.createElement("button",{type:"button",className:"navigate-button navigate-right-button",onMouseEnter:P,onMouseLeave:M,onMouseDown:k,onClick:F},e.createElement("svg",{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M0.589843 1.46298L5.16984 6.05298L0.589844 10.643L1.99984 12.053L7.99984 6.05298L1.99984 0.0529785L0.589843 1.46298Z",fill:"#828282"}))))),s<=1?null:e.createElement("div",{className:"horizontal-tile-paginators-container"},Array.from(Array(s).keys()).map((t=>{let n="paginator-anchor";return t===d&&(n+=" active"),e.createElement("a",{className:n,onMouseEnter:e=>{e.stopPropagation(),t!==d&&(t<d?(p(t),v(null)):(p(null),v(t)),h(null))},onMouseLeave:e=>{e.stopPropagation()},onMouseDown:e=>{e.stopPropagation()},onClick:e=>{if(e.stopPropagation(),t===d)return;const n=d,o=t;h(n),u(o),n<o?p(n):v(n)}})}))))};R("horizontal-tile",Pe);const Me=({graphingTile:n})=>{const o=null==n?void 0:n.tile;if(!o)return null;const[r,i]=l(""),[a,s]=l(null),[c,d]=l([]),u=U();t((()=>{const e=Object.keys(o.states);if(d(e.map((e=>{var t;return{label:null===(t=o.states[e])||void 0===t?void 0:t.title,value:e}}))),e&&e.length>0){const t=e[0];m(t)}else i(""),s(null)}),[o.states]);const m=e=>{i(e),s(o.states[e])};return e.createElement("div",{className:"selectable-states-tile-component"},e.createElement("div",{className:"selectable-states-tile-header"},e.createElement("div",{className:"selected-state-tile-title"},e.createElement("h6",null,null==a?void 0:a.title)),e.createElement("div",{className:"selectable-states-dropdown-container"},e.createElement(G,{options:c,label:"Select",value:r,handleChange:e=>{var t;m(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value),(null==u?void 0:u.handleSelectableStatesTileChange)&&(null==u||u.handleSelectableStatesTileChange(e))}}))),e.createElement("div",{className:"selected-state-tile-container"},a?e.createElement(K,{tilePrefix:r,graphingTiles:a.tiles,responsive:a.responsive,columns:a.columns,containerPadding:a.containerPadding,referenceMargin:a.referenceMargin,referenceWidth:a.referenceWidth}):null))};R("selectable-states-tile",Me);const ke=({graphingTile:t,graphingTileIndex:n})=>{const o=null==t?void 0:t.tile;if(!o)return null;const l=U(),r=e=>{a.isFunction(l.handleUIChange)&&l.handleUIChange(e)};return e.createElement("div",{className:"simple-form-tile-component"},(()=>{if(!a.isArray(o.controls)||o.controls.length<0)return null;const l=o.controls;return e.createElement(Ne,{graphingTile:t,graphingTileIndex:n,graphingTileControls:l,ControlProps:{onUIChange:r}})})())};R("simple-form-tile",ke);const Fe=({graphingTile:t,graphingTileIndex:n})=>{const o=null==t?void 0:t.tile;if(!o)return null;const l=[o.control],r={background:t.getBackground()};return e.createElement("div",{className:"single-tile-component",style:r},e.createElement(Ne,{graphingTile:t,graphingTileIndex:n,graphingTileControls:l}))};R("single-tile",Fe);const Ae=({graphingTile:t,graphingTileIndex:n})=>{const o=null==t?void 0:t.tile;if(!o)return null;const l=o.controls;return e.createElement("div",{className:"vertical-tile-component"},e.createElement(Ne,{graphingTile:t,graphingTileIndex:n,graphingTileControls:l}))};R("vertical-tile",Ae);const Ie=()=>{const e=Be.pop();e&&(e.classList.add("moorr-modal-container-closing"),setTimeout((()=>{e&&(M.unmountComponentAtNode(e),e.remove())}),300))};let Le=class{constructor(e){this._props=e}open(){const t=this._props;return new Promise(((n,o)=>{let l,r;"function"==typeof t.onClose&&(l=t.onClose),t.onClose=e=>{l&&l(e),n({dismissed:!1,result:e}),t.showModal=!1,Ie()},"function"==typeof t.onDismiss&&(r=t.onClose),t.onDismiss=()=>{r&&r(),n({dismissed:!0}),t.showModal=!1,Ie()},t.showModal=!0;let i=e.createElement(_,{stylePrefix:"MoorrReactMuiModal"},e.createElement(this.getComponent(),t));Be.push(this._container=document.createElement("div")),this._container.className="moorr-modal-container",document.body.appendChild(this._container),M.render(i,this._container)}))}};const Be=[],Se={},Ge=c((e=>({modal:{display:"flex",alignItems:"center",justifyContent:"center"},paper:{width:825,backgroundColor:e.palette.background.paper,borderRadius:"5px",boxShadow:e.shadows[5],padding:e.spacing(2,4,3)}}))),$e=n=>{const o=Ge(),r={};n.fixedWidth&&(r.width=n.fixedWidth),n.fixedHeight&&(r.height=n.fixedHeight);let i=o.paper+" moorr-modal-content-container";n.contentClassName&&(i+=" "+n.contentClassName);const[s,c]=l(!1),[d,u]=l(!1);t((()=>{u(!s&&!1!==n.showModal)}),[s,d,n.showModal]);const m=e=>{c(!0),(null==n?void 0:n.onDismiss)&&n.onDismiss(e)};let h=o.modal;switch(h+=" moorr-modal-container",n.effect){case"fade":h+=" moorr-fade-modal";break;case"slide":h+=" moorr-slide-modal"}return s&&(h+=" moorr-modal-closing"),e.createElement(p,{disableEnforceFocus:!0,className:h,open:d,onClose:m,closeAfterTransition:!0,BackdropComponent:f,BackdropProps:{timeout:300,onClick:e=>{e.preventDefault(),e.stopPropagation(),a.isFunction(n.onBackdropClick)?n.onBackdropClick(e):m("backdrop")}}},(()=>{switch(n.effect){case"fade":default:return e.createElement(v,{in:d},e.createElement("div",{className:i,style:r},n.children));case"slide":return e.createElement(k,{in:d,direction:"left",timeout:300},e.createElement("div",{className:i},n.children))}})())},De=(t,n)=>{(t=>{F(t,{icon:e.createElement(A,{sx:{color:"#EB5757"}}),style:{color:"#EB5757",backgroundColor:"#FCECEC",border:"2px solid #EB5757",fontFamily:'"Poppins", sans-serif',borderRadius:"0.7em",marginLeft:"-100px"},closeButton:()=>e.createElement(I,{sx:{color:"#EB5757"}})})})(n)},He=t=>e.createElement($e,{effect:"fade",contentClassName:`${t.className}-content-container`,fixedWidth:t.widthValue,fixedHeight:t.heightValue,showModal:t.showModal,onClose:t.onClose,onDismiss:t.onDismiss,onBackdropClick:t.onBackdropClick},e.createElement("div",{className:`${t.className} moorr-modal-container`},e.createElement("div",{className:"moorr-modal-header"},t.renderHeader),e.createElement("div",{className:"moorr-modal-body"},t.renderBody),!1===t.hasFooter?null:e.createElement("div",{className:"moorr-modal-footer"},e.createElement("div",{className:"left-buttons"},t.renderLeftButtons),e.createElement("div",{className:"status-message"},t.renderStatusMessage),e.createElement("div",{className:"right-buttons"},t.renderRightButtons)))),Oe=e=>{var t,n,o,l,r;const i=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.modal;if(!i||!Se[i])return Promise.reject("invalid-modal");const a=new Se[i]((null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.props)||{}).open();(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.then)&&a.then((t=>{var n,o;if(!(null==t?void 0:t.dismissed)&&(null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.finally))try{null===(o=null==e?void 0:e.detail)||void 0===o||o.then(null==t?void 0:t.result)}catch(e){console.error(e)}})),(null===(l=null==e?void 0:e.detail)||void 0===l?void 0:l.catch)&&a.catch(null===(r=null==e?void 0:e.detail)||void 0===r?void 0:r.catch),a.finally((()=>{var t,n;if(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.finally)try{null===(n=null==e?void 0:e.detail)||void 0===n||n.finally()}catch(e){console.error(e)}})),(null==e?void 0:e.detail)&&((null==e?void 0:e.detail).promise=a)};document&&(document.removeEventListener("openModal",Oe),document.addEventListener("openModal",Oe));export{L as Button,G as Dropdown,He as FadeModal,ce as FormGroupModel,xe as FormGroupsTile,he as FormGroupsTileModel,ae as FormInputModel,W as GraphingContext,Ce as GraphingControl,ie as GraphingControlModel,se as GraphingControlSettingsModel,ye as GraphingGrid,te as GraphingSettingsModel,j as GraphingTile,Ne as GraphingTileControls,de as GraphingTileModel,ee as GraphingTileSettingsModel,K as GraphingTiles,Pe as HorizontalTile,ge as HorizontalTileModel,Le as Modal,$e as MoorrModal,me as MultipleControlsTileModel,Me as SelectableStatesTile,pe as SelectableStatesTileModel,ke as SimpleFormTile,fe as SimpleFormTileModel,ue as SingleControlTileModel,Fe as SingleTile,ve as SingleTileModel,_ as StylesProvider,H as SvgIcon,Ae as VerticalTile,Ee as VerticalTileModel,le as createGraphingControl,re as createGraphingControls,X as createGraphingTile,Y as createGraphingTiles,Se as modals,Be as modalsStack,oe as registerGraphingControl,we as registerGraphingControlComponent,Q as registerGraphingTile,R as registerGraphingTileComponent,D as registerSvgIconComponent,De as toastMessage,U as useGraphingContext};
1
+ import e,{useEffect as t,createContext as n,useContext as o,useState as l,useRef as r,useCallback as i}from"react";import{utils as a}from"moorr-common";import s from"@material-ui/core/MenuItem";import{makeStyles as c,createStyles as d,withStyles as u,StylesProvider as m}from"@material-ui/core/styles";import h from"@material-ui/core/TextField";import{StylesProvider as g,Modal as p,Backdrop as f,Fade as v}from"@material-ui/core";import{createGenerateClassName as E,StylesProvider as y}from"@material-ui/styles";import{v4 as b}from"uuid";import w,{Responsive as C}from"react-grid-layout";import N from"@mui/material/Accordion";import T from"@mui/material/AccordionSummary";import x from"@mui/material/AccordionDetails";import P from"@mui/icons-material/ExpandMore";import M from"react-dom";import{Slide as k}from"@mui/material";import{toast as F}from"react-toastify";import A from"@mui/icons-material/Cancel";import I from"@mui/icons-material/Close";const L=({type:n,label:o})=>(t((()=>(console.log(`Message from moorr-react-mui: ${a.hello()}`),()=>{console.log(`Message from moorr-react-mui: ${a.bye()}`)})),[]),n||(n="button"),e.createElement("button",{type:n,className:"moorr-button"},e.createElement("span",null,o))),B=e=>({root:{"&:hover:not($disabled):not($focused):not($error) $notchedOutline":{},"&$checked":{color:"var(--primary-color)"},"& .vldt-MuiSelect-select.vldt-MuiSelect-select":{color:"var(--grey-color-2)"}},disabled:{},focused:{},error:{},notchedOutline:{},checked:{},notchedOutlineMBRequired:{flex:3,borderColor:"blue",borderWidth:2},fieldSetMBRequired:{"& fieldset":{flex:3,borderColor:"blue",borderWidth:2}},fieldSetErrorField:{"& fieldset":{borderColor:"var(--error-color)"}},blue:{color:"blue"}});c(B);const S=c((()=>d({root:{overflow:"hidden",display:"flex",alignItems:"center","&.start":{flexDirection:"row"},"&.top":{flexDirection:"column"},"& .Mui-disabled":{backgroundColor:"var(--grey-color-3)",cursor:"not-allowed",borderRadius:"4px"}},label:{flex:2},field:{flex:3},required:{color:"red"},menuItem:{color:"var(--grey-color-2)","&:hover":{backgroundColor:"var(--primary-color-scale-25)",color:"var(--grey-color-2)"}},menuItemSelected:{color:"var(--grey-color-2)"},mandatory:{border:"red 2px solid",borderRadius:"4px"}})));var G=u(B)((({handleChange:t,value:n,disabled:o=!1,name:l,className:r,classes:i,size:a,menuItemLabel:c,options:d,labelPlacement:u="start",label:m,required:g=!1,isMBRequiredField:p,fullWidth:f,selectIconComponent:v})=>{const{root:E,focused:y,error:b,notchedOutline:w,notchedOutlineMBRequired:C}=i,N=S();let T;return v&&(T={IconComponent:v}),e.createElement(h,{fullWidth:!1!==f,id:"outlined-basic",variant:"outlined",value:n,onChange:t,disabled:o,name:l,className:[r].join(" "),InputProps:{classes:{root:E,focused:y,error:b,notchedOutline:!p||n&&0!==(null==n?void 0:n.length)?!g||n&&0!==(null==n?void 0:n.length)?w:N.mandatory:C}},color:"primary",size:a||"small",select:!0,SelectProps:T,defaultValue:""},e.createElement(s,{value:"",disabled:!0},e.createElement("em",null,c)),d&&d.map(((t,n)=>"-separator-"===t?e.createElement(s,{key:`separator-${n}`,value:"",disabled:!0},e.createElement("em",null,"-----------")):e.createElement(s,{key:`menu-item-${n}-${t.value||t}`,value:t.value||t},t.label||t))))}));const $={};function D(e,t){e&&t&&($[e]=t)}const H=({className:t,icon:n,width:o,height:l,fill:r,stroke:i,accent:s,dropShadow:c})=>{if(a.isNullOrUndefined(n))return null;const d=$[n]||null;return d?e.createElement(d,{className:t,fill:r,width:o,height:l,stroke:i,accent:s,dropShadow:c}):null},O={};var _=({stylePrefix:t,children:n})=>{let o;if(t)o=O[t]?O[t]:O[t]=E({seed:t});else{const e=`MoorrStylesProvider-${b()}-`;o=E({seed:e})}return e.createElement(y,{generateClassName:o,injectFirst:!0},e.createElement(g,{generateClassName:o,injectFirst:!0},e.createElement(m,{generateClassName:o},n)))};const W=n({});function U(){return o(W)}const z={};function R(e,t){e&&t&&(z[e]=t)}const j=({graphingTile:t,graphingTileIndex:n})=>{var o;if(!(null===(o=null==t?void 0:t.tile)||void 0===o?void 0:o.tileType))return null;const l=z[t.tile.tileType]||null;return l?e.createElement(l,{graphingTile:t,graphingTileIndex:n}):null},q=[20,20],V={lg:600,sm:0},Z={lg:8,sm:2},K=({tilePrefix:n,responsive:o,columns:i,containerPadding:a,referenceMargin:s,referenceWidth:c,graphingTiles:d})=>{const[u,m]=l(null),[h,g]=l(null),[p,f]=l(null),[v,E]=l(null),y=r(null),b=()=>{const e=(null==y?void 0:y.current)?(null==y?void 0:y.current).getBoundingClientRect().width:null;E(e);const t=P(e);m(t)};let N;const T=e=>{b(),clearTimeout(N),N=setTimeout((()=>{b()}),300)};t((()=>{b()}),[y]),t((()=>(window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)})),[]),t((()=>{if(o){if(!Array.isArray(d)||0===d.length)return void f({lg:[]});f({lg:d.map(((e,t)=>({x:e.x,y:e.y,w:isNaN(e.w)?1:e.w,h:isNaN(e.h)?1:e.h,i:`${n?n+"_":""}tile_${t}`})))})}else{if(!Array.isArray(d)||0===d.length)return void g([]);g(d.map(((e,t)=>({x:e.x,y:e.y,w:isNaN(e.w)?1:e.w,h:isNaN(e.h)?1:e.h,i:`${n?n+"_":""}tile_${t}`,static:!0}))))}}),[d]);const x=()=>null==d?void 0:d.map(((t,o)=>{if(!t.tile||!t.visible)return null;let l="graphing-tile-container";!1!==t.border&&(l+=" bordered"),t.autoHeight&&(l+=" auto-height");const r=`${n?n+"_":""}tile_${o}`;return e.createElement("div",{className:l,key:r},e.createElement(j,{graphingTile:t,graphingTileIndex:o}))})),P=e=>{if(!s||isNaN(s)||s<=0||!c||isNaN(c)||c<=0||null==e)return q;const t=e/c*s;return[t,t]};return e.createElement("div",{ref:y,className:"graphing-tiles-container"},(()=>{if(!v||!u)return null;if(!1!==o){if(!p)return null;const t=[a||0,0];return e.createElement(C,{width:v,breakpoints:V,cols:i||Z,rowHeight:1,layouts:p,containerPadding:t,margin:u,isDraggable:!1},x())}return h?e.createElement(w,{width:v,cols:9,rowHeight:50,margin:u,isDraggable:!1,layout:h},x()):null})())},J={};function Q(e,t){J[e]=t}function X(e){const t=J[null==e?void 0:e.tileType];return t?new t(e):null}function Y(e){const t=[];return e.forEach((e=>{const n=X(e);n&&t.push(n)})),t}class ee{constructor(e){this.x=e.x,this.y=e.y,this.w=e.w,this.h=e.h,this.border=!0===e.border,this.background=e.background||null,this.autoHeight=!0===e.autoHeight,this.tile=X(e.tile),this.visible=!1!==e.visible}getBackground(){return this.background||"#FFFFFF"}}class te{constructor(e){this.title=e.title||"",this.infoIconUrl=e.infoUrl,this.infoIconHref=e.infoHref,this.responsive=!1!==e.responsive,this.columns=e.columns||{lg:8,sm:2},this.containerPadding=e.containerPadding||0,this.referenceMargin=e.referenceMargin||null,this.referenceWidth=e.referenceWidth||null,this.tiles=[],Array.isArray(e.tiles)&&e.tiles.forEach((e=>{this.tiles.push(new ee(e))}))}}const ne={};function oe(e,t){ne[e]=t}function le(e){const t=ne[null==e?void 0:e.controlType];return t?new t(e):null}function re(e){const t=[];return e.forEach((e=>{const n=le(e);n&&t.push(n)})),t}class ie{constructor(e){this.controlType=e.controlType,this.dataKey=e.dataKey}}class ae extends ie{constructor(e){super(e),this.inputLabel=e.inputLabel||"",this.readOnly=!0===e.readOnly,this.readOnlyBorderless=!0===e.readOnlyBorderless,this.hasAsAtDate=!1===e.hasAsAtDate||!0===e.hasAsAtDate?e.hasAsAtDate:null,this.staticAsAtDate=!0===e.staticAsAtDate,this.validationSchemaPath=(a.isArray(e.validationSchemaPath)?e.validationSchemaPath:[]).filter((e=>a.isString(e))),this.validationErrorMessages=e.validationErrorMessages||{}}}class se{constructor(e){this.border=e.border,this.background=e.background||null,this.control=le(e.control)}getBackground(e){return this.background||(null==e?void 0:e.background)||"#FFFFFF"}}class ce{constructor(e){this.id=e.id||"",this.title=e.title||"",this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new se(e))})),this.add=!0===e.add}}class de{constructor(e){this.tileType=e.tileType}}class ue extends de{constructor(e){super(e),this.control=new se(e.control)}}class me extends de{constructor(e){super(e),this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new se(e))}))}}class he extends de{constructor(e){super(e),a.isArray(e.formGroups)&&e.formGroups.length>0?this.formGroups=e.formGroups.map((e=>new ce(e))):this.formGroups=[]}}Q("form-groups-tile",he);class ge extends me{constructor(e){super(e),this.controlsPerPage=e.controlsPerPage,(isNaN(this.controlsPerPage)||this.controlsPerPage<=1)&&(this.controlsPerPage=1)}}Q("horizontal-tile",ge);class pe extends me{constructor(e){super(e),this.states={};for(const t in e.states){const n=e.states[t];n&&(this.states[t]=new te(n))}}}Q("selectable-states-tile",pe);class fe extends de{constructor(e){super(e),this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new se(e))}))}}Q("simple-form-tile",fe);class ve extends ue{constructor(e){super(e)}}Q("single-tile",ve);class Ee extends me{constructor(e){super(e)}}Q("vertical-tile",Ee);const ye=({})=>{const{settings:n}=U(),[o,r]=l(null),[i,s]=l(!1);t((()=>{setTimeout((()=>{window.dispatchEvent(new Event("resize")),setTimeout((()=>{s(!0)}),300)}),300)}),[]),t((()=>{r(n?new te(n):null)}),[n]);const c=()=>(null==n?void 0:n.infoIconUrl)&&n.infoIconHref?e.createElement("a",{className:"information-anchor",href:n.infoIconHref,target:"_blank"},e.createElement("img",{alt:null==n?void 0:n.title,src:null==n?void 0:n.infoIconUrl})):null;if(!o)return null;let d="graphing-grid-container";return i&&(d+=" in"),e.createElement(e.Fragment,null,e.createElement("div",{className:d},a.isNullOrUndefined(null==n?void 0:n.title)?null:e.createElement(e.Fragment,null,e.createElement("h2",{className:"graphing-grid-title"},null==n?void 0:n.title,c()),e.createElement("hr",{className:"graphing-grid-hr"})),e.createElement(K,{graphingTiles:o.tiles,responsive:o.responsive,columns:o.columns,containerPadding:o.containerPadding,referenceMargin:o.referenceMargin,referenceWidth:o.referenceWidth})))},be={};function we(e,t){e&&t&&(be[e]=t)}const Ce=({graphingTile:t,graphingTileIndex:n,graphingTileControl:o,ControlProps:l})=>{var r;if(!(null===(r=null==o?void 0:o.control)||void 0===r?void 0:r.controlType))return null;const i=be[o.control.controlType]||null;return i?e.createElement(i,Object.assign({graphingTile:t,graphingTileIndex:n,graphingTileControl:o},l)):null},Ne=({graphingTile:t,graphingTileIndex:n,graphingTileControls:o,ControlProps:l})=>{var r,i;let a="graphing-tile-controls-container";return(null===(r=null==t?void 0:t.tile)||void 0===r?void 0:r.tileType)&&(a+=" "+(null===(i=null==t?void 0:t.tile)||void 0===i?void 0:i.tileType)),e.createElement("div",{className:a},null==o?void 0:o.map(((o,r)=>{var i,a;if(!o.control)return null;let s="graphing-tile-control-container";(null===(i=o.control)||void 0===i?void 0:i.controlType)&&(s+=" "+(null===(a=o.control)||void 0===a?void 0:a.controlType)),!1!==o.border&&(s+=" bordered");const c=`control_${n}_${r}`;return e.createElement("div",{className:s,key:c},e.createElement(Ce,{graphingTile:t,graphingTileIndex:n,graphingTileControl:o,ControlProps:l}))})))};function Te(e,t,n,o){return new(n||(n=Promise))((function(l,r){function i(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?l(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}s((o=o.apply(e,t||[])).next())}))}const xe=({graphingTile:n,graphingTileIndex:o})=>{const s=null==n?void 0:n.tile;if(!s)return null;const c=U();return e.createElement("div",{className:"form-groups-tile-component"},!a.isArray(s.formGroups)||s.formGroups.length<0?null:s.formGroups.map(((s,d)=>{const u=r(null),[m,h]=l("normal"),[g,p]=l("form-group-container");t((()=>{b()}),[g,m]);const[f,v]=l(0),[E,y]=l(!0);t((()=>{if(E){const e=u.current;a.isNullOrUndefined(e)?v(0):setTimeout((()=>{v(e.scrollHeight)}),10)}else v(0)}),[E]);const b=e=>{if(E){const e=u.current;a.isNullOrUndefined(e)?v(0):setTimeout((()=>{v(Math.max(e.clientHeight,e.scrollHeight))}),10)}else v(0)},w=i((()=>!0!==s.add||a.isFunction(c.formGroupHasAddMode)&&!c.formGroupHasAddMode(s.id)?null:e.createElement("button",{type:"button",className:"form-group-tile-add-button",onClick:C,disabled:"add"==m},e.createElement(H,{icon:"add-icon",stroke:"#ffffff"}))),[m,c.formGroupHasAddMode]);i((()=>"add"===m?null:e.createElement("svg",{viewBox:"0 0 11 8",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M5.89844 1.1626L10.4688 5.70947C10.6797 5.94385 10.6797 6.29541 10.4688 6.50635L9.92969 7.04541C9.71875 7.25635 9.36719 7.25635 9.13281 7.04541L5.5 3.43603L1.89063 7.04541C1.65625 7.25635 1.30469 7.25635 1.09375 7.04541L0.554688 6.50635C0.34375 6.29541 0.34375 5.94385 0.554688 5.70947L5.125 1.1626C5.33594 0.95166 5.6875 0.95166 5.89844 1.1626Z",fill:"#333333"}))),[m]);const C=e=>{e.stopPropagation(),h("add"),y(!0)},M=e=>Te(void 0,void 0,void 0,(function*(){a.isFunction(null==c?void 0:c.handleFormGroupCancel)&&(yield Promise.all([null==c?void 0:c.handleFormGroupCancel({formGroup:s})])),h("normal")})),[k,F]=l(!1),A=e=>Te(void 0,void 0,void 0,(function*(){if(a.isFunction(null==c?void 0:c.handleFormGroupSave))try{F(!0);const[e]=yield Promise.all([null==c?void 0:c.handleFormGroupSave({formGroup:s})]);if(!1===e)return}finally{F(!1)}h("normal")}));let I="form-group-container";return a.isFunction(c.isFormGroupVisible)&&(c.isFormGroupVisible(s.id)||(I+=" hidden")),I!==g&&p(I),e.createElement(N,{key:`${s.id}-{${d}}`,className:I,expanded:E,onChange:e=>{"add"!==m&&y((e=>!e))},TransitionProps:{unmountOnExit:!0}},e.createElement(T,{className:"form-group-title",expandIcon:"add"!==m?e.createElement(P,null):null},e.createElement("span",{className:"form-group-title-text"},s.title),w()),e.createElement("hr",null),e.createElement(x,{className:"form-group-components"},(()=>{if("add"===m){let t;return a.isFunction(c.renderFormGroup)&&(t=c.renderFormGroup(s,"add")),e.createElement(e.Fragment,null,t,e.createElement("hr",null),e.createElement("div",{className:"form-group-add-mode-buttons"},e.createElement("button",{className:"cancel-button",disabled:k,onClick:M},"Cancel"),e.createElement("button",{className:"save-button",disabled:k,onClick:A},"Create")))}{const t=s.controls;let l;return a.isFunction(c.renderFormGroup)&&(l=c.renderFormGroup(s,"normal"),!a.isNullOrUndefined(l))?l:e.createElement(Ne,{graphingTile:n,graphingTileIndex:o,graphingTileControls:t,ControlProps:{onUIChange:b}})}})()))})))};R("form-groups-tile",xe);const Pe=({graphingTile:n,graphingTileIndex:o})=>{const r=null==n?void 0:n.tile;if(!r)return null;const[i,a]=l(null),[s,c]=l(0),[d,u]=l(0),[m,h]=l(null),[g,p]=l(null),[f,v]=l(null),[E,y]=l([]);t((()=>{let e=[];const t=Math.ceil(r.controls.length/r.controlsPerPage);if(t>0)for(let n=0;n<t;n++){const t={pageIndex:n,controls:[]};for(let e=0;e<r.controlsPerPage;e++){const o=n*r.controlsPerPage+e;if(o>=r.controls.length)break;t.controls.push(r.controls[o])}e.push(t)}c(t),u(0),h(null),p(null),v(null),y(e)}),r.controls);const b=e=>{let t=e-1;t<0&&(t=s-1),p(t)},w=e=>{e.stopPropagation(),b(d),v(null),h(null)},C=e=>{e.stopPropagation()},N=e=>{e.stopPropagation()},T=e=>{if(e.stopPropagation(),null!==i)return;const t=d;let n=d-1;n<0&&(n=s-1),h(t),u(n),p(null),v(t);const o=setTimeout((()=>{b(n),v(null),h(null),setTimeout((function(){a(null)}),300)}),300);a(o)},x=e=>{let t=e+1;t>=s&&(t=0),v(t)},P=e=>{e.stopPropagation(),p(null),x(d),h(null)},M=e=>{e.stopPropagation()},k=e=>{e.stopPropagation()},F=e=>{if(e.stopPropagation(),null!==i)return;const t=d;let n=d+1;n>=s&&(n=0),h(t),u(n),p(t),v(null);const o=setTimeout((()=>{p(null),x(n),h(null),setTimeout((function(){a(null)}),300)}),300);a(o)},A={background:n.getBackground()};return e.createElement("div",{className:"horizontal-tile-component",style:A},e.createElement("div",{className:"horizontal-tile-pages-container"},E.map(((t,l)=>{let r="horizontal-tile-page-container";return l===d?r+=" active":l===g?r+=" navigating-from-left":l===f&&(r+=" navigating-from-right"),l===m&&(r+=" previous"),e.createElement("div",{className:r},e.createElement(Ne,{graphingTile:n,graphingTileIndex:o,graphingTileControls:t.controls}))})),e.createElement("div",{className:"horizontal-tile-page-container background",style:A}),s<=1?null:e.createElement(e.Fragment,null,e.createElement("button",{type:"button",className:"navigate-button navigate-left-button",onMouseEnter:w,onMouseLeave:C,onMouseDown:N,onClick:T},e.createElement("svg",{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M7.40991 10.643L2.82991 6.05298L7.40991 1.46298L5.99991 0.0529785L-8.80003e-05 6.05298L5.99991 12.053L7.40991 10.643Z",fill:"#828282"}))),e.createElement("button",{type:"button",className:"navigate-button navigate-right-button",onMouseEnter:P,onMouseLeave:M,onMouseDown:k,onClick:F},e.createElement("svg",{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M0.589843 1.46298L5.16984 6.05298L0.589844 10.643L1.99984 12.053L7.99984 6.05298L1.99984 0.0529785L0.589843 1.46298Z",fill:"#828282"}))))),s<=1?null:e.createElement("div",{className:"horizontal-tile-paginators-container"},Array.from(Array(s).keys()).map((t=>{let n="paginator-anchor";return t===d&&(n+=" active"),e.createElement("a",{className:n,onMouseEnter:e=>{e.stopPropagation(),t!==d&&(t<d?(p(t),v(null)):(p(null),v(t)),h(null))},onMouseLeave:e=>{e.stopPropagation()},onMouseDown:e=>{e.stopPropagation()},onClick:e=>{if(e.stopPropagation(),t===d)return;const n=d,o=t;h(n),u(o),n<o?p(n):v(n)}})}))))};R("horizontal-tile",Pe);const Me=({graphingTile:n})=>{const o=null==n?void 0:n.tile;if(!o)return null;const[r,i]=l(""),[a,s]=l(null),[c,d]=l([]),u=U();t((()=>{const e=Object.keys(o.states);if(d(e.map((e=>{var t;return{label:null===(t=o.states[e])||void 0===t?void 0:t.title,value:e}}))),e&&e.length>0){const t=e[0];m(t)}else i(""),s(null)}),[o.states]);const m=e=>{i(e),s(o.states[e])};return e.createElement("div",{className:"selectable-states-tile-component"},e.createElement("div",{className:"selectable-states-tile-header"},e.createElement("div",{className:"selected-state-tile-title"},e.createElement("h6",null,null==a?void 0:a.title)),e.createElement("div",{className:"selectable-states-dropdown-container"},e.createElement(G,{options:c,label:"Select",value:r,handleChange:e=>{var t;m(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value),(null==u?void 0:u.handleSelectableStatesTileChange)&&(null==u||u.handleSelectableStatesTileChange(e))}}))),e.createElement("div",{className:"selected-state-tile-container"},a?e.createElement(K,{tilePrefix:r,graphingTiles:a.tiles,responsive:a.responsive,columns:a.columns,containerPadding:a.containerPadding,referenceMargin:a.referenceMargin,referenceWidth:a.referenceWidth}):null))};R("selectable-states-tile",Me);const ke=({graphingTile:t,graphingTileIndex:n})=>{const o=null==t?void 0:t.tile;if(!o)return null;const l=U(),r=e=>{a.isFunction(l.handleUIChange)&&l.handleUIChange(e)};return e.createElement("div",{className:"simple-form-tile-component"},(()=>{if(!a.isArray(o.controls)||o.controls.length<0)return null;const l=o.controls;return e.createElement(Ne,{graphingTile:t,graphingTileIndex:n,graphingTileControls:l,ControlProps:{onUIChange:r}})})())};R("simple-form-tile",ke);const Fe=({graphingTile:t,graphingTileIndex:n})=>{const o=null==t?void 0:t.tile;if(!o)return null;const l=[o.control],r={background:t.getBackground()};return e.createElement("div",{className:"single-tile-component",style:r},e.createElement(Ne,{graphingTile:t,graphingTileIndex:n,graphingTileControls:l}))};R("single-tile",Fe);const Ae=({graphingTile:t,graphingTileIndex:n})=>{const o=null==t?void 0:t.tile;if(!o)return null;const l=o.controls;return e.createElement("div",{className:"vertical-tile-component"},e.createElement(Ne,{graphingTile:t,graphingTileIndex:n,graphingTileControls:l}))};R("vertical-tile",Ae);const Ie=()=>{const e=Be.pop();e&&(e.classList.add("moorr-modal-container-closing"),setTimeout((()=>{e&&(M.unmountComponentAtNode(e),e.remove())}),300))};let Le=class{constructor(e){this._props=e}open(){const t=this._props;return new Promise(((n,o)=>{let l,r;"function"==typeof t.onClose&&(l=t.onClose),t.onClose=e=>{l&&l(e),n({dismissed:!1,result:e}),t.showModal=!1,Ie()},"function"==typeof t.onDismiss&&(r=t.onClose),t.onDismiss=()=>{r&&r(),n({dismissed:!0}),t.showModal=!1,Ie()},t.showModal=!0;let i=e.createElement(_,{stylePrefix:"MoorrReactMuiModal"},e.createElement(this.getComponent(),t));Be.push(this._container=document.createElement("div")),this._container.className="moorr-modal-container",document.body.appendChild(this._container),M.render(i,this._container)}))}};const Be=[],Se={},Ge=c((e=>({modal:{display:"flex",alignItems:"center",justifyContent:"center"},paper:{width:825,backgroundColor:e.palette.background.paper,borderRadius:"5px",boxShadow:e.shadows[5],padding:e.spacing(2,4,3)}}))),$e=n=>{const o=Ge(),r={};n.fixedWidth&&(r.width=n.fixedWidth),n.fixedHeight&&(r.height=n.fixedHeight);let i=o.paper+" moorr-modal-content-container";n.contentClassName&&(i+=" "+n.contentClassName);const[s,c]=l(!1),[d,u]=l(!1);t((()=>{u(!s&&!1!==n.showModal)}),[s,d,n.showModal]);const m=e=>{c(!0),(null==n?void 0:n.onDismiss)&&n.onDismiss(e)};let h=o.modal;switch(h+=" moorr-modal-container",n.effect){case"fade":h+=" moorr-fade-modal";break;case"slide":h+=" moorr-slide-modal"}return s&&(h+=" moorr-modal-closing"),e.createElement(p,{disableEnforceFocus:!0,className:h,open:d,onClose:m,closeAfterTransition:!0,BackdropComponent:f,BackdropProps:{timeout:300,onClick:e=>{e.preventDefault(),e.stopPropagation(),a.isFunction(n.onBackdropClick)?n.onBackdropClick(e):m("backdrop")}}},(()=>{switch(n.effect){case"fade":default:return e.createElement(v,{in:d},e.createElement("div",{className:i,style:r},n.children));case"slide":return e.createElement(k,{in:d,direction:"left",timeout:300},e.createElement("div",{className:i},n.children))}})())},De=(t,n)=>{(t=>{F(t,{icon:e.createElement(A,{sx:{color:"#EB5757"}}),style:{color:"#EB5757",backgroundColor:"#FCECEC",border:"2px solid #EB5757",fontFamily:'"Poppins", sans-serif',borderRadius:"0.7em",marginLeft:"-100px"},closeButton:()=>e.createElement(I,{sx:{color:"#EB5757"}})})})(n)},He=t=>e.createElement($e,{effect:"fade",contentClassName:`${t.className}-content-container`,fixedWidth:t.widthValue,fixedHeight:t.heightValue,showModal:t.showModal,onClose:t.onClose,onDismiss:t.onDismiss,onBackdropClick:t.onBackdropClick},e.createElement("div",{className:`${t.className} moorr-modal-container`},e.createElement("div",{className:"moorr-modal-header"},t.renderHeader),e.createElement("div",{className:"moorr-modal-body"},t.renderBody),!1===t.hasFooter?null:e.createElement("div",{className:"moorr-modal-footer"},e.createElement("div",{className:"left-buttons"},t.renderLeftButtons),e.createElement("div",{className:"status-message"},t.renderStatusMessage),e.createElement("div",{className:"right-buttons"},t.renderRightButtons)))),Oe=e=>{var t,n,o,l,r,i;const a=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.modal;if(!a||!Se[a])return Promise.reject("invalid-modal");const s=new Se[a]((null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.props)||{}).open();console.log(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.then),(null===(l=null==e?void 0:e.detail)||void 0===l?void 0:l.then)&&s.then((t=>{var n,o;if(!(null==t?void 0:t.dismissed)&&(null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.finally))try{null===(o=null==e?void 0:e.detail)||void 0===o||o.then(null==t?void 0:t.result)}catch(e){console.error(e)}})),(null===(r=null==e?void 0:e.detail)||void 0===r?void 0:r.catch)&&s.catch(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.catch),s.finally((()=>{var t,n;if(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.finally)try{null===(n=null==e?void 0:e.detail)||void 0===n||n.finally()}catch(e){console.error(e)}})),(null==e?void 0:e.detail)&&((null==e?void 0:e.detail).promise=s)};document&&(document.removeEventListener("openModal",Oe),document.addEventListener("openModal",Oe));export{L as Button,G as Dropdown,He as FadeModal,ce as FormGroupModel,xe as FormGroupsTile,he as FormGroupsTileModel,ae as FormInputModel,W as GraphingContext,Ce as GraphingControl,ie as GraphingControlModel,se as GraphingControlSettingsModel,ye as GraphingGrid,te as GraphingSettingsModel,j as GraphingTile,Ne as GraphingTileControls,de as GraphingTileModel,ee as GraphingTileSettingsModel,K as GraphingTiles,Pe as HorizontalTile,ge as HorizontalTileModel,Le as Modal,$e as MoorrModal,me as MultipleControlsTileModel,Me as SelectableStatesTile,pe as SelectableStatesTileModel,ke as SimpleFormTile,fe as SimpleFormTileModel,ue as SingleControlTileModel,Fe as SingleTile,ve as SingleTileModel,_ as StylesProvider,H as SvgIcon,Ae as VerticalTile,Ee as VerticalTileModel,le as createGraphingControl,re as createGraphingControls,X as createGraphingTile,Y as createGraphingTiles,Se as modals,Be as modalsStack,oe as registerGraphingControl,we as registerGraphingControlComponent,Q as registerGraphingTile,R as registerGraphingTileComponent,D as registerSvgIconComponent,De as toastMessage,U as useGraphingContext};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moorr-react-mui",
3
- "version": "0.2.113",
3
+ "version": "0.2.115",
4
4
  "description": "Moorr React MUI Common Library",
5
5
  "scripts": {
6
6
  "_clear": "rimraf index.* && rimraf typings/* && rimraf cjs/*",
@@ -43,7 +43,7 @@
43
43
  "@mui/material": "^5.11.8",
44
44
  "@mui/icons-material": "^5.11.16",
45
45
  "jss": "^10.9.2",
46
- "moorr-common": "^0.2.9",
46
+ "moorr-common": "^0.2.33",
47
47
  "react": "^17.0.2",
48
48
  "react-dom": "^17.0.2",
49
49
  "react-grid-layout": "^1.3.4",