@symply.io/basic-components 1.3.11-alpha.9 → 1.4.0-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.
Files changed (127) hide show
  1. package/AlertDialog/index.d.ts +2 -2
  2. package/AlertDialog/index.js +30 -9
  3. package/AlertDialog/types.d.ts +3 -3
  4. package/Autocomplete/index.d.ts +2 -2
  5. package/Autocomplete/index.js +32 -11
  6. package/Autocomplete/types.d.ts +2 -2
  7. package/Autocomplete/useInteractions.js +3 -3
  8. package/AutocompleteWithFilter/index.d.ts +2 -2
  9. package/AutocompleteWithFilter/index.js +35 -13
  10. package/AutocompleteWithFilter/types.d.ts +5 -5
  11. package/BasicModal/Content.js +16 -5
  12. package/BasicModal/index.d.ts +2 -2
  13. package/BasicModal/index.js +31 -10
  14. package/BasicModal/types.d.ts +2 -2
  15. package/BreadCrumbs/index.d.ts +2 -2
  16. package/BreadCrumbs/index.js +19 -9
  17. package/BreadCrumbs/types.d.ts +1 -1
  18. package/CheckBox/index.d.ts +4 -3
  19. package/CheckBox/index.js +36 -3
  20. package/CheckBox/types.d.ts +2 -6
  21. package/CheckBoxGroup/index.d.ts +4 -0
  22. package/CheckBoxGroup/index.js +30 -0
  23. package/CheckBoxGroup/types.d.ts +5 -0
  24. package/CheckBoxGroup/types.js +1 -0
  25. package/ConfirmPasswordInput/index.d.ts +4 -0
  26. package/ConfirmPasswordInput/index.js +42 -0
  27. package/ConfirmPasswordInput/types.d.ts +9 -0
  28. package/ConfirmPasswordInput/types.js +1 -0
  29. package/Copyright/index.d.ts +2 -2
  30. package/Copyright/index.js +14 -4
  31. package/Copyright/types.d.ts +1 -1
  32. package/DataTable/TableBody.js +24 -2
  33. package/DataTable/TableBodyRow.js +52 -41
  34. package/DataTable/TableFooter.js +41 -30
  35. package/DataTable/TableHeader.js +47 -36
  36. package/DataTable/index.d.ts +2 -1
  37. package/DataTable/index.js +30 -18
  38. package/DataTable/useTable.js +54 -46
  39. package/DateInput/FullDateInput/index.js +42 -20
  40. package/DateInput/FullDateInput/useInteractions.js +10 -10
  41. package/DateInput/MonthDayInput/index.js +36 -14
  42. package/DateInput/MonthDayInput/useInteractions.js +9 -9
  43. package/DateInput/MonthYearInput/index.js +36 -14
  44. package/DateInput/MonthYearInput/useInteractions.js +9 -9
  45. package/DateInput/index.d.ts +4 -3
  46. package/DateInput/index.js +4 -3
  47. package/DigitInput/index.d.ts +2 -2
  48. package/DigitInput/index.js +28 -7
  49. package/DigitInput/types.d.ts +3 -3
  50. package/DigitInput/useInteractions.js +9 -9
  51. package/DynamicHeaderBar/HeaderBar.d.ts +1 -13
  52. package/DynamicHeaderBar/HeaderBar.js +17 -6
  53. package/DynamicHeaderBar/HeaderButtons.d.ts +1 -1
  54. package/DynamicHeaderBar/HeaderButtons.js +24 -13
  55. package/DynamicHeaderBar/HeaderLine.d.ts +1 -6
  56. package/DynamicHeaderBar/HeaderLine.js +2 -2
  57. package/DynamicHeaderBar/index.d.ts +1 -17
  58. package/DynamicHeaderBar/index.js +26 -18
  59. package/DynamicHeaderBar/types.d.ts +33 -5
  60. package/FeinInput/index.d.ts +2 -2
  61. package/FeinInput/index.js +38 -17
  62. package/FeinInput/types.d.ts +2 -2
  63. package/FeinInput/useInteractions.js +9 -9
  64. package/FileUploader/index.d.ts +2 -2
  65. package/FileUploader/index.js +33 -12
  66. package/FileUploader/useInteractions.js +44 -29
  67. package/FormRadioGroup/index.d.ts +2 -2
  68. package/FormRadioGroup/index.js +29 -5
  69. package/FormRadioGroup/types.d.ts +3 -4
  70. package/FormSelector/MultipleSelector.js +32 -9
  71. package/FormSelector/SimpleSelector.js +32 -9
  72. package/FormSelector/useInteractions.js +7 -7
  73. package/HelpCaption/index.d.ts +2 -2
  74. package/HelpCaption/index.js +17 -6
  75. package/HelpCaption/useInteractions.js +2 -2
  76. package/LoadingModal/Modal.js +15 -4
  77. package/LoadingModal/index.d.ts +2 -1
  78. package/LoadingModal/index.js +3 -1
  79. package/LoadingModal/useLoadingModal.d.ts +1 -1
  80. package/LoadingModal/useLoadingModal.js +34 -16
  81. package/MenuButtonGroup/MenuItem.js +14 -3
  82. package/MenuButtonGroup/index.js +82 -14
  83. package/NumberInput/index.js +27 -5
  84. package/NumberInput/useInteractions.js +17 -17
  85. package/PasswordInput/index.d.ts +6 -4
  86. package/PasswordInput/index.js +79 -4
  87. package/PasswordInput/{Password.d.ts → types.d.ts} +3 -6
  88. package/PasswordInput/types.js +1 -0
  89. package/PhoneNumberInput/index.js +39 -17
  90. package/PhoneNumberInput/useInteractions.js +10 -10
  91. package/README.md +4 -8
  92. package/Sidebar/SidebarItem.js +17 -6
  93. package/Sidebar/SidebarItemsGroup.js +21 -10
  94. package/Sidebar/SidebarLink.js +27 -5
  95. package/Sidebar/index.js +17 -6
  96. package/SocialInput/index.d.ts +2 -2
  97. package/SocialInput/index.js +40 -19
  98. package/SocialInput/useInteractions.js +14 -14
  99. package/TabGroup/index.d.ts +2 -2
  100. package/TabGroup/index.js +25 -15
  101. package/TablePagination/Actions.js +15 -4
  102. package/TablePagination/index.d.ts +2 -2
  103. package/TablePagination/index.js +14 -4
  104. package/TablePagination/useInteractions.js +9 -9
  105. package/TextInput/index.d.ts +1 -1
  106. package/TextInput/index.js +31 -9
  107. package/TextInput/useInteractions.js +4 -4
  108. package/ToastPrompt/Prompt.d.ts +4 -2
  109. package/ToastPrompt/Prompt.js +23 -55
  110. package/ToastPrompt/index.js +22 -8
  111. package/ToastPrompt/types.d.ts +10 -17
  112. package/ToastPrompt/useInteractions.d.ts +8 -8
  113. package/ToastPrompt/useInteractions.js +23 -16
  114. package/VideoPlayerModal/index.d.ts +2 -2
  115. package/VideoPlayerModal/index.js +27 -6
  116. package/index.d.ts +6 -0
  117. package/index.js +6 -0
  118. package/package.json +1 -2
  119. package/useCustomTheme.js +16 -11
  120. package/utils/uuid.js +11 -10
  121. package/CheckBox/CheckBox.d.ts +0 -3
  122. package/CheckBox/CheckBox.js +0 -14
  123. package/CheckBox/CheckBoxGroup.d.ts +0 -3
  124. package/CheckBox/CheckBoxGroup.js +0 -8
  125. package/PasswordInput/ConfirmPassword.d.ts +0 -11
  126. package/PasswordInput/ConfirmPassword.js +0 -20
  127. package/PasswordInput/Password.js +0 -56
@@ -1,27 +1,34 @@
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
+ };
1
12
  import { useState, useCallback } from "react";
2
13
  function useInteractions() {
3
- const ERROR_MESSAGE = "Internal Server Error";
4
- const [promptArgs, setPromptArgs] = useState({
14
+ var ERROR_MESSAGE = "Internal Server Error";
15
+ var UNKNOWN_MESSAGE = "Unknown Message";
16
+ var _a = useState({
5
17
  open: false,
6
- message: "Saved",
7
- variant: "success",
18
+ message: UNKNOWN_MESSAGE,
19
+ type: "error",
8
20
  timeout: 3500
9
- });
10
- const onHide = useCallback((_, reason) => {
21
+ }), promptArgs = _a[0], setPromptArgs = _a[1];
22
+ var onHide = useCallback(function (_, reason) {
11
23
  if (reason === "clickaway") {
12
24
  return;
13
25
  }
14
- setPromptArgs(args => ({ ...args, open: false }));
26
+ setPromptArgs(function (args) { return (__assign(__assign({}, args), { open: false })); });
15
27
  }, []);
16
- const onShow = useCallback(args => {
17
- const { message = "Unknown message", variant = "info", timeout = 3500 } = args;
18
- setPromptArgs({
19
- open: true,
20
- message: message === 400 ? ERROR_MESSAGE : message,
21
- variant,
22
- timeout
23
- });
28
+ var onShow = useCallback(function (args) {
29
+ var _a = args.message, message = _a === void 0 ? UNKNOWN_MESSAGE : _a, _b = args.type, type = _b === void 0 ? "error" : _b, _c = args.timeout, timeout = _c === void 0 ? 3500 : _c;
30
+ setPromptArgs(function (args) { return (__assign(__assign({}, args), { message: message === 400 ? ERROR_MESSAGE : message, type: type, timeout: timeout, open: true })); });
24
31
  }, []);
25
- return { promptArgs, onShow, onHide };
32
+ return __assign(__assign({}, promptArgs), { onShow: onShow, onHide: onHide });
26
33
  }
27
34
  export default useInteractions;
@@ -1,4 +1,4 @@
1
- import { VideoPlayerModalProps } from "./types";
1
+ import type { VideoPlayerModalProps } from "./types";
2
2
  declare function VideoPlayerModal(props: VideoPlayerModalProps): JSX.Element;
3
3
  export default VideoPlayerModal;
4
- export * from "./types";
4
+ export type { VideoPlayerModalProps };
@@ -1,3 +1,25 @@
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
+ };
1
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
24
  import ReactPlayer from "react-player";
3
25
  import Grid from "@mui/material/Grid";
@@ -10,12 +32,11 @@ import useMediaQuery from "@mui/material/useMediaQuery";
10
32
  import ThemeProvider from "@mui/material/styles/ThemeProvider";
11
33
  import useCustomTheme from "../useCustomTheme";
12
34
  function VideoPlayerModal(props) {
13
- const { url, pip = false, open = false, title, onClose, extraButtons = [], primaryColor, secondaryColor, ...playerProps } = props;
14
- const theme = useCustomTheme({ primaryColor, secondaryColor });
15
- const fullScreen = useMediaQuery(theme.breakpoints.down("sm"));
16
- return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Dialog, { open: open, fullScreen: fullScreen, onClose: onClose, fullWidth: true, maxWidth: "lg", "aria-labelledby": "react-video-dialog", children: [title && _jsx(DialogTitle, { children: title }), _jsx(DialogContent, { children: _jsx(ReactPlayer, { controls: true, url: url, style: { minHeight: "480px" }, width: "100%", config: {
35
+ var url = props.url, _a = props.pip, pip = _a === void 0 ? false : _a, _b = props.open, open = _b === void 0 ? false : _b, title = props.title, onClose = props.onClose, _c = props.extraButtons, extraButtons = _c === void 0 ? [] : _c, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, playerProps = __rest(props, ["url", "pip", "open", "title", "onClose", "extraButtons", "primaryColor", "secondaryColor"]);
36
+ var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
37
+ var fullScreen = useMediaQuery(theme.breakpoints.down("sm"));
38
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsxs(Dialog, __assign({ open: open, fullScreen: fullScreen, onClose: onClose, fullWidth: true, maxWidth: "lg", "aria-labelledby": "react-video-dialog" }, { children: [title && _jsx(DialogTitle, { children: title }), _jsx(DialogContent, { children: _jsx(ReactPlayer, __assign({ controls: true, url: url, style: { minHeight: "480px" }, width: "100%", config: {
17
39
  file: { attributes: { disablePictureInPicture: !pip } }
18
- }, ...playerProps }) }), _jsx(DialogActions, { children: _jsxs(Grid, { container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", spacing: 1, children: [extraButtons.map((buttonProps, index) => (_jsx(Grid, { item: true, xs: 12, md: 3, lg: 2, children: _jsx(Button, { ...buttonProps }) }, `extraButton_${index}`))), _jsx(Grid, { item: true, xs: 12, md: 2, lg: 1, children: _jsx(Button, { variant: "outlined", fullWidth: true, color: "secondary", onClick: onClose, children: "Close" }) })] }) })] }) }));
40
+ } }, playerProps)) }), _jsx(DialogActions, { children: _jsxs(Grid, __assign({ container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", spacing: 1 }, { children: [extraButtons.map(function (buttonProps, index) { return (_jsx(Grid, __assign({ item: true, xs: 12, md: 3, lg: 2 }, { children: _jsx(Button, __assign({}, buttonProps)) }), "extraButton_".concat(index))); }), _jsx(Grid, __assign({ item: true, xs: 12, md: 2, lg: 1 }, { children: _jsx(Button, __assign({ variant: "outlined", fullWidth: true, color: "secondary", onClick: onClose }, { children: "Close" })) }))] })) })] })) })));
19
41
  }
20
42
  export default VideoPlayerModal;
21
- export * from "./types";
package/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export * from "./AutocompleteWithFilter";
4
4
  export * from "./BasicModal";
5
5
  export * from "./BreadCrumbs";
6
6
  export * from "./CheckBox";
7
+ export * from "./CheckBoxGroup";
8
+ export * from "./ConfirmPasswordInput";
7
9
  export * from "./Copyright";
8
10
  export * from "./DataTable";
9
11
  export * from "./DateInput";
@@ -31,6 +33,9 @@ export { default as Autocomplete } from "./Autocomplete";
31
33
  export { default as AutocompleteWithFilter } from "./AutocompleteWithFilter";
32
34
  export { default as BasicModal } from "./BasicModal";
33
35
  export { default as BreadCrumbs } from "./BreadCrumbs";
36
+ export { default as CheckBox } from "./CheckBox";
37
+ export { default as CheckBoxGroup } from "./CheckBoxGroup";
38
+ export { default as ConfirmPasswordInput } from "./ConfirmPasswordInput";
34
39
  export { default as Copyright } from "./Copyright";
35
40
  export { default as DataTable } from "./DataTable";
36
41
  export { default as DigitInput } from "./DigitInput";
@@ -42,6 +47,7 @@ export { default as HelpCaption } from "./HelpCaption";
42
47
  export { default as LoadingModal } from "./LoadingModal";
43
48
  export { default as MenuButtonGroup } from "./MenuButtonGroup";
44
49
  export { default as NumberInput } from "./NumberInput";
50
+ export { default as PasswordInput } from "./PasswordInput";
45
51
  export { default as PhoneNumberInput } from "./PhoneNumberInput";
46
52
  export { default as Sidebar } from "./Sidebar";
47
53
  export { default as SocialInput } from "./SocialInput";
package/index.js CHANGED
@@ -4,6 +4,8 @@ export * from "./AutocompleteWithFilter";
4
4
  export * from "./BasicModal";
5
5
  export * from "./BreadCrumbs";
6
6
  export * from "./CheckBox";
7
+ export * from "./CheckBoxGroup";
8
+ export * from "./ConfirmPasswordInput";
7
9
  export * from "./Copyright";
8
10
  export * from "./DataTable";
9
11
  export * from "./DateInput";
@@ -31,6 +33,9 @@ export { default as Autocomplete } from "./Autocomplete";
31
33
  export { default as AutocompleteWithFilter } from "./AutocompleteWithFilter";
32
34
  export { default as BasicModal } from "./BasicModal";
33
35
  export { default as BreadCrumbs } from "./BreadCrumbs";
36
+ export { default as CheckBox } from "./CheckBox";
37
+ export { default as CheckBoxGroup } from "./CheckBoxGroup";
38
+ export { default as ConfirmPasswordInput } from "./ConfirmPasswordInput";
34
39
  export { default as Copyright } from "./Copyright";
35
40
  export { default as DataTable } from "./DataTable";
36
41
  export { default as DigitInput } from "./DigitInput";
@@ -42,6 +47,7 @@ export { default as HelpCaption } from "./HelpCaption";
42
47
  export { default as LoadingModal } from "./LoadingModal";
43
48
  export { default as MenuButtonGroup } from "./MenuButtonGroup";
44
49
  export { default as NumberInput } from "./NumberInput";
50
+ export { default as PasswordInput } from "./PasswordInput";
45
51
  export { default as PhoneNumberInput } from "./PhoneNumberInput";
46
52
  export { default as Sidebar } from "./Sidebar";
47
53
  export { default as SocialInput } from "./SocialInput";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.3.11-alpha.9",
3
+ "version": "1.4.0-alpha.10",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",
@@ -8,7 +8,6 @@
8
8
  "material-ui"
9
9
  ],
10
10
  "main": "index.js",
11
- "type": "module",
12
11
  "types": "**/*.d.ts",
13
12
  "license": "MIT",
14
13
  "private": false,
package/useCustomTheme.js CHANGED
@@ -1,7 +1,18 @@
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
+ };
1
12
  import { createTheme } from "@mui/material/styles";
2
13
  function useCustomTheme(props) {
3
- const { primaryColor, secondaryColor } = props || {};
4
- const themeOptions = {
14
+ var _a = props || {}, primaryColor = _a.primaryColor, secondaryColor = _a.secondaryColor;
15
+ var themeOptions = {
5
16
  components: {
6
17
  MuiButton: {
7
18
  styleOverrides: {
@@ -23,19 +34,13 @@ function useCustomTheme(props) {
23
34
  };
24
35
  if (!!primaryColor || !!secondaryColor) {
25
36
  if (!!primaryColor) {
26
- themeOptions.palette = {
27
- ...themeOptions.palette,
28
- primary: { main: primaryColor }
29
- };
37
+ themeOptions.palette = __assign(__assign({}, themeOptions.palette), { primary: { main: primaryColor } });
30
38
  }
31
39
  if (!!secondaryColor) {
32
- themeOptions.palette = {
33
- ...themeOptions.palette,
34
- secondary: { main: secondaryColor }
35
- };
40
+ themeOptions.palette = __assign(__assign({}, themeOptions.palette), { secondary: { main: secondaryColor } });
36
41
  }
37
42
  }
38
- const theme = createTheme(themeOptions);
43
+ var theme = createTheme(themeOptions);
39
44
  return theme;
40
45
  }
41
46
  export default useCustomTheme;
package/utils/uuid.js CHANGED
@@ -1,4 +1,5 @@
1
- function generateUUID(length = 32) {
1
+ function generateUUID(length) {
2
+ if (length === void 0) { length = 32; }
2
3
  if (length < 16)
3
4
  throw new Error("Length should be equal or greater than 16");
4
5
  function UUID() {
@@ -23,28 +24,28 @@ function generateUUID(length = 32) {
23
24
  this.rand = "";
24
25
  }
25
26
  UUID.prototype = {
26
- getRandomUInt() {
27
- let s = "";
28
- this.chars.sort(() => {
27
+ getRandomUInt: function () {
28
+ var s = "";
29
+ this.chars.sort(function () {
29
30
  return Date.now() % (Math.random() * length * 23) >
30
31
  Math.random() * 7 * length
31
32
  ? -1
32
33
  : 1;
33
34
  });
34
- for (let i = 0; i < this.chars.length; i += 1) {
35
+ for (var i = 0; i < this.chars.length; i += 1) {
35
36
  s = s.concat(this.chars[i]);
36
37
  }
37
38
  return s;
38
39
  },
39
- getRandomChars() {
40
+ getRandomChars: function () {
40
41
  this.rand = Date.now().toString(16).concat(this.getRandomUInt());
41
42
  return this.rand;
42
43
  },
43
- generate() {
44
- let id = Date.now().toString();
45
- const idLen = id.length;
44
+ generate: function () {
45
+ var id = Date.now().toString();
46
+ var idLen = id.length;
46
47
  this.getRandomChars();
47
- for (let i = 0; i < length - idLen; i += 1) {
48
+ for (var i = 0; i < length - idLen; i += 1) {
48
49
  id = id.concat(this.rand.charAt(Math.floor(Math.random() * this.rand.length)));
49
50
  }
50
51
  return id.toString();
@@ -1,3 +0,0 @@
1
- import { CheckBoxProps } from "./types";
2
- export declare function CheckBox(props: CheckBoxProps): JSX.Element;
3
- export default CheckBox;
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import Checkbox from "@mui/material/Checkbox";
3
- import FormControlLabel from "@mui/material/FormControlLabel";
4
- import ThemeProvider from "@mui/material/styles/ThemeProvider";
5
- import useCustomTheme from "../useCustomTheme";
6
- export function CheckBox(props) {
7
- const { label, onChange, primaryColor, secondaryColor, ...rest } = props;
8
- const theme = useCustomTheme({ primaryColor, secondaryColor });
9
- return (_jsx(ThemeProvider, { theme: theme, children: _jsx(FormControlLabel, { control: _jsx(Checkbox, { onChange: event => {
10
- event.stopPropagation();
11
- onChange(event.target.checked);
12
- }, ...rest }), label: label }) }));
13
- }
14
- export default CheckBox;
@@ -1,3 +0,0 @@
1
- import { CheckBoxGroupProps } from "./types";
2
- export declare function CheckBoxGroup(props: CheckBoxGroupProps): JSX.Element;
3
- export default CheckBoxGroup;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import FormGroup from "@mui/material/FormGroup";
3
- import CheckBox from "./CheckBox";
4
- export function CheckBoxGroup(props) {
5
- const { checkboxes, ...rest } = props;
6
- return (_jsx(FormGroup, { ...rest, children: checkboxes.map((checkbox, index) => (_jsx(CheckBox, { ...checkbox }, index))) }));
7
- }
8
- export default CheckBoxGroup;
@@ -1,11 +0,0 @@
1
- import { CSSProperties } from "react";
2
- import { TextFieldProps } from "@mui/material/TextField";
3
- export interface ConfirmPasswordProps extends Omit<TextFieldProps, "onChange"> {
4
- password: string;
5
- value: string;
6
- primaryColor?: CSSProperties["color"];
7
- secondaryColor?: CSSProperties["color"];
8
- onChange: (value: string) => void;
9
- }
10
- declare function ConfirmPassword(props: ConfirmPasswordProps): JSX.Element;
11
- export default ConfirmPassword;
@@ -1,20 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import TextField from "@mui/material/TextField";
4
- import ThemeProvider from "@mui/material/styles/ThemeProvider";
5
- import useCustomTheme from "../useCustomTheme";
6
- function ConfirmPassword(props) {
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) {
11
- return password === value;
12
- }
13
- return true;
14
- }, [value, password]);
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 => {
16
- event.preventDefault();
17
- onChange(event.target.value);
18
- }, fullWidth: true, required: true, ...rest }) }));
19
- }
20
- export default ConfirmPassword;
@@ -1,56 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import TextField from "@mui/material/TextField";
4
- import Typography from "@mui/material/Typography";
5
- import ThemeProvider from "@mui/material/styles/ThemeProvider";
6
- import useCustomTheme from "../useCustomTheme";
7
- export function onValidatePassword(password) {
8
- const reg = /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~a-zA-z0-9]{8,})$/;
9
- return reg.test(password);
10
- }
11
- function Password(props) {
12
- const { strategies = {
13
- uppercaseLetter: { label: "1 Uppercase Letter", regex: /[A-Z]+/ },
14
- lowercaseLetter: { label: "1 Lowercase Letter", regex: /[a-z]+/ },
15
- specialCharacter: {
16
- label: "1 Special Character",
17
- regex: /[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/
18
- },
19
- number: { label: "1 Number", regex: /\d+/ },
20
- minimum8: { label: "Minimum 8 characters", regex: /.{8,}/ }
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) {
25
- return onValidate ? onValidate(value) : onValidatePassword(value);
26
- }
27
- return true;
28
- }, [value, onValidate, onValidatePassword]);
29
- const helperTextColor = useMemo(() => {
30
- const textColors = Object.keys(strategies).reduce((temp, key) => {
31
- const { regex } = strategies[key];
32
- if (value === "") {
33
- temp[key] = undefined;
34
- }
35
- else if (regex.test(value)) {
36
- temp[key] = successColor;
37
- }
38
- else {
39
- temp[key] = "red";
40
- }
41
- return temp;
42
- }, {});
43
- return textColors;
44
- }, [value, strategies]);
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));
49
- }) }));
50
- }, [helperTextColor, strategies]);
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 => {
52
- event.preventDefault();
53
- onChange(event.target.value);
54
- }, fullWidth: true, required: true, ...rest }) }));
55
- }
56
- export default Password;