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