ywana-core8 0.1.16 → 0.1.17
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 +130 -47
- 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 +130 -47
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +130 -47
- 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 +16 -0
- package/src/widgets/login/HelloTest.js +7 -0
- 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/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);
|
@@ -1376,6 +1379,20 @@ var TextField = function TextField(props) {
|
|
1376
1379
|
function clear() {
|
1377
1380
|
if (onChange) onChange(id, "");
|
1378
1381
|
}
|
1382
|
+
function toggle() {
|
1383
|
+
var input = document.getElementById(id);
|
1384
|
+
var icon = document.getElementById(id + "-visibility");
|
1385
|
+
if (input) {
|
1386
|
+
var _type = input.getAttribute("type");
|
1387
|
+
if (_type === "password") {
|
1388
|
+
input.setAttribute("type", "text");
|
1389
|
+
icon.setHTMLUnsafe("visibility");
|
1390
|
+
} else {
|
1391
|
+
input.setAttribute("type", "password");
|
1392
|
+
icon.setHTMLUnsafe("visibility_off");
|
1393
|
+
}
|
1394
|
+
}
|
1395
|
+
}
|
1379
1396
|
var borderStyle = outlined ? "textfield-outlined" : "textfield";
|
1380
1397
|
var labelStyle = label ? "" : "no-label";
|
1381
1398
|
var labelPositionStyle = labelPosition == 'left' ? "label-left" : "label-top";
|
@@ -1402,6 +1419,12 @@ var TextField = function TextField(props) {
|
|
1402
1419
|
clickable: true,
|
1403
1420
|
size: "small",
|
1404
1421
|
action: clear
|
1422
|
+
}) : null, type === "password" ? /*#__PURE__*/React.createElement(Icon, {
|
1423
|
+
id: id + "-visibility",
|
1424
|
+
icon: "visibility_off",
|
1425
|
+
clickable: true,
|
1426
|
+
size: "small",
|
1427
|
+
action: toggle
|
1405
1428
|
}) : null, /*#__PURE__*/React.createElement("span", {
|
1406
1429
|
className: "bar"
|
1407
1430
|
}), label ? /*#__PURE__*/React.createElement("label", null, labelTxt) : null);
|
@@ -1804,47 +1827,100 @@ function validatePassword(contraseña) {
|
|
1804
1827
|
* Reset Password
|
1805
1828
|
*/
|
1806
1829
|
var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
1807
|
-
var
|
1808
|
-
title = _ref.title,
|
1830
|
+
var title = _ref.title,
|
1809
1831
|
_ref$userRequired = _ref.userRequired,
|
1810
1832
|
userRequired = _ref$userRequired === void 0 ? true : _ref$userRequired,
|
1811
1833
|
_ref$oldPwdRequired = _ref.oldPwdRequired,
|
1812
1834
|
oldPwdRequired = _ref$oldPwdRequired === void 0 ? false : _ref$oldPwdRequired,
|
1813
|
-
|
1814
|
-
lang = _ref$lang === void 0 ? "EN" : _ref$lang,
|
1835
|
+
validator = _ref.validator,
|
1815
1836
|
children = _ref.children,
|
1816
|
-
onOK = _ref.onOK
|
1817
|
-
|
1818
|
-
|
1837
|
+
onOK = _ref.onOK;
|
1838
|
+
var _useState = useState({
|
1839
|
+
user: "",
|
1840
|
+
oldPassword: "",
|
1841
|
+
password1: "",
|
1842
|
+
password2: ""
|
1843
|
+
}),
|
1819
1844
|
form = _useState[0],
|
1820
1845
|
setForm = _useState[1];
|
1821
1846
|
var _useState2 = useState(false),
|
1822
1847
|
isValid = _useState2[0],
|
1823
1848
|
setIsValid = _useState2[1];
|
1824
|
-
var _useState3 = useState(),
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
var
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
var
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1849
|
+
var _useState3 = useState({}),
|
1850
|
+
errors = _useState3[0],
|
1851
|
+
setErrors = _useState3[1];
|
1852
|
+
function validateUser(user) {
|
1853
|
+
var error = "";
|
1854
|
+
var isValid = user && user.length > 0;
|
1855
|
+
error = /*#__PURE__*/React.createElement(Text, null, "User is required.");
|
1856
|
+
return [isValid, error];
|
1857
|
+
}
|
1858
|
+
function validateOldPassword(oldPassword) {
|
1859
|
+
var error = "";
|
1860
|
+
var isValid = oldPassword && oldPassword.length > 0;
|
1861
|
+
error = /*#__PURE__*/React.createElement(Text, null, "Old password is required.");
|
1862
|
+
return [isValid, error];
|
1863
|
+
}
|
1864
|
+
function validateNewPassword(password) {
|
1865
|
+
var hasPassword = password && password.length > 0;
|
1866
|
+
if (!hasPassword) {
|
1867
|
+
var _error = /*#__PURE__*/React.createElement(Text, null, "Password is required");
|
1868
|
+
return [false, _error];
|
1869
|
+
}
|
1870
|
+
var _ref2 = validator && typeof validator === 'function' ? validator(password) : validatePassword(password),
|
1839
1871
|
isValid = _ref2[0],
|
1840
1872
|
error = _ref2[1];
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1873
|
+
if (!isValid) {
|
1874
|
+
return [false, error];
|
1875
|
+
}
|
1876
|
+
return [true, ""];
|
1877
|
+
}
|
1878
|
+
function validatePasswordsMatch(password1, password2) {
|
1879
|
+
var error = "";
|
1880
|
+
var isValid = password1 === password2;
|
1881
|
+
error = /*#__PURE__*/React.createElement(Text, null, "Passwords do not match.");
|
1882
|
+
return [isValid, error];
|
1883
|
+
}
|
1884
|
+
function validate(form) {
|
1885
|
+
var isValid = true;
|
1886
|
+
var nextErrors = Object.assign({}, errors);
|
1887
|
+
if (userRequired) {
|
1888
|
+
var _validateUser = validateUser(form.user),
|
1889
|
+
validation = _validateUser[0],
|
1890
|
+
error = _validateUser[1];
|
1891
|
+
if (isValid) isValid = validation;
|
1892
|
+
nextErrors.user = error;
|
1893
|
+
}
|
1894
|
+
if (oldPwdRequired) {
|
1895
|
+
var _validateOldPassword = validateOldPassword(form.oldPassword),
|
1896
|
+
_validation = _validateOldPassword[0],
|
1897
|
+
_error2 = _validateOldPassword[1];
|
1898
|
+
if (isValid) isValid = _validation;
|
1899
|
+
nextErrors.oldPassword = _error2;
|
1900
|
+
}
|
1901
|
+
var _validateNewPassword = validateNewPassword(form.password1),
|
1902
|
+
pwdValidation = _validateNewPassword[0],
|
1903
|
+
pwdError = _validateNewPassword[1];
|
1904
|
+
if (isValid) isValid = pwdValidation;
|
1905
|
+
nextErrors.password1 = pwdError;
|
1906
|
+
var _validateNewPassword2 = validateNewPassword(form.password2),
|
1907
|
+
pwd2Validation = _validateNewPassword2[0],
|
1908
|
+
pwd2Error = _validateNewPassword2[1];
|
1909
|
+
var _validatePasswordsMat = validatePasswordsMatch(form.password1, form.password2),
|
1910
|
+
matchValidation = _validatePasswordsMat[0],
|
1911
|
+
matchError = _validatePasswordsMat[1];
|
1912
|
+
if (isValid) isValid = matchValidation && pwd2Validation;
|
1913
|
+
nextErrors.password2 = matchError || pwd2Error;
|
1914
|
+
return [isValid, nextErrors];
|
1844
1915
|
}
|
1845
1916
|
function changeField(id, value) {
|
1846
1917
|
var _Object$assign;
|
1847
1918
|
var next = Object.assign({}, form, (_Object$assign = {}, _Object$assign[id] = value, _Object$assign));
|
1919
|
+
var _validate = validate(next),
|
1920
|
+
isValid = _validate[0],
|
1921
|
+
errors = _validate[1];
|
1922
|
+
setIsValid(isValid);
|
1923
|
+
setErrors(errors);
|
1848
1924
|
setForm(next);
|
1849
1925
|
}
|
1850
1926
|
function ok() {
|
@@ -1852,30 +1928,34 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1852
1928
|
onOK(form);
|
1853
1929
|
}
|
1854
1930
|
}
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
var
|
1859
|
-
var
|
1860
|
-
var
|
1861
|
-
var
|
1862
|
-
var
|
1931
|
+
var userLabel = /*#__PURE__*/React.createElement(Text, null, "User");
|
1932
|
+
var passwordLabel = /*#__PURE__*/React.createElement(Text, null, "New Password");
|
1933
|
+
var password2Label = /*#__PURE__*/React.createElement(Text, null, "Confirm New Password");
|
1934
|
+
var okLabel = /*#__PURE__*/React.createElement(Text, null, "OK");
|
1935
|
+
var userStyle = errors.user ? "error" : "";
|
1936
|
+
var oldPasswordStyle = errors.oldPassword ? "error" : "";
|
1937
|
+
var password1Style = errors.password1 ? "error" : "";
|
1938
|
+
var password2Style = errors.password2 ? "error" : "";
|
1863
1939
|
return /*#__PURE__*/React.createElement("div", {
|
1864
1940
|
className: "reset-password-box"
|
1865
|
-
}, /*#__PURE__*/React.createElement("header", null,
|
1866
|
-
src: logo
|
1867
|
-
}) : null, title ? /*#__PURE__*/React.createElement("div", {
|
1941
|
+
}, /*#__PURE__*/React.createElement("header", null, title ? /*#__PURE__*/React.createElement("div", {
|
1868
1942
|
className: "title"
|
1869
|
-
}, /*#__PURE__*/React.createElement(Text, null, title)) : null
|
1943
|
+
}, /*#__PURE__*/React.createElement(Text, null, title)) : null), /*#__PURE__*/React.createElement("main", {
|
1944
|
+
className: "reset-password-form"
|
1945
|
+
}, userRequired ? /*#__PURE__*/React.createElement(TextField, {
|
1870
1946
|
id: "user",
|
1947
|
+
className: userStyle,
|
1871
1948
|
outlined: true,
|
1872
1949
|
icon: "person",
|
1873
1950
|
label: userLabel,
|
1874
1951
|
lapse: 100,
|
1875
1952
|
onChange: changeField,
|
1876
1953
|
onEnter: ok
|
1877
|
-
}) : null,
|
1954
|
+
}) : null, userRequired ? errors.user ? /*#__PURE__*/React.createElement("div", {
|
1955
|
+
className: "error-message"
|
1956
|
+
}, errors.user) : null : null, oldPwdRequired ? /*#__PURE__*/React.createElement(TextField, {
|
1878
1957
|
id: "oldPassword",
|
1958
|
+
className: oldPasswordStyle,
|
1879
1959
|
outlined: true,
|
1880
1960
|
icon: "lock",
|
1881
1961
|
type: "password",
|
@@ -1883,8 +1963,11 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1883
1963
|
lapse: 100,
|
1884
1964
|
onChange: changeField,
|
1885
1965
|
onEnter: ok
|
1886
|
-
}) : null, /*#__PURE__*/React.createElement(
|
1966
|
+
}) : null, oldPwdRequired ? errors.oldPassword ? /*#__PURE__*/React.createElement("div", {
|
1967
|
+
className: "error-message"
|
1968
|
+
}, errors.oldPassword) : null : null, /*#__PURE__*/React.createElement(TextField, {
|
1887
1969
|
id: "password1",
|
1970
|
+
className: password1Style,
|
1888
1971
|
outlined: true,
|
1889
1972
|
icon: "lock",
|
1890
1973
|
type: "password",
|
@@ -1892,8 +1975,11 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1892
1975
|
lapse: 100,
|
1893
1976
|
onChange: changeField,
|
1894
1977
|
onEnter: ok
|
1895
|
-
}), /*#__PURE__*/React.createElement(
|
1978
|
+
}), errors.password1 ? /*#__PURE__*/React.createElement("div", {
|
1979
|
+
className: "error-message"
|
1980
|
+
}, errors.password1) : null, children, /*#__PURE__*/React.createElement(TextField, {
|
1896
1981
|
id: "password2",
|
1982
|
+
className: password2Style,
|
1897
1983
|
outlined: true,
|
1898
1984
|
icon: "lock",
|
1899
1985
|
type: "password",
|
@@ -1901,12 +1987,9 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1901
1987
|
lapse: 100,
|
1902
1988
|
onChange: changeField,
|
1903
1989
|
onEnter: ok
|
1904
|
-
}),
|
1905
|
-
className: "error"
|
1906
|
-
},
|
1907
|
-
label: cancelLabel,
|
1908
|
-
action: close
|
1909
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
1990
|
+
}), errors.password2 ? /*#__PURE__*/React.createElement("div", {
|
1991
|
+
className: "error-message"
|
1992
|
+
}, errors.password2) : null), /*#__PURE__*/React.createElement("footer", null, /*#__PURE__*/React.createElement(Button, {
|
1910
1993
|
label: okLabel,
|
1911
1994
|
raised: true,
|
1912
1995
|
disabled: !isValid,
|