@australiangreens/ag-internal-components 0.0.20 → 0.0.21
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 +16 -8
- package/dist/cjs/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -46,13 +46,21 @@ const Alert = require("@mui/material/Alert");
|
|
|
46
46
|
const LinearProgress = require("@mui/material/LinearProgress");
|
|
47
47
|
const CircularProgress = require("@mui/material/CircularProgress");
|
|
48
48
|
const agError = require("@australiangreens/ag-error");
|
|
49
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
50
|
+
const Button__default = /* @__PURE__ */ _interopDefault(Button);
|
|
51
|
+
const Paper__default = /* @__PURE__ */ _interopDefault(Paper);
|
|
52
|
+
const Typography__default = /* @__PURE__ */ _interopDefault(Typography);
|
|
53
|
+
const Snackbar__default = /* @__PURE__ */ _interopDefault(Snackbar);
|
|
54
|
+
const Alert__default = /* @__PURE__ */ _interopDefault(Alert);
|
|
55
|
+
const LinearProgress__default = /* @__PURE__ */ _interopDefault(LinearProgress);
|
|
56
|
+
const CircularProgress__default = /* @__PURE__ */ _interopDefault(CircularProgress);
|
|
49
57
|
function ExampleComponent({ text }) {
|
|
50
58
|
const [num, setNum] = react.useState(0);
|
|
51
59
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
52
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
53
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typography__default.default, { variant: "h6", color: "inherit", component: "div", sx: { fontSize: "22px" }, children: "Hello world" }),
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx(Typography__default.default, { variant: "caption", display: "block", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Just ensuring MUI is working as planned as a peer dependency. v0.0.11" }) }),
|
|
54
62
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
-
|
|
63
|
+
Button__default.default,
|
|
56
64
|
{
|
|
57
65
|
variant: "outlined",
|
|
58
66
|
onClick: () => setNum((oldNum) => oldNum + 1),
|
|
@@ -64,7 +72,7 @@ function ExampleComponent({ text }) {
|
|
|
64
72
|
"This is some text: ",
|
|
65
73
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: text })
|
|
66
74
|
] }),
|
|
67
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Paper__default.default, { children: [
|
|
68
76
|
"This number will incremember when button pressed: ",
|
|
69
77
|
num
|
|
70
78
|
] })
|
|
@@ -335,7 +343,7 @@ function SaladBarProvider(_a) {
|
|
|
335
343
|
children: [
|
|
336
344
|
children,
|
|
337
345
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
338
|
-
|
|
346
|
+
Snackbar__default.default,
|
|
339
347
|
__spreadProps(__spreadValues(__spreadValues({}, snackbarFinalProps), currentNotificationSnackbarProps), {
|
|
340
348
|
open,
|
|
341
349
|
onClose: handleClose,
|
|
@@ -346,17 +354,17 @@ function SaladBarProvider(_a) {
|
|
|
346
354
|
sx: { zIndex: SALADBAR_INDEX },
|
|
347
355
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
348
356
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
349
|
-
|
|
357
|
+
Alert__default.default,
|
|
350
358
|
{
|
|
351
359
|
onClose: handleClose,
|
|
352
360
|
severity: currentNotification.severity,
|
|
353
361
|
variant: "filled",
|
|
354
|
-
icon: currentNotification.progressIndicator === "circular" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
362
|
+
icon: currentNotification.progressIndicator === "circular" ? /* @__PURE__ */ jsxRuntime.jsx(CircularProgress__default.default, { size: "1em" }) : void 0,
|
|
355
363
|
style: currentNotification.progressIndicator === "linear" ? alertWithLinearProgressStyle : void 0,
|
|
356
364
|
children: currentNotification.message
|
|
357
365
|
}
|
|
358
366
|
),
|
|
359
|
-
currentNotification.progressIndicator === "linear" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
367
|
+
currentNotification.progressIndicator === "linear" && /* @__PURE__ */ jsxRuntime.jsx(LinearProgress__default.default, { color: "primary" })
|
|
360
368
|
] })
|
|
361
369
|
})
|
|
362
370
|
)
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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":["useState","jsxs","Fragment","jsx","createTheme","alpha","ThemeProvider","AgError","createContext","useRef","_a","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASwB,SAAA,iBAAiB,EAAE,QAA+B;AACxE,QAAM,CAAC,KAAK,MAAM,IAAIA,eAAS,CA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A,YAAA,gDACK,qBACA,mCAFL;AAAA,cAGC;AAAA,cACA,SAAS;AAAA,cACT,iBAAiB;AAAA,gBACf,UAAU;AAAA,gBACV,QAAQ;AAAA,cACV;AAAA,cACA,IAAI,EAAE,QAAQ,eAAe;AAAA,cAE7B,0CAAC,OACC,EAAA,UAAA;AAAA,gBAAAA,2BAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,SAAS;AAAA,oBACT,UAAU,oBAAoB;AAAA,oBAC9B,SAAS;AAAA,oBACT,MACE,oBAAoB,sBAAsB,4CACvC,kBAAiB,EAAA,MAAK,OAAM,IAC3B;AAAA,oBAEN,OACE,oBAAoB,sBAAsB,WACtC,+BACA;AAAA,oBAGL,UAAoB,oBAAA;AAAA,kBAAA;AAAA,gBACvB;AAAA,gBACC,oBAAoB,sBAAsB,YAAaA,2BAAAA,IAAA,gBAAA,EAAe,OAAM,WAAU;AAAA,cAAA,GACzF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA;AAEJ;ACnLA,SAAwB,cAAc;AACpC,SAAOQ,MAAAA,WAAW,eAAe;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 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":["useState","jsxs","Fragment","jsx","Typography","Button","Paper","createTheme","alpha","ThemeProvider","AgError","createContext","useRef","_a","Snackbar","Alert","CircularProgress","LinearProgress","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASwB,SAAA,iBAAiB,EAAE,QAA+B;AACxE,QAAM,CAAC,KAAK,MAAM,IAAIA,eAAS,CAAC;AAEhC,SAEIC,2BAAA,KAAAC,qBAAA,EAAA,UAAA;AAAA,IAAAC,2BAAA,IAACC,oBAAW,SAAA,EAAA,SAAQ,MAAK,OAAM,WAAU,WAAU,OAAM,IAAI,EAAE,UAAU,OAAO,GAAG,UAEnF,eAAA;AAAA,IAEAD,2BAAAA,IAACC,oBAAAA,WAAW,SAAQ,WAAU,SAAQ,SACpC,UAAAD,2BAAAA,IAAC,QAAK,EAAA,UAAA,wEAAA,CAAqE,EAC7E,CAAA;AAAA,IACAA,2BAAA;AAAA,MAACE,gBAAA;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,SAAS,MAAM,OAAO,CAAC,WAAW,SAAS,CAAC;AAAA,QAC5C,cAAW;AAAA,QACZ,UAAA;AAAA,MAAA;AAAA,IAED;AAAA,oCACC,KAAE,EAAA,UAAA;AAAA,MAAA;AAAA,MACkBF,2BAAAA,IAAC,UAAM,UAAK,KAAA,CAAA;AAAA,IAAA,GACjC;AAAA,oCACCG,eAAAA,SAAM,EAAA,UAAA;AAAA,MAAA;AAAA,MAAmD;AAAA,IAAA,GAAI;AAAA,EAChE,EAAA,CAAA;AAEJ;AChCO,MAAM,yBAAyBC,OAAAA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