ywana-core8 0.1.15 → 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 -44
- 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 -44
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +130 -44
- 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 +102 -36
- 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,44 +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
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
var
|
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),
|
1835
1871
|
isValid = _ref2[0],
|
1836
1872
|
error = _ref2[1];
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
return
|
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];
|
1841
1915
|
}
|
1842
1916
|
function changeField(id, value) {
|
1843
1917
|
var _Object$assign;
|
1844
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);
|
1845
1924
|
setForm(next);
|
1846
1925
|
}
|
1847
1926
|
function ok() {
|
@@ -1849,30 +1928,34 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1849
1928
|
onOK(form);
|
1850
1929
|
}
|
1851
1930
|
}
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
var
|
1856
|
-
var
|
1857
|
-
var
|
1858
|
-
var
|
1859
|
-
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" : "";
|
1860
1939
|
return /*#__PURE__*/React.createElement("div", {
|
1861
1940
|
className: "reset-password-box"
|
1862
|
-
}, /*#__PURE__*/React.createElement("header", null,
|
1863
|
-
src: logo
|
1864
|
-
}) : null, title ? /*#__PURE__*/React.createElement("div", {
|
1941
|
+
}, /*#__PURE__*/React.createElement("header", null, title ? /*#__PURE__*/React.createElement("div", {
|
1865
1942
|
className: "title"
|
1866
|
-
}, /*#__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, {
|
1867
1946
|
id: "user",
|
1947
|
+
className: userStyle,
|
1868
1948
|
outlined: true,
|
1869
1949
|
icon: "person",
|
1870
1950
|
label: userLabel,
|
1871
1951
|
lapse: 100,
|
1872
1952
|
onChange: changeField,
|
1873
1953
|
onEnter: ok
|
1874
|
-
}) : null,
|
1954
|
+
}) : null, userRequired ? errors.user ? /*#__PURE__*/React.createElement("div", {
|
1955
|
+
className: "error-message"
|
1956
|
+
}, errors.user) : null : null, oldPwdRequired ? /*#__PURE__*/React.createElement(TextField, {
|
1875
1957
|
id: "oldPassword",
|
1958
|
+
className: oldPasswordStyle,
|
1876
1959
|
outlined: true,
|
1877
1960
|
icon: "lock",
|
1878
1961
|
type: "password",
|
@@ -1880,8 +1963,11 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1880
1963
|
lapse: 100,
|
1881
1964
|
onChange: changeField,
|
1882
1965
|
onEnter: ok
|
1883
|
-
}) : 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, {
|
1884
1969
|
id: "password1",
|
1970
|
+
className: password1Style,
|
1885
1971
|
outlined: true,
|
1886
1972
|
icon: "lock",
|
1887
1973
|
type: "password",
|
@@ -1889,8 +1975,11 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1889
1975
|
lapse: 100,
|
1890
1976
|
onChange: changeField,
|
1891
1977
|
onEnter: ok
|
1892
|
-
}), /*#__PURE__*/React.createElement(
|
1978
|
+
}), errors.password1 ? /*#__PURE__*/React.createElement("div", {
|
1979
|
+
className: "error-message"
|
1980
|
+
}, errors.password1) : null, children, /*#__PURE__*/React.createElement(TextField, {
|
1893
1981
|
id: "password2",
|
1982
|
+
className: password2Style,
|
1894
1983
|
outlined: true,
|
1895
1984
|
icon: "lock",
|
1896
1985
|
type: "password",
|
@@ -1898,12 +1987,9 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
1898
1987
|
lapse: 100,
|
1899
1988
|
onChange: changeField,
|
1900
1989
|
onEnter: ok
|
1901
|
-
}),
|
1902
|
-
className: "error"
|
1903
|
-
},
|
1904
|
-
label: cancelLabel,
|
1905
|
-
action: close
|
1906
|
-
}), /*#__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, {
|
1907
1993
|
label: okLabel,
|
1908
1994
|
raised: true,
|
1909
1995
|
disabled: !isValid,
|