@symply.io/basic-components 1.0.0-alpha.1 → 1.0.0-alpha.12
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 +15 -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.d.ts +2 -1
- package/FormSelector/MultipleSelector.js +25 -11
- package/FormSelector/SimpleSelector.d.ts +2 -1
- package/FormSelector/SimpleSelector.js +25 -11
- package/FormSelector/types.d.ts +5 -7
- 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 +46 -47
- 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
@@ -10,12 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
-
import { memo } from "react";
|
14
13
|
import MenuItem from "@mui/material/MenuItem";
|
15
14
|
import ListItemIcon from "@mui/material/ListItemIcon";
|
16
15
|
import ListItemText from "@mui/material/ListItemText";
|
16
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
17
|
+
import useCustomTheme from "../useCustomTheme";
|
17
18
|
function ButtonMenuItem(props) {
|
18
19
|
var buttonText = props.buttonText, buttonIcon = props.buttonIcon, _a = props.disabled, disabled = _a === void 0 ? false : _a, onClick = props.onClick;
|
19
|
-
|
20
|
+
var theme = useCustomTheme();
|
21
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsxs(MenuItem, __assign({ onClick: onClick, disabled: disabled }, { children: [buttonIcon && _jsx(ListItemIcon, { children: buttonIcon }, void 0), _jsx(ListItemText, { primary: buttonText }, void 0)] }), void 0) }), void 0));
|
20
22
|
}
|
21
|
-
export default
|
23
|
+
export default ButtonMenuItem;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import { CSSProperties } from "react";
|
2
2
|
import { ButtonProps } from "@mui/material/Button";
|
3
3
|
import { ButtonItemProps } from "./MenuItem";
|
4
4
|
export interface MenuButtonGroupProps {
|
@@ -8,6 +8,8 @@ export interface MenuButtonGroupProps {
|
|
8
8
|
variant?: ButtonProps["variant"];
|
9
9
|
color?: ButtonProps["color"];
|
10
10
|
buttons: Array<ButtonItemProps>;
|
11
|
+
primaryColor?: CSSProperties["color"];
|
12
|
+
secondaryColor?: CSSProperties["color"];
|
11
13
|
}
|
12
14
|
declare function MenuButtonGroup(props: MenuButtonGroupProps): JSX.Element;
|
13
15
|
export default MenuButtonGroup;
|
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
@@ -23,6 +23,7 @@
|
|
23
23
|
- [PasswordInput](#passwordinput)
|
24
24
|
- [PhoneNumberInput](#phonenumberinput)
|
25
25
|
- [TabGroup](#tabgroup)
|
26
|
+
- [TextInput](#textinput)
|
26
27
|
- [ToastPrompt](#toastprompt)
|
27
28
|
- [VideoPlayerModal](#videoplayermodal)
|
28
29
|
- [Changelog](#changelog)
|
@@ -31,21 +32,21 @@
|
|
31
32
|
|
32
33
|
<h2>Installation</h2>
|
33
34
|
|
34
|
-
|
35
|
+
It is available as an [npm package](https://www.npmjs.com/package/@symply.io/basic-components).
|
35
36
|
|
36
|
-
```
|
37
|
+
```shell
|
37
38
|
// with npm
|
38
|
-
npm install @symply.io/
|
39
|
+
npm install @symply.io/basic-components
|
39
40
|
|
40
41
|
// with yarn
|
41
|
-
yarn add @symply.io/
|
42
|
+
yarn add @symply.io/basic-components
|
42
43
|
```
|
43
44
|
|
44
45
|
|
45
46
|
|
46
47
|
<h2>License</h2>
|
47
48
|
|
48
|
-
This project is licensed under the terms of the [MIT license](https://github.com/
|
49
|
+
This project is licensed under the terms of the [MIT license](https://github.com/baseline-software/symply-basic-components/blob/main/LICENSE).
|
49
50
|
|
50
51
|
|
51
52
|
|
@@ -58,9 +59,9 @@ Diglog component for alerts or confirmations.
|
|
58
59
|
<h5>Import</h5>
|
59
60
|
|
60
61
|
```typescript
|
61
|
-
import { AlertDialog } from '@symply.io/
|
62
|
+
import { AlertDialog } from '@symply.io/basic-components/';
|
62
63
|
// or
|
63
|
-
import AlertDialog from '@symply.io/
|
64
|
+
import AlertDialog from '@symply.io/basic-components/AlertDialog';
|
64
65
|
```
|
65
66
|
|
66
67
|
<h5>Props</h5>
|
@@ -83,9 +84,9 @@ Reusable modal component.
|
|
83
84
|
<h5>Import</h5>
|
84
85
|
|
85
86
|
```typescript
|
86
|
-
import { BasicModal } from '@symply.io/
|
87
|
+
import { BasicModal } from '@symply.io/basic-components/';
|
87
88
|
// or
|
88
|
-
import BasicModal from '@symply.io/
|
89
|
+
import BasicModal from '@symply.io/basic-components/BasicModal';
|
89
90
|
```
|
90
91
|
|
91
92
|
<h5>Props</h5>
|
@@ -119,9 +120,9 @@ It is extended from `@mui/material/TextField`, so it includes all properties of
|
|
119
120
|
<h5>Import</h5>
|
120
121
|
|
121
122
|
```typescript
|
122
|
-
import { DigitInput } from '@symply.io/
|
123
|
+
import { DigitInput } from '@symply.io/basic-components/';
|
123
124
|
// or
|
124
|
-
import DigitInput from '@symply.io/
|
125
|
+
import DigitInput from '@symply.io/basic-components/DigitInput';
|
125
126
|
```
|
126
127
|
|
127
128
|
<h5>Props</h5>
|
@@ -144,9 +145,9 @@ Radio Group allow the user to select one option from a set.
|
|
144
145
|
<h5>Import</h5>
|
145
146
|
|
146
147
|
```typescript
|
147
|
-
import { FormRadioGroup } from '@symply.io/
|
148
|
+
import { FormRadioGroup } from '@symply.io/basic-components/';
|
148
149
|
// or
|
149
|
-
import FormRadioGroup from '@symply.io/
|
150
|
+
import FormRadioGroup from '@symply.io/basic-components/FormRadioGroup';
|
150
151
|
```
|
151
152
|
|
152
153
|
<h5>Radio Option Props</h5>
|
@@ -179,9 +180,9 @@ Selector components are used for collecting user provided information from a lis
|
|
179
180
|
|
180
181
|
```typescript
|
181
182
|
// Simple Selector
|
182
|
-
import { SimpleSelector } from '@symply.io/
|
183
|
+
import { SimpleSelector } from '@symply.io/basic-components/FormSelector';
|
183
184
|
// Multiple Selector
|
184
|
-
import { MultipleSelector } from '@symply.io/
|
185
|
+
import { MultipleSelector } from '@symply.io/basic-components/FormRadioGroup';
|
185
186
|
```
|
186
187
|
|
187
188
|
<h5>Selector Option Props</h5>
|
@@ -194,18 +195,16 @@ import { MultipleSelector } from '@symply.io/symply-basic-components/FormRadioGr
|
|
194
195
|
|
195
196
|
<h5>Base Props</h5>
|
196
197
|
|
197
|
-
|
198
|
-
|
199
|
-
|
|
200
|
-
|
|
201
|
-
| helperText | string
|
202
|
-
| label | string
|
203
|
-
| multiple | bool
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
| tooltip | string | | false | A tooltip for the `Select` element. |
|
208
|
-
| variant | 'filled' \| 'contained' \| 'outlined' | 'outlined' | false | The variant of the `Select` element. |
|
198
|
+
It is extended from `@mui/material/FormControl`, so it includes all properties of `@mui/material/FormControl`.
|
199
|
+
|
200
|
+
| Name | Type | Default | Required | Description |
|
201
|
+
| -------------- | --------------------- | ------- | -------- | ----------------------------------------------------------- |
|
202
|
+
| helperText | string | | false | The helper text of the `Select` element. |
|
203
|
+
| label | string | | false | The label of `Select` element. |
|
204
|
+
| multiple | bool | false | false | If `true`, you can select more than 1 option. |
|
205
|
+
| options | Array\<IRadioOption\> | | true | The radio options. See the **Selector Option Props** above. |
|
206
|
+
| showHelperText | bool | false | False | If `true`, show the helper text. |
|
207
|
+
| tooltip | string | | false | A tooltip for the `Select` element. |
|
209
208
|
|
210
209
|
<h5>Simple Selector Props</h5> Extended from the Base Props
|
211
210
|
|
@@ -230,9 +229,9 @@ You can use it to add a hint/help paragraph.
|
|
230
229
|
<h5>Import</h5>
|
231
230
|
|
232
231
|
```typescript
|
233
|
-
import { HelpCaption } from '@symply.io/
|
232
|
+
import { HelpCaption } from '@symply.io/basic-components/';
|
234
233
|
// or
|
235
|
-
import HelpCaption from '@symply.io/
|
234
|
+
import HelpCaption from '@symply.io/basic-components/HelpCaption';
|
236
235
|
```
|
237
236
|
|
238
237
|
<h5>Props</h5>
|
@@ -254,9 +253,9 @@ A modal for loading.
|
|
254
253
|
<h5>Import</h5>
|
255
254
|
|
256
255
|
```typescript
|
257
|
-
import { LoadingModal } from '@symply.io/
|
256
|
+
import { LoadingModal } from '@symply.io/basic-components/';
|
258
257
|
// or
|
259
|
-
import LoadingModal from '@symply.io/
|
258
|
+
import LoadingModal from '@symply.io/basic-components/LoadingModal';
|
260
259
|
```
|
261
260
|
|
262
261
|
<h5>Props</h5>
|
@@ -278,9 +277,9 @@ A button with menu options.
|
|
278
277
|
<h5>Import</h5>
|
279
278
|
|
280
279
|
```typescript
|
281
|
-
import { MenuButtonGroup } from '@symply.io/
|
280
|
+
import { MenuButtonGroup } from '@symply.io/basic-components/';
|
282
281
|
// or
|
283
|
-
import MenuButtonGroup from '@symply.io/
|
282
|
+
import MenuButtonGroup from '@symply.io/basic-components/MenuButtonGroup';
|
284
283
|
```
|
285
284
|
|
286
285
|
<h5>Menu Button Props</h5>
|
@@ -315,9 +314,9 @@ It is extended from `@mui/material/TextField`, so it includes all properties of
|
|
315
314
|
<h5>Import</h5>
|
316
315
|
|
317
316
|
```typescript
|
318
|
-
import { NumberInput } from '@symply.io/
|
317
|
+
import { NumberInput } from '@symply.io/basic-components/';
|
319
318
|
// or
|
320
|
-
import NumberInput from '@symply.io/
|
319
|
+
import NumberInput from '@symply.io/basic-components/NumberInput';
|
321
320
|
```
|
322
321
|
|
323
322
|
<h5>Props</h5>
|
@@ -343,9 +342,9 @@ It is extended from `@mui/material/TextField`, so it includes all properties of
|
|
343
342
|
|
344
343
|
```typescript
|
345
344
|
// Password
|
346
|
-
import { Password } from '@symply.io/
|
345
|
+
import { Password } from '@symply.io/basic-components/PasswordInput';
|
347
346
|
// Confirm Password
|
348
|
-
import { ConfirmPassword } from '@symply.io/
|
347
|
+
import { ConfirmPassword } from '@symply.io/basic-components/PasswordInput';
|
349
348
|
```
|
350
349
|
|
351
350
|
<h5>Password Props</h5>
|
@@ -377,9 +376,9 @@ It is extended from `@mui/material/TextField`, so it includes all properties of
|
|
377
376
|
<h5>Import</h5>
|
378
377
|
|
379
378
|
```typescript
|
380
|
-
import { PhoneNumberInput } from '@symply.io/
|
379
|
+
import { PhoneNumberInput } from '@symply.io/basic-components/';
|
381
380
|
// or
|
382
|
-
import PhoneNumberInput from '@symply.io/
|
381
|
+
import PhoneNumberInput from '@symply.io/basic-components/PhoneNumberInput';
|
383
382
|
```
|
384
383
|
|
385
384
|
<h5>Props</h5>
|
@@ -399,9 +398,9 @@ Tabs group.
|
|
399
398
|
<h5>Import</h5>
|
400
399
|
|
401
400
|
```typescript
|
402
|
-
import { TabGroup } from '@symply.io/
|
401
|
+
import { TabGroup } from '@symply.io/basic-components/';
|
403
402
|
// or
|
404
|
-
import TabGroup from '@symply.io/
|
403
|
+
import TabGroup from '@symply.io/basic-components/TabGroup';
|
405
404
|
```
|
406
405
|
|
407
406
|
<h5>Props</h5>
|
@@ -425,9 +424,9 @@ It is extended from `@mui/material/TextField`, so it includes all properties of
|
|
425
424
|
<h5>Import</h5>
|
426
425
|
|
427
426
|
```typescript
|
428
|
-
import { TextInput } from '@symply.io/
|
427
|
+
import { TextInput } from '@symply.io/basic-components/';
|
429
428
|
// or
|
430
|
-
import TextInput from '@symply.io/
|
429
|
+
import TextInput from '@symply.io/basic-components/TextInput';
|
431
430
|
```
|
432
431
|
|
433
432
|
<h5>Props</h5>
|
@@ -449,7 +448,7 @@ Global prompt component.
|
|
449
448
|
<h5>Import</h5>
|
450
449
|
|
451
450
|
```typescript
|
452
|
-
import { usePrompt } from '@symply.io/
|
451
|
+
import { usePrompt } from '@symply.io/basic-components';
|
453
452
|
```
|
454
453
|
|
455
454
|
<h5>Usage</h5>
|
@@ -474,9 +473,9 @@ A modal for playing videos.
|
|
474
473
|
<h5>Import</h5>
|
475
474
|
|
476
475
|
```typescript
|
477
|
-
import { VideoPlayerModal } from '@symply.io/
|
476
|
+
import { VideoPlayerModal } from '@symply.io/basic-components/';
|
478
477
|
// or
|
479
|
-
import VideoPlayerModal from '@symply.io/
|
478
|
+
import VideoPlayerModal from '@symply.io/basic-components/VideoPlayerModal';
|
480
479
|
```
|
481
480
|
|
482
481
|
<h5>Props</h5>
|
@@ -495,5 +494,5 @@ import VideoPlayerModal from '@symply.io/symply-basic-components/VideoPlayerModa
|
|
495
494
|
|
496
495
|
<h2>Changelog</h2>
|
497
496
|
|
498
|
-
If you have recently updated, please read the [changelog](https://github.com/
|
497
|
+
If you have recently updated, please read the [changelog](https://github.com/baseline-software/symply-basic-components/releases) for details of what has changed.
|
499
498
|
|
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";
|