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