@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.
- package/AlertDialog/index.js +8 -30
- package/Autocomplete/index.js +10 -32
- package/Autocomplete/useInteractions.js +3 -3
- package/AutocompleteWithFilter/index.js +12 -35
- package/BasicModal/Content.js +5 -16
- package/BasicModal/index.js +9 -31
- package/BreadCrumbs/index.js +8 -19
- package/CheckBox/CheckBox.js +4 -26
- package/CheckBox/CheckBoxGroup.js +2 -24
- package/Copyright/index.js +3 -14
- package/DataTable/TableBody.js +2 -24
- package/DataTable/TableBodyRow.js +41 -52
- package/DataTable/TableFooter.js +30 -41
- package/DataTable/TableHeader.js +36 -47
- package/DataTable/index.js +17 -28
- package/DataTable/useTable.js +46 -54
- package/DateInput/FullDateInput/index.js +20 -42
- package/DateInput/FullDateInput/useInteractions.js +10 -10
- package/DateInput/MonthDayInput/index.js +14 -36
- package/DateInput/MonthDayInput/useInteractions.js +9 -9
- package/DateInput/MonthYearInput/index.js +14 -36
- package/DateInput/MonthYearInput/useInteractions.js +9 -9
- package/DigitInput/index.js +6 -28
- package/DigitInput/useInteractions.js +9 -9
- package/DynamicHeaderBar/HeaderBar.js +6 -17
- package/DynamicHeaderBar/HeaderButtons.js +13 -24
- package/DynamicHeaderBar/HeaderLine.js +2 -2
- package/DynamicHeaderBar/index.js +15 -26
- package/FeinInput/index.js +16 -38
- package/FeinInput/useInteractions.js +9 -9
- package/FileUploader/index.js +11 -33
- package/FileUploader/useInteractions.js +29 -44
- package/FormRadioGroup/index.js +4 -29
- package/FormSelector/MultipleSelector.js +9 -32
- package/FormSelector/SimpleSelector.js +9 -32
- package/FormSelector/useInteractions.js +7 -7
- package/HelpCaption/index.js +6 -17
- package/HelpCaption/useInteractions.js +2 -2
- package/LoadingModal/Modal.js +4 -15
- package/LoadingModal/useLoadingModal.js +15 -33
- package/MenuButtonGroup/MenuItem.js +3 -14
- package/MenuButtonGroup/index.js +14 -82
- package/NumberInput/index.js +5 -27
- package/NumberInput/useInteractions.js +17 -17
- package/PasswordInput/ConfirmPassword.js +6 -28
- package/PasswordInput/Password.js +15 -37
- package/PhoneNumberInput/index.js +17 -39
- package/PhoneNumberInput/useInteractions.js +10 -10
- package/Sidebar/SidebarItem.js +6 -17
- package/Sidebar/SidebarItemsGroup.js +10 -21
- package/Sidebar/SidebarLink.js +5 -27
- package/Sidebar/index.js +6 -17
- package/SocialInput/index.js +18 -40
- package/SocialInput/useInteractions.js +14 -14
- package/TabGroup/index.js +14 -25
- package/TablePagination/Actions.js +4 -15
- package/TablePagination/index.js +3 -14
- package/TablePagination/useInteractions.js +9 -9
- package/TextInput/index.js +8 -30
- package/TextInput/useInteractions.js +4 -4
- package/ToastPrompt/Prompt.d.ts +3 -0
- package/ToastPrompt/Prompt.js +63 -0
- package/ToastPrompt/index.d.ts +2 -13
- package/ToastPrompt/index.js +10 -25
- package/ToastPrompt/types.d.ts +35 -0
- package/ToastPrompt/types.js +1 -0
- package/ToastPrompt/useInteractions.d.ts +14 -0
- package/ToastPrompt/useInteractions.js +27 -0
- package/VideoPlayerModal/index.js +5 -27
- package/package.json +1 -1
- package/useCustomTheme.js +11 -16
- package/utils/uuid.js +10 -11
- package/ToastPrompt/Logics.d.ts +0 -12
- package/ToastPrompt/Logics.js +0 -37
- package/ToastPrompt/Presentation.d.ts +0 -16
- package/ToastPrompt/Presentation.js +0 -82
package/ToastPrompt/index.d.ts
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
import {
|
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;
|
package/ToastPrompt/index.js
CHANGED
@@ -1,30 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
return (_jsx(ThemeProvider,
|
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
|
-
}
|
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
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
|
-
|
15
|
-
|
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 =
|
26
|
+
themeOptions.palette = {
|
27
|
+
...themeOptions.palette,
|
28
|
+
primary: { main: primaryColor }
|
29
|
+
};
|
38
30
|
}
|
39
31
|
if (!!secondaryColor) {
|
40
|
-
themeOptions.palette =
|
32
|
+
themeOptions.palette = {
|
33
|
+
...themeOptions.palette,
|
34
|
+
secondary: { main: secondaryColor }
|
35
|
+
};
|
41
36
|
}
|
42
37
|
}
|
43
|
-
|
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
|
28
|
-
|
29
|
-
this.chars.sort(
|
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 (
|
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
|
39
|
+
getRandomChars() {
|
41
40
|
this.rand = Date.now().toString(16).concat(this.getRandomUInt());
|
42
41
|
return this.rand;
|
43
42
|
},
|
44
|
-
generate
|
45
|
-
|
46
|
-
|
43
|
+
generate() {
|
44
|
+
let id = Date.now().toString();
|
45
|
+
const idLen = id.length;
|
47
46
|
this.getRandomChars();
|
48
|
-
for (
|
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();
|
package/ToastPrompt/Logics.d.ts
DELETED
@@ -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;
|
package/ToastPrompt/Logics.js
DELETED
@@ -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;
|