@australiangreens/ag-internal-components 0.0.22 → 0.0.24

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.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var W=Object.defineProperty,G=Object.defineProperties;var X=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var F=(e,t,r)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,s=(e,t)=>{for(var r in t||(t={}))P.call(t,r)&&F(e,r,t[r]);if(g)for(var r of g(t))T.call(t,r)&&F(e,r,t[r]);return e},v=(e,t)=>G(e,X(t));var _=(e,t)=>{var r={};for(var o in e)P.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&g)for(var o of g(e))t.indexOf(o)<0&&T.call(e,o)&&(r[o]=e[o]);return r};var b=(e,t,r)=>(F(e,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("react"),Q=require("@mui/material/Button"),V=require("@mui/material/Paper"),$=require("@mui/material/Typography"),f=require("@mui/material/styles"),K=require("@mui/material/Snackbar"),J=require("@mui/material/Alert"),Y=require("@mui/material/LinearProgress"),Z=require("@mui/material/CircularProgress"),ee=require("@australiangreens/ag-error"),d=e=>e&&e.__esModule?e:{default:e},te=d(Q),re=d(V),A=d($),ne=d(K),oe=d(J),ae=d(Y),ie=d(Z);function se({text:e}){const[t,r]=u.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(A.default,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(A.default,{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(te.default,{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(re.default,{children:["This number will incremember when button pressed: ",t]})]})}const ce=f.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:f.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:f.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:f.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}}}),le=f.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 ue({name:e="internal",children:t}){const r=e==="internal"?ce:e==="fed21"?le:void 0;return n.jsx(f.ThemeProvider,{theme:r,children:t})}class x extends ee.AgError{}b(x,"errorName","ContextError");const h=()=>{throw new x("SaladBarContext can only be used in a child of a <SaladBarProvider>")},de=e=>{throw new x("SaladBarContext can only be used in a child of a <SaladBarProvider>")},fe={enqueueNotification:h,enqueueSuccessNotification:h,enqueueInfoNotification:h,enqueueWarningNotification:h,enqueueErrorNotification:h,removeNotification:de},N=u.createContext(fe),pe={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},q={message:"",severity:"info",variant:"standard",progressIndicator:void 0},B=100,D=2e3,he=2e3,me=(()=>{let e=0;return()=>(e+=1,e)})(),ge={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"};function xe(r){var o=r,{children:e}=o,t=_(o,["children"]);var E;const[j,m]=u.useState(!1),c=u.useRef([]),S=u.useRef(Date.now()),y=u.useRef(0),p=(i={})=>{y.current+=1,c.current.length>=B&&Date.now()-S.current>=D&&(S.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${B}) hit ${y.current} times in last ${D}ms)`),y.current=0);const a=s(v(s({},q),{key:me()}),i);return c.current.push(a),c.current.length===1&&m(!0),a.key},w=(i="",a={})=>p(s({message:i,severity:"success"},a)),M=(i="",a={})=>p(s({message:i,severity:"info"},a)),I=(i="",a={})=>p(s({message:i,severity:"warning"},a)),R=(i="",a={})=>p(s({message:i,severity:"error"},a)),H=i=>{const a=c.current.findIndex(U=>U.key===i);if(a!==-1)return a===0?(m(!1),c.current[0]):c.current.splice(a,1)},C=i=>{m(!1)},L=()=>{},O=()=>{c.current.shift(),c.current.length>0&&m(!0)},l=(E=c.current[0])!=null?E:s({},q),k={};"autoHideDuration"in l&&(k.autoHideDuration=l.autoHideDuration);const z=s(s({},pe),t);return n.jsxs(N.Provider,{value:{enqueueNotification:p,enqueueSuccessNotification:w,enqueueInfoNotification:M,enqueueWarningNotification:I,enqueueErrorNotification:R,removeNotification:H},children:[e,n.jsx(ne.default,v(s(s({},z),k),{open:j,onClose:C,TransitionProps:{onExited:O,onExit:L},sx:{zIndex:he},children:n.jsxs("div",{children:[n.jsx(oe.default,{onClose:C,severity:l.severity,variant:"filled",icon:l.progressIndicator==="circular"?n.jsx(ie.default,{size:"1em"}):void 0,style:l.progressIndicator==="linear"?ge:void 0,children:l.message}),l.progressIndicator==="linear"&&n.jsx(ae.default,{color:"primary"})]})}))]})}function ye(){return u.useContext(N)}exports.AgThemeProvider=ue;exports.ContextError=x;exports.ExampleComponent=se;exports.SaladBarProvider=xe;exports.useSaladBar=ye;
1
+ "use strict";var G=Object.defineProperty,X=Object.defineProperties;var Q=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var F=(e,t,r)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,s=(e,t)=>{for(var r in t||(t={}))T.call(t,r)&&F(e,r,t[r]);if(g)for(var r of g(t))_.call(t,r)&&F(e,r,t[r]);return e},v=(e,t)=>X(e,Q(t));var A=(e,t)=>{var r={};for(var i in e)T.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&g)for(var i of g(e))t.indexOf(i)<0&&_.call(e,i)&&(r[i]=e[i]);return r};var b=(e,t,r)=>(F(e,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),u=require("react"),V=require("@mui/material/Button"),$=require("@mui/material/Paper"),K=require("@mui/material/Typography"),f=require("@mui/material/styles"),J=require("@mui/material/Snackbar"),Y=require("@mui/material/Alert"),Z=require("@mui/material/LinearProgress"),ee=require("@mui/material/CircularProgress"),te=require("@australiangreens/ag-error"),d=e=>e&&e.__esModule?e:{default:e},re=d(V),ne=d($),B=d(K),oe=d(J),ae=d(Y),ie=d(Z),se=d(ee);function ce({text:e}){const[t,r]=u.useState(0);return o.jsxs(o.Fragment,{children:[o.jsx(B.default,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),o.jsx(B.default,{variant:"caption",display:"block",children:o.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),o.jsx(re.default,{variant:"outlined",onClick:()=>r(i=>i+1),"aria-label":"Increment",children:"Hello I am a button"}),o.jsxs("p",{children:["This is some text: ",o.jsx("span",{children:e})]}),o.jsxs(ne.default,{children:["This number will incremember when button pressed: ",t]})]})}const le=f.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:f.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:f.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:f.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}}}),ue=f.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 de({name:e="internal",children:t}){const r=e==="internal"?le:e==="fed21"?ue:void 0;return o.jsx(f.ThemeProvider,{theme:r,children:t})}class x extends te.AgError{}b(x,"errorName","ContextError");const h=()=>{throw new x("SaladBarContext can only be used in a child of a <SaladBarProvider>")},fe=e=>{throw new x("SaladBarContext can only be used in a child of a <SaladBarProvider>")},pe={enqueueNotification:h,enqueueSuccessNotification:h,enqueueInfoNotification:h,enqueueWarningNotification:h,enqueueErrorNotification:h,removeNotification:fe},j=u.createContext(pe),he={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},me={shouldClose:(e,t)=>t!=="clickaway"},q={message:"",severity:"info",variant:"standard",progressIndicator:void 0},D=100,N=2e3,ge=2e3,xe=(()=>{let e=0;return()=>(e+=1,e)})(),ye={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"};function Fe(i){var C=i,{children:e,shouldClose:t=me.shouldClose}=C,r=A(C,["children","shouldClose"]);var P;const[w,m]=u.useState(!1),c=u.useRef([]),S=u.useRef(Date.now()),y=u.useRef(0),p=(a={})=>{y.current+=1,c.current.length>=D&&Date.now()-S.current>=N&&(S.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${D}) hit ${y.current} times in last ${N}ms)`),y.current=0);const n=s(v(s({},q),{key:xe()}),a);return c.current.push(n),c.current.length===1&&m(!0),n.key},M=(a="",n={})=>p(s({message:a,severity:"success"},n)),I=(a="",n={})=>p(s({message:a,severity:"info"},n)),R=(a="",n={})=>p(s({message:a,severity:"warning"},n)),H=(a="",n={})=>p(s({message:a,severity:"error"},n)),L=a=>{const n=c.current.findIndex(W=>W.key===a);if(n!==-1)return n===0?(m(!1),c.current[0]):c.current.splice(n,1)},k=(a,n)=>{t(a,n)&&m(!1)},O=()=>{},z=()=>{c.current.shift(),c.current.length>0&&m(!0)},l=(P=c.current[0])!=null?P:s({},q),E={};"autoHideDuration"in l&&(E.autoHideDuration=l.autoHideDuration);const U=s(s({},he),r);return o.jsxs(j.Provider,{value:{enqueueNotification:p,enqueueSuccessNotification:M,enqueueInfoNotification:I,enqueueWarningNotification:R,enqueueErrorNotification:H,removeNotification:L},children:[e,o.jsx(oe.default,v(s(s({},U),E),{open:w,onClose:k,TransitionProps:{onExited:z,onExit:O},sx:{zIndex:ge},children:o.jsxs("div",{children:[o.jsx(ae.default,{onClose:a=>k(a,"closeAlert"),severity:l.severity,variant:"filled",icon:l.progressIndicator==="circular"?o.jsx(se.default,{size:"1em"}):void 0,style:l.progressIndicator==="linear"?ye:void 0,children:l.message}),l.progressIndicator==="linear"&&o.jsx(ie.default,{color:"primary"})]})}))]})}function ve(){return u.useContext(j)}exports.AgThemeProvider=de;exports.ContextError=x;exports.ExampleComponent=ce;exports.SaladBarProvider=Fe;exports.useSaladBar=ve;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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, { SnackbarProps } 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\nexport interface SaladBarProviderProps extends SnackbarProps {}\n\nexport default function SaladBarProvider({ children, ...snackbarProps }: SaladBarProviderProps) {\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","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","SaladBarProvider","_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":"orCASwB,SAAAA,GAAiB,CAAE,KAAAC,GAA+B,CACxE,KAAM,CAACC,EAAKC,CAAM,EAAIC,WAAS,CAAC,EAEhC,OAEIC,EAAA,KAAAC,WAAA,CAAA,SAAA,CAAAC,EAAA,IAACC,EAAW,QAAA,CAAA,QAAQ,KAAK,MAAM,UAAU,UAAU,MAAM,GAAI,CAAE,SAAU,MAAO,EAAG,SAEnF,cAAA,EAEAD,EAAAA,IAACC,EAAAA,SAAW,QAAQ,UAAU,QAAQ,QACpC,SAAAD,EAAAA,IAAC,OAAK,CAAA,SAAA,uEAAA,CAAqE,CAC7E,CAAA,EACAA,EAAA,IAACE,GAAA,QAAA,CACC,QAAQ,WAC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AM,EAC3B,OAEN,MACEL,EAAoB,oBAAsB,SACtC9B,GACA,OAGL,SAAoB8B,EAAA,OAAA,CACvB,EACCA,EAAoB,oBAAsB,UAAa5D,EAAAA,IAAAkE,GAAAA,QAAA,CAAe,MAAM,UAAU,CAAA,EACzF,CAAA,EACF,CAAA,CAAA,CACF,CAEJ,CCnLA,SAAwBC,IAAc,CACpC,OAAOC,EAAAA,WAAW/C,CAAe,CACnC"}
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 defaultSaladBarProps = {\n shouldClose: (_event: Event | React.SyntheticEvent<Element, Event>, reason: string) => {\n return reason !== 'clickaway';\n },\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, { SnackbarProps, SnackbarCloseReason } 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 {\n defaultSaladBarProps,\n defaultSnackbarProps,\n defaultEnqueueNotificationOptions,\n} 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\nexport type SaladBarCloseReason = SnackbarCloseReason | 'closeAlert';\n\nexport interface SaladBarProviderProps extends SnackbarProps {\n /** Called when an event triggers closing of currently displayed snackbar.\n * Default implementation returns false if reason is 'clickaway', otherwise\n * true.*/\n shouldClose?: (\n event: Event | React.SyntheticEvent<Element, Event>,\n reason: SaladBarCloseReason\n ) => boolean;\n}\n\nexport default function SaladBarProvider({\n children,\n shouldClose = defaultSaladBarProps.shouldClose,\n ...snackbarProps\n}: SaladBarProviderProps) {\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 const handleClose = (\n event: Event | React.SyntheticEvent<Element, Event>,\n reason: SaladBarCloseReason\n ) => {\n if (shouldClose(event, reason)) 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={(event) => handleClose(event, 'closeAlert')}\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","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","defaultSaladBarProps","_event","reason","defaultEnqueueNotificationOptions","MAX_QUEUE_LENGTH","MAX_QUEUE_HIT_REPORT_INTERVAL","SALADBAR_INDEX","generateNotificationKey","previousKey","alertWithLinearProgressStyle","SaladBarProvider","_a","_b","shouldClose","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":"srCASwB,SAAAA,GAAiB,CAAE,KAAAC,GAA+B,CACxE,KAAM,CAACC,EAAKC,CAAM,EAAIC,WAAS,CAAC,EAEhC,OAEIC,EAAA,KAAAC,WAAA,CAAA,SAAA,CAAAC,EAAA,IAACC,EAAW,QAAA,CAAA,QAAQ,KAAK,MAAM,UAAU,UAAU,MAAM,GAAI,CAAE,SAAU,MAAO,EAAG,SAEnF,cAAA,EAEAD,EAAAA,IAACC,EAAAA,SAAW,QAAQ,UAAU,QAAQ,QACpC,SAAAD,EAAAA,IAAC,OAAK,CAAA,SAAA,uEAAA,CAAqE,CAC7E,CAAA,EACAA,EAAA,IAACE,GAAA,QAAA,CACC,QAAQ,WACR,QAAS,IAAMN,EAAQO,GAAWA,EAAS,CAAC,EAC5C,aAAW,YACZ,SAAA,qBAAA,CAED,SACC,IAAE,CAAA,SAAA,CAAA,sBACkBH,EAAAA,IAAC,QAAM,SAAKN,CAAA,CAAA,CAAA,EACjC,SACCU,GAAAA,QAAM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ACEL,EAAoB,oBAAsB,SACtC/B,GACA,OAGL,SAAoB+B,EAAA,OAAA,CACvB,EACCA,EAAoB,oBAAsB,UAAahE,EAAAA,IAAAsE,GAAAA,QAAA,CAAe,MAAM,UAAU,CAAA,EACzF,CAAA,EACF,CAAA,CAAA,CACF,CAEJ,CC3LA,SAAwBC,IAAc,CACpC,OAAOC,EAAAA,WAAWnD,CAAe,CACnC"}
package/dist/esm/index.js CHANGED
@@ -1,61 +1,61 @@
1
- var Q = Object.defineProperty, V = Object.defineProperties;
2
- var $ = Object.getOwnPropertyDescriptors;
1
+ var V = Object.defineProperty, $ = Object.defineProperties;
2
+ var j = Object.getOwnPropertyDescriptors;
3
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) => {
4
+ var T = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
5
+ var F = (e, t, r) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, a = (e, t) => {
6
6
  for (var r in t || (t = {}))
7
7
  T.call(t, r) && F(e, r, t[r]);
8
8
  if (m)
9
9
  for (var r of m(t))
10
- A.call(t, r) && F(e, r, t[r]);
10
+ N.call(t, r) && F(e, r, t[r]);
11
11
  return e;
12
- }, g = (e, t) => V(e, $(t));
13
- var N = (e, t) => {
12
+ }, g = (e, t) => $(e, j(t));
13
+ var P = (e, t) => {
14
14
  var r = {};
15
- for (var n in e)
16
- T.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
15
+ for (var i in e)
16
+ T.call(e, i) && t.indexOf(i) < 0 && (r[i] = e[i]);
17
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]);
18
+ for (var i of m(e))
19
+ t.indexOf(i) < 0 && N.call(e, i) && (r[i] = e[i]);
20
20
  return r;
21
21
  };
22
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 c } 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";
23
+ import { jsxs as p, Fragment as K, jsx as s } from "react/jsx-runtime";
24
+ import { useState as M, createContext as J, useRef as y, useContext as Y } from "react";
25
+ import Z from "@mui/material/Button";
26
+ import ee from "@mui/material/Paper";
27
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";
28
+ import { createTheme as q, alpha as x, ThemeProvider as te } from "@mui/material/styles";
29
+ import re from "@mui/material/Snackbar";
30
+ import oe from "@mui/material/Alert";
31
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__ */ c(D, { variant: "h6", color: "inherit", component: "div", sx: { fontSize: "22px" }, children: "Hello world" }),
38
- /* @__PURE__ */ c(D, { variant: "caption", display: "block", children: /* @__PURE__ */ c("span", { children: "Just ensuring MUI is working as planned as a peer dependency. v0.0.11" }) }),
39
- /* @__PURE__ */ c(
40
- Y,
32
+ import ie from "@mui/material/CircularProgress";
33
+ import { AgError as ae } from "@australiangreens/ag-error";
34
+ function Pe({ text: e }) {
35
+ const [t, r] = M(0);
36
+ return /* @__PURE__ */ p(K, { 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
+ Z,
41
41
  {
42
42
  variant: "outlined",
43
- onClick: () => r((n) => n + 1),
43
+ onClick: () => r((i) => i + 1),
44
44
  "aria-label": "Increment",
45
45
  children: "Hello I am a button"
46
46
  }
47
47
  ),
48
48
  /* @__PURE__ */ p("p", { children: [
49
49
  "This is some text: ",
50
- /* @__PURE__ */ c("span", { children: e })
50
+ /* @__PURE__ */ s("span", { children: e })
51
51
  ] }),
52
- /* @__PURE__ */ p(Z, { children: [
52
+ /* @__PURE__ */ p(ee, { children: [
53
53
  "This number will incremember when button pressed: ",
54
54
  t
55
55
  ] })
56
56
  ] });
57
57
  }
58
- const ae = M({
58
+ const se = q({
59
59
  palette: {
60
60
  primary: {
61
61
  main: "#007236",
@@ -143,7 +143,7 @@ const ae = M({
143
143
  fontWeight: 700
144
144
  }
145
145
  }
146
- }), ce = M({
146
+ }), ce = q({
147
147
  palette: {
148
148
  primary: {
149
149
  dark: "#00A651",
@@ -192,108 +192,116 @@ const ae = M({
192
192
  }
193
193
  }
194
194
  });
195
- function Ne({
195
+ function be({
196
196
  name: e = "internal",
197
197
  children: t
198
198
  }) {
199
- return /* @__PURE__ */ c(ee, { theme: e === "internal" ? ae : e === "fed21" ? ce : void 0, children: t });
199
+ return /* @__PURE__ */ s(te, { theme: e === "internal" ? se : e === "fed21" ? ce : void 0, children: t });
200
200
  }
201
- class v extends ie {
201
+ class v extends ae {
202
202
  }
203
203
  b(v, "errorName", "ContextError");
204
204
  const d = () => {
205
205
  throw new v("SaladBarContext can only be used in a child of a <SaladBarProvider>");
206
- }, se = (e) => {
206
+ }, le = (e) => {
207
207
  throw new v("SaladBarContext can only be used in a child of a <SaladBarProvider>");
208
- }, le = {
208
+ }, ue = {
209
209
  enqueueNotification: d,
210
210
  enqueueSuccessNotification: d,
211
211
  enqueueInfoNotification: d,
212
212
  enqueueWarningNotification: d,
213
213
  enqueueErrorNotification: d,
214
- removeNotification: se
215
- }, q = K(le), ue = {
214
+ removeNotification: le
215
+ }, H = J(ue), de = {
216
216
  autoHideDuration: 6e3,
217
217
  anchorOrigin: { vertical: "top", horizontal: "center" },
218
218
  // The default is false. If we prefer timer to continue when window loses
219
219
  // focus, change to true
220
220
  disableWindowBlurListener: !1
221
- }, P = {
221
+ }, pe = {
222
+ shouldClose: (e, t) => t !== "clickaway"
223
+ }, B = {
222
224
  message: "",
223
225
  severity: "info",
224
226
  variant: "standard",
225
227
  progressIndicator: void 0
226
228
  // Can use 'circular' or 'linear'
227
- }, B = 100, w = 2e3, de = 2e3, pe = (() => {
229
+ }, w = 100, I = 2e3, fe = 2e3, me = (() => {
228
230
  let e = 0;
229
231
  return () => (e += 1, e);
230
- })(), fe = {
232
+ })(), he = {
231
233
  borderBottomLeftRadius: "0px",
232
234
  borderBottomRightRadius: "0px"
233
235
  };
234
- function be(r) {
235
- var n = r, { children: e } = n, t = N(n, ["children"]);
236
- var S;
237
- const [H, f] = I(!1), s = y([]), k = y(Date.now()), h = y(0), u = (i = {}) => {
238
- h.current += 1, s.current.length >= B && Date.now() - k.current >= w && (k.current = Date.now(), console.error(
239
- `SaladBarProvider: MAX_QUEUE_LENGTH (${B}) hit ${h.current} times in last ${w}ms)`
236
+ function De(i) {
237
+ var C = i, {
238
+ children: e,
239
+ shouldClose: t = pe.shouldClose
240
+ } = C, r = P(C, [
241
+ "children",
242
+ "shouldClose"
243
+ ]);
244
+ var A;
245
+ const [L, f] = M(!1), c = y([]), k = y(Date.now()), h = y(0), u = (n = {}) => {
246
+ h.current += 1, c.current.length >= w && Date.now() - k.current >= I && (k.current = Date.now(), console.error(
247
+ `SaladBarProvider: MAX_QUEUE_LENGTH (${w}) hit ${h.current} times in last ${I}ms)`
240
248
  ), h.current = 0);
241
- const o = a(g(a({}, P), {
242
- key: pe()
243
- }), i);
244
- return s.current.push(o), s.current.length === 1 && f(!0), o.key;
245
- }, 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) => {
246
- const o = s.current.findIndex((X) => X.key === i);
249
+ const o = a(g(a({}, B), {
250
+ key: me()
251
+ }), n);
252
+ return c.current.push(o), c.current.length === 1 && f(!0), o.key;
253
+ }, R = (n = "", o = {}) => u(a({ message: n, severity: "success" }, o)), _ = (n = "", o = {}) => u(a({ message: n, severity: "info" }, o)), O = (n = "", o = {}) => u(a({ message: n, severity: "warning" }, o)), z = (n = "", o = {}) => u(a({ message: n, severity: "error" }, o)), U = (n) => {
254
+ const o = c.current.findIndex((Q) => Q.key === n);
247
255
  if (o !== -1)
248
- return o === 0 ? (f(!1), s.current[0]) : s.current.splice(o, 1);
249
- }, C = (i) => {
250
- f(!1);
251
- }, U = () => {
256
+ return o === 0 ? (f(!1), c.current[0]) : c.current.splice(o, 1);
257
+ }, S = (n, o) => {
258
+ t(n, o) && f(!1);
252
259
  }, W = () => {
253
- s.current.shift(), s.current.length > 0 && f(!0);
254
- }, l = (S = s.current[0]) != null ? S : a({}, P), E = {};
260
+ }, G = () => {
261
+ c.current.shift(), c.current.length > 0 && f(!0);
262
+ }, l = (A = c.current[0]) != null ? A : a({}, B), E = {};
255
263
  "autoHideDuration" in l && (E.autoHideDuration = l.autoHideDuration);
256
- const G = a(a({}, ue), t);
264
+ const X = a(a({}, de), r);
257
265
  return (
258
266
  // Should be resolved when we move to React >= 18
259
267
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
260
268
  // @ts-ignore
261
269
  /* @__PURE__ */ p(
262
- q.Provider,
270
+ H.Provider,
263
271
  {
264
272
  value: {
265
273
  enqueueNotification: u,
266
- enqueueSuccessNotification: L,
267
- enqueueInfoNotification: R,
268
- enqueueWarningNotification: _,
269
- enqueueErrorNotification: O,
270
- removeNotification: z
274
+ enqueueSuccessNotification: R,
275
+ enqueueInfoNotification: _,
276
+ enqueueWarningNotification: O,
277
+ enqueueErrorNotification: z,
278
+ removeNotification: U
271
279
  },
272
280
  children: [
273
281
  e,
274
- /* @__PURE__ */ c(
275
- te,
276
- g(a(a({}, G), E), {
277
- open: H,
278
- onClose: C,
282
+ /* @__PURE__ */ s(
283
+ re,
284
+ g(a(a({}, X), E), {
285
+ open: L,
286
+ onClose: S,
279
287
  TransitionProps: {
280
- onExited: W,
281
- onExit: U
288
+ onExited: G,
289
+ onExit: W
282
290
  },
283
- sx: { zIndex: de },
291
+ sx: { zIndex: fe },
284
292
  children: /* @__PURE__ */ p("div", { children: [
285
- /* @__PURE__ */ c(
286
- re,
293
+ /* @__PURE__ */ s(
294
+ oe,
287
295
  {
288
- onClose: C,
296
+ onClose: (n) => S(n, "closeAlert"),
289
297
  severity: l.severity,
290
298
  variant: "filled",
291
- icon: l.progressIndicator === "circular" ? /* @__PURE__ */ c(oe, { size: "1em" }) : void 0,
292
- style: l.progressIndicator === "linear" ? fe : void 0,
299
+ icon: l.progressIndicator === "circular" ? /* @__PURE__ */ s(ie, { size: "1em" }) : void 0,
300
+ style: l.progressIndicator === "linear" ? he : void 0,
293
301
  children: l.message
294
302
  }
295
303
  ),
296
- l.progressIndicator === "linear" && /* @__PURE__ */ c(ne, { color: "primary" })
304
+ l.progressIndicator === "linear" && /* @__PURE__ */ s(ne, { color: "primary" })
297
305
  ] })
298
306
  })
299
307
  )
@@ -302,14 +310,14 @@ function be(r) {
302
310
  )
303
311
  );
304
312
  }
305
- function De() {
306
- return J(q);
313
+ function Be() {
314
+ return Y(H);
307
315
  }
308
316
  export {
309
- Ne as AgThemeProvider,
317
+ be as AgThemeProvider,
310
318
  v as ContextError,
311
- Ae as ExampleComponent,
312
- be as SaladBarProvider,
313
- De as useSaladBar
319
+ Pe as ExampleComponent,
320
+ De as SaladBarProvider,
321
+ Be as useSaladBar
314
322
  };
315
323
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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, { SnackbarProps } 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\nexport interface SaladBarProviderProps extends SnackbarProps {}\n\nexport default function SaladBarProvider({ children, ...snackbarProps }: SaladBarProviderProps) {\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","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","SaladBarProvider","_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","Sn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AAA,UACA,4BAAAC;AAAA,UACA,0BAAAC;AAAA,UACA,oBAAAC;AAAA,QACF;AAAA,QAEC,UAAA;AAAA,UAAAzC;AAAA,UACD,gBAAAZ;AAAA,YAAC+D;AAAA,YAAAjB,EAAAD,IAAA,IACKiB,IACAD,IAFL;AAAA,cAGC,MAAAzB;AAAA,cACA,SAASoB;AAAA,cACT,iBAAiB;AAAA,gBACf,UAAUG;AAAA,gBACV,QAAQD;AAAA,cACV;AAAA,cACA,IAAI,EAAE,QAAQ/B,GAAe;AAAA,cAE7B,4BAAC,OACC,EAAA,UAAA;AAAA,gBAAA,gBAAA3B;AAAA,kBAACgE;AAAA,kBAAA;AAAA,oBACC,SAASR;AAAA,oBACT,UAAUI,EAAoB;AAAA,oBAC9B,SAAS;AAAA,oBACT,MACEA,EAAoB,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;ACnLA,SAAwBC,KAAc;AACpC,SAAOC,EAAW/C,CAAe;AACnC;"}
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 defaultSaladBarProps = {\n shouldClose: (_event: Event | React.SyntheticEvent<Element, Event>, reason: string) => {\n return reason !== 'clickaway';\n },\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, { SnackbarProps, SnackbarCloseReason } 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 {\n defaultSaladBarProps,\n defaultSnackbarProps,\n defaultEnqueueNotificationOptions,\n} 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\nexport type SaladBarCloseReason = SnackbarCloseReason | 'closeAlert';\n\nexport interface SaladBarProviderProps extends SnackbarProps {\n /** Called when an event triggers closing of currently displayed snackbar.\n * Default implementation returns false if reason is 'clickaway', otherwise\n * true.*/\n shouldClose?: (\n event: Event | React.SyntheticEvent<Element, Event>,\n reason: SaladBarCloseReason\n ) => boolean;\n}\n\nexport default function SaladBarProvider({\n children,\n shouldClose = defaultSaladBarProps.shouldClose,\n ...snackbarProps\n}: SaladBarProviderProps) {\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 const handleClose = (\n event: Event | React.SyntheticEvent<Element, Event>,\n reason: SaladBarCloseReason\n ) => {\n if (shouldClose(event, reason)) 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={(event) => handleClose(event, 'closeAlert')}\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","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","defaultSaladBarProps","_event","reason","defaultEnqueueNotificationOptions","MAX_QUEUE_LENGTH","MAX_QUEUE_HIT_REPORT_INTERVAL","SALADBAR_INDEX","generateNotificationKey","previousKey","alertWithLinearProgressStyle","SaladBarProvider","_a","_b","shouldClose","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":";;;;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AA,IAIE,gBAAAxC;AAAA,MAACuB,EAAgB;AAAA,MAAhB;AAAA,QACC,OAAO;AAAA,UACL,qBAAAyB;AAAA,UACA,4BAAAK;AAAA,UACA,yBAAAG;AAAA,UACA,4BAAAC;AAAA,UACA,0BAAAC;AAAA,UACA,oBAAAC;AAAA,QACF;AAAA,QAEC,UAAA;AAAA,UAAA7C;AAAA,UACD,gBAAAZ;AAAA,YAACmE;AAAA,YAAAjB,EAAAD,IAAA,IACKiB,IACAD,IAFL;AAAA,cAGC,MAAAzB;AAAA,cACA,SAASoB;AAAA,cACT,iBAAiB;AAAA,gBACf,UAAUG;AAAA,gBACV,QAAQD;AAAA,cACV;AAAA,cACA,IAAI,EAAE,QAAQhC,GAAe;AAAA,cAE7B,4BAAC,OACC,EAAA,UAAA;AAAA,gBAAA,gBAAA9B;AAAA,kBAACoE;AAAA,kBAAA;AAAA,oBACC,SAAS,CAACP,MAAUD,EAAYC,GAAO,YAAY;AAAA,oBACnD,UAAUG,EAAoB;AAAA,oBAC9B,SAAS;AAAA,oBACT,MACEA,EAAoB,sBAAsB,+BACvCK,IAAiB,EAAA,MAAK,OAAM,IAC3B;AAAA,oBAEN,OACEL,EAAoB,sBAAsB,WACtC/B,KACA;AAAA,oBAGL,UAAoB+B,EAAA;AAAA,kBAAA;AAAA,gBACvB;AAAA,gBACCA,EAAoB,sBAAsB,YAAa,gBAAAhE,EAAAsE,IAAA,EAAe,OAAM,WAAU;AAAA,cAAA,GACzF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA;AAEJ;AC3LA,SAAwBC,KAAc;AACpC,SAAOC,EAAWnD,CAAe;AACnC;"}
@@ -1,5 +1,11 @@
1
- import { SnackbarProps } from '@mui/material/Snackbar';
1
+ import React from 'react';
2
+ import { SnackbarProps, SnackbarCloseReason } from '@mui/material/Snackbar';
3
+ export type SaladBarCloseReason = SnackbarCloseReason | 'closeAlert';
2
4
  export interface SaladBarProviderProps extends SnackbarProps {
5
+ /** Called when an event triggers closing of currently displayed snackbar.
6
+ * Default implementation returns false if reason is 'clickaway', otherwise
7
+ * true.*/
8
+ shouldClose?: (event: Event | React.SyntheticEvent<Element, Event>, reason: SaladBarCloseReason) => boolean;
3
9
  }
4
- export default function SaladBarProvider({ children, ...snackbarProps }: SaladBarProviderProps): JSX.Element;
10
+ export default function SaladBarProvider({ children, shouldClose, ...snackbarProps }: SaladBarProviderProps): JSX.Element;
5
11
  //# sourceMappingURL=SaladBarProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SaladBarProvider.d.ts","sourceRoot":"","sources":["../../../../src/providers/SaladBar/SaladBarProvider.tsx"],"names":[],"mappings":"AACA,OAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA0BjE,MAAM,WAAW,qBAAsB,SAAQ,aAAa;CAAG;AAE/D,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,EAAE,qBAAqB,eA6K7F"}
1
+ {"version":3,"file":"SaladBarProvider.d.ts","sourceRoot":"","sources":["../../../../src/providers/SaladBar/SaladBarProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAChD,OAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AA8BtF,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,YAAY,CAAC;AAErE,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D;;cAEU;IACV,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,EACnD,MAAM,EAAE,mBAAmB,KACxB,OAAO,CAAC;CACd;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EACR,WAA8C,EAC9C,GAAG,aAAa,EACjB,EAAE,qBAAqB,eAmKvB"}
@@ -4,6 +4,9 @@ export declare const defaultSnackbarProps: {
4
4
  anchorOrigin: SnackbarOrigin;
5
5
  disableWindowBlurListener: boolean;
6
6
  };
7
+ export declare const defaultSaladBarProps: {
8
+ shouldClose: (_event: Event | React.SyntheticEvent<Element, Event>, reason: string) => boolean;
9
+ };
7
10
  export declare const defaultEnqueueNotificationOptions: {
8
11
  message: string;
9
12
  severity: string;
@@ -1 +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"}
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,oBAAoB;0BACT,KAAK,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,MAAM;CAGnF,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;CAK7C,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.22",
4
+ "version": "0.0.24",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/australiangreens/ag-internal-components#readme",
7
7
  "license": "MIT",
@@ -56,7 +56,7 @@
56
56
  "@mui/material": "5.11.0",
57
57
  "@mui/styles": "5.11.0",
58
58
  "@testing-library/dom": "9.3.0",
59
- "@testing-library/jest-dom": "5.16.5",
59
+ "@testing-library/jest-dom": "^5.16.5",
60
60
  "@testing-library/react": "12.1.2",
61
61
  "@testing-library/user-event": "^14.4.3",
62
62
  "@types/node": "16.18.0",
@@ -65,7 +65,7 @@
65
65
  "@types/react-test-renderer": "^18.0.0",
66
66
  "@typescript-eslint/eslint-plugin": "^5.59.8",
67
67
  "@typescript-eslint/parser": "^5.59.8",
68
- "@vitejs/plugin-react": "^4.0.0",
68
+ "@vitejs/plugin-react": "^4.0.1",
69
69
  "@vitejs/plugin-react-swc": "^3.0.0",
70
70
  "@vitest/coverage-c8": "^0.31.4",
71
71
  "eslint": "^8.41.0",
@@ -85,6 +85,7 @@
85
85
  "prettier": "^2.8.8",
86
86
  "react": "17.0.2",
87
87
  "react-dom": "17.0.2",
88
+ "react-router-dom": "^6.14.0",
88
89
  "typescript": "^5.0.2",
89
90
  "vite": "^4.3.9",
90
91
  "vite-plugin-dts": "^2.3.0",