@alextheman/components 5.3.0 → 5.4.0

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/index.d.cts CHANGED
@@ -144,13 +144,16 @@ interface LoaderDataBaseProps<T> {
144
144
  interface LoaderDataPropsOnNullable<T> extends LoaderDataBaseProps<T> {
145
145
  onUndefined?: never;
146
146
  onNull?: never;
147
- /** A function to run if the data is undefined or null, and not loading. This may either return React components or nothing. */
147
+ /** A function to run if the data is undefined or null, and not loading. This may either return React components or nothing.
148
+ * @deprecated Please use the nullableComponent prop on LoaderError instead */
148
149
  onNullable: () => ReactNode | void;
149
150
  }
150
151
  interface LoaderDataPropsOnUndefinedOrNull<T> extends LoaderDataBaseProps<T> {
151
- /** A function to run if the data is undefined and not loading. This may either return React components or nothing. */
152
+ /** A function to run if the data is undefined and not loading. This may either return React components or nothing.
153
+ * @deprecated Please use the nullableComponent prop on LoaderError instead */
152
154
  onUndefined?: () => ReactNode | void;
153
- /** A function to run if the data is null and not loading. This may either return React components or nothing. */
155
+ /** A function to run if the data is null and not loading. This may either return React components or nothing.
156
+ * @deprecated Please use the nullableComponent prop on LoaderError instead */
154
157
  onNull?: () => ReactNode | void;
155
158
  onNullable?: never;
156
159
  }
@@ -158,8 +161,26 @@ type LoaderDataProps<T> = LoaderDataPropsOnUndefinedOrNull<T> | LoaderDataPropsO
158
161
  /** The component responsible for showing the data provided by LoaderProvider. */
159
162
  declare function LoaderData<T>({ children, dataParser: loaderDataParser, loadingComponent, onNullable, onUndefined, onNull, showOnError, }: LoaderDataProps<T>): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element;
160
163
 
164
+ interface LoaderErrorBaseProps {
165
+ /** The component to show if an error has been thrown. */
166
+ errorComponent?: ReactNode | ((error: unknown) => ReactNode);
167
+ }
168
+ interface LoaderErrorPropsWithUndefinedOrNull extends LoaderErrorBaseProps {
169
+ /** The component to show if no error was thrown but data is undefined */
170
+ undefinedComponent?: ReactNode;
171
+ /** The component to show if no error was thrown but data is null */
172
+ nullComponent?: ReactNode;
173
+ /** The component to show if no error was thrown but data is undefined or null */
174
+ nullableComponent?: never;
175
+ }
176
+ interface LoaderErrorPropsWithNullable extends LoaderErrorBaseProps {
177
+ undefinedComponent?: never;
178
+ nullComponent?: never;
179
+ nullableComponent?: ReactNode;
180
+ }
181
+ type LoaderErrorProps = LoaderErrorPropsWithUndefinedOrNull | LoaderErrorPropsWithNullable;
161
182
  /** The component responsible for showing any errors provided by LoaderProvider. */
162
- declare function LoaderError(): string | number | bigint | boolean | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
183
+ declare function LoaderError({ errorComponent: propsErrorComponent, undefinedComponent, nullComponent, nullableComponent, }: LoaderErrorProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
163
184
 
164
185
  declare function useMode(): {
165
186
  toggleMode: () => void;
@@ -195,11 +216,11 @@ interface SnackbarContextValue {
195
216
  declare function useSnackbar(): SnackbarContextValue;
196
217
  declare function SnackbarProvider({ children, autoHideDuration }: SnackbarProviderProps): react_jsx_runtime.JSX.Element;
197
218
 
198
- type LoaderProps<T> = Omit<LoaderProviderProps<T>, "children"> & Omit<LoaderDataProps<T>, "showOnError">;
219
+ type LoaderProps<T> = Omit<LoaderProviderProps<T>, "children" | "errorComponent"> & LoaderErrorProps & Omit<LoaderDataProps<T>, "showOnError" | "onUndefined" | "onNull" | "onNullable">;
199
220
  /** An in-line component that deals with state management when fetching data from an API.
200
221
  * This may be used over LoaderProvider if you don't require as much control over the placement of the error message and data display.
201
222
  */
202
- declare function Loader<T>({ children, onUndefined, onNull, onNullable, loadingComponent, ...loaderProviderProps }: LoaderProps<T>): react_jsx_runtime.JSX.Element;
223
+ declare function Loader<T>({ children, undefinedComponent, nullComponent, nullableComponent, loadingComponent, ...loaderProviderProps }: LoaderProps<T>): react_jsx_runtime.JSX.Element;
203
224
 
204
225
  interface NavItemBottom {
205
226
  value: string;
@@ -269,4 +290,4 @@ declare function SwitchWithIcons({ checkedIcon: CheckedIcon, checkedIconStyles,
269
290
 
270
291
  declare function useHash<S extends string>(initialHash: S | undefined): [S, Dispatch<SetStateAction<S>>];
271
292
 
272
- export { CollapsableItem, type CollapsableItemProps, DarkModeToggle, DropdownMenu, type DropdownMenuProps, ExternalLink, type ExternalLinkProps, FileInput, FileInputList, type FileInputListProps, type FileInputProps, FileType, IconWithPopover, type IconWithPopoverProps, InternalLink, type InternalLinkProps, ListItemInternalLink, type ListItemInternalLinkProps, Loader, type LoaderContextValue, LoaderData, type LoaderDataProps, LoaderError, type LoaderProps, LoaderProvider, type LoaderProviderBaseProps, type LoaderProviderProps, type LoaderProviderPropsWithError, type LoaderProviderPropsWithNoError, type Mode, ModeProvider, type ModeProviderProps, type NavItemBottom, type NavMenuItem, NavigationBottom, type NavigationBottomProps, NavigationDrawer, type NavigationDrawerProps, PopoverText, type PopoverTextProps, ReactPlayground, type ReactPlaygroundProps, type ScreenSizeContextValue, type ScreenSizeProps, ScreenSizeProvider, SkeletonRow, type SkeletonRowProps, SnackbarProvider, type SnackbarProviderProps, SubmitButton, type SubmitButtonProps, SwitchWithIcons, type SwitchWithIconsProps, useHash, useLoader, useMode, useScreenSize, useSnackbar };
293
+ export { CollapsableItem, type CollapsableItemProps, DarkModeToggle, DropdownMenu, type DropdownMenuProps, ExternalLink, type ExternalLinkProps, FileInput, FileInputList, type FileInputListProps, type FileInputProps, FileType, IconWithPopover, type IconWithPopoverProps, InternalLink, type InternalLinkProps, ListItemInternalLink, type ListItemInternalLinkProps, Loader, type LoaderContextValue, LoaderData, type LoaderDataBaseProps, type LoaderDataProps, type LoaderDataPropsOnNullable, type LoaderDataPropsOnUndefinedOrNull, LoaderError, type LoaderErrorBaseProps, type LoaderErrorProps, type LoaderErrorPropsWithNullable, type LoaderErrorPropsWithUndefinedOrNull, type LoaderProps, LoaderProvider, type LoaderProviderBaseProps, type LoaderProviderProps, type LoaderProviderPropsWithError, type LoaderProviderPropsWithNoError, type Mode, ModeProvider, type ModeProviderProps, type NavItemBottom, type NavMenuItem, NavigationBottom, type NavigationBottomProps, NavigationDrawer, type NavigationDrawerProps, PopoverText, type PopoverTextProps, ReactPlayground, type ReactPlaygroundProps, type ScreenSizeContextValue, type ScreenSizeProps, ScreenSizeProvider, SkeletonRow, type SkeletonRowProps, SnackbarProvider, type SnackbarProviderProps, SubmitButton, type SubmitButtonProps, SwitchWithIcons, type SwitchWithIconsProps, useHash, useLoader, useMode, useScreenSize, useSnackbar };
package/dist/index.d.ts CHANGED
@@ -144,13 +144,16 @@ interface LoaderDataBaseProps<T> {
144
144
  interface LoaderDataPropsOnNullable<T> extends LoaderDataBaseProps<T> {
145
145
  onUndefined?: never;
146
146
  onNull?: never;
147
- /** A function to run if the data is undefined or null, and not loading. This may either return React components or nothing. */
147
+ /** A function to run if the data is undefined or null, and not loading. This may either return React components or nothing.
148
+ * @deprecated Please use the nullableComponent prop on LoaderError instead */
148
149
  onNullable: () => ReactNode | void;
149
150
  }
150
151
  interface LoaderDataPropsOnUndefinedOrNull<T> extends LoaderDataBaseProps<T> {
151
- /** A function to run if the data is undefined and not loading. This may either return React components or nothing. */
152
+ /** A function to run if the data is undefined and not loading. This may either return React components or nothing.
153
+ * @deprecated Please use the nullableComponent prop on LoaderError instead */
152
154
  onUndefined?: () => ReactNode | void;
153
- /** A function to run if the data is null and not loading. This may either return React components or nothing. */
155
+ /** A function to run if the data is null and not loading. This may either return React components or nothing.
156
+ * @deprecated Please use the nullableComponent prop on LoaderError instead */
154
157
  onNull?: () => ReactNode | void;
155
158
  onNullable?: never;
156
159
  }
@@ -158,8 +161,26 @@ type LoaderDataProps<T> = LoaderDataPropsOnUndefinedOrNull<T> | LoaderDataPropsO
158
161
  /** The component responsible for showing the data provided by LoaderProvider. */
159
162
  declare function LoaderData<T>({ children, dataParser: loaderDataParser, loadingComponent, onNullable, onUndefined, onNull, showOnError, }: LoaderDataProps<T>): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element;
160
163
 
164
+ interface LoaderErrorBaseProps {
165
+ /** The component to show if an error has been thrown. */
166
+ errorComponent?: ReactNode | ((error: unknown) => ReactNode);
167
+ }
168
+ interface LoaderErrorPropsWithUndefinedOrNull extends LoaderErrorBaseProps {
169
+ /** The component to show if no error was thrown but data is undefined */
170
+ undefinedComponent?: ReactNode;
171
+ /** The component to show if no error was thrown but data is null */
172
+ nullComponent?: ReactNode;
173
+ /** The component to show if no error was thrown but data is undefined or null */
174
+ nullableComponent?: never;
175
+ }
176
+ interface LoaderErrorPropsWithNullable extends LoaderErrorBaseProps {
177
+ undefinedComponent?: never;
178
+ nullComponent?: never;
179
+ nullableComponent?: ReactNode;
180
+ }
181
+ type LoaderErrorProps = LoaderErrorPropsWithUndefinedOrNull | LoaderErrorPropsWithNullable;
161
182
  /** The component responsible for showing any errors provided by LoaderProvider. */
162
- declare function LoaderError(): string | number | bigint | boolean | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
183
+ declare function LoaderError({ errorComponent: propsErrorComponent, undefinedComponent, nullComponent, nullableComponent, }: LoaderErrorProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
163
184
 
164
185
  declare function useMode(): {
165
186
  toggleMode: () => void;
@@ -195,11 +216,11 @@ interface SnackbarContextValue {
195
216
  declare function useSnackbar(): SnackbarContextValue;
196
217
  declare function SnackbarProvider({ children, autoHideDuration }: SnackbarProviderProps): react_jsx_runtime.JSX.Element;
197
218
 
198
- type LoaderProps<T> = Omit<LoaderProviderProps<T>, "children"> & Omit<LoaderDataProps<T>, "showOnError">;
219
+ type LoaderProps<T> = Omit<LoaderProviderProps<T>, "children" | "errorComponent"> & LoaderErrorProps & Omit<LoaderDataProps<T>, "showOnError" | "onUndefined" | "onNull" | "onNullable">;
199
220
  /** An in-line component that deals with state management when fetching data from an API.
200
221
  * This may be used over LoaderProvider if you don't require as much control over the placement of the error message and data display.
201
222
  */
202
- declare function Loader<T>({ children, onUndefined, onNull, onNullable, loadingComponent, ...loaderProviderProps }: LoaderProps<T>): react_jsx_runtime.JSX.Element;
223
+ declare function Loader<T>({ children, undefinedComponent, nullComponent, nullableComponent, loadingComponent, ...loaderProviderProps }: LoaderProps<T>): react_jsx_runtime.JSX.Element;
203
224
 
204
225
  interface NavItemBottom {
205
226
  value: string;
@@ -269,4 +290,4 @@ declare function SwitchWithIcons({ checkedIcon: CheckedIcon, checkedIconStyles,
269
290
 
270
291
  declare function useHash<S extends string>(initialHash: S | undefined): [S, Dispatch<SetStateAction<S>>];
271
292
 
272
- export { CollapsableItem, type CollapsableItemProps, DarkModeToggle, DropdownMenu, type DropdownMenuProps, ExternalLink, type ExternalLinkProps, FileInput, FileInputList, type FileInputListProps, type FileInputProps, FileType, IconWithPopover, type IconWithPopoverProps, InternalLink, type InternalLinkProps, ListItemInternalLink, type ListItemInternalLinkProps, Loader, type LoaderContextValue, LoaderData, type LoaderDataProps, LoaderError, type LoaderProps, LoaderProvider, type LoaderProviderBaseProps, type LoaderProviderProps, type LoaderProviderPropsWithError, type LoaderProviderPropsWithNoError, type Mode, ModeProvider, type ModeProviderProps, type NavItemBottom, type NavMenuItem, NavigationBottom, type NavigationBottomProps, NavigationDrawer, type NavigationDrawerProps, PopoverText, type PopoverTextProps, ReactPlayground, type ReactPlaygroundProps, type ScreenSizeContextValue, type ScreenSizeProps, ScreenSizeProvider, SkeletonRow, type SkeletonRowProps, SnackbarProvider, type SnackbarProviderProps, SubmitButton, type SubmitButtonProps, SwitchWithIcons, type SwitchWithIconsProps, useHash, useLoader, useMode, useScreenSize, useSnackbar };
293
+ export { CollapsableItem, type CollapsableItemProps, DarkModeToggle, DropdownMenu, type DropdownMenuProps, ExternalLink, type ExternalLinkProps, FileInput, FileInputList, type FileInputListProps, type FileInputProps, FileType, IconWithPopover, type IconWithPopoverProps, InternalLink, type InternalLinkProps, ListItemInternalLink, type ListItemInternalLinkProps, Loader, type LoaderContextValue, LoaderData, type LoaderDataBaseProps, type LoaderDataProps, type LoaderDataPropsOnNullable, type LoaderDataPropsOnUndefinedOrNull, LoaderError, type LoaderErrorBaseProps, type LoaderErrorProps, type LoaderErrorPropsWithNullable, type LoaderErrorPropsWithUndefinedOrNull, type LoaderProps, LoaderProvider, type LoaderProviderBaseProps, type LoaderProviderProps, type LoaderProviderPropsWithError, type LoaderProviderPropsWithNoError, type Mode, ModeProvider, type ModeProviderProps, type NavItemBottom, type NavMenuItem, NavigationBottom, type NavigationBottomProps, NavigationDrawer, type NavigationDrawerProps, PopoverText, type PopoverTextProps, ReactPlayground, type ReactPlaygroundProps, type ScreenSizeContextValue, type ScreenSizeProps, ScreenSizeProvider, SkeletonRow, type SkeletonRowProps, SnackbarProvider, type SnackbarProviderProps, SubmitButton, type SubmitButtonProps, SwitchWithIcons, type SwitchWithIconsProps, useHash, useLoader, useMode, useScreenSize, useSnackbar };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var Ie=Object.defineProperty,ke=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var Y=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var K=(e,o,r)=>o in e?Ie(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,a=(e,o)=>{for(var r in o||(o={}))Y.call(o,r)&&K(e,r,o[r]);if(T)for(var r of T(o))q.call(o,r)&&K(e,r,o[r]);return e},c=(e,o)=>ke(e,Ce(o));var P=(e,o)=>{var r={};for(var n in e)Y.call(e,n)&&o.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&T)for(var n of T(e))o.indexOf(n)<0&&q.call(e,n)&&(r[n]=e[n]);return r};var Q=(e,o,r)=>new Promise((n,i)=>{var t=d=>{try{p(r.next(d))}catch(u){i(u)}},s=d=>{try{p(r.throw(d))}catch(u){i(u)}},p=d=>d.done?n(d.value):Promise.resolve(d.value).then(t,s);p((r=r.apply(e,o)).next())});import Te from"@mui/icons-material/ArrowDropDown";import Be from"@mui/icons-material/ArrowDropUp";import Ne from"@mui/material/Box";import M from"@mui/material/ButtonBase";import De from"@mui/material/Collapse";import{useEffect as Re,useState as Me}from"react";import{jsx as E,jsxs as Z}from"react/jsx-runtime";function Ee({isInitiallyOpen:e,onOpen:o,onClose:r,children:n,buttonStyles:i,buttonContents:t,buttonComponent:s=M,collapseProps:p,openIcon:d=E(Be,{}),closedIcon:u=E(Te,{}),useDefaultStyling:m=s===M}){let[l,f]=Me(!!e);return Re(()=>{l&&o?o():!l&&r&&r()},[l]),Z(Ne,{children:[Z(s,{onClick:()=>{f(g=>!g)},sx:m?a({width:"100%",display:"flex",alignItems:"center",justifyContent:"center",paddingY:1.5,paddingX:2,textAlign:"center","&:hover":s===M?{backgroundColor:"action.hover"}:null},i):i,"aria-expanded":l,children:[t,l?d:u]}),E(De,c(a({in:l},p),{children:n}))]})}var Oe=Ee;import Po from"@mui/icons-material/DarkMode";import go from"@mui/icons-material/LightMode";import vo from"@mui/material/IconButton";import yo from"@mui/material/Tooltip";import Ae from"@mui/material/CircularProgress";import{createContext as Fe,useContext as We}from"react";import{jsx as j}from"react/jsx-runtime";var ee=Fe(void 0);function w(){let e=We(ee);if(!e)throw new Error("LOADER_CONTEXT_NOT_SET");return e}function ze(n){var i=n,{children:e,loadingComponent:o=j(Ae,{})}=i,r=P(i,["children","loadingComponent"]);return j(ee.Provider,{value:a({loadingComponent:o},r),children:e})}var O=ze;import{useRef as He}from"react";import{Fragment as y,jsx as h}from"react/jsx-runtime";var oe="Data is undefined after loading. This could either be an issue with the query or you have not passed in the data to LoaderProvider. Please double-check that you have provided data.";function Ve({children:e,dataParser:o,loadingComponent:r,onNullable:n,onUndefined:i,onNull:t,showOnError:s}){let{isLoading:p,data:d,dataParser:u,loadingComponent:m,error:l}=w(),f=He(!1),g=o!=null?o:u;if(p)return h(y,{children:r!=null?r:m});if(l&&!s)return h(y,{});if(!d){if(n){d===void 0&&!f.current&&(console.warn(oe),f.current=!0);let x=n();return x!=null?x:h(y,{})}if(d===void 0&&i){f.current||(console.warn(oe),f.current=!0);let x=i();return x!=null?x:h(y,{})}if(d===null&&t){let x=t();return x!=null?x:h(y,{})}return h(y,{})}return g?typeof e=="function"?h(y,{children:e(g(d))}):h(y,{children:e}):typeof e=="function"?h(y,{children:e(d)}):h(y,{children:e})}var A=Ve;import Ue from"@mui/material/Alert";import{Fragment as re,jsx as F}from"react/jsx-runtime";function Xe(){var r;let{error:e,errorComponent:o}=w();return e?typeof o=="function"?o(e):o?F(re,{children:o}):F(Ue,{severity:"error",children:(r=e==null?void 0:e.message)!=null?r:"An unknown error has occured. Please try again later."}):F(re,{})}var W=Xe;import $e from"@mui/material/CssBaseline";import{createTheme as _e,ThemeProvider as Ge}from"@mui/material/styles";import{createContext as Je,useContext as Ke,useMemo as Ye,useState as qe}from"react";import{jsx as te,jsxs as je}from"react/jsx-runtime";var ne=Je({toggleMode:()=>{},mode:"dark"});function I(){return Ke(ne)}function Qe({children:e,mode:o="dark"}){let[r,n]=qe(o),i=Ye(()=>_e({palette:{mode:r}}),[r]);return te(ne.Provider,{value:{mode:r,toggleMode:()=>{n(t=>t==="light"?"dark":"light")}},children:je(Ge,{theme:i,children:[te($e,{}),e]})})}var Ze=Qe;import{createContext as eo,useContext as oo,useEffect as ie,useState as z}from"react";import{jsx as io}from"react/jsx-runtime";var ae=eo({windowWidth:0,windowHeight:0,isLargeScreen:!1});function ro(){return oo(ae)}function to({children:e,largeScreenWidth:o,largeScreenHeight:r}){let[n,i]=z(window.innerWidth),[t,s]=z(window.innerHeight);function p(m,l,f=669,g=600){return m>f&&l>g}let[d,u]=z(p(window.innerWidth,window.innerHeight,o,r));return ie(()=>{function m(){i(window.innerWidth),s(window.innerHeight)}return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[]),ie(()=>{u(p(n,t,o,r))},[n,t,o,r]),io(ae.Provider,{value:{isLargeScreen:d,windowWidth:n,windowHeight:t},children:e})}var no=to;import{wait as ao}from"@alextheman/utility";import po from"@mui/material/Alert";import so from"@mui/material/Snackbar";import{createContext as mo,useContext as lo,useState as B}from"react";import{jsx as pe,jsxs as xo}from"react/jsx-runtime";var se=mo(void 0);function co(){let e=lo(se);if(!e)throw new Error("SNACKBAR_CONTEXT_NOT_SET");return e}function uo({children:e,autoHideDuration:o=5e3}){let[r,n]=B(!1),[i,t]=B(o),[s,p]=B(""),[d,u]=B("info");function m(f,g,x){n(!0),t(x!=null?x:o),u(g!=null?g:"info"),p(f)}function l(){return Q(this,null,function*(){n(!1),yield ao(.2),p("")})}return xo(se.Provider,{value:{addSnackbar:m},children:[pe(so,{open:r,autoHideDuration:i,onClose:l,children:pe(po,{onClose:l,severity:d,children:s})}),e]})}var fo=uo;import{jsx as N}from"react/jsx-runtime";function ho(){let{mode:e,toggleMode:o}=I();return N(yo,{title:`Enable ${e==="dark"?"light":"dark"} mode`,children:N(vo,{sx:{marginLeft:"auto"},onClick:o,"aria-label":`Enable ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?N(go,{}):N(Po,{})})})}var So=ho;import bo from"@mui/icons-material/ArrowDropDown";import Lo from"@mui/icons-material/ArrowDropUp";import de from"@mui/material/Box";import me from"@mui/material/Button";import wo from"@mui/material/Menu";import{useEffect as Io,useMemo as ko,useState as Co}from"react";import{jsx as k,jsxs as No}from"react/jsx-runtime";function To({children:e,button:o=me,buttonChildren:r="Menu",buttonProps:n,isOpenIcon:i=k(Lo,{}),isClosedIcon:t=k(bo,{}),onOpen:s,onClose:p}){let[d,u]=Co(null),m=ko(()=>!!d,[d]),l=c(a({},n),{onClick:f=>{u(f.currentTarget)},"aria-controls":m?"dropdown-menu":void 0,"aria-haspopup":"true","aria-expanded":m});return o===me&&(l.endIcon=m?i:t),Io(()=>{m&&s?s():!m&&p&&p()},[m,s,p]),No(de,{children:[k(o,c(a({},l),{children:r})),k(wo,{id:"dropdown-menu",anchorEl:d,open:m,onClose:()=>{u(null)},children:typeof e=="function"?k(de,{children:e(()=>{u(null)})}):e})]})}var Bo=To;import Do from"@mui/material/Link";import{jsx as Eo}from"react/jsx-runtime";function Ro(n){var i=n,{href:e,children:o}=i,r=P(i,["href","children"]);return Eo(Do,c(a({component:"a",href:e,target:"_blank",rel:"noopener noreferrer"},r),{children:o}))}var Mo=Ro;import Oo from"@mui/icons-material/CloudUpload";import Ao from"@mui/material/Button";import{styled as le}from"@mui/material/styles";import{useState as Fo}from"react";import{jsx as H,jsxs as Uo}from"react/jsx-runtime";var Wo={PDF:"application/pdf",PNG:"image/png",JPEG:"image/jpeg",JPG:"image/jpg",XLSX:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",DOCX:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",MP3:"audio/mp3",MP4:"video/mp4",WAV:"audio/wav"},zo=le("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1}),Ho=le("div")(({theme:e,$dragging:o})=>({border:"2px dashed",borderColor:o?e.palette.primary.main:"#ccc",backgroundColor:o?e.palette.action.hover:"transparent",borderRadius:8,padding:"1.5rem",textAlign:"center",transition:"border-color 0.2s",cursor:"pointer"}));function Vo(s){var p=s,{onFileInput:e,label:o="Upload files",multiple:r,accept:n,useDropzone:i}=p,t=P(p,["onFileInput","label","multiple","accept","useDropzone"]);var l;let[d,u]=Fo(!1),m=Uo(Ao,c(a({variant:"contained",component:"label","aria-label":"File upload button",onKeyDown:f=>{var g;(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),(g=document.getElementById("file-input"))==null||g.click())}},t),{startIcon:(l=t.startIcon)!=null?l:H(Oo,{}),children:[o,H(zo,{id:"file-input",type:"file",onChange:f=>{var x;let g=f.target;e(Array.from((x=g.files)!=null?x:[])),g.value=""},multiple:r,accept:n==null?void 0:n.join(","),disabled:t.disabled})]}));return i?H(Ho,{$dragging:d,onDragOver:f=>{f.preventDefault(),!t.disabled&&u(!0)},onDragLeave:f=>{f.preventDefault(),u(!1)},onDrop:f=>{var x;if(f.preventDefault(),u(!1),t.disabled)return;let g=Array.from((x=f.dataTransfer.files)!=null?x:[]);e(g)},children:m}):m}var V=Vo;import Xo from"@mui/icons-material/Delete";import $o from"@mui/material/Box";import _o from"@mui/material/IconButton";import Go from"@mui/material/List";import Jo from"@mui/material/ListItem";import Ko from"@mui/material/ListItemText";import{jsx as L,jsxs as Qo}from"react/jsx-runtime";function Yo(n){var i=n,{files:e,setFiles:o}=i,r=P(i,["files","setFiles"]);function t(p){o(d=>[...d,...p])}let s=c(a({},r),{onFileInput:t});return(s==null?void 0:s.multiple)===void 0&&(s.multiple=!0),Qo($o,{children:[L(V,a({},s)),L(Go,{children:e.map(p=>L(Jo,{secondaryAction:L(_o,{"aria-label":"Delete",edge:"end",onClick:()=>{o(d=>d.filter(u=>u!==p))},children:L(Xo,{})}),children:L(Ko,{primary:p.name})},p.name))})]})}var qo=Yo;import Zo from"@mui/material/Box";import jo from"@mui/material/Popover";import{useId as er,useState as or}from"react";import{jsx as ce,jsxs as nr}from"react/jsx-runtime";function rr({icon:e,onOpen:o,onClose:r,iconProps:n,children:i}){let[t,s]=or(null),p=!!t,d=er();function u(l){s(l.currentTarget),o&&o()}function m(){s(null),r&&r()}return nr(Zo,{children:[ce(e,a({"aria-owns":p?d:void 0,"aria-haspopup":"true",onMouseEnter:u,onMouseLeave:m},n)),ce(jo,{id:d,sx:{pointerEvents:"none"},open:p,anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:m,disableRestoreFocus:!0,children:i})]})}var tr=rr;import ir from"@mui/material/Link";import{Link as ar}from"react-router-dom";import{jsx as sr}from"react/jsx-runtime";function pr(n){var i=n,{to:e,children:o}=i,r=P(i,["to","children"]);return sr(ir,c(a({component:ar,to:e},r),{children:o}))}var U=pr;import dr from"@mui/material/ListItemButton";import{jsx as cr}from"react/jsx-runtime";function mr(r){var n=r,{children:e}=n,o=P(n,["children"]);return cr(dr,c(a({component:U},o),{children:e}))}var lr=mr;import ur from"@mui/material/CircularProgress";import{jsx as X,jsxs as Pr}from"react/jsx-runtime";function fr(s){var p=s,{children:e,onUndefined:o,onNull:r,onNullable:n,loadingComponent:i=X(ur,{})}=p,t=P(p,["children","onUndefined","onNull","onNullable","loadingComponent"]);return Pr(O,c(a({loadingComponent:i},t),{children:[X(W,{}),X(A,{onUndefined:o,onNull:r,onNullable:n,children:e})]}))}var xr=fr;import gr from"@mui/material/BottomNavigation";import vr from"@mui/material/BottomNavigationAction";import yr from"@mui/material/Box";import hr from"@mui/material/Paper";import{useState as Sr}from"react";import{Link as br}from"react-router-dom";import{Fragment as Ir,jsx as D,jsxs as kr}from"react/jsx-runtime";function Lr({children:e,navItems:o}){let[r,n]=Sr("");return kr(Ir,{children:[D(yr,{sx:{paddingBottom:7},children:e}),D(hr,{sx:{position:"fixed",bottom:0,left:0,right:0},children:D(gr,{showLabels:!0,value:r,onChange:(i,t)=>{n(t)},children:o.map(i=>D(vr,c(a({},i),{component:br}),i.value))})})]})}var wr=Lr;import{truncate as ue}from"@alextheman/utility";import Cr from"@mui/icons-material/ChevronLeft";import Tr from"@mui/icons-material/ChevronRight";import Br from"@mui/icons-material/Menu";import Nr from"@mui/material/AppBar";import fe from"@mui/material/Box";import Dr from"@mui/material/CssBaseline";import xe from"@mui/material/Divider";import Rr from"@mui/material/Drawer";import Pe from"@mui/material/IconButton";import Mr from"@mui/material/List";import Er from"@mui/material/ListItem";import Or from"@mui/material/ListItemButton";import Ar from"@mui/material/ListItemIcon";import Fr from"@mui/material/ListItemText";import{styled as _,useTheme as Wr}from"@mui/material/styles";import zr from"@mui/material/Toolbar";import $ from"@mui/material/Typography";import{Fragment as Hr,useState as Vr}from"react";import{Link as Ur,useLocation as Xr}from"react-router-dom";import{jsx as v,jsxs as b}from"react/jsx-runtime";var R=240;function ge(e){return{width:R,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen}),overflowX:"hidden"}}function ve(e){return{transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden",width:`calc(${e.spacing(7)} + 1px)`,[e.breakpoints.up("sm")]:{width:`calc(${e.spacing(8)} + 1px)`}}}var ye=_("div")(({theme:e})=>a({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:e.spacing(0,1)},e.mixins.toolbar)),$r=_(Nr,{shouldForwardProp:e=>e!=="open"})(({theme:e})=>({zIndex:e.zIndex.drawer+1,transition:e.transitions.create(["width","margin"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),variants:[{props:({open:o})=>o,style:{marginLeft:R,width:`calc(100% - ${R}px)`,transition:e.transitions.create(["width","margin"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen})}}]})),_r=_(Rr,{shouldForwardProp:e=>e!=="open"})(({theme:e})=>({width:R,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",variants:[{props:({open:o})=>o,style:c(a({},ge(e)),{"& .MuiDrawer-paper":ge(e)})},{props:({open:o})=>!o,style:c(a({},ve(e)),{"& .MuiDrawer-paper":ve(e)})}]}));function Gr({title:e,navItems:o,children:r,headerElements:n}){let i=Wr(),[t,s]=Vr(!0),p=Xr();function d(){s(!0)}function u(){s(!1)}return b(fe,{sx:{display:"flex"},children:[v(Dr,{}),v($r,{position:"fixed",open:t,children:b(zr,{children:[v(Pe,{color:"inherit","aria-label":"open drawer",onClick:d,edge:"start",sx:[{marginRight:5},t&&{display:"none"}],children:v(Br,{})}),v($,{variant:"h6",noWrap:!0,component:"div",children:e}),n]})}),b(_r,{variant:"permanent",open:t,children:[v(ye,{children:v(Pe,{onClick:u,children:i.direction==="rtl"?v(Tr,{}):v(Cr,{})})}),v(xe,{}),o.map(m=>b(Hr,{children:[b(Mr,{children:[v($,{variant:t?"h5":"h6",paddingLeft:t?2:1,children:t?m.category:ue(m.category,4)}),m.options.map(l=>v(Er,{disablePadding:!0,sx:{display:"block"},children:b(Or,{sx:[{minHeight:48,px:2.5},t?{justifyContent:"initial"}:{justifyContent:"center"}],component:Ur,to:l.to,selected:p.pathname===l.to,children:[v(Ar,{sx:[{minWidth:0,justifyContent:"center"},t?{mr:3}:{mr:"auto"}],children:l.icon?l.icon:t?null:v($,{children:ue(l.label,4)})}),v(Fr,{primary:l.label,sx:[t?{opacity:1}:{opacity:0}]})]})},l.to))]}),v(xe,{})]},m.category))]}),b(fe,{component:"main",sx:{flexGrow:1,p:3},children:[v(ye,{}),r]})]})}var Jr=Gr;import Kr from"@mui/material/Typography";import{Fragment as Qr,jsx as he}from"react/jsx-runtime";function Yr(n){var i=n,{text:e,sx:o}=i,r=P(i,["text","sx"]);return he(Qr,{children:e.split(`
2
- `).map((t,s)=>he(Kr,c(a({sx:a({margin:1},o)},r),{children:t}),s))})}var qr=Yr;import G from"@mui/material/Box";import Se from"@mui/material/Typography";import{stripIndent as Zr}from"common-tags";import{LiveEditor as jr,LiveError as et,LivePreview as ot,LiveProvider as rt}from"react-live";import{jsx as S,jsxs as be}from"react/jsx-runtime";function tt({code:e,scope:o,previewStyles:r,noInline:n,enableTypeScript:i,language:t}){let{mode:s}=I(),p={backgroundColor:s==="dark"?"black":"white",border:.3,borderRadius:1,padding:2,borderColor:"darkgray"},d=r?a(a({},p),r):a({},p);return S(G,{sx:{borderRadius:1,border:.5,padding:2},children:be(rt,{code:Zr(e),scope:o,noInline:n,enableTypeScript:i,language:t,children:[S(Se,{variant:"h5",children:"Code"}),S(G,{sx:{border:.3,borderRadius:.3,borderColor:"darkgray"},children:S(jr,{})}),S("br",{}),S(Se,{variant:"h5",children:"Result"}),be(G,{sx:d,children:[S(ot,{}),S(et,{})]})]})})}var nt=tt;import{fillArray as it}from"@alextheman/utility";import at from"@mui/material/Skeleton";import pt from"@mui/material/TableCell";import st from"@mui/material/TableRow";import{jsx as J}from"react/jsx-runtime";function dt({columns:e}){return J(st,{children:it(o=>J(pt,{children:J(at,{})},o),e)})}var mt=dt;import lt from"@mui/material/Button";import{useFormContext as ct}from"react-hook-form";import{jsx as xt}from"react/jsx-runtime";function ut(n){var i=n,{disableClean:e,label:o}=i,r=P(i,["disableClean","label"]);let{formState:{disabled:t,isDirty:s,isSubmitting:p}}=ct();return xt(lt,c(a({color:"primary",disabled:r.disabled||e&&!s||t,loading:p,type:"submit",variant:"contained"},r),{children:o}))}var ft=ut;import Le from"@mui/material/Box";import{styled as Pt}from"@mui/material/styles";import gt from"@mui/material/Switch";import{jsx as C}from"react/jsx-runtime";var vt=Pt(gt)(()=>({padding:8,"& .MuiSwitch-track":{borderRadius:11,"&::before, &::after":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",fontSize:16,width:28,height:28}}}));function yt(t){var s=t,{checkedIcon:e,checkedIconStyles:o,uncheckedIcon:r,uncheckedIconStyles:n}=s,i=P(s,["checkedIcon","checkedIconStyles","uncheckedIcon","uncheckedIconStyles"]);let p={borderRadius:"50%",borderColor:"white",backgroundColor:"white",display:"flex",alignItems:"center",justifyContent:"center",padding:.25},d={color:"black",maxWidth:16.5,maxHeight:16.5};return C(vt,a({checkedIcon:C(Le,{sx:p,children:C(e,{style:a(a({},d),o)})}),icon:C(Le,{sx:p,children:C(r,{style:a(a({},d),n)})})},i))}var ht=yt;import{useCallback as we,useEffect as St,useState as bt}from"react";function Lt(e){let[o,r]=bt(()=>{let t=window.location.hash.replace("#","");return e&&t===""?e:t}),n=we(()=>{let t=window.location.hash.replace("#","");r(e&&t===""?e:t)},[r,e]);St(()=>(window.addEventListener("hashchange",n),()=>{window.removeEventListener("hashchange",n)}),[n]);let i=we(t=>{let s=typeof t=="function"?t(o):t;s!==o&&(window.location.hash=s)},[o]);return[o,i]}var wt=Lt;export{Oe as CollapsableItem,So as DarkModeToggle,Bo as DropdownMenu,Mo as ExternalLink,V as FileInput,qo as FileInputList,Wo as FileType,tr as IconWithPopover,U as InternalLink,lr as ListItemInternalLink,xr as Loader,A as LoaderData,W as LoaderError,O as LoaderProvider,Ze as ModeProvider,wr as NavigationBottom,Jr as NavigationDrawer,qr as PopoverText,nt as ReactPlayground,no as ScreenSizeProvider,mt as SkeletonRow,fo as SnackbarProvider,ft as SubmitButton,ht as SwitchWithIcons,wt as useHash,w as useLoader,I as useMode,ro as useScreenSize,co as useSnackbar};
1
+ var we=Object.defineProperty,Ie=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var Y=(e,o,r)=>o in e?we(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,s=(e,o)=>{for(var r in o||(o={}))q.call(o,r)&&Y(e,r,o[r]);if(B)for(var r of B(o))Q.call(o,r)&&Y(e,r,o[r]);return e},f=(e,o)=>Ie(e,Ce(o));var P=(e,o)=>{var r={};for(var n in e)q.call(e,n)&&o.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&B)for(var n of B(e))o.indexOf(n)<0&&Q.call(e,n)&&(r[n]=e[n]);return r};var Z=(e,o,r)=>new Promise((n,a)=>{var t=p=>{try{i(r.next(p))}catch(c){a(c)}},d=p=>{try{i(r.throw(p))}catch(c){a(c)}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(t,d);i((r=r.apply(e,o)).next())});import ke from"@mui/icons-material/ArrowDropDown";import Te from"@mui/icons-material/ArrowDropUp";import Ne from"@mui/material/Box";import O from"@mui/material/ButtonBase";import Be from"@mui/material/Collapse";import{useEffect as Ee,useState as Re}from"react";import{jsx as A,jsxs as j}from"react/jsx-runtime";function De({isInitiallyOpen:e,onOpen:o,onClose:r,children:n,buttonStyles:a,buttonContents:t,buttonComponent:d=O,collapseProps:i,openIcon:p=A(Te,{}),closedIcon:c=A(ke,{}),useDefaultStyling:l=d===O}){let[m,x]=Re(!!e);return Ee(()=>{m&&o?o():!m&&r&&r()},[m]),j(Ne,{children:[j(d,{onClick:()=>{x(u=>!u)},sx:l?s({width:"100%",display:"flex",alignItems:"center",justifyContent:"center",paddingY:1.5,paddingX:2,textAlign:"center","&:hover":d===O?{backgroundColor:"action.hover"}:null},a):a,"aria-expanded":m,children:[t,m?p:c]}),A(Be,f(s({in:m},i),{children:n}))]})}var Me=De;import Po from"@mui/icons-material/DarkMode";import vo from"@mui/icons-material/LightMode";import go from"@mui/material/IconButton";import ho from"@mui/material/Tooltip";import Oe from"@mui/material/CircularProgress";import{createContext as Ae,useContext as We}from"react";import{jsx as ee}from"react/jsx-runtime";var oe=Ae(void 0);function I(){let e=We(oe);if(!e)throw new Error("LOADER_CONTEXT_NOT_SET");return e}function Fe(n){var a=n,{children:e,loadingComponent:o=ee(Oe,{})}=a,r=P(a,["children","loadingComponent"]);return ee(oe.Provider,{value:s({loadingComponent:o},r),children:e})}var W=Fe;import{Fragment as g,jsx as h}from"react/jsx-runtime";function ze({children:e,dataParser:o,loadingComponent:r,onNullable:n,onUndefined:a,onNull:t,showOnError:d}){let{isLoading:i,data:p,dataParser:c,loadingComponent:l,error:m}=I(),x=o!=null?o:c;if(i)return h(g,{children:r!=null?r:l});if(m&&!d)return h(g,{});if(p==null){if(n){let u=n();return u!=null?u:h(g,{})}if(p===void 0&&a){let u=a();return u!=null?u:h(g,{})}if(p===null&&t){let u=t();return u!=null?u:h(g,{})}return h(g,{})}return x?typeof e=="function"?h(g,{children:e(x(p))}):h(g,{children:e}):typeof e=="function"?h(g,{children:e(p)}):h(g,{children:e})}var F=ze;import Ue from"@mui/material/Alert";import{useRef as He}from"react";import{Fragment as C,jsx as S}from"react/jsx-runtime";var Ve="Data is undefined after loading. This could either be an issue with the query or you have not passed in the data to LoaderProvider. Please double-check that you have provided data.";function Xe({errorComponent:e,undefinedComponent:o,nullComponent:r,nullableComponent:n}){var c;let{data:a,error:t,errorComponent:d}=I(),i=He(!1),p=e!=null?e:d;if(t)return typeof p=="function"?p(t):p?S(C,{children:p}):S(Ue,{severity:"error",children:(c=t==null?void 0:t.message)!=null?c:"An unknown error has occured. Please try again later."});if(a==null){if(n)return S(C,{children:n});if(a===void 0&&o)return i.current||(console.warn(Ve),i.current=!0),S(C,{children:o});if(a===null&&r)return S(C,{children:r})}return S(C,{})}var z=Xe;import $e from"@mui/material/CssBaseline";import{createTheme as _e,ThemeProvider as Ge}from"@mui/material/styles";import{createContext as Je,useContext as Ke,useMemo as Ye,useState as qe}from"react";import{jsx as re,jsxs as je}from"react/jsx-runtime";var te=Je({toggleMode:()=>{},mode:"dark"});function k(){return Ke(te)}function Qe({children:e,mode:o="dark"}){let[r,n]=qe(o),a=Ye(()=>_e({palette:{mode:r}}),[r]);return re(te.Provider,{value:{mode:r,toggleMode:()=>{n(t=>t==="light"?"dark":"light")}},children:je(Ge,{theme:a,children:[re($e,{}),e]})})}var Ze=Qe;import{createContext as eo,useContext as oo,useEffect as ne,useState as U}from"react";import{jsx as ao}from"react/jsx-runtime";var ae=eo({windowWidth:0,windowHeight:0,isLargeScreen:!1});function ro(){return oo(ae)}function to({children:e,largeScreenWidth:o,largeScreenHeight:r}){let[n,a]=U(window.innerWidth),[t,d]=U(window.innerHeight);function i(l,m,x=669,u=600){return l>x&&m>u}let[p,c]=U(i(window.innerWidth,window.innerHeight,o,r));return ne(()=>{function l(){a(window.innerWidth),d(window.innerHeight)}return l(),window.addEventListener("resize",l),()=>{window.removeEventListener("resize",l)}},[]),ne(()=>{c(i(n,t,o,r))},[n,t,o,r]),ao(ae.Provider,{value:{isLargeScreen:p,windowWidth:n,windowHeight:t},children:e})}var no=to;import{wait as io}from"@alextheman/utility";import po from"@mui/material/Alert";import so from"@mui/material/Snackbar";import{createContext as lo,useContext as mo,useState as E}from"react";import{jsx as ie,jsxs as xo}from"react/jsx-runtime";var pe=lo(void 0);function co(){let e=mo(pe);if(!e)throw new Error("SNACKBAR_CONTEXT_NOT_SET");return e}function uo({children:e,autoHideDuration:o=5e3}){let[r,n]=E(!1),[a,t]=E(o),[d,i]=E(""),[p,c]=E("info");function l(x,u,y){n(!0),t(y!=null?y:o),c(u!=null?u:"info"),i(x)}function m(){return Z(this,null,function*(){n(!1),yield io(.2),i("")})}return xo(pe.Provider,{value:{addSnackbar:l},children:[ie(so,{open:r,autoHideDuration:a,onClose:m,children:ie(po,{onClose:m,severity:p,children:d})}),e]})}var fo=uo;import{jsx as R}from"react/jsx-runtime";function yo(){let{mode:e,toggleMode:o}=k();return R(ho,{title:`Enable ${e==="dark"?"light":"dark"} mode`,children:R(go,{sx:{marginLeft:"auto"},onClick:o,"aria-label":`Enable ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?R(vo,{}):R(Po,{})})})}var Lo=yo;import bo from"@mui/icons-material/ArrowDropDown";import So from"@mui/icons-material/ArrowDropUp";import se from"@mui/material/Box";import de from"@mui/material/Button";import wo from"@mui/material/Menu";import{useEffect as Io,useMemo as Co,useState as ko}from"react";import{jsx as T,jsxs as Bo}from"react/jsx-runtime";function To({children:e,button:o=de,buttonChildren:r="Menu",buttonProps:n,isOpenIcon:a=T(So,{}),isClosedIcon:t=T(bo,{}),onOpen:d,onClose:i}){let[p,c]=ko(null),l=Co(()=>!!p,[p]),m=f(s({},n),{onClick:x=>{c(x.currentTarget)},"aria-controls":l?"dropdown-menu":void 0,"aria-haspopup":"true","aria-expanded":l});return o===de&&(m.endIcon=l?a:t),Io(()=>{l&&d?d():!l&&i&&i()},[l,d,i]),Bo(se,{children:[T(o,f(s({},m),{children:r})),T(wo,{id:"dropdown-menu",anchorEl:p,open:l,onClose:()=>{c(null)},children:typeof e=="function"?T(se,{children:e(()=>{c(null)})}):e})]})}var No=To;import Eo from"@mui/material/Link";import{jsx as Mo}from"react/jsx-runtime";function Ro(n){var a=n,{href:e,children:o}=a,r=P(a,["href","children"]);return Mo(Eo,f(s({component:"a",href:e,target:"_blank",rel:"noopener noreferrer"},r),{children:o}))}var Do=Ro;import Oo from"@mui/icons-material/CloudUpload";import Ao from"@mui/material/Button";import{styled as le}from"@mui/material/styles";import{useState as Wo}from"react";import{jsx as H,jsxs as Vo}from"react/jsx-runtime";var Fo={PDF:"application/pdf",PNG:"image/png",JPEG:"image/jpeg",JPG:"image/jpg",XLSX:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",DOCX:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",MP3:"audio/mp3",MP4:"video/mp4",WAV:"audio/wav"},zo=le("input")({clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,overflow:"hidden",position:"absolute",bottom:0,left:0,whiteSpace:"nowrap",width:1}),Uo=le("div")(({theme:e,$dragging:o})=>({border:"2px dashed",borderColor:o?e.palette.primary.main:"#ccc",backgroundColor:o?e.palette.action.hover:"transparent",borderRadius:8,padding:"1.5rem",textAlign:"center",transition:"border-color 0.2s",cursor:"pointer"}));function Ho(d){var i=d,{onFileInput:e,label:o="Upload files",multiple:r,accept:n,useDropzone:a}=i,t=P(i,["onFileInput","label","multiple","accept","useDropzone"]);var m;let[p,c]=Wo(!1),l=Vo(Ao,f(s({variant:"contained",component:"label","aria-label":"File upload button",onKeyDown:x=>{var u;(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),(u=document.getElementById("file-input"))==null||u.click())}},t),{startIcon:(m=t.startIcon)!=null?m:H(Oo,{}),children:[o,H(zo,{id:"file-input",type:"file",onChange:x=>{var y;let u=x.target;e(Array.from((y=u.files)!=null?y:[])),u.value=""},multiple:r,accept:n==null?void 0:n.join(","),disabled:t.disabled})]}));return a?H(Uo,{$dragging:p,onDragOver:x=>{x.preventDefault(),!t.disabled&&c(!0)},onDragLeave:x=>{x.preventDefault(),c(!1)},onDrop:x=>{var y;if(x.preventDefault(),c(!1),t.disabled)return;let u=Array.from((y=x.dataTransfer.files)!=null?y:[]);e(u)},children:l}):l}var V=Ho;import Xo from"@mui/icons-material/Delete";import $o from"@mui/material/Box";import _o from"@mui/material/IconButton";import Go from"@mui/material/List";import Jo from"@mui/material/ListItem";import Ko from"@mui/material/ListItemText";import{jsx as w,jsxs as Qo}from"react/jsx-runtime";function Yo(n){var a=n,{files:e,setFiles:o}=a,r=P(a,["files","setFiles"]);function t(i){o(p=>[...p,...i])}let d=f(s({},r),{onFileInput:t});return(d==null?void 0:d.multiple)===void 0&&(d.multiple=!0),Qo($o,{children:[w(V,s({},d)),w(Go,{children:e.map(i=>w(Jo,{secondaryAction:w(_o,{"aria-label":"Delete",edge:"end",onClick:()=>{o(p=>p.filter(c=>c!==i))},children:w(Xo,{})}),children:w(Ko,{primary:i.name})},i.name))})]})}var qo=Yo;import Zo from"@mui/material/Box";import jo from"@mui/material/Popover";import{useId as er,useState as or}from"react";import{jsx as me,jsxs as nr}from"react/jsx-runtime";function rr({icon:e,onOpen:o,onClose:r,iconProps:n,children:a}){let[t,d]=or(null),i=!!t,p=er();function c(m){d(m.currentTarget),o&&o()}function l(){d(null),r&&r()}return nr(Zo,{children:[me(e,s({"aria-owns":i?p:void 0,"aria-haspopup":"true",onMouseEnter:c,onMouseLeave:l},n)),me(jo,{id:p,sx:{pointerEvents:"none"},open:i,anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:l,disableRestoreFocus:!0,children:a})]})}var tr=rr;import ar from"@mui/material/Link";import{Link as ir}from"react-router-dom";import{jsx as sr}from"react/jsx-runtime";function pr(n){var a=n,{to:e,children:o}=a,r=P(a,["to","children"]);return sr(ar,f(s({component:ir,to:e},r),{children:o}))}var X=pr;import dr from"@mui/material/ListItemButton";import{jsx as cr}from"react/jsx-runtime";function lr(r){var n=r,{children:e}=n,o=P(n,["children"]);return cr(dr,f(s({component:X},o),{children:e}))}var mr=lr;import ur from"@mui/material/CircularProgress";import{jsx as $,jsxs as Pr}from"react/jsx-runtime";function fr(d){var i=d,{children:e,undefinedComponent:o,nullComponent:r,nullableComponent:n,loadingComponent:a=$(ur,{})}=i,t=P(i,["children","undefinedComponent","nullComponent","nullableComponent","loadingComponent"]);return Pr(W,f(s({loadingComponent:a},t),{children:[$(z,{undefinedComponent:o,nullComponent:r,nullableComponent:n}),$(F,{children:e})]}))}var xr=fr;import vr from"@mui/material/BottomNavigation";import gr from"@mui/material/BottomNavigationAction";import hr from"@mui/material/Box";import yr from"@mui/material/Paper";import{useState as Lr}from"react";import{Link as br}from"react-router-dom";import{Fragment as Ir,jsx as D,jsxs as Cr}from"react/jsx-runtime";function Sr({children:e,navItems:o}){let[r,n]=Lr("");return Cr(Ir,{children:[D(hr,{sx:{paddingBottom:7},children:e}),D(yr,{sx:{position:"fixed",bottom:0,left:0,right:0},children:D(vr,{showLabels:!0,value:r,onChange:(a,t)=>{n(t)},children:o.map(a=>D(gr,f(s({},a),{component:br}),a.value))})})]})}var wr=Sr;import{truncate as ce}from"@alextheman/utility";import kr from"@mui/icons-material/ChevronLeft";import Tr from"@mui/icons-material/ChevronRight";import Nr from"@mui/icons-material/Menu";import Br from"@mui/material/AppBar";import ue from"@mui/material/Box";import Er from"@mui/material/CssBaseline";import fe from"@mui/material/Divider";import Rr from"@mui/material/Drawer";import xe from"@mui/material/IconButton";import Dr from"@mui/material/List";import Mr from"@mui/material/ListItem";import Or from"@mui/material/ListItemButton";import Ar from"@mui/material/ListItemIcon";import Wr from"@mui/material/ListItemText";import{styled as G,useTheme as Fr}from"@mui/material/styles";import zr from"@mui/material/Toolbar";import _ from"@mui/material/Typography";import{Fragment as Ur,useState as Hr}from"react";import{Link as Vr,useLocation as Xr}from"react-router-dom";import{jsx as v,jsxs as b}from"react/jsx-runtime";var M=240;function Pe(e){return{width:M,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen}),overflowX:"hidden"}}function ve(e){return{transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),overflowX:"hidden",width:`calc(${e.spacing(7)} + 1px)`,[e.breakpoints.up("sm")]:{width:`calc(${e.spacing(8)} + 1px)`}}}var ge=G("div")(({theme:e})=>s({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:e.spacing(0,1)},e.mixins.toolbar)),$r=G(Br,{shouldForwardProp:e=>e!=="open"})(({theme:e})=>({zIndex:e.zIndex.drawer+1,transition:e.transitions.create(["width","margin"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),variants:[{props:({open:o})=>o,style:{marginLeft:M,width:`calc(100% - ${M}px)`,transition:e.transitions.create(["width","margin"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen})}}]})),_r=G(Rr,{shouldForwardProp:e=>e!=="open"})(({theme:e})=>({width:M,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",variants:[{props:({open:o})=>o,style:f(s({},Pe(e)),{"& .MuiDrawer-paper":Pe(e)})},{props:({open:o})=>!o,style:f(s({},ve(e)),{"& .MuiDrawer-paper":ve(e)})}]}));function Gr({title:e,navItems:o,children:r,headerElements:n}){let a=Fr(),[t,d]=Hr(!0),i=Xr();function p(){d(!0)}function c(){d(!1)}return b(ue,{sx:{display:"flex"},children:[v(Er,{}),v($r,{position:"fixed",open:t,children:b(zr,{children:[v(xe,{color:"inherit","aria-label":"open drawer",onClick:p,edge:"start",sx:[{marginRight:5},t&&{display:"none"}],children:v(Nr,{})}),v(_,{variant:"h6",noWrap:!0,component:"div",children:e}),n]})}),b(_r,{variant:"permanent",open:t,children:[v(ge,{children:v(xe,{onClick:c,children:a.direction==="rtl"?v(Tr,{}):v(kr,{})})}),v(fe,{}),o.map(l=>b(Ur,{children:[b(Dr,{children:[v(_,{variant:t?"h5":"h6",paddingLeft:t?2:1,children:t?l.category:ce(l.category,4)}),l.options.map(m=>v(Mr,{disablePadding:!0,sx:{display:"block"},children:b(Or,{sx:[{minHeight:48,px:2.5},t?{justifyContent:"initial"}:{justifyContent:"center"}],component:Vr,to:m.to,selected:i.pathname===m.to,children:[v(Ar,{sx:[{minWidth:0,justifyContent:"center"},t?{mr:3}:{mr:"auto"}],children:m.icon?m.icon:t?null:v(_,{children:ce(m.label,4)})}),v(Wr,{primary:m.label,sx:[t?{opacity:1}:{opacity:0}]})]})},m.to))]}),v(fe,{})]},l.category))]}),b(ue,{component:"main",sx:{flexGrow:1,p:3},children:[v(ge,{}),r]})]})}var Jr=Gr;import Kr from"@mui/material/Typography";import{Fragment as Qr,jsx as he}from"react/jsx-runtime";function Yr(n){var a=n,{text:e,sx:o}=a,r=P(a,["text","sx"]);return he(Qr,{children:e.split(`
2
+ `).map((t,d)=>he(Kr,f(s({sx:s({margin:1},o)},r),{children:t}),d))})}var qr=Yr;import J from"@mui/material/Box";import ye from"@mui/material/Typography";import{stripIndent as Zr}from"common-tags";import{LiveEditor as jr,LiveError as et,LivePreview as ot,LiveProvider as rt}from"react-live";import{jsx as L,jsxs as Le}from"react/jsx-runtime";function tt({code:e,scope:o,previewStyles:r,noInline:n,enableTypeScript:a,language:t}){let{mode:d}=k(),i={backgroundColor:d==="dark"?"black":"white",border:.3,borderRadius:1,padding:2,borderColor:"darkgray"},p=r?s(s({},i),r):s({},i);return L(J,{sx:{borderRadius:1,border:.5,padding:2},children:Le(rt,{code:Zr(e),scope:o,noInline:n,enableTypeScript:a,language:t,children:[L(ye,{variant:"h5",children:"Code"}),L(J,{sx:{border:.3,borderRadius:.3,borderColor:"darkgray"},children:L(jr,{})}),L("br",{}),L(ye,{variant:"h5",children:"Result"}),Le(J,{sx:p,children:[L(ot,{}),L(et,{})]})]})})}var nt=tt;import{fillArray as at}from"@alextheman/utility";import it from"@mui/material/Skeleton";import pt from"@mui/material/TableCell";import st from"@mui/material/TableRow";import{jsx as K}from"react/jsx-runtime";function dt({columns:e}){return K(st,{children:at(o=>K(pt,{children:K(it,{})},o),e)})}var lt=dt;import mt from"@mui/material/Button";import{useFormContext as ct}from"react-hook-form";import{jsx as xt}from"react/jsx-runtime";function ut(n){var a=n,{disableClean:e,label:o}=a,r=P(a,["disableClean","label"]);let{formState:{disabled:t,isDirty:d,isSubmitting:i}}=ct();return xt(mt,f(s({color:"primary",disabled:r.disabled||e&&!d||t,loading:i,type:"submit",variant:"contained"},r),{children:o}))}var ft=ut;import be from"@mui/material/Box";import{styled as Pt}from"@mui/material/styles";import vt from"@mui/material/Switch";import{jsx as N}from"react/jsx-runtime";var gt=Pt(vt)(()=>({padding:8,"& .MuiSwitch-track":{borderRadius:11,"&::before, &::after":{content:'""',position:"absolute",top:"50%",transform:"translateY(-50%)",fontSize:16,width:28,height:28}}}));function ht(t){var d=t,{checkedIcon:e,checkedIconStyles:o,uncheckedIcon:r,uncheckedIconStyles:n}=d,a=P(d,["checkedIcon","checkedIconStyles","uncheckedIcon","uncheckedIconStyles"]);let i={borderRadius:"50%",borderColor:"white",backgroundColor:"white",display:"flex",alignItems:"center",justifyContent:"center",padding:.25},p={color:"black",maxWidth:16.5,maxHeight:16.5};return N(gt,s({checkedIcon:N(be,{sx:i,children:N(e,{style:s(s({},p),o)})}),icon:N(be,{sx:i,children:N(r,{style:s(s({},p),n)})})},a))}var yt=ht;import{useCallback as Se,useEffect as Lt,useState as bt}from"react";function St(e){let[o,r]=bt(()=>{let t=window.location.hash.replace("#","");return e&&t===""?e:t}),n=Se(()=>{let t=window.location.hash.replace("#","");r(e&&t===""?e:t)},[r,e]);Lt(()=>(window.addEventListener("hashchange",n),()=>{window.removeEventListener("hashchange",n)}),[n]);let a=Se(t=>{let d=typeof t=="function"?t(o):t;d!==o&&(window.location.hash=d)},[o]);return[o,a]}var wt=St;export{Me as CollapsableItem,Lo as DarkModeToggle,No as DropdownMenu,Do as ExternalLink,V as FileInput,qo as FileInputList,Fo as FileType,tr as IconWithPopover,X as InternalLink,mr as ListItemInternalLink,xr as Loader,F as LoaderData,z as LoaderError,W as LoaderProvider,Ze as ModeProvider,wr as NavigationBottom,Jr as NavigationDrawer,qr as PopoverText,nt as ReactPlayground,no as ScreenSizeProvider,lt as SkeletonRow,fo as SnackbarProvider,ft as SubmitButton,yt as SwitchWithIcons,wt as useHash,I as useLoader,k as useMode,ro as useScreenSize,co as useSnackbar};
3
3
  //# sourceMappingURL=index.js.map