@symply.io/basic-components 1.0.0-alpha.2 → 1.0.0-alpha.20

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.
Files changed (99) hide show
  1. package/AlertDialog/index.d.ts +0 -1
  2. package/AlertDialog/index.js +10 -9
  3. package/AlertDialog/types.d.ts +3 -1
  4. package/Autocomplete/index.d.ts +4 -0
  5. package/Autocomplete/index.js +38 -0
  6. package/Autocomplete/types.d.ts +15 -0
  7. package/Autocomplete/types.js +1 -0
  8. package/Autocomplete/useInteractions.d.ts +5 -0
  9. package/Autocomplete/useInteractions.js +9 -0
  10. package/AutocompleteWithFilter/index.d.ts +4 -0
  11. package/AutocompleteWithFilter/index.js +54 -0
  12. package/AutocompleteWithFilter/types.d.ts +16 -0
  13. package/AutocompleteWithFilter/types.js +1 -0
  14. package/BasicModal/Content.d.ts +0 -1
  15. package/BasicModal/Content.js +1 -1
  16. package/BasicModal/index.d.ts +0 -1
  17. package/BasicModal/index.js +16 -18
  18. package/BasicModal/types.d.ts +3 -1
  19. package/BreadCrumbs/index.d.ts +4 -0
  20. package/BreadCrumbs/index.js +37 -0
  21. package/BreadCrumbs/types.d.ts +9 -0
  22. package/BreadCrumbs/types.js +1 -0
  23. package/CheckBox/CheckBox.d.ts +3 -0
  24. package/CheckBox/CheckBox.js +36 -0
  25. package/CheckBox/CheckBoxGroup.d.ts +3 -0
  26. package/CheckBox/CheckBoxGroup.js +30 -0
  27. package/CheckBox/index.d.ts +3 -0
  28. package/CheckBox/index.js +3 -0
  29. package/CheckBox/types.d.ts +12 -0
  30. package/CheckBox/types.js +1 -0
  31. package/Copyright/index.d.ts +4 -0
  32. package/Copyright/index.js +25 -0
  33. package/Copyright/types.d.ts +5 -0
  34. package/Copyright/types.js +1 -0
  35. package/DigitInput/index.d.ts +1 -4
  36. package/DigitInput/index.js +7 -4
  37. package/DigitInput/types.d.ts +5 -1
  38. package/DynamicHeaderBar/HeaderBar.d.ts +2 -0
  39. package/DynamicHeaderBar/HeaderBar.js +7 -6
  40. package/DynamicHeaderBar/HeaderButtons.d.ts +0 -1
  41. package/DynamicHeaderBar/HeaderButtons.js +20 -19
  42. package/DynamicHeaderBar/HeaderLine.js +4 -4
  43. package/DynamicHeaderBar/index.js +2 -2
  44. package/FeinInput/index.d.ts +6 -0
  45. package/FeinInput/index.js +73 -0
  46. package/FeinInput/types.d.ts +9 -0
  47. package/FeinInput/types.js +1 -0
  48. package/FeinInput/useInteractions.d.ts +8 -0
  49. package/FeinInput/useInteractions.js +16 -0
  50. package/FormRadioGroup/index.d.ts +0 -1
  51. package/FormRadioGroup/index.js +15 -12
  52. package/FormRadioGroup/types.d.ts +3 -0
  53. package/FormSelector/MultipleSelector.d.ts +0 -1
  54. package/FormSelector/MultipleSelector.js +25 -11
  55. package/FormSelector/SimpleSelector.d.ts +0 -1
  56. package/FormSelector/SimpleSelector.js +25 -11
  57. package/FormSelector/types.d.ts +7 -8
  58. package/HelpCaption/index.d.ts +3 -1
  59. package/HelpCaption/index.js +15 -14
  60. package/LoadingModal/index.d.ts +0 -1
  61. package/LoadingModal/index.js +8 -5
  62. package/LoadingModal/types.d.ts +3 -0
  63. package/MenuButtonGroup/MenuItem.d.ts +1 -3
  64. package/MenuButtonGroup/MenuItem.js +5 -3
  65. package/MenuButtonGroup/index.d.ts +3 -1
  66. package/MenuButtonGroup/index.js +9 -6
  67. package/NumberInput/index.d.ts +5 -4
  68. package/NumberInput/index.js +8 -5
  69. package/PasswordInput/ConfirmPassword.d.ts +5 -4
  70. package/PasswordInput/ConfirmPassword.js +10 -7
  71. package/PasswordInput/Password.d.ts +5 -4
  72. package/PasswordInput/Password.js +18 -10
  73. package/PhoneNumberInput/index.d.ts +6 -4
  74. package/PhoneNumberInput/index.js +25 -7
  75. package/PhoneNumberInput/useInteractions.d.ts +0 -1
  76. package/PhoneNumberInput/useInteractions.js +1 -14
  77. package/README.md +261 -45
  78. package/TabGroup/index.js +26 -20
  79. package/TabGroup/types.d.ts +3 -0
  80. package/TablePagination/Actions.d.ts +3 -0
  81. package/TablePagination/Actions.js +27 -0
  82. package/TablePagination/index.d.ts +4 -0
  83. package/TablePagination/index.js +30 -0
  84. package/TablePagination/types.d.ts +14 -0
  85. package/TablePagination/types.js +1 -0
  86. package/TablePagination/useInteractions.d.ts +14 -0
  87. package/TablePagination/useInteractions.js +23 -0
  88. package/TextInput/index.d.ts +5 -4
  89. package/TextInput/index.js +18 -5
  90. package/ToastPrompt/Presentation.js +28 -27
  91. package/ToastPrompt/index.js +1 -1
  92. package/VideoPlayerModal/index.d.ts +1 -3
  93. package/VideoPlayerModal/index.js +8 -7
  94. package/VideoPlayerModal/types.d.ts +5 -1
  95. package/index.d.ts +13 -0
  96. package/index.js +13 -0
  97. package/package.json +9 -2
  98. package/useCustomTheme.d.ts +6 -0
  99. package/useCustomTheme.js +51 -0
@@ -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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
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(_Fragment, { 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: {
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" }), disabled: disabled }, { children: buttonText })), _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
+ }) }))] })));
99
102
  }
100
103
  export default MenuButtonGroup;
@@ -1,13 +1,14 @@
1
- /// <reference types="react" />
1
+ import { CSSProperties } from "react";
2
2
  import { TextFieldProps } from "@mui/material/TextField";
3
- declare type TextProps = Omit<TextFieldProps, "onChange">;
4
- export interface NumberInputProps {
3
+ export interface NumberInputProps extends Omit<TextFieldProps, "onChange"> {
5
4
  onChange: (value: string) => void;
6
5
  value: string;
7
6
  integerOnly?: boolean;
8
7
  tooltip?: string;
9
8
  maxValue?: number;
10
9
  minValue?: number;
10
+ primaryColor?: CSSProperties["color"];
11
+ secondaryColor?: CSSProperties["color"];
11
12
  }
12
- declare function NumberInput(props: NumberInputProps & TextProps): JSX.Element;
13
+ declare function NumberInput(props: NumberInputProps): JSX.Element;
13
14
  export default NumberInput;
@@ -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
- onCloseTooltip();
35
- handleBlur();
36
- }, onChange: handleChange, error: error || exceedError, helperText: helperText || (exceedError ? EXCEED_ERROR : "") }, rest), void 0) }), void 0));
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)) })) })));
37
40
  }
38
41
  export default NumberInput;
@@ -1,10 +1,11 @@
1
- /// <reference types="react" />
1
+ import { CSSProperties } from "react";
2
2
  import { TextFieldProps } from "@mui/material/TextField";
3
- declare type TextInputProps = Omit<TextFieldProps, "onChange">;
4
- export interface ConfirmPasswordProps {
3
+ export interface ConfirmPasswordProps extends Omit<TextFieldProps, "onChange"> {
5
4
  password: string;
6
5
  value: string;
6
+ primaryColor?: CSSProperties["color"];
7
+ secondaryColor?: CSSProperties["color"];
7
8
  onChange: (value: string) => void;
8
9
  }
9
- declare function ConfirmPassword(props: ConfirmPasswordProps & TextInputProps): JSX.Element;
10
+ declare function ConfirmPassword(props: ConfirmPasswordProps): JSX.Element;
10
11
  export default ConfirmPassword;
@@ -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 && password === value) {
30
- return true;
32
+ if ((value === null || value === void 0 ? void 0 : value.length) > 0) {
33
+ return password === value;
31
34
  }
32
- return false;
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
- onChange(event.target.value);
36
- }, fullWidth: true, required: true }, rest), void 0));
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)) })));
37
40
  }
38
41
  export default ConfirmPassword;
@@ -1,18 +1,19 @@
1
1
  import { CSSProperties } from "react";
2
2
  import { TextFieldProps } from "@mui/material/TextField";
3
- declare type TextInputProps = Omit<TextFieldProps, "onChange">;
4
3
  export interface PasswordStrategyProps {
5
4
  [key: string]: {
6
5
  label: string;
7
6
  regex: RegExp;
8
7
  };
9
8
  }
10
- export interface PasswordProps {
11
- strategies: PasswordStrategyProps;
9
+ export interface PasswordProps extends Omit<TextFieldProps, "onChange"> {
10
+ strategies?: PasswordStrategyProps;
12
11
  value: string;
13
12
  successColor?: CSSProperties["color"];
13
+ primaryColor?: CSSProperties["color"];
14
+ secondaryColor?: CSSProperties["color"];
14
15
  onChange: (value: string) => void;
15
16
  onVerify?: (value: string) => boolean;
16
17
  }
17
- declare function Password(props: PasswordProps & TextInputProps): JSX.Element;
18
+ declare function Password(props: PasswordProps): JSX.Element;
18
19
  export default Password;
@@ -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 isValidPassword = useMemo(function () { return !!value && onVerify(value); }, [value, onVerify]);
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: "p", variant: "caption", style: { color: helperTextColor[key] } }, { children: label }), key));
62
- }) }, void 0));
69
+ return (_jsx(Typography, __assign({ component: "li", variant: "caption", style: { color: helperTextColor[key] } }, { children: label }), key));
70
+ }) }));
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
- onChange(event.target.value);
66
- }, fullWidth: true, required: true }, rest), void 0));
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)) })));
67
75
  }
68
76
  export default Password;
@@ -1,11 +1,13 @@
1
- /// <reference types="react" />
1
+ import { CSSProperties } from "react";
2
2
  import { InputProps } from "@mui/material/Input";
3
3
  import { TextFieldProps } from "@mui/material/TextField";
4
- declare type TextInputProps = Omit<TextFieldProps, "onChange">;
5
- export interface PhoneInputProps {
4
+ export interface PhoneInputProps extends Omit<TextFieldProps, "onChange"> {
6
5
  value: string;
7
6
  endAdornment?: InputProps["endAdornment"];
7
+ primaryColor?: CSSProperties["color"];
8
+ secondaryColor?: CSSProperties["color"];
8
9
  onChange: (val: string) => void;
9
10
  }
10
- declare function PhoneInput(props: TextInputProps & PhoneInputProps): JSX.Element;
11
+ export declare function phoneFormat(str: string): string;
12
+ declare function PhoneInput(props: PhoneInputProps): JSX.Element;
11
13
  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 _a = useInteractions({ value: value }), addMask = _a.addMask, phoneFormat = _a.phoneFormat;
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
- startAdornment: (_jsx(InputAdornment, __assign({ position: "start" }, { children: _jsx(Typography, __assign({ variant: "body2" }, { children: "+1" }), void 0) }), void 0)),
41
- endAdornment: endAdornment,
42
- }, onChange: rifm.onChange }, rest), void 0));
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" })) }))),
59
+ endAdornment: endAdornment
60
+ }, onChange: rifm.onChange }, rest)) })));
43
61
  }
44
62
  export default PhoneInput;
@@ -4,6 +4,5 @@ interface InteractionProps {
4
4
  declare function useInteractions(props: InteractionProps): {
5
5
  valLength: number;
6
6
  addMask: (str: string) => string;
7
- phoneFormat: (str: string) => string;
8
7
  };
9
8
  export default useInteractions;
@@ -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, phoneFormat: phoneFormat };
15
+ return { valLength: valLength, addMask: addMask };
29
16
  }
30
17
  export default useInteractions;