@australiangreens/ag-internal-components 0.0.16 → 0.0.17

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.
Files changed (31) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/components/index.d.ts +3 -0
  4. package/dist/components/index.d.ts.map +1 -0
  5. package/dist/errors/ContextError.d.ts +5 -0
  6. package/dist/errors/ContextError.d.ts.map +1 -0
  7. package/dist/errors/index.d.ts +2 -0
  8. package/dist/errors/index.d.ts.map +1 -0
  9. package/dist/esm/index.js +164 -28
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/index.d.ts +4 -5
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/providers/AgTheme/index.d.ts.map +1 -0
  14. package/dist/providers/AgTheme/themes.d.ts.map +1 -0
  15. package/dist/providers/SaladBar/SaladBarContext.d.ts +26 -0
  16. package/dist/providers/SaladBar/SaladBarContext.d.ts.map +1 -0
  17. package/dist/providers/SaladBar/SaladBarProvider.d.ts +7 -0
  18. package/dist/providers/SaladBar/SaladBarProvider.d.ts.map +1 -0
  19. package/dist/providers/SaladBar/defaults.d.ts +13 -0
  20. package/dist/providers/SaladBar/defaults.d.ts.map +1 -0
  21. package/dist/providers/SaladBar/index.d.ts +3 -0
  22. package/dist/providers/SaladBar/index.d.ts.map +1 -0
  23. package/dist/providers/SaladBar/useSaladBar.d.ts +29 -0
  24. package/dist/providers/SaladBar/useSaladBar.d.ts.map +1 -0
  25. package/dist/providers/index.d.ts +5 -0
  26. package/dist/providers/index.d.ts.map +1 -0
  27. package/package.json +5 -2
  28. package/dist/components/AgThemeProvider/index.d.ts.map +0 -1
  29. package/dist/components/AgThemeProvider/themes.d.ts.map +0 -1
  30. /package/dist/{components/AgThemeProvider → providers/AgTheme}/index.d.ts +0 -0
  31. /package/dist/{components/AgThemeProvider → providers/AgTheme}/themes.d.ts +0 -0
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("react"),c=require("@mui/material/Button"),l=require("@mui/material/Paper"),a=require("@mui/material/Typography"),r=require("@mui/material/styles");function d({text:e}){const[n,o]=s.useState(0);return t.jsxs(t.Fragment,{children:[t.jsx(a,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),t.jsx(a,{variant:"caption",display:"block",children:t.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),t.jsx(c,{variant:"outlined",onClick:()=>o(i=>i+1),"aria-label":"Increment",children:"Hello I am a button"}),t.jsxs("p",{children:["This is some text: ",t.jsx("span",{children:e})]}),t.jsxs(l,{children:["This number will incremember when button pressed: ",n]})]})}const p=r.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:r.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:r.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:r.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}}}),u=r.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"}}});function F({name:e="internal",children:n}){const o=e==="internal"?p:e==="fed21"?u:void 0;return t.jsx(r.ThemeProvider,{theme:o,children:n})}exports.AgThemeProvider=F;exports.ExampleComponent=d;
1
+ "use strict";var U=Object.defineProperty,W=Object.defineProperties;var G=Object.getOwnPropertyDescriptors;var m=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var y=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,s=(e,t)=>{for(var r in t||(t={}))k.call(t,r)&&y(e,r,t[r]);if(m)for(var r of m(t))T.call(t,r)&&y(e,r,t[r]);return e},F=(e,t)=>W(e,G(t));var b=(e,t)=>{var r={};for(var o in e)k.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&m)for(var o of m(e))t.indexOf(o)<0&&T.call(e,o)&&(r[o]=e[o]);return r};var A=(e,t,r)=>(y(e,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("react"),X=require("@mui/material/Button"),Q=require("@mui/material/Paper"),P=require("@mui/material/Typography"),d=require("@mui/material/styles"),V=require("@mui/material/Snackbar"),$=require("@mui/material/Alert"),K=require("@mui/material/LinearProgress"),J=require("@mui/material/CircularProgress"),Y=require("@australiangreens/ag-error");function Z({text:e}){const[t,r]=u.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(P,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(P,{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(X,{variant:"outlined",onClick:()=>r(o=>o+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(Q,{children:["This number will incremember when button pressed: ",t]})]})}const ee=d.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:d.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:d.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:d.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}}}),te=d.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"}}});function re({name:e="internal",children:t}){const r=e==="internal"?ee:e==="fed21"?te:void 0;return n.jsx(d.ThemeProvider,{theme:r,children:t})}class x extends Y.AgError{}A(x,"errorName","ContextError");const f=()=>{throw new x("SaladBarContext can only be used in a child of a <SaladBarProvider>")},ne=e=>{throw new x("SaladBarContext can only be used in a child of a <SaladBarProvider>")},oe={enqueueNotification:f,enqueueSuccessNotification:f,enqueueInfoNotification:f,enqueueWarningNotification:f,enqueueErrorNotification:f,removeNotification:ne},D=u.createContext(oe),ie={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},q={message:"",severity:"info",variant:"standard",progressIndicator:void 0},N=100,B=2e3,ae=2e3,se=(()=>{let e=0;return()=>(e+=1,e)})(),ce={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},le=r=>{var o=r,{children:e}=o,t=b(o,["children"]);var E;const[j,h]=u.useState(!1),c=u.useRef([]),v=u.useRef(Date.now()),g=u.useRef(0),p=(a={})=>{g.current+=1,c.current.length>=N&&Date.now()-v.current>=B&&(v.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${N}) hit ${g.current} times in last ${B}ms)`),g.current=0);const i=s(F(s({},q),{key:se()}),a);return c.current.push(i),c.current.length===1&&h(!0),i.key},w=(a="",i={})=>p(s({message:a,severity:"success"},i)),I=(a="",i={})=>p(s({message:a,severity:"info"},i)),M=(a="",i={})=>p(s({message:a,severity:"warning"},i)),R=(a="",i={})=>p(s({message:a,severity:"error"},i)),H=a=>{const i=c.current.findIndex(z=>z.key===a);if(i!==-1)return i===0?(h(!1),c.current[0]):c.current.splice(i,1)},S=a=>{h(!1)},L=()=>{},_=()=>{c.current.shift(),c.current.length>0&&h(!0)},l=(E=c.current[0])!=null?E:s({},q),C={};"autoHideDuration"in l&&(C.autoHideDuration=l.autoHideDuration);const O=s(s({},ie),t);return n.jsxs(D.Provider,{value:{enqueueNotification:p,enqueueSuccessNotification:w,enqueueInfoNotification:I,enqueueWarningNotification:M,enqueueErrorNotification:R,removeNotification:H},children:[e,n.jsx(V,F(s(s({},O),C),{open:j,onClose:S,TransitionProps:{onExited:_,onExit:L},sx:{zIndex:ae},children:n.jsxs("div",{children:[n.jsx($,{onClose:S,severity:l.severity,variant:"filled",icon:l.progressIndicator==="circular"?n.jsx(J,{size:"1em"}):void 0,style:l.progressIndicator==="linear"?ce:void 0,children:l.message}),l.progressIndicator==="linear"&&n.jsx(K,{color:"primary"})]})}))]})};function ue(){return u.useContext(D)}exports.AgThemeProvider=re;exports.ContextError=x;exports.ExampleComponent=Z;exports.SaladBarProvider=le;exports.useSaladBar=ue;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/components/ExampleComponent/index.tsx","../../src/components/AgThemeProvider/themes.ts","../../src/components/AgThemeProvider/index.tsx"],"sourcesContent":["import { useState } from 'react';\nimport Button from '@mui/material/Button';\nimport Paper from '@mui/material/Paper';\nimport Typography from '@mui/material/Typography';\n\nexport interface ExampleComponentProps {\n text: string;\n}\n\nexport default function ExampleComponent({ text }: ExampleComponentProps) {\n const [num, setNum] = useState(0);\n\n return (\n <>\n <Typography variant=\"h6\" color=\"inherit\" component=\"div\" sx={{ fontSize: '22px' }}>\n Hello world\n </Typography>\n\n <Typography variant=\"caption\" display=\"block\">\n <span>Just ensuring MUI is working as planned as a peer dependency. v0.0.11</span>\n </Typography>\n <Button\n variant=\"outlined\"\n onClick={() => setNum((oldNum) => oldNum + 1)}\n aria-label=\"Increment\"\n >\n Hello I am a button\n </Button>\n <p>\n This is some text: <span>{text}</span>\n </p>\n <Paper>This number will incremember when button pressed: {num}</Paper>\n </>\n );\n}\n","import { alpha, createTheme } from '@mui/material/styles';\n\nexport const internalAGSystemsTheme = createTheme({\n palette: {\n primary: {\n main: '#007236',\n dark: '#005221',\n light: '#00A04E',\n contrastText: '#FFFFFF',\n },\n secondary: {\n main: '#662D91',\n dark: '#440E62',\n light: '#93268F',\n contrastText: '#FFFFFF',\n },\n error: {\n main: '#D32F2F',\n dark: '#C62828',\n light: '#EF5350',\n },\n info: {\n main: '#0288D1',\n dark: '#01579B',\n light: '#03A9F4',\n },\n success: {\n main: '#0288D1',\n dark: '#01579B',\n light: '#03A9F4',\n },\n },\n components: {\n MuiTextField: {\n defaultProps: { color: 'secondary' },\n },\n MuiToggleButtonGroup: {\n defaultProps: { color: 'secondary' },\n },\n MuiCheckbox: {\n defaultProps: { color: 'secondary' },\n },\n MuiSelect: {\n defaultProps: { color: 'secondary' },\n },\n MuiSwitch: {\n defaultProps: { color: 'secondary' },\n },\n MuiFormControl: {\n defaultProps: { color: 'secondary' },\n },\n MuiMenuItem: {\n // Setting defaultProps for color on MenuItem does not work, so update manually\n styleOverrides: {\n root: ({ theme }) => ({\n '&.Mui-selected': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.selectedOpacity\n ),\n '&:hover': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.selectedOpacity\n ),\n },\n '&.Mui-focusVisible': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.focusOpacity\n ),\n },\n },\n }),\n },\n },\n },\n typography: {\n // I couldn't think of what to call this. It is an attempt to match\n // https://www.figma.com/file/atonRPl2YD9A1NCntbDtKR/List-Filter-and-Product-Concept?node-id=1187%3A43730\n // but not sure if line height should be changed\n explainer: {\n fontSize: '14px',\n marginBlockStart: '1em',\n },\n h3: {\n fontSize: '1rem',\n fontWeight: 700,\n },\n },\n});\n\nexport const fed21Theme = createTheme({\n palette: {\n primary: {\n dark: '#00A651',\n light: '#A3D39C',\n main: '#007236',\n contrastText: '#FFF',\n },\n warning: {\n main: '#F5871F',\n light: '#FCC589',\n dark: '#A2590A',\n contrastText: '#FFF',\n },\n secondary: {\n main: '#662D91',\n light: '#BD8CBF',\n dark: '#440E62',\n contrastText: '#FFF',\n },\n error: {\n main: '#D43C95',\n light: '#8F2064',\n dark: '#F9CDE0',\n contrastText: '#FFF',\n },\n info: {\n main: '#00A88D',\n light: '#ADDCCF',\n dark: '#005243',\n contrastText: '#FFF',\n },\n success: {\n main: '#00A651',\n light: '#A3D39C',\n dark: '#007236',\n contrastText: '#FFF',\n },\n },\n typography: {\n // I couldn't think of what to call this. It is an attempt to match\n // https://www.figma.com/file/atonRPl2YD9A1NCntbDtKR/List-Filter-and-Product-Concept?node-id=1187%3A43730\n // but not sure if line height should be changed\n explainer: {\n fontSize: '14px',\n marginBlockStart: '1em',\n },\n },\n});\n","import { PropsWithChildren } from 'react';\nimport { ThemeProvider } from '@mui/material/styles';\n\nimport { internalAGSystemsTheme, fed21Theme } from './themes';\n\nexport type AgThemeName = 'internal' | 'fed21';\n\nexport interface AgThemeProviderProps {\n name?: AgThemeName;\n}\n\nexport default function AgThemeProvider({\n name = 'internal',\n children,\n}: PropsWithChildren<AgThemeProviderProps>) {\n const theme =\n name === 'internal' ? internalAGSystemsTheme : name === 'fed21' ? fed21Theme : undefined;\n\n // Should be resolved when we move to React >= 18\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return <ThemeProvider theme={theme}>{children}</ThemeProvider>;\n}\n"],"names":["ExampleComponent","text","num","setNum","useState","jsxs","Fragment","jsx","Typography","Button","oldNum","Paper","internalAGSystemsTheme","createTheme","theme","alpha","fed21Theme","AgThemeProvider","name","children","ThemeProvider"],"mappings":"mRASwB,SAAAA,EAAiB,CAAE,KAAAC,GAA+B,CACxE,KAAM,CAACC,EAAKC,CAAM,EAAIC,WAAS,CAAC,EAEhC,OAEIC,EAAA,KAAAC,WAAA,CAAA,SAAA,CAAAC,EAAA,IAACC,EAAW,CAAA,QAAQ,KAAK,MAAM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UAAW,CACT,gBAAiBC,EAAA,MACfD,EAAM,QAAQ,UAAU,KACxBA,EAAM,QAAQ,OAAO,eACvB,CACF,EACA,qBAAsB,CACpB,gBAAiBC,EAAA,MACfD,EAAM,QAAQ,UAAU,KACxBA,EAAM,QAAQ,OAAO,YACvB,CACF,CACF,CAAA,EAEJ,CACF,CACF,EACA,WAAY,CAIV,UAAW,CACT,SAAU,OACV,iBAAkB,KACpB,EACA,GAAI,CACF,SAAU,OACV,WAAY,GACd,CACF,CACF,CAAC,EAEYE,EAAaH,EAAAA,YAAY,CACpC,QAAS,CACP,QAAS,CACP,KAAM,UACN,MAAO,UACP,KAAM,UACN,aAAc,MAChB,EACA,QAAS,CACP,KAAM,UACN,MAAO,UACP,KAAM,UACN,aAAc,MAChB,EACA,UAAW,CACT,KAAM,UACN,MAAO,UACP,KAAM,UACN,aAAc,MAChB,EACA,MAAO,CACL,KAAM,UACN,MAAO,UACP,KAAM,UACN,aAAc,MAChB,EACA,KAAM,CACJ,KAAM,UACN,MAAO,UACP,KAAM,UACN,aAAc,MAChB,EACA,QAAS,CACP,KAAM,UACN,MAAO,UACP,KAAM,UACN,aAAc,MAChB,CACF,EACA,WAAY,CAIV,UAAW,CACT,SAAU,OACV,iBAAkB,KACpB,CACF,CACF,CAAC,ECjID,SAAwBI,EAAgB,CACtC,KAAAC,EAAO,WACP,SAAAC,CACF,EAA4C,CAC1C,MAAML,EACJI,IAAS,WAAaN,EAAyBM,IAAS,QAAUF,EAAa,OAK1E,OAAAT,EAAA,IAACa,EAAc,cAAA,CAAA,MAAAN,EAAe,SAAAK,CAAS,CAAA,CAChD"}
1
+ {"version":3,"file":"index.js","sources":["../../src/components/ExampleComponent/index.tsx","../../src/providers/AgTheme/themes.ts","../../src/providers/AgTheme/index.tsx","../../src/errors/ContextError.ts","../../src/providers/SaladBar/SaladBarContext.ts","../../src/providers/SaladBar/defaults.ts","../../src/providers/SaladBar/SaladBarProvider.tsx","../../src/providers/SaladBar/useSaladBar.ts"],"sourcesContent":["import { useState } from 'react';\nimport Button from '@mui/material/Button';\nimport Paper from '@mui/material/Paper';\nimport Typography from '@mui/material/Typography';\n\nexport interface ExampleComponentProps {\n text: string;\n}\n\nexport default function ExampleComponent({ text }: ExampleComponentProps) {\n const [num, setNum] = useState(0);\n\n return (\n <>\n <Typography variant=\"h6\" color=\"inherit\" component=\"div\" sx={{ fontSize: '22px' }}>\n Hello world\n </Typography>\n\n <Typography variant=\"caption\" display=\"block\">\n <span>Just ensuring MUI is working as planned as a peer dependency. v0.0.11</span>\n </Typography>\n <Button\n variant=\"outlined\"\n onClick={() => setNum((oldNum) => oldNum + 1)}\n aria-label=\"Increment\"\n >\n Hello I am a button\n </Button>\n <p>\n This is some text: <span>{text}</span>\n </p>\n <Paper>This number will incremember when button pressed: {num}</Paper>\n </>\n );\n}\n","import { alpha, createTheme } from '@mui/material/styles';\n\nexport const internalAGSystemsTheme = createTheme({\n palette: {\n primary: {\n main: '#007236',\n dark: '#005221',\n light: '#00A04E',\n contrastText: '#FFFFFF',\n },\n secondary: {\n main: '#662D91',\n dark: '#440E62',\n light: '#93268F',\n contrastText: '#FFFFFF',\n },\n error: {\n main: '#D32F2F',\n dark: '#C62828',\n light: '#EF5350',\n },\n info: {\n main: '#0288D1',\n dark: '#01579B',\n light: '#03A9F4',\n },\n success: {\n main: '#0288D1',\n dark: '#01579B',\n light: '#03A9F4',\n },\n },\n components: {\n MuiTextField: {\n defaultProps: { color: 'secondary' },\n },\n MuiToggleButtonGroup: {\n defaultProps: { color: 'secondary' },\n },\n MuiCheckbox: {\n defaultProps: { color: 'secondary' },\n },\n MuiSelect: {\n defaultProps: { color: 'secondary' },\n },\n MuiSwitch: {\n defaultProps: { color: 'secondary' },\n },\n MuiFormControl: {\n defaultProps: { color: 'secondary' },\n },\n MuiMenuItem: {\n // Setting defaultProps for color on MenuItem does not work, so update manually\n styleOverrides: {\n root: ({ theme }) => ({\n '&.Mui-selected': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.selectedOpacity\n ),\n '&:hover': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.selectedOpacity\n ),\n },\n '&.Mui-focusVisible': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.focusOpacity\n ),\n },\n },\n }),\n },\n },\n },\n typography: {\n // I couldn't think of what to call this. It is an attempt to match\n // https://www.figma.com/file/atonRPl2YD9A1NCntbDtKR/List-Filter-and-Product-Concept?node-id=1187%3A43730\n // but not sure if line height should be changed\n explainer: {\n fontSize: '14px',\n marginBlockStart: '1em',\n },\n h3: {\n fontSize: '1rem',\n fontWeight: 700,\n },\n },\n});\n\nexport const fed21Theme = createTheme({\n palette: {\n primary: {\n dark: '#00A651',\n light: '#A3D39C',\n main: '#007236',\n contrastText: '#FFF',\n },\n warning: {\n main: '#F5871F',\n light: '#FCC589',\n dark: '#A2590A',\n contrastText: '#FFF',\n },\n secondary: {\n main: '#662D91',\n light: '#BD8CBF',\n dark: '#440E62',\n contrastText: '#FFF',\n },\n error: {\n main: '#D43C95',\n light: '#8F2064',\n dark: '#F9CDE0',\n contrastText: '#FFF',\n },\n info: {\n main: '#00A88D',\n light: '#ADDCCF',\n dark: '#005243',\n contrastText: '#FFF',\n },\n success: {\n main: '#00A651',\n light: '#A3D39C',\n dark: '#007236',\n contrastText: '#FFF',\n },\n },\n typography: {\n // I couldn't think of what to call this. It is an attempt to match\n // https://www.figma.com/file/atonRPl2YD9A1NCntbDtKR/List-Filter-and-Product-Concept?node-id=1187%3A43730\n // but not sure if line height should be changed\n explainer: {\n fontSize: '14px',\n marginBlockStart: '1em',\n },\n },\n});\n","import { PropsWithChildren } from 'react';\nimport { ThemeProvider } from '@mui/material/styles';\n\nimport { internalAGSystemsTheme, fed21Theme } from './themes';\n\nexport type AgThemeName = 'internal' | 'fed21';\n\nexport interface AgThemeProviderProps {\n name?: AgThemeName;\n}\n\nexport default function AgThemeProvider({\n name = 'internal',\n children,\n}: PropsWithChildren<AgThemeProviderProps>) {\n const theme =\n name === 'internal' ? internalAGSystemsTheme : name === 'fed21' ? fed21Theme : undefined;\n\n // Should be resolved when we move to React >= 18\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return <ThemeProvider theme={theme}>{children}</ThemeProvider>;\n}\n","import { AgError } from '@australiangreens/ag-error';\n\n// Superclass for errors involving React context.\nexport class ContextError extends AgError {\n static errorName = 'ContextError';\n}\n","import { createContext } from 'react';\n\nimport { ContextError } from '../../errors/ContextError';\n\nconst stub: () => void = () => {\n throw new ContextError('SaladBarContext can only be used in a child of a <SaladBarProvider>');\n};\n\nexport type NotificationType = {\n key: number;\n message: string;\n severity: 'success' | 'info' | 'warning' | 'error' | undefined;\n variant: 'standard' | 'outlined' | 'filled' | undefined;\n progressIndicator: string | undefined;\n autoHideDuration: number | undefined;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst notstub = (key: unknown): NotificationType | NotificationType[] | void => {\n throw new ContextError('SaladBarContext can only be used in a child of a <SaladBarProvider>');\n};\n\ntype SaladBarContextFunction = typeof stub | typeof notstub;\n\ntype SaladBarContextType = {\n enqueueNotification: SaladBarContextFunction; // Call as enqueueNotification(options)\n // where options include message and severity of 'error' ,'warning', 'info' or\n // 'success'\n enqueueSuccessNotification: SaladBarContextFunction; // Call as const key =\n // enqueueSuccessNotification(msg),\n enqueueInfoNotification: SaladBarContextFunction; // Call as const key =\n // enqueueInfoNotification(msg),\n enqueueWarningNotification: SaladBarContextFunction; // Call as const key =\n // enqueueWarningNotification(msg),\n enqueueErrorNotification: SaladBarContextFunction; // Call as const key =\n // enqueueErrorNotification(msg),\n removeNotification: SaladBarContextFunction; // Call as enqueueErrorNotification(key),\n};\n\n// The defaultValue argument is only used when a component does not have a\n// matching Provider above it in the tree. See\n// https://reactjs.org/docs/context.html#reactcreatecontext\n// Using createContext doesn't itself maintain any type of state exactly, it\n// just provides a way for children to access shared references.\nconst defaultValue = {\n enqueueNotification: stub,\n enqueueSuccessNotification: stub,\n enqueueInfoNotification: stub,\n enqueueWarningNotification: stub,\n enqueueErrorNotification: stub,\n removeNotification: notstub,\n} as SaladBarContextType;\n\n/**\n * @returns A SaladBarContext\n */\nconst SaladBarContext = createContext(defaultValue);\n\nexport default SaladBarContext;\n","// The default props passed to the underlying Snackbar component\nimport { SnackbarOrigin } from '@mui/material/Snackbar';\n\nexport const defaultSnackbarProps = {\n autoHideDuration: 6000,\n anchorOrigin: { vertical: 'top', horizontal: 'center' } as SnackbarOrigin,\n\n // The default is false. If we prefer timer to continue when window loses\n // focus, change to true\n disableWindowBlurListener: false,\n};\n\nexport const defaultEnqueueNotificationOptions = {\n message: '',\n severity: 'info',\n variant: 'standard',\n progressIndicator: undefined, // Can use 'circular' or 'linear'\n};\n","import React, { useRef, useState } from 'react';\nimport Snackbar from '@mui/material/Snackbar';\nimport Alert from '@mui/material/Alert';\nimport LinearProgress from '@mui/material/LinearProgress';\nimport CircularProgress from '@mui/material/CircularProgress';\n\nimport SaladBarContext, { NotificationType } from './SaladBarContext';\nimport { defaultSnackbarProps, defaultEnqueueNotificationOptions } from './defaults';\n\nconst MAX_QUEUE_LENGTH = 100;\nconst MAX_QUEUE_HIT_REPORT_INTERVAL = 2000;\nconst SALADBAR_INDEX = 2000;\n\n// No need to use uuids, just use an incremented value\nconst generateNotificationKey = (() => {\n let previousKey = 0;\n return () => {\n previousKey += 1;\n return previousKey;\n };\n})();\n\nconst alertWithLinearProgressStyle = {\n borderBottomLeftRadius: '0px',\n borderBottomRightRadius: '0px',\n};\n\ntype SaladBarProps = {\n children: React.ReactNode;\n};\n\nconst SaladBar = ({ children, ...snackbarProps }: SaladBarProps) => {\n const [open, setOpen] = useState(false);\n\n // We use a ref instead of a state to store the actual data, because we want\n // queue to be persistent across the whole lifetime of component. I considered\n // using yocto-queue because it would be O(1) instead of O(n), but its not\n // designed to access the head without removing it and its not going to make\n // much difference anyway.\n const queueRef = useRef<NotificationType[]>([]);\n\n const limitLastHitAt = useRef(Date.now());\n const limitHitCountSinceLastReport = useRef(0);\n\n const enqueueNotification = (notification = {}) => {\n limitHitCountSinceLastReport.current += 1;\n if (queueRef.current.length >= MAX_QUEUE_LENGTH) {\n // If the queue length is hit, probably stuck in some sort of loop, so\n // don't want to spam logs instantly so space it out\n if (Date.now() - limitLastHitAt.current >= MAX_QUEUE_HIT_REPORT_INTERVAL) {\n limitLastHitAt.current = Date.now();\n console.error(\n `SaladBarProvider: MAX_QUEUE_LENGTH (${MAX_QUEUE_LENGTH}) hit ${limitHitCountSinceLastReport.current} times in last ${MAX_QUEUE_HIT_REPORT_INTERVAL}ms)`\n );\n limitHitCountSinceLastReport.current = 0;\n }\n }\n\n const newNotification = {\n ...defaultEnqueueNotificationOptions,\n key: generateNotificationKey(), // Can be overridden.\n ...notification, // This could result in collisons, but unlikely.\n };\n\n // Add to the end of queue\n queueRef.current.push(newNotification as NotificationType);\n\n // If the queue was previously empty, then open the snackbar. We don't do it\n // whenever enqueueNotification is called since it will mess up transitions\n if (queueRef.current.length === 1) setOpen(true);\n\n return newNotification.key;\n };\n\n const enqueueSuccessNotification = (message = '', options = {}) =>\n enqueueNotification({ message, severity: 'success', ...options });\n\n const enqueueInfoNotification = (message = '', options = {}) =>\n enqueueNotification({ message, severity: 'info', ...options });\n\n const enqueueWarningNotification = (message = '', options = {}) =>\n enqueueNotification({ message, severity: 'warning', ...options });\n\n const enqueueErrorNotification = (message = '', options = {}) =>\n enqueueNotification({ message, severity: 'error', ...options });\n\n /**\n * Remove the notification with specified key from the queue. If the key is\n * not found, immediately returns null.\n *\n * @param key - The key as returned from enqueue...() function.\n *\n * @returns The removed notification\n */\n const removeNotification = (key: unknown) => {\n const index = queueRef.current.findIndex((x) => x.key === key);\n if (index === -1) return;\n\n if (index === 0) {\n // If its at the front of the queue, it is either currently being\n // displayed or in process of being closed. Either way, we can just set\n // open to false\n setOpen(false);\n return queueRef.current[0];\n }\n // Otherwise we just remove it from the queue, it won't need to transition\n return queueRef.current.splice(index, 1);\n };\n\n // Callback fired when the component requests to be closed\n // const handleClose = (_event, reason) => {\n // // We ignore click away, letting user continue with UI while its still\n // // displayed\n // if (reason === 'clickaway') return;\n\n // setOpen(false);\n // };\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const handleClose = (_event: Event | React.SyntheticEvent<Element, Event>) => {\n // We ignore click away, letting user continue with UI while its still\n // displayed\n\n setOpen(false);\n };\n\n // Callback fired before the transition is exiting.\n const handleExit = () => {};\n\n // Callback fired when the transition has exited.\n const handleExited = () => {\n // Remove head of queue\n queueRef.current.shift();\n\n // If there is still something on the queue, then re-open\n if (queueRef.current.length > 0) setOpen(true);\n };\n\n // The notification to display is the one at head of queue\n const currentNotification = queueRef.current[0] ?? {\n ...defaultEnqueueNotificationOptions,\n };\n\n // Can also override certain props on a notification level\n const currentNotificationSnackbarProps: { autoHideDuration?: number } = {};\n // Probably a better way of doing this\n if ('autoHideDuration' in currentNotification) {\n currentNotificationSnackbarProps.autoHideDuration = currentNotification.autoHideDuration;\n }\n\n // Note the order of props in Snackbar, we don't allow overriding open and\n // onClose.\n\n const snackbarFinalProps = { ...defaultSnackbarProps, ...snackbarProps };\n\n return (\n // Should be resolved when we move to React >= 18\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n <SaladBarContext.Provider\n value={{\n enqueueNotification,\n enqueueSuccessNotification,\n enqueueInfoNotification,\n enqueueWarningNotification,\n enqueueErrorNotification,\n removeNotification,\n }}\n >\n {children}\n <Snackbar\n {...snackbarFinalProps}\n {...currentNotificationSnackbarProps}\n open={open}\n onClose={handleClose}\n TransitionProps={{\n onExited: handleExited,\n onExit: handleExit,\n }}\n sx={{ zIndex: SALADBAR_INDEX }}\n >\n <div>\n <Alert\n onClose={handleClose}\n severity={currentNotification.severity}\n variant={'filled'}\n icon={\n currentNotification.progressIndicator === 'circular' ? (\n <CircularProgress size=\"1em\" />\n ) : undefined\n }\n style={\n currentNotification.progressIndicator === 'linear'\n ? alertWithLinearProgressStyle\n : undefined\n }\n >\n {currentNotification.message}\n </Alert>\n {currentNotification.progressIndicator === 'linear' && <LinearProgress color=\"primary\" />}\n </div>\n </Snackbar>\n </SaladBarContext.Provider>\n );\n};\n\nexport default SaladBar;\n","import { useContext } from 'react';\nimport SaladBarContext from './SaladBarContext';\n\n/**\n * Use the `useSaladBar` hook in components to access the enqueueNotification()\n * method to add a snackbar message to queue.\n *\n * Example:\n *\n * ```js\n * const {\n * enqueueNotification,\n * enqueueSuccessNotification,\n * enqueueInfoNotification,\n * enqueueWarningNotification,\n * enqueueErrorNotification,\n * } = useSaladBar();\n * ...\n * enqueueNotification({message: 'hello', severity: 'info'});\n * // or\n * enqueueInfoNotification('hello');\n * ```\n */\nexport default function useSaladBar() {\n return useContext(SaladBarContext);\n}\n"],"names":["ExampleComponent","text","num","setNum","useState","jsxs","Fragment","jsx","Typography","Button","oldNum","Paper","internalAGSystemsTheme","createTheme","theme","alpha","fed21Theme","AgThemeProvider","name","children","ThemeProvider","ContextError","AgError","__publicField","stub","notstub","key","defaultValue","SaladBarContext","createContext","defaultSnackbarProps","defaultEnqueueNotificationOptions","MAX_QUEUE_LENGTH","MAX_QUEUE_HIT_REPORT_INTERVAL","SALADBAR_INDEX","generateNotificationKey","previousKey","alertWithLinearProgressStyle","SaladBar","_a","_b","snackbarProps","__objRest","open","setOpen","queueRef","useRef","limitLastHitAt","limitHitCountSinceLastReport","enqueueNotification","notification","newNotification","__spreadValues","__spreadProps","enqueueSuccessNotification","message","options","enqueueInfoNotification","enqueueWarningNotification","enqueueErrorNotification","removeNotification","index","x","handleClose","_event","handleExit","handleExited","currentNotification","currentNotificationSnackbarProps","snackbarFinalProps","Snackbar","Alert","CircularProgress","LinearProgress","useSaladBar","useContext"],"mappings":"ylCASwB,SAAAA,EAAiB,CAAE,KAAAC,GAA+B,CACxE,KAAM,CAACC,EAAKC,CAAM,EAAIC,WAAS,CAAC,EAEhC,OAEIC,EAAA,KAAAC,WAAA,CAAA,SAAA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A,QAASoB,EACT,gBAAiB,CACf,SAAUG,EACV,OAAQD,CACV,EACA,GAAI,CAAE,OAAQ/B,EAAe,EAE7B,gBAAC,MACC,CAAA,SAAA,CAAA3B,EAAA,IAACgE,EAAA,CACC,QAASR,EACT,SAAUI,EAAoB,SAC9B,QAAS,SACT,KACEA,EAAoB,oBAAsB,iBACvCK,EAAiB,CAAA,KAAK,MAAM,EAC3B,OAEN,MACEL,EAAoB,oBAAsB,SACtC9B,GACA,OAGL,SAAoB8B,EAAA,OAAA,CACvB,EACCA,EAAoB,oBAAsB,UAAa5D,EAAAA,IAAAkE,EAAA,CAAe,MAAM,UAAU,CAAA,EACzF,CAAA,EACF,CAAA,CAAA,CACF,CAEJ,ECrLA,SAAwBC,IAAc,CACpC,OAAOC,EAAAA,WAAW/C,CAAe,CACnC"}
@@ -0,0 +1,3 @@
1
+ export { default as ExampleComponent } from './ExampleComponent';
2
+ export * from './ExampleComponent';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { AgError } from '@australiangreens/ag-error';
2
+ export declare class ContextError extends AgError {
3
+ static errorName: string;
4
+ }
5
+ //# sourceMappingURL=ContextError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextError.d.ts","sourceRoot":"","sources":["../../../src/errors/ContextError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGrD,qBAAa,YAAa,SAAQ,OAAO;IACvC,MAAM,CAAC,SAAS,SAAkB;CACnC"}
@@ -0,0 +1,2 @@
1
+ export * from './ContextError';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,34 +1,61 @@
1
- import { jsxs as o, Fragment as s, jsx as t } from "react/jsx-runtime";
2
- import { useState as d } from "react";
3
- import p from "@mui/material/Button";
4
- import m from "@mui/material/Paper";
5
- import i from "@mui/material/Typography";
6
- import { createTheme as l, alpha as n, ThemeProvider as F } from "@mui/material/styles";
7
- function C({ text: e }) {
8
- const [r, a] = d(0);
9
- return /* @__PURE__ */ o(s, { children: [
10
- /* @__PURE__ */ t(i, { variant: "h6", color: "inherit", component: "div", sx: { fontSize: "22px" }, children: "Hello world" }),
11
- /* @__PURE__ */ t(i, { variant: "caption", display: "block", children: /* @__PURE__ */ t("span", { children: "Just ensuring MUI is working as planned as a peer dependency. v0.0.11" }) }),
12
- /* @__PURE__ */ t(
13
- p,
1
+ var Q = Object.defineProperty, V = Object.defineProperties;
2
+ var $ = Object.getOwnPropertyDescriptors;
3
+ var m = Object.getOwnPropertySymbols;
4
+ var T = Object.prototype.hasOwnProperty, A = Object.prototype.propertyIsEnumerable;
5
+ var F = (e, t, r) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, a = (e, t) => {
6
+ for (var r in t || (t = {}))
7
+ T.call(t, r) && F(e, r, t[r]);
8
+ if (m)
9
+ for (var r of m(t))
10
+ A.call(t, r) && F(e, r, t[r]);
11
+ return e;
12
+ }, g = (e, t) => V(e, $(t));
13
+ var N = (e, t) => {
14
+ var r = {};
15
+ for (var n in e)
16
+ T.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
17
+ if (e != null && m)
18
+ for (var n of m(e))
19
+ t.indexOf(n) < 0 && A.call(e, n) && (r[n] = e[n]);
20
+ return r;
21
+ };
22
+ var b = (e, t, r) => (F(e, typeof t != "symbol" ? t + "" : t, r), r);
23
+ import { jsxs as p, Fragment as j, jsx as s } from "react/jsx-runtime";
24
+ import { useState as I, createContext as K, useRef as y, useContext as J } from "react";
25
+ import Y from "@mui/material/Button";
26
+ import Z from "@mui/material/Paper";
27
+ import D from "@mui/material/Typography";
28
+ import { createTheme as M, alpha as x, ThemeProvider as ee } from "@mui/material/styles";
29
+ import te from "@mui/material/Snackbar";
30
+ import re from "@mui/material/Alert";
31
+ import ne from "@mui/material/LinearProgress";
32
+ import oe from "@mui/material/CircularProgress";
33
+ import { AgError as ie } from "@australiangreens/ag-error";
34
+ function Ae({ text: e }) {
35
+ const [t, r] = I(0);
36
+ return /* @__PURE__ */ p(j, { children: [
37
+ /* @__PURE__ */ s(D, { variant: "h6", color: "inherit", component: "div", sx: { fontSize: "22px" }, children: "Hello world" }),
38
+ /* @__PURE__ */ s(D, { variant: "caption", display: "block", children: /* @__PURE__ */ s("span", { children: "Just ensuring MUI is working as planned as a peer dependency. v0.0.11" }) }),
39
+ /* @__PURE__ */ s(
40
+ Y,
14
41
  {
15
42
  variant: "outlined",
16
- onClick: () => a((c) => c + 1),
43
+ onClick: () => r((n) => n + 1),
17
44
  "aria-label": "Increment",
18
45
  children: "Hello I am a button"
19
46
  }
20
47
  ),
21
- /* @__PURE__ */ o("p", { children: [
48
+ /* @__PURE__ */ p("p", { children: [
22
49
  "This is some text: ",
23
- /* @__PURE__ */ t("span", { children: e })
50
+ /* @__PURE__ */ s("span", { children: e })
24
51
  ] }),
25
- /* @__PURE__ */ o(m, { children: [
52
+ /* @__PURE__ */ p(Z, { children: [
26
53
  "This number will incremember when button pressed: ",
27
- r
54
+ t
28
55
  ] })
29
56
  ] });
30
57
  }
31
- const u = l({
58
+ const ae = M({
32
59
  palette: {
33
60
  primary: {
34
61
  main: "#007236",
@@ -82,18 +109,18 @@ const u = l({
82
109
  styleOverrides: {
83
110
  root: ({ theme: e }) => ({
84
111
  "&.Mui-selected": {
85
- backgroundColor: n(
112
+ backgroundColor: x(
86
113
  e.palette.secondary.main,
87
114
  e.palette.action.selectedOpacity
88
115
  ),
89
116
  "&:hover": {
90
- backgroundColor: n(
117
+ backgroundColor: x(
91
118
  e.palette.secondary.main,
92
119
  e.palette.action.selectedOpacity
93
120
  )
94
121
  },
95
122
  "&.Mui-focusVisible": {
96
- backgroundColor: n(
123
+ backgroundColor: x(
97
124
  e.palette.secondary.main,
98
125
  e.palette.action.focusOpacity
99
126
  )
@@ -116,7 +143,7 @@ const u = l({
116
143
  fontWeight: 700
117
144
  }
118
145
  }
119
- }), h = l({
146
+ }), se = M({
120
147
  palette: {
121
148
  primary: {
122
149
  dark: "#00A651",
@@ -165,14 +192,123 @@ const u = l({
165
192
  }
166
193
  }
167
194
  });
168
- function A({
195
+ function Ne({
169
196
  name: e = "internal",
170
- children: r
197
+ children: t
171
198
  }) {
172
- return /* @__PURE__ */ t(F, { theme: e === "internal" ? u : e === "fed21" ? h : void 0, children: r });
199
+ return /* @__PURE__ */ s(ee, { theme: e === "internal" ? ae : e === "fed21" ? se : void 0, children: t });
200
+ }
201
+ class v extends ie {
202
+ }
203
+ b(v, "errorName", "ContextError");
204
+ const d = () => {
205
+ throw new v("SaladBarContext can only be used in a child of a <SaladBarProvider>");
206
+ }, ce = (e) => {
207
+ throw new v("SaladBarContext can only be used in a child of a <SaladBarProvider>");
208
+ }, le = {
209
+ enqueueNotification: d,
210
+ enqueueSuccessNotification: d,
211
+ enqueueInfoNotification: d,
212
+ enqueueWarningNotification: d,
213
+ enqueueErrorNotification: d,
214
+ removeNotification: ce
215
+ }, q = K(le), ue = {
216
+ autoHideDuration: 6e3,
217
+ anchorOrigin: { vertical: "top", horizontal: "center" },
218
+ // The default is false. If we prefer timer to continue when window loses
219
+ // focus, change to true
220
+ disableWindowBlurListener: !1
221
+ }, P = {
222
+ message: "",
223
+ severity: "info",
224
+ variant: "standard",
225
+ progressIndicator: void 0
226
+ // Can use 'circular' or 'linear'
227
+ }, B = 100, w = 2e3, de = 2e3, pe = (() => {
228
+ let e = 0;
229
+ return () => (e += 1, e);
230
+ })(), fe = {
231
+ borderBottomLeftRadius: "0px",
232
+ borderBottomRightRadius: "0px"
233
+ }, be = (r) => {
234
+ var n = r, { children: e } = n, t = N(n, ["children"]);
235
+ var E;
236
+ const [H, f] = I(!1), c = y([]), k = y(Date.now()), h = y(0), u = (i = {}) => {
237
+ h.current += 1, c.current.length >= B && Date.now() - k.current >= w && (k.current = Date.now(), console.error(
238
+ `SaladBarProvider: MAX_QUEUE_LENGTH (${B}) hit ${h.current} times in last ${w}ms)`
239
+ ), h.current = 0);
240
+ const o = a(g(a({}, P), {
241
+ key: pe()
242
+ }), i);
243
+ return c.current.push(o), c.current.length === 1 && f(!0), o.key;
244
+ }, L = (i = "", o = {}) => u(a({ message: i, severity: "success" }, o)), R = (i = "", o = {}) => u(a({ message: i, severity: "info" }, o)), _ = (i = "", o = {}) => u(a({ message: i, severity: "warning" }, o)), O = (i = "", o = {}) => u(a({ message: i, severity: "error" }, o)), z = (i) => {
245
+ const o = c.current.findIndex((X) => X.key === i);
246
+ if (o !== -1)
247
+ return o === 0 ? (f(!1), c.current[0]) : c.current.splice(o, 1);
248
+ }, C = (i) => {
249
+ f(!1);
250
+ }, U = () => {
251
+ }, W = () => {
252
+ c.current.shift(), c.current.length > 0 && f(!0);
253
+ }, l = (E = c.current[0]) != null ? E : a({}, P), S = {};
254
+ "autoHideDuration" in l && (S.autoHideDuration = l.autoHideDuration);
255
+ const G = a(a({}, ue), t);
256
+ return (
257
+ // Should be resolved when we move to React >= 18
258
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
259
+ // @ts-ignore
260
+ /* @__PURE__ */ p(
261
+ q.Provider,
262
+ {
263
+ value: {
264
+ enqueueNotification: u,
265
+ enqueueSuccessNotification: L,
266
+ enqueueInfoNotification: R,
267
+ enqueueWarningNotification: _,
268
+ enqueueErrorNotification: O,
269
+ removeNotification: z
270
+ },
271
+ children: [
272
+ e,
273
+ /* @__PURE__ */ s(
274
+ te,
275
+ g(a(a({}, G), S), {
276
+ open: H,
277
+ onClose: C,
278
+ TransitionProps: {
279
+ onExited: W,
280
+ onExit: U
281
+ },
282
+ sx: { zIndex: de },
283
+ children: /* @__PURE__ */ p("div", { children: [
284
+ /* @__PURE__ */ s(
285
+ re,
286
+ {
287
+ onClose: C,
288
+ severity: l.severity,
289
+ variant: "filled",
290
+ icon: l.progressIndicator === "circular" ? /* @__PURE__ */ s(oe, { size: "1em" }) : void 0,
291
+ style: l.progressIndicator === "linear" ? fe : void 0,
292
+ children: l.message
293
+ }
294
+ ),
295
+ l.progressIndicator === "linear" && /* @__PURE__ */ s(ne, { color: "primary" })
296
+ ] })
297
+ })
298
+ )
299
+ ]
300
+ }
301
+ )
302
+ );
303
+ };
304
+ function De() {
305
+ return J(q);
173
306
  }
174
307
  export {
175
- A as AgThemeProvider,
176
- C as ExampleComponent
308
+ Ne as AgThemeProvider,
309
+ v as ContextError,
310
+ Ae as ExampleComponent,
311
+ be as SaladBarProvider,
312
+ De as useSaladBar
177
313
  };
178
314
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/components/ExampleComponent/index.tsx","../../src/components/AgThemeProvider/themes.ts","../../src/components/AgThemeProvider/index.tsx"],"sourcesContent":["import { useState } from 'react';\nimport Button from '@mui/material/Button';\nimport Paper from '@mui/material/Paper';\nimport Typography from '@mui/material/Typography';\n\nexport interface ExampleComponentProps {\n text: string;\n}\n\nexport default function ExampleComponent({ text }: ExampleComponentProps) {\n const [num, setNum] = useState(0);\n\n return (\n <>\n <Typography variant=\"h6\" color=\"inherit\" component=\"div\" sx={{ fontSize: '22px' }}>\n Hello world\n </Typography>\n\n <Typography variant=\"caption\" display=\"block\">\n <span>Just ensuring MUI is working as planned as a peer dependency. v0.0.11</span>\n </Typography>\n <Button\n variant=\"outlined\"\n onClick={() => setNum((oldNum) => oldNum + 1)}\n aria-label=\"Increment\"\n >\n Hello I am a button\n </Button>\n <p>\n This is some text: <span>{text}</span>\n </p>\n <Paper>This number will incremember when button pressed: {num}</Paper>\n </>\n );\n}\n","import { alpha, createTheme } from '@mui/material/styles';\n\nexport const internalAGSystemsTheme = createTheme({\n palette: {\n primary: {\n main: '#007236',\n dark: '#005221',\n light: '#00A04E',\n contrastText: '#FFFFFF',\n },\n secondary: {\n main: '#662D91',\n dark: '#440E62',\n light: '#93268F',\n contrastText: '#FFFFFF',\n },\n error: {\n main: '#D32F2F',\n dark: '#C62828',\n light: '#EF5350',\n },\n info: {\n main: '#0288D1',\n dark: '#01579B',\n light: '#03A9F4',\n },\n success: {\n main: '#0288D1',\n dark: '#01579B',\n light: '#03A9F4',\n },\n },\n components: {\n MuiTextField: {\n defaultProps: { color: 'secondary' },\n },\n MuiToggleButtonGroup: {\n defaultProps: { color: 'secondary' },\n },\n MuiCheckbox: {\n defaultProps: { color: 'secondary' },\n },\n MuiSelect: {\n defaultProps: { color: 'secondary' },\n },\n MuiSwitch: {\n defaultProps: { color: 'secondary' },\n },\n MuiFormControl: {\n defaultProps: { color: 'secondary' },\n },\n MuiMenuItem: {\n // Setting defaultProps for color on MenuItem does not work, so update manually\n styleOverrides: {\n root: ({ theme }) => ({\n '&.Mui-selected': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.selectedOpacity\n ),\n '&:hover': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.selectedOpacity\n ),\n },\n '&.Mui-focusVisible': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.focusOpacity\n ),\n },\n },\n }),\n },\n },\n },\n typography: {\n // I couldn't think of what to call this. It is an attempt to match\n // https://www.figma.com/file/atonRPl2YD9A1NCntbDtKR/List-Filter-and-Product-Concept?node-id=1187%3A43730\n // but not sure if line height should be changed\n explainer: {\n fontSize: '14px',\n marginBlockStart: '1em',\n },\n h3: {\n fontSize: '1rem',\n fontWeight: 700,\n },\n },\n});\n\nexport const fed21Theme = createTheme({\n palette: {\n primary: {\n dark: '#00A651',\n light: '#A3D39C',\n main: '#007236',\n contrastText: '#FFF',\n },\n warning: {\n main: '#F5871F',\n light: '#FCC589',\n dark: '#A2590A',\n contrastText: '#FFF',\n },\n secondary: {\n main: '#662D91',\n light: '#BD8CBF',\n dark: '#440E62',\n contrastText: '#FFF',\n },\n error: {\n main: '#D43C95',\n light: '#8F2064',\n dark: '#F9CDE0',\n contrastText: '#FFF',\n },\n info: {\n main: '#00A88D',\n light: '#ADDCCF',\n dark: '#005243',\n contrastText: '#FFF',\n },\n success: {\n main: '#00A651',\n light: '#A3D39C',\n dark: '#007236',\n contrastText: '#FFF',\n },\n },\n typography: {\n // I couldn't think of what to call this. It is an attempt to match\n // https://www.figma.com/file/atonRPl2YD9A1NCntbDtKR/List-Filter-and-Product-Concept?node-id=1187%3A43730\n // but not sure if line height should be changed\n explainer: {\n fontSize: '14px',\n marginBlockStart: '1em',\n },\n },\n});\n","import { PropsWithChildren } from 'react';\nimport { ThemeProvider } from '@mui/material/styles';\n\nimport { internalAGSystemsTheme, fed21Theme } from './themes';\n\nexport type AgThemeName = 'internal' | 'fed21';\n\nexport interface AgThemeProviderProps {\n name?: AgThemeName;\n}\n\nexport default function AgThemeProvider({\n name = 'internal',\n children,\n}: PropsWithChildren<AgThemeProviderProps>) {\n const theme =\n name === 'internal' ? internalAGSystemsTheme : name === 'fed21' ? fed21Theme : undefined;\n\n // Should be resolved when we move to React >= 18\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return <ThemeProvider theme={theme}>{children}</ThemeProvider>;\n}\n"],"names":["ExampleComponent","text","num","setNum","useState","jsxs","Fragment","jsx","Typography","Button","oldNum","Paper","internalAGSystemsTheme","createTheme","theme","alpha","fed21Theme","AgThemeProvider","name","children","ThemeProvider"],"mappings":";;;;;;AASwB,SAAAA,EAAiB,EAAE,MAAAC,KAA+B;AACxE,QAAM,CAACC,GAAKC,CAAM,IAAIC,EAAS,CAAC;AAEhC,SAEI,gBAAAC,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAAC,EAACC,GAAW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M;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,MACN,cAAc;AAAA,IAChB;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,MACN,cAAc;AAAA,IAChB;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,MACN,cAAc;AAAA,IAChB;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,MACN,cAAc;AAAA,IAChB;AAAA,EACF;AAAA,EACA,YAAY;AAAA;AAAA;AAAA;AAAA,IAIV,WAAW;AAAA,MACT,UAAU;AAAA,MACV,kBAAkB;AAAA,IACpB;AAAA,EACF;AACF,CAAC;ACjID,SAAwBI,EAAgB;AAAA,EACtC,MAAAC,IAAO;AAAA,EACP,UAAAC;AACF,GAA4C;AAOnC,SAAA,gBAAAZ,EAACa,GAAc,EAAA,OALpBF,MAAS,aAAaN,IAAyBM,MAAS,UAAUF,IAAa,QAK5C,UAAAG,EAAS,CAAA;AAChD;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/components/ExampleComponent/index.tsx","../../src/providers/AgTheme/themes.ts","../../src/providers/AgTheme/index.tsx","../../src/errors/ContextError.ts","../../src/providers/SaladBar/SaladBarContext.ts","../../src/providers/SaladBar/defaults.ts","../../src/providers/SaladBar/SaladBarProvider.tsx","../../src/providers/SaladBar/useSaladBar.ts"],"sourcesContent":["import { useState } from 'react';\nimport Button from '@mui/material/Button';\nimport Paper from '@mui/material/Paper';\nimport Typography from '@mui/material/Typography';\n\nexport interface ExampleComponentProps {\n text: string;\n}\n\nexport default function ExampleComponent({ text }: ExampleComponentProps) {\n const [num, setNum] = useState(0);\n\n return (\n <>\n <Typography variant=\"h6\" color=\"inherit\" component=\"div\" sx={{ fontSize: '22px' }}>\n Hello world\n </Typography>\n\n <Typography variant=\"caption\" display=\"block\">\n <span>Just ensuring MUI is working as planned as a peer dependency. v0.0.11</span>\n </Typography>\n <Button\n variant=\"outlined\"\n onClick={() => setNum((oldNum) => oldNum + 1)}\n aria-label=\"Increment\"\n >\n Hello I am a button\n </Button>\n <p>\n This is some text: <span>{text}</span>\n </p>\n <Paper>This number will incremember when button pressed: {num}</Paper>\n </>\n );\n}\n","import { alpha, createTheme } from '@mui/material/styles';\n\nexport const internalAGSystemsTheme = createTheme({\n palette: {\n primary: {\n main: '#007236',\n dark: '#005221',\n light: '#00A04E',\n contrastText: '#FFFFFF',\n },\n secondary: {\n main: '#662D91',\n dark: '#440E62',\n light: '#93268F',\n contrastText: '#FFFFFF',\n },\n error: {\n main: '#D32F2F',\n dark: '#C62828',\n light: '#EF5350',\n },\n info: {\n main: '#0288D1',\n dark: '#01579B',\n light: '#03A9F4',\n },\n success: {\n main: '#0288D1',\n dark: '#01579B',\n light: '#03A9F4',\n },\n },\n components: {\n MuiTextField: {\n defaultProps: { color: 'secondary' },\n },\n MuiToggleButtonGroup: {\n defaultProps: { color: 'secondary' },\n },\n MuiCheckbox: {\n defaultProps: { color: 'secondary' },\n },\n MuiSelect: {\n defaultProps: { color: 'secondary' },\n },\n MuiSwitch: {\n defaultProps: { color: 'secondary' },\n },\n MuiFormControl: {\n defaultProps: { color: 'secondary' },\n },\n MuiMenuItem: {\n // Setting defaultProps for color on MenuItem does not work, so update manually\n styleOverrides: {\n root: ({ theme }) => ({\n '&.Mui-selected': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.selectedOpacity\n ),\n '&:hover': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.selectedOpacity\n ),\n },\n '&.Mui-focusVisible': {\n backgroundColor: alpha(\n theme.palette.secondary.main,\n theme.palette.action.focusOpacity\n ),\n },\n },\n }),\n },\n },\n },\n typography: {\n // I couldn't think of what to call this. It is an attempt to match\n // https://www.figma.com/file/atonRPl2YD9A1NCntbDtKR/List-Filter-and-Product-Concept?node-id=1187%3A43730\n // but not sure if line height should be changed\n explainer: {\n fontSize: '14px',\n marginBlockStart: '1em',\n },\n h3: {\n fontSize: '1rem',\n fontWeight: 700,\n },\n },\n});\n\nexport const fed21Theme = createTheme({\n palette: {\n primary: {\n dark: '#00A651',\n light: '#A3D39C',\n main: '#007236',\n contrastText: '#FFF',\n },\n warning: {\n main: '#F5871F',\n light: '#FCC589',\n dark: '#A2590A',\n contrastText: '#FFF',\n },\n secondary: {\n main: '#662D91',\n light: '#BD8CBF',\n dark: '#440E62',\n contrastText: '#FFF',\n },\n error: {\n main: '#D43C95',\n light: '#8F2064',\n dark: '#F9CDE0',\n contrastText: '#FFF',\n },\n info: {\n main: '#00A88D',\n light: '#ADDCCF',\n dark: '#005243',\n contrastText: '#FFF',\n },\n success: {\n main: '#00A651',\n light: '#A3D39C',\n dark: '#007236',\n contrastText: '#FFF',\n },\n },\n typography: {\n // I couldn't think of what to call this. It is an attempt to match\n // https://www.figma.com/file/atonRPl2YD9A1NCntbDtKR/List-Filter-and-Product-Concept?node-id=1187%3A43730\n // but not sure if line height should be changed\n explainer: {\n fontSize: '14px',\n marginBlockStart: '1em',\n },\n },\n});\n","import { PropsWithChildren } from 'react';\nimport { ThemeProvider } from '@mui/material/styles';\n\nimport { internalAGSystemsTheme, fed21Theme } from './themes';\n\nexport type AgThemeName = 'internal' | 'fed21';\n\nexport interface AgThemeProviderProps {\n name?: AgThemeName;\n}\n\nexport default function AgThemeProvider({\n name = 'internal',\n children,\n}: PropsWithChildren<AgThemeProviderProps>) {\n const theme =\n name === 'internal' ? internalAGSystemsTheme : name === 'fed21' ? fed21Theme : undefined;\n\n // Should be resolved when we move to React >= 18\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return <ThemeProvider theme={theme}>{children}</ThemeProvider>;\n}\n","import { AgError } from '@australiangreens/ag-error';\n\n// Superclass for errors involving React context.\nexport class ContextError extends AgError {\n static errorName = 'ContextError';\n}\n","import { createContext } from 'react';\n\nimport { ContextError } from '../../errors/ContextError';\n\nconst stub: () => void = () => {\n throw new ContextError('SaladBarContext can only be used in a child of a <SaladBarProvider>');\n};\n\nexport type NotificationType = {\n key: number;\n message: string;\n severity: 'success' | 'info' | 'warning' | 'error' | undefined;\n variant: 'standard' | 'outlined' | 'filled' | undefined;\n progressIndicator: string | undefined;\n autoHideDuration: number | undefined;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst notstub = (key: unknown): NotificationType | NotificationType[] | void => {\n throw new ContextError('SaladBarContext can only be used in a child of a <SaladBarProvider>');\n};\n\ntype SaladBarContextFunction = typeof stub | typeof notstub;\n\ntype SaladBarContextType = {\n enqueueNotification: SaladBarContextFunction; // Call as enqueueNotification(options)\n // where options include message and severity of 'error' ,'warning', 'info' or\n // 'success'\n enqueueSuccessNotification: SaladBarContextFunction; // Call as const key =\n // enqueueSuccessNotification(msg),\n enqueueInfoNotification: SaladBarContextFunction; // Call as const key =\n // enqueueInfoNotification(msg),\n enqueueWarningNotification: SaladBarContextFunction; // Call as const key =\n // enqueueWarningNotification(msg),\n enqueueErrorNotification: SaladBarContextFunction; // Call as const key =\n // enqueueErrorNotification(msg),\n removeNotification: SaladBarContextFunction; // Call as enqueueErrorNotification(key),\n};\n\n// The defaultValue argument is only used when a component does not have a\n// matching Provider above it in the tree. See\n// https://reactjs.org/docs/context.html#reactcreatecontext\n// Using createContext doesn't itself maintain any type of state exactly, it\n// just provides a way for children to access shared references.\nconst defaultValue = {\n enqueueNotification: stub,\n enqueueSuccessNotification: stub,\n enqueueInfoNotification: stub,\n enqueueWarningNotification: stub,\n enqueueErrorNotification: stub,\n removeNotification: notstub,\n} as SaladBarContextType;\n\n/**\n * @returns A SaladBarContext\n */\nconst SaladBarContext = createContext(defaultValue);\n\nexport default SaladBarContext;\n","// The default props passed to the underlying Snackbar component\nimport { SnackbarOrigin } from '@mui/material/Snackbar';\n\nexport const defaultSnackbarProps = {\n autoHideDuration: 6000,\n anchorOrigin: { vertical: 'top', horizontal: 'center' } as SnackbarOrigin,\n\n // The default is false. If we prefer timer to continue when window loses\n // focus, change to true\n disableWindowBlurListener: false,\n};\n\nexport const defaultEnqueueNotificationOptions = {\n message: '',\n severity: 'info',\n variant: 'standard',\n progressIndicator: undefined, // Can use 'circular' or 'linear'\n};\n","import React, { useRef, useState } from 'react';\nimport Snackbar from '@mui/material/Snackbar';\nimport Alert from '@mui/material/Alert';\nimport LinearProgress from '@mui/material/LinearProgress';\nimport CircularProgress from '@mui/material/CircularProgress';\n\nimport SaladBarContext, { NotificationType } from './SaladBarContext';\nimport { defaultSnackbarProps, defaultEnqueueNotificationOptions } from './defaults';\n\nconst MAX_QUEUE_LENGTH = 100;\nconst MAX_QUEUE_HIT_REPORT_INTERVAL = 2000;\nconst SALADBAR_INDEX = 2000;\n\n// No need to use uuids, just use an incremented value\nconst generateNotificationKey = (() => {\n let previousKey = 0;\n return () => {\n previousKey += 1;\n return previousKey;\n };\n})();\n\nconst alertWithLinearProgressStyle = {\n borderBottomLeftRadius: '0px',\n borderBottomRightRadius: '0px',\n};\n\ntype SaladBarProps = {\n children: React.ReactNode;\n};\n\nconst SaladBar = ({ children, ...snackbarProps }: SaladBarProps) => {\n const [open, setOpen] = useState(false);\n\n // We use a ref instead of a state to store the actual data, because we want\n // queue to be persistent across the whole lifetime of component. I considered\n // using yocto-queue because it would be O(1) instead of O(n), but its not\n // designed to access the head without removing it and its not going to make\n // much difference anyway.\n const queueRef = useRef<NotificationType[]>([]);\n\n const limitLastHitAt = useRef(Date.now());\n const limitHitCountSinceLastReport = useRef(0);\n\n const enqueueNotification = (notification = {}) => {\n limitHitCountSinceLastReport.current += 1;\n if (queueRef.current.length >= MAX_QUEUE_LENGTH) {\n // If the queue length is hit, probably stuck in some sort of loop, so\n // don't want to spam logs instantly so space it out\n if (Date.now() - limitLastHitAt.current >= MAX_QUEUE_HIT_REPORT_INTERVAL) {\n limitLastHitAt.current = Date.now();\n console.error(\n `SaladBarProvider: MAX_QUEUE_LENGTH (${MAX_QUEUE_LENGTH}) hit ${limitHitCountSinceLastReport.current} times in last ${MAX_QUEUE_HIT_REPORT_INTERVAL}ms)`\n );\n limitHitCountSinceLastReport.current = 0;\n }\n }\n\n const newNotification = {\n ...defaultEnqueueNotificationOptions,\n key: generateNotificationKey(), // Can be overridden.\n ...notification, // This could result in collisons, but unlikely.\n };\n\n // Add to the end of queue\n queueRef.current.push(newNotification as NotificationType);\n\n // If the queue was previously empty, then open the snackbar. We don't do it\n // whenever enqueueNotification is called since it will mess up transitions\n if (queueRef.current.length === 1) setOpen(true);\n\n return newNotification.key;\n };\n\n const enqueueSuccessNotification = (message = '', options = {}) =>\n enqueueNotification({ message, severity: 'success', ...options });\n\n const enqueueInfoNotification = (message = '', options = {}) =>\n enqueueNotification({ message, severity: 'info', ...options });\n\n const enqueueWarningNotification = (message = '', options = {}) =>\n enqueueNotification({ message, severity: 'warning', ...options });\n\n const enqueueErrorNotification = (message = '', options = {}) =>\n enqueueNotification({ message, severity: 'error', ...options });\n\n /**\n * Remove the notification with specified key from the queue. If the key is\n * not found, immediately returns null.\n *\n * @param key - The key as returned from enqueue...() function.\n *\n * @returns The removed notification\n */\n const removeNotification = (key: unknown) => {\n const index = queueRef.current.findIndex((x) => x.key === key);\n if (index === -1) return;\n\n if (index === 0) {\n // If its at the front of the queue, it is either currently being\n // displayed or in process of being closed. Either way, we can just set\n // open to false\n setOpen(false);\n return queueRef.current[0];\n }\n // Otherwise we just remove it from the queue, it won't need to transition\n return queueRef.current.splice(index, 1);\n };\n\n // Callback fired when the component requests to be closed\n // const handleClose = (_event, reason) => {\n // // We ignore click away, letting user continue with UI while its still\n // // displayed\n // if (reason === 'clickaway') return;\n\n // setOpen(false);\n // };\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const handleClose = (_event: Event | React.SyntheticEvent<Element, Event>) => {\n // We ignore click away, letting user continue with UI while its still\n // displayed\n\n setOpen(false);\n };\n\n // Callback fired before the transition is exiting.\n const handleExit = () => {};\n\n // Callback fired when the transition has exited.\n const handleExited = () => {\n // Remove head of queue\n queueRef.current.shift();\n\n // If there is still something on the queue, then re-open\n if (queueRef.current.length > 0) setOpen(true);\n };\n\n // The notification to display is the one at head of queue\n const currentNotification = queueRef.current[0] ?? {\n ...defaultEnqueueNotificationOptions,\n };\n\n // Can also override certain props on a notification level\n const currentNotificationSnackbarProps: { autoHideDuration?: number } = {};\n // Probably a better way of doing this\n if ('autoHideDuration' in currentNotification) {\n currentNotificationSnackbarProps.autoHideDuration = currentNotification.autoHideDuration;\n }\n\n // Note the order of props in Snackbar, we don't allow overriding open and\n // onClose.\n\n const snackbarFinalProps = { ...defaultSnackbarProps, ...snackbarProps };\n\n return (\n // Should be resolved when we move to React >= 18\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n <SaladBarContext.Provider\n value={{\n enqueueNotification,\n enqueueSuccessNotification,\n enqueueInfoNotification,\n enqueueWarningNotification,\n enqueueErrorNotification,\n removeNotification,\n }}\n >\n {children}\n <Snackbar\n {...snackbarFinalProps}\n {...currentNotificationSnackbarProps}\n open={open}\n onClose={handleClose}\n TransitionProps={{\n onExited: handleExited,\n onExit: handleExit,\n }}\n sx={{ zIndex: SALADBAR_INDEX }}\n >\n <div>\n <Alert\n onClose={handleClose}\n severity={currentNotification.severity}\n variant={'filled'}\n icon={\n currentNotification.progressIndicator === 'circular' ? (\n <CircularProgress size=\"1em\" />\n ) : undefined\n }\n style={\n currentNotification.progressIndicator === 'linear'\n ? alertWithLinearProgressStyle\n : undefined\n }\n >\n {currentNotification.message}\n </Alert>\n {currentNotification.progressIndicator === 'linear' && <LinearProgress color=\"primary\" />}\n </div>\n </Snackbar>\n </SaladBarContext.Provider>\n );\n};\n\nexport default SaladBar;\n","import { useContext } from 'react';\nimport SaladBarContext from './SaladBarContext';\n\n/**\n * Use the `useSaladBar` hook in components to access the enqueueNotification()\n * method to add a snackbar message to queue.\n *\n * Example:\n *\n * ```js\n * const {\n * enqueueNotification,\n * enqueueSuccessNotification,\n * enqueueInfoNotification,\n * enqueueWarningNotification,\n * enqueueErrorNotification,\n * } = useSaladBar();\n * ...\n * enqueueNotification({message: 'hello', severity: 'info'});\n * // or\n * enqueueInfoNotification('hello');\n * ```\n */\nexport default function useSaladBar() {\n return useContext(SaladBarContext);\n}\n"],"names":["ExampleComponent","text","num","setNum","useState","jsxs","Fragment","jsx","Typography","Button","oldNum","Paper","internalAGSystemsTheme","createTheme","theme","alpha","fed21Theme","AgThemeProvider","name","children","ThemeProvider","ContextError","AgError","__publicField","stub","notstub","key","defaultValue","SaladBarContext","createContext","defaultSnackbarProps","defaultEnqueueNotificationOptions","MAX_QUEUE_LENGTH","MAX_QUEUE_HIT_REPORT_INTERVAL","SALADBAR_INDEX","generateNotificationKey","previousKey","alertWithLinearProgressStyle","SaladBar","_a","_b","snackbarProps","__objRest","open","setOpen","queueRef","useRef","limitLastHitAt","limitHitCountSinceLastReport","enqueueNotification","notification","newNotification","__spreadValues","__spreadProps","enqueueSuccessNotification","message","options","enqueueInfoNotification","enqueueWarningNotification","enqueueErrorNotification","removeNotification","index","x","handleClose","_event","handleExit","handleExited","currentNotification","currentNotificationSnackbarProps","snackbarFinalProps","Snackbar","Alert","CircularProgress","LinearProgress","useSaladBar","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASwB,SAAAA,GAAiB,EAAE,MAAAC,KAA+B;AACxE,QAAM,CAACC,GAAKC,CAAM,IAAIC,EAAS,CAAC;AAEhC,SAEI,gBAAAC,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAAC,EAACC,GAAW,EAAA,SAAQ,MAAK,OAAM,WAAU,WAAU,OAAM,IAAI,EAAE,UAAU,OAAO,GAAG,UAEnF,eAAA;AAAA,IAEA,gBAAAD,EAACC,KAAW,SAAQ,WAAU,SAAQ,SACpC,UAAA,gBAAAD,EAAC,QAAK,EAAA,UAAA,wEAAA,CAAqE,EAC7E,CAAA;AAAA,IACA,gBAAAA;AAAA,MAACE;A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sBAAsB,+BACvCK,IAAiB,EAAA,MAAK,OAAM,IAC3B;AAAA,oBAEN,OACEL,EAAoB,sBAAsB,WACtC9B,KACA;AAAA,oBAGL,UAAoB8B,EAAA;AAAA,kBAAA;AAAA,gBACvB;AAAA,gBACCA,EAAoB,sBAAsB,YAAa,gBAAA5D,EAAAkE,IAAA,EAAe,OAAM,WAAU;AAAA,cAAA,GACzF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA;AAEJ;ACrLA,SAAwBC,KAAc;AACpC,SAAOC,EAAW/C,CAAe;AACnC;"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // --- BEGIN AUGMENTATIONS SECTION ---
2
- // From 0: src/components/AgThemeProvider/augmentations.d.ts
2
+ // From 0: src/providers/AgTheme/augmentations.d.ts
3
3
  import '@mui/material/styles';
4
4
  import '@mui/material/Typography';
5
5
 
@@ -20,8 +20,7 @@ declare module '@mui/material/Typography' {
20
20
  }
21
21
  // --- END AUGMENTATIONS SECTION ---
22
22
 
23
- export { default as ExampleComponent } from './components/ExampleComponent';
24
- export * from './components/ExampleComponent';
25
- export { default as AgThemeProvider } from './components/AgThemeProvider';
26
- export * from './components/AgThemeProvider';
23
+ export * from './components';
24
+ export * from './providers';
25
+ export * from './errors';
27
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/AgTheme/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK1C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,IAAiB,EACjB,QAAQ,GACT,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,eAQzC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../../../src/providers/AgTheme/themes.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,sCAwFjC,CAAC;AAEH,eAAO,MAAM,UAAU,sCAgDrB,CAAC"}
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ declare const stub: () => void;
3
+ export type NotificationType = {
4
+ key: number;
5
+ message: string;
6
+ severity: 'success' | 'info' | 'warning' | 'error' | undefined;
7
+ variant: 'standard' | 'outlined' | 'filled' | undefined;
8
+ progressIndicator: string | undefined;
9
+ autoHideDuration: number | undefined;
10
+ };
11
+ declare const notstub: (key: unknown) => NotificationType | NotificationType[] | void;
12
+ type SaladBarContextFunction = typeof stub | typeof notstub;
13
+ type SaladBarContextType = {
14
+ enqueueNotification: SaladBarContextFunction;
15
+ enqueueSuccessNotification: SaladBarContextFunction;
16
+ enqueueInfoNotification: SaladBarContextFunction;
17
+ enqueueWarningNotification: SaladBarContextFunction;
18
+ enqueueErrorNotification: SaladBarContextFunction;
19
+ removeNotification: SaladBarContextFunction;
20
+ };
21
+ /**
22
+ * @returns A SaladBarContext
23
+ */
24
+ declare const SaladBarContext: import("react").Context<SaladBarContextType>;
25
+ export default SaladBarContext;
26
+ //# sourceMappingURL=SaladBarContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SaladBarContext.d.ts","sourceRoot":"","sources":["../../../../src/providers/SaladBar/SaladBarContext.ts"],"names":[],"mappings":";AAIA,QAAA,MAAM,IAAI,EAAE,MAAM,IAEjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAC/D,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;IACxD,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,CAAC;AAGF,QAAA,MAAM,OAAO,QAAS,OAAO,KAAG,gBAAgB,GAAG,gBAAgB,EAAE,GAAG,IAEvE,CAAC;AAEF,KAAK,uBAAuB,GAAG,OAAO,IAAI,GAAG,OAAO,OAAO,CAAC;AAE5D,KAAK,mBAAmB,GAAG;IACzB,mBAAmB,EAAE,uBAAuB,CAAC;IAG7C,0BAA0B,EAAE,uBAAuB,CAAC;IAEpD,uBAAuB,EAAE,uBAAuB,CAAC;IAEjD,0BAA0B,EAAE,uBAAuB,CAAC;IAEpD,wBAAwB,EAAE,uBAAuB,CAAC;IAElD,kBAAkB,EAAE,uBAAuB,CAAC;CAC7C,CAAC;AAgBF;;GAEG;AACH,QAAA,MAAM,eAAe,8CAA8B,CAAC;AAEpD,eAAe,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ type SaladBarProps = {
3
+ children: React.ReactNode;
4
+ };
5
+ declare const SaladBar: ({ children, ...snackbarProps }: SaladBarProps) => JSX.Element;
6
+ export default SaladBar;
7
+ //# sourceMappingURL=SaladBarProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SaladBarProvider.d.ts","sourceRoot":"","sources":["../../../../src/providers/SaladBar/SaladBarProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AA2BhD,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,QAAQ,mCAAoC,aAAa,gBA6K9D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { SnackbarOrigin } from '@mui/material/Snackbar';
2
+ export declare const defaultSnackbarProps: {
3
+ autoHideDuration: number;
4
+ anchorOrigin: SnackbarOrigin;
5
+ disableWindowBlurListener: boolean;
6
+ };
7
+ export declare const defaultEnqueueNotificationOptions: {
8
+ message: string;
9
+ severity: string;
10
+ variant: string;
11
+ progressIndicator: undefined;
12
+ };
13
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../../src/providers/SaladBar/defaults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,eAAO,MAAM,oBAAoB;;;;CAOhC,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;CAK7C,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as default } from './SaladBarProvider';
2
+ export { default as useSaladBar } from './useSaladBar';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/SaladBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Use the `useSaladBar` hook in components to access the enqueueNotification()
3
+ * method to add a snackbar message to queue.
4
+ *
5
+ * Example:
6
+ *
7
+ * ```js
8
+ * const {
9
+ * enqueueNotification,
10
+ * enqueueSuccessNotification,
11
+ * enqueueInfoNotification,
12
+ * enqueueWarningNotification,
13
+ * enqueueErrorNotification,
14
+ * } = useSaladBar();
15
+ * ...
16
+ * enqueueNotification({message: 'hello', severity: 'info'});
17
+ * // or
18
+ * enqueueInfoNotification('hello');
19
+ * ```
20
+ */
21
+ export default function useSaladBar(): {
22
+ enqueueNotification: (() => void) | ((key: unknown) => void | import("./SaladBarContext").NotificationType | import("./SaladBarContext").NotificationType[]);
23
+ enqueueSuccessNotification: (() => void) | ((key: unknown) => void | import("./SaladBarContext").NotificationType | import("./SaladBarContext").NotificationType[]);
24
+ enqueueInfoNotification: (() => void) | ((key: unknown) => void | import("./SaladBarContext").NotificationType | import("./SaladBarContext").NotificationType[]);
25
+ enqueueWarningNotification: (() => void) | ((key: unknown) => void | import("./SaladBarContext").NotificationType | import("./SaladBarContext").NotificationType[]);
26
+ enqueueErrorNotification: (() => void) | ((key: unknown) => void | import("./SaladBarContext").NotificationType | import("./SaladBarContext").NotificationType[]);
27
+ removeNotification: (() => void) | ((key: unknown) => void | import("./SaladBarContext").NotificationType | import("./SaladBarContext").NotificationType[]);
28
+ };
29
+ //# sourceMappingURL=useSaladBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSaladBar.d.ts","sourceRoot":"","sources":["../../../../src/providers/SaladBar/useSaladBar.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW;;;;;;;EAElC"}
@@ -0,0 +1,5 @@
1
+ export { default as AgThemeProvider } from './AgTheme';
2
+ export * from './AgTheme';
3
+ export { default as SaladBarProvider } from './SaladBar';
4
+ export * from './SaladBar';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAC;AACvD,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzD,cAAc,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@australiangreens/ag-internal-components",
3
3
  "private": false,
4
- "version": "0.0.16",
4
+ "version": "0.0.17",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/australiangreens/ag-internal-components#readme",
7
7
  "license": "MIT",
@@ -36,7 +36,10 @@
36
36
  "type": "git",
37
37
  "url": "https://github.com/australiangreens/ag-internal-components.git"
38
38
  },
39
- "dependencies": {},
39
+ "dependencies": {
40
+ "@australiangreens/ag-error": "^0.1.7",
41
+ "@australiangreens/ag-error-jest": "^0.1.9"
42
+ },
40
43
  "peerDependencies": {
41
44
  "@emotion/react": "11.10.5",
42
45
  "@emotion/styled": "11.10.5",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/AgThemeProvider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK1C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,IAAiB,EACjB,QAAQ,GACT,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,eAQzC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../../../src/components/AgThemeProvider/themes.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,sCAwFjC,CAAC;AAEH,eAAO,MAAM,UAAU,sCAgDrB,CAAC"}