@australiangreens/ag-internal-components 0.0.31 → 0.0.33
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/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/components/NavBar/Styling.d.ts +1 -1
- package/dist/domainCode/DomainCodeDialog.d.ts +4 -2
- package/dist/domainCode/DomainCodeDialog.d.ts.map +1 -1
- package/dist/domainCode/hooks.d.ts +2 -3
- package/dist/domainCode/hooks.d.ts.map +1 -1
- package/dist/esm/index.js +730 -564
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/layouts/AppLayout/AppLayout.d.ts +5 -4
- package/dist/layouts/AppLayout/AppLayout.d.ts.map +1 -1
- package/dist/layouts/AppLayout/NavBar/Styling.d.ts +1 -1
- package/dist/layouts/PageLayout/PageContainer.d.ts +2 -2
- package/dist/themes/fed21Theme.d.ts +3 -0
- package/dist/themes/fed21Theme.d.ts.map +1 -0
- package/dist/themes/index.d.ts +4 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/internalAgSystemsTheme.d.ts +3 -0
- package/dist/themes/internalAgSystemsTheme.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Ye=Object.defineProperty,Ke=Object.defineProperties;var Je=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var ee=(e,t,n)=>t in e?Ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,r=(e,t)=>{for(var n in t||(t={}))xe.call(t,n)&&ee(e,n,t[n]);if(G)for(var n of G(t))he.call(t,n)&&ee(e,n,t[n]);return e},v=(e,t)=>Ke(e,Je(t));var fe=(e,t)=>{var n={};for(var a in e)xe.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&G)for(var a of G(e))t.indexOf(a)<0&&he.call(e,a)&&(n[a]=e[a]);return n};var ve=(e,t,n)=>(ee(e,typeof t!="symbol"?t+"":t,n),n);var te=(e,t,n)=>new Promise((a,s)=>{var c=d=>{try{g(n.next(d))}catch(l){s(l)}},p=d=>{try{g(n.throw(d))}catch(l){s(l)}},g=d=>d.done?a(d.value):Promise.resolve(d.value).then(c,p);g((n=n.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),u=require("react"),i=require("@mui/material"),Ze=require("@mui/material/CssBaseline"),D=require("@mui/material/styles"),et=require("@mui/material/Drawer"),tt=require("@australiangreens/ag-error"),Ae=require("souvlaki"),nt=require("@mui/material/List"),ot=require("@mui/material/Button"),rt=require("@mui/material/Dialog"),at=require("@mui/material/DialogActions"),it=require("@mui/material/DialogContent"),st=require("@mui/material/DialogTitle"),R=require("@mui/icons-material"),lt=require("src/components/AgDialog"),re=require("jotai"),Ne=require("jotai/utils"),S=e=>e&&e.__esModule?e:{default:e},dt=S(Ze),je=S(et),me=S(nt),Ce=S(ot),ct=S(rt),ut=S(at),pt=S(it),gt=S(st),xt=S(lt);function ht({text:e}){const[t,n]=u.useState(0);return o.jsxs(o.Fragment,{children:[o.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),o.jsx(i.Typography,{variant:"caption",display:"block",children:o.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),o.jsx(i.Button,{variant:"outlined",onClick:()=>n(a=>a+1),"aria-label":"Increment",children:"Hello I am a button"}),o.jsxs("p",{children:["This is some text: ",o.jsx("span",{children:e})]}),o.jsxs(i.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const ae=330,ie=73,A="Navbar",j={root:`${A}-root`,menuButton:`${A}-menuButton`,hide:`${A}-hide`,content:`${A}-content`,userInfoHolder:`${A}-userInfoHolder`,settings:`${A}-settings`,pieChartIcon:`${A}-pieChartIcon`},ft=D.styled("div",{name:"NavBar"})(({theme:e})=>({[`&.${j.root}`]:{display:"flex"},[`& .${j.menuButton}`]:{marginRight:36},[`& .${j.hide}`]:{display:"none"},[`& .${j.content}`]:{flexGrow:1,padding:e.spacing(3)},[`& .${j.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),De=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),vt=()=>r({width:ae},De()),Ct=()=>r({width:ie},De()),wt=D.styled(je.default,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>r(r({width:t?ae:ie,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":vt()}),!t&&{"& .MuiDrawer-paper":Ct()}));class H extends tt.AgError{}ve(H,"errorName","ContextError");const Le=u.createContext(null),Bt={},Tt={},Ee=({overrideState:e=Bt,overrideActions:t=Tt,children:n})=>{const[{open:a},s]=u.useState({open:!0}),c=u.useCallback(d=>{s({open:d})},[]),p=u.useCallback(()=>{s(d=>v(r({},d),{open:!d.open}))},[]),g=r(r({open:a,setOpen:c,toggleOpen:p},e),t);return o.jsx(Le.Provider,{value:g,children:n})},_e=()=>{const e=u.useContext(Le);if(e===null)throw new H("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},$e=(e={})=>r({open:!0},e),Ot=Ae.createHelper((e=$e(),t={})=>({children:n})=>o.jsx(Ee,{overrideState:e,overrideActions:t,children:n})),we=7,St=D.styled(me.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${we}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${we}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Be=7,bt=D.styled(me.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Be}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Be}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function yt({"data-testid":e,children:t}){const{open:n}=_e();return o.jsxs(ft,{className:j.root,"data-testid":e,children:[o.jsx(dt.default,{}),o.jsx(wt,{variant:"permanent",anchor:"left",transitionDuration:null,open:n,children:t})]})}const It=({isOpen:e,dialogTitle:t,children:n,maxWidth:a,primaryButton:s,secondaryButton:c,onClose:p})=>{var l,C;const[g,d]=u.useState(!1);return o.jsxs(ct.default,{open:e,onClose:()=>{g||p()},fullWidth:!0,maxWidth:a!=null?a:"xs",children:[o.jsx(gt.default,{children:t}),o.jsx(pt.default,{sx:{"& > :last-child":{marginBottom:0}},children:n}),o.jsxs(ut.default,{children:[o.jsx(Ce.default,{onClick:(l=c==null?void 0:c.onClick)!=null?l:p,"data-testid":c==null?void 0:c.testId,disabled:(c==null?void 0:c.disabled)||g,children:(C=c==null?void 0:c.text)!=null?C:"Cancel"}),s&&o.jsx(Ce.default,{onClick:()=>te(exports,null,function*(){var w;d(!0),yield(w=s.onClick)==null?void 0:w.call(s),d(!1)}),"data-testid":s.testId,disabled:s.disabled||g,children:s.text})]})]})},At=24,Nt=64,N="TopBar",T={topStripe:`${N}-topStripe`,titleBar:`${N}-titleBar`,titleSlider:`${N}-titleSlider`,titleText:`${N}-titleText`,leftPanelButton:`${N}-leftPanelButton`,rightPanelButton:`${N}-leftPanelButton`},jt=i.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:N})(({theme:e,leftPanel:t,rightPanel:n})=>{var a,s;return{width:"100%",[`& .${T.topStripe}`]:{width:"100%",height:`${At}px`,backgroundColor:e.palette.primary.main},[`& .${T.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Nt}px`,padding:e.spacing(0,3),width:"100%"},[`& .${T.titleSlider}`]:r(r({height:"100%",display:"flex",alignItems:"center",color:"white",transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),[`& .${T.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${T.titleText}`]:{flexGrow:1},[`& .${T.rightPanelButton}`]:{flexGrow:0}},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(a=t==null?void 0:t.width)!=null?a:0}px`}),(n==null?void 0:n.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(s=n==null?void 0:n.width)!=null?s:0}px`})}});function mt({titleText:e="",leftPanel:t,rightPanel:n,"data-testid":a}){return o.jsxs(jt,{leftPanel:t,rightPanel:n,"data-testid":a,children:[o.jsx("div",{className:T.topStripe}),o.jsx("div",{className:T.titleBar,children:o.jsxs(i.Box,{className:T.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&o.jsxs(i.IconButton,{className:T.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",o.jsx(R.ArrowForward,{})]}),o.jsx(i.Typography,{className:T.titleText,variant:"h6",noWrap:!0,children:e}),n!==void 0&&!n.open&&n.showOpenArrow&&o.jsxs(i.IconButton,{className:T.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:n==null?void 0:n.onOpen,edge:"end",size:"large",children:[" ",o.jsx(R.ArrowBack,{})]})]})})]})}const Pe=400,Dt=i.styled(i.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:n,navBarOpen:a,navBarWidthOpen:s,navBarWidthClosed:c})=>({width:e,"& .MuiDrawer-paper":r(r({position:"absolute",width:e,boxSizing:"border-box",border:"unset",boxShadow:"0px 4px 5px rgba(0, 0, 0, 0.14), 0px 1px 10px rgba(0, 0, 0, 0.12), 0px 2px 4px rgba(0, 0, 0, 0.2)"},t&&{opacity:"50%"}),n==="left"&&r({marginLeft:`${c}px`},a&&{marginLeft:`${s}px`}))})),Lt=i.styled(i.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>v(r({display:"flex",alignItems:"center",padding:e.spacing(2)},e.mixins.toolbar),{justifyContent:t==="left"?"space-between":"flex-start",backgroundColor:e.palette.primary.light,height:"88px","&,*":{color:"white"}," .MuiTypography-root":{fontSize:"22px"}," .MuiButtonBase-root":{marginRight:t==="right"?e.spacing(2):0}}));function Te({children:e,anchor:t="left",open:n,onClose:a=()=>{},titleText:s="",width:c=Pe,showCloseArrow:p=!0,debugOpacity:g=!1,headerBoxProps:d={},onOpened:l,onClosed:C,"data-testid":w,navBarOpen:x=!1,navBarWidthOpen:B=0,navBarWidthClosed:b=0}){return o.jsxs(Dt,{SlideProps:{onEntered:()=>l==null?void 0:l(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:n,width:c,debugOpacity:g,"data-testid":w,navBarOpen:x,navBarWidthOpen:B,navBarWidthClosed:b,children:[o.jsx(Lt,v(r({anchor:t},d),{children:t==="left"?o.jsxs(o.Fragment,{children:[o.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s}),p&&o.jsxs(i.IconButton,{onClick:a,size:"large","aria-label":"Close left side panel",children:[o.jsx(R.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):o.jsxs(o.Fragment,{children:[p&&o.jsxs(i.IconButton,{onClick:a,size:"large","aria-label":"Close right side panel",children:[o.jsx(R.ArrowForward,{})," "]}),o.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const Et=i.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:n})=>{var a,s;return r(r({transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(a=t==null?void 0:t.width)!=null?a:0}px`}),(n==null?void 0:n.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(s=n==null?void 0:n.width)!=null?s:0}px`})}),_t=i.styled(i.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),ne=!1,oe=!1,V={titleText:"",flavour:"push",width:Pe,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:o.jsx(o.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function $t({children:e,titleText:t="",leftPanel:n,rightPanel:a,sidePanelsAreMutuallyExclusive:s=!0,debugOpacity:c=!1,pageContainerProps:p,pageContentDataTestId:g,topBarDataTestId:d,navBarOpen:l,navBarWidthOpen:C,navBarWidthClosed:w}){const[x,B]=u.useState(ne),[b,y]=u.useState(oe),[X,M]=u.useState(ne),[Q,L]=u.useState(oe),E=n!==void 0,_=a!==void 0,{titleText:O,content:W,flavour:F,open:$,onChangeOpen:P,width:h,arrowButtons:f,startOpen:m,onOpened:Fe,onClosed:qe,dataTestId:ze}=n?r(r({},V),n):r({},V),{titleText:Ge,content:Ve,flavour:ce,open:Y,onChangeOpen:ue,width:K,arrowButtons:q,startOpen:z,onOpened:Ue,onClosed:Xe,dataTestId:Qe}=a?r(r({},V),a):r({},V);u.useEffect(()=>{m!==ne&&(B(m),M(m))},[m]),u.useEffect(()=>{z!==oe&&(y(z),L(z))},[z]);const J=$===void 0?x:$,Z=Y===void 0?b:Y,pe=I=>{$===void 0&&(B(I),s&&_&&(I?(y(!1),L(b)):y(Q))),P&&P(I)},ge=I=>{Y===void 0&&(y(I),s&&E&&(I?(B(!1),M(x)):B(X))),ue&&ue(I)};return o.jsxs(i.Box,{children:[E&&o.jsx(Te,{"data-testid":ze,anchor:"left",open:J,onClose:()=>pe(!1),width:h,titleText:O,debugOpacity:c,showCloseArrow:f==="both"||f==="close",onOpened:Fe,onClosed:qe,navBarOpen:l,navBarWidthOpen:C,navBarWidthClosed:w,children:W}),_&&o.jsx(Te,{"data-testid":Qe,anchor:"right",open:Z,onClose:()=>ge(!1),width:K,titleText:Ge,debugOpacity:c,showCloseArrow:q==="both"||q==="close",onOpened:Ue,onClosed:Xe,navBarOpen:l,navBarWidthOpen:C,navBarWidthClosed:w,children:Ve}),o.jsx(mt,r(r({titleText:t,"data-testid":d},E&&F==="push"?{leftPanel:{open:J,width:h,onOpen:()=>pe(!0),showOpenArrow:f==="both"||f==="open"}}:{}),_&&ce==="push"?{rightPanel:{open:Z,width:K,onOpen:()=>ge(!0),showOpenArrow:q==="both"||q==="open"}}:{})),o.jsx(Et,v(r(r({},F==="push"?{leftPanel:{open:J,width:h}}:{}),ce==="push"?{rightPanel:{open:Z,width:K}}:{}),{children:o.jsx(_t,v(r({"data-testid":g},p),{children:e}))}))]})}const Pt=64,kt=64,Rt=256,Ht={navBarOpen:!0,titleText:"",navBarWidthOpen:Rt,navBarWidthClosed:kt,topBarHeight:Pt,navBarTop:void 0};function Mt(e,t){switch(t.type){case"toggleNavBarOpen":return v(r({},e),{navBarOpen:!e.navBarOpen});case"setNavBarOpen":return v(r({},e),{navBarOpen:t.payload});case"setTitleText":return v(r({},e),{titleText:t.payload});case"setNavBarWidthOpen":return v(r({},e),{navBarWidthOpen:t.payload});case"setTopBarHeight":return v(r({},e),{topBarHeight:t.payload});case"setNavBarTop":return v(r({},e),{navBarTop:t.payload});default:throw new Error("Invalid action.type")}}const ke=u.createContext(null),Wt={},Ft={},Re=({overrideState:e=Wt,overrideActions:t=Ft,children:n})=>{const[{titleText:a,topBarHeight:s,navBarOpen:c,navBarWidthOpen:p,navBarWidthClosed:g,navBarTop:d},l]=u.useReducer(Mt,Ht),C=u.useMemo(()=>({toggleNavBarOpen:()=>l({type:"toggleNavBarOpen"}),setNavBarOpen:x=>l({type:"setNavBarOpen",payload:x}),setNavBarWidthOpen:x=>l({type:"setNavBarWidthOpen",payload:x}),setNavBarWidthClosed:x=>l({type:"setNavBarWidthClosed",payload:x}),setTitleText:x=>l({type:"setTitleText",payload:x}),setTopBarHeight:x=>l({type:"setTopBarHeight",payload:x}),setNavBarTop:x=>l({type:"setNavBarTop",payload:x}),clearNavBarTop:()=>l({type:"setNavBarTop",payload:void 0})}),[]),w=r(r(r({navBarOpen:c,navBarWidthOpen:p,navBarWidthClosed:g,titleText:a,topBarHeight:s,navBarTop:d},C),e),t);return o.jsx(ke.Provider,{value:w,children:n})},se=()=>{const e=u.useContext(ke);if(e===null)throw new H("Error: Tried to call useAppLayout() outside of a <AppLayoutProvider>");return e},qt="TopBar",zt={titleText:`${qt}-titleText`};function Gt({titleText:e="",height:t,"data-testid":n}){const{toggleNavBarOpen:a}=se();return o.jsx("header",{"data-testid":n,children:o.jsxs(i.Paper,{square:!0,elevation:0,sx:{width:"100%",position:"sticky",color:"primary.contrastText",backgroundColor:"primary.main",display:"flex",alignItems:"center",gap:2,flexShrink:0,height:t},children:[o.jsx(i.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:a,children:o.jsx(R.ViewHeadline,{fontSize:"medium"})}),o.jsx(i.Typography,{className:zt.titleText,variant:"h6",children:e})]})})}const U="Navbar",k={root:`${U}-root`,menuButton:`${U}-menuButton`,hide:`${U}-hide`,content:`${U}-content`},Vt=D.styled("div",{name:"NavBar"})(({theme:e})=>({[`&.${k.root}`]:{display:"flex"},[`& .${k.menuButton}`]:{marginRight:36},[`& .${k.hide}`]:{display:"none"},[`& .${k.content}`]:{flexGrow:1,padding:e.spacing(3)}})),He=(e,t)=>{var n,a;return{height:`calc(100vh - ${t})`,top:t,overflowX:"hidden",overflowY:"hidden",color:"inherit",backgroundColor:(a=(n=e==null?void 0:e.navBar)==null?void 0:n.backgroundColor)!=null?a:"white"}},Oe=(e,t,n)=>r({width:t,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen})},He(e,n)),Se=(e,t,n)=>r({width:t,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden"},He(e,n)),Ut=D.styled(je.default,{shouldForwardProp:e=>!["open","widthOpen","widthClosed","offsetTop"].includes(e)})(({theme:e,open:t,widthOpen:n,widthClosed:a,offsetTop:s})=>r(r({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box"},t&&v(r({},Oe(e,n,s)),{"& .MuiDrawer-paper":Oe(e,n,s)})),!t&&v(r({},Se(e,a,s)),{"& .MuiDrawer-paper":Se(e,a,s)})));function Xt({links:e}){return o.jsx("div",{children:"LinksMenu not implemented yet"})}function Qt({open:e,offsetTop:t=0,widthOpen:n,widthClosed:a,"data-testid":s,top:c,middle:p,bottom:g}){return o.jsx(Vt,{className:k.root,"data-testid":s,children:o.jsx(Ut,{variant:"permanent",anchor:"left",open:e,widthOpen:n,widthClosed:a,offsetTop:t,children:o.jsxs(i.Box,{component:"nav",sx:{},children:[c&&o.jsxs(i.Box,{sx:{flexGrow:1},children:[c,o.jsx(i.Divider,{variant:"middle"})]}),Array.isArray(p)?o.jsx(Xt,{links:p}):p,g&&o.jsxs(i.Box,{sx:{},children:[o.jsx(i.Divider,{variant:"middle"}),g]})]})})})}function Yt({children:e,topBarHeight:t}){return o.jsx(i.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:o.jsx(i.Container,{component:"main",id:"main-content",sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}function Kt({children:e,initialTitleText:t,initialNavBarOpen:n,pageContainerProps:a,pageContentDataTestId:s,topBarDataTestId:c,navBarDataTestId:p,navBarMiddle:g}){const{navBarOpen:d,setNavBarOpen:l,titleText:C,setTitleText:w,topBarHeight:x,navBarWidthOpen:B,navBarWidthClosed:b,navBarTop:y}=se();return u.useEffect(()=>{t!==void 0&&w(t)},[t,w]),u.useEffect(()=>{console.log(n),n!==void 0&&l(n)},[n,l]),o.jsxs(i.Box,{children:[o.jsx(i.CssBaseline,{}),o.jsx(Gt,{titleText:C,"data-testid":c,height:x}),o.jsxs(i.Box,{sx:{display:"flex"},children:[o.jsx(Qt,{open:d,top:y,middle:g,bottom:o.jsx(i.Box,{sx:{padding:2},children:o.jsx(i.Paper,{sx:{padding:2,textWrap:"initial"},variant:"outlined",children:"Placeholder for standard user settings, domain selector etc. It should be at the very bottom, but WIP"})}),widthOpen:B,widthClosed:b,offsetTop:x,"data-testid":p}),o.jsx(Yt,v(r({"data-testid":s,topBarHeight:x},a),{children:e}))]})]})}function Jt(e){return o.jsx(Re,{children:o.jsx(Kt,r({},e))})}const Zt={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},en={shouldClose:(e,t)=>t!=="clickaway"},be={message:"",severity:"info",variant:"standard",progressIndicator:void 0},ye=100,Ie=2e3,tn=2e3,nn=(()=>{let e=0;return()=>(e+=1,e)})(),on={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},rn={},an={},le=u.createContext(null);function Me(c){var p=c,{overrideState:e=rn,overrideActions:t=an,shouldClose:n=en.shouldClose,children:a}=p,s=fe(p,["overrideState","overrideActions","shouldClose","children"]);var P;const[{open:g},d]=u.useState({open:!1}),l=u.useRef([]),C=u.useRef(Date.now()),w=u.useRef(0),x=u.useCallback(h=>{d({open:h})},[]),B=u.useCallback((h={})=>{w.current+=1,l.current.length>=ye&&Date.now()-C.current>=Ie&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${ye}) hit ${w.current} times in last ${Ie}ms)`),w.current=0);const f=r(v(r({},be),{key:nn()}),h);return l.current.push(f),l.current.length===1&&d({open:!0}),f.key},[]),b=(h="",f={})=>B(r({message:h,severity:"success"},f)),y=(h="",f={})=>B(r({message:h,severity:"info"},f)),X=(h="",f={})=>B(r({message:h,severity:"warning"},f)),M=(h="",f={})=>B(r({message:h,severity:"error"},f)),Q=h=>{const f=l.current.findIndex(m=>m.key===h);if(f!==-1)return f===0?(d({open:!1}),l.current[0]):l.current.splice(f,1)},L=(h,f)=>{n(h,f)&&d({open:!1})},E=()=>{},_=()=>{l.current.shift(),l.current.length>0&&d({open:!0})},O=(P=l.current[0])!=null?P:r({},be),W={};"autoHideDuration"in O&&(W.autoHideDuration=O.autoHideDuration);const F=r(r({},Zt),s),$=r(r({open:g,setOpen:x,enqueueNotification:B,enqueueSuccessNotification:b,enqueueInfoNotification:y,enqueueWarningNotification:X,enqueueErrorNotification:M,removeNotification:Q},e),t);return o.jsxs(le.Provider,{value:$,children:[a,o.jsx(i.Snackbar,v(r(r({},F),W),{open:g,onClose:L,TransitionProps:{onExited:_,onExit:E},sx:{zIndex:tn},children:o.jsxs("div",{children:[o.jsx(i.Alert,{onClose:h=>L(h,"closeAlert"),severity:O.severity,variant:"filled",icon:O.progressIndicator==="circular"?o.jsx(i.CircularProgress,{size:"1em"}):void 0,style:O.progressIndicator==="linear"?on:void 0,children:O.message}),O.progressIndicator==="linear"&&o.jsx(i.LinearProgress,{color:"primary"})]})}))]})}function sn(){const e=u.useContext(le);if(e===null)throw new H("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const ln=Ae.createHelper((e={autoHideDuration:1},t={},n={})=>({children:a})=>o.jsx(Me,v(r({},e),{overrideState:t,overrideActions:n,children:a}))),de=Ne.atomWithStorage("domainCode","ag"),We=()=>{const[e,t]=re.useAtom(de);return[e,t,()=>t(Ne.RESET)]},dn=()=>re.useAtomValue(de),cn=()=>re.useSetAtom(de),un={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},pn=e=>{var t;return e===null?"N/A":(t=un[e])!=null?t:""},gn=({isLoading:e,isOpen:t,onClose:n,domainOptions:a})=>{const[s,c]=We(),[p,g]=u.useState(s);return o.jsxs(xt.default,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:()=>te(exports,null,function*(){c(p),n()})},onClose:n,children:[o.jsx("p",{children:"Select the default organisation that you want to use with the List Manager."}),o.jsx(i.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:p,onChange:(d,l)=>g(l!=null?l:""),getOptionLabel:pn,options:a,renderInput:d=>o.jsx(i.TextField,v(r({},d),{variant:"filled",label:"Select organisation",InputProps:v(r({},d.InputProps),{endAdornment:o.jsxs(o.Fragment,{children:[e?o.jsx(i.CircularProgress,{color:"inherit",size:20}):null,d.InputProps.endAdornment]})})}))})]})};exports.AgDialog=It;exports.AppLayout=Jt;exports.AppLayoutProvider=Re;exports.Context=le;exports.ContextError=H;exports.DomainCodeDialog=gn;exports.ExampleComponent=ht;exports.NAVBAR_WIDTH_CLOSED=ie;exports.NAVBAR_WIDTH_OPENED=ae;exports.NavBar=yt;exports.NavBarDarkStyledList=St;exports.NavBarLightStyledList=bt;exports.NavBarProvider=Ee;exports.PageLayout=$t;exports.SaladBarProvider=Me;exports.buildNavBarState=$e;exports.navBarClasses=j;exports.useAppLayout=se;exports.useDomainCode=We;exports.useDomainCodeValue=dn;exports.useNavBar=_e;exports.useSaladBar=sn;exports.useSetDomainCode=cn;exports.withNavBarProvider=Ot;exports.withSaladBarProvider=ln;
|
|
1
|
+
"use strict";var et=Object.defineProperty,tt=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var ne=(e,t,n)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,r=(e,t)=>{for(var n in t||(t={}))xe.call(t,n)&&ne(e,n,t[n]);if(U)for(var n of U(t))he.call(t,n)&&ne(e,n,t[n]);return e},C=(e,t)=>tt(e,nt(t));var fe=(e,t)=>{var n={};for(var a in e)xe.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&U)for(var a of U(e))t.indexOf(a)<0&&he.call(e,a)&&(n[a]=e[a]);return n};var ve=(e,t,n)=>(ne(e,typeof t!="symbol"?t+"":t,n),n);var X=(e,t,n)=>new Promise((a,s)=>{var c=l=>{try{x(n.next(l))}catch(d){s(d)}},u=l=>{try{x(n.throw(l))}catch(d){s(d)}},x=l=>l.done?a(l.value):Promise.resolve(l.value).then(c,u);x((n=n.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),g=require("react"),i=require("@mui/material"),ot=require("@mui/material/CssBaseline"),T=require("@mui/material/styles"),rt=require("@mui/material/Drawer"),at=require("@australiangreens/ag-error"),Ie=require("souvlaki"),it=require("@mui/material/List"),st=require("@mui/material/Button"),lt=require("@mui/material/Dialog"),dt=require("@mui/material/DialogActions"),ct=require("@mui/material/DialogContent"),ut=require("@mui/material/DialogTitle"),H=require("@mui/icons-material"),R=require("jotai"),O=e=>e&&e.__esModule?e:{default:e},pt=O(ot),Ne=O(rt),je=O(it),Ce=O(st),gt=O(lt),xt=O(dt),ht=O(ct),ft=O(ut);function vt({text:e}){const[t,n]=g.useState(0);return o.jsxs(o.Fragment,{children:[o.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),o.jsx(i.Typography,{variant:"caption",display:"block",children:o.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),o.jsx(i.Button,{variant:"outlined",onClick:()=>n(a=>a+1),"aria-label":"Increment",children:"Hello I am a button"}),o.jsxs("p",{children:["This is some text: ",o.jsx("span",{children:e})]}),o.jsxs(i.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const ae=330,ie=73,N="Navbar",E={root:`${N}-root`,menuButton:`${N}-menuButton`,hide:`${N}-hide`,content:`${N}-content`,userInfoHolder:`${N}-userInfoHolder`,settings:`${N}-settings`,pieChartIcon:`${N}-pieChartIcon`},Ct=T.styled("div",{name:"NavBar"})(({theme:e})=>({[`&.${E.root}`]:{display:"flex"},[`& .${E.menuButton}`]:{marginRight:36},[`& .${E.hide}`]:{display:"none"},[`& .${E.content}`]:{flexGrow:1,padding:e.spacing(3)},[`& .${E.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),Ee=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),Bt=()=>r({width:ae},Ee()),mt=()=>r({width:ie},Ee()),wt=T.styled(Ne.default,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>r(r({width:t?ae:ie,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Bt()}),!t&&{"& .MuiDrawer-paper":mt()}));class W extends at.AgError{}ve(W,"errorName","ContextError");const ke=g.createContext(null),yt={},Tt={},Le=({overrideState:e=yt,overrideActions:t=Tt,children:n})=>{const[{open:a},s]=g.useState({open:!0}),c=g.useCallback(l=>{s({open:l})},[]),u=g.useCallback(()=>{s(l=>C(r({},l),{open:!l.open}))},[]),x=r(r({open:a,setOpen:c,toggleOpen:u},e),t);return o.jsx(ke.Provider,{value:x,children:n})},Pe=()=>{const e=g.useContext(ke);if(e===null)throw new W("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},$e=(e={})=>r({open:!0},e),St=Ie.createHelper((e=$e(),t={})=>({children:n})=>o.jsx(Le,{overrideState:e,overrideActions:t,children:n})),Be=7,bt=T.styled(je.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${Be}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Be}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),me=7,Dt=T.styled(je.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${me}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${me}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function At({"data-testid":e,children:t}){const{open:n}=Pe();return o.jsxs(Ct,{className:E.root,"data-testid":e,children:[o.jsx(pt.default,{}),o.jsx(wt,{variant:"permanent",anchor:"left",transitionDuration:null,open:n,children:t})]})}const Fe=({isOpen:e,dialogTitle:t,children:n,maxWidth:a,primaryButton:s,secondaryButton:c,onClose:u})=>{var d,B;const[x,l]=g.useState(!1);return o.jsxs(gt.default,{open:e,onClose:()=>{x||u()},fullWidth:!0,maxWidth:a!=null?a:"xs",children:[o.jsx(ft.default,{children:t}),o.jsx(ht.default,{sx:{"& > :last-child":{marginBottom:0}},children:n}),o.jsxs(xt.default,{children:[o.jsx(Ce.default,{onClick:(d=c==null?void 0:c.onClick)!=null?d:u,"data-testid":c==null?void 0:c.testId,disabled:(c==null?void 0:c.disabled)||x,children:(B=c==null?void 0:c.text)!=null?B:"Cancel"}),s&&o.jsx(Ce.default,{onClick:()=>X(exports,null,function*(){var h;l(!0),yield(h=s.onClick)==null?void 0:h.call(s),l(!1)}),"data-testid":s.testId,disabled:s.disabled||x,children:s.text})]})]})},Ot=24,It=64,j="TopBar",y={topStripe:`${j}-topStripe`,titleBar:`${j}-titleBar`,titleSlider:`${j}-titleSlider`,titleText:`${j}-titleText`,leftPanelButton:`${j}-leftPanelButton`,rightPanelButton:`${j}-leftPanelButton`},Nt=i.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:j})(({theme:e,leftPanel:t,rightPanel:n})=>{var a,s;return{width:"100%",[`& .${y.topStripe}`]:{width:"100%",height:`${Ot}px`,backgroundColor:e.palette.primary.main},[`& .${y.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${It}px`,padding:e.spacing(0,3),width:"100%"},[`& .${y.titleSlider}`]:r(r({height:"100%",display:"flex",alignItems:"center",color:"white",transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),[`& .${y.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${y.titleText}`]:{flexGrow:1},[`& .${y.rightPanelButton}`]:{flexGrow:0}},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(a=t==null?void 0:t.width)!=null?a:0}px`}),(n==null?void 0:n.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(s=n==null?void 0:n.width)!=null?s:0}px`})}});function jt({titleText:e="",leftPanel:t,rightPanel:n,"data-testid":a}){return o.jsxs(Nt,{leftPanel:t,rightPanel:n,"data-testid":a,children:[o.jsx("div",{className:y.topStripe}),o.jsx("div",{className:y.titleBar,children:o.jsxs(i.Box,{className:y.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&o.jsxs(i.IconButton,{className:y.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",o.jsx(H.ArrowForward,{})]}),o.jsx(i.Typography,{className:y.titleText,variant:"h6",noWrap:!0,children:e}),n!==void 0&&!n.open&&n.showOpenArrow&&o.jsxs(i.IconButton,{className:y.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:n==null?void 0:n.onOpen,edge:"end",size:"large",children:[" ",o.jsx(H.ArrowBack,{})]})]})})]})}const _e=400,Et=i.styled(i.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:n,navBarOpen:a,navBarWidthOpen:s,navBarWidthClosed:c})=>({width:e,"& .MuiDrawer-paper":r(r({position:"absolute",width:e,boxSizing:"border-box",border:"unset",boxShadow:"0px 4px 5px rgba(0, 0, 0, 0.14), 0px 1px 10px rgba(0, 0, 0, 0.12), 0px 2px 4px rgba(0, 0, 0, 0.2)"},t&&{opacity:"50%"}),n==="left"&&r({marginLeft:`${c}px`},a&&{marginLeft:`${s}px`}))})),kt=i.styled(i.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>C(r({display:"flex",alignItems:"center",padding:e.spacing(2)},e.mixins.toolbar),{justifyContent:t==="left"?"space-between":"flex-start",backgroundColor:e.palette.primary.light,height:"88px","&,*":{color:"white"}," .MuiTypography-root":{fontSize:"22px"}," .MuiButtonBase-root":{marginRight:t==="right"?e.spacing(2):0}}));function we({children:e,anchor:t="left",open:n,onClose:a=()=>{},titleText:s="",width:c=_e,showCloseArrow:u=!0,debugOpacity:x=!1,headerBoxProps:l={},onOpened:d,onClosed:B,"data-testid":h,navBarOpen:p=!1,navBarWidthOpen:m=0,navBarWidthClosed:S=0}){return o.jsxs(Et,{SlideProps:{onEntered:()=>d==null?void 0:d(),onExited:()=>B==null?void 0:B()},variant:"persistent",anchor:t,open:n,width:c,debugOpacity:x,"data-testid":h,navBarOpen:p,navBarWidthOpen:m,navBarWidthClosed:S,children:[o.jsx(kt,C(r({anchor:t},l),{children:t==="left"?o.jsxs(o.Fragment,{children:[o.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s}),u&&o.jsxs(i.IconButton,{onClick:a,size:"large","aria-label":"Close left side panel",children:[o.jsx(H.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):o.jsxs(o.Fragment,{children:[u&&o.jsxs(i.IconButton,{onClick:a,size:"large","aria-label":"Close right side panel",children:[o.jsx(H.ArrowForward,{})," "]}),o.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const Lt=i.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:n})=>{var a,s;return r(r({transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(a=t==null?void 0:t.width)!=null?a:0}px`}),(n==null?void 0:n.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(s=n==null?void 0:n.width)!=null?s:0}px`})}),Pt=i.styled(i.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),oe=!1,re=!1,Y={titleText:"",flavour:"push",width:_e,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:o.jsx(o.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function $t({children:e,titleText:t="",leftPanel:n,rightPanel:a,sidePanelsAreMutuallyExclusive:s=!0,debugOpacity:c=!1,pageContainerProps:u,pageContentDataTestId:x,topBarDataTestId:l,navBarOpen:d,navBarWidthOpen:B,navBarWidthClosed:h}){const[p,m]=g.useState(oe),[S,w]=g.useState(re),[D,A]=g.useState(oe),[K,L]=g.useState(re),P=n!==void 0,$=a!==void 0,{titleText:b,content:q,flavour:z,open:F,onChangeOpen:_,width:f,arrowButtons:v,startOpen:k,onOpened:Ve,onClosed:Ue,dataTestId:Xe}=n?r(r({},Y),n):r({},Y),{titleText:Ye,content:Qe,flavour:ce,open:J,onChangeOpen:ue,width:Z,arrowButtons:G,startOpen:V,onOpened:Ke,onClosed:Je,dataTestId:Ze}=a?r(r({},Y),a):r({},Y);g.useEffect(()=>{k!==oe&&(m(k),A(k))},[k]),g.useEffect(()=>{V!==re&&(w(V),L(V))},[V]);const ee=F===void 0?p:F,te=J===void 0?S:J,pe=I=>{F===void 0&&(m(I),s&&$&&(I?(w(!1),L(S)):w(K))),_&&_(I)},ge=I=>{J===void 0&&(w(I),s&&P&&(I?(m(!1),A(p)):m(D))),ue&&ue(I)};return o.jsxs(i.Box,{children:[P&&o.jsx(we,{"data-testid":Xe,anchor:"left",open:ee,onClose:()=>pe(!1),width:f,titleText:b,debugOpacity:c,showCloseArrow:v==="both"||v==="close",onOpened:Ve,onClosed:Ue,navBarOpen:d,navBarWidthOpen:B,navBarWidthClosed:h,children:q}),$&&o.jsx(we,{"data-testid":Ze,anchor:"right",open:te,onClose:()=>ge(!1),width:Z,titleText:Ye,debugOpacity:c,showCloseArrow:G==="both"||G==="close",onOpened:Ke,onClosed:Je,navBarOpen:d,navBarWidthOpen:B,navBarWidthClosed:h,children:Qe}),o.jsx(jt,r(r({titleText:t,"data-testid":l},P&&z==="push"?{leftPanel:{open:ee,width:f,onOpen:()=>pe(!0),showOpenArrow:v==="both"||v==="open"}}:{}),$&&ce==="push"?{rightPanel:{open:te,width:Z,onOpen:()=>ge(!0),showOpenArrow:G==="both"||G==="open"}}:{})),o.jsx(Lt,C(r(r({},z==="push"?{leftPanel:{open:ee,width:f}}:{}),ce==="push"?{rightPanel:{open:te,width:Z}}:{}),{children:o.jsx(Pt,C(r({"data-testid":x},u),{children:e}))}))]})}const Ft=64,_t=64,Mt=256,Ht={navBarOpen:!0,titleText:"",navBarWidthOpen:Mt,navBarWidthClosed:_t,topBarHeight:Ft,navBarTop:void 0};function Rt(e,t){switch(t.type){case"toggleNavBarOpen":return C(r({},e),{navBarOpen:!e.navBarOpen});case"setNavBarOpen":return C(r({},e),{navBarOpen:t.payload});case"setTitleText":return C(r({},e),{titleText:t.payload});case"setNavBarWidthOpen":return C(r({},e),{navBarWidthOpen:t.payload});case"setTopBarHeight":return C(r({},e),{topBarHeight:t.payload});case"setNavBarTop":return C(r({},e),{navBarTop:t.payload});default:throw new Error("Invalid action.type")}}const Me=g.createContext(null),Wt={},qt={},He=({overrideState:e=Wt,overrideActions:t=qt,children:n})=>{const[{titleText:a,topBarHeight:s,navBarOpen:c,navBarWidthOpen:u,navBarWidthClosed:x,navBarTop:l},d]=g.useReducer(Rt,Ht),B=g.useMemo(()=>({toggleNavBarOpen:()=>d({type:"toggleNavBarOpen"}),setNavBarOpen:p=>d({type:"setNavBarOpen",payload:p}),setNavBarWidthOpen:p=>d({type:"setNavBarWidthOpen",payload:p}),setNavBarWidthClosed:p=>d({type:"setNavBarWidthClosed",payload:p}),setTitleText:p=>d({type:"setTitleText",payload:p}),setTopBarHeight:p=>d({type:"setTopBarHeight",payload:p}),setNavBarTop:p=>d({type:"setNavBarTop",payload:p}),clearNavBarTop:()=>d({type:"setNavBarTop",payload:void 0})}),[]),h=r(r(r({navBarOpen:c,navBarWidthOpen:u,navBarWidthClosed:x,titleText:a,topBarHeight:s,navBarTop:l},B),e),t);return o.jsx(Me.Provider,{value:h,children:n})},se=()=>{const e=g.useContext(Me);if(e===null)throw new W("Error: Tried to call useAppLayout() outside of a <AppLayoutProvider>");return e},zt="TopBar",Gt={titleText:`${zt}-titleText`};function Vt({titleText:e="",height:t,"data-testid":n}){const{toggleNavBarOpen:a}=se();return o.jsx("header",{"data-testid":n,children:o.jsxs(i.Paper,{square:!0,elevation:0,sx:{width:"100%",position:"sticky",color:"primary.contrastText",backgroundColor:"primary.main",display:"flex",alignItems:"center",gap:2,flexShrink:0,height:t},children:[o.jsx(i.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:a,children:o.jsx(H.ViewHeadline,{fontSize:"medium"})}),o.jsx(i.Typography,{className:Gt.titleText,variant:"h6",children:e})]})})}const Q="Navbar",M={root:`${Q}-root`,menuButton:`${Q}-menuButton`,hide:`${Q}-hide`,content:`${Q}-content`},Ut=T.styled("div",{name:"NavBar"})(({theme:e})=>({[`&.${M.root}`]:{display:"flex"},[`& .${M.menuButton}`]:{marginRight:36},[`& .${M.hide}`]:{display:"none"},[`& .${M.content}`]:{flexGrow:1,padding:e.spacing(3)}})),Re=(e,t)=>{var n,a;return{height:`calc(100vh - ${t})`,top:t,overflowX:"hidden",overflowY:"hidden",color:"inherit",backgroundColor:(a=(n=e==null?void 0:e.navBar)==null?void 0:n.backgroundColor)!=null?a:"white"}},ye=(e,t,n)=>r({width:t,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen})},Re(e,n)),Te=(e,t,n)=>r({width:t,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden"},Re(e,n)),Xt=T.styled(Ne.default,{shouldForwardProp:e=>!["open","widthOpen","widthClosed","offsetTop"].includes(e)})(({theme:e,open:t,widthOpen:n,widthClosed:a,offsetTop:s})=>r(r({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box"},t&&C(r({},ye(e,n,s)),{"& .MuiDrawer-paper":ye(e,n,s)})),!t&&C(r({},Te(e,a,s)),{"& .MuiDrawer-paper":Te(e,a,s)})));function Yt({links:e}){return o.jsx("div",{children:"LinksMenu not implemented yet"})}function Qt({open:e,offsetTop:t=0,widthOpen:n,widthClosed:a,"data-testid":s,top:c,middle:u,bottom:x}){return o.jsx(Ut,{className:M.root,"data-testid":s,children:o.jsx(Xt,{variant:"permanent",anchor:"left",open:e,widthOpen:n,widthClosed:a,offsetTop:t,children:o.jsxs(i.Box,{component:"nav",sx:{},children:[c&&o.jsxs(i.Box,{sx:{flexGrow:1},children:[c,o.jsx(i.Divider,{variant:"middle"})]}),Array.isArray(u)?o.jsx(Yt,{links:u}):u,x&&o.jsxs(i.Box,{sx:{},children:[o.jsx(i.Divider,{variant:"middle"}),x]})]})})})}function Kt({children:e,topBarHeight:t}){return o.jsx(i.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:o.jsx(i.Container,{component:"main",id:"main-content",sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}function Jt({children:e,initialTitleText:t,initialNavBarOpen:n,pageContainerProps:a,pageContentDataTestId:s,topBarDataTestId:c,navBarDataTestId:u,navBarMiddle:x}){const{navBarOpen:l,setNavBarOpen:d,titleText:B,setTitleText:h,topBarHeight:p,navBarWidthOpen:m,navBarWidthClosed:S,navBarTop:w}=se();return g.useEffect(()=>{t!==void 0&&h(t)},[t,h]),g.useEffect(()=>{console.log(n),n!==void 0&&d(n)},[n,d]),o.jsxs(i.Box,{children:[o.jsx(i.CssBaseline,{}),o.jsx(Vt,{titleText:B,"data-testid":c,height:p}),o.jsxs(i.Box,{sx:{display:"flex"},children:[o.jsx(Qt,{open:l,top:w,middle:x,bottom:l?o.jsx(i.Box,{sx:{padding:2},children:o.jsx(i.Paper,{sx:{padding:2,textWrap:"initial"},variant:"outlined",children:"Placeholder for standard user settings, domain selector etc. It should be at the very bottom, but WIP"})}):o.jsx(i.Box,{sx:{paddingTop:2},children:o.jsx(i.Paper,{sx:{padding:2,textWrap:"initial"},variant:"outlined",children:"WIP"})}),widthOpen:m,widthClosed:S,offsetTop:p,"data-testid":u}),o.jsx(Kt,C(r({"data-testid":s,topBarHeight:p},a),{children:e}))]})]})}function Zt(e){return o.jsx(He,{children:o.jsx(Jt,r({},e))})}const en={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},tn={shouldClose:(e,t)=>t!=="clickaway"},Se={message:"",severity:"info",variant:"standard",progressIndicator:void 0},be=100,De=2e3,nn=2e3,on=(()=>{let e=0;return()=>(e+=1,e)})(),rn={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},an={},sn={},le=g.createContext(null);function We(c){var u=c,{overrideState:e=an,overrideActions:t=sn,shouldClose:n=tn.shouldClose,children:a}=u,s=fe(u,["overrideState","overrideActions","shouldClose","children"]);var _;const[{open:x},l]=g.useState({open:!1}),d=g.useRef([]),B=g.useRef(Date.now()),h=g.useRef(0),p=g.useCallback(f=>{l({open:f})},[]),m=g.useCallback((f={})=>{h.current+=1,d.current.length>=be&&Date.now()-B.current>=De&&(B.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${be}) hit ${h.current} times in last ${De}ms)`),h.current=0);const v=r(C(r({},Se),{key:on()}),f);return d.current.push(v),d.current.length===1&&l({open:!0}),v.key},[]),S=(f="",v={})=>m(r({message:f,severity:"success"},v)),w=(f="",v={})=>m(r({message:f,severity:"info"},v)),D=(f="",v={})=>m(r({message:f,severity:"warning"},v)),A=(f="",v={})=>m(r({message:f,severity:"error"},v)),K=f=>{const v=d.current.findIndex(k=>k.key===f);if(v!==-1)return v===0?(l({open:!1}),d.current[0]):d.current.splice(v,1)},L=(f,v)=>{n(f,v)&&l({open:!1})},P=()=>{},$=()=>{d.current.shift(),d.current.length>0&&l({open:!0})},b=(_=d.current[0])!=null?_:r({},Se),q={};"autoHideDuration"in b&&(q.autoHideDuration=b.autoHideDuration);const z=r(r({},en),s),F=r(r({open:x,setOpen:p,enqueueNotification:m,enqueueSuccessNotification:S,enqueueInfoNotification:w,enqueueWarningNotification:D,enqueueErrorNotification:A,removeNotification:K},e),t);return o.jsxs(le.Provider,{value:F,children:[a,o.jsx(i.Snackbar,C(r(r({},z),q),{open:x,onClose:L,TransitionProps:{onExited:$,onExit:P},sx:{zIndex:nn},children:o.jsxs("div",{children:[o.jsx(i.Alert,{onClose:f=>L(f,"closeAlert"),severity:b.severity,variant:"filled",icon:b.progressIndicator==="circular"?o.jsx(i.CircularProgress,{size:"1em"}):void 0,style:b.progressIndicator==="linear"?rn:void 0,children:b.message}),b.progressIndicator==="linear"&&o.jsx(i.LinearProgress,{color:"primary"})]})}))]})}function qe(){const e=g.useContext(le);if(e===null)throw new W("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const ln=Ie.createHelper((e={autoHideDuration:1},t={},n={})=>({children:a})=>o.jsx(We,C(r({},e),{overrideState:t,overrideActions:n,children:a}))),ze="domainCode";var Oe;const Ae=R.atom((Oe=localStorage.getItem(ze))!=null?Oe:""),de=R.atom(e=>e(Ae),(e,t,n)=>{t(Ae,n),localStorage.setItem(ze,n)}),Ge=()=>{const[e,t]=R.useAtom(de);return[e,t,()=>t("")]},dn=()=>R.useAtomValue(de),cn=()=>R.useSetAtom(de),un={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},pn=e=>{var t;return e===null?"N/A":(t=un[e])!=null?t:""},gn=({isLoading:e,isOpen:t,onClose:n,domainOptions:a,applicationName:s,handleLogout:c})=>{const[u,x]=Ge(),[l,d]=g.useState(u),{enqueueSuccessNotification:B}=qe(),h=a.length===0,p=!!u&&!a.includes(u)&&!!l&&!a.includes(l),m=()=>X(exports,null,function*(){l?(x(l),B(`Set domain to ${l}`),n()):x("")}),S=()=>X(exports,null,function*(){u&&!h&&!p?(d(u),n()):(!u||h||p)&&c()});let w;return h?w="Unable to retrieve your active organisations. Try logging in again.":p&&(w="You no longer have any roles in your chosen organisation. Please choose another."),o.jsxs(Fe,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:m,disabled:!l||h||p},secondaryButton:{text:!l||h||p?"Logout":"Cancel",onClick:S},onClose:n,children:[o.jsxs(i.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",s,"."]}),o.jsx(i.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:l,onChange:(D,A)=>d(A!=null?A:""),getOptionLabel:pn,options:a,renderInput:D=>o.jsx(i.TextField,C(r({},D),{variant:"filled",label:"Select organisation",InputProps:C(r({},D.InputProps),{endAdornment:o.jsxs(o.Fragment,{children:[e?o.jsx(i.CircularProgress,{color:"inherit",size:20}):null,D.InputProps.endAdornment]})})}))}),w&&o.jsx(i.FormHelperText,{error:!0,children:w})]})},xn=T.createTheme({palette:{primary:{dark:"#00A651",light:"#A3D39C",main:"#007236",contrastText:"#FFF"},warning:{main:"#F5871F",light:"#FCC589",dark:"#A2590A",contrastText:"#FFF"},secondary:{main:"#662D91",light:"#BD8CBF",dark:"#440E62",contrastText:"#FFF"},error:{main:"#D43C95",light:"#8F2064",dark:"#F9CDE0",contrastText:"#FFF"},info:{main:"#00A88D",light:"#ADDCCF",dark:"#005243",contrastText:"#FFF"},success:{main:"#00A651",light:"#A3D39C",dark:"#007236",contrastText:"#FFF"}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}}),hn=T.createTheme({palette:{primary:{main:"#007236",dark:"#005221",light:"#00A04E",contrastText:"#FFFFFF"},secondary:{main:"#662D91",dark:"#440E62",light:"#93268F",contrastText:"#FFFFFF"},error:{main:"#D32F2F",dark:"#C62828",light:"#EF5350"},info:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"},success:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"}},components:{MuiTextField:{defaultProps:{color:"secondary"}},MuiToggleButtonGroup:{defaultProps:{color:"secondary"}},MuiCheckbox:{defaultProps:{color:"secondary"}},MuiSelect:{defaultProps:{color:"secondary"}},MuiSwitch:{defaultProps:{color:"secondary"}},MuiFormControl:{defaultProps:{color:"secondary"}},MuiMenuItem:{styleOverrides:{root:({theme:e})=>({"&.Mui-selected":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}});exports.AgDialog=Fe;exports.AppLayout=Zt;exports.AppLayoutProvider=He;exports.Context=le;exports.ContextError=W;exports.DomainCodeDialog=gn;exports.ExampleComponent=vt;exports.NAVBAR_WIDTH_CLOSED=ie;exports.NAVBAR_WIDTH_OPENED=ae;exports.NavBar=At;exports.NavBarDarkStyledList=bt;exports.NavBarLightStyledList=Dt;exports.NavBarProvider=Le;exports.PageLayout=$t;exports.SaladBarProvider=We;exports.buildNavBarState=$e;exports.fed21Theme=xn;exports.internalAgSystemsTheme=hn;exports.navBarClasses=E;exports.useAppLayout=se;exports.useDomainCode=Ge;exports.useDomainCodeValue=dn;exports.useNavBar=Pe;exports.useSaladBar=qe;exports.useSetDomainCode=cn;exports.withNavBarProvider=St;exports.withSaladBarProvider=ln;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|