@symply.io/basic-components 1.3.10 → 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 +3 -13
- package/ToastPrompt/index.js +12 -26
- 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
@@ -1,35 +1,15 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
14
|
-
if (ar || !(i in from)) {
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
16
|
-
ar[i] = from[i];
|
17
|
-
}
|
18
|
-
}
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
20
|
-
};
|
21
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
22
2
|
import { cloneElement, useMemo, useState, useContext, useCallback, createContext } from "react";
|
23
3
|
import generateUUID from "../utils/uuid";
|
24
4
|
import LoadingModal from "./Modal";
|
25
|
-
|
26
|
-
onOpenLoadingModal:
|
27
|
-
onCloseLoadingModal:
|
5
|
+
const LoadingModalContext = createContext({
|
6
|
+
onOpenLoadingModal: () => null,
|
7
|
+
onCloseLoadingModal: () => { }
|
28
8
|
});
|
29
9
|
export function LoadingModalProvider(props) {
|
30
|
-
|
31
|
-
|
32
|
-
|
10
|
+
const { children, primaryColor, secondaryColor } = props;
|
11
|
+
const [instances, setInstances] = useState([]);
|
12
|
+
const modalArgs = useMemo(() => {
|
33
13
|
return instances.length > 0
|
34
14
|
? {
|
35
15
|
open: true,
|
@@ -37,20 +17,22 @@ export function LoadingModalProvider(props) {
|
|
37
17
|
}
|
38
18
|
: { open: false, text: "Loading..." };
|
39
19
|
}, [instances]);
|
40
|
-
|
41
|
-
|
20
|
+
const onOpenLoadingModal = useCallback((loadingText) => {
|
21
|
+
const instance = {
|
42
22
|
id: generateUUID(),
|
43
23
|
text: loadingText || "Loading..."
|
44
24
|
};
|
45
|
-
setInstances(
|
25
|
+
setInstances(insts => [...insts, instance]);
|
46
26
|
return instance;
|
47
27
|
}, []);
|
48
|
-
|
49
|
-
if (instance
|
50
|
-
setInstances(
|
28
|
+
const onCloseLoadingModal = useCallback((instance) => {
|
29
|
+
if (instance?.id) {
|
30
|
+
setInstances(insts => [
|
31
|
+
...insts.filter(inst => inst.id !== instance.id)
|
32
|
+
]);
|
51
33
|
}
|
52
34
|
}, []);
|
53
|
-
return (_jsx(LoadingModalContext.Provider,
|
35
|
+
return (_jsx(LoadingModalContext.Provider, { value: { onOpenLoadingModal, onCloseLoadingModal }, children: _jsxs(_Fragment, { children: [cloneElement(children), _jsx(LoadingModal, { ...modalArgs, primaryColor: primaryColor, secondaryColor: secondaryColor })] }) }));
|
54
36
|
}
|
55
37
|
export function useLoadingModal() {
|
56
38
|
return useContext(LoadingModalContext);
|
@@ -1,14 +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
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
13
2
|
import MenuItem from "@mui/material/MenuItem";
|
14
3
|
import ListItemIcon from "@mui/material/ListItemIcon";
|
@@ -16,8 +5,8 @@ import ListItemText from "@mui/material/ListItemText";
|
|
16
5
|
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
17
6
|
import useCustomTheme from "../useCustomTheme";
|
18
7
|
function ButtonMenuItem(props) {
|
19
|
-
|
20
|
-
|
21
|
-
return (_jsx(ThemeProvider,
|
8
|
+
const { buttonText, buttonIcon, disabled = false, onClick } = props;
|
9
|
+
const theme = useCustomTheme();
|
10
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(MenuItem, { onClick: onClick, disabled: disabled, children: [buttonIcon && _jsx(ListItemIcon, { children: buttonIcon }), _jsx(ListItemText, { primary: buttonText })] }) }));
|
22
11
|
}
|
23
12
|
export default ButtonMenuItem;
|
package/MenuButtonGroup/index.js
CHANGED
@@ -1,61 +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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
19
|
-
});
|
20
|
-
};
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
25
|
-
function step(op) {
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
27
|
-
while (_) try {
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
30
|
-
switch (op[0]) {
|
31
|
-
case 0: case 1: t = op; break;
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
35
|
-
default:
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
40
|
-
if (t[2]) _.ops.pop();
|
41
|
-
_.trys.pop(); continue;
|
42
|
-
}
|
43
|
-
op = body.call(thisArg, _);
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
46
|
-
}
|
47
|
-
};
|
48
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
49
|
-
var t = {};
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
51
|
-
t[p] = s[p];
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
55
|
-
t[p[i]] = s[p[i]];
|
56
|
-
}
|
57
|
-
return t;
|
58
|
-
};
|
59
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
60
2
|
import { useState } from "react";
|
61
3
|
import Menu from "@mui/material/Menu";
|
@@ -65,39 +7,29 @@ import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
|
|
65
7
|
import ButtonItem from "./MenuItem";
|
66
8
|
import useCustomTheme from "../useCustomTheme";
|
67
9
|
function MenuButtonGroup(props) {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
var _d = useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
|
10
|
+
const { buttonText, buttons, size, color = "primary", disabled = false, variant = "outlined", primaryColor, secondaryColor } = props;
|
11
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
12
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
72
13
|
function onClick(event) {
|
73
14
|
setAnchorEl(event.currentTarget);
|
74
15
|
}
|
75
|
-
|
16
|
+
const onClose = () => {
|
76
17
|
setAnchorEl(null);
|
77
18
|
};
|
78
|
-
return (_jsxs(ThemeProvider,
|
19
|
+
return (_jsxs(ThemeProvider, { theme: theme, children: [_jsx(Button, { "aria-haspopup": "true", variant: variant, color: color, onClick: onClick, fullWidth: true, size: size, endIcon: _jsx(ArrowDropDownIcon, { fontSize: "small" }), disabled: disabled, children: buttonText }), _jsx(Menu, { id: "button-menu", anchorEl: anchorEl, keepMounted: true, elevation: 2, anchorOrigin: {
|
79
20
|
vertical: "bottom",
|
80
21
|
horizontal: "center"
|
81
22
|
}, transformOrigin: {
|
82
23
|
vertical: "top",
|
83
24
|
horizontal: "center"
|
84
|
-
}, open: Boolean(anchorEl), onClose: onClose
|
85
|
-
|
86
|
-
return (_jsx(ButtonItem,
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
_a.sent();
|
94
|
-
_a.label = 2;
|
95
|
-
case 2:
|
96
|
-
onClose();
|
97
|
-
return [2];
|
98
|
-
}
|
99
|
-
});
|
100
|
-
}); } }), buttonText));
|
101
|
-
}) }))] })));
|
25
|
+
}, open: Boolean(anchorEl), onClose: onClose, children: buttons.map(button => {
|
26
|
+
const { onClick, buttonText, ...rest } = button;
|
27
|
+
return (_jsx(ButtonItem, { buttonText: buttonText, ...rest, onClick: async (event) => {
|
28
|
+
if (onClick) {
|
29
|
+
await onClick(event);
|
30
|
+
}
|
31
|
+
onClose();
|
32
|
+
} }, buttonText));
|
33
|
+
}) })] }));
|
102
34
|
}
|
103
35
|
export default MenuButtonGroup;
|
package/NumberInput/index.js
CHANGED
@@ -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 } from "react/jsx-runtime";
|
24
2
|
import Tooltip from "@mui/material/Tooltip";
|
25
3
|
import Field from "@mui/material/TextField";
|
@@ -27,12 +5,12 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
|
27
5
|
import useInteractions from "./useInteractions";
|
28
6
|
import useCustomTheme from "../useCustomTheme";
|
29
7
|
function NumberInput(props) {
|
30
|
-
|
31
|
-
|
32
|
-
|
8
|
+
const { onChange, value, size = "small", tooltip, integerOnly = false, minValue = Number.MIN_SAFE_INTEGER, maxValue = Number.MAX_SAFE_INTEGER, error, helperText, primaryColor, secondaryColor, ...rest } = props;
|
9
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
10
|
+
const EXCEED_ERROR = "Your value exceeds the exceptable input range";
|
33
11
|
if (maxValue < minValue)
|
34
12
|
throw new Error("Max should be bigger than the `miniValue`!");
|
35
|
-
|
36
|
-
return (_jsx(ThemeProvider,
|
13
|
+
const { exceedError, tooltipOpen, handleBlur, handleChange, onOpenTooltip, onCloseTooltip } = useInteractions({ maxValue, minValue, value, onChange });
|
14
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(Tooltip, { arrow: true, placement: "top", title: tooltip ?? "", open: !!tooltip && tooltipOpen, children: _jsx(Field, { size: size, margin: "dense", type: "number", value: value === undefined || value === null ? "" : value, onMouseEnter: onOpenTooltip, onMouseLeave: onCloseTooltip, onBlur: handleBlur, onChange: handleChange, error: error || exceedError, helperText: helperText || (exceedError ? EXCEED_ERROR : ""), ...rest }) }) }));
|
37
15
|
}
|
38
16
|
export default NumberInput;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { useState, useCallback, useMemo } from "react";
|
2
2
|
function useInteractions(props) {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
const { value, integerOnly, minValue = Number.MIN_SAFE_INTEGER, maxValue = Number.MAX_SAFE_INTEGER, onChange } = props;
|
4
|
+
const [tooltipOpen, setTooltipOpen] = useState(false);
|
5
|
+
const exceedError = useMemo(() => !!value && (Number(value) < minValue || Number(value) > maxValue), [value, minValue, maxValue]);
|
6
|
+
const handleChange = useCallback((event) => {
|
7
7
|
event.preventDefault();
|
8
|
-
|
8
|
+
const val = event.currentTarget.value;
|
9
9
|
if (val !== "" && minValue >= 0 && val.includes("-"))
|
10
10
|
return;
|
11
11
|
if (integerOnly) {
|
@@ -16,8 +16,8 @@ function useInteractions(props) {
|
|
16
16
|
return;
|
17
17
|
onChange(val);
|
18
18
|
}, [onChange, minValue, integerOnly]);
|
19
|
-
|
20
|
-
|
19
|
+
const handleBlur = useCallback(() => {
|
20
|
+
const excludedValue = [
|
21
21
|
null,
|
22
22
|
undefined,
|
23
23
|
".",
|
@@ -27,9 +27,9 @@ function useInteractions(props) {
|
|
27
27
|
"null",
|
28
28
|
"undefined"
|
29
29
|
];
|
30
|
-
|
30
|
+
const strVal = String(value).trim();
|
31
31
|
if (strVal !== null && strVal.lastIndexOf(".") === strVal.length - 1) {
|
32
|
-
|
32
|
+
const newValue = strVal.substring(0, String(value).length - 1);
|
33
33
|
onChange(newValue);
|
34
34
|
}
|
35
35
|
else if (excludedValue.includes(strVal)) {
|
@@ -39,19 +39,19 @@ function useInteractions(props) {
|
|
39
39
|
onChange(Number(strVal).toString());
|
40
40
|
}
|
41
41
|
}, [value, onChange]);
|
42
|
-
|
42
|
+
const onOpenTooltip = useCallback(() => {
|
43
43
|
setTooltipOpen(true);
|
44
44
|
}, []);
|
45
|
-
|
45
|
+
const onCloseTooltip = useCallback(() => {
|
46
46
|
setTooltipOpen(false);
|
47
47
|
}, []);
|
48
48
|
return {
|
49
|
-
exceedError
|
50
|
-
tooltipOpen
|
51
|
-
handleBlur
|
52
|
-
handleChange
|
53
|
-
onOpenTooltip
|
54
|
-
onCloseTooltip
|
49
|
+
exceedError,
|
50
|
+
tooltipOpen,
|
51
|
+
handleBlur,
|
52
|
+
handleChange,
|
53
|
+
onOpenTooltip,
|
54
|
+
onCloseTooltip
|
55
55
|
};
|
56
56
|
}
|
57
57
|
export default useInteractions;
|
@@ -1,42 +1,20 @@
|
|
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 } from "react/jsx-runtime";
|
24
2
|
import { useMemo } from "react";
|
25
3
|
import TextField from "@mui/material/TextField";
|
26
4
|
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
27
5
|
import useCustomTheme from "../useCustomTheme";
|
28
6
|
function ConfirmPassword(props) {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if (
|
7
|
+
const { password, helperText = "Passwords do not match", value, label = "Confirm Password", name = "confirmPassword", variant = "outlined", margin = "dense", disabled, primaryColor, secondaryColor, onChange, ...rest } = props;
|
8
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
9
|
+
const isMatched = useMemo(() => {
|
10
|
+
if (value?.length > 0) {
|
33
11
|
return password === value;
|
34
12
|
}
|
35
13
|
return true;
|
36
14
|
}, [value, password]);
|
37
|
-
return (_jsx(ThemeProvider,
|
15
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(TextField, { error: !isMatched, label: label, value: value, variant: variant, margin: margin, disabled: disabled, type: "password", size: "small", helperText: !isMatched && helperText, onChange: event => {
|
38
16
|
event.preventDefault();
|
39
17
|
onChange(event.target.value);
|
40
|
-
}, fullWidth: true, required: true
|
18
|
+
}, fullWidth: true, required: true, ...rest }) }));
|
41
19
|
}
|
42
20
|
export default ConfirmPassword;
|
@@ -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, Fragment as _Fragment } from "react/jsx-runtime";
|
24
2
|
import { useMemo } from "react";
|
25
3
|
import TextField from "@mui/material/TextField";
|
@@ -27,11 +5,11 @@ import Typography from "@mui/material/Typography";
|
|
27
5
|
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
28
6
|
import useCustomTheme from "../useCustomTheme";
|
29
7
|
export function onValidatePassword(password) {
|
30
|
-
|
8
|
+
const reg = /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~a-zA-z0-9]{8,})$/;
|
31
9
|
return reg.test(password);
|
32
10
|
}
|
33
11
|
function Password(props) {
|
34
|
-
|
12
|
+
const { strategies = {
|
35
13
|
uppercaseLetter: { label: "1 Uppercase Letter", regex: /[A-Z]+/ },
|
36
14
|
lowercaseLetter: { label: "1 Lowercase Letter", regex: /[a-z]+/ },
|
37
15
|
specialCharacter: {
|
@@ -40,17 +18,17 @@ function Password(props) {
|
|
40
18
|
},
|
41
19
|
number: { label: "1 Number", regex: /\d+/ },
|
42
20
|
minimum8: { label: "Minimum 8 characters", regex: /.{8,}/ }
|
43
|
-
}
|
44
|
-
|
45
|
-
|
46
|
-
if (
|
21
|
+
}, successColor = "green", value, error, primaryColor, secondaryColor, onValidate, onChange, ...rest } = props;
|
22
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
23
|
+
const isValidPassword = useMemo(() => {
|
24
|
+
if (value?.length > 0) {
|
47
25
|
return onValidate ? onValidate(value) : onValidatePassword(value);
|
48
26
|
}
|
49
27
|
return true;
|
50
28
|
}, [value, onValidate, onValidatePassword]);
|
51
|
-
|
52
|
-
|
53
|
-
|
29
|
+
const helperTextColor = useMemo(() => {
|
30
|
+
const textColors = Object.keys(strategies).reduce((temp, key) => {
|
31
|
+
const { regex } = strategies[key];
|
54
32
|
if (value === "") {
|
55
33
|
temp[key] = undefined;
|
56
34
|
}
|
@@ -64,15 +42,15 @@ function Password(props) {
|
|
64
42
|
}, {});
|
65
43
|
return textColors;
|
66
44
|
}, [value, strategies]);
|
67
|
-
|
68
|
-
return (_jsx(_Fragment, { children: Object.keys(strategies).map(
|
69
|
-
|
70
|
-
return (_jsx(Typography,
|
45
|
+
const helperText = useMemo(() => {
|
46
|
+
return (_jsx(_Fragment, { children: Object.keys(strategies).map(key => {
|
47
|
+
const { label } = strategies[key];
|
48
|
+
return (_jsx(Typography, { component: "li", variant: "caption", style: { color: helperTextColor[key] }, children: label }, key));
|
71
49
|
}) }));
|
72
50
|
}, [helperTextColor, strategies]);
|
73
|
-
return (_jsx(ThemeProvider,
|
51
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(TextField, { error: !isValidPassword || error, helperText: helperText, type: "password", label: "Password", size: "small", margin: "dense", value: value, onChange: event => {
|
74
52
|
event.preventDefault();
|
75
53
|
onChange(event.target.value);
|
76
|
-
}, fullWidth: true, required: true
|
54
|
+
}, fullWidth: true, required: true, ...rest }) }));
|
77
55
|
}
|
78
56
|
export default Password;
|
@@ -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 } from "react/jsx-runtime";
|
24
2
|
import { useRifm } from "rifm";
|
25
3
|
import Typography from "@mui/material/Typography";
|
@@ -29,38 +7,38 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
|
29
7
|
import useInteractions from "./useInteractions";
|
30
8
|
import useCustomTheme from "../useCustomTheme";
|
31
9
|
export function onValidatePhone(str) {
|
32
|
-
|
10
|
+
const reg = /^\(\d{3}\)\s?\d{3}\s?-\s?\d{4}$/g;
|
33
11
|
return reg.test(str);
|
34
12
|
}
|
35
13
|
export function phoneFormat(str) {
|
36
|
-
|
37
|
-
|
38
|
-
return chars.reduce(
|
14
|
+
const digits = (str.match(/\d+/g) || []).join("");
|
15
|
+
const chars = digits.split("");
|
16
|
+
return chars.reduce((prev, curr, index) => {
|
39
17
|
if (index === 3) {
|
40
|
-
return
|
18
|
+
return `${prev}) ${curr}`;
|
41
19
|
}
|
42
20
|
else if (index === 6) {
|
43
|
-
return
|
21
|
+
return `${prev}-${curr}`;
|
44
22
|
}
|
45
23
|
else {
|
46
|
-
return
|
24
|
+
return `${prev}${curr}`;
|
47
25
|
}
|
48
|
-
},
|
26
|
+
}, `(`);
|
49
27
|
}
|
50
28
|
function PhoneInput(props) {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
29
|
+
const { value, error, endAdornment, primaryColor, secondaryColor, helperText = "Please enter a valid phone number", onChange, onValidate, ...rest } = props;
|
30
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
31
|
+
const { valLength, addMask } = useInteractions({ value });
|
32
|
+
const rifm = useRifm({
|
55
33
|
mask: true,
|
56
34
|
value: String(value),
|
57
|
-
onChange
|
35
|
+
onChange,
|
58
36
|
replace: addMask,
|
59
37
|
format: phoneFormat
|
60
38
|
});
|
61
|
-
return (_jsx(ThemeProvider,
|
62
|
-
startAdornment: (_jsx(InputAdornment,
|
63
|
-
endAdornment
|
39
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(TextField, { value: rifm.value, InputProps: {
|
40
|
+
startAdornment: (_jsx(InputAdornment, { position: "start", children: _jsx(Typography, { sx: { fontSize: 16, fontWeight: 500 }, children: "+1" }) })),
|
41
|
+
endAdornment
|
64
42
|
}, onChange: rifm.onChange, helperText: valLength > 0 &&
|
65
43
|
(onValidate ? !onValidate(rifm.value) : !onValidatePhone(rifm.value))
|
66
44
|
? helperText
|
@@ -68,6 +46,6 @@ function PhoneInput(props) {
|
|
68
46
|
(valLength > 0 &&
|
69
47
|
(onValidate
|
70
48
|
? !onValidate(rifm.value)
|
71
|
-
: !onValidatePhone(rifm.value)))
|
49
|
+
: !onValidatePhone(rifm.value))), ...rest }) }));
|
72
50
|
}
|
73
51
|
export default PhoneInput;
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
2
2
|
function useInteractions(props) {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
return
|
3
|
+
const { value } = props;
|
4
|
+
const addMask = useCallback((str) => {
|
5
|
+
const digits = (str.match(/\d+/g) || []).join("");
|
6
|
+
const areaCode = digits.slice(0, 3).padEnd(3, "_");
|
7
|
+
const prefixCode = digits.slice(3, 6).padEnd(3, "_");
|
8
|
+
const subscriber = digits.slice(6, 10).padEnd(4, "_");
|
9
|
+
return `(${areaCode}) ${prefixCode}-${subscriber}`;
|
10
10
|
}, []);
|
11
|
-
|
12
|
-
|
11
|
+
const valLength = useMemo(() => {
|
12
|
+
const digitsArr = String(value).match(/\d/g);
|
13
13
|
return digitsArr ? digitsArr.length : 0;
|
14
14
|
}, [value]);
|
15
|
-
return { valLength
|
15
|
+
return { valLength, addMask };
|
16
16
|
}
|
17
17
|
export default useInteractions;
|