@australiangreens/ag-internal-components 0.0.40 → 0.0.42
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/AgDialog/index.d.ts +1 -0
- package/dist/components/AgDialog/index.d.ts.map +1 -1
- package/dist/domainCode/DomainCodeDialog.d.ts.map +1 -1
- package/dist/esm/index.js +140 -136
- package/dist/esm/index.js.map +1 -1
- package/dist/providers/Atom/AtomProvider.d.ts +1 -1
- 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 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 d=l=>{try{p(o.next(l))}catch(c){s(c)}},u=l=>{try{p(o.throw(l))}catch(c){s(c)}},p=l=>l.done?r(l.value):Promise.resolve(l.value).then(d,u);p((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),i=require("@mui/material"),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"),f=require("jotai"),ft=require("jotai/utils"),I=e=>e&&e.__esModule?e:{default:e},vt=I(st),Fe=I(lt),$e=I(ct),be=I(ut),mt=I(pt),Ct=I(gt),wt=I(xt),At=I(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),yt={},jt={},Me=({overrideState:e=yt,overrideActions:t=jt,children:o})=>{const[{open:r},s]=g.useState({open:!0}),d=g.useCallback(l=>{s({open:l})},[]),u=g.useCallback(()=>{s(l=>w(a({},l),{open:!l.open}))},[]),p=a(a({open:r,setOpen:d,toggleOpen:u},e),t);return n.jsx(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),It=J.createHelper((e=Re(),t={})=>({children:o})=>n.jsx(Me,{overrideState:e,overrideActions:t,children:o})),Te=7,Ot=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:d,onClose:u})=>{var c,C;const[p,l]=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=d==null?void 0:d.onClick)!=null?c:u,"data-testid":d==null?void 0:d.testId,disabled:(d==null?void 0:d.disabled)||p,children:(C=d==null?void 0:d.text)!=null?C:"Cancel"}),s&&n.jsx(be.default,{onClick:()=>X(exports,null,function*(){var v;l(!0),yield(v=s.onClick)==null?void 0:v.call(s),l(!1)}),"data-testid":s.testId,disabled:s.disabled||p,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: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`}))})),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 ye({children:e,anchor:t="left",open:o,onClose:r=()=>{},titleText:s="",width:d=qe,showCloseArrow:u=!0,debugOpacity:p=!1,headerBoxProps:l={},onOpened:c,onClosed:C,"data-testid":v,navBarOpen:A=!1,navBarWidthOpen:m=0,navBarWidthClosed:B=0}){return n.jsxs(_t,{SlideProps:{onEntered:()=>c==null?void 0:c(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:o,width:d,debugOpacity:p,"data-testid":v,navBarOpen:A,navBarWidthOpen:m,navBarWidthClosed:B,children:[n.jsx(Lt,w(a({anchor:t},l),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s}),u&&n.jsxs(i.IconButton,{onClick:r,size:"large","aria-label":"Close left side panel",children:[n.jsx(W.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[u&&n.jsxs(i.IconButton,{onClick:r,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",children:s})]})})),e]})}const 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:d=!1,pageContainerProps:u,pageContentDataTestId:p,topBarDataTestId:l,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:v}){const[A,m]=g.useState(ae),[B,T]=g.useState(ie),[j,D]=g.useState(ae),[O,$]=g.useState(ie),_=o!==void 0,L=r!==void 0,{titleText:y,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&&(m(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&&(m(k),s&&L&&(k?(T(!1),$(B)):T(O))),H&&H(k)},Ce=k=>{ee===void 0&&(T(k),s&&_&&(k?(m(!1),D(A)):m(j))),ve&&ve(k)};return n.jsxs(i.Box,{children:[_&&n.jsx(ye,{"data-testid":Ke,anchor:"left",open:ne,onClose:()=>me(!1),width:x,titleText:y,debugOpacity:d,showCloseArrow:h==="both"||h==="close",onOpened:Ye,onClosed:Je,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:v,children:q}),L&&n.jsx(ye,{"data-testid":ot,anchor:"right",open:oe,onClose:()=>Ce(!1),width:te,titleText:Ze,debugOpacity:d,showCloseArrow:G==="both"||G==="close",onOpened:tt,onClosed:nt,navBarOpen:c,navBarWidthOpen:C,navBarWidthClosed:v,children:et}),n.jsx($t,a(a({titleText:t,"data-testid":l},_&&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=f.atom(!0),de=f.atom(zt),ce=f.atom(qt),ue=f.atom(""),pe=f.atom(Wt),ge=f.atom(void 0),Gt="TopBar",Vt={titleText:`${Gt}-titleText`};function Ut({titleText:e="",height:t,"data-testid":o}){const r=f.useSetAtom(Z),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: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"}},je=(e,t,o)=>a({width:t,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen})},ze(e,o)),Ie=(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({},je(e,o,s)),{"& .MuiDrawer-paper":je(e,o,s)})),!t&&w(a({},Ie(e,r,s)),{"& .MuiDrawer-paper":Ie(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:d,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:[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,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:d,navBarDataTestId:u,navBarMiddle:p}){const[l,c]=f.useAtom(Z),[C]=f.useAtom(de),[v]=f.useAtom(ce),[A,m]=f.useAtom(ue),[B]=f.useAtom(pe),[T]=f.useAtom(ge);return g.useEffect(()=>{t!==void 0&&m(t)},[t,m]),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":d,height:B}),n.jsxs(i.Box,{sx:{display:"flex"},children:[n.jsx(Jt,{open:l,top:T,middle:p,bottom:l?n.jsx(i.Box,{sx:{padding:2},children:n.jsx(i.Paper,{sx:{padding:2,textWrap:"initial"},variant:"outlined",children:"Placeholder for standard user settings, domain selector etc. It should be at the very bottom, but WIP"})}):n.jsx(i.Box,{sx:{paddingTop:2},children:n.jsx(i.Paper,{sx:{padding:2,textWrap:"initial"},variant:"outlined",children:"WIP"})}),widthOpen:C,widthClosed:v,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"},Oe={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(d){var u=d,{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},l]=g.useState({open:!1}),c=g.useRef([]),C=g.useRef(Date.now()),v=g.useRef(0),A=g.useCallback(x=>{l({open:x})},[]),m=g.useCallback((x={})=>{v.current+=1,c.current.length>=ke&&Date.now()-C.current>=Ee&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${ke}) hit ${v.current} times in last ${Ee}ms)`),v.current=0);const h=a(w(a({},Oe),{key:on()}),x);return c.current.push(h),c.current.length===1&&l({open:!0}),h.key},[]),B=(x="",h={})=>m(a({message:x,severity:"success"},h)),T=(x="",h={})=>m(a({message:x,severity:"info"},h)),j=(x="",h={})=>m(a({message:x,severity:"warning"},h)),D=(x="",h={})=>m(a({message:x,severity:"error"},h)),O=x=>{const h=c.current.findIndex(F=>F.key===x);if(h!==-1)return h===0?(l({open:!1}),c.current[0]):c.current.splice(h,1)},$=(x,h)=>{o(x,h)&&l({open:!1})},_=()=>{},L=()=>{c.current.shift(),c.current.length>0&&l({open:!0})},y=(H=c.current[0])!=null?H:a({},Oe),q={};"autoHideDuration"in y&&(q.autoHideDuration=y.autoHideDuration);const z=a(a({},en),s),M=a(a({open:p,setOpen:A,enqueueNotification:m,enqueueSuccessNotification:B,enqueueInfoNotification:T,enqueueWarningNotification:j,enqueueErrorNotification:D,removeNotification:O},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:y.severity,variant:"filled",icon:y.progressIndicator==="circular"?n.jsx(i.CircularProgress,{size:"1em"}):void 0,style:y.progressIndicator==="linear"?rn:void 0,children:y.message}),y.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=f.getDefaultStore(),dn=({children:e,store:t})=>n.jsx(f.Provider,{store:t!=null?t:Ue,children:e}),Xe="domainCode";var Pe;const Ne=f.atom(JSON.parse((Pe=localStorage.getItem(Xe))!=null?Pe:"{}").domainCode),he=f.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:d})=>{const[u,p]=f.useAtom(he),[l,c]=g.useState(u),{enqueueSuccessNotification:C}=Ve(),v=r.length===0,A=!!u&&!r.includes(u)&&!r.includes(l),m=!u||v||A,B=()=>X(exports,null,function*(){l?(p(l),C(`Set domain to ${l}`),o()):p("")}),T=()=>X(exports,null,function*(){u&&!v&&!A?(c(u),o()):m&&d()});let j;return v?j="Unable to retrieve your active organisations. Try logging in again.":A&&(j="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:!l||v||A},secondaryButton:{text:m?"Logout":"Cancel",onClick:T},onClose:o,children:[n.jsxs(i.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",s,"."]}),n.jsx(i.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:l!=null?l:null,onChange:(D,O)=>c(O!=null?O:""),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]})})}))}),j&&n.jsx(i.FormHelperText,{error:!0,children:j})]})},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(f.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=Ot;exports.NavBarLightStyledList=kt;exports.NavBarProvider=Me;exports.PageLayout=Rt;exports.SaladBarProvider=Ge;exports.buildNavBarState=Re;exports.defaultStore=Ue;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=It;exports.withOverrideDefaults=vn;exports.withSaladBarProvider=ln;
|
|
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;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|