@superdispatch/ui-lab 0.49.4 → 0.50.0
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/dist-node/index.js +170 -0
- package/dist-node/index.js.map +1 -1
- package/dist-src/index.js +1 -0
- package/dist-src/passwordStepper/PasswordStrength.js +84 -0
- package/dist-src/passwordStepper/PasswordUtils.js +26 -0
- package/dist-src/passwordStepper/PasswordValidationComponents.js +69 -0
- package/dist-types/index.d.ts +6 -1
- package/dist-web/index.js +171 -2
- package/dist-web/index.js.map +1 -1
- package/package.json +4 -4
package/dist-src/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { useNavbarContext } from "./navbar/NavbarContext.js";
|
|
|
22
22
|
export * from "./navbar/NavbarItem.js";
|
|
23
23
|
export * from "./navbar/NavbarList.js";
|
|
24
24
|
export * from "./navbar/NavbarMenu.js";
|
|
25
|
+
export * from "./passwordStepper/PasswordStrength.js";
|
|
25
26
|
export * from "./sidebar/Sidebar.js";
|
|
26
27
|
export * from "./sidebar/SidebarBackButton.js";
|
|
27
28
|
export * from "./sidebar/SidebarContainer.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Typography } from '@material-ui/core';
|
|
2
|
+
import { Color, ColorDynamic, Stack } from '@superdispatch/ui';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { Box } from "../box/Box.js";
|
|
6
|
+
import { getPasswordStrength, hasEnoughCharacters, hasLowerCaseAndUpperCase, hasNumber, hasSpecialCharacter } from "./PasswordUtils.js";
|
|
7
|
+
import { CheckPasswordItem, Stepper, StepperItem } from "./PasswordValidationComponents.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
var passwordStepperTitle = {
|
|
10
|
+
weak: {
|
|
11
|
+
textColor: ColorDynamic.Red500,
|
|
12
|
+
text: 'Weak Password'
|
|
13
|
+
},
|
|
14
|
+
average: {
|
|
15
|
+
textColor: ColorDynamic.Yellow500,
|
|
16
|
+
text: 'Average Password'
|
|
17
|
+
},
|
|
18
|
+
good: {
|
|
19
|
+
textColor: ColorDynamic.Green500,
|
|
20
|
+
text: 'Good Password'
|
|
21
|
+
},
|
|
22
|
+
strong: {
|
|
23
|
+
textColor: ColorDynamic.Green500,
|
|
24
|
+
text: 'Strong Password'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var passwordStrengthToActiveStepsCount = {
|
|
28
|
+
weak: 1,
|
|
29
|
+
average: 2,
|
|
30
|
+
good: 3,
|
|
31
|
+
strong: 4
|
|
32
|
+
};
|
|
33
|
+
function steps(passwordStrength) {
|
|
34
|
+
return [passwordStrengthToActiveStepsCount[passwordStrength] >= 1, passwordStrengthToActiveStepsCount[passwordStrength] >= 2, passwordStrengthToActiveStepsCount[passwordStrength] >= 3, passwordStrengthToActiveStepsCount[passwordStrength] >= 4];
|
|
35
|
+
}
|
|
36
|
+
var PasswordText = /*#__PURE__*/styled(Typography).withConfig({
|
|
37
|
+
displayName: "PasswordStrength__PasswordText",
|
|
38
|
+
componentId: "SD__sc-1ddnv91-0"
|
|
39
|
+
})(["color:", ";"], _ref => {
|
|
40
|
+
var {
|
|
41
|
+
colorProp
|
|
42
|
+
} = _ref;
|
|
43
|
+
return colorProp !== null && colorProp !== void 0 ? colorProp : Color.Dark100;
|
|
44
|
+
});
|
|
45
|
+
export function PasswordStrength(_ref2) {
|
|
46
|
+
var {
|
|
47
|
+
value
|
|
48
|
+
} = _ref2;
|
|
49
|
+
var passwordStrength = useMemo(() => getPasswordStrength(value), [value]);
|
|
50
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
51
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
|
52
|
+
children: [/*#__PURE__*/_jsx(PasswordText, {
|
|
53
|
+
variant: "body2",
|
|
54
|
+
colorProp: passwordStrength && passwordStepperTitle[passwordStrength].textColor,
|
|
55
|
+
children: passwordStrength ? passwordStepperTitle[passwordStrength].text : 'Password Strength'
|
|
56
|
+
}), /*#__PURE__*/_jsx(Stepper, {
|
|
57
|
+
children: steps(passwordStrength !== null && passwordStrength !== void 0 ? passwordStrength : '').map((isStepActive, index) => /*#__PURE__*/_jsx(StepperItem, {
|
|
58
|
+
isActive: isStepActive,
|
|
59
|
+
passwordStrength: passwordStrength
|
|
60
|
+
}, index))
|
|
61
|
+
})]
|
|
62
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
63
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
64
|
+
variant: "body2",
|
|
65
|
+
children: "It must have:"
|
|
66
|
+
}), /*#__PURE__*/_jsxs(Stack, {
|
|
67
|
+
space: "xxsmall",
|
|
68
|
+
children: [/*#__PURE__*/_jsx(CheckPasswordItem, {
|
|
69
|
+
isDone: hasEnoughCharacters(value),
|
|
70
|
+
text: "At least 8 characters"
|
|
71
|
+
}), /*#__PURE__*/_jsx(CheckPasswordItem, {
|
|
72
|
+
isDone: hasLowerCaseAndUpperCase(value),
|
|
73
|
+
text: "Upper & lowercase letters"
|
|
74
|
+
}), /*#__PURE__*/_jsx(CheckPasswordItem, {
|
|
75
|
+
isDone: hasNumber(value),
|
|
76
|
+
text: "A number"
|
|
77
|
+
}), /*#__PURE__*/_jsx(CheckPasswordItem, {
|
|
78
|
+
isDone: hasSpecialCharacter(value),
|
|
79
|
+
text: "A special character (%, $, #, etc.)"
|
|
80
|
+
})]
|
|
81
|
+
})]
|
|
82
|
+
})]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function getPasswordStrength(value) {
|
|
2
|
+
var count = [hasEnoughCharacters, hasNumber, hasLowerCaseAndUpperCase, hasSpecialCharacter, hasSeveralSpecialCharacters].reduce((acc, check) => check(value) ? acc += 1 : acc, 0);
|
|
3
|
+
if (count === 1 || count === 2) return 'weak';
|
|
4
|
+
if (count === 3) return 'average';
|
|
5
|
+
if (count >= 4) {
|
|
6
|
+
return value.length > 11 ? 'strong' : 'good';
|
|
7
|
+
}
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
export function hasEnoughCharacters(text) {
|
|
11
|
+
return text.trim().length > 7;
|
|
12
|
+
}
|
|
13
|
+
export function hasNumber(text) {
|
|
14
|
+
return /(?=.*[0-9])/.test(text);
|
|
15
|
+
}
|
|
16
|
+
export function hasLowerCaseAndUpperCase(text) {
|
|
17
|
+
return /^(?=.*[a-z])(?=.*[A-Z]).+$/.test(text);
|
|
18
|
+
}
|
|
19
|
+
export function hasSpecialCharacter(text) {
|
|
20
|
+
return /[!@#$%^&*()_+\-={[}\]|\\;:'"<>?,.]/.test(text);
|
|
21
|
+
}
|
|
22
|
+
export function hasSeveralSpecialCharacters(text) {
|
|
23
|
+
var regex = /[!@#$%^&*()_+\-={[}\]|\\;:'"<>?,.]/g;
|
|
24
|
+
var charactersList = text.match(regex);
|
|
25
|
+
return !!charactersList && charactersList.length > 1;
|
|
26
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Check } from '@material-ui/icons';
|
|
2
|
+
import { Color, ColorDynamic, Inline } from '@superdispatch/ui';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { Box } from "../box/Box.js";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
var ListItem = /*#__PURE__*/styled.div.withConfig({
|
|
7
|
+
displayName: "PasswordValidationComponents__ListItem",
|
|
8
|
+
componentId: "SD__sc-ikou1j-0"
|
|
9
|
+
})(["display:flex;align-items:center;"]);
|
|
10
|
+
var Dot = /*#__PURE__*/styled.div.withConfig({
|
|
11
|
+
displayName: "PasswordValidationComponents__Dot",
|
|
12
|
+
componentId: "SD__sc-ikou1j-1"
|
|
13
|
+
})(["height:4px;width:4px;background-color:", ";border-radius:100px;"], Color.Blue300);
|
|
14
|
+
var TickBox = /*#__PURE__*/styled(Box).withConfig({
|
|
15
|
+
displayName: "PasswordValidationComponents__TickBox",
|
|
16
|
+
componentId: "SD__sc-ikou1j-2"
|
|
17
|
+
})(["width:13.33px;height:13.33px;border-radius:15px;background-color:", ";display:flex;align-items:center;justify-content:center;"], ColorDynamic.Blue50);
|
|
18
|
+
export function CheckPasswordItem(_ref) {
|
|
19
|
+
var {
|
|
20
|
+
isDone,
|
|
21
|
+
text
|
|
22
|
+
} = _ref;
|
|
23
|
+
return /*#__PURE__*/_jsxs(ListItem, {
|
|
24
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
25
|
+
minWidth: "16px",
|
|
26
|
+
children: /*#__PURE__*/_jsx(Inline, {
|
|
27
|
+
verticalAlign: "center",
|
|
28
|
+
horizontalAlign: "center",
|
|
29
|
+
children: isDone ? /*#__PURE__*/_jsx(TickBox, {
|
|
30
|
+
children: /*#__PURE__*/_jsx(Check, {
|
|
31
|
+
style: {
|
|
32
|
+
fontSize: '10px',
|
|
33
|
+
color: Color.Green500
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}) : /*#__PURE__*/_jsx(Dot, {})
|
|
37
|
+
})
|
|
38
|
+
}), text]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export var Stepper = /*#__PURE__*/styled.div.withConfig({
|
|
42
|
+
displayName: "PasswordValidationComponents__Stepper",
|
|
43
|
+
componentId: "SD__sc-ikou1j-3"
|
|
44
|
+
})(["height:5px;display:flex;width:100%;margin-bottom:8px;margin-top:4px;"]);
|
|
45
|
+
export var StepperItem = /*#__PURE__*/styled.div.withConfig({
|
|
46
|
+
displayName: "PasswordValidationComponents__StepperItem",
|
|
47
|
+
componentId: "SD__sc-ikou1j-4"
|
|
48
|
+
})(["height:2px;background-color:", ";flex:1;border-radius:100px;&:not(:last-child){margin-right:10px;flex:1;}"], _ref2 => {
|
|
49
|
+
var {
|
|
50
|
+
isActive,
|
|
51
|
+
passwordStrength
|
|
52
|
+
} = _ref2;
|
|
53
|
+
return getStepperItemColor(isActive, passwordStrength);
|
|
54
|
+
});
|
|
55
|
+
function getStepperItemColor(isActive, passwordStrength) {
|
|
56
|
+
if (!isActive || !passwordStrength) return ColorDynamic.Silver400;
|
|
57
|
+
switch (isActive) {
|
|
58
|
+
case passwordStrength === 'strong':
|
|
59
|
+
return ColorDynamic.Green500;
|
|
60
|
+
case passwordStrength === 'weak':
|
|
61
|
+
return ColorDynamic.Red500;
|
|
62
|
+
case passwordStrength === 'average':
|
|
63
|
+
return ColorDynamic.Yellow500;
|
|
64
|
+
case passwordStrength === 'good':
|
|
65
|
+
return ColorDynamic.Green500;
|
|
66
|
+
default:
|
|
67
|
+
return ColorDynamic.Silver400;
|
|
68
|
+
}
|
|
69
|
+
}
|
package/dist-types/index.d.ts
CHANGED
|
@@ -340,6 +340,11 @@ interface NavbarMenuProps {
|
|
|
340
340
|
}
|
|
341
341
|
declare function NavbarMenu({ items, children }: NavbarMenuProps): ReactElement;
|
|
342
342
|
|
|
343
|
+
interface PasswordStrengthProps {
|
|
344
|
+
value: string;
|
|
345
|
+
}
|
|
346
|
+
declare function PasswordStrength({ value, }: PasswordStrengthProps): JSX.Element;
|
|
347
|
+
|
|
343
348
|
interface SidebarProps {
|
|
344
349
|
id?: string;
|
|
345
350
|
title?: ReactNode;
|
|
@@ -430,4 +435,4 @@ interface TextBoxProps {
|
|
|
430
435
|
}
|
|
431
436
|
declare const TextBox: ForwardRefExoticComponent<TextBoxProps & RefAttributes<HTMLElement>>;
|
|
432
437
|
|
|
433
|
-
export { Alert, AlertProps, AlertSeverityProp, AnchorButton, AnchorButtonProps, Banner, BorderRadiusProp, BorderWidthProp, Box, BoxProps, Button, ButtonArea, ButtonAreaProps, ButtonProps, ButtonSizeProp, ButtonVariantProp, Chat, ChatMessage, Container, ContainerProps, DescriptionItem, DescriptionItemProps, DescriptionLineItem, DottedLine, EmailAutocomplete, EmailAutocompleteProps, FileDropZone, FileDropZoneProps, FileListItem, FileListItemProps, FlagList, FlagListItem, LinkComponentProps, LinkedText, LinkedTextProps, MarginProp, MultilineText, MultilineTextProps, Navbar, NavbarAccordionOptions, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarBottomBarItem, NavbarItem, NavbarItemOptions, NavbarItemProps, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, NavbarMenuItemOption, Sidebar, SidebarBackButton, SidebarContainer, SidebarContainerProps, SidebarContent, SidebarContentProps, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemActionProps, SidebarMenuItemAvatar, SidebarMenuItemAvatarProps, SidebarMenuItemProps, SidebarProps, SidebarSubheader, SidebarSubheaderProps, TextAlignProp, TextBox, TextBoxProps, TextColorProp, TextDisplayProp, TextVariantProp, formatBytes, toBytes, useNavbarContext, useSidebarContext };
|
|
438
|
+
export { Alert, AlertProps, AlertSeverityProp, AnchorButton, AnchorButtonProps, Banner, BorderRadiusProp, BorderWidthProp, Box, BoxProps, Button, ButtonArea, ButtonAreaProps, ButtonProps, ButtonSizeProp, ButtonVariantProp, Chat, ChatMessage, Container, ContainerProps, DescriptionItem, DescriptionItemProps, DescriptionLineItem, DottedLine, EmailAutocomplete, EmailAutocompleteProps, FileDropZone, FileDropZoneProps, FileListItem, FileListItemProps, FlagList, FlagListItem, LinkComponentProps, LinkedText, LinkedTextProps, MarginProp, MultilineText, MultilineTextProps, Navbar, NavbarAccordionOptions, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarBottomBarItem, NavbarItem, NavbarItemOptions, NavbarItemProps, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, NavbarMenuItemOption, PasswordStrength, Sidebar, SidebarBackButton, SidebarContainer, SidebarContainerProps, SidebarContent, SidebarContentProps, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemActionProps, SidebarMenuItemAvatar, SidebarMenuItemAvatarProps, SidebarMenuItemProps, SidebarProps, SidebarSubheader, SidebarSubheaderProps, TextAlignProp, TextBox, TextBoxProps, TextColorProp, TextDisplayProp, TextVariantProp, formatBytes, toBytes, useNavbarContext, useSidebarContext };
|
package/dist-web/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckCircle, Info, Error as Error$1, WarningRounded, Image, Refresh, Delete, Warning, Flag, Help, Menu, ExpandMore, MenuOpen, ArrowBack, OpenInNew } from '@material-ui/icons';
|
|
1
|
+
import { CheckCircle, Info, Error as Error$1, WarningRounded, Image, Refresh, Delete, Warning, Flag, Help, Menu, ExpandMore, MenuOpen, Check, ArrowBack, OpenInNew } from '@material-ui/icons';
|
|
2
2
|
import { Alert as Alert$1, Autocomplete } from '@material-ui/lab';
|
|
3
3
|
import { ColorDynamic, parseResponsiveProp, isColorDynamicProp, parseSpaceProp, Stack, Color, Inline, mergeRefs, useUID, isEmptyReactNode, Columns, Column, Tag, CardButton, useResponsiveValue, ColorDark, useCollapseBreakpoint } from '@superdispatch/ui';
|
|
4
4
|
import { forwardRef, useState, useEffect, Children, useRef, useLayoutEffect, Suspense, memo, useContext, createContext, useMemo, createElement } from 'react';
|
|
@@ -1866,6 +1866,175 @@ function NavbarMenu(_ref2) {
|
|
|
1866
1866
|
});
|
|
1867
1867
|
}
|
|
1868
1868
|
|
|
1869
|
+
function getPasswordStrength(value) {
|
|
1870
|
+
var count = [hasEnoughCharacters, hasNumber, hasLowerCaseAndUpperCase, hasSpecialCharacter, hasSeveralSpecialCharacters].reduce((acc, check) => check(value) ? acc += 1 : acc, 0);
|
|
1871
|
+
if (count === 1 || count === 2) return 'weak';
|
|
1872
|
+
if (count === 3) return 'average';
|
|
1873
|
+
if (count >= 4) {
|
|
1874
|
+
return value.length > 11 ? 'strong' : 'good';
|
|
1875
|
+
}
|
|
1876
|
+
return undefined;
|
|
1877
|
+
}
|
|
1878
|
+
function hasEnoughCharacters(text) {
|
|
1879
|
+
return text.trim().length > 7;
|
|
1880
|
+
}
|
|
1881
|
+
function hasNumber(text) {
|
|
1882
|
+
return /(?=.*[0-9])/.test(text);
|
|
1883
|
+
}
|
|
1884
|
+
function hasLowerCaseAndUpperCase(text) {
|
|
1885
|
+
return /^(?=.*[a-z])(?=.*[A-Z]).+$/.test(text);
|
|
1886
|
+
}
|
|
1887
|
+
function hasSpecialCharacter(text) {
|
|
1888
|
+
return /[!@#$%^&*()_+\-={[}\]|\\;:'"<>?,.]/.test(text);
|
|
1889
|
+
}
|
|
1890
|
+
function hasSeveralSpecialCharacters(text) {
|
|
1891
|
+
var regex = /[!@#$%^&*()_+\-={[}\]|\\;:'"<>?,.]/g;
|
|
1892
|
+
var charactersList = text.match(regex);
|
|
1893
|
+
return !!charactersList && charactersList.length > 1;
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
var ListItem = /*#__PURE__*/styled.div.withConfig({
|
|
1897
|
+
displayName: "PasswordValidationComponents__ListItem",
|
|
1898
|
+
componentId: "SD__sc-ikou1j-0"
|
|
1899
|
+
})(["display:flex;align-items:center;"]);
|
|
1900
|
+
var Dot = /*#__PURE__*/styled.div.withConfig({
|
|
1901
|
+
displayName: "PasswordValidationComponents__Dot",
|
|
1902
|
+
componentId: "SD__sc-ikou1j-1"
|
|
1903
|
+
})(["height:4px;width:4px;background-color:", ";border-radius:100px;"], Color.Blue300);
|
|
1904
|
+
var TickBox = /*#__PURE__*/styled(Box).withConfig({
|
|
1905
|
+
displayName: "PasswordValidationComponents__TickBox",
|
|
1906
|
+
componentId: "SD__sc-ikou1j-2"
|
|
1907
|
+
})(["width:13.33px;height:13.33px;border-radius:15px;background-color:", ";display:flex;align-items:center;justify-content:center;"], ColorDynamic.Blue50);
|
|
1908
|
+
function CheckPasswordItem(_ref) {
|
|
1909
|
+
var {
|
|
1910
|
+
isDone,
|
|
1911
|
+
text
|
|
1912
|
+
} = _ref;
|
|
1913
|
+
return /*#__PURE__*/jsxs(ListItem, {
|
|
1914
|
+
children: [/*#__PURE__*/jsx(Box, {
|
|
1915
|
+
minWidth: "16px",
|
|
1916
|
+
children: /*#__PURE__*/jsx(Inline, {
|
|
1917
|
+
verticalAlign: "center",
|
|
1918
|
+
horizontalAlign: "center",
|
|
1919
|
+
children: isDone ? /*#__PURE__*/jsx(TickBox, {
|
|
1920
|
+
children: /*#__PURE__*/jsx(Check, {
|
|
1921
|
+
style: {
|
|
1922
|
+
fontSize: '10px',
|
|
1923
|
+
color: Color.Green500
|
|
1924
|
+
}
|
|
1925
|
+
})
|
|
1926
|
+
}) : /*#__PURE__*/jsx(Dot, {})
|
|
1927
|
+
})
|
|
1928
|
+
}), text]
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
var Stepper = /*#__PURE__*/styled.div.withConfig({
|
|
1932
|
+
displayName: "PasswordValidationComponents__Stepper",
|
|
1933
|
+
componentId: "SD__sc-ikou1j-3"
|
|
1934
|
+
})(["height:5px;display:flex;width:100%;margin-bottom:8px;margin-top:4px;"]);
|
|
1935
|
+
var StepperItem = /*#__PURE__*/styled.div.withConfig({
|
|
1936
|
+
displayName: "PasswordValidationComponents__StepperItem",
|
|
1937
|
+
componentId: "SD__sc-ikou1j-4"
|
|
1938
|
+
})(["height:2px;background-color:", ";flex:1;border-radius:100px;&:not(:last-child){margin-right:10px;flex:1;}"], _ref2 => {
|
|
1939
|
+
var {
|
|
1940
|
+
isActive,
|
|
1941
|
+
passwordStrength
|
|
1942
|
+
} = _ref2;
|
|
1943
|
+
return getStepperItemColor(isActive, passwordStrength);
|
|
1944
|
+
});
|
|
1945
|
+
function getStepperItemColor(isActive, passwordStrength) {
|
|
1946
|
+
if (!isActive || !passwordStrength) return ColorDynamic.Silver400;
|
|
1947
|
+
switch (isActive) {
|
|
1948
|
+
case passwordStrength === 'strong':
|
|
1949
|
+
return ColorDynamic.Green500;
|
|
1950
|
+
case passwordStrength === 'weak':
|
|
1951
|
+
return ColorDynamic.Red500;
|
|
1952
|
+
case passwordStrength === 'average':
|
|
1953
|
+
return ColorDynamic.Yellow500;
|
|
1954
|
+
case passwordStrength === 'good':
|
|
1955
|
+
return ColorDynamic.Green500;
|
|
1956
|
+
default:
|
|
1957
|
+
return ColorDynamic.Silver400;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
var passwordStepperTitle = {
|
|
1962
|
+
weak: {
|
|
1963
|
+
textColor: ColorDynamic.Red500,
|
|
1964
|
+
text: 'Weak Password'
|
|
1965
|
+
},
|
|
1966
|
+
average: {
|
|
1967
|
+
textColor: ColorDynamic.Yellow500,
|
|
1968
|
+
text: 'Average Password'
|
|
1969
|
+
},
|
|
1970
|
+
good: {
|
|
1971
|
+
textColor: ColorDynamic.Green500,
|
|
1972
|
+
text: 'Good Password'
|
|
1973
|
+
},
|
|
1974
|
+
strong: {
|
|
1975
|
+
textColor: ColorDynamic.Green500,
|
|
1976
|
+
text: 'Strong Password'
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
var passwordStrengthToActiveStepsCount = {
|
|
1980
|
+
weak: 1,
|
|
1981
|
+
average: 2,
|
|
1982
|
+
good: 3,
|
|
1983
|
+
strong: 4
|
|
1984
|
+
};
|
|
1985
|
+
function steps(passwordStrength) {
|
|
1986
|
+
return [passwordStrengthToActiveStepsCount[passwordStrength] >= 1, passwordStrengthToActiveStepsCount[passwordStrength] >= 2, passwordStrengthToActiveStepsCount[passwordStrength] >= 3, passwordStrengthToActiveStepsCount[passwordStrength] >= 4];
|
|
1987
|
+
}
|
|
1988
|
+
var PasswordText = /*#__PURE__*/styled(Typography).withConfig({
|
|
1989
|
+
displayName: "PasswordStrength__PasswordText",
|
|
1990
|
+
componentId: "SD__sc-1ddnv91-0"
|
|
1991
|
+
})(["color:", ";"], _ref => {
|
|
1992
|
+
var {
|
|
1993
|
+
colorProp
|
|
1994
|
+
} = _ref;
|
|
1995
|
+
return colorProp !== null && colorProp !== void 0 ? colorProp : Color.Dark100;
|
|
1996
|
+
});
|
|
1997
|
+
function PasswordStrength(_ref2) {
|
|
1998
|
+
var {
|
|
1999
|
+
value
|
|
2000
|
+
} = _ref2;
|
|
2001
|
+
var passwordStrength = useMemo(() => getPasswordStrength(value), [value]);
|
|
2002
|
+
return /*#__PURE__*/jsxs(Box, {
|
|
2003
|
+
children: [/*#__PURE__*/jsxs(Box, {
|
|
2004
|
+
children: [/*#__PURE__*/jsx(PasswordText, {
|
|
2005
|
+
variant: "body2",
|
|
2006
|
+
colorProp: passwordStrength && passwordStepperTitle[passwordStrength].textColor,
|
|
2007
|
+
children: passwordStrength ? passwordStepperTitle[passwordStrength].text : 'Password Strength'
|
|
2008
|
+
}), /*#__PURE__*/jsx(Stepper, {
|
|
2009
|
+
children: steps(passwordStrength !== null && passwordStrength !== void 0 ? passwordStrength : '').map((isStepActive, index) => /*#__PURE__*/jsx(StepperItem, {
|
|
2010
|
+
isActive: isStepActive,
|
|
2011
|
+
passwordStrength: passwordStrength
|
|
2012
|
+
}, index))
|
|
2013
|
+
})]
|
|
2014
|
+
}), /*#__PURE__*/jsxs(Box, {
|
|
2015
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
2016
|
+
variant: "body2",
|
|
2017
|
+
children: "It must have:"
|
|
2018
|
+
}), /*#__PURE__*/jsxs(Stack, {
|
|
2019
|
+
space: "xxsmall",
|
|
2020
|
+
children: [/*#__PURE__*/jsx(CheckPasswordItem, {
|
|
2021
|
+
isDone: hasEnoughCharacters(value),
|
|
2022
|
+
text: "At least 8 characters"
|
|
2023
|
+
}), /*#__PURE__*/jsx(CheckPasswordItem, {
|
|
2024
|
+
isDone: hasLowerCaseAndUpperCase(value),
|
|
2025
|
+
text: "Upper & lowercase letters"
|
|
2026
|
+
}), /*#__PURE__*/jsx(CheckPasswordItem, {
|
|
2027
|
+
isDone: hasNumber(value),
|
|
2028
|
+
text: "A number"
|
|
2029
|
+
}), /*#__PURE__*/jsx(CheckPasswordItem, {
|
|
2030
|
+
isDone: hasSpecialCharacter(value),
|
|
2031
|
+
text: "A special character (%, $, #, etc.)"
|
|
2032
|
+
})]
|
|
2033
|
+
})]
|
|
2034
|
+
})]
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
|
|
1869
2038
|
var SidebarRoot = /*#__PURE__*/styled.aside.withConfig({
|
|
1870
2039
|
displayName: "Sidebar__SidebarRoot",
|
|
1871
2040
|
componentId: "SD__sc-b77o22-0"
|
|
@@ -2348,5 +2517,5 @@ var SidebarSubheader = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
2348
2517
|
});
|
|
2349
2518
|
if (process.env.NODE_ENV !== "production") SidebarSubheader.displayName = "SidebarSubheader";
|
|
2350
2519
|
|
|
2351
|
-
export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, Chat, ChatMessage, Container, DescriptionItem, DescriptionLineItem, DottedLine, EmailAutocomplete, FileDropZone, FileListItem, FlagList, FlagListItem, LinkedText, MultilineText, Navbar, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarItem, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, Sidebar, SidebarBackButton, SidebarContainer, SidebarContent, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes, useNavbarContext, useSidebarContext };
|
|
2520
|
+
export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, Chat, ChatMessage, Container, DescriptionItem, DescriptionLineItem, DottedLine, EmailAutocomplete, FileDropZone, FileListItem, FlagList, FlagListItem, LinkedText, MultilineText, Navbar, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarItem, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, PasswordStrength, Sidebar, SidebarBackButton, SidebarContainer, SidebarContent, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes, useNavbarContext, useSidebarContext };
|
|
2352
2521
|
//# sourceMappingURL=index.js.map
|