@symply.io/basic-components 1.3.11-alpha.8 → 1.4.0-beta.1
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 +30 -8
- package/Autocomplete/index.js +32 -10
- package/Autocomplete/useInteractions.js +3 -3
- package/AutocompleteWithFilter/index.js +35 -12
- package/BasicModal/Content.js +16 -5
- package/BasicModal/index.js +31 -9
- package/BreadCrumbs/index.js +19 -8
- package/CheckBox/CheckBox.js +26 -4
- package/CheckBox/CheckBoxGroup.js +24 -2
- package/Copyright/index.js +14 -3
- package/DataTable/TableBody.js +24 -2
- package/DataTable/TableBodyRow.js +52 -41
- package/DataTable/TableFooter.js +41 -30
- package/DataTable/TableHeader.js +47 -36
- package/DataTable/index.js +28 -17
- package/DataTable/useTable.js +54 -46
- package/DateInput/FullDateInput/index.js +42 -20
- package/DateInput/FullDateInput/useInteractions.js +10 -10
- package/DateInput/MonthDayInput/index.js +36 -14
- package/DateInput/MonthDayInput/useInteractions.js +9 -9
- package/DateInput/MonthYearInput/index.js +36 -14
- package/DateInput/MonthYearInput/useInteractions.js +9 -9
- package/DigitInput/index.js +28 -6
- package/DigitInput/useInteractions.js +9 -9
- package/DynamicHeaderBar/HeaderBar.js +17 -6
- package/DynamicHeaderBar/HeaderButtons.js +24 -13
- package/DynamicHeaderBar/HeaderLine.js +2 -2
- package/DynamicHeaderBar/index.js +26 -15
- package/FeinInput/index.js +38 -16
- package/FeinInput/useInteractions.js +9 -9
- package/FileUploader/index.js +33 -11
- package/FileUploader/useInteractions.js +44 -29
- package/FormRadioGroup/index.js +29 -4
- package/FormSelector/MultipleSelector.js +32 -9
- package/FormSelector/SimpleSelector.js +32 -9
- package/FormSelector/useInteractions.js +7 -7
- package/HelpCaption/index.js +17 -6
- package/HelpCaption/useInteractions.js +2 -2
- package/LoadingModal/Modal.js +15 -4
- package/LoadingModal/useLoadingModal.js +33 -15
- package/MenuButtonGroup/MenuItem.js +14 -3
- package/MenuButtonGroup/index.js +82 -14
- package/NumberInput/index.js +27 -5
- package/NumberInput/useInteractions.js +17 -17
- package/PasswordInput/ConfirmPassword.js +28 -6
- package/PasswordInput/Password.js +37 -15
- package/PhoneNumberInput/index.js +39 -17
- package/PhoneNumberInput/useInteractions.js +10 -10
- package/Sidebar/SidebarItem.js +17 -6
- package/Sidebar/SidebarItemsGroup.js +21 -10
- package/Sidebar/SidebarLink.js +27 -5
- package/Sidebar/index.js +17 -6
- package/SocialInput/index.js +40 -18
- package/SocialInput/useInteractions.js +14 -14
- package/TabGroup/index.js +25 -14
- package/TablePagination/Actions.js +15 -4
- package/TablePagination/index.js +14 -3
- package/TablePagination/useInteractions.js +9 -9
- package/TextInput/index.js +30 -8
- package/TextInput/useInteractions.js +4 -4
- package/ToastPrompt/Prompt.d.ts +2 -1
- package/ToastPrompt/Prompt.js +22 -57
- package/ToastPrompt/index.js +18 -7
- package/ToastPrompt/types.d.ts +2 -8
- package/ToastPrompt/useInteractions.d.ts +2 -1
- package/ToastPrompt/useInteractions.js +21 -10
- package/VideoPlayerModal/index.js +27 -5
- package/package.json +1 -1
- package/useCustomTheme.js +16 -11
- package/utils/uuid.js +11 -10
package/ToastPrompt/Prompt.js
CHANGED
@@ -1,62 +1,27 @@
|
|
1
|
-
|
2
|
-
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
+
import Alert from "@mui/material/Alert";
|
3
14
|
import Slide from "@mui/material/Slide";
|
15
|
+
import AlertTitle from "@mui/material/AlertTitle";
|
4
16
|
import Snackbar from "@mui/material/Snackbar";
|
5
|
-
import Typography from "@mui/material/Typography";
|
6
|
-
import SnackbarContent from "@mui/material/SnackbarContent";
|
7
17
|
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
8
|
-
import InfoIcon from "@mui/icons-material/Info";
|
9
|
-
import ErrorIcon from "@mui/icons-material/Error";
|
10
|
-
import WarningIcon from "@mui/icons-material/Warning";
|
11
|
-
import SuccessIcon from "@mui/icons-material/CheckCircle";
|
12
|
-
import { green, amber, red, blue } from "@mui/material/colors";
|
13
18
|
import useCustomTheme from "../useCustomTheme";
|
14
|
-
|
15
|
-
return _jsx(Slide, {
|
16
|
-
}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
success: {
|
22
|
-
backgroundColor: green[500]
|
23
|
-
},
|
24
|
-
error: {
|
25
|
-
backgroundColor: red[400]
|
26
|
-
},
|
27
|
-
info: {
|
28
|
-
backgroundColor: blue[600]
|
29
|
-
},
|
30
|
-
warning: {
|
31
|
-
backgroundColor: amber["A700"]
|
32
|
-
}
|
33
|
-
}), []);
|
34
|
-
const VariantIcon = useMemo(() => ({
|
35
|
-
success: SuccessIcon,
|
36
|
-
warning: WarningIcon,
|
37
|
-
error: ErrorIcon,
|
38
|
-
info: InfoIcon
|
39
|
-
}), []);
|
40
|
-
const Icon = useMemo(() => VariantIcon[variant], []);
|
41
|
-
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(Snackbar, { anchorOrigin: { vertical: "bottom", horizontal: "left" }, open: open, onClose: onClose, autoHideDuration: timeout, TransitionComponent: Transition, sx: {
|
42
|
-
zIndex: 99999,
|
43
|
-
marginTop: "3vh"
|
44
|
-
}, children: _jsx(SnackbarContent, { sx: {
|
45
|
-
...styles[variant],
|
46
|
-
root: {
|
47
|
-
[theme.breakpoints.down("sm")]: {
|
48
|
-
maxWidth: "320px",
|
49
|
-
borderRadius: "4px"
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}, "aria-describedby": "Toast", message: _jsxs(Typography, { id: "Toast", component: "span", sx: {
|
53
|
-
fontSize: 14,
|
54
|
-
fontWeight: 700,
|
55
|
-
display: "flex",
|
56
|
-
alignItems: "center"
|
57
|
-
}, children: [!icon ? (_jsx(Icon, { sx: {
|
58
|
-
fontSize: 20,
|
59
|
-
opacity: 0.9,
|
60
|
-
marginRight: theme.spacing(1)
|
61
|
-
} })) : (_jsx(_Fragment, { children: icon })), message] }) }) }, `${Date.now() * Math.round(Math.random())}`) }));
|
19
|
+
function Transition(args) {
|
20
|
+
return _jsx(Slide, __assign({}, args, { direction: "up" }));
|
21
|
+
}
|
22
|
+
function Prompt(props) {
|
23
|
+
var open = props.open, variant = props.variant, message = props.message, timeout = props.timeout, onClose = props.onClose;
|
24
|
+
var theme = useCustomTheme();
|
25
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Snackbar, __assign({ anchorOrigin: { vertical: "bottom", horizontal: "left" }, open: open, onClose: onClose, autoHideDuration: timeout, TransitionComponent: Transition, sx: { zIndex: 99999 } }, { children: _jsxs(Alert, __assign({ variant: "filled", security: variant, sx: { width: "100%" }, onClose: onClose }, { children: [_jsx(AlertTitle, __assign({ sx: { textTransform: "capitalize" } }, { children: variant })), message] })) }), "".concat(Date.now() * Math.round(Math.random()))) })));
|
62
26
|
}
|
27
|
+
export default Prompt;
|
package/ToastPrompt/index.js
CHANGED
@@ -1,14 +1,25 @@
|
|
1
|
-
|
2
|
-
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
+
import { createContext, useContext, cloneElement } from "react";
|
3
14
|
import Prompt from "./Prompt";
|
4
15
|
import useInteractions from "./useInteractions";
|
5
|
-
|
6
|
-
showPrompt: ()
|
16
|
+
var PromptContext = createContext({
|
17
|
+
showPrompt: function () { }
|
7
18
|
});
|
8
19
|
export function PromptProvider(props) {
|
9
|
-
|
10
|
-
|
11
|
-
return (
|
20
|
+
var children = props.children;
|
21
|
+
var _a = useInteractions(), promptArgs = _a.promptArgs, onShow = _a.onShow, onHide = _a.onHide;
|
22
|
+
return (_jsxs(PromptContext.Provider, __assign({ value: { showPrompt: onShow } }, { children: [children, cloneElement(_jsx(Prompt, __assign({}, promptArgs, { onClose: onHide })))] })));
|
12
23
|
}
|
13
24
|
export function usePrompt() {
|
14
25
|
return useContext(PromptContext);
|
package/ToastPrompt/types.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { CSSProperties, ReactNode } from "react";
|
1
|
+
import type { CSSProperties, ReactNode, SyntheticEvent } from "react";
|
2
2
|
import type { SnackbarCloseReason } from "@mui/material/Snackbar";
|
3
3
|
import type { SvgIconComponent } from "@mui/icons-material";
|
4
4
|
export declare type Variant = "success" | "warning" | "info" | "error";
|
@@ -13,19 +13,13 @@ declare type PromptArgs = {
|
|
13
13
|
};
|
14
14
|
export interface InterfaceStates {
|
15
15
|
promptArgs: PromptArgs & Record<"open", boolean>;
|
16
|
-
onHide: (
|
16
|
+
onHide: (event: SyntheticEvent | Event, reason?: SnackbarCloseReason) => void;
|
17
17
|
onShow: (args: PromptArgs) => void;
|
18
18
|
}
|
19
19
|
export interface PromptProps extends PromptArgs {
|
20
20
|
open: boolean;
|
21
|
-
icon?: SvgIconComponent;
|
22
21
|
onClose: InterfaceStates["onHide"];
|
23
22
|
}
|
24
|
-
export interface PromptStates {
|
25
|
-
styles: PromptStyles;
|
26
|
-
icons: PromptIcons;
|
27
|
-
icon: SvgIconComponent;
|
28
|
-
}
|
29
23
|
export interface PromptProviderProps {
|
30
24
|
children: ReactNode;
|
31
25
|
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/// <reference types="react" />
|
1
2
|
declare function useInteractions(): {
|
2
3
|
promptArgs: {
|
3
4
|
message: string | 400;
|
@@ -9,6 +10,6 @@ declare function useInteractions(): {
|
|
9
10
|
variant: import("./types").Variant;
|
10
11
|
timeout: number;
|
11
12
|
}) => void;
|
12
|
-
onHide: (
|
13
|
+
onHide: (event: Event | import("react").SyntheticEvent<Element, Event>, reason?: import("@mui/material").SnackbarCloseReason | undefined) => void;
|
13
14
|
};
|
14
15
|
export default useInteractions;
|
@@ -1,27 +1,38 @@
|
|
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
|
+
};
|
1
12
|
import { useState, useCallback } from "react";
|
2
13
|
function useInteractions() {
|
3
|
-
|
4
|
-
|
14
|
+
var ERROR_MESSAGE = "Internal Server Error";
|
15
|
+
var _a = useState({
|
5
16
|
open: false,
|
6
17
|
message: "Saved",
|
7
18
|
variant: "success",
|
8
19
|
timeout: 3500
|
9
|
-
});
|
10
|
-
|
20
|
+
}), promptArgs = _a[0], setPromptArgs = _a[1];
|
21
|
+
var onHide = useCallback(function (_, reason) {
|
11
22
|
if (reason === "clickaway") {
|
12
23
|
return;
|
13
24
|
}
|
14
|
-
setPromptArgs(args
|
25
|
+
setPromptArgs(function (args) { return (__assign(__assign({}, args), { open: false })); });
|
15
26
|
}, []);
|
16
|
-
|
17
|
-
|
27
|
+
var onShow = useCallback(function (args) {
|
28
|
+
var _a = args.message, message = _a === void 0 ? "Unknown message" : _a, _b = args.variant, variant = _b === void 0 ? "info" : _b, _c = args.timeout, timeout = _c === void 0 ? 3500 : _c;
|
18
29
|
setPromptArgs({
|
19
30
|
open: true,
|
20
31
|
message: message === 400 ? ERROR_MESSAGE : message,
|
21
|
-
variant,
|
22
|
-
timeout
|
32
|
+
variant: variant,
|
33
|
+
timeout: timeout
|
23
34
|
});
|
24
35
|
}, []);
|
25
|
-
return { promptArgs, onShow, onHide };
|
36
|
+
return { promptArgs: promptArgs, onShow: onShow, onHide: onHide };
|
26
37
|
}
|
27
38
|
export default useInteractions;
|
@@ -1,3 +1,25 @@
|
|
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
|
+
};
|
1
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
24
|
import ReactPlayer from "react-player";
|
3
25
|
import Grid from "@mui/material/Grid";
|
@@ -10,12 +32,12 @@ import useMediaQuery from "@mui/material/useMediaQuery";
|
|
10
32
|
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
11
33
|
import useCustomTheme from "../useCustomTheme";
|
12
34
|
function VideoPlayerModal(props) {
|
13
|
-
|
14
|
-
|
15
|
-
|
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: {
|
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: {
|
17
39
|
file: { attributes: { disablePictureInPicture: !pip } }
|
18
|
-
},
|
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" })) }))] })) })] })) })));
|
19
41
|
}
|
20
42
|
export default VideoPlayerModal;
|
21
43
|
export * from "./types";
|
package/package.json
CHANGED
package/useCustomTheme.js
CHANGED
@@ -1,7 +1,18 @@
|
|
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
|
+
};
|
1
12
|
import { createTheme } from "@mui/material/styles";
|
2
13
|
function useCustomTheme(props) {
|
3
|
-
|
4
|
-
|
14
|
+
var _a = props || {}, primaryColor = _a.primaryColor, secondaryColor = _a.secondaryColor;
|
15
|
+
var themeOptions = {
|
5
16
|
components: {
|
6
17
|
MuiButton: {
|
7
18
|
styleOverrides: {
|
@@ -23,19 +34,13 @@ function useCustomTheme(props) {
|
|
23
34
|
};
|
24
35
|
if (!!primaryColor || !!secondaryColor) {
|
25
36
|
if (!!primaryColor) {
|
26
|
-
themeOptions.palette = {
|
27
|
-
...themeOptions.palette,
|
28
|
-
primary: { main: primaryColor }
|
29
|
-
};
|
37
|
+
themeOptions.palette = __assign(__assign({}, themeOptions.palette), { primary: { main: primaryColor } });
|
30
38
|
}
|
31
39
|
if (!!secondaryColor) {
|
32
|
-
themeOptions.palette = {
|
33
|
-
...themeOptions.palette,
|
34
|
-
secondary: { main: secondaryColor }
|
35
|
-
};
|
40
|
+
themeOptions.palette = __assign(__assign({}, themeOptions.palette), { secondary: { main: secondaryColor } });
|
36
41
|
}
|
37
42
|
}
|
38
|
-
|
43
|
+
var theme = createTheme(themeOptions);
|
39
44
|
return theme;
|
40
45
|
}
|
41
46
|
export default useCustomTheme;
|
package/utils/uuid.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
function generateUUID(length
|
1
|
+
function generateUUID(length) {
|
2
|
+
if (length === void 0) { length = 32; }
|
2
3
|
if (length < 16)
|
3
4
|
throw new Error("Length should be equal or greater than 16");
|
4
5
|
function UUID() {
|
@@ -23,28 +24,28 @@ function generateUUID(length = 32) {
|
|
23
24
|
this.rand = "";
|
24
25
|
}
|
25
26
|
UUID.prototype = {
|
26
|
-
getRandomUInt() {
|
27
|
-
|
28
|
-
this.chars.sort(()
|
27
|
+
getRandomUInt: function () {
|
28
|
+
var s = "";
|
29
|
+
this.chars.sort(function () {
|
29
30
|
return Date.now() % (Math.random() * length * 23) >
|
30
31
|
Math.random() * 7 * length
|
31
32
|
? -1
|
32
33
|
: 1;
|
33
34
|
});
|
34
|
-
for (
|
35
|
+
for (var i = 0; i < this.chars.length; i += 1) {
|
35
36
|
s = s.concat(this.chars[i]);
|
36
37
|
}
|
37
38
|
return s;
|
38
39
|
},
|
39
|
-
getRandomChars() {
|
40
|
+
getRandomChars: function () {
|
40
41
|
this.rand = Date.now().toString(16).concat(this.getRandomUInt());
|
41
42
|
return this.rand;
|
42
43
|
},
|
43
|
-
generate() {
|
44
|
-
|
45
|
-
|
44
|
+
generate: function () {
|
45
|
+
var id = Date.now().toString();
|
46
|
+
var idLen = id.length;
|
46
47
|
this.getRandomChars();
|
47
|
-
for (
|
48
|
+
for (var i = 0; i < length - idLen; i += 1) {
|
48
49
|
id = id.concat(this.rand.charAt(Math.floor(Math.random() * this.rand.length)));
|
49
50
|
}
|
50
51
|
return id.toString();
|