moorr-react-mui 0.2.13 → 0.2.15

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/cjs/index.css CHANGED
@@ -2,6 +2,7 @@
2
2
  .graphing-tiles-container{box-sizing:border-box;margin:0;padding:0;width:100%;position:relative;}.graphing-tiles-container>.react-grid-layout{width:100%;position:relative;}.graphing-tiles-container .react-grid-placeholder{background:#E3E3E3;z-index:0;}.graphing-tiles-container .graphing-tile-container.react-draggable-dragging{z-index:1;}.graphing-tiles-container .graphing-tile-container{margin:0;padding:0;background-color:#FFFFFF;}.graphing-tiles-container .graphing-tile-container.bordered{border:1px solid #E3E3E3;border-radius:0.5rem;box-shadow:0 0 2px 1px #F4F4F4;}.graphing-tiles-container .graphing-tile-container.auto-height{height:100%!important;}
3
3
  .graphing-grid-container{margin-top:1em;padding:0 24px;opacity:0;transition:opacity 1000ms cubic-bezier(0.4,0,0.2,1) 0ms;}.graphing-grid-container.in{opacity:1;}.graphing-grid-container>.graphing-grid-title{font-size:32px!important;margin-bottom:0;margin-top:0;display:flex;}.graphing-grid-container>.graphing-grid-title>a{margin-left:.5rem;margin-top:.5rem;}.graphing-grid-container>.graphing-grid-hr{margin-top:0!important;}
4
4
  .graphing-tile-controls-container{box-sizing:border-box;margin:0;padding:0;}.graphing-tile-controls-container>.graphing-tile-control-container{margin:0;padding:0;background-color:transparent;}.graphing-tile-controls-container>.graphing-tile-control-container.bordered{border:1px solid #E3E3E3;border-radius:0.5rem;box-shadow:0 0 2px 1px #F4F4F4;}
5
+ .form-group-tile-component{display:block;width:100%;height:100%;border-radius:0.5rem;background:#FFFFFF;box-shadow:0 3px 3px rgba(0,0,0,0.25);}.form-group-tile-component:focus,.form-group-tile-component.focus{box-shadow:0 3px 3px rgba(0,0,0,0.35);}.form-group-tile-component>.form-group-tile-title{display:block;}.form-group-tile-component>.form-group-tile-components>.graphing-tile-controls-container.form-group-tile{display:flex;width:100%;height:100%;flex-direction:column;overflow-x:hidden;overflow-y:auto;justify-content:space-between;}
5
6
  .horizontal-tile-component{display:flex;width:100%;height:100%;position:relative;flex-direction:column;border-radius:.5rem;}.horizontal-tile-component>.horizontal-tile-pages-container{display:block;width:100%;height:100%;position:relative;overflow:hidden;flex-grow:1;border-radius:0.5rem;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container{display:block;width:100%;height:100%;position:absolute;left:0;top:0;z-index:0;background-color:transparent;transition:left 300ms ease-in-out;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.active{z-index:3;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.previous{z-index:2;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.navigating-from-left{left:-100%;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.navigating-from-right{left:100%;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container>.graphing-tile-controls-container.horizontal-tile{display:flex;width:100%;height:100%;flex-direction:row;justify-content:space-evenly;align-items:center;padding:.5rem;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container>.graphing-tile-controls-container.horizontal-tile>.graphing-tile-control-container{height:100%;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.background{z-index:1;}.horizontal-tile-component>.horizontal-tile-pages-container>button.navigate-button{position:absolute;border:none;background-color:transparent;opacity:0;z-index:3;}.horizontal-tile-component:hover>.horizontal-tile-pages-container>button.navigate-button{opacity:1;}.horizontal-tile-component>.horizontal-tile-pages-container>button.navigate-button.navigate-left-button{left:15px;top:50%;margin-top:-11px;transition:left 300ms ease-in-out,opacity 300ms ease-in-out;}.horizontal-tile-component:hover>.horizontal-tile-pages-container>button.navigate-button.navigate-left-button{left:5px;}.horizontal-tile-component>.horizontal-tile-pages-container>button.navigate-button.navigate-right-button{right:15px;top:50%;margin-top:-11px;transition:right 300ms ease-in-out,opacity 300ms ease-in-out;}.horizontal-tile-component:hover>.horizontal-tile-pages-container>button.navigate-button.navigate-right-button{right:5px;}.horizontal-tile-component>.horizontal-tile-paginators-container{display:flex;flex-direction:row;justify-content:center;padding:0.25rem;opacity:0;transition:opacity 300ms ease-in-out;}.horizontal-tile-component:hover>.horizontal-tile-paginators-container{opacity:1;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor{display:block;width:8px;height:8px;border-radius:4px;border:none;background-color:#D4C5D9;cursor:pointer;transition:width 300ms ease-in-out,background-color 300ms ease-in-out;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor+.paginator-anchor{margin-left:4px;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor.active{width:20px;background-color:#541868;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor:hover{background-color:#946EA0;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor.active:hover{background-color:#541868;}
6
7
  .selectable-states-tile-component{display:flex;width:100%;height:100%;flex-direction:column;}.selectable-states-tile-component>.selectable-states-tile-header{display:flex;flex-direction:row;}.selectable-states-tile-component>.selectable-states-tile-header>.selected-state-tile-title{flex-grow:1;padding:0.5rem 1rem;font-size:1.2rem;line-height:1.2rem;}.selectable-states-tile-component>.selectable-states-tile-header>.selected-state-tile-title>h6{text-align:center;}.selectable-states-tile-component>.selectable-states-tile-header>.selectable-states-dropdown-container{padding:0.5rem;}.selectable-states-tile-component>.selected-state-tile-container{display:flex;flex-grow:1;padding:0 1rem 1rem 1rem;}.selectable-states-tile-component>.selected-state-tile-container>.graphing-tiles-container{padding:0;}.selectable-states-tile-component>.selected-state-tile-container>.graphing-tiles-container>.react-grid-layout{height:100%!important;overflow:hidden;}
7
8
  .single-tile-component{display:block;width:100%;height:100%;border-radius:0.5rem;}.single-tile-component>.graphing-tile-controls-container.single-tile{display:block;width:100%;height:100%;}.single-tile-component>.graphing-tile-controls-container.single-tile>.graphing-tile-control-container{display:flex;width:100%;height:100%;flex-wrap:wrap;align-content:center;justify-content:center;}
package/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("moorr-common"),l=require("@material-ui/core/MenuItem"),n=require("@material-ui/core/styles"),r=require("@material-ui/core/TextField"),o=require("@material-ui/core"),i=require("@material-ui/styles"),a=require("uuid"),s=require("react-grid-layout"),c=require("react-dom"),u=require("@mui/material");const d=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"}});n.makeStyles(d);const g=n.makeStyles((()=>n.createStyles({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 m=n.withStyles(d)((({handleChange:t,value:n,disabled:o=!1,name:i,className:a,classes:s,size:c,menuItemLabel:u,options:d,labelPlacement:m="start",label:p,required:h=!1,isMBRequiredField:v,fullWidth:f,selectIconComponent:x})=>{const{root:E,focused:b,error:y,notchedOutline:T,notchedOutlineMBRequired:w}=s,N=g();let C;return x&&(C={IconComponent:x}),e.createElement(r,{fullWidth:!1!==f,id:"outlined-basic",variant:"outlined",value:n,onChange:t,disabled:o,name:i,className:[a].join(" "),InputProps:{classes:{root:E,focused:b,error:y,notchedOutline:!v||n&&0!==(null==n?void 0:n.length)?!h||n&&0!==(null==n?void 0:n.length)?T:N.mandatory:w}},color:"primary",size:c||"small",select:!0,SelectProps:C,defaultValue:""},e.createElement(l,{value:"",disabled:!0},e.createElement("em",null,u)),d&&d.map(((t,n)=>"-separator-"===t?e.createElement(l,{key:`separator-${n}`,value:"",disabled:!0},e.createElement("em",null,"-----------")):e.createElement(l,{key:`menu-item-${n}-${t.value||t}`,value:t.value||t},t.label||t))))}));const p={};var h=({stylePrefix:t,children:l})=>{let r;if(t)r=p[t]?p[t]:p[t]=i.createGenerateClassName({seed:t});else{const e=`MoorrStylesProvider-${a.v4()}-`;r=i.createGenerateClassName({seed:e})}return e.createElement(i.StylesProvider,{generateClassName:r,injectFirst:!0},e.createElement(o.StylesProvider,{generateClassName:r,injectFirst:!0},e.createElement(n.StylesProvider,{generateClassName:r},l)))};const v=e.createContext({});function f(){return e.useContext(v)}const x={};function E(e,t){e&&t&&(x[e]=t)}const b=({graphingTile:t,graphingTileIndex:l})=>{var n;if(!(null===(n=null==t?void 0:t.tile)||void 0===n?void 0:n.tileType))return null;const r=x[t.tile.tileType]||null;return r?e.createElement(r,{graphingTile:t,graphingTileIndex:l}):null},y=[20,20],T={lg:600,sm:0},w={lg:8,sm:2},N=({tilePrefix:t,responsive:l,columns:n,containerPadding:r,referenceMargin:o,referenceWidth:i,graphingTiles:a})=>{const[c,u]=e.useState(null),[d,g]=e.useState(null),[m,p]=e.useState(null),[h,v]=e.useState(null),f=e.useRef(null),x=()=>{const e=(null==f?void 0:f.current)?(null==f?void 0:f.current).getBoundingClientRect().width:null;v(e);const t=M(e);u(t)};let E;const N=e=>{x(),clearTimeout(E),E=setTimeout((()=>{x()}),300)};e.useEffect((()=>{x()}),[f]),e.useEffect((()=>(window.addEventListener("resize",N),()=>{window.removeEventListener("resize",N)})),[]),e.useEffect((()=>{if(l){if(!Array.isArray(a)||0===a.length)return void p({lg:[]});p({lg:a.map(((e,l)=>({x:e.x,y:e.y,w:isNaN(e.w)?1:e.w,h:isNaN(e.h)?1:e.h,i:`${t?t+"_":""}tile_${l}`})))})}else{if(!Array.isArray(a)||0===a.length)return void g([]);g(a.map(((e,l)=>({x:e.x,y:e.y,w:isNaN(e.w)?1:e.w,h:isNaN(e.h)?1:e.h,i:`${t?t+"_":""}tile_${l}`,static:!0}))))}}),[a]);const C=()=>null==a?void 0:a.map(((l,n)=>{if(!l.tile||!l.visible)return null;let r="graphing-tile-container";!1!==l.border&&(r+=" bordered"),l.autoHeight&&(r+=" auto-height");const o=`${t?t+"_":""}tile_${n}`;return e.createElement("div",{className:r,key:o},e.createElement(b,{graphingTile:l,graphingTileIndex:n}))})),M=e=>{if(!o||isNaN(o)||o<=0||!i||isNaN(i)||i<=0||null==e)return y;const t=e/i*o;return[t,t]};return e.createElement("div",{ref:f,className:"graphing-tiles-container"},(()=>{if(!h||!c)return null;if(!1!==l){if(!m)return null;const t=[r||0,0];return e.createElement(s.Responsive,{width:h,breakpoints:T,cols:n||w,rowHeight:1,layouts:m,containerPadding:t,margin:c,isDraggable:!1},C())}return d?e.createElement(s,{width:h,cols:9,rowHeight:50,margin:c,isDraggable:!1,layout:d},C()):null})())},C={};function M(e,t){C[e]=t}function S(e){const t=C[null==e?void 0:e.tileType];return t?new t(e):null}class P{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=S(e.tile),this.visible=!1!==e.visible}getBackground(){return this.background||"#FFFFFF"}}class k{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 P(e))}))}}const I={};function G(e){const t=I[null==e?void 0:e.controlType];return t?new t(e):null}class F{constructor(e){this.border=e.border,this.background=e.background||null,this.control=G(e.control)}getBackground(e){return this.background||(null==e?void 0:e.background)||"#FFFFFF"}}class L{constructor(e){this.tileType=e.tileType}}class $ extends L{constructor(e){super(e),this.control=new F(e.control)}}class B extends L{constructor(e){super(e),this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new F(e))}))}}class q extends B{constructor(e){super(e),this.controlsPerPage=e.controlsPerPage,(isNaN(this.controlsPerPage)||this.controlsPerPage<=1)&&(this.controlsPerPage=1)}}M("horizontal-tile",q);class H extends B{constructor(e){super(e),this.states={};for(const t in e.states){const l=e.states[t];l&&(this.states[t]=new k(l))}}}M("selectable-states-tile",H);class _ extends ${constructor(e){super(e)}}M("single-tile",_);class z extends B{constructor(e){super(e)}}M("vertical-tile",z);const D={};const W=({graphingTile:t,graphingTileIndex:l,graphingTileControl:n,ControlProps:r})=>{var o;if(!(null===(o=null==n?void 0:n.control)||void 0===o?void 0:o.controlType))return null;const i=D[n.control.controlType]||null;return i?e.createElement(i,Object.assign({graphingTile:t,graphingTileIndex:l,graphingTileControl:n},r)):null},A=({graphingTile:t,graphingTileIndex:l,graphingTileControls:n})=>{var r,o;let i="graphing-tile-controls-container";return(null===(r=null==t?void 0:t.tile)||void 0===r?void 0:r.tileType)&&(i+=" "+(null===(o=null==t?void 0:t.tile)||void 0===o?void 0:o.tileType)),e.createElement("div",{className:i},null==n?void 0:n.map(((n,r)=>{var o,i;if(!n.control)return null;let a="graphing-tile-control-container";(null===(o=n.control)||void 0===o?void 0:o.controlType)&&(a+=" "+(null===(i=n.control)||void 0===i?void 0:i.controlType)),!1!==n.border&&(a+=" bordered");const s=`control_${l}_${r}`;return e.createElement("div",{className:a,key:s},e.createElement(W,{graphingTile:t,graphingTileIndex:l,graphingTileControl:n}))})))},R=({graphingTile:t,graphingTileIndex:l})=>{const n=null==t?void 0:t.tile;if(!n)return null;const[r,o]=e.useState(null),[i,a]=e.useState(0),[s,c]=e.useState(0),[u,d]=e.useState(null),[g,m]=e.useState(null),[p,h]=e.useState(null),[v,f]=e.useState([]);e.useEffect((()=>{let e=[];const t=Math.ceil(n.controls.length/n.controlsPerPage);if(t>0)for(let l=0;l<t;l++){const t={pageIndex:l,controls:[]};for(let e=0;e<n.controlsPerPage;e++){const r=l*n.controlsPerPage+e;if(r>=n.controls.length)break;t.controls.push(n.controls[r])}e.push(t)}a(t),c(0),d(null),m(null),h(null),f(e)}),n.controls);const x=e=>{let t=e-1;t<0&&(t=i-1),m(t)},E=e=>{e.stopPropagation(),x(s),h(null),d(null)},b=e=>{e.stopPropagation()},y=e=>{e.stopPropagation()},T=e=>{if(e.stopPropagation(),null!==r)return;const t=s;let l=s-1;l<0&&(l=i-1),d(t),c(l),m(null),h(t);const n=setTimeout((()=>{x(l),h(null),d(null),setTimeout((function(){o(null)}),300)}),300);o(n)},w=e=>{let t=e+1;t>=i&&(t=0),h(t)},N=e=>{e.stopPropagation(),m(null),w(s),d(null)},C=e=>{e.stopPropagation()},M=e=>{e.stopPropagation()},S=e=>{if(e.stopPropagation(),null!==r)return;const t=s;let l=s+1;l>=i&&(l=0),d(t),c(l),m(t),h(null);const n=setTimeout((()=>{m(null),w(l),d(null),setTimeout((function(){o(null)}),300)}),300);o(n)},P={background:t.getBackground()};return e.createElement("div",{className:"horizontal-tile-component",style:P},e.createElement("div",{className:"horizontal-tile-pages-container"},v.map(((n,r)=>{let o="horizontal-tile-page-container";return r===s?o+=" active":r===g?o+=" navigating-from-left":r===p&&(o+=" navigating-from-right"),r===u&&(o+=" previous"),e.createElement("div",{className:o},e.createElement(A,{graphingTile:t,graphingTileIndex:l,graphingTileControls:n.controls}))})),e.createElement("div",{className:"horizontal-tile-page-container background",style:P}),i<=1?null:e.createElement(e.Fragment,null,e.createElement("button",{type:"button",className:"navigate-button navigate-left-button",onMouseEnter:E,onMouseLeave:b,onMouseDown:y,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:N,onMouseLeave:C,onMouseDown:M,onClick:S},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"}))))),i<=1?null:e.createElement("div",{className:"horizontal-tile-paginators-container"},Array.from(Array(i).keys()).map((t=>{let l="paginator-anchor";return t===s&&(l+=" active"),e.createElement("a",{className:l,onMouseEnter:e=>{e.stopPropagation(),t!==s&&(t<s?(m(t),h(null)):(m(null),h(t)),d(null))},onMouseLeave:e=>{e.stopPropagation()},onMouseDown:e=>{e.stopPropagation()},onClick:e=>{if(e.stopPropagation(),t===s)return;const l=s,n=t;d(l),c(n),l<n?m(l):h(l)}})}))))};E("horizontal-tile",R);const O=({graphingTile:t})=>{const l=null==t?void 0:t.tile;if(!l)return null;const[n,r]=e.useState(""),[o,i]=e.useState(null),[a,s]=e.useState([]),c=f();e.useEffect((()=>{const e=Object.keys(l.states);if(s(e.map((e=>{var t;return{label:null===(t=l.states[e])||void 0===t?void 0:t.title,value:e}}))),e&&e.length>0){const t=e[0];u(t)}else r(""),i(null)}),[l.states]);const u=e=>{r(e),i(l.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==o?void 0:o.title)),e.createElement("div",{className:"selectable-states-dropdown-container"},e.createElement(m,{options:a,label:"Select",value:n,handleChange:e=>{var t;u(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value),(null==c?void 0:c.handleSelectableStatesTileChange)&&(null==c||c.handleSelectableStatesTileChange(e))}}))),e.createElement("div",{className:"selected-state-tile-container"},o?e.createElement(N,{tilePrefix:n,graphingTiles:o.tiles,responsive:o.responsive,columns:o.columns,containerPadding:o.containerPadding,referenceMargin:o.referenceMargin,referenceWidth:o.referenceWidth}):null))};E("selectable-states-tile",O);const j=({graphingTile:t,graphingTileIndex:l})=>{const n=null==t?void 0:t.tile;if(!n)return null;const r=[n.control],o={background:t.getBackground()};return e.createElement("div",{className:"single-tile-component",style:o},e.createElement(A,{graphingTile:t,graphingTileIndex:l,graphingTileControls:r}))};E("single-tile",j);const U=({graphingTile:t,graphingTileIndex:l})=>{const n=null==t?void 0:t.tile;if(!n)return null;const r=n.controls;return e.createElement("div",{className:"vertical-tile-component"},e.createElement(A,{graphingTile:t,graphingTileIndex:l,graphingTileControls:r}))};E("vertical-tile",U);const V=()=>{setTimeout((()=>{const e=K.pop();e&&(c.unmountComponentAtNode(e),e.remove())}),300)};const K=[],Z={},J=n.makeStyles((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)}}))),Q=t=>{const l=J(),n={};t.fixedWidth&&(n.width=t.fixedWidth),t.fixedHeight&&(n.height=t.fixedHeight);let r=l.paper+" moorr-modal-content-container";t.contentClassName&&(r+=" "+t.contentClassName);let i=l.modal;switch(i+=" moorr-modal-container",t.effect){case"fade":i+=" moorr-fade-modal";break;case"slide":i+=" moorr-slide-modal"}const[a,s]=e.useState(!1),[c,d]=e.useState(!1);e.useEffect((()=>{d(!a&&!1!==t.showModal)}),[a,c]);return e.createElement(o.Modal,{className:i,open:c,onClose:e=>{s(!0),(null==t?void 0:t.onDismiss)&&t.onDismiss(e)},closeAfterTransition:!0,BackdropComponent:o.Backdrop,BackdropProps:{timeout:300}},(()=>{switch(t.effect){case"fade":default:return e.createElement(o.Fade,{in:c},e.createElement("div",{className:r,style:n},t.children));case"slide":return e.createElement(u.Slide,{in:c,direction:"left",timeout:300},e.createElement("div",{className:r},t.children))}})())},X=e=>{var t,l,n,r,o;const i=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.modal;if(!i||!Z[i])return Promise.reject("invalid-modal");const a=new Z[i]((null===(l=null==e?void 0:e.detail)||void 0===l?void 0:l.props)||{}).open();(null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.then)&&a.then((t=>{var l,n;if(!(null==t?void 0:t.dismissed)&&(null===(l=null==e?void 0:e.detail)||void 0===l?void 0:l.finally))try{null===(n=null==e?void 0:e.detail)||void 0===n||n.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)&&a.catch(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.catch),a.finally((()=>{var t,l;if(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.finally)try{null===(l=null==e?void 0:e.detail)||void 0===l||l.finally()}catch(e){console.error(e)}})),(null==e?void 0:e.detail)&&((null==e?void 0:e.detail).promise=a)};document&&(document.removeEventListener("openModal",X),document.addEventListener("openModal",X)),exports.Button=({type:l,label:n})=>(e.useEffect((()=>(console.log(`Message from moorr-react-mui: ${t.utils.hello()}`),()=>{console.log(`Message from moorr-react-mui: ${t.utils.bye()}`)})),[]),l||(l="button"),e.createElement("button",{type:l,className:"moorr-button"},e.createElement("span",null,n))),exports.Dropdown=m,exports.FadeModal=t=>e.createElement(Q,{fixedWidth:t.widthValue,fixedHeight:t.heightValue,showModal:t.showModal,onClose:t.onClose,onDismiss:t.onDismiss},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),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)))),exports.GraphingContext=v,exports.GraphingControl=W,exports.GraphingControlModel=class{constructor(e){this.controlType=e.controlType,this.dataKey=e.dataKey}},exports.GraphingControlSettingsModel=F,exports.GraphingGrid=({})=>{const{settings:l}=f(),[n,r]=e.useState(null),[o,i]=e.useState(!1);e.useEffect((()=>{setTimeout((()=>{window.dispatchEvent(new Event("resize")),setTimeout((()=>{i(!0)}),300)}),300)}),[]),e.useEffect((()=>{r(l?new k(l):null)}),[l]);const a=()=>(null==l?void 0:l.infoIconUrl)&&l.infoIconHref?e.createElement("a",{className:"information-anchor",href:l.infoIconHref,target:"_blank"},e.createElement("img",{alt:null==l?void 0:l.title,src:null==l?void 0:l.infoIconUrl})):null;if(!n)return null;let s="graphing-grid-container";return o&&(s+=" in"),e.createElement(e.Fragment,null,e.createElement("div",{className:s},t.utils.isNullOrUndefined(null==l?void 0:l.title)?null:e.createElement(e.Fragment,null,e.createElement("h2",{className:"graphing-grid-title"},null==l?void 0:l.title,a()),e.createElement("hr",{className:"graphing-grid-hr"})),e.createElement(N,{graphingTiles:n.tiles,responsive:n.responsive,columns:n.columns,containerPadding:n.containerPadding,referenceMargin:n.referenceMargin,referenceWidth:n.referenceWidth})))},exports.GraphingSettingsModel=k,exports.GraphingTile=b,exports.GraphingTileControls=A,exports.GraphingTileModel=L,exports.GraphingTileSettingsModel=P,exports.GraphingTiles=N,exports.HorizontalTile=R,exports.HorizontalTileModel=q,exports.Modal=class{constructor(e){this._props=e}open(){const t=this._props;return new Promise(((l,n)=>{let r,o;"function"==typeof t.onClose&&(r=t.onClose),t.onClose=e=>{r&&r(e),l({dismissed:!1,result:e}),t.showModal=!1,V()},"function"==typeof t.onDismiss&&(o=t.onClose),t.onDismiss=()=>{o&&o(),l({dismissed:!0}),t.showModal=!1,V()},t.showModal=!0;let i=e.createElement(h,{stylePrefix:"MoorrReactMuiModal"},e.createElement(this.getComponent(),t));K.push(this._container=document.createElement("div")),this._container.className="moorr-modal-container",document.body.appendChild(this._container),c.render(i,this._container)}))}},exports.MoorrModal=Q,exports.MultipleControlsTileModel=B,exports.SelectableStatesTile=O,exports.SelectableStatesTileModel=H,exports.SingleControlTileModel=$,exports.SingleTile=j,exports.SingleTileModel=_,exports.VerticalTile=U,exports.VerticalTileModel=z,exports.createGraphingControl=G,exports.createGraphingControls=function(e){const t=[];return e.forEach((e=>{const l=G(e);l&&t.push(l)})),t},exports.createGraphingTile=S,exports.createGraphingTiles=function(e){const t=[];return e.forEach((e=>{const l=S(e);l&&t.push(l)})),t},exports.modals=Z,exports.modalsStack=K,exports.registerGraphingControl=function(e,t){I[e]=t},exports.registerGraphingControlComponent=function(e,t){e&&t&&(D[e]=t)},exports.registerGraphingTile=M,exports.registerGraphingTileComponent=E,exports.useGraphingContext=f;
1
+ "use strict";var e=require("react"),t=require("moorr-common"),l=require("@material-ui/core/MenuItem"),n=require("@material-ui/core/styles"),r=require("@material-ui/core/TextField"),o=require("@material-ui/core"),i=require("@material-ui/styles"),a=require("uuid"),s=require("react-grid-layout"),c=require("react-dom"),u=require("@mui/material");const d=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"}});n.makeStyles(d);const g=n.makeStyles((()=>n.createStyles({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 m=n.withStyles(d)((({handleChange:t,value:n,disabled:o=!1,name:i,className:a,classes:s,size:c,menuItemLabel:u,options:d,labelPlacement:m="start",label:p,required:h=!1,isMBRequiredField:v,fullWidth:f,selectIconComponent:x})=>{const{root:E,focused:T,error:b,notchedOutline:y,notchedOutlineMBRequired:N}=s,w=g();let C;return x&&(C={IconComponent:x}),e.createElement(r,{fullWidth:!1!==f,id:"outlined-basic",variant:"outlined",value:n,onChange:t,disabled:o,name:i,className:[a].join(" "),InputProps:{classes:{root:E,focused:T,error:b,notchedOutline:!v||n&&0!==(null==n?void 0:n.length)?!h||n&&0!==(null==n?void 0:n.length)?y:w.mandatory:N}},color:"primary",size:c||"small",select:!0,SelectProps:C,defaultValue:""},e.createElement(l,{value:"",disabled:!0},e.createElement("em",null,u)),d&&d.map(((t,n)=>"-separator-"===t?e.createElement(l,{key:`separator-${n}`,value:"",disabled:!0},e.createElement("em",null,"-----------")):e.createElement(l,{key:`menu-item-${n}-${t.value||t}`,value:t.value||t},t.label||t))))}));const p={};var h=({stylePrefix:t,children:l})=>{let r;if(t)r=p[t]?p[t]:p[t]=i.createGenerateClassName({seed:t});else{const e=`MoorrStylesProvider-${a.v4()}-`;r=i.createGenerateClassName({seed:e})}return e.createElement(i.StylesProvider,{generateClassName:r,injectFirst:!0},e.createElement(o.StylesProvider,{generateClassName:r,injectFirst:!0},e.createElement(n.StylesProvider,{generateClassName:r},l)))};const v=e.createContext({});function f(){return e.useContext(v)}const x={};function E(e,t){e&&t&&(x[e]=t)}const T=({graphingTile:t,graphingTileIndex:l})=>{var n;if(!(null===(n=null==t?void 0:t.tile)||void 0===n?void 0:n.tileType))return null;const r=x[t.tile.tileType]||null;return r?e.createElement(r,{graphingTile:t,graphingTileIndex:l}):null},b=[20,20],y={lg:600,sm:0},N={lg:8,sm:2},w=({tilePrefix:t,responsive:l,columns:n,containerPadding:r,referenceMargin:o,referenceWidth:i,graphingTiles:a})=>{const[c,u]=e.useState(null),[d,g]=e.useState(null),[m,p]=e.useState(null),[h,v]=e.useState(null),f=e.useRef(null),x=()=>{const e=(null==f?void 0:f.current)?(null==f?void 0:f.current).getBoundingClientRect().width:null;v(e);const t=M(e);u(t)};let E;const w=e=>{x(),clearTimeout(E),E=setTimeout((()=>{x()}),300)};e.useEffect((()=>{x()}),[f]),e.useEffect((()=>(window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w)})),[]),e.useEffect((()=>{if(l){if(!Array.isArray(a)||0===a.length)return void p({lg:[]});p({lg:a.map(((e,l)=>({x:e.x,y:e.y,w:isNaN(e.w)?1:e.w,h:isNaN(e.h)?1:e.h,i:`${t?t+"_":""}tile_${l}`})))})}else{if(!Array.isArray(a)||0===a.length)return void g([]);g(a.map(((e,l)=>({x:e.x,y:e.y,w:isNaN(e.w)?1:e.w,h:isNaN(e.h)?1:e.h,i:`${t?t+"_":""}tile_${l}`,static:!0}))))}}),[a]);const C=()=>null==a?void 0:a.map(((l,n)=>{if(!l.tile||!l.visible)return null;let r="graphing-tile-container";!1!==l.border&&(r+=" bordered"),l.autoHeight&&(r+=" auto-height");const o=`${t?t+"_":""}tile_${n}`;return e.createElement("div",{className:r,key:o},e.createElement(T,{graphingTile:l,graphingTileIndex:n}))})),M=e=>{if(!o||isNaN(o)||o<=0||!i||isNaN(i)||i<=0||null==e)return b;const t=e/i*o;return[t,t]};return e.createElement("div",{ref:f,className:"graphing-tiles-container"},(()=>{if(!h||!c)return null;if(!1!==l){if(!m)return null;const t=[r||0,0];return e.createElement(s.Responsive,{width:h,breakpoints:y,cols:n||N,rowHeight:1,layouts:m,containerPadding:t,margin:c,isDraggable:!1},C())}return d?e.createElement(s,{width:h,cols:9,rowHeight:50,margin:c,isDraggable:!1,layout:d},C()):null})())},C={};function M(e,t){C[e]=t}function S(e){const t=C[null==e?void 0:e.tileType];return t?new t(e):null}class P{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=S(e.tile),this.visible=!1!==e.visible}getBackground(){return this.background||"#FFFFFF"}}class k{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 P(e))}))}}const I={};function G(e){const t=I[null==e?void 0:e.controlType];return t?new t(e):null}class F{constructor(e){this.border=e.border,this.background=e.background||null,this.control=G(e.control)}getBackground(e){return this.background||(null==e?void 0:e.background)||"#FFFFFF"}}class L{constructor(e){this.tileType=e.tileType}}class $ extends L{constructor(e){super(e),this.control=new F(e.control)}}class B extends L{constructor(e){super(e),this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new F(e))}))}}class q extends B{constructor(e){super(e),this.title=e.title||""}}M("form-group-tile",q);class H extends B{constructor(e){super(e),this.controlsPerPage=e.controlsPerPage,(isNaN(this.controlsPerPage)||this.controlsPerPage<=1)&&(this.controlsPerPage=1)}}M("horizontal-tile",H);class _ extends B{constructor(e){super(e),this.states={};for(const t in e.states){const l=e.states[t];l&&(this.states[t]=new k(l))}}}M("selectable-states-tile",_);class z extends ${constructor(e){super(e)}}M("single-tile",z);class D extends B{constructor(e){super(e)}}M("vertical-tile",D);const W={};const A=({graphingTile:t,graphingTileIndex:l,graphingTileControl:n,ControlProps:r})=>{var o;if(!(null===(o=null==n?void 0:n.control)||void 0===o?void 0:o.controlType))return null;const i=W[n.control.controlType]||null;return i?e.createElement(i,Object.assign({graphingTile:t,graphingTileIndex:l,graphingTileControl:n},r)):null},R=({graphingTile:t,graphingTileIndex:l,graphingTileControls:n})=>{var r,o;let i="graphing-tile-controls-container";return(null===(r=null==t?void 0:t.tile)||void 0===r?void 0:r.tileType)&&(i+=" "+(null===(o=null==t?void 0:t.tile)||void 0===o?void 0:o.tileType)),e.createElement("div",{className:i},null==n?void 0:n.map(((n,r)=>{var o,i;if(!n.control)return null;let a="graphing-tile-control-container";(null===(o=n.control)||void 0===o?void 0:o.controlType)&&(a+=" "+(null===(i=n.control)||void 0===i?void 0:i.controlType)),!1!==n.border&&(a+=" bordered");const s=`control_${l}_${r}`;return e.createElement("div",{className:a,key:s},e.createElement(A,{graphingTile:t,graphingTileIndex:l,graphingTileControl:n}))})))},O=({graphingTile:t,graphingTileIndex:l})=>{const n=null==t?void 0:t.tile;if(!n)return null;const r=n.controls;return e.createElement("div",{className:"form-group-tile-component"},e.createElement("div",{className:"form-group-tile-title"},e.createElement("span",null,n.title)),e.createElement("div",{className:"form-group-tile-components"},e.createElement(R,{graphingTile:t,graphingTileIndex:l,graphingTileControls:r})))};E("form-group-tile",O);const j=({graphingTile:t,graphingTileIndex:l})=>{const n=null==t?void 0:t.tile;if(!n)return null;const[r,o]=e.useState(null),[i,a]=e.useState(0),[s,c]=e.useState(0),[u,d]=e.useState(null),[g,m]=e.useState(null),[p,h]=e.useState(null),[v,f]=e.useState([]);e.useEffect((()=>{let e=[];const t=Math.ceil(n.controls.length/n.controlsPerPage);if(t>0)for(let l=0;l<t;l++){const t={pageIndex:l,controls:[]};for(let e=0;e<n.controlsPerPage;e++){const r=l*n.controlsPerPage+e;if(r>=n.controls.length)break;t.controls.push(n.controls[r])}e.push(t)}a(t),c(0),d(null),m(null),h(null),f(e)}),n.controls);const x=e=>{let t=e-1;t<0&&(t=i-1),m(t)},E=e=>{e.stopPropagation(),x(s),h(null),d(null)},T=e=>{e.stopPropagation()},b=e=>{e.stopPropagation()},y=e=>{if(e.stopPropagation(),null!==r)return;const t=s;let l=s-1;l<0&&(l=i-1),d(t),c(l),m(null),h(t);const n=setTimeout((()=>{x(l),h(null),d(null),setTimeout((function(){o(null)}),300)}),300);o(n)},N=e=>{let t=e+1;t>=i&&(t=0),h(t)},w=e=>{e.stopPropagation(),m(null),N(s),d(null)},C=e=>{e.stopPropagation()},M=e=>{e.stopPropagation()},S=e=>{if(e.stopPropagation(),null!==r)return;const t=s;let l=s+1;l>=i&&(l=0),d(t),c(l),m(t),h(null);const n=setTimeout((()=>{m(null),N(l),d(null),setTimeout((function(){o(null)}),300)}),300);o(n)},P={background:t.getBackground()};return e.createElement("div",{className:"horizontal-tile-component",style:P},e.createElement("div",{className:"horizontal-tile-pages-container"},v.map(((n,r)=>{let o="horizontal-tile-page-container";return r===s?o+=" active":r===g?o+=" navigating-from-left":r===p&&(o+=" navigating-from-right"),r===u&&(o+=" previous"),e.createElement("div",{className:o},e.createElement(R,{graphingTile:t,graphingTileIndex:l,graphingTileControls:n.controls}))})),e.createElement("div",{className:"horizontal-tile-page-container background",style:P}),i<=1?null:e.createElement(e.Fragment,null,e.createElement("button",{type:"button",className:"navigate-button navigate-left-button",onMouseEnter:E,onMouseLeave:T,onMouseDown:b,onClick:y},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:w,onMouseLeave:C,onMouseDown:M,onClick:S},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"}))))),i<=1?null:e.createElement("div",{className:"horizontal-tile-paginators-container"},Array.from(Array(i).keys()).map((t=>{let l="paginator-anchor";return t===s&&(l+=" active"),e.createElement("a",{className:l,onMouseEnter:e=>{e.stopPropagation(),t!==s&&(t<s?(m(t),h(null)):(m(null),h(t)),d(null))},onMouseLeave:e=>{e.stopPropagation()},onMouseDown:e=>{e.stopPropagation()},onClick:e=>{if(e.stopPropagation(),t===s)return;const l=s,n=t;d(l),c(n),l<n?m(l):h(l)}})}))))};E("horizontal-tile",j);const U=({graphingTile:t})=>{const l=null==t?void 0:t.tile;if(!l)return null;const[n,r]=e.useState(""),[o,i]=e.useState(null),[a,s]=e.useState([]),c=f();e.useEffect((()=>{const e=Object.keys(l.states);if(s(e.map((e=>{var t;return{label:null===(t=l.states[e])||void 0===t?void 0:t.title,value:e}}))),e&&e.length>0){const t=e[0];u(t)}else r(""),i(null)}),[l.states]);const u=e=>{r(e),i(l.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==o?void 0:o.title)),e.createElement("div",{className:"selectable-states-dropdown-container"},e.createElement(m,{options:a,label:"Select",value:n,handleChange:e=>{var t;u(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value),(null==c?void 0:c.handleSelectableStatesTileChange)&&(null==c||c.handleSelectableStatesTileChange(e))}}))),e.createElement("div",{className:"selected-state-tile-container"},o?e.createElement(w,{tilePrefix:n,graphingTiles:o.tiles,responsive:o.responsive,columns:o.columns,containerPadding:o.containerPadding,referenceMargin:o.referenceMargin,referenceWidth:o.referenceWidth}):null))};E("selectable-states-tile",U);const V=({graphingTile:t,graphingTileIndex:l})=>{const n=null==t?void 0:t.tile;if(!n)return null;const r=[n.control],o={background:t.getBackground()};return e.createElement("div",{className:"single-tile-component",style:o},e.createElement(R,{graphingTile:t,graphingTileIndex:l,graphingTileControls:r}))};E("single-tile",V);const K=({graphingTile:t,graphingTileIndex:l})=>{const n=null==t?void 0:t.tile;if(!n)return null;const r=n.controls;return e.createElement("div",{className:"vertical-tile-component"},e.createElement(R,{graphingTile:t,graphingTileIndex:l,graphingTileControls:r}))};E("vertical-tile",K);const Z=()=>{setTimeout((()=>{const e=J.pop();e&&(c.unmountComponentAtNode(e),e.remove())}),300)};const J=[],Q={},X=n.makeStyles((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)}}))),Y=t=>{const l=X(),n={};t.fixedWidth&&(n.width=t.fixedWidth),t.fixedHeight&&(n.height=t.fixedHeight);let r=l.paper+" moorr-modal-content-container";t.contentClassName&&(r+=" "+t.contentClassName);let i=l.modal;switch(i+=" moorr-modal-container",t.effect){case"fade":i+=" moorr-fade-modal";break;case"slide":i+=" moorr-slide-modal"}const[a,s]=e.useState(!1),[c,d]=e.useState(!1);e.useEffect((()=>{d(!a&&!1!==t.showModal)}),[a,c]);return e.createElement(o.Modal,{className:i,open:c,onClose:e=>{s(!0),(null==t?void 0:t.onDismiss)&&t.onDismiss(e)},closeAfterTransition:!0,BackdropComponent:o.Backdrop,BackdropProps:{timeout:300}},(()=>{switch(t.effect){case"fade":default:return e.createElement(o.Fade,{in:c},e.createElement("div",{className:r,style:n},t.children));case"slide":return e.createElement(u.Slide,{in:c,direction:"left",timeout:300},e.createElement("div",{className:r},t.children))}})())},ee=e=>{var t,l,n,r,o;const i=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.modal;if(!i||!Q[i])return Promise.reject("invalid-modal");const a=new Q[i]((null===(l=null==e?void 0:e.detail)||void 0===l?void 0:l.props)||{}).open();(null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.then)&&a.then((t=>{var l,n;if(!(null==t?void 0:t.dismissed)&&(null===(l=null==e?void 0:e.detail)||void 0===l?void 0:l.finally))try{null===(n=null==e?void 0:e.detail)||void 0===n||n.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)&&a.catch(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.catch),a.finally((()=>{var t,l;if(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.finally)try{null===(l=null==e?void 0:e.detail)||void 0===l||l.finally()}catch(e){console.error(e)}})),(null==e?void 0:e.detail)&&((null==e?void 0:e.detail).promise=a)};document&&(document.removeEventListener("openModal",ee),document.addEventListener("openModal",ee)),exports.Button=({type:l,label:n})=>(e.useEffect((()=>(console.log(`Message from moorr-react-mui: ${t.utils.hello()}`),()=>{console.log(`Message from moorr-react-mui: ${t.utils.bye()}`)})),[]),l||(l="button"),e.createElement("button",{type:l,className:"moorr-button"},e.createElement("span",null,n))),exports.Dropdown=m,exports.FadeModal=t=>e.createElement(Y,{contentClassName:`${t.className}-content-container`,fixedWidth:t.widthValue,fixedHeight:t.heightValue,showModal:t.showModal,onClose:t.onClose,onDismiss:t.onDismiss},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),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)))),exports.FormGroupTile=O,exports.FormGroupTileModel=q,exports.GraphingContext=v,exports.GraphingControl=A,exports.GraphingControlModel=class{constructor(e){this.controlType=e.controlType,this.dataKey=e.dataKey}},exports.GraphingControlSettingsModel=F,exports.GraphingGrid=({})=>{const{settings:l}=f(),[n,r]=e.useState(null),[o,i]=e.useState(!1);e.useEffect((()=>{setTimeout((()=>{window.dispatchEvent(new Event("resize")),setTimeout((()=>{i(!0)}),300)}),300)}),[]),e.useEffect((()=>{r(l?new k(l):null)}),[l]);const a=()=>(null==l?void 0:l.infoIconUrl)&&l.infoIconHref?e.createElement("a",{className:"information-anchor",href:l.infoIconHref,target:"_blank"},e.createElement("img",{alt:null==l?void 0:l.title,src:null==l?void 0:l.infoIconUrl})):null;if(!n)return null;let s="graphing-grid-container";return o&&(s+=" in"),e.createElement(e.Fragment,null,e.createElement("div",{className:s},t.utils.isNullOrUndefined(null==l?void 0:l.title)?null:e.createElement(e.Fragment,null,e.createElement("h2",{className:"graphing-grid-title"},null==l?void 0:l.title,a()),e.createElement("hr",{className:"graphing-grid-hr"})),e.createElement(w,{graphingTiles:n.tiles,responsive:n.responsive,columns:n.columns,containerPadding:n.containerPadding,referenceMargin:n.referenceMargin,referenceWidth:n.referenceWidth})))},exports.GraphingSettingsModel=k,exports.GraphingTile=T,exports.GraphingTileControls=R,exports.GraphingTileModel=L,exports.GraphingTileSettingsModel=P,exports.GraphingTiles=w,exports.HorizontalTile=j,exports.HorizontalTileModel=H,exports.Modal=class{constructor(e){this._props=e}open(){const t=this._props;return new Promise(((l,n)=>{let r,o;"function"==typeof t.onClose&&(r=t.onClose),t.onClose=e=>{r&&r(e),l({dismissed:!1,result:e}),t.showModal=!1,Z()},"function"==typeof t.onDismiss&&(o=t.onClose),t.onDismiss=()=>{o&&o(),l({dismissed:!0}),t.showModal=!1,Z()},t.showModal=!0;let i=e.createElement(h,{stylePrefix:"MoorrReactMuiModal"},e.createElement(this.getComponent(),t));J.push(this._container=document.createElement("div")),this._container.className="moorr-modal-container",document.body.appendChild(this._container),c.render(i,this._container)}))}},exports.MoorrModal=Y,exports.MultipleControlsTileModel=B,exports.SelectableStatesTile=U,exports.SelectableStatesTileModel=_,exports.SingleControlTileModel=$,exports.SingleTile=V,exports.SingleTileModel=z,exports.VerticalTile=K,exports.VerticalTileModel=D,exports.createGraphingControl=G,exports.createGraphingControls=function(e){const t=[];return e.forEach((e=>{const l=G(e);l&&t.push(l)})),t},exports.createGraphingTile=S,exports.createGraphingTiles=function(e){const t=[];return e.forEach((e=>{const l=S(e);l&&t.push(l)})),t},exports.modals=Q,exports.modalsStack=J,exports.registerGraphingControl=function(e,t){I[e]=t},exports.registerGraphingControlComponent=function(e,t){e&&t&&(W[e]=t)},exports.registerGraphingTile=M,exports.registerGraphingTileComponent=E,exports.useGraphingContext=f;
@@ -1,3 +1,4 @@
1
+ export * from "./form-group-tile.component";
1
2
  export * from "./graphing-tile.component";
2
3
  export * from "./horizontal-tile.component";
3
4
  export * from "./selectable-states-tile.component";
@@ -1,3 +1,4 @@
1
+ export * from "./form-group-tile.model";
1
2
  export * from "./graphing-tile.factory";
2
3
  export * from "./graphing-tile.model";
3
4
  export * from "./horizontal-tile.model";
package/index.css CHANGED
@@ -2,6 +2,7 @@
2
2
  .graphing-tiles-container{box-sizing:border-box;margin:0;padding:0;width:100%;position:relative;}.graphing-tiles-container>.react-grid-layout{width:100%;position:relative;}.graphing-tiles-container .react-grid-placeholder{background:#E3E3E3;z-index:0;}.graphing-tiles-container .graphing-tile-container.react-draggable-dragging{z-index:1;}.graphing-tiles-container .graphing-tile-container{margin:0;padding:0;background-color:#FFFFFF;}.graphing-tiles-container .graphing-tile-container.bordered{border:1px solid #E3E3E3;border-radius:0.5rem;box-shadow:0 0 2px 1px #F4F4F4;}.graphing-tiles-container .graphing-tile-container.auto-height{height:100%!important;}
3
3
  .graphing-grid-container{margin-top:1em;padding:0 24px;opacity:0;transition:opacity 1000ms cubic-bezier(0.4,0,0.2,1) 0ms;}.graphing-grid-container.in{opacity:1;}.graphing-grid-container>.graphing-grid-title{font-size:32px!important;margin-bottom:0;margin-top:0;display:flex;}.graphing-grid-container>.graphing-grid-title>a{margin-left:.5rem;margin-top:.5rem;}.graphing-grid-container>.graphing-grid-hr{margin-top:0!important;}
4
4
  .graphing-tile-controls-container{box-sizing:border-box;margin:0;padding:0;}.graphing-tile-controls-container>.graphing-tile-control-container{margin:0;padding:0;background-color:transparent;}.graphing-tile-controls-container>.graphing-tile-control-container.bordered{border:1px solid #E3E3E3;border-radius:0.5rem;box-shadow:0 0 2px 1px #F4F4F4;}
5
+ .form-group-tile-component{display:block;width:100%;height:100%;border-radius:0.5rem;background:#FFFFFF;box-shadow:0 3px 3px rgba(0,0,0,0.25);}.form-group-tile-component:focus,.form-group-tile-component.focus{box-shadow:0 3px 3px rgba(0,0,0,0.35);}.form-group-tile-component>.form-group-tile-title{display:block;}.form-group-tile-component>.form-group-tile-components>.graphing-tile-controls-container.form-group-tile{display:flex;width:100%;height:100%;flex-direction:column;overflow-x:hidden;overflow-y:auto;justify-content:space-between;}
5
6
  .horizontal-tile-component{display:flex;width:100%;height:100%;position:relative;flex-direction:column;border-radius:.5rem;}.horizontal-tile-component>.horizontal-tile-pages-container{display:block;width:100%;height:100%;position:relative;overflow:hidden;flex-grow:1;border-radius:0.5rem;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container{display:block;width:100%;height:100%;position:absolute;left:0;top:0;z-index:0;background-color:transparent;transition:left 300ms ease-in-out;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.active{z-index:3;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.previous{z-index:2;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.navigating-from-left{left:-100%;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.navigating-from-right{left:100%;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container>.graphing-tile-controls-container.horizontal-tile{display:flex;width:100%;height:100%;flex-direction:row;justify-content:space-evenly;align-items:center;padding:.5rem;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container>.graphing-tile-controls-container.horizontal-tile>.graphing-tile-control-container{height:100%;}.horizontal-tile-component>.horizontal-tile-pages-container>.horizontal-tile-page-container.background{z-index:1;}.horizontal-tile-component>.horizontal-tile-pages-container>button.navigate-button{position:absolute;border:none;background-color:transparent;opacity:0;z-index:3;}.horizontal-tile-component:hover>.horizontal-tile-pages-container>button.navigate-button{opacity:1;}.horizontal-tile-component>.horizontal-tile-pages-container>button.navigate-button.navigate-left-button{left:15px;top:50%;margin-top:-11px;transition:left 300ms ease-in-out,opacity 300ms ease-in-out;}.horizontal-tile-component:hover>.horizontal-tile-pages-container>button.navigate-button.navigate-left-button{left:5px;}.horizontal-tile-component>.horizontal-tile-pages-container>button.navigate-button.navigate-right-button{right:15px;top:50%;margin-top:-11px;transition:right 300ms ease-in-out,opacity 300ms ease-in-out;}.horizontal-tile-component:hover>.horizontal-tile-pages-container>button.navigate-button.navigate-right-button{right:5px;}.horizontal-tile-component>.horizontal-tile-paginators-container{display:flex;flex-direction:row;justify-content:center;padding:0.25rem;opacity:0;transition:opacity 300ms ease-in-out;}.horizontal-tile-component:hover>.horizontal-tile-paginators-container{opacity:1;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor{display:block;width:8px;height:8px;border-radius:4px;border:none;background-color:#D4C5D9;cursor:pointer;transition:width 300ms ease-in-out,background-color 300ms ease-in-out;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor+.paginator-anchor{margin-left:4px;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor.active{width:20px;background-color:#541868;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor:hover{background-color:#946EA0;}.horizontal-tile-component>.horizontal-tile-paginators-container>.paginator-anchor.active:hover{background-color:#541868;}
6
7
  .selectable-states-tile-component{display:flex;width:100%;height:100%;flex-direction:column;}.selectable-states-tile-component>.selectable-states-tile-header{display:flex;flex-direction:row;}.selectable-states-tile-component>.selectable-states-tile-header>.selected-state-tile-title{flex-grow:1;padding:0.5rem 1rem;font-size:1.2rem;line-height:1.2rem;}.selectable-states-tile-component>.selectable-states-tile-header>.selected-state-tile-title>h6{text-align:center;}.selectable-states-tile-component>.selectable-states-tile-header>.selectable-states-dropdown-container{padding:0.5rem;}.selectable-states-tile-component>.selected-state-tile-container{display:flex;flex-grow:1;padding:0 1rem 1rem 1rem;}.selectable-states-tile-component>.selected-state-tile-container>.graphing-tiles-container{padding:0;}.selectable-states-tile-component>.selected-state-tile-container>.graphing-tiles-container>.react-grid-layout{height:100%!important;overflow:hidden;}
7
8
  .single-tile-component{display:block;width:100%;height:100%;border-radius:0.5rem;}.single-tile-component>.graphing-tile-controls-container.single-tile{display:block;width:100%;height:100%;}.single-tile-component>.graphing-tile-controls-container.single-tile>.graphing-tile-control-container{display:flex;width:100%;height:100%;flex-wrap:wrap;align-content:center;justify-content:center;}
package/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import React__default from 'react';
7
7
  * Private
8
8
  * ----------------------------------------------------------------------------
9
9
  */
10
- interface Props$7 {
10
+ interface Props$8 {
11
11
  type?: "button" | "submit" | "reset" | undefined;
12
12
  label: string;
13
13
  }
@@ -15,7 +15,7 @@ interface Props$7 {
15
15
  * Component
16
16
  * ----------------------------------------------------------------------------
17
17
  */
18
- declare const Button: ({ type, label }: Props$7) => JSX.Element;
18
+ declare const Button: ({ type, label }: Props$8) => JSX.Element;
19
19
 
20
20
  /**
21
21
  * * Interface for Reusable Components
@@ -137,6 +137,15 @@ declare class GraphingSettingsModel {
137
137
  constructor(json: any);
138
138
  }
139
139
 
140
+ /** ---------------------------------------------------------------------------
141
+ * Model
142
+ * ----------------------------------------------------------------------------
143
+ */
144
+ declare class FormGroupTileModel extends MultipleControlsTileModel {
145
+ title: string;
146
+ constructor(json: any);
147
+ }
148
+
140
149
  interface TileConstructor {
141
150
  new (json: any): GraphingTileModel;
142
151
  }
@@ -210,19 +219,19 @@ declare function useGraphingContext(): GraphingContextResult;
210
219
  * Private
211
220
  * ----------------------------------------------------------------------------
212
221
  */
213
- interface Props$6 {
222
+ interface Props$7 {
214
223
  }
215
224
  /** ---------------------------------------------------------------------------
216
225
  * Component
217
226
  * ----------------------------------------------------------------------------
218
227
  */
219
- declare const GraphingGrid: ({}: Props$6) => JSX.Element | null;
228
+ declare const GraphingGrid: ({}: Props$7) => JSX.Element | null;
220
229
 
221
230
  /** ---------------------------------------------------------------------------
222
231
  * Private
223
232
  * ----------------------------------------------------------------------------
224
233
  */
225
- interface Props$5 {
234
+ interface Props$6 {
226
235
  graphingTile: GraphingTileSettingsModel;
227
236
  graphingTileIndex: number;
228
237
  graphingTileControls: GraphingControlSettingsModel[];
@@ -231,13 +240,13 @@ interface Props$5 {
231
240
  * Component
232
241
  * ----------------------------------------------------------------------------
233
242
  */
234
- declare const GraphingTileControls: ({ graphingTile, graphingTileIndex, graphingTileControls }: Props$5) => JSX.Element;
243
+ declare const GraphingTileControls: ({ graphingTile, graphingTileIndex, graphingTileControls }: Props$6) => JSX.Element;
235
244
 
236
245
  /** ---------------------------------------------------------------------------
237
246
  * Private
238
247
  * ----------------------------------------------------------------------------
239
248
  */
240
- interface Props$4 {
249
+ interface Props$5 {
241
250
  tilePrefix?: string | null;
242
251
  graphingTiles: GraphingTileSettingsModel[];
243
252
  responsive?: boolean;
@@ -252,7 +261,7 @@ interface Props$4 {
252
261
  * Component
253
262
  * ----------------------------------------------------------------------------
254
263
  */
255
- declare const GraphingTiles: ({ tilePrefix, responsive, columns, containerPadding, referenceMargin, referenceWidth, graphingTiles }: Props$4) => JSX.Element;
264
+ declare const GraphingTiles: ({ tilePrefix, responsive, columns, containerPadding, referenceMargin, referenceWidth, graphingTiles }: Props$5) => JSX.Element;
256
265
 
257
266
  /** ---------------------------------------------------------------------------
258
267
  * Private
@@ -290,6 +299,18 @@ declare function registerGraphingTileComponent(key: string, component: GraphingT
290
299
  */
291
300
  declare const GraphingTile: ({ graphingTile, graphingTileIndex, }: GraphingTileProps) => JSX.Element | null;
292
301
 
302
+ /** ---------------------------------------------------------------------------
303
+ * Private
304
+ * ----------------------------------------------------------------------------
305
+ */
306
+ interface Props$4 extends GraphingTileProps {
307
+ }
308
+ /** ---------------------------------------------------------------------------
309
+ * Component
310
+ * ----------------------------------------------------------------------------
311
+ */
312
+ declare const FormGroupTile: ({ graphingTile, graphingTileIndex }: Props$4) => JSX.Element | null;
313
+
293
314
  /** ---------------------------------------------------------------------------
294
315
  * Private
295
316
  * ----------------------------------------------------------------------------
@@ -394,4 +415,4 @@ interface FadeModalProps {
394
415
  }
395
416
  declare const FadeModal: React__default.FC<FadeModalProps>;
396
417
 
397
- export { Button, _default as Dropdown, FadeModal, GraphingContext, GraphingContextResult, GraphingControl, GraphingControlModel, GraphingControlProps, GraphingControlSettingsModel, GraphingGrid, GraphingSettingsModel, GraphingTile, GraphingTileControls, GraphingTileModel, GraphingTileProps, GraphingTileSettingsModel, GraphingTiles, HorizontalTile, HorizontalTileModel, Modal, ModalContructor, ModalProps, Modal$1 as MoorrModal, MultipleControlsTileModel, SelectableStatesTile, SelectableStatesTileModel, SingleControlTileModel, SingleTile, SingleTileModel, VerticalTile, VerticalTileModel, createGraphingControl, createGraphingControls, createGraphingTile, createGraphingTiles, modals, modalsStack, registerGraphingControl, registerGraphingControlComponent, registerGraphingTile, registerGraphingTileComponent, useGraphingContext };
418
+ export { Button, _default as Dropdown, FadeModal, FormGroupTile, FormGroupTileModel, GraphingContext, GraphingContextResult, GraphingControl, GraphingControlModel, GraphingControlProps, GraphingControlSettingsModel, GraphingGrid, GraphingSettingsModel, GraphingTile, GraphingTileControls, GraphingTileModel, GraphingTileProps, GraphingTileSettingsModel, GraphingTiles, HorizontalTile, HorizontalTileModel, Modal, ModalContructor, ModalProps, Modal$1 as MoorrModal, MultipleControlsTileModel, SelectableStatesTile, SelectableStatesTileModel, SingleControlTileModel, SingleTile, SingleTileModel, VerticalTile, VerticalTileModel, createGraphingControl, createGraphingControls, createGraphingTile, createGraphingTiles, modals, modalsStack, registerGraphingControl, registerGraphingControlComponent, registerGraphingTile, registerGraphingTileComponent, useGraphingContext };
package/index.js CHANGED
@@ -1 +1 @@
1
- import e,{useEffect as t,createContext as n,useContext as l,useState as o,useRef as r}from"react";import{utils as i}from"moorr-common";import a from"@material-ui/core/MenuItem";import{makeStyles as s,createStyles as c,withStyles as d,StylesProvider as u}from"@material-ui/core/styles";import m from"@material-ui/core/TextField";import{StylesProvider as g,Modal as h,Backdrop as p,Fade as v}from"@material-ui/core";import{createGenerateClassName as f,StylesProvider as b}from"@material-ui/styles";import{v4 as E}from"uuid";import y,{Responsive as T}from"react-grid-layout";import w from"react-dom";import{Slide as N}from"@mui/material";const x=({type:n,label:l})=>(t((()=>(console.log(`Message from moorr-react-mui: ${i.hello()}`),()=>{console.log(`Message from moorr-react-mui: ${i.bye()}`)})),[]),n||(n="button"),e.createElement("button",{type:n,className:"moorr-button"},e.createElement("span",null,l))),P=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"}});s(P);const M=s((()=>c({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 C=d(P)((({handleChange:t,value:n,disabled:l=!1,name:o,className:r,classes:i,size:s,menuItemLabel:c,options:d,labelPlacement:u="start",label:g,required:h=!1,isMBRequiredField:p,fullWidth:v,selectIconComponent:f})=>{const{root:b,focused:E,error:y,notchedOutline:T,notchedOutlineMBRequired:w}=i,N=M();let x;return f&&(x={IconComponent:f}),e.createElement(m,{fullWidth:!1!==v,id:"outlined-basic",variant:"outlined",value:n,onChange:t,disabled:l,name:o,className:[r].join(" "),InputProps:{classes:{root:b,focused:E,error:y,notchedOutline:!p||n&&0!==(null==n?void 0:n.length)?!h||n&&0!==(null==n?void 0:n.length)?T:N.mandatory:w}},color:"primary",size:s||"small",select:!0,SelectProps:x,defaultValue:""},e.createElement(a,{value:"",disabled:!0},e.createElement("em",null,c)),d&&d.map(((t,n)=>"-separator-"===t?e.createElement(a,{key:`separator-${n}`,value:"",disabled:!0},e.createElement("em",null,"-----------")):e.createElement(a,{key:`menu-item-${n}-${t.value||t}`,value:t.value||t},t.label||t))))}));const k={};var I=({stylePrefix:t,children:n})=>{let l;if(t)l=k[t]?k[t]:k[t]=f({seed:t});else{const e=`MoorrStylesProvider-${E()}-`;l=f({seed:e})}return e.createElement(b,{generateClassName:l,injectFirst:!0},e.createElement(g,{generateClassName:l,injectFirst:!0},e.createElement(u,{generateClassName:l},n)))};const L=n({});function F(){return l(L)}const $={};function S(e,t){e&&t&&($[e]=t)}const B=({graphingTile:t,graphingTileIndex:n})=>{var l;if(!(null===(l=null==t?void 0:t.tile)||void 0===l?void 0:l.tileType))return null;const o=$[t.tile.tileType]||null;return o?e.createElement(o,{graphingTile:t,graphingTileIndex:n}):null},_=[20,20],D={lg:600,sm:0},W={lg:8,sm:2},H=({tilePrefix:n,responsive:l,columns:i,containerPadding:a,referenceMargin:s,referenceWidth:c,graphingTiles:d})=>{const[u,m]=o(null),[g,h]=o(null),[p,v]=o(null),[f,b]=o(null),E=r(null),w=()=>{const e=(null==E?void 0:E.current)?(null==E?void 0:E.current).getBoundingClientRect().width:null;b(e);const t=M(e);m(t)};let N;const x=e=>{w(),clearTimeout(N),N=setTimeout((()=>{w()}),300)};t((()=>{w()}),[E]),t((()=>(window.addEventListener("resize",x),()=>{window.removeEventListener("resize",x)})),[]),t((()=>{if(l){if(!Array.isArray(d)||0===d.length)return void v({lg:[]});v({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 h([]);h(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 P=()=>null==d?void 0:d.map(((t,l)=>{if(!t.tile||!t.visible)return null;let o="graphing-tile-container";!1!==t.border&&(o+=" bordered"),t.autoHeight&&(o+=" auto-height");const r=`${n?n+"_":""}tile_${l}`;return e.createElement("div",{className:o,key:r},e.createElement(B,{graphingTile:t,graphingTileIndex:l}))})),M=e=>{if(!s||isNaN(s)||s<=0||!c||isNaN(c)||c<=0||null==e)return _;const t=e/c*s;return[t,t]};return e.createElement("div",{ref:E,className:"graphing-tiles-container"},(()=>{if(!f||!u)return null;if(!1!==l){if(!p)return null;const t=[a||0,0];return e.createElement(T,{width:f,breakpoints:D,cols:i||W,rowHeight:1,layouts:p,containerPadding:t,margin:u,isDraggable:!1},P())}return g?e.createElement(y,{width:f,cols:9,rowHeight:50,margin:u,isDraggable:!1,layout:g},P()):null})())},z={};function A(e,t){z[e]=t}function R(e){const t=z[null==e?void 0:e.tileType];return t?new t(e):null}function O(e){const t=[];return e.forEach((e=>{const n=R(e);n&&t.push(n)})),t}class j{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=R(e.tile),this.visible=!1!==e.visible}getBackground(){return this.background||"#FFFFFF"}}class q{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 j(e))}))}}const U={};function V(e,t){U[e]=t}function K(e){const t=U[null==e?void 0:e.controlType];return t?new t(e):null}function Z(e){const t=[];return e.forEach((e=>{const n=K(e);n&&t.push(n)})),t}class G{constructor(e){this.controlType=e.controlType,this.dataKey=e.dataKey}}class J{constructor(e){this.border=e.border,this.background=e.background||null,this.control=K(e.control)}getBackground(e){return this.background||(null==e?void 0:e.background)||"#FFFFFF"}}class Q{constructor(e){this.tileType=e.tileType}}class X extends Q{constructor(e){super(e),this.control=new J(e.control)}}class Y extends Q{constructor(e){super(e),this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new J(e))}))}}class ee extends Y{constructor(e){super(e),this.controlsPerPage=e.controlsPerPage,(isNaN(this.controlsPerPage)||this.controlsPerPage<=1)&&(this.controlsPerPage=1)}}A("horizontal-tile",ee);class te extends Y{constructor(e){super(e),this.states={};for(const t in e.states){const n=e.states[t];n&&(this.states[t]=new q(n))}}}A("selectable-states-tile",te);class ne extends X{constructor(e){super(e)}}A("single-tile",ne);class le extends Y{constructor(e){super(e)}}A("vertical-tile",le);const oe=({})=>{const{settings:n}=F(),[l,r]=o(null),[a,s]=o(!1);t((()=>{setTimeout((()=>{window.dispatchEvent(new Event("resize")),setTimeout((()=>{s(!0)}),300)}),300)}),[]),t((()=>{r(n?new q(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(!l)return null;let d="graphing-grid-container";return a&&(d+=" in"),e.createElement(e.Fragment,null,e.createElement("div",{className:d},i.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(H,{graphingTiles:l.tiles,responsive:l.responsive,columns:l.columns,containerPadding:l.containerPadding,referenceMargin:l.referenceMargin,referenceWidth:l.referenceWidth})))},re={};function ie(e,t){e&&t&&(re[e]=t)}const ae=({graphingTile:t,graphingTileIndex:n,graphingTileControl:l,ControlProps:o})=>{var r;if(!(null===(r=null==l?void 0:l.control)||void 0===r?void 0:r.controlType))return null;const i=re[l.control.controlType]||null;return i?e.createElement(i,Object.assign({graphingTile:t,graphingTileIndex:n,graphingTileControl:l},o)):null},se=({graphingTile:t,graphingTileIndex:n,graphingTileControls:l})=>{var o,r;let i="graphing-tile-controls-container";return(null===(o=null==t?void 0:t.tile)||void 0===o?void 0:o.tileType)&&(i+=" "+(null===(r=null==t?void 0:t.tile)||void 0===r?void 0:r.tileType)),e.createElement("div",{className:i},null==l?void 0:l.map(((l,o)=>{var r,i;if(!l.control)return null;let a="graphing-tile-control-container";(null===(r=l.control)||void 0===r?void 0:r.controlType)&&(a+=" "+(null===(i=l.control)||void 0===i?void 0:i.controlType)),!1!==l.border&&(a+=" bordered");const s=`control_${n}_${o}`;return e.createElement("div",{className:a,key:s},e.createElement(ae,{graphingTile:t,graphingTileIndex:n,graphingTileControl:l}))})))},ce=({graphingTile:n,graphingTileIndex:l})=>{const r=null==n?void 0:n.tile;if(!r)return null;const[i,a]=o(null),[s,c]=o(0),[d,u]=o(0),[m,g]=o(null),[h,p]=o(null),[v,f]=o(null),[b,E]=o([]);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 l=n*r.controlsPerPage+e;if(l>=r.controls.length)break;t.controls.push(r.controls[l])}e.push(t)}c(t),u(0),g(null),p(null),f(null),E(e)}),r.controls);const y=e=>{let t=e-1;t<0&&(t=s-1),p(t)},T=e=>{e.stopPropagation(),y(d),f(null),g(null)},w=e=>{e.stopPropagation()},N=e=>{e.stopPropagation()},x=e=>{if(e.stopPropagation(),null!==i)return;const t=d;let n=d-1;n<0&&(n=s-1),g(t),u(n),p(null),f(t);const l=setTimeout((()=>{y(n),f(null),g(null),setTimeout((function(){a(null)}),300)}),300);a(l)},P=e=>{let t=e+1;t>=s&&(t=0),f(t)},M=e=>{e.stopPropagation(),p(null),P(d),g(null)},C=e=>{e.stopPropagation()},k=e=>{e.stopPropagation()},I=e=>{if(e.stopPropagation(),null!==i)return;const t=d;let n=d+1;n>=s&&(n=0),g(t),u(n),p(t),f(null);const l=setTimeout((()=>{p(null),P(n),g(null),setTimeout((function(){a(null)}),300)}),300);a(l)},L={background:n.getBackground()};return e.createElement("div",{className:"horizontal-tile-component",style:L},e.createElement("div",{className:"horizontal-tile-pages-container"},b.map(((t,o)=>{let r="horizontal-tile-page-container";return o===d?r+=" active":o===h?r+=" navigating-from-left":o===v&&(r+=" navigating-from-right"),o===m&&(r+=" previous"),e.createElement("div",{className:r},e.createElement(se,{graphingTile:n,graphingTileIndex:l,graphingTileControls:t.controls}))})),e.createElement("div",{className:"horizontal-tile-page-container background",style:L}),s<=1?null:e.createElement(e.Fragment,null,e.createElement("button",{type:"button",className:"navigate-button navigate-left-button",onMouseEnter:T,onMouseLeave:w,onMouseDown:N,onClick:x},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:M,onMouseLeave:C,onMouseDown:k,onClick:I},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),f(null)):(p(null),f(t)),g(null))},onMouseLeave:e=>{e.stopPropagation()},onMouseDown:e=>{e.stopPropagation()},onClick:e=>{if(e.stopPropagation(),t===d)return;const n=d,l=t;g(n),u(l),n<l?p(n):f(n)}})}))))};S("horizontal-tile",ce);const de=({graphingTile:n})=>{const l=null==n?void 0:n.tile;if(!l)return null;const[r,i]=o(""),[a,s]=o(null),[c,d]=o([]),u=F();t((()=>{const e=Object.keys(l.states);if(d(e.map((e=>{var t;return{label:null===(t=l.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)}),[l.states]);const m=e=>{i(e),s(l.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(C,{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(H,{tilePrefix:r,graphingTiles:a.tiles,responsive:a.responsive,columns:a.columns,containerPadding:a.containerPadding,referenceMargin:a.referenceMargin,referenceWidth:a.referenceWidth}):null))};S("selectable-states-tile",de);const ue=({graphingTile:t,graphingTileIndex:n})=>{const l=null==t?void 0:t.tile;if(!l)return null;const o=[l.control],r={background:t.getBackground()};return e.createElement("div",{className:"single-tile-component",style:r},e.createElement(se,{graphingTile:t,graphingTileIndex:n,graphingTileControls:o}))};S("single-tile",ue);const me=({graphingTile:t,graphingTileIndex:n})=>{const l=null==t?void 0:t.tile;if(!l)return null;const o=l.controls;return e.createElement("div",{className:"vertical-tile-component"},e.createElement(se,{graphingTile:t,graphingTileIndex:n,graphingTileControls:o}))};S("vertical-tile",me);const ge=()=>{setTimeout((()=>{const e=pe.pop();e&&(w.unmountComponentAtNode(e),e.remove())}),300)};let he=class{constructor(e){this._props=e}open(){const t=this._props;return new Promise(((n,l)=>{let o,r;"function"==typeof t.onClose&&(o=t.onClose),t.onClose=e=>{o&&o(e),n({dismissed:!1,result:e}),t.showModal=!1,ge()},"function"==typeof t.onDismiss&&(r=t.onClose),t.onDismiss=()=>{r&&r(),n({dismissed:!0}),t.showModal=!1,ge()},t.showModal=!0;let i=e.createElement(I,{stylePrefix:"MoorrReactMuiModal"},e.createElement(this.getComponent(),t));pe.push(this._container=document.createElement("div")),this._container.className="moorr-modal-container",document.body.appendChild(this._container),w.render(i,this._container)}))}};const pe=[],ve={},fe=s((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)}}))),be=n=>{const l=fe(),r={};n.fixedWidth&&(r.width=n.fixedWidth),n.fixedHeight&&(r.height=n.fixedHeight);let i=l.paper+" moorr-modal-content-container";n.contentClassName&&(i+=" "+n.contentClassName);let a=l.modal;switch(a+=" moorr-modal-container",n.effect){case"fade":a+=" moorr-fade-modal";break;case"slide":a+=" moorr-slide-modal"}const[s,c]=o(!1),[d,u]=o(!1);t((()=>{u(!s&&!1!==n.showModal)}),[s,d]);return e.createElement(h,{className:a,open:d,onClose:e=>{c(!0),(null==n?void 0:n.onDismiss)&&n.onDismiss(e)},closeAfterTransition:!0,BackdropComponent:p,BackdropProps:{timeout:300}},(()=>{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(N,{in:d,direction:"left",timeout:300},e.createElement("div",{className:i},n.children))}})())},Ee=t=>e.createElement(be,{fixedWidth:t.widthValue,fixedHeight:t.heightValue,showModal:t.showModal,onClose:t.onClose,onDismiss:t.onDismiss},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),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)))),ye=e=>{var t,n,l,o,r;const i=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.modal;if(!i||!ve[i])return Promise.reject("invalid-modal");const a=new ve[i]((null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.props)||{}).open();(null===(l=null==e?void 0:e.detail)||void 0===l?void 0:l.then)&&a.then((t=>{var n,l;if(!(null==t?void 0:t.dismissed)&&(null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.finally))try{null===(l=null==e?void 0:e.detail)||void 0===l||l.then(null==t?void 0:t.result)}catch(e){console.error(e)}})),(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.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",ye),document.addEventListener("openModal",ye));export{x as Button,C as Dropdown,Ee as FadeModal,L as GraphingContext,ae as GraphingControl,G as GraphingControlModel,J as GraphingControlSettingsModel,oe as GraphingGrid,q as GraphingSettingsModel,B as GraphingTile,se as GraphingTileControls,Q as GraphingTileModel,j as GraphingTileSettingsModel,H as GraphingTiles,ce as HorizontalTile,ee as HorizontalTileModel,he as Modal,be as MoorrModal,Y as MultipleControlsTileModel,de as SelectableStatesTile,te as SelectableStatesTileModel,X as SingleControlTileModel,ue as SingleTile,ne as SingleTileModel,me as VerticalTile,le as VerticalTileModel,K as createGraphingControl,Z as createGraphingControls,R as createGraphingTile,O as createGraphingTiles,ve as modals,pe as modalsStack,V as registerGraphingControl,ie as registerGraphingControlComponent,A as registerGraphingTile,S as registerGraphingTileComponent,F as useGraphingContext};
1
+ import e,{useEffect as t,createContext as n,useContext as l,useState as o,useRef as r}from"react";import{utils as i}from"moorr-common";import a from"@material-ui/core/MenuItem";import{makeStyles as s,createStyles as c,withStyles as d,StylesProvider as u}from"@material-ui/core/styles";import m from"@material-ui/core/TextField";import{StylesProvider as g,Modal as h,Backdrop as p,Fade as v}from"@material-ui/core";import{createGenerateClassName as f,StylesProvider as E}from"@material-ui/styles";import{v4 as b}from"uuid";import y,{Responsive as T}from"react-grid-layout";import N from"react-dom";import{Slide as w}from"@mui/material";const x=({type:n,label:l})=>(t((()=>(console.log(`Message from moorr-react-mui: ${i.hello()}`),()=>{console.log(`Message from moorr-react-mui: ${i.bye()}`)})),[]),n||(n="button"),e.createElement("button",{type:n,className:"moorr-button"},e.createElement("span",null,l))),P=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"}});s(P);const M=s((()=>c({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 C=d(P)((({handleChange:t,value:n,disabled:l=!1,name:o,className:r,classes:i,size:s,menuItemLabel:c,options:d,labelPlacement:u="start",label:g,required:h=!1,isMBRequiredField:p,fullWidth:v,selectIconComponent:f})=>{const{root:E,focused:b,error:y,notchedOutline:T,notchedOutlineMBRequired:N}=i,w=M();let x;return f&&(x={IconComponent:f}),e.createElement(m,{fullWidth:!1!==v,id:"outlined-basic",variant:"outlined",value:n,onChange:t,disabled:l,name:o,className:[r].join(" "),InputProps:{classes:{root:E,focused:b,error:y,notchedOutline:!p||n&&0!==(null==n?void 0:n.length)?!h||n&&0!==(null==n?void 0:n.length)?T:w.mandatory:N}},color:"primary",size:s||"small",select:!0,SelectProps:x,defaultValue:""},e.createElement(a,{value:"",disabled:!0},e.createElement("em",null,c)),d&&d.map(((t,n)=>"-separator-"===t?e.createElement(a,{key:`separator-${n}`,value:"",disabled:!0},e.createElement("em",null,"-----------")):e.createElement(a,{key:`menu-item-${n}-${t.value||t}`,value:t.value||t},t.label||t))))}));const k={};var I=({stylePrefix:t,children:n})=>{let l;if(t)l=k[t]?k[t]:k[t]=f({seed:t});else{const e=`MoorrStylesProvider-${b()}-`;l=f({seed:e})}return e.createElement(E,{generateClassName:l,injectFirst:!0},e.createElement(g,{generateClassName:l,injectFirst:!0},e.createElement(u,{generateClassName:l},n)))};const L=n({});function $(){return l(L)}const F={};function S(e,t){e&&t&&(F[e]=t)}const B=({graphingTile:t,graphingTileIndex:n})=>{var l;if(!(null===(l=null==t?void 0:t.tile)||void 0===l?void 0:l.tileType))return null;const o=F[t.tile.tileType]||null;return o?e.createElement(o,{graphingTile:t,graphingTileIndex:n}):null},_=[20,20],D={lg:600,sm:0},W={lg:8,sm:2},H=({tilePrefix:n,responsive:l,columns:i,containerPadding:a,referenceMargin:s,referenceWidth:c,graphingTiles:d})=>{const[u,m]=o(null),[g,h]=o(null),[p,v]=o(null),[f,E]=o(null),b=r(null),N=()=>{const e=(null==b?void 0:b.current)?(null==b?void 0:b.current).getBoundingClientRect().width:null;E(e);const t=M(e);m(t)};let w;const x=e=>{N(),clearTimeout(w),w=setTimeout((()=>{N()}),300)};t((()=>{N()}),[b]),t((()=>(window.addEventListener("resize",x),()=>{window.removeEventListener("resize",x)})),[]),t((()=>{if(l){if(!Array.isArray(d)||0===d.length)return void v({lg:[]});v({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 h([]);h(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 P=()=>null==d?void 0:d.map(((t,l)=>{if(!t.tile||!t.visible)return null;let o="graphing-tile-container";!1!==t.border&&(o+=" bordered"),t.autoHeight&&(o+=" auto-height");const r=`${n?n+"_":""}tile_${l}`;return e.createElement("div",{className:o,key:r},e.createElement(B,{graphingTile:t,graphingTileIndex:l}))})),M=e=>{if(!s||isNaN(s)||s<=0||!c||isNaN(c)||c<=0||null==e)return _;const t=e/c*s;return[t,t]};return e.createElement("div",{ref:b,className:"graphing-tiles-container"},(()=>{if(!f||!u)return null;if(!1!==l){if(!p)return null;const t=[a||0,0];return e.createElement(T,{width:f,breakpoints:D,cols:i||W,rowHeight:1,layouts:p,containerPadding:t,margin:u,isDraggable:!1},P())}return g?e.createElement(y,{width:f,cols:9,rowHeight:50,margin:u,isDraggable:!1,layout:g},P()):null})())},z={};function A(e,t){z[e]=t}function R(e){const t=z[null==e?void 0:e.tileType];return t?new t(e):null}function O(e){const t=[];return e.forEach((e=>{const n=R(e);n&&t.push(n)})),t}class j{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=R(e.tile),this.visible=!1!==e.visible}getBackground(){return this.background||"#FFFFFF"}}class q{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 j(e))}))}}const U={};function V(e,t){U[e]=t}function K(e){const t=U[null==e?void 0:e.controlType];return t?new t(e):null}function Z(e){const t=[];return e.forEach((e=>{const n=K(e);n&&t.push(n)})),t}class G{constructor(e){this.controlType=e.controlType,this.dataKey=e.dataKey}}class J{constructor(e){this.border=e.border,this.background=e.background||null,this.control=K(e.control)}getBackground(e){return this.background||(null==e?void 0:e.background)||"#FFFFFF"}}class Q{constructor(e){this.tileType=e.tileType}}class X extends Q{constructor(e){super(e),this.control=new J(e.control)}}class Y extends Q{constructor(e){super(e),this.controls=[],Array.isArray(e.controls)&&e.controls.forEach((e=>{this.controls.push(new J(e))}))}}class ee extends Y{constructor(e){super(e),this.title=e.title||""}}A("form-group-tile",ee);class te extends Y{constructor(e){super(e),this.controlsPerPage=e.controlsPerPage,(isNaN(this.controlsPerPage)||this.controlsPerPage<=1)&&(this.controlsPerPage=1)}}A("horizontal-tile",te);class ne extends Y{constructor(e){super(e),this.states={};for(const t in e.states){const n=e.states[t];n&&(this.states[t]=new q(n))}}}A("selectable-states-tile",ne);class le extends X{constructor(e){super(e)}}A("single-tile",le);class oe extends Y{constructor(e){super(e)}}A("vertical-tile",oe);const re=({})=>{const{settings:n}=$(),[l,r]=o(null),[a,s]=o(!1);t((()=>{setTimeout((()=>{window.dispatchEvent(new Event("resize")),setTimeout((()=>{s(!0)}),300)}),300)}),[]),t((()=>{r(n?new q(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(!l)return null;let d="graphing-grid-container";return a&&(d+=" in"),e.createElement(e.Fragment,null,e.createElement("div",{className:d},i.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(H,{graphingTiles:l.tiles,responsive:l.responsive,columns:l.columns,containerPadding:l.containerPadding,referenceMargin:l.referenceMargin,referenceWidth:l.referenceWidth})))},ie={};function ae(e,t){e&&t&&(ie[e]=t)}const se=({graphingTile:t,graphingTileIndex:n,graphingTileControl:l,ControlProps:o})=>{var r;if(!(null===(r=null==l?void 0:l.control)||void 0===r?void 0:r.controlType))return null;const i=ie[l.control.controlType]||null;return i?e.createElement(i,Object.assign({graphingTile:t,graphingTileIndex:n,graphingTileControl:l},o)):null},ce=({graphingTile:t,graphingTileIndex:n,graphingTileControls:l})=>{var o,r;let i="graphing-tile-controls-container";return(null===(o=null==t?void 0:t.tile)||void 0===o?void 0:o.tileType)&&(i+=" "+(null===(r=null==t?void 0:t.tile)||void 0===r?void 0:r.tileType)),e.createElement("div",{className:i},null==l?void 0:l.map(((l,o)=>{var r,i;if(!l.control)return null;let a="graphing-tile-control-container";(null===(r=l.control)||void 0===r?void 0:r.controlType)&&(a+=" "+(null===(i=l.control)||void 0===i?void 0:i.controlType)),!1!==l.border&&(a+=" bordered");const s=`control_${n}_${o}`;return e.createElement("div",{className:a,key:s},e.createElement(se,{graphingTile:t,graphingTileIndex:n,graphingTileControl:l}))})))},de=({graphingTile:t,graphingTileIndex:n})=>{const l=null==t?void 0:t.tile;if(!l)return null;const o=l.controls;return e.createElement("div",{className:"form-group-tile-component"},e.createElement("div",{className:"form-group-tile-title"},e.createElement("span",null,l.title)),e.createElement("div",{className:"form-group-tile-components"},e.createElement(ce,{graphingTile:t,graphingTileIndex:n,graphingTileControls:o})))};S("form-group-tile",de);const ue=({graphingTile:n,graphingTileIndex:l})=>{const r=null==n?void 0:n.tile;if(!r)return null;const[i,a]=o(null),[s,c]=o(0),[d,u]=o(0),[m,g]=o(null),[h,p]=o(null),[v,f]=o(null),[E,b]=o([]);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 l=n*r.controlsPerPage+e;if(l>=r.controls.length)break;t.controls.push(r.controls[l])}e.push(t)}c(t),u(0),g(null),p(null),f(null),b(e)}),r.controls);const y=e=>{let t=e-1;t<0&&(t=s-1),p(t)},T=e=>{e.stopPropagation(),y(d),f(null),g(null)},N=e=>{e.stopPropagation()},w=e=>{e.stopPropagation()},x=e=>{if(e.stopPropagation(),null!==i)return;const t=d;let n=d-1;n<0&&(n=s-1),g(t),u(n),p(null),f(t);const l=setTimeout((()=>{y(n),f(null),g(null),setTimeout((function(){a(null)}),300)}),300);a(l)},P=e=>{let t=e+1;t>=s&&(t=0),f(t)},M=e=>{e.stopPropagation(),p(null),P(d),g(null)},C=e=>{e.stopPropagation()},k=e=>{e.stopPropagation()},I=e=>{if(e.stopPropagation(),null!==i)return;const t=d;let n=d+1;n>=s&&(n=0),g(t),u(n),p(t),f(null);const l=setTimeout((()=>{p(null),P(n),g(null),setTimeout((function(){a(null)}),300)}),300);a(l)},L={background:n.getBackground()};return e.createElement("div",{className:"horizontal-tile-component",style:L},e.createElement("div",{className:"horizontal-tile-pages-container"},E.map(((t,o)=>{let r="horizontal-tile-page-container";return o===d?r+=" active":o===h?r+=" navigating-from-left":o===v&&(r+=" navigating-from-right"),o===m&&(r+=" previous"),e.createElement("div",{className:r},e.createElement(ce,{graphingTile:n,graphingTileIndex:l,graphingTileControls:t.controls}))})),e.createElement("div",{className:"horizontal-tile-page-container background",style:L}),s<=1?null:e.createElement(e.Fragment,null,e.createElement("button",{type:"button",className:"navigate-button navigate-left-button",onMouseEnter:T,onMouseLeave:N,onMouseDown:w,onClick:x},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:M,onMouseLeave:C,onMouseDown:k,onClick:I},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),f(null)):(p(null),f(t)),g(null))},onMouseLeave:e=>{e.stopPropagation()},onMouseDown:e=>{e.stopPropagation()},onClick:e=>{if(e.stopPropagation(),t===d)return;const n=d,l=t;g(n),u(l),n<l?p(n):f(n)}})}))))};S("horizontal-tile",ue);const me=({graphingTile:n})=>{const l=null==n?void 0:n.tile;if(!l)return null;const[r,i]=o(""),[a,s]=o(null),[c,d]=o([]),u=$();t((()=>{const e=Object.keys(l.states);if(d(e.map((e=>{var t;return{label:null===(t=l.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)}),[l.states]);const m=e=>{i(e),s(l.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(C,{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(H,{tilePrefix:r,graphingTiles:a.tiles,responsive:a.responsive,columns:a.columns,containerPadding:a.containerPadding,referenceMargin:a.referenceMargin,referenceWidth:a.referenceWidth}):null))};S("selectable-states-tile",me);const ge=({graphingTile:t,graphingTileIndex:n})=>{const l=null==t?void 0:t.tile;if(!l)return null;const o=[l.control],r={background:t.getBackground()};return e.createElement("div",{className:"single-tile-component",style:r},e.createElement(ce,{graphingTile:t,graphingTileIndex:n,graphingTileControls:o}))};S("single-tile",ge);const he=({graphingTile:t,graphingTileIndex:n})=>{const l=null==t?void 0:t.tile;if(!l)return null;const o=l.controls;return e.createElement("div",{className:"vertical-tile-component"},e.createElement(ce,{graphingTile:t,graphingTileIndex:n,graphingTileControls:o}))};S("vertical-tile",he);const pe=()=>{setTimeout((()=>{const e=fe.pop();e&&(N.unmountComponentAtNode(e),e.remove())}),300)};let ve=class{constructor(e){this._props=e}open(){const t=this._props;return new Promise(((n,l)=>{let o,r;"function"==typeof t.onClose&&(o=t.onClose),t.onClose=e=>{o&&o(e),n({dismissed:!1,result:e}),t.showModal=!1,pe()},"function"==typeof t.onDismiss&&(r=t.onClose),t.onDismiss=()=>{r&&r(),n({dismissed:!0}),t.showModal=!1,pe()},t.showModal=!0;let i=e.createElement(I,{stylePrefix:"MoorrReactMuiModal"},e.createElement(this.getComponent(),t));fe.push(this._container=document.createElement("div")),this._container.className="moorr-modal-container",document.body.appendChild(this._container),N.render(i,this._container)}))}};const fe=[],Ee={},be=s((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)}}))),ye=n=>{const l=be(),r={};n.fixedWidth&&(r.width=n.fixedWidth),n.fixedHeight&&(r.height=n.fixedHeight);let i=l.paper+" moorr-modal-content-container";n.contentClassName&&(i+=" "+n.contentClassName);let a=l.modal;switch(a+=" moorr-modal-container",n.effect){case"fade":a+=" moorr-fade-modal";break;case"slide":a+=" moorr-slide-modal"}const[s,c]=o(!1),[d,u]=o(!1);t((()=>{u(!s&&!1!==n.showModal)}),[s,d]);return e.createElement(h,{className:a,open:d,onClose:e=>{c(!0),(null==n?void 0:n.onDismiss)&&n.onDismiss(e)},closeAfterTransition:!0,BackdropComponent:p,BackdropProps:{timeout:300}},(()=>{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(w,{in:d,direction:"left",timeout:300},e.createElement("div",{className:i},n.children))}})())},Te=t=>e.createElement(ye,{contentClassName:`${t.className}-content-container`,fixedWidth:t.widthValue,fixedHeight:t.heightValue,showModal:t.showModal,onClose:t.onClose,onDismiss:t.onDismiss},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),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)))),Ne=e=>{var t,n,l,o,r;const i=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.modal;if(!i||!Ee[i])return Promise.reject("invalid-modal");const a=new Ee[i]((null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.props)||{}).open();(null===(l=null==e?void 0:e.detail)||void 0===l?void 0:l.then)&&a.then((t=>{var n,l;if(!(null==t?void 0:t.dismissed)&&(null===(n=null==e?void 0:e.detail)||void 0===n?void 0:n.finally))try{null===(l=null==e?void 0:e.detail)||void 0===l||l.then(null==t?void 0:t.result)}catch(e){console.error(e)}})),(null===(o=null==e?void 0:e.detail)||void 0===o?void 0:o.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",Ne),document.addEventListener("openModal",Ne));export{x as Button,C as Dropdown,Te as FadeModal,de as FormGroupTile,ee as FormGroupTileModel,L as GraphingContext,se as GraphingControl,G as GraphingControlModel,J as GraphingControlSettingsModel,re as GraphingGrid,q as GraphingSettingsModel,B as GraphingTile,ce as GraphingTileControls,Q as GraphingTileModel,j as GraphingTileSettingsModel,H as GraphingTiles,ue as HorizontalTile,te as HorizontalTileModel,ve as Modal,ye as MoorrModal,Y as MultipleControlsTileModel,me as SelectableStatesTile,ne as SelectableStatesTileModel,X as SingleControlTileModel,ge as SingleTile,le as SingleTileModel,he as VerticalTile,oe as VerticalTileModel,K as createGraphingControl,Z as createGraphingControls,R as createGraphingTile,O as createGraphingTiles,Ee as modals,fe as modalsStack,V as registerGraphingControl,ae as registerGraphingControlComponent,A as registerGraphingTile,S as registerGraphingTileComponent,$ as useGraphingContext};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moorr-react-mui",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Moorr React MUI Common Library",
5
5
  "scripts": {
6
6
  "_clear": "rimraf index.* && rimraf typings/* && rimraf cjs/*",