@symply.io/basic-components 1.3.11-alpha.1 → 1.3.11-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/AlertDialog/index.js +8 -30
  2. package/Autocomplete/index.js +10 -32
  3. package/Autocomplete/useInteractions.js +3 -3
  4. package/AutocompleteWithFilter/index.js +12 -35
  5. package/BasicModal/Content.js +5 -16
  6. package/BasicModal/index.js +9 -31
  7. package/BreadCrumbs/index.js +8 -19
  8. package/CheckBox/CheckBox.js +4 -26
  9. package/CheckBox/CheckBoxGroup.js +2 -24
  10. package/Copyright/index.js +3 -14
  11. package/DataTable/TableBody.js +2 -24
  12. package/DataTable/TableBodyRow.js +41 -52
  13. package/DataTable/TableFooter.js +30 -41
  14. package/DataTable/TableHeader.js +36 -47
  15. package/DataTable/index.js +17 -28
  16. package/DataTable/useTable.js +46 -54
  17. package/DateInput/FullDateInput/index.js +20 -42
  18. package/DateInput/FullDateInput/useInteractions.js +10 -10
  19. package/DateInput/MonthDayInput/index.js +14 -36
  20. package/DateInput/MonthDayInput/useInteractions.js +9 -9
  21. package/DateInput/MonthYearInput/index.js +14 -36
  22. package/DateInput/MonthYearInput/useInteractions.js +9 -9
  23. package/DigitInput/index.js +6 -28
  24. package/DigitInput/useInteractions.js +9 -9
  25. package/DynamicHeaderBar/HeaderBar.js +6 -17
  26. package/DynamicHeaderBar/HeaderButtons.js +13 -24
  27. package/DynamicHeaderBar/HeaderLine.js +2 -2
  28. package/DynamicHeaderBar/index.js +15 -26
  29. package/FeinInput/index.js +16 -38
  30. package/FeinInput/useInteractions.js +9 -9
  31. package/FileUploader/index.js +11 -33
  32. package/FileUploader/useInteractions.js +29 -44
  33. package/FormRadioGroup/index.js +4 -29
  34. package/FormSelector/MultipleSelector.js +9 -32
  35. package/FormSelector/SimpleSelector.js +9 -32
  36. package/FormSelector/useInteractions.js +7 -7
  37. package/HelpCaption/index.js +6 -17
  38. package/HelpCaption/useInteractions.js +2 -2
  39. package/LoadingModal/Modal.js +4 -15
  40. package/LoadingModal/useLoadingModal.js +15 -33
  41. package/MenuButtonGroup/MenuItem.js +3 -14
  42. package/MenuButtonGroup/index.js +14 -82
  43. package/NumberInput/index.js +5 -27
  44. package/NumberInput/useInteractions.js +17 -17
  45. package/PasswordInput/ConfirmPassword.js +6 -28
  46. package/PasswordInput/Password.js +15 -37
  47. package/PhoneNumberInput/index.js +17 -39
  48. package/PhoneNumberInput/useInteractions.js +10 -10
  49. package/Sidebar/SidebarItem.js +6 -17
  50. package/Sidebar/SidebarItemsGroup.js +10 -21
  51. package/Sidebar/SidebarLink.js +5 -27
  52. package/Sidebar/index.js +6 -17
  53. package/SocialInput/index.js +18 -40
  54. package/SocialInput/useInteractions.js +14 -14
  55. package/TabGroup/index.js +14 -25
  56. package/TablePagination/Actions.js +4 -15
  57. package/TablePagination/index.js +3 -14
  58. package/TablePagination/useInteractions.js +9 -9
  59. package/TextInput/index.js +8 -30
  60. package/TextInput/useInteractions.js +4 -4
  61. package/ToastPrompt/Prompt.d.ts +3 -0
  62. package/ToastPrompt/Prompt.js +63 -0
  63. package/ToastPrompt/index.d.ts +2 -13
  64. package/ToastPrompt/index.js +10 -25
  65. package/ToastPrompt/types.d.ts +35 -0
  66. package/ToastPrompt/types.js +1 -0
  67. package/ToastPrompt/useInteractions.d.ts +14 -0
  68. package/ToastPrompt/useInteractions.js +27 -0
  69. package/VideoPlayerModal/index.js +5 -27
  70. package/package.json +1 -1
  71. package/useCustomTheme.js +11 -16
  72. package/utils/uuid.js +10 -11
  73. package/ToastPrompt/Logics.d.ts +0 -12
  74. package/ToastPrompt/Logics.js +0 -37
  75. package/ToastPrompt/Presentation.d.ts +0 -16
  76. package/ToastPrompt/Presentation.js +0 -82
@@ -1,14 +1,3 @@
1
- import { ReactNode } from "react";
2
- export interface PromptProviderProps {
3
- children: ReactNode;
4
- }
5
- export interface ShowPromptProps {
6
- type: "success" | "warning" | "error" | "info";
7
- message: string | 400;
8
- timeout?: number;
9
- }
1
+ import type { PromptProviderProps, PromptContextProps } from "./types";
10
2
  export declare function PromptProvider(props: PromptProviderProps): JSX.Element;
11
- export declare function usePrompt(): {
12
- showPrompt: (props: ShowPromptProps) => void;
13
- };
14
- export default usePrompt;
3
+ export declare function usePrompt(): PromptContextProps;
@@ -1,30 +1,15 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { createContext, useRef, useContext } from "react";
14
- import Logics from "./Logics";
15
- import ToastPrompt from "./Presentation";
16
- var PromptContext = createContext({});
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useContext, cloneElement } from "react";
3
+ import { default as Prompt } from "./Prompt";
4
+ import useInteractions from "./useInteractions";
5
+ const PromptContext = createContext({
6
+ showPrompt: () => { }
7
+ });
17
8
  export function PromptProvider(props) {
18
- var children = props.children;
19
- var toastRef = useRef(null);
20
- function showPrompt(props) {
21
- var type = props.type, message = props.message, timeout = props.timeout;
22
- var _a = ((toastRef === null || toastRef === void 0 ? void 0 : toastRef.current) || {}).show, show = _a === void 0 ? function () { } : _a;
23
- show(type, message, timeout);
24
- }
25
- return (_jsx(PromptContext.Provider, __assign({ value: { showPrompt: showPrompt } }, { children: _jsxs(_Fragment, { children: [children, _jsx(Logics, __assign({ ref: toastRef }, { children: _jsx(ToastPrompt, {}) }))] }) })));
9
+ const { children } = props;
10
+ const { promptArgs, onShow, onHide } = useInteractions();
11
+ return (_jsxs(PromptContext.Provider, { value: { showPrompt: onShow }, children: [children, cloneElement(_jsx(Prompt, { ...promptArgs, onClose: onHide }))] }));
26
12
  }
27
13
  export function usePrompt() {
28
14
  return useContext(PromptContext);
29
15
  }
30
- export default usePrompt;
@@ -0,0 +1,35 @@
1
+ import type { CSSProperties, ReactNode } from "react";
2
+ import type { SnackbarCloseReason } from "@mui/material/Snackbar";
3
+ import type { SvgIconComponent } from "@mui/icons-material";
4
+ export declare type Variant = "success" | "warning" | "info" | "error";
5
+ export declare type PromptStyles = Record<Variant, {
6
+ backgroundColor: CSSProperties["color"];
7
+ }>;
8
+ export declare type PromptIcons = Record<Variant, SvgIconComponent>;
9
+ declare type PromptArgs = {
10
+ message: string | 400;
11
+ variant: Variant;
12
+ timeout: number;
13
+ };
14
+ export interface InterfaceStates {
15
+ promptArgs: PromptArgs & Record<"open", boolean>;
16
+ onHide: (_: any, reason: SnackbarCloseReason) => void;
17
+ onShow: (args: PromptArgs) => void;
18
+ }
19
+ export interface PromptProps extends PromptArgs {
20
+ open: boolean;
21
+ icon?: SvgIconComponent;
22
+ onClose: InterfaceStates["onHide"];
23
+ }
24
+ export interface PromptStates {
25
+ styles: PromptStyles;
26
+ icons: PromptIcons;
27
+ icon: SvgIconComponent;
28
+ }
29
+ export interface PromptProviderProps {
30
+ children: ReactNode;
31
+ }
32
+ export interface PromptContextProps {
33
+ showPrompt: InterfaceStates["onShow"];
34
+ }
35
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ declare function useInteractions(): {
2
+ promptArgs: {
3
+ message: string | 400;
4
+ variant: import("./types").Variant;
5
+ timeout: number;
6
+ } & Record<"open", boolean>;
7
+ onShow: (args: {
8
+ message: string | 400;
9
+ variant: import("./types").Variant;
10
+ timeout: number;
11
+ }) => void;
12
+ onHide: (_: any, reason: import("@mui/material").SnackbarCloseReason) => void;
13
+ };
14
+ export default useInteractions;
@@ -0,0 +1,27 @@
1
+ import { useState, useCallback } from "react";
2
+ function useInteractions() {
3
+ const ERROR_MESSAGE = "Internal Server Error";
4
+ const [promptArgs, setPromptArgs] = useState({
5
+ open: false,
6
+ message: "Saved",
7
+ variant: "success",
8
+ timeout: 3500
9
+ });
10
+ const onHide = useCallback((_, reason) => {
11
+ if (reason === "clickaway") {
12
+ return;
13
+ }
14
+ setPromptArgs(args => ({ ...args, open: false }));
15
+ }, []);
16
+ const onShow = useCallback(args => {
17
+ const { message = "Unknown message", variant = "info", timeout = 3500 } = args;
18
+ setPromptArgs({
19
+ open: true,
20
+ message: message === 400 ? ERROR_MESSAGE : message,
21
+ variant,
22
+ timeout
23
+ });
24
+ }, []);
25
+ return { promptArgs, onShow, onHide };
26
+ }
27
+ export default useInteractions;
@@ -1,25 +1,3 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
2
  import ReactPlayer from "react-player";
25
3
  import Grid from "@mui/material/Grid";
@@ -32,12 +10,12 @@ import useMediaQuery from "@mui/material/useMediaQuery";
32
10
  import ThemeProvider from "@mui/material/styles/ThemeProvider";
33
11
  import useCustomTheme from "../useCustomTheme";
34
12
  function VideoPlayerModal(props) {
35
- var url = props.url, _a = props.pip, pip = _a === void 0 ? false : _a, _b = props.open, open = _b === void 0 ? false : _b, title = props.title, onClose = props.onClose, _c = props.extraButtons, extraButtons = _c === void 0 ? [] : _c, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, playerProps = __rest(props, ["url", "pip", "open", "title", "onClose", "extraButtons", "primaryColor", "secondaryColor"]);
36
- var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
37
- var fullScreen = useMediaQuery(theme.breakpoints.down("sm"));
38
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsxs(Dialog, __assign({ open: open, fullScreen: fullScreen, onClose: onClose, fullWidth: true, maxWidth: "lg", "aria-labelledby": "react-video-dialog" }, { children: [title && _jsx(DialogTitle, { children: title }), _jsx(DialogContent, { children: _jsx(ReactPlayer, __assign({ controls: true, url: url, style: { minHeight: "480px" }, width: "100%", config: {
13
+ const { url, pip = false, open = false, title, onClose, extraButtons = [], primaryColor, secondaryColor, ...playerProps } = props;
14
+ const theme = useCustomTheme({ primaryColor, secondaryColor });
15
+ const fullScreen = useMediaQuery(theme.breakpoints.down("sm"));
16
+ return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Dialog, { open: open, fullScreen: fullScreen, onClose: onClose, fullWidth: true, maxWidth: "lg", "aria-labelledby": "react-video-dialog", children: [title && _jsx(DialogTitle, { children: title }), _jsx(DialogContent, { children: _jsx(ReactPlayer, { controls: true, url: url, style: { minHeight: "480px" }, width: "100%", config: {
39
17
  file: { attributes: { disablePictureInPicture: !pip } }
40
- } }, playerProps)) }), _jsx(DialogActions, { children: _jsxs(Grid, __assign({ container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", spacing: 1 }, { children: [extraButtons.map(function (buttonProps, index) { return (_jsx(Grid, __assign({ item: true, xs: 12, md: 3, lg: 2 }, { children: _jsx(Button, __assign({}, buttonProps)) }), "extraButton_".concat(index))); }), _jsx(Grid, __assign({ item: true, xs: 12, md: 2, lg: 1 }, { children: _jsx(Button, __assign({ variant: "outlined", fullWidth: true, color: "secondary", onClick: onClose }, { children: "Close" })) }))] })) })] })) })));
18
+ }, ...playerProps }) }), _jsx(DialogActions, { children: _jsxs(Grid, { container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", spacing: 1, children: [extraButtons.map((buttonProps, index) => (_jsx(Grid, { item: true, xs: 12, md: 3, lg: 2, children: _jsx(Button, { ...buttonProps }) }, `extraButton_${index}`))), _jsx(Grid, { item: true, xs: 12, md: 2, lg: 1, children: _jsx(Button, { variant: "outlined", fullWidth: true, color: "secondary", onClick: onClose, children: "Close" }) })] }) })] }) }));
41
19
  }
42
20
  export default VideoPlayerModal;
43
21
  export * from "./types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.3.11-alpha.1",
3
+ "version": "1.3.11-alpha.10",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",
package/useCustomTheme.js CHANGED
@@ -1,18 +1,7 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import { createTheme } from "@mui/material/styles";
13
2
  function useCustomTheme(props) {
14
- var _a = props || {}, primaryColor = _a.primaryColor, secondaryColor = _a.secondaryColor;
15
- var themeOptions = {
3
+ const { primaryColor, secondaryColor } = props || {};
4
+ const themeOptions = {
16
5
  components: {
17
6
  MuiButton: {
18
7
  styleOverrides: {
@@ -34,13 +23,19 @@ function useCustomTheme(props) {
34
23
  };
35
24
  if (!!primaryColor || !!secondaryColor) {
36
25
  if (!!primaryColor) {
37
- themeOptions.palette = __assign(__assign({}, themeOptions.palette), { primary: { main: primaryColor } });
26
+ themeOptions.palette = {
27
+ ...themeOptions.palette,
28
+ primary: { main: primaryColor }
29
+ };
38
30
  }
39
31
  if (!!secondaryColor) {
40
- themeOptions.palette = __assign(__assign({}, themeOptions.palette), { secondary: { main: secondaryColor } });
32
+ themeOptions.palette = {
33
+ ...themeOptions.palette,
34
+ secondary: { main: secondaryColor }
35
+ };
41
36
  }
42
37
  }
43
- var theme = createTheme(themeOptions);
38
+ const theme = createTheme(themeOptions);
44
39
  return theme;
45
40
  }
46
41
  export default useCustomTheme;
package/utils/uuid.js CHANGED
@@ -1,5 +1,4 @@
1
- function generateUUID(length) {
2
- if (length === void 0) { length = 32; }
1
+ function generateUUID(length = 32) {
3
2
  if (length < 16)
4
3
  throw new Error("Length should be equal or greater than 16");
5
4
  function UUID() {
@@ -24,28 +23,28 @@ function generateUUID(length) {
24
23
  this.rand = "";
25
24
  }
26
25
  UUID.prototype = {
27
- getRandomUInt: function () {
28
- var s = "";
29
- this.chars.sort(function () {
26
+ getRandomUInt() {
27
+ let s = "";
28
+ this.chars.sort(() => {
30
29
  return Date.now() % (Math.random() * length * 23) >
31
30
  Math.random() * 7 * length
32
31
  ? -1
33
32
  : 1;
34
33
  });
35
- for (var i = 0; i < this.chars.length; i += 1) {
34
+ for (let i = 0; i < this.chars.length; i += 1) {
36
35
  s = s.concat(this.chars[i]);
37
36
  }
38
37
  return s;
39
38
  },
40
- getRandomChars: function () {
39
+ getRandomChars() {
41
40
  this.rand = Date.now().toString(16).concat(this.getRandomUInt());
42
41
  return this.rand;
43
42
  },
44
- generate: function () {
45
- var id = Date.now().toString();
46
- var idLen = id.length;
43
+ generate() {
44
+ let id = Date.now().toString();
45
+ const idLen = id.length;
47
46
  this.getRandomChars();
48
- for (var i = 0; i < length - idLen; i += 1) {
47
+ for (let i = 0; i < length - idLen; i += 1) {
49
48
  id = id.concat(this.rand.charAt(Math.floor(Math.random() * this.rand.length)));
50
49
  }
51
50
  return id.toString();
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- interface LogicsProps {
3
- children: React.ReactNode | undefined;
4
- }
5
- export interface PromptPropsType {
6
- open: boolean;
7
- message: string | number;
8
- variant: "success" | "warning" | "error" | "info" | undefined;
9
- timeout: number;
10
- }
11
- declare const Logics: import("react").ForwardRefExoticComponent<LogicsProps & import("react").RefAttributes<unknown>>;
12
- export default Logics;
@@ -1,37 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { useState, cloneElement, forwardRef, useImperativeHandle } from "react";
13
- var ERROR_MESSAGE = "Internal Server Error";
14
- var Logics = forwardRef(function (props, ref) {
15
- var children = props.children;
16
- var _a = useState({
17
- open: false,
18
- message: "Saved",
19
- variant: "success",
20
- timeout: 3500
21
- }), promptProps = _a[0], setPromptProps = _a[1];
22
- function hide(_, reason) {
23
- if (reason === "clickaway") {
24
- return;
25
- }
26
- setPromptProps(__assign(__assign({}, promptProps), { open: false }));
27
- }
28
- function show(type, message, timeout) {
29
- if (timeout === void 0) { timeout = 3500; }
30
- setPromptProps(__assign(__assign({}, promptProps), { open: true, variant: type, message: message === 400 ? ERROR_MESSAGE : message, timeout: timeout }));
31
- }
32
- useImperativeHandle(ref, function () { return ({
33
- show: show
34
- }); });
35
- return cloneElement(children, __assign(__assign({}, promptProps), { onClose: hide }));
36
- });
37
- export default Logics;
@@ -1,16 +0,0 @@
1
- import { ElementType } from "react";
2
- import { SlideProps } from "@mui/material/Slide";
3
- import { SnackbarOrigin } from "@mui/material/Snackbar";
4
- interface ToastPromptProps {
5
- open?: boolean;
6
- vertical?: SnackbarOrigin["vertical"];
7
- horizontal?: SnackbarOrigin["horizontal"];
8
- timeout?: number;
9
- onClose?: () => void;
10
- transitionDirection?: SlideProps["direction"];
11
- message?: string;
12
- icon?: ElementType;
13
- variant?: "success" | "warning" | "info" | "error";
14
- }
15
- declare const ToastPrompt: (props: ToastPromptProps) => JSX.Element;
16
- export default ToastPrompt;
@@ -1,82 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
- import Typography from "@mui/material/Typography";
25
- import ThemeProvider from "@mui/material/styles/ThemeProvider";
26
- import Slide from "@mui/material/Slide";
27
- import SnackbarContent from "@mui/material/SnackbarContent";
28
- import Snackbar from "@mui/material/Snackbar";
29
- import InfoIcon from "@mui/icons-material/Info";
30
- import ErrorIcon from "@mui/icons-material/Error";
31
- import WarningIcon from "@mui/icons-material/Warning";
32
- import SuccessIcon from "@mui/icons-material/CheckCircle";
33
- import { green, amber, red, blue } from "@mui/material/colors";
34
- import useCustomTheme from "../useCustomTheme";
35
- var ToastPrompt = function (props) {
36
- var _a;
37
- var _b = props.open, open = _b === void 0 ? false : _b, _c = props.vertical, vertical = _c === void 0 ? "bottom" : _c, _d = props.horizontal, horizontal = _d === void 0 ? "left" : _d, _e = props.timeout, timeout = _e === void 0 ? 3000 : _e, onClose = props.onClose, _f = props.transitionDirection, transitionDirection = _f === void 0 ? "up" : _f, _g = props.message, message = _g === void 0 ? "Unknown message" : _g, _h = props.icon, icon = _h === void 0 ? _jsx(_Fragment, {}) : _h, _j = props.variant, variant = _j === void 0 ? "info" : _j, other = __rest(props, ["open", "vertical", "horizontal", "timeout", "onClose", "transitionDirection", "message", "icon", "variant"]);
38
- var theme = useCustomTheme();
39
- var styles = {
40
- success: {
41
- backgroundColor: green[500]
42
- },
43
- error: {
44
- backgroundColor: red[400]
45
- },
46
- info: {
47
- backgroundColor: blue[600]
48
- },
49
- warning: {
50
- backgroundColor: amber["A700"]
51
- }
52
- };
53
- var Transition = function (args) {
54
- return _jsx(Slide, __assign({}, args, { direction: transitionDirection }));
55
- };
56
- var VariantIcon = {
57
- success: SuccessIcon,
58
- warning: WarningIcon,
59
- error: ErrorIcon,
60
- info: InfoIcon
61
- };
62
- var Icon = VariantIcon[variant];
63
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Snackbar, __assign({ anchorOrigin: { vertical: vertical, horizontal: horizontal }, open: open, onClose: onClose, autoHideDuration: timeout, TransitionComponent: Transition, sx: {
64
- zIndex: 99999,
65
- marginTop: "3vh"
66
- } }, { children: _jsx(SnackbarContent, __assign({ sx: __assign(__assign({}, styles[variant]), { root: (_a = {},
67
- _a[theme.breakpoints.down("sm")] = {
68
- maxWidth: "320px",
69
- borderRadius: "4px"
70
- },
71
- _a) }), "aria-describedby": "Toast", message: _jsxs(Typography, __assign({ id: "Toast", component: "span", sx: {
72
- fontSize: 14,
73
- fontWeight: 700,
74
- display: "flex",
75
- alignItems: "center"
76
- } }, { children: [variant ? (_jsx(Icon, { sx: {
77
- fontSize: 20,
78
- opacity: 0.9,
79
- marginRight: theme.spacing(1)
80
- } })) : (_jsx(_Fragment, { children: icon })), message] })) }, other)) }), "".concat(Date.now() * Math.round(Math.random()))) })));
81
- };
82
- export default ToastPrompt;