@symply.io/basic-components 1.0.0-alpha.4 → 1.0.0-alpha.7
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 +9 -8
- package/AlertDialog/types.d.ts +3 -1
- package/BasicModal/index.js +18 -17
- package/BasicModal/types.d.ts +3 -1
- package/DigitInput/index.js +7 -4
- package/DigitInput/types.d.ts +3 -0
- package/DynamicHeaderBar/HeaderBar.d.ts +2 -0
- package/DynamicHeaderBar/HeaderBar.js +7 -6
- package/DynamicHeaderBar/HeaderButtons.js +20 -19
- package/DynamicHeaderBar/HeaderLine.js +3 -3
- package/FormRadioGroup/index.js +15 -12
- package/FormRadioGroup/types.d.ts +3 -0
- package/FormSelector/MultipleSelector.js +14 -11
- package/FormSelector/SimpleSelector.js +14 -11
- package/FormSelector/types.d.ts +3 -1
- package/HelpCaption/index.d.ts +3 -1
- package/HelpCaption/index.js +15 -14
- package/LoadingModal/index.js +8 -5
- package/LoadingModal/types.d.ts +3 -0
- package/MenuButtonGroup/MenuItem.d.ts +1 -2
- package/MenuButtonGroup/MenuItem.js +5 -3
- package/MenuButtonGroup/index.d.ts +3 -1
- package/MenuButtonGroup/index.js +9 -6
- package/NumberInput/index.d.ts +3 -1
- package/NumberInput/index.js +8 -5
- package/PasswordInput/ConfirmPassword.d.ts +3 -1
- package/PasswordInput/ConfirmPassword.js +10 -7
- package/PasswordInput/Password.d.ts +2 -0
- package/PasswordInput/Password.js +17 -9
- package/PhoneNumberInput/index.d.ts +4 -1
- package/PhoneNumberInput/index.js +25 -7
- package/PhoneNumberInput/useInteractions.d.ts +0 -1
- package/PhoneNumberInput/useInteractions.js +1 -14
- package/README.md +1 -0
- package/TabGroup/index.js +19 -18
- package/TabGroup/types.d.ts +3 -0
- package/TextInput/index.d.ts +3 -1
- package/TextInput/index.js +8 -5
- package/ToastPrompt/Presentation.js +26 -25
- package/VideoPlayerModal/index.js +8 -7
- package/VideoPlayerModal/types.d.ts +3 -0
- package/package.json +2 -1
- package/useCustomTheme.d.ts +6 -0
- package/useCustomTheme.js +51 -0
package/MenuButtonGroup/index.js
CHANGED
@@ -56,15 +56,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
56
56
|
}
|
57
57
|
return t;
|
58
58
|
};
|
59
|
-
import { jsx as _jsx,
|
59
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
60
60
|
import { useState } from "react";
|
61
61
|
import Menu from "@mui/material/Menu";
|
62
62
|
import Button from "@mui/material/Button";
|
63
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
63
64
|
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
|
64
65
|
import ButtonItem from "./MenuItem";
|
66
|
+
import useCustomTheme from "../useCustomTheme";
|
65
67
|
function MenuButtonGroup(props) {
|
66
68
|
var _this = this;
|
67
|
-
var buttonText = props.buttonText, buttons = props.buttons, size = props.size, _a = props.color, color = _a === void 0 ? "primary" : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.variant, variant = _c === void 0 ? "outlined" : _c;
|
69
|
+
var buttonText = props.buttonText, buttons = props.buttons, size = props.size, _a = props.color, color = _a === void 0 ? "primary" : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.variant, variant = _c === void 0 ? "outlined" : _c, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
|
70
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
68
71
|
var _d = useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
|
69
72
|
function onClick(event) {
|
70
73
|
setAnchorEl(event.currentTarget);
|
@@ -72,12 +75,12 @@ function MenuButtonGroup(props) {
|
|
72
75
|
var onClose = function () {
|
73
76
|
setAnchorEl(null);
|
74
77
|
};
|
75
|
-
return (_jsxs(
|
78
|
+
return (_jsxs(ThemeProvider, __assign({ theme: theme }, { children: [_jsx(Button, __assign({ "aria-controls": "customized-menu", "data-nw": "download-button", "aria-haspopup": "true", variant: variant, color: color, onClick: onClick, fullWidth: true, size: size, endIcon: _jsx(ArrowDropDownIcon, { fontSize: "small" }, void 0), disabled: disabled }, { children: buttonText }), void 0), _jsx(Menu, __assign({ id: "button-menu", anchorEl: anchorEl, keepMounted: true, elevation: 2, anchorOrigin: {
|
76
79
|
vertical: "bottom",
|
77
|
-
horizontal: "center"
|
80
|
+
horizontal: "center"
|
78
81
|
}, transformOrigin: {
|
79
82
|
vertical: "top",
|
80
|
-
horizontal: "center"
|
83
|
+
horizontal: "center"
|
81
84
|
}, open: Boolean(anchorEl), onClose: onClose }, { children: buttons.map(function (button) {
|
82
85
|
var onClick = button.onClick, buttonText = button.buttonText, rest = __rest(button, ["onClick", "buttonText"]);
|
83
86
|
return (_jsx(ButtonItem, __assign({ buttonText: buttonText }, rest, { onClick: function (event) { return __awaiter(_this, void 0, void 0, function () {
|
@@ -95,6 +98,6 @@ function MenuButtonGroup(props) {
|
|
95
98
|
}
|
96
99
|
});
|
97
100
|
}); } }), buttonText));
|
98
|
-
}) }), void 0)] }, void 0));
|
101
|
+
}) }), void 0)] }), void 0));
|
99
102
|
}
|
100
103
|
export default MenuButtonGroup;
|
package/NumberInput/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import { CSSProperties } from "react";
|
2
2
|
import { TextFieldProps } from "@mui/material/TextField";
|
3
3
|
declare type TextProps = Omit<TextFieldProps, "onChange">;
|
4
4
|
export interface NumberInputProps {
|
@@ -8,6 +8,8 @@ export interface NumberInputProps {
|
|
8
8
|
tooltip?: string;
|
9
9
|
maxValue?: number;
|
10
10
|
minValue?: number;
|
11
|
+
primaryColor?: CSSProperties["color"];
|
12
|
+
secondaryColor?: CSSProperties["color"];
|
11
13
|
}
|
12
14
|
declare function NumberInput(props: NumberInputProps & TextProps): JSX.Element;
|
13
15
|
export default NumberInput;
|
package/NumberInput/index.js
CHANGED
@@ -23,16 +23,19 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
24
|
import Tooltip from "@mui/material/Tooltip";
|
25
25
|
import Field from "@mui/material/TextField";
|
26
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
26
27
|
import useInteractions from "./useInteractions";
|
28
|
+
import useCustomTheme from "../useCustomTheme";
|
27
29
|
function NumberInput(props) {
|
28
|
-
var onChange = props.onChange, value = props.value, _a = props.size, size = _a === void 0 ? "small" : _a, tooltip = props.tooltip, _b = props.integerOnly, integerOnly = _b === void 0 ? false : _b, _c = props.minValue, minValue = _c === void 0 ? Number.MIN_SAFE_INTEGER : _c, _d = props.maxValue, maxValue = _d === void 0 ? Number.MAX_SAFE_INTEGER : _d, error = props.error, helperText = props.helperText, rest = __rest(props, ["onChange", "value", "size", "tooltip", "integerOnly", "minValue", "maxValue", "error", "helperText"]);
|
30
|
+
var onChange = props.onChange, value = props.value, _a = props.size, size = _a === void 0 ? "small" : _a, tooltip = props.tooltip, _b = props.integerOnly, integerOnly = _b === void 0 ? false : _b, _c = props.minValue, minValue = _c === void 0 ? Number.MIN_SAFE_INTEGER : _c, _d = props.maxValue, maxValue = _d === void 0 ? Number.MAX_SAFE_INTEGER : _d, error = props.error, helperText = props.helperText, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["onChange", "value", "size", "tooltip", "integerOnly", "minValue", "maxValue", "error", "helperText", "primaryColor", "secondaryColor"]);
|
31
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
29
32
|
var EXCEED_ERROR = "Your value exceeds the exceptable input range";
|
30
33
|
if (maxValue < minValue)
|
31
34
|
throw new Error("Max should be bigger than min!");
|
32
35
|
var _e = useInteractions({ maxValue: maxValue, minValue: minValue, value: value, onChange: onChange }), exceedError = _e.exceedError, tooltipOpen = _e.tooltipOpen, handleBlur = _e.handleBlur, handleChange = _e.handleChange, onOpenTooltip = _e.onOpenTooltip, onCloseTooltip = _e.onCloseTooltip;
|
33
|
-
return (_jsx(Tooltip, __assign({ title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: "number", value: value === undefined || value === null ? "" : value, onFocus: onOpenTooltip, onBlur: function () {
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: "number", value: value === undefined || value === null ? "" : value, onFocus: onOpenTooltip, onBlur: function () {
|
37
|
+
onCloseTooltip();
|
38
|
+
handleBlur();
|
39
|
+
}, onChange: handleChange, error: error || exceedError, helperText: helperText || (exceedError ? EXCEED_ERROR : "") }, rest), void 0) }), void 0) }), void 0));
|
37
40
|
}
|
38
41
|
export default NumberInput;
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
import { CSSProperties } from "react";
|
2
2
|
import { TextFieldProps } from "@mui/material/TextField";
|
3
3
|
declare type TextInputProps = Omit<TextFieldProps, "onChange">;
|
4
4
|
export interface ConfirmPasswordProps {
|
5
5
|
password: string;
|
6
6
|
value: string;
|
7
|
+
primaryColor?: CSSProperties["color"];
|
8
|
+
secondaryColor?: CSSProperties["color"];
|
7
9
|
onChange: (value: string) => void;
|
8
10
|
}
|
9
11
|
declare function ConfirmPassword(props: ConfirmPasswordProps & TextInputProps): JSX.Element;
|
@@ -23,16 +23,19 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
24
|
import { useMemo } from "react";
|
25
25
|
import TextField from "@mui/material/TextField";
|
26
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
27
|
+
import useCustomTheme from "../useCustomTheme";
|
26
28
|
function ConfirmPassword(props) {
|
27
|
-
var password = props.password, _a = props.helperText, helperText = _a === void 0 ? "Passwords do not match" : _a, value = props.value, _b = props.label, label = _b === void 0 ? "Confirm Password" : _b, _c = props.name, name = _c === void 0 ? "confirmPassword" : _c, _d = props.variant, variant = _d === void 0 ? "outlined" : _d, _e = props.margin, margin = _e === void 0 ? "dense" : _e, disabled = props.disabled, onChange = props.onChange, rest = __rest(props, ["password", "helperText", "value", "label", "name", "variant", "margin", "disabled", "onChange"]);
|
29
|
+
var password = props.password, _a = props.helperText, helperText = _a === void 0 ? "Passwords do not match" : _a, value = props.value, _b = props.label, label = _b === void 0 ? "Confirm Password" : _b, _c = props.name, name = _c === void 0 ? "confirmPassword" : _c, _d = props.variant, variant = _d === void 0 ? "outlined" : _d, _e = props.margin, margin = _e === void 0 ? "dense" : _e, disabled = props.disabled, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onChange = props.onChange, rest = __rest(props, ["password", "helperText", "value", "label", "name", "variant", "margin", "disabled", "primaryColor", "secondaryColor", "onChange"]);
|
30
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
28
31
|
var isMatched = useMemo(function () {
|
29
|
-
if ((value === null || value === void 0 ? void 0 : value.length) > 0
|
30
|
-
return
|
32
|
+
if ((value === null || value === void 0 ? void 0 : value.length) > 0) {
|
33
|
+
return password === value;
|
31
34
|
}
|
32
|
-
return
|
35
|
+
return true;
|
33
36
|
}, [value, password]);
|
34
|
-
return (_jsx(TextField, __assign({ error: !isMatched, label: label, value: value, variant: variant, margin: margin, disabled: disabled, type: "password", size: "small", helperText: !isMatched && helperText, onChange: function (event) {
|
35
|
-
|
36
|
-
|
37
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, __assign({ error: !isMatched, label: label, value: value, variant: variant, margin: margin, disabled: disabled, type: "password", size: "small", helperText: !isMatched && helperText, onChange: function (event) {
|
38
|
+
onChange(event.target.value);
|
39
|
+
}, fullWidth: true, required: true }, rest), void 0) }), void 0));
|
37
40
|
}
|
38
41
|
export default ConfirmPassword;
|
@@ -11,6 +11,8 @@ export interface PasswordProps {
|
|
11
11
|
strategies: PasswordStrategyProps;
|
12
12
|
value: string;
|
13
13
|
successColor?: CSSProperties["color"];
|
14
|
+
primaryColor?: CSSProperties["color"];
|
15
|
+
secondaryColor?: CSSProperties["color"];
|
14
16
|
onChange: (value: string) => void;
|
15
17
|
onVerify?: (value: string) => boolean;
|
16
18
|
}
|
@@ -24,21 +24,29 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
24
|
import { useMemo } from "react";
|
25
25
|
import TextField from "@mui/material/TextField";
|
26
26
|
import Typography from "@mui/material/Typography";
|
27
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
28
|
+
import useCustomTheme from "../useCustomTheme";
|
27
29
|
function Password(props) {
|
28
30
|
var _a = props.strategies, strategies = _a === void 0 ? {
|
29
31
|
uppercaseLetter: { label: "1 Uppercase Letter", regex: /[A-Z]+/ },
|
30
32
|
lowercaseLetter: { label: "1 Lowercase Letter", regex: /[a-z]+/ },
|
31
33
|
specialCharacter: {
|
32
34
|
label: "1 Special Character",
|
33
|
-
regex: /[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]
|
35
|
+
regex: /[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/
|
34
36
|
},
|
35
37
|
number: { label: "1 Number", regex: /\d+/ },
|
36
|
-
minimum8: { label: "Minimum 8 characters", regex: /.{8,}/ }
|
37
|
-
} : _a, _b = props.successColor, successColor = _b === void 0 ? "green" : _b, value = props.value, error = props.error, _c = props.onVerify, onVerify = _c === void 0 ? function (password) {
|
38
|
+
minimum8: { label: "Minimum 8 characters", regex: /.{8,}/ }
|
39
|
+
} : _a, _b = props.successColor, successColor = _b === void 0 ? "green" : _b, value = props.value, error = props.error, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, _c = props.onVerify, onVerify = _c === void 0 ? function (password) {
|
38
40
|
var reg = /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~a-zA-z0-9]{8,})$/;
|
39
41
|
return reg.test(password);
|
40
|
-
} : _c, onChange = props.onChange, rest = __rest(props, ["strategies", "successColor", "value", "error", "onVerify", "onChange"]);
|
41
|
-
var
|
42
|
+
} : _c, onChange = props.onChange, rest = __rest(props, ["strategies", "successColor", "value", "error", "primaryColor", "secondaryColor", "onVerify", "onChange"]);
|
43
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
44
|
+
var isValidPassword = useMemo(function () {
|
45
|
+
if ((value === null || value === void 0 ? void 0 : value.length) > 0) {
|
46
|
+
return onVerify(value);
|
47
|
+
}
|
48
|
+
return true;
|
49
|
+
}, [value, onVerify]);
|
42
50
|
var helperTextColor = useMemo(function () {
|
43
51
|
var textColors = Object.keys(strategies).reduce(function (temp, key) {
|
44
52
|
var regex = strategies[key].regex;
|
@@ -58,11 +66,11 @@ function Password(props) {
|
|
58
66
|
var helperText = useMemo(function () {
|
59
67
|
return (_jsx(_Fragment, { children: Object.keys(strategies).map(function (key) {
|
60
68
|
var label = strategies[key].label;
|
61
|
-
return (_jsx(Typography, __assign({ component: "
|
69
|
+
return (_jsx(Typography, __assign({ component: "li", variant: "caption", style: { color: helperTextColor[key] } }, { children: label }), key));
|
62
70
|
}) }, void 0));
|
63
71
|
}, [helperTextColor, strategies]);
|
64
|
-
return (_jsx(TextField, __assign({ error: !isValidPassword || error, helperText: helperText, type: "password", label: "Password", size: "small", margin: "dense", value: value, onChange: function (event) {
|
65
|
-
|
66
|
-
|
72
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, __assign({ error: !isValidPassword || error, helperText: helperText, type: "password", label: "Password", size: "small", margin: "dense", value: value, onChange: function (event) {
|
73
|
+
onChange(event.target.value);
|
74
|
+
}, fullWidth: true, required: true }, rest), void 0) }), void 0));
|
67
75
|
}
|
68
76
|
export default Password;
|
@@ -1,11 +1,14 @@
|
|
1
|
-
|
1
|
+
import { CSSProperties } from "react";
|
2
2
|
import { InputProps } from "@mui/material/Input";
|
3
3
|
import { TextFieldProps } from "@mui/material/TextField";
|
4
4
|
declare type TextInputProps = Omit<TextFieldProps, "onChange">;
|
5
5
|
export interface PhoneInputProps {
|
6
6
|
value: string;
|
7
7
|
endAdornment?: InputProps["endAdornment"];
|
8
|
+
primaryColor?: CSSProperties["color"];
|
9
|
+
secondaryColor?: CSSProperties["color"];
|
8
10
|
onChange: (val: string) => void;
|
9
11
|
}
|
12
|
+
export declare function phoneFormat(str: string): string;
|
10
13
|
declare function PhoneInput(props: TextInputProps & PhoneInputProps): JSX.Element;
|
11
14
|
export default PhoneInput;
|
@@ -25,20 +25,38 @@ import { useRifm } from "rifm";
|
|
25
25
|
import Typography from "@mui/material/Typography";
|
26
26
|
import InputAdornment from "@mui/material/InputAdornment";
|
27
27
|
import TextField from "@mui/material/TextField";
|
28
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
28
29
|
import useInteractions from "./useInteractions";
|
30
|
+
import useCustomTheme from "../useCustomTheme";
|
31
|
+
export function phoneFormat(str) {
|
32
|
+
var digits = (str.match(/\d+/g) || []).join("");
|
33
|
+
var chars = digits.split("");
|
34
|
+
return chars.reduce(function (prev, curr, index) {
|
35
|
+
if (index === 3) {
|
36
|
+
return "".concat(prev, ") ").concat(curr);
|
37
|
+
}
|
38
|
+
else if (index === 6) {
|
39
|
+
return "".concat(prev, "-").concat(curr);
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
return "".concat(prev).concat(curr);
|
43
|
+
}
|
44
|
+
}, "(");
|
45
|
+
}
|
29
46
|
function PhoneInput(props) {
|
30
|
-
var value = props.value, endAdornment = props.endAdornment, onChange = props.onChange, rest = __rest(props, ["value", "endAdornment", "onChange"]);
|
31
|
-
var
|
47
|
+
var value = props.value, endAdornment = props.endAdornment, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onChange = props.onChange, rest = __rest(props, ["value", "endAdornment", "primaryColor", "secondaryColor", "onChange"]);
|
48
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
49
|
+
var addMask = useInteractions({ value: value }).addMask;
|
32
50
|
var rifm = useRifm({
|
33
51
|
mask: true,
|
34
52
|
value: String(value),
|
35
53
|
onChange: onChange,
|
36
54
|
replace: addMask,
|
37
|
-
format: phoneFormat
|
55
|
+
format: phoneFormat
|
38
56
|
});
|
39
|
-
return (_jsx(TextField, __assign({ value: rifm.value, InputProps: {
|
40
|
-
|
41
|
-
|
42
|
-
|
57
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, __assign({ value: rifm.value, InputProps: {
|
58
|
+
startAdornment: (_jsx(InputAdornment, __assign({ position: "start" }, { children: _jsx(Typography, __assign({ variant: "body2" }, { children: "+1" }), void 0) }), void 0)),
|
59
|
+
endAdornment: endAdornment
|
60
|
+
}, onChange: rifm.onChange }, rest), void 0) }), void 0));
|
43
61
|
}
|
44
62
|
export default PhoneInput;
|
@@ -1,19 +1,6 @@
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
2
2
|
function useInteractions(props) {
|
3
3
|
var value = props.value;
|
4
|
-
var phoneFormat = useCallback(function (str) {
|
5
|
-
var digits = (str.match(/\d+/g) || []).join("");
|
6
|
-
var chars = digits.split("");
|
7
|
-
return chars.reduce(function (prev, curr, index) {
|
8
|
-
if (index === 3) {
|
9
|
-
return "".concat(prev, ") ").concat(curr);
|
10
|
-
}
|
11
|
-
if (index === 6) {
|
12
|
-
return "".concat(prev, "-").concat(curr);
|
13
|
-
}
|
14
|
-
return "".concat(prev).concat(curr);
|
15
|
-
}, "(");
|
16
|
-
}, []);
|
17
4
|
var addMask = useCallback(function (str) {
|
18
5
|
var digits = (str.match(/\d+/g) || []).join("");
|
19
6
|
var areaCode = digits.slice(0, 3).padEnd(3, "_");
|
@@ -25,6 +12,6 @@ function useInteractions(props) {
|
|
25
12
|
var digitsArr = String(value).match(/\d/g);
|
26
13
|
return digitsArr ? digitsArr.length : 0;
|
27
14
|
}, [value]);
|
28
|
-
return { valLength: valLength, addMask: addMask
|
15
|
+
return { valLength: valLength, addMask: addMask };
|
29
16
|
}
|
30
17
|
export default useInteractions;
|
package/README.md
CHANGED
package/TabGroup/index.js
CHANGED
@@ -15,32 +15,33 @@ import Tab from "@mui/material/Tab";
|
|
15
15
|
import Tabs from "@mui/material/Tabs";
|
16
16
|
import Typography from "@mui/material/Typography";
|
17
17
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
18
|
-
import
|
18
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
19
|
+
import useCustomTheme from "../useCustomTheme";
|
19
20
|
var TabGroup = forwardRef(function (props, ref) {
|
20
|
-
var
|
21
|
+
var tabs = props.tabs, _a = props.textColor, textColor = _a === void 0 ? "primary" : _a, _b = props.variant, variant = _b === void 0 ? "scrollable" : _b, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onTabChange = props.onTabChange, _c = props.currentTabIndex, outerTabIndex = _c === void 0 ? 0 : _c;
|
22
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
21
23
|
var mobileViewport = useMediaQuery(theme.breakpoints.down("md"));
|
22
|
-
var tabs = props.tabs, _a = props.textColor, textColor = _a === void 0 ? "primary" : _a, _b = props.variant, variant = _b === void 0 ? "scrollable" : _b, onTabChange = props.onTabChange, _c = props.currentTabIndex, outerTabIndex = _c === void 0 ? 0 : _c;
|
23
24
|
var _d = useState(outerTabIndex), currentTabIndex = _d[0], setCurrentTabIndex = _d[1];
|
24
25
|
var onClick = function (index) {
|
25
26
|
setCurrentTabIndex(index);
|
26
27
|
};
|
27
28
|
useImperativeHandle(ref, function () { return ({
|
28
|
-
tabIndex: currentTabIndex
|
29
|
+
tabIndex: currentTabIndex
|
29
30
|
}); });
|
30
|
-
return (_jsx(Tabs, __assign({ value: currentTabIndex, TabIndicatorProps: { hidden: true }, variant: mobileViewport ? "scrollable" : variant, textColor: textColor, onChange: function (_, val) {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tabs, __assign({ value: currentTabIndex, TabIndicatorProps: { hidden: true }, variant: mobileViewport ? "scrollable" : variant, textColor: textColor, onChange: function (_, val) {
|
32
|
+
onClick(val);
|
33
|
+
onTabChange(val);
|
34
|
+
} }, { children: tabs.map(function (tab, index) {
|
35
|
+
var text = tab.text, _a = tab.disabled, disabled = _a === void 0 ? false : _a;
|
36
|
+
var active = currentTabIndex === index;
|
37
|
+
return (_jsx(Tab, { disableFocusRipple: true, disableRipple: true, label: _jsx(Typography, __assign({ variant: "body2" }, { children: text }), void 0), disabled: disabled, sx: {
|
38
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
39
|
+
margin: theme.spacing(0.75, 0.25),
|
40
|
+
background: active ? "#fff" : undefined,
|
41
|
+
borderRadius: active ? theme.spacing(0.5) : undefined,
|
42
|
+
boxShadow: active ? "0px 4px 6px #acc1c2" : undefined
|
43
|
+
} }, index));
|
44
|
+
}) }), void 0) }), void 0));
|
44
45
|
});
|
45
46
|
export default TabGroup;
|
46
47
|
export * from "./types";
|
package/TabGroup/types.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { CSSProperties } from "react";
|
1
2
|
import { TabsProps } from "@mui/material/Tabs";
|
2
3
|
export interface TabGroupProps {
|
3
4
|
textColor?: TabsProps["textColor"];
|
@@ -7,5 +8,7 @@ export interface TabGroupProps {
|
|
7
8
|
}>;
|
8
9
|
variant?: TabsProps["variant"];
|
9
10
|
currentTabIndex?: number;
|
11
|
+
primaryColor?: CSSProperties["color"];
|
12
|
+
secondaryColor?: CSSProperties["color"];
|
10
13
|
onTabChange: (index: number) => void;
|
11
14
|
}
|
package/TextInput/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import { CSSProperties } from "react";
|
2
2
|
import { TextFieldProps } from "@mui/material/TextField";
|
3
3
|
declare type TextProps = Omit<TextFieldProps, "onChange">;
|
4
4
|
export interface TextInputProps {
|
@@ -7,6 +7,8 @@ export interface TextInputProps {
|
|
7
7
|
tooltip?: TextFieldProps;
|
8
8
|
maxLength?: number;
|
9
9
|
minLength?: number;
|
10
|
+
primaryColor?: CSSProperties["color"];
|
11
|
+
secondaryColor?: CSSProperties["color"];
|
10
12
|
}
|
11
13
|
declare const TextInput: (props: TextInputProps & TextProps) => JSX.Element;
|
12
14
|
export default TextInput;
|
package/TextInput/index.js
CHANGED
@@ -23,13 +23,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
24
|
import Tooltip from "@mui/material/Tooltip";
|
25
25
|
import Field from "@mui/material/TextField";
|
26
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
26
27
|
import useInteractions from "./useInteractions";
|
28
|
+
import useCustomTheme from "../useCustomTheme";
|
27
29
|
var TextInput = function (props) {
|
28
|
-
var _a = props.type, type = _a === void 0 ? "text" : _a, onChange = props.onChange, value = props.value, _b = props.size, size = _b === void 0 ? "small" : _b, tooltip = props.tooltip, _c = props.maxLength, maxLength = _c === void 0 ? 999 : _c, _d = props.minLength, minLength = _d === void 0 ? 0 : _d, rest = __rest(props, ["type", "onChange", "value", "size", "tooltip", "maxLength", "minLength"]);
|
30
|
+
var _a = props.type, type = _a === void 0 ? "text" : _a, onChange = props.onChange, value = props.value, _b = props.size, size = _b === void 0 ? "small" : _b, tooltip = props.tooltip, _c = props.maxLength, maxLength = _c === void 0 ? 999 : _c, _d = props.minLength, minLength = _d === void 0 ? 0 : _d, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["type", "onChange", "value", "size", "tooltip", "maxLength", "minLength", "primaryColor", "secondaryColor"]);
|
31
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
29
32
|
var _e = useInteractions(), tooltipOpen = _e.tooltipOpen, onOpenTooltip = _e.onOpenTooltip, onCloseTooltip = _e.onCloseTooltip;
|
30
|
-
return (_jsx(Tooltip, __assign({ title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: type, value: value, onFocus: onOpenTooltip, onBlur: onCloseTooltip, onChange: function (event) {
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: type, value: value, onFocus: onOpenTooltip, onBlur: onCloseTooltip, onChange: function (event) {
|
34
|
+
event.preventDefault();
|
35
|
+
onChange(event.target.value);
|
36
|
+
}, inputProps: { maxLength: maxLength, minLength: minLength } }, rest), void 0) }), void 0) }), void 0));
|
34
37
|
};
|
35
38
|
export default TextInput;
|
@@ -22,7 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
22
22
|
};
|
23
23
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
24
24
|
import Typography from "@mui/material/Typography";
|
25
|
-
import
|
25
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
26
26
|
import Slide from "@mui/material/Slide";
|
27
27
|
import SnackbarContent from "@mui/material/SnackbarContent";
|
28
28
|
import Snackbar from "@mui/material/Snackbar";
|
@@ -31,23 +31,24 @@ import ErrorIcon from "@mui/icons-material/Error";
|
|
31
31
|
import WarningIcon from "@mui/icons-material/Warning";
|
32
32
|
import SuccessIcon from "@mui/icons-material/CheckCircle";
|
33
33
|
import { green, amber, red, blue } from "@mui/material/colors";
|
34
|
+
import useCustomTheme from "../useCustomTheme";
|
34
35
|
var ToastPrompt = function (props) {
|
35
36
|
var _a;
|
36
37
|
var _b = props.open, open = _b === void 0 ? false : _b, _c = props.vertical, vertical = _c === void 0 ? "top" : _c, _d = props.horizontal, horizontal = _d === void 0 ? "center" : _d, _e = props.timeout, timeout = _e === void 0 ? 3000 : _e, onClose = props.onClose, _f = props.transitionDirection, transitionDirection = _f === void 0 ? "down" : _f, _g = props.message, message = _g === void 0 ? "Unknown message" : _g, _h = props.icon, icon = _h === void 0 ? _jsx(_Fragment, {}, void 0) : _h, _j = props.variant, variant = _j === void 0 ? "info" : _j, other = __rest(props, ["open", "vertical", "horizontal", "timeout", "onClose", "transitionDirection", "message", "icon", "variant"]);
|
37
|
-
var theme =
|
38
|
+
var theme = useCustomTheme();
|
38
39
|
var styles = {
|
39
40
|
success: {
|
40
|
-
backgroundColor: green[600]
|
41
|
+
backgroundColor: green[600]
|
41
42
|
},
|
42
43
|
error: {
|
43
|
-
backgroundColor: red[700]
|
44
|
+
backgroundColor: red[700]
|
44
45
|
},
|
45
46
|
info: {
|
46
|
-
backgroundColor: blue[600]
|
47
|
+
backgroundColor: blue[600]
|
47
48
|
},
|
48
49
|
warning: {
|
49
|
-
backgroundColor: amber[900]
|
50
|
-
}
|
50
|
+
backgroundColor: amber[900]
|
51
|
+
}
|
51
52
|
};
|
52
53
|
var Transition = function (args) {
|
53
54
|
return _jsx(Slide, __assign({}, args, { direction: transitionDirection }), void 0);
|
@@ -56,25 +57,25 @@ var ToastPrompt = function (props) {
|
|
56
57
|
success: SuccessIcon,
|
57
58
|
warning: WarningIcon,
|
58
59
|
error: ErrorIcon,
|
59
|
-
info: InfoIcon
|
60
|
+
info: InfoIcon
|
60
61
|
};
|
61
62
|
var Icon = VariantIcon[variant];
|
62
|
-
return (_jsx(Snackbar, __assign({ anchorOrigin: { vertical: vertical, horizontal: horizontal }, open: open, onClose: onClose, autoHideDuration: timeout, TransitionComponent: Transition, sx: {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
+
display: "flex",
|
74
|
+
alignItems: "center"
|
75
|
+
} }, { children: [variant ? (_jsx(Icon, { sx: {
|
76
|
+
fontSize: 20,
|
77
|
+
opacity: 0.9,
|
78
|
+
marginRight: theme.spacing(1)
|
79
|
+
} }, void 0)) : (_jsx(_Fragment, { children: icon }, void 0)), message] }), void 0) }, other), void 0) }), "".concat(Date.now() * Math.round(Math.random()))) }), void 0));
|
79
80
|
};
|
80
81
|
export default ToastPrompt;
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
20
20
|
}
|
21
21
|
return t;
|
22
22
|
};
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
24
24
|
import ReactPlayer from "react-player";
|
25
25
|
import Grid from "@mui/material/Grid";
|
26
26
|
import Dialog from "@mui/material/Dialog";
|
@@ -28,15 +28,16 @@ import DialogTitle from "@mui/material/DialogTitle";
|
|
28
28
|
import DialogContent from "@mui/material/DialogContent";
|
29
29
|
import DialogActions from "@mui/material/DialogActions";
|
30
30
|
import Button from "@mui/material/Button";
|
31
|
-
import useTheme from "@mui/material/styles/useTheme";
|
32
31
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
32
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
33
|
+
import useCustomTheme from "../useCustomTheme";
|
33
34
|
function VideoPlayerModal(props) {
|
34
|
-
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, playerProps = __rest(props, ["url", "pip", "open", "title", "onClose", "extraButtons"]);
|
35
|
-
var theme =
|
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();
|
36
37
|
var fullScreen = useMediaQuery(theme.breakpoints.down("sm"));
|
37
|
-
return (_jsx(
|
38
|
-
file: { attributes: { disablePictureInPicture: !pip } }
|
39
|
-
} }, playerProps), void 0) }, void 0), _jsxs(DialogActions, { children: [extraButtons.map(function (buttonProps, index) { return (_jsx(Grid, __assign({ item: true, xs: 12, md: 3, lg: 2 }, { children: _jsx(Button, __assign({}, buttonProps), void 0) }), "extraButton_".concat(index))); }), _jsx(Button, __assign({ variant: "outlined", color: "secondary", onClick: onClose }, { children: "Close" }), void 0)] }, void 0)] }), void 0) }, void 0));
|
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 }, void 0), _jsx(DialogContent, { children: _jsx(ReactPlayer, __assign({ controls: true, url: url, style: { minHeight: "480px" }, width: "100%", config: {
|
39
|
+
file: { attributes: { disablePictureInPicture: !pip } }
|
40
|
+
} }, playerProps), void 0) }, void 0), _jsxs(DialogActions, { children: [extraButtons.map(function (buttonProps, index) { return (_jsx(Grid, __assign({ item: true, xs: 12, md: 3, lg: 2 }, { children: _jsx(Button, __assign({}, buttonProps), void 0) }), "extraButton_".concat(index))); }), _jsx(Button, __assign({ variant: "outlined", color: "secondary", onClick: onClose }, { children: "Close" }), void 0)] }, void 0)] }), void 0) }), void 0));
|
40
41
|
}
|
41
42
|
export default VideoPlayerModal;
|
42
43
|
export * from "./types";
|
@@ -1,8 +1,11 @@
|
|
1
|
+
import { CSSProperties } from "react";
|
1
2
|
import { ButtonProps } from "@mui/material/Button";
|
2
3
|
export interface VideoPlayerModalProps {
|
3
4
|
title?: string;
|
4
5
|
open: boolean;
|
5
6
|
pip?: boolean;
|
6
7
|
extraButtons?: Array<ButtonProps>;
|
8
|
+
primaryColor?: CSSProperties["color"];
|
9
|
+
secondaryColor?: CSSProperties["color"];
|
7
10
|
onClose: () => void;
|
8
11
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@symply.io/basic-components",
|
3
|
-
"version": "1.0.0-alpha.
|
3
|
+
"version": "1.0.0-alpha.7",
|
4
4
|
"description": "Basic and reusable components for all frontend of Symply apps",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -55,6 +55,7 @@
|
|
55
55
|
"@mui/icons-material": "^5.4.2",
|
56
56
|
"@mui/material": "^5.4.2",
|
57
57
|
"@mui/system": "^5.4.2",
|
58
|
+
"color-alpha": "^1.1.3",
|
58
59
|
"react-player": "^2.9.0",
|
59
60
|
"rifm": "^0.12.1"
|
60
61
|
},
|