@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-node/index.js
CHANGED
|
@@ -1873,6 +1873,175 @@ function NavbarMenu(_ref2) {
|
|
|
1873
1873
|
});
|
|
1874
1874
|
}
|
|
1875
1875
|
|
|
1876
|
+
function getPasswordStrength(value) {
|
|
1877
|
+
var count = [hasEnoughCharacters, hasNumber, hasLowerCaseAndUpperCase, hasSpecialCharacter, hasSeveralSpecialCharacters].reduce((acc, check) => check(value) ? acc += 1 : acc, 0);
|
|
1878
|
+
if (count === 1 || count === 2) return 'weak';
|
|
1879
|
+
if (count === 3) return 'average';
|
|
1880
|
+
if (count >= 4) {
|
|
1881
|
+
return value.length > 11 ? 'strong' : 'good';
|
|
1882
|
+
}
|
|
1883
|
+
return undefined;
|
|
1884
|
+
}
|
|
1885
|
+
function hasEnoughCharacters(text) {
|
|
1886
|
+
return text.trim().length > 7;
|
|
1887
|
+
}
|
|
1888
|
+
function hasNumber(text) {
|
|
1889
|
+
return /(?=.*[0-9])/.test(text);
|
|
1890
|
+
}
|
|
1891
|
+
function hasLowerCaseAndUpperCase(text) {
|
|
1892
|
+
return /^(?=.*[a-z])(?=.*[A-Z]).+$/.test(text);
|
|
1893
|
+
}
|
|
1894
|
+
function hasSpecialCharacter(text) {
|
|
1895
|
+
return /[!@#$%^&*()_+\-={[}\]|\\;:'"<>?,.]/.test(text);
|
|
1896
|
+
}
|
|
1897
|
+
function hasSeveralSpecialCharacters(text) {
|
|
1898
|
+
var regex = /[!@#$%^&*()_+\-={[}\]|\\;:'"<>?,.]/g;
|
|
1899
|
+
var charactersList = text.match(regex);
|
|
1900
|
+
return !!charactersList && charactersList.length > 1;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
var ListItem = /*#__PURE__*/styled__default.div.withConfig({
|
|
1904
|
+
displayName: "PasswordValidationComponents__ListItem",
|
|
1905
|
+
componentId: "SD__sc-ikou1j-0"
|
|
1906
|
+
})(["display:flex;align-items:center;"]);
|
|
1907
|
+
var Dot = /*#__PURE__*/styled__default.div.withConfig({
|
|
1908
|
+
displayName: "PasswordValidationComponents__Dot",
|
|
1909
|
+
componentId: "SD__sc-ikou1j-1"
|
|
1910
|
+
})(["height:4px;width:4px;background-color:", ";border-radius:100px;"], ui.Color.Blue300);
|
|
1911
|
+
var TickBox = /*#__PURE__*/styled__default(Box).withConfig({
|
|
1912
|
+
displayName: "PasswordValidationComponents__TickBox",
|
|
1913
|
+
componentId: "SD__sc-ikou1j-2"
|
|
1914
|
+
})(["width:13.33px;height:13.33px;border-radius:15px;background-color:", ";display:flex;align-items:center;justify-content:center;"], ui.ColorDynamic.Blue50);
|
|
1915
|
+
function CheckPasswordItem(_ref) {
|
|
1916
|
+
var {
|
|
1917
|
+
isDone,
|
|
1918
|
+
text
|
|
1919
|
+
} = _ref;
|
|
1920
|
+
return /*#__PURE__*/jsxRuntime.jsxs(ListItem, {
|
|
1921
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Box, {
|
|
1922
|
+
minWidth: "16px",
|
|
1923
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ui.Inline, {
|
|
1924
|
+
verticalAlign: "center",
|
|
1925
|
+
horizontalAlign: "center",
|
|
1926
|
+
children: isDone ? /*#__PURE__*/jsxRuntime.jsx(TickBox, {
|
|
1927
|
+
children: /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
|
|
1928
|
+
style: {
|
|
1929
|
+
fontSize: '10px',
|
|
1930
|
+
color: ui.Color.Green500
|
|
1931
|
+
}
|
|
1932
|
+
})
|
|
1933
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(Dot, {})
|
|
1934
|
+
})
|
|
1935
|
+
}), text]
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
var Stepper = /*#__PURE__*/styled__default.div.withConfig({
|
|
1939
|
+
displayName: "PasswordValidationComponents__Stepper",
|
|
1940
|
+
componentId: "SD__sc-ikou1j-3"
|
|
1941
|
+
})(["height:5px;display:flex;width:100%;margin-bottom:8px;margin-top:4px;"]);
|
|
1942
|
+
var StepperItem = /*#__PURE__*/styled__default.div.withConfig({
|
|
1943
|
+
displayName: "PasswordValidationComponents__StepperItem",
|
|
1944
|
+
componentId: "SD__sc-ikou1j-4"
|
|
1945
|
+
})(["height:2px;background-color:", ";flex:1;border-radius:100px;&:not(:last-child){margin-right:10px;flex:1;}"], _ref2 => {
|
|
1946
|
+
var {
|
|
1947
|
+
isActive,
|
|
1948
|
+
passwordStrength
|
|
1949
|
+
} = _ref2;
|
|
1950
|
+
return getStepperItemColor(isActive, passwordStrength);
|
|
1951
|
+
});
|
|
1952
|
+
function getStepperItemColor(isActive, passwordStrength) {
|
|
1953
|
+
if (!isActive || !passwordStrength) return ui.ColorDynamic.Silver400;
|
|
1954
|
+
switch (isActive) {
|
|
1955
|
+
case passwordStrength === 'strong':
|
|
1956
|
+
return ui.ColorDynamic.Green500;
|
|
1957
|
+
case passwordStrength === 'weak':
|
|
1958
|
+
return ui.ColorDynamic.Red500;
|
|
1959
|
+
case passwordStrength === 'average':
|
|
1960
|
+
return ui.ColorDynamic.Yellow500;
|
|
1961
|
+
case passwordStrength === 'good':
|
|
1962
|
+
return ui.ColorDynamic.Green500;
|
|
1963
|
+
default:
|
|
1964
|
+
return ui.ColorDynamic.Silver400;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
var passwordStepperTitle = {
|
|
1969
|
+
weak: {
|
|
1970
|
+
textColor: ui.ColorDynamic.Red500,
|
|
1971
|
+
text: 'Weak Password'
|
|
1972
|
+
},
|
|
1973
|
+
average: {
|
|
1974
|
+
textColor: ui.ColorDynamic.Yellow500,
|
|
1975
|
+
text: 'Average Password'
|
|
1976
|
+
},
|
|
1977
|
+
good: {
|
|
1978
|
+
textColor: ui.ColorDynamic.Green500,
|
|
1979
|
+
text: 'Good Password'
|
|
1980
|
+
},
|
|
1981
|
+
strong: {
|
|
1982
|
+
textColor: ui.ColorDynamic.Green500,
|
|
1983
|
+
text: 'Strong Password'
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
var passwordStrengthToActiveStepsCount = {
|
|
1987
|
+
weak: 1,
|
|
1988
|
+
average: 2,
|
|
1989
|
+
good: 3,
|
|
1990
|
+
strong: 4
|
|
1991
|
+
};
|
|
1992
|
+
function steps(passwordStrength) {
|
|
1993
|
+
return [passwordStrengthToActiveStepsCount[passwordStrength] >= 1, passwordStrengthToActiveStepsCount[passwordStrength] >= 2, passwordStrengthToActiveStepsCount[passwordStrength] >= 3, passwordStrengthToActiveStepsCount[passwordStrength] >= 4];
|
|
1994
|
+
}
|
|
1995
|
+
var PasswordText = /*#__PURE__*/styled__default(core.Typography).withConfig({
|
|
1996
|
+
displayName: "PasswordStrength__PasswordText",
|
|
1997
|
+
componentId: "SD__sc-1ddnv91-0"
|
|
1998
|
+
})(["color:", ";"], _ref => {
|
|
1999
|
+
var {
|
|
2000
|
+
colorProp
|
|
2001
|
+
} = _ref;
|
|
2002
|
+
return colorProp !== null && colorProp !== void 0 ? colorProp : ui.Color.Dark100;
|
|
2003
|
+
});
|
|
2004
|
+
function PasswordStrength(_ref2) {
|
|
2005
|
+
var {
|
|
2006
|
+
value
|
|
2007
|
+
} = _ref2;
|
|
2008
|
+
var passwordStrength = react.useMemo(() => getPasswordStrength(value), [value]);
|
|
2009
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Box, {
|
|
2010
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Box, {
|
|
2011
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(PasswordText, {
|
|
2012
|
+
variant: "body2",
|
|
2013
|
+
colorProp: passwordStrength && passwordStepperTitle[passwordStrength].textColor,
|
|
2014
|
+
children: passwordStrength ? passwordStepperTitle[passwordStrength].text : 'Password Strength'
|
|
2015
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Stepper, {
|
|
2016
|
+
children: steps(passwordStrength !== null && passwordStrength !== void 0 ? passwordStrength : '').map((isStepActive, index) => /*#__PURE__*/jsxRuntime.jsx(StepperItem, {
|
|
2017
|
+
isActive: isStepActive,
|
|
2018
|
+
passwordStrength: passwordStrength
|
|
2019
|
+
}, index))
|
|
2020
|
+
})]
|
|
2021
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Box, {
|
|
2022
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(core.Typography, {
|
|
2023
|
+
variant: "body2",
|
|
2024
|
+
children: "It must have:"
|
|
2025
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(ui.Stack, {
|
|
2026
|
+
space: "xxsmall",
|
|
2027
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(CheckPasswordItem, {
|
|
2028
|
+
isDone: hasEnoughCharacters(value),
|
|
2029
|
+
text: "At least 8 characters"
|
|
2030
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CheckPasswordItem, {
|
|
2031
|
+
isDone: hasLowerCaseAndUpperCase(value),
|
|
2032
|
+
text: "Upper & lowercase letters"
|
|
2033
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CheckPasswordItem, {
|
|
2034
|
+
isDone: hasNumber(value),
|
|
2035
|
+
text: "A number"
|
|
2036
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CheckPasswordItem, {
|
|
2037
|
+
isDone: hasSpecialCharacter(value),
|
|
2038
|
+
text: "A special character (%, $, #, etc.)"
|
|
2039
|
+
})]
|
|
2040
|
+
})]
|
|
2041
|
+
})]
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2044
|
+
|
|
1876
2045
|
var SidebarRoot = /*#__PURE__*/styled__default.aside.withConfig({
|
|
1877
2046
|
displayName: "Sidebar__SidebarRoot",
|
|
1878
2047
|
componentId: "SD__sc-b77o22-0"
|
|
@@ -2383,6 +2552,7 @@ exports.NavbarLabel = NavbarLabel;
|
|
|
2383
2552
|
exports.NavbarList = NavbarList;
|
|
2384
2553
|
exports.NavbarMenu = NavbarMenu;
|
|
2385
2554
|
exports.NavbarMenuItem = NavbarMenuItem;
|
|
2555
|
+
exports.PasswordStrength = PasswordStrength;
|
|
2386
2556
|
exports.Sidebar = Sidebar;
|
|
2387
2557
|
exports.SidebarBackButton = SidebarBackButton;
|
|
2388
2558
|
exports.SidebarContainer = SidebarContainer;
|