ywana-core8 0.1.16 → 0.1.18
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/index.cjs +142 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +15 -7
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +142 -55
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +142 -55
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/icon.js +3 -3
- package/src/html/textfield.js +18 -2
- package/src/widgets/login/HelloTest.js +7 -0
- package/src/widgets/login/LoginBox.js +1 -1
- package/src/widgets/login/ResetPasswordBox.css +15 -7
- package/src/widgets/login/ResetPasswordBox.js +101 -37
- package/src/widgets/login/ResetPasswordBoxTest.js +14 -4
- package/src/widgets/login/login_commons.js +6 -6
- package/preview.config.cjs +0 -35
package/dist/index.modern.js
CHANGED
@@ -267,7 +267,8 @@ var Tooltip = function Tooltip(props) {
|
|
267
267
|
* Icon
|
268
268
|
*/
|
269
269
|
var Icon = function Icon(_ref) {
|
270
|
-
var
|
270
|
+
var id = _ref.id,
|
271
|
+
icon = _ref.icon,
|
271
272
|
_ref$size = _ref.size,
|
272
273
|
size = _ref$size === void 0 ? "normal" : _ref$size,
|
273
274
|
tooltip = _ref.tooltip,
|
@@ -288,9 +289,11 @@ var Icon = function Icon(_ref) {
|
|
288
289
|
}
|
289
290
|
var style = disabled ? "disabled" : clickable ? "clickable" : "";
|
290
291
|
return tooltip ? /*#__PURE__*/React.createElement(Tooltip, tooltip, /*#__PURE__*/React.createElement("i", {
|
292
|
+
id: id,
|
291
293
|
className: "icon " + size + " " + style + " " + className + " material-icons",
|
292
294
|
onClick: click
|
293
295
|
}, icon)) : /*#__PURE__*/React.createElement("i", {
|
296
|
+
id: id,
|
294
297
|
className: "icon " + size + " " + style + " " + className + " material-icons",
|
295
298
|
onClick: click
|
296
299
|
}, icon);
|
@@ -1354,7 +1357,9 @@ var TextField = function TextField(props) {
|
|
1354
1357
|
onEnter = props.onEnter,
|
1355
1358
|
onClick = props.onClick,
|
1356
1359
|
onFocus = props.onFocus,
|
1357
|
-
onBlur = props.onBlur
|
1360
|
+
onBlur = props.onBlur,
|
1361
|
+
_props$autoComplete = props.autoComplete,
|
1362
|
+
autoComplete = _props$autoComplete === void 0 ? false : _props$autoComplete;
|
1358
1363
|
function onKeyPress(event) {
|
1359
1364
|
var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;
|
1360
1365
|
if (key == 13) {
|
@@ -1376,6 +1381,20 @@ var TextField = function TextField(props) {
|
|
1376
1381
|
function clear() {
|
1377
1382
|
if (onChange) onChange(id, "");
|
1378
1383
|
}
|
1384
|
+
function toggle() {
|
1385
|
+
var input = document.getElementById(id);
|
1386
|
+
var icon = document.getElementById(id + "-visibility");
|
1387
|
+
if (input) {
|
1388
|
+
var _type = input.getAttribute("type");
|
1389
|
+
if (_type === "password") {
|
1390
|
+
input.setAttribute("type", "text");
|
1391
|
+
icon.setHTMLUnsafe("visibility");
|
1392
|
+
} else {
|
1393
|
+
input.setAttribute("type", "password");
|
1394
|
+
icon.setHTMLUnsafe("visibility_off");
|
1395
|
+
}
|
1396
|
+
}
|
1397
|
+
}
|
1379
1398
|
var borderStyle = outlined ? "textfield-outlined" : "textfield";
|
1380
1399
|
var labelStyle = label ? "" : "no-label";
|
1381
1400
|
var labelPositionStyle = labelPosition == 'left' ? "label-left" : "label-top";
|
@@ -1396,12 +1415,19 @@ var TextField = function TextField(props) {
|
|
1396
1415
|
onFocus: focus,
|
1397
1416
|
onBlur: blur,
|
1398
1417
|
readOnly: readOnly,
|
1399
|
-
step: "any"
|
1418
|
+
step: "any",
|
1419
|
+
autoComplete: autoComplete
|
1400
1420
|
}), readOnly === false && canClear && value && value.length > 0 ? /*#__PURE__*/React.createElement(Icon, {
|
1401
1421
|
icon: "close",
|
1402
1422
|
clickable: true,
|
1403
1423
|
size: "small",
|
1404
1424
|
action: clear
|
1425
|
+
}) : null, type === "password" ? /*#__PURE__*/React.createElement(Icon, {
|
1426
|
+
id: id + "-visibility",
|
1427
|
+
icon: "visibility_off",
|
1428
|
+
clickable: true,
|
1429
|
+
size: "small",
|
1430
|
+
action: toggle
|
1405
1431
|
}) : null, /*#__PURE__*/React.createElement("span", {
|
1406
1432
|
className: "bar"
|
1407
1433
|
}), label ? /*#__PURE__*/React.createElement("label", null, labelTxt) : null);
|
@@ -1729,6 +1755,7 @@ var LoginBox = function LoginBox(_ref) {
|
|
1729
1755
|
onEnter: ok,
|
1730
1756
|
outlined: true
|
1731
1757
|
}), /*#__PURE__*/React.createElement(TextField, {
|
1758
|
+
id: "loginbox-password",
|
1732
1759
|
label: tx(passwordLabel),
|
1733
1760
|
value: password,
|
1734
1761
|
onChange: changePassword,
|
@@ -1760,37 +1787,37 @@ function validatePassword(contraseña) {
|
|
1760
1787
|
|
1761
1788
|
// Verificar longitud mínima y máxima
|
1762
1789
|
if (contraseña.length < 15 || contraseña.length > 50) {
|
1763
|
-
error = '
|
1790
|
+
error = 'The password must be between 15 and 50 characters.';
|
1764
1791
|
return [false, error];
|
1765
1792
|
}
|
1766
1793
|
|
1767
1794
|
// Verificar al menos una letra (mayúscula o minúscula)
|
1768
1795
|
if (!/[A-Za-z]/.test(contraseña)) {
|
1769
|
-
error = '
|
1796
|
+
error = 'The password must contain at least one letter (A-Z or a-z).';
|
1770
1797
|
return [false, error];
|
1771
1798
|
}
|
1772
1799
|
|
1773
1800
|
// Verificar al menos un número
|
1774
1801
|
if (!/[0-9]/.test(contraseña)) {
|
1775
|
-
error = '
|
1802
|
+
error = 'The password must contain at least one number (0-9).';
|
1776
1803
|
return [false, error];
|
1777
1804
|
}
|
1778
1805
|
|
1779
1806
|
// Verificar al menos una minúscula
|
1780
1807
|
if (!/[a-z]/.test(contraseña)) {
|
1781
|
-
error = '
|
1808
|
+
error = 'The password must contain at least one lowercase letter (a-z).';
|
1782
1809
|
return [false, error];
|
1783
1810
|
}
|
1784
1811
|
|
1785
1812
|
// Verificar al menos una mayúscula
|
1786
1813
|
if (!/[A-Z]/.test(contraseña)) {
|
1787
|
-
error = '
|
1814
|
+
error = 'The password must contain at least one uppercase letter (A-Z).';
|
1788
1815
|
return [false, error];
|
1789
1816
|
}
|
1790
1817
|
|
1791
1818
|
// Verificar al menos un carácter especial
|
1792
1819
|
if (!/[<>+&!?*\-_%\.:=]/.test(contraseña)) {
|
1793
|
-
error = '
|
1820
|
+
error = 'The password must contain at least one special character (< > + & ! ? * - _ % . : =).';
|
1794
1821
|
return [false, error];
|
1795
1822
|
}
|
1796
1823
|
|
@@ -1804,47 +1831,100 @@ function validatePassword(contraseña) {
|
|
1804
1831
|
* Reset Password
|
1805
1832
|
*/
|
1806
1833
|
var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
1807
|
-
var
|
1808
|
-
title = _ref.title,
|
1834
|
+
var title = _ref.title,
|
1809
1835
|
_ref$userRequired = _ref.userRequired,
|
1810
1836
|
userRequired = _ref$userRequired === void 0 ? true : _ref$userRequired,
|
1811
1837
|
_ref$oldPwdRequired = _ref.oldPwdRequired,
|
1812
1838
|
oldPwdRequired = _ref$oldPwdRequired === void 0 ? false : _ref$oldPwdRequired,
|
1813
|
-
|
1814
|
-
lang = _ref$lang === void 0 ? "EN" : _ref$lang,
|
1839
|
+
validator = _ref.validator,
|
1815
1840
|
children = _ref.children,
|
1816
|
-
onOK = _ref.onOK
|
1817
|
-
|
1818
|
-
|
1841
|
+
onOK = _ref.onOK;
|
1842
|
+
var _useState = useState({
|
1843
|
+
user: "",
|
1844
|
+
oldPassword: "",
|
1845
|
+
password1: "",
|
1846
|
+
password2: ""
|
1847
|
+
}),
|
1819
1848
|
form = _useState[0],
|
1820
1849
|
setForm = _useState[1];
|
1821
1850
|
var _useState2 = useState(false),
|
1822
1851
|
isValid = _useState2[0],
|
1823
1852
|
setIsValid = _useState2[1];
|
1824
|
-
var _useState3 = useState(),
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
var
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
var
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1853
|
+
var _useState3 = useState({}),
|
1854
|
+
errors = _useState3[0],
|
1855
|
+
setErrors = _useState3[1];
|
1856
|
+
function validateUser(user) {
|
1857
|
+
var error = "";
|
1858
|
+
var isValid = user && user.length > 0;
|
1859
|
+
error = /*#__PURE__*/React.createElement(Text, null, "User is required.");
|
1860
|
+
return [isValid, error];
|
1861
|
+
}
|
1862
|
+
function validateOldPassword(oldPassword) {
|
1863
|
+
var error = "";
|
1864
|
+
var isValid = oldPassword && oldPassword.length > 0;
|
1865
|
+
error = /*#__PURE__*/React.createElement(Text, null, "Old password is required.");
|
1866
|
+
return [isValid, error];
|
1867
|
+
}
|
1868
|
+
function validateNewPassword(password) {
|
1869
|
+
var hasPassword = password && password.length > 0;
|
1870
|
+
if (!hasPassword) {
|
1871
|
+
var _error = /*#__PURE__*/React.createElement(Text, null, "Password is required");
|
1872
|
+
return [false, _error];
|
1873
|
+
}
|
1874
|
+
var _ref2 = validator && typeof validator === 'function' ? validator(password) : validatePassword(password),
|
1839
1875
|
isValid = _ref2[0],
|
1840
1876
|
error = _ref2[1];
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1877
|
+
if (!isValid) {
|
1878
|
+
return [false, error];
|
1879
|
+
}
|
1880
|
+
return [true, ""];
|
1881
|
+
}
|
1882
|
+
function validatePasswordsMatch(password1, password2) {
|
1883
|
+
var error = "";
|
1884
|
+
var isValid = password1 === password2;
|
1885
|
+
error = /*#__PURE__*/React.createElement(Text, null, "Passwords do not match.");
|
1886
|
+
return [isValid, error];
|
1887
|
+
}
|
1888
|
+
function validate(form) {
|
1889
|
+
var isValid = true;
|
1890
|
+
var nextErrors = Object.assign({}, errors);
|
1891
|
+
if (userRequired) {
|
1892
|
+
var _validateUser = validateUser(form.user),
|
1893
|
+
validation = _validateUser[0],
|
1894
|
+
error = _validateUser[1];
|
1895
|
+
if (isValid) isValid = validation;
|
1896
|
+
nextErrors.user = error;
|
1897
|
+
}
|
1898
|
+
if (oldPwdRequired) {
|
1899
|
+
var _validateOldPassword = validateOldPassword(form.oldPassword),
|
1900
|
+
_validation = _validateOldPassword[0],
|
1901
|
+
_error2 = _validateOldPassword[1];
|
1902
|
+
if (isValid) isValid = _validation;
|
1903
|
+
nextErrors.oldPassword = _error2;
|
1904
|
+
}
|
1905
|
+
var _validateNewPassword = validateNewPassword(form.password1),
|
1906
|
+
pwdValidation = _validateNewPassword[0],
|
1907
|
+
pwdError = _validateNewPassword[1];
|
1908
|
+
if (isValid) isValid = pwdValidation;
|
1909
|
+
nextErrors.password1 = pwdError;
|
1910
|
+
var _validateNewPassword2 = validateNewPassword(form.password2),
|
1911
|
+
pwd2Validation = _validateNewPassword2[0],
|
1912
|
+
pwd2Error = _validateNewPassword2[1];
|
1913
|
+
var _validatePasswordsMat = validatePasswordsMatch(form.password1, form.password2),
|
1914
|
+
matchValidation = _validatePasswordsMat[0],
|
1915
|
+
matchError = _validatePasswordsMat[1];
|
1916
|
+
if (isValid) isValid = matchValidation && pwd2Validation;
|
1917
|
+
nextErrors.password2 = matchError || pwd2Error;
|
1918
|
+
return [isValid, nextErrors];
|
1844
1919
|
}
|
1845
1920
|
function changeField(id, value) {
|
1846
1921
|
var _Object$assign;
|
1847
1922
|
var next = Object.assign({}, form, (_Object$assign = {}, _Object$assign[id] = value, _Object$assign));
|
1923
|
+
var _validate = validate(next),
|
1924
|
+
isValid = _validate[0],
|
1925
|
+
errors = _validate[1];
|
1926
|
+
setIsValid(isValid);
|
1927
|
+
setErrors(errors);
|
1848
1928
|
setForm(next);
|
1849
1929
|
}
|
1850
1930
|
function ok() {
|
@@ -1852,30 +1932,34 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1852
1932
|
onOK(form);
|
1853
1933
|
}
|
1854
1934
|
}
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
var
|
1859
|
-
var
|
1860
|
-
var
|
1861
|
-
var
|
1862
|
-
var
|
1935
|
+
var userLabel = /*#__PURE__*/React.createElement(Text, null, "User");
|
1936
|
+
var passwordLabel = /*#__PURE__*/React.createElement(Text, null, "New Password");
|
1937
|
+
var password2Label = /*#__PURE__*/React.createElement(Text, null, "Confirm New Password");
|
1938
|
+
var okLabel = /*#__PURE__*/React.createElement(Text, null, "OK");
|
1939
|
+
var userStyle = errors.user ? "error" : "";
|
1940
|
+
var oldPasswordStyle = errors.oldPassword ? "error" : "";
|
1941
|
+
var password1Style = errors.password1 ? "error" : "";
|
1942
|
+
var password2Style = errors.password2 ? "error" : "";
|
1863
1943
|
return /*#__PURE__*/React.createElement("div", {
|
1864
1944
|
className: "reset-password-box"
|
1865
|
-
}, /*#__PURE__*/React.createElement("header", null,
|
1866
|
-
src: logo
|
1867
|
-
}) : null, title ? /*#__PURE__*/React.createElement("div", {
|
1945
|
+
}, /*#__PURE__*/React.createElement("header", null, title ? /*#__PURE__*/React.createElement("div", {
|
1868
1946
|
className: "title"
|
1869
|
-
}, /*#__PURE__*/React.createElement(Text, null, title)) : null
|
1947
|
+
}, /*#__PURE__*/React.createElement(Text, null, title)) : null), /*#__PURE__*/React.createElement("main", {
|
1948
|
+
className: "reset-password-form"
|
1949
|
+
}, userRequired ? /*#__PURE__*/React.createElement(TextField, {
|
1870
1950
|
id: "user",
|
1951
|
+
className: userStyle,
|
1871
1952
|
outlined: true,
|
1872
1953
|
icon: "person",
|
1873
1954
|
label: userLabel,
|
1874
1955
|
lapse: 100,
|
1875
1956
|
onChange: changeField,
|
1876
1957
|
onEnter: ok
|
1877
|
-
}) : null,
|
1958
|
+
}) : null, userRequired ? errors.user ? /*#__PURE__*/React.createElement("div", {
|
1959
|
+
className: "error-message"
|
1960
|
+
}, errors.user) : null : null, oldPwdRequired ? /*#__PURE__*/React.createElement(TextField, {
|
1878
1961
|
id: "oldPassword",
|
1962
|
+
className: oldPasswordStyle,
|
1879
1963
|
outlined: true,
|
1880
1964
|
icon: "lock",
|
1881
1965
|
type: "password",
|
@@ -1883,8 +1967,11 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1883
1967
|
lapse: 100,
|
1884
1968
|
onChange: changeField,
|
1885
1969
|
onEnter: ok
|
1886
|
-
}) : null, /*#__PURE__*/React.createElement(
|
1970
|
+
}) : null, oldPwdRequired ? errors.oldPassword ? /*#__PURE__*/React.createElement("div", {
|
1971
|
+
className: "error-message"
|
1972
|
+
}, errors.oldPassword) : null : null, /*#__PURE__*/React.createElement(TextField, {
|
1887
1973
|
id: "password1",
|
1974
|
+
className: password1Style,
|
1888
1975
|
outlined: true,
|
1889
1976
|
icon: "lock",
|
1890
1977
|
type: "password",
|
@@ -1892,8 +1979,11 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1892
1979
|
lapse: 100,
|
1893
1980
|
onChange: changeField,
|
1894
1981
|
onEnter: ok
|
1895
|
-
}), /*#__PURE__*/React.createElement(
|
1982
|
+
}), errors.password1 ? /*#__PURE__*/React.createElement("div", {
|
1983
|
+
className: "error-message"
|
1984
|
+
}, errors.password1) : null, children, /*#__PURE__*/React.createElement(TextField, {
|
1896
1985
|
id: "password2",
|
1986
|
+
className: password2Style,
|
1897
1987
|
outlined: true,
|
1898
1988
|
icon: "lock",
|
1899
1989
|
type: "password",
|
@@ -1901,12 +1991,9 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1901
1991
|
lapse: 100,
|
1902
1992
|
onChange: changeField,
|
1903
1993
|
onEnter: ok
|
1904
|
-
}),
|
1905
|
-
className: "error"
|
1906
|
-
},
|
1907
|
-
label: cancelLabel,
|
1908
|
-
action: close
|
1909
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
1994
|
+
}), errors.password2 ? /*#__PURE__*/React.createElement("div", {
|
1995
|
+
className: "error-message"
|
1996
|
+
}, errors.password2) : null), /*#__PURE__*/React.createElement("footer", null, /*#__PURE__*/React.createElement(Button, {
|
1910
1997
|
label: okLabel,
|
1911
1998
|
raised: true,
|
1912
1999
|
disabled: !isValid,
|