@symply.io/basic-components 1.0.0-beta.2 → 1.0.0-beta.4

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.
@@ -24,14 +24,14 @@ function Content(props) {
24
24
  var children = props.children, title = props.title, desc = props.desc, _a = props.color, color = _a === void 0 ? "primary" : _a, loading = props.loading, disabled = props.disabled, buttons = props.buttons, _b = props.submitText, submitText = _b === void 0 ? "Save" : _b, _c = props.cancelText, cancelText = _c === void 0 ? "Cancel" : _c, _d = props.showTopRightCloseButton, showTopRightCloseButton = _d === void 0 ? false : _d, _e = props.hideBottomButtons, hideBottomButtons = _e === void 0 ? false : _e, _f = props.noForm, noForm = _f === void 0 ? false : _f, onClose = props.onClose, onSubmit = props.onSubmit;
25
25
  var theme = useTheme();
26
26
  return (_jsxs(_Fragment, { children: [_jsxs(DialogTitle, __assign({ id: "form-dialog-title", sx: {
27
- "& > h6": {
28
- fontWeight: "700",
29
- },
30
- } }, { children: [title, showTopRightCloseButton ? (_jsx(IconButton, __assign({ "aria-label": "close", onClick: onClose, sx: {
27
+ "& > span": {
28
+ fontWeight: "700!important"
29
+ }
30
+ } }, { children: [_jsx("span", { children: title }), showTopRightCloseButton ? (_jsx(IconButton, __assign({ "aria-label": "close", onClick: onClose, sx: {
31
31
  position: "absolute",
32
32
  right: 8,
33
33
  top: 8,
34
- color: theme.palette.grey[500],
34
+ color: theme.palette.grey[500]
35
35
  } }, { children: _jsx(CloseIcon, {}) }))) : null] })), _jsxs(DialogContent, __assign({ sx: { paddingTop: theme.spacing(1.25) } }, { children: [desc && _jsx(DialogContentText, { children: desc }), Boolean(children) && cloneElement(children)] })), !hideBottomButtons && (_jsx(DialogActions, __assign({ sx: { padding: theme.spacing(1.25) } }, { children: _jsx(Grid, __assign({ container: true, spacing: 2, justifyContent: "flex-end", alignItems: "center", sx: { margin: 0 } }, { children: buttons || (_jsxs(_Fragment, { children: [_jsx(Grid, __assign({ item: true, xs: 12, md: 3, xl: 2 }, { children: _jsx(Button, __assign({ onClick: onClose, variant: "outlined", color: color, disabled: loading, fullWidth: true }, { children: cancelText })) })), _jsx(Grid, __assign({ item: true, xs: 12, md: 3, xl: 2 }, { children: _jsx(Button, __assign({ type: noForm ? "button" : "submit", onClick: noForm ? onSubmit : undefined, variant: "contained", color: color, disabled: loading || disabled, fullWidth: true }, { children: submitText })) }))] })) })) })))] }));
36
36
  }
37
37
  export default Content;
@@ -1,5 +1,5 @@
1
1
  import { DateInputprops } from "./types";
2
2
  export declare function MonthDayYearFormat(str: string): string;
3
- export declare function verifyDate(dateString: string): boolean;
3
+ export declare function onValidateDate(dateString: string): boolean;
4
4
  declare function FullDateInput(props: DateInputprops): JSX.Element;
5
5
  export default FullDateInput;
@@ -30,7 +30,7 @@ export function MonthDayYearFormat(str) {
30
30
  }
31
31
  }, "");
32
32
  }
33
- export function verifyDate(dateString) {
33
+ export function onValidateDate(dateString) {
34
34
  var reg = /^((((0[1,3,5,7,8]{1})|(1[0,2]{1}))\s?\/\s?((0[1-9]{1})|([1-2]{1}\d{1})|(3[0-1]{1})))|(((0[4,6,9]{1})|(11))\s?\/\s?((0[1-9]{1})|([1-2]{1}\d{1})|(30)))|((02)\s?\/\s?(0[1-9]{1}|[1-2]{1}\d{1})))\s?\/\s?\d{4}$/g;
35
35
  if (reg.test(dateString)) {
36
36
  var tmpArr = dateString.split("/");
@@ -46,7 +46,7 @@ export function verifyDate(dateString) {
46
46
  return false;
47
47
  }
48
48
  function FullDateInput(props) {
49
- var name = props.name, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, value = props.value, _a = props.margin, margin = _a === void 0 ? "normal" : _a, error = props.error, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid date" : _b, verifyFn = props.verifyFn, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
49
+ var name = props.name, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, value = props.value, _a = props.margin, margin = _a === void 0 ? "normal" : _a, error = props.error, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid date" : _b, onValidate = props.onValidate, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
50
50
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
51
51
  var _c = useInteractions({ value: value }), valLength = _c.valLength, addMask = _c.addMask;
52
52
  var rifm = useRifm({
@@ -57,7 +57,9 @@ function FullDateInput(props) {
57
57
  format: MonthDayYearFormat
58
58
  });
59
59
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, { placeholder: "MM / DD / YYYY", error: error ||
60
- (valLength > 0 && (verifyFn ? !verifyFn(value) : !verifyDate(value))), margin: margin, name: name, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 && (verifyFn ? !verifyFn(value) : !verifyDate(value))
60
+ (valLength > 0 &&
61
+ (onValidate ? !onValidate(value) : !onValidateDate(value))), margin: margin, name: name, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 &&
62
+ (onValidate ? !onValidate(value) : !onValidateDate(value))
61
63
  ? helperText
62
64
  : "", onFocus: onFocus, onBlur: onBlur, InputLabelProps: {
63
65
  shrink: true
@@ -4,7 +4,7 @@ export interface DateInputprops {
4
4
  onChange: (value: string) => void;
5
5
  onFocus?: () => void;
6
6
  onBlur?: () => void;
7
- verifyFn?: (value?: string) => boolean;
7
+ onValidate?: (value?: string) => boolean;
8
8
  helperText?: string;
9
9
  margin?: "none" | "normal" | "dense" | undefined;
10
10
  error?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { DateInputprops } from "./types";
2
2
  export declare function MonthDayFormat(str: string): string;
3
- export declare function verifyMonthDayDate(monthDayString: string): boolean;
3
+ export declare function onValidateMonthDay(monthDayString: string): boolean;
4
4
  declare function MonthDayInput(props: DateInputprops): JSX.Element;
5
5
  export default MonthDayInput;
@@ -27,12 +27,12 @@ export function MonthDayFormat(str) {
27
27
  }
28
28
  }, "");
29
29
  }
30
- export function verifyMonthDayDate(monthDayString) {
30
+ export function onValidateMonthDay(monthDayString) {
31
31
  var reg = /^((((0[1,3,5,7,8]{1})|(1[0,2]{1}))\s?\/\s?((0[1-9]{1})|([1-2]{1}\d{1})|(3[0-1]{1})))|(((0[4,6,9]{1})|(11))\s?\/\s?((0[1-9]{1})|([1-2]{1}\d{1})|(30)))|((02)\s?\/\s?(0[1-9]{1})|([1-2]{1}\d{1})))$/g;
32
32
  return reg.test(monthDayString);
33
33
  }
34
34
  function MonthDayInput(props) {
35
- var name = props.name, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, value = props.value, _a = props.margin, margin = _a === void 0 ? "normal" : _a, error = props.error, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid date" : _b, verifyFn = props.verifyFn, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
35
+ var name = props.name, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, value = props.value, _a = props.margin, margin = _a === void 0 ? "normal" : _a, error = props.error, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid date" : _b, onValidate = props.onValidate, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
36
36
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
37
37
  var _c = useInteractions({ value: value }), valLength = _c.valLength, addMask = _c.addMask;
38
38
  var rifm = useRifm({
@@ -44,8 +44,8 @@ function MonthDayInput(props) {
44
44
  });
45
45
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, { placeholder: "MM / DD", error: error ||
46
46
  (valLength > 0 &&
47
- (verifyFn ? !verifyFn(value) : !verifyMonthDayDate(value))), margin: margin, name: name, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 &&
48
- (verifyFn ? !verifyFn(value) : !verifyMonthDayDate(value))
47
+ (onValidate ? !onValidate(value) : !onValidateMonthDay(value))), margin: margin, name: name, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 &&
48
+ (onValidate ? !onValidate(value) : !onValidateMonthDay(value))
49
49
  ? helperText
50
50
  : "", onFocus: onFocus, onBlur: onBlur, InputLabelProps: {
51
51
  shrink: true
@@ -4,7 +4,7 @@ export interface DateInputprops {
4
4
  onChange: (value: string) => void;
5
5
  onFocus?: () => void;
6
6
  onBlur?: () => void;
7
- verifyFn?: (value?: string) => boolean;
7
+ onValidate?: (value?: string) => boolean;
8
8
  helperText?: string;
9
9
  margin?: "none" | "normal" | "dense" | undefined;
10
10
  error?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { DateInputprops } from "./types";
2
2
  export declare function MonthYearFormat(str: string): string;
3
- export declare function verifyMonthYearDate(monthYearString: string): boolean;
3
+ export declare function onValidateMonthYear(monthYearString: string): boolean;
4
4
  declare function MonthYearInput(props: DateInputprops): JSX.Element;
5
5
  export default MonthYearInput;
@@ -27,13 +27,13 @@ export function MonthYearFormat(str) {
27
27
  }
28
28
  }, "");
29
29
  }
30
- export function verifyMonthYearDate(monthYearString) {
30
+ export function onValidateMonthYear(monthYearString) {
31
31
  var reg = /^(((0[1-9]{1})|(1[0-2]{1}))\s?\/\s?([1-2]{1}\d{3}))$/g;
32
32
  reg.lastIndex = 0;
33
33
  return reg.test(monthYearString);
34
34
  }
35
35
  function MonthYearInput(props) {
36
- var name = props.name, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, value = props.value, _a = props.margin, margin = _a === void 0 ? "normal" : _a, error = props.error, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid date" : _b, verifyFn = props.verifyFn, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
36
+ var name = props.name, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, value = props.value, _a = props.margin, margin = _a === void 0 ? "normal" : _a, error = props.error, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid date" : _b, onValidate = props.onValidate, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
37
37
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
38
38
  var _c = useInteractions({ value: value }), valLength = _c.valLength, addMask = _c.addMask;
39
39
  var rifm = useRifm({
@@ -45,8 +45,8 @@ function MonthYearInput(props) {
45
45
  });
46
46
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, { placeholder: "MM / YYYY", error: error ||
47
47
  (valLength > 0 &&
48
- (verifyFn ? !verifyFn(value) : !verifyMonthYearDate(value))), margin: margin, name: name, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 &&
49
- (verifyFn ? !verifyFn(value) : !verifyMonthYearDate(value))
48
+ (onValidate ? !onValidate(value) : !onValidateMonthYear(value))), margin: margin, name: name, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 &&
49
+ (onValidate ? !onValidate(value) : !onValidateMonthYear(value))
50
50
  ? helperText
51
51
  : "", onFocus: onFocus, onBlur: onBlur, InputLabelProps: {
52
52
  shrink: true
@@ -4,7 +4,7 @@ export interface DateInputprops {
4
4
  onChange: (value: string) => void;
5
5
  onFocus?: () => void;
6
6
  onBlur?: () => void;
7
- verifyFn?: (value?: string) => boolean;
7
+ onValidate?: (value?: string) => boolean;
8
8
  helperText?: string;
9
9
  margin?: "none" | "normal" | "dense" | undefined;
10
10
  error?: boolean;
@@ -29,8 +29,8 @@ function HeaderButtons(props) {
29
29
  return (_jsx(Grid, __assign({ item: true, xs: isLessThanSm ? 12 : undefined, style: { textAlign: "end" } }, { children: _jsx(Button, __assign({ fullWidth: isLessThanSm, variant: variant, onClick: onClick, color: color, size: isLessThanSm ? "small" : size, startIcon: startIcon, endIcon: endIcon, disabled: disabled }, { children: text })) }), text));
30
30
  }
31
31
  case HeaderButtonCategory.IconButton: {
32
- var title = button.title, onClick = button.onClick, color = button.color, _b = button.size, size = _b === void 0 ? "medium" : _b, icon = button.icon;
33
- return (_jsx(Grid, __assign({ item: true, style: { textAlign: "end" } }, { children: _jsx(Fab, __assign({ onClick: onClick, color: color, title: title, size: isLessThanSm ? "small" : size }, { children: icon })) }), title));
32
+ var title = button.title, onClick = button.onClick, color = button.color, _b = button.size, size = _b === void 0 ? "medium" : _b, icon = button.icon, disabled = button.disabled, variant = button.variant;
33
+ return (_jsx(Grid, __assign({ item: true, style: { textAlign: "end" } }, { children: _jsx(Fab, __assign({ onClick: onClick, color: color, title: title, size: isLessThanSm ? "small" : size, disabled: disabled, variant: variant }, { children: icon })) }), title));
34
34
  }
35
35
  case HeaderButtonCategory.MenuButton: {
36
36
  var btns = button.buttons, buttonText = button.buttonText, disabled = button.disabled, variant = button.variant, size = button.size;
@@ -1,6 +1,7 @@
1
1
  import { ReactElement } from "react";
2
2
  import { ButtonProps } from "@mui/material/Button";
3
3
  import { IconButtonProps } from "@mui/material/IconButton";
4
+ import { FabProps } from "@mui/material/Fab";
4
5
  import { MenuButtonGroupProps } from "../MenuButtonGroup";
5
6
  export declare enum HeaderButtonCategory {
6
7
  IconButton = "icon",
@@ -21,7 +22,9 @@ interface HeaderTextButtonProps {
21
22
  interface HeaderIconButtonProps {
22
23
  title: string;
23
24
  icon: ReactElement;
25
+ disabled?: boolean;
24
26
  type: HeaderButtonCategory.IconButton;
27
+ variant?: FabProps["variant"];
25
28
  color?: IconButtonProps["color"];
26
29
  size?: IconButtonProps["size"];
27
30
  onClick: IconButtonProps["onClick"];
@@ -1,6 +1,6 @@
1
1
  import { FeinInputProps } from "./types";
2
2
  export declare function FeinInputFormat(str: string): string;
3
- export declare function verifyFein(feinString: string): boolean;
3
+ export declare function onValidateFein(feinString: string): boolean;
4
4
  declare function FeinInput(props: FeinInputProps): JSX.Element;
5
5
  export default FeinInput;
6
6
  export * from "./types";
@@ -38,12 +38,12 @@ export function FeinInputFormat(str) {
38
38
  }
39
39
  }, "");
40
40
  }
41
- export function verifyFein(feinString) {
41
+ export function onValidateFein(feinString) {
42
42
  var reg = /^\d{2}\s?-\s?\d{7}$/g;
43
43
  return reg.test(feinString);
44
44
  }
45
45
  function FeinInput(props) {
46
- var value = props.value, _a = props.error, error = _a === void 0 ? false : _a, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid FEIN" : _b, onChange = props.onChange, verifyFn = props.verifyFn, onFocus = props.onFocus, onBlur = props.onBlur, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["value", "error", "helperText", "onChange", "verifyFn", "onFocus", "onBlur", "primaryColor", "secondaryColor"]);
46
+ var value = props.value, _a = props.error, error = _a === void 0 ? false : _a, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid FEIN" : _b, onBlur = props.onBlur, onFocus = props.onFocus, onChange = props.onChange, onValidate = props.onValidate, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["value", "error", "helperText", "onBlur", "onFocus", "onChange", "onValidate", "primaryColor", "secondaryColor"]);
47
47
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
48
48
  var _c = useInteractions({ value: value }), valLength = _c.valLength, addMask = _c.addMask;
49
49
  var rifm = useRifm({
@@ -54,7 +54,9 @@ function FeinInput(props) {
54
54
  format: FeinInputFormat
55
55
  });
56
56
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, __assign({ value: rifm.value, onChange: rifm.onChange, error: error ||
57
- (valLength > 0 && (verifyFn ? !verifyFn(value) : verifyFein(value))), helperText: valLength > 0 && (verifyFn ? !verifyFn(value) : verifyFein(value))
57
+ (valLength > 0 &&
58
+ (onValidate ? !onValidate(value) : onValidateFein(value))), helperText: valLength > 0 &&
59
+ (onValidate ? !onValidate(value) : onValidateFein(value))
58
60
  ? helperText
59
61
  : "", onFocus: function (event) {
60
62
  if (onFocus) {
@@ -2,7 +2,7 @@ import { CSSProperties } from "react";
2
2
  import { TextFieldProps } from "@mui/material/TextField";
3
3
  export interface FeinInputProps extends Omit<TextFieldProps, "onChange"> {
4
4
  onChange: (value: string) => void;
5
- verifyFn?: (value?: string) => boolean;
5
+ onValidate?: (value?: string) => boolean;
6
6
  value: string;
7
7
  primaryColor?: CSSProperties["color"];
8
8
  secondaryColor?: CSSProperties["color"];
@@ -13,7 +13,8 @@ export interface PasswordProps extends Omit<TextFieldProps, "onChange"> {
13
13
  primaryColor?: CSSProperties["color"];
14
14
  secondaryColor?: CSSProperties["color"];
15
15
  onChange: (value: string) => void;
16
- onVerify?: (value: string) => boolean;
16
+ onValidate?: (value: string) => boolean;
17
17
  }
18
+ export declare function onValidatePassword(password: string): boolean;
18
19
  declare function Password(props: PasswordProps): JSX.Element;
19
20
  export default Password;
@@ -26,6 +26,10 @@ import TextField from "@mui/material/TextField";
26
26
  import Typography from "@mui/material/Typography";
27
27
  import ThemeProvider from "@mui/material/styles/ThemeProvider";
28
28
  import useCustomTheme from "../useCustomTheme";
29
+ export function onValidatePassword(password) {
30
+ var reg = /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~a-zA-z0-9]{8,})$/;
31
+ return reg.test(password);
32
+ }
29
33
  function Password(props) {
30
34
  var _a = props.strategies, strategies = _a === void 0 ? {
31
35
  uppercaseLetter: { label: "1 Uppercase Letter", regex: /[A-Z]+/ },
@@ -36,17 +40,14 @@ function Password(props) {
36
40
  },
37
41
  number: { label: "1 Number", regex: /\d+/ },
38
42
  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) {
40
- var reg = /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~a-zA-z0-9]{8,})$/;
41
- return reg.test(password);
42
- } : _c, onChange = props.onChange, rest = __rest(props, ["strategies", "successColor", "value", "error", "primaryColor", "secondaryColor", "onVerify", "onChange"]);
43
+ } : _a, _b = props.successColor, successColor = _b === void 0 ? "green" : _b, value = props.value, error = props.error, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onValidate = props.onValidate, onChange = props.onChange, rest = __rest(props, ["strategies", "successColor", "value", "error", "primaryColor", "secondaryColor", "onValidate", "onChange"]);
43
44
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
44
45
  var isValidPassword = useMemo(function () {
45
46
  if ((value === null || value === void 0 ? void 0 : value.length) > 0) {
46
- return onVerify(value);
47
+ return onValidate ? onValidate(value) : onValidatePassword(value);
47
48
  }
48
49
  return true;
49
- }, [value, onVerify]);
50
+ }, [value, onValidate, onValidatePassword]);
50
51
  var helperTextColor = useMemo(function () {
51
52
  var textColors = Object.keys(strategies).reduce(function (temp, key) {
52
53
  var regex = strategies[key].regex;
@@ -7,7 +7,9 @@ export interface PhoneInputProps extends Omit<TextFieldProps, "onChange"> {
7
7
  primaryColor?: CSSProperties["color"];
8
8
  secondaryColor?: CSSProperties["color"];
9
9
  onChange: (val: string) => void;
10
+ onValidate?: (val: string) => boolean;
10
11
  }
12
+ export declare function onValidatePhone(str: string): boolean;
11
13
  export declare function phoneFormat(str: string): string;
12
14
  declare function PhoneInput(props: PhoneInputProps): JSX.Element;
13
15
  export default PhoneInput;
@@ -28,6 +28,10 @@ import TextField from "@mui/material/TextField";
28
28
  import ThemeProvider from "@mui/material/styles/ThemeProvider";
29
29
  import useInteractions from "./useInteractions";
30
30
  import useCustomTheme from "../useCustomTheme";
31
+ export function onValidatePhone(str) {
32
+ var reg = /^\(\d{3}\)\s?\d{3}\s?-\s?\d{4}$/g;
33
+ return reg.test(str);
34
+ }
31
35
  export function phoneFormat(str) {
32
36
  var digits = (str.match(/\d+/g) || []).join("");
33
37
  var chars = digits.split("");
@@ -44,9 +48,9 @@ export function phoneFormat(str) {
44
48
  }, "(");
45
49
  }
46
50
  function PhoneInput(props) {
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"]);
51
+ var value = props.value, error = props.error, endAdornment = props.endAdornment, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, _a = props.helperText, helperText = _a === void 0 ? "Please enter a valid phone number" : _a, onChange = props.onChange, onValidate = props.onValidate, rest = __rest(props, ["value", "error", "endAdornment", "primaryColor", "secondaryColor", "helperText", "onChange", "onValidate"]);
48
52
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
49
- var addMask = useInteractions({ value: value }).addMask;
53
+ var _b = useInteractions({ value: value }), valLength = _b.valLength, addMask = _b.addMask;
50
54
  var rifm = useRifm({
51
55
  mask: true,
52
56
  value: String(value),
@@ -57,6 +61,13 @@ function PhoneInput(props) {
57
61
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, __assign({ value: rifm.value, InputProps: {
58
62
  startAdornment: (_jsx(InputAdornment, __assign({ position: "start" }, { children: _jsx(Typography, __assign({ variant: "body2" }, { children: "+1" })) }))),
59
63
  endAdornment: endAdornment
60
- }, onChange: rifm.onChange }, rest)) })));
64
+ }, onChange: rifm.onChange, helperText: valLength > 0 &&
65
+ (onValidate ? !onValidate(rifm.value) : !onValidatePhone(rifm.value))
66
+ ? helperText
67
+ : "", error: error ||
68
+ (valLength > 0 &&
69
+ (onValidate
70
+ ? !onValidate(rifm.value)
71
+ : !onValidatePhone(rifm.value))) }, rest)) })));
61
72
  }
62
73
  export default PhoneInput;
package/README.md CHANGED
@@ -116,7 +116,7 @@ import { Autocomplete } from '@symply.io/basic-components/';
116
116
  import Autocomplete from '@symply.io/basic-components/Autocomplete';
117
117
  ```
118
118
 
119
- <h5>Option Props (AutocompleteOptionType)</h5>
119
+ <h5>Option Props (IOption)</h5>
120
120
 
121
121
  | Name | Type | Default | Required | Description |
122
122
  | ------ | ------- | ------- | -------- | -------------------------- |
@@ -125,12 +125,12 @@ import Autocomplete from '@symply.io/basic-components/Autocomplete';
125
125
 
126
126
  <h5>Props</h5>
127
127
 
128
- | Name | Type | Default | Required | Description |
129
- | -------- | ------------------------------- | ------- | -------- | ------------------------------------------------------------ |
130
- | multiple | bool | false | false | If `true`, `value` must be an array and the menu will support multiple selections. |
131
- | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: Array<AutocompleteOptionType)|AutocompleteOptionType|null => void`<br/>*value:* The value of the `Input` element. |
132
- | options | Array\<AutocompleteOptionType\> | | true | Array of suggestion options. |
133
- | value | AutocompleteOptionType | | true | The value of the `Input` element. |
128
+ | Name | Type | Default | Required | Description |
129
+ | -------- | ---------------------- | ------- | -------- | ------------------------------------------------------------ |
130
+ | multiple | bool | false | false | If `true`, `value` must be an array and the menu will support multiple selections. |
131
+ | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: Array<IOption|string>|IOption|string|null) => void`<br/>*value:* The value of the `Input` element. |
132
+ | options | Array<IOption\|string> | | true | Array of suggestion options. |
133
+ | value | string | | true | The value of the `Input` element. |
134
134
 
135
135
 
136
136
 
@@ -148,7 +148,7 @@ import { AutocompleteWithFilter } from '@symply.io/basic-components/';
148
148
  import AutocompleteWithFilter from '@symply.io/basic-components/AutocompleteWithFilter';
149
149
  ```
150
150
 
151
- <h5>Option Props (AutocompleteOptionType)</h5>
151
+ <h5>Option Props (IOption)</h5>
152
152
 
153
153
  | Name | Type | Default | Required | Description |
154
154
  | ------ | ------- | ------- | -------- | -------------------------- |
@@ -157,13 +157,13 @@ import AutocompleteWithFilter from '@symply.io/basic-components/AutocompleteWith
157
157
 
158
158
  <h5>Props</h5>
159
159
 
160
- | Name | Type | Default | Required | Description |
161
- | -------------------- | ------------------------------- | ------- | -------- | ------------------------------------------------------------ |
162
- | disableCloseOnSelect | bool | false | false | If `true`, the popup won't close when a value is selected. |
163
- | multiple | bool | false | false | If `true`, `value` must be an array and the menu will support multiple selections. |
164
- | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: Array<AutocompleteOptionType)|AutocompleteOptionType|null => void`<br/>*value:* The value of the `Input` element. |
165
- | options | Array\<AutocompleteOptionType\> | | true | Array of suggestion options. |
166
- | value | AutocompleteOptionType | | true | The value of the `Input` element. |
160
+ | Name | Type | Default | Required | Description |
161
+ | -------------------- | ---------------------- | ------- | -------- | ------------------------------------------------------------ |
162
+ | disableCloseOnSelect | bool | false | false | If `true`, the popup won't close when a value is selected. |
163
+ | multiple | bool | false | false | If `true`, `value` must be an array and the menu will support multiple selections. |
164
+ | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: Array<IOption|string>|IOption|string|null) => void`<br/>*value:* The value of the `Input` element. |
165
+ | options | Array<IOption\|string> | | true | Array of suggestion options. |
166
+ | value | string | | true | The value of the `Input` element. |
167
167
 
168
168
 
169
169
 
@@ -311,8 +311,8 @@ import FullDateInput from '@symply.io/basic-components/DateInput/FullDateInput';
311
311
  | onBlur | func | | false | Callback fired when the `input` is blurred. Notice that the first argument (event) might be undefined. |
312
312
  | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
313
313
  | onFocus | func | | false | Callback fired when the `input` is focused. |
314
+ | onValidate | func | | false | Customized validation function. |
314
315
  | value | string | | true | The value of the `Input` element. |
315
- | verifyFn | func | | false | Customized verification function. |
316
316
 
317
317
  <h4>MonthDayInput</h4>
318
318
 
@@ -339,8 +339,8 @@ import MonthDayInput from '@symply.io/basic-components/DateInput/MonthDayInput';
339
339
  | onBlur | func | | false | Callback fired when the `input` is blurred. Notice that the first argument (event) might be undefined. |
340
340
  | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
341
341
  | onFocus | func | | false | Callback fired when the `input` is focused. |
342
+ | onValidate | func | | false | Customized validation function. |
342
343
  | value | string | | true | The value of the `Input` element. |
343
- | verifyFn | func | | false | Customized verification function. |
344
344
 
345
345
  <h4>MonthYearInput</h4>
346
346
 
@@ -367,8 +367,8 @@ import MonthYearInput from '@symply.io/basic-components/DateInput/MonthYearInput
367
367
  | onBlur | func | | false | Callback fired when the `input` is blurred. Notice that the first argument (event) might be undefined. |
368
368
  | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
369
369
  | onFocus | func | | false | Callback fired when the `input` is focused. |
370
+ | onValidate | func | | false | Customized validation function. |
370
371
  | value | string | | true | The value of the `Input` element. |
371
- | verifyFn | func | | false | Customized verification function. |
372
372
 
373
373
 
374
374
 
@@ -415,11 +415,11 @@ import FeinInput from '@symply.io/basic-components/FeinInput';
415
415
 
416
416
  <h5>Props</h5>
417
417
 
418
- | Name | Type | Default | Required | Description |
419
- | -------- | ------ | ------- | -------- | ------------------------------------------------------------ |
420
- | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
421
- | value | string | | true | The value of the `Input` element. |
422
- | verifyFn | func | | false | Customized verification function. |
418
+ | Name | Type | Default | Required | Description |
419
+ | ---------- | ------ | ------- | -------- | ------------------------------------------------------------ |
420
+ | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
421
+ | onValidate | func | | false | Customized validation function. |
422
+ | value | string | | true | The value of the `Input` element. |
423
423
 
424
424
 
425
425
 
@@ -637,7 +637,7 @@ import { ConfirmPassword } from '@symply.io/basic-components/PasswordInput';
637
637
  | Name | Type | Default | Required | Description |
638
638
  | ------------ | -------------------------------------------------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
639
639
  | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
640
- | onVerify | func | | false | Customized verify function when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
640
+ | onValidate | func | | false | Customized verify function when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
641
641
  | strategies | { [key: string]: { label: string, regex: RegExp }} | {<br />uppercaseLetter: { label: "1 Uppercase Letter", regex: /[A-Z]+/ },<br />lowercaseLetter: { label: "1 Lowercase Letter", regex: /[a-z]+/ },<br />specialCharacter: { label: "1 Special Character", regex: /[!"#$%&'()*+,-./:;<=>?@[\]^_`{}~]/ },<br />number: { label: "1 Number", regex: /\d+/ },<br />minimum8: { label: "Minimum 8 characters", regex: /.{8,}/ }<br />} | false | The strategies of the password |
642
642
  | successColor | Color | 'green' | false | The color of component when success. |
643
643
  | value | string | | true | The password value. |
@@ -672,6 +672,7 @@ import PhoneNumberInput from '@symply.io/basic-components/PhoneNumberInput';
672
672
  | ------------ | ------ | ------- | -------- | ------------------------------------------------------------ |
673
673
  | endAdornment | node | | false | An end adornment element for the `Input` element. |
674
674
  | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
675
+ | onValidate | func | | false | Customized validation function. |
675
676
  | value | string | | true | The value of the `Input` element. |
676
677
 
677
678
 
@@ -725,11 +726,11 @@ import SocialInput from '@symply.io/basic-components/SocialInput';
725
726
 
726
727
  <h5>Props</h5>
727
728
 
728
- | Name | Type | Default | Required | Description |
729
- | -------- | ------ | ------- | -------- | ------------------------------------------------------------ |
730
- | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
731
- | value | string | | true | The value of the `Input` element. |
732
- | verifyFn | func | | false | Customized verification function. |
729
+ | Name | Type | Default | Required | Description |
730
+ | ---------- | ------ | ------- | -------- | ------------------------------------------------------------ |
731
+ | onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
732
+ | onValidate | func | | false | Customized validation function. |
733
+ | value | string | | true | The value of the `Input` element. |
733
734
 
734
735
 
735
736
 
@@ -1,6 +1,6 @@
1
1
  import { SocialInputProps } from "./types";
2
2
  export declare function SocialInputFormat(str: string): string;
3
- export declare function verifySocial(socialString: string): boolean;
3
+ export declare function onValidateSocial(socialString: string): boolean;
4
4
  declare function SocialInput(props: SocialInputProps): JSX.Element;
5
5
  export default SocialInput;
6
6
  export * from "./types";
@@ -45,12 +45,12 @@ export function SocialInputFormat(str) {
45
45
  }
46
46
  }, "");
47
47
  }
48
- export function verifySocial(socialString) {
48
+ export function onValidateSocial(socialString) {
49
49
  var reg = /^\d{3}\s?-\s?\d{2}\s?-\s?\d{4}$/g;
50
50
  return reg.test(socialString);
51
51
  }
52
52
  function SocialInput(props) {
53
- var value = props.value, _a = props.helperText, helperText = _a === void 0 ? "Please enter a valid SSN" : _a, error = props.error, verifyFn = props.verifyFn, onChange = props.onChange, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["value", "helperText", "error", "verifyFn", "onChange", "primaryColor", "secondaryColor"]);
53
+ var value = props.value, _a = props.helperText, helperText = _a === void 0 ? "Please enter a valid SSN" : _a, error = props.error, onChange = props.onChange, onValidate = props.onValidate, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["value", "helperText", "error", "onChange", "onValidate", "primaryColor", "secondaryColor"]);
54
54
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
55
55
  var _b = useInteractions({
56
56
  value: value
@@ -62,11 +62,12 @@ function SocialInput(props) {
62
62
  replace: addMask,
63
63
  format: SocialInputFormat
64
64
  });
65
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, __assign({ helperText: valLength > 0 && (verifyFn ? !verifyFn(value) : !verifySocial(value))
65
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, __assign({ helperText: valLength > 0 &&
66
+ (onValidate ? !onValidate(value) : !onValidateSocial(value))
66
67
  ? helperText
67
68
  : "", value: rifm.value, onChange: rifm.onChange, type: visible ? "text" : "password", error: error ||
68
69
  (valLength > 0 &&
69
- (verifyFn ? !verifyFn(value) : !verifySocial(value))), InputProps: {
70
+ (onValidate ? !onValidate(value) : !onValidateSocial(value))), InputProps: {
70
71
  endAdornment: (_jsx(InputAdornment, __assign({ position: "end" }, { children: valLength === 9 && (_jsx(IconButton, __assign({ "aria-label": "Toggle SSN visibility", onClick: onSwitching }, { children: visible ? _jsx(Visibility, {}) : _jsx(VisibilityOff, {}) }))) })))
71
72
  }, InputLabelProps: {
72
73
  shrink: true
@@ -2,7 +2,7 @@ import { CSSProperties } from "react";
2
2
  import { TextFieldProps } from "@mui/material/TextField";
3
3
  export interface SocialInputProps extends Omit<TextFieldProps, "onChange"> {
4
4
  onChange: (value: string) => void;
5
- verifyFn?: (value?: string) => boolean;
5
+ onValidate?: (value?: string) => boolean;
6
6
  value: string;
7
7
  primaryColor?: CSSProperties["color"];
8
8
  secondaryColor?: CSSProperties["color"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",