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