@skalfa/skalfa-component 1.0.19 → 1.0.20
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.
|
@@ -6,7 +6,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const skalfa_icon_1 = require("@skalfa/skalfa-icon");
|
|
8
8
|
const _utils_1 = require("@utils");
|
|
9
|
+
const skalfa_lang_1 = require("@skalfa/skalfa-lang");
|
|
9
10
|
function InputPasswordComponent({ label, tip, leftIcon, rightIcon, value, invalid, validations, register, unregister, onChange, className = "", ...props }) {
|
|
11
|
+
const l = (0, skalfa_lang_1.useLang)();
|
|
10
12
|
const [password, setPassword] = (0, react_1.useState)("");
|
|
11
13
|
const [confirmPassword, setConfirmPassword] = (0, react_1.useState)("");
|
|
12
14
|
const [strength, setStrength] = (0, react_1.useState)("");
|
|
@@ -52,8 +54,8 @@ function InputPasswordComponent({ label, tip, leftIcon, rightIcon, value, invali
|
|
|
52
54
|
}, onBlur: (e) => {
|
|
53
55
|
props.onBlur?.(e);
|
|
54
56
|
setTimeout(() => inputHandler.setFocus(false), 100);
|
|
55
|
-
}, autoComplete: "off" }), leftIcon && ((0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { className: (0, _utils_1.cn)("input-icon", "input-icon-left", (0, _utils_1.pcn)(className, "icon")), icon: leftIcon })), rightIcon && ((0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { className: (0, _utils_1.cn)("input-icon", "input-icon-right", (0, _utils_1.pcn)(className, "icon")), icon: rightIcon }))] }), invalidMessage && ((0, jsx_runtime_1.jsx)("small", { className: "input-error-message", children: invalidMessage })), strength && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", strength === "weak" && "password-strength-bar-weak", strength === "strong" && "password-strength-bar-strong", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", strength === "weak" && "password-strength-bar-empty", strength === "strong" && "password-strength-bar-strong", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", (strength === "weak" || strength === "strong") && "password-strength-bar-empty", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("span", { className: (0, _utils_1.cn)("password-strength-text", strength === "weak" && "password-strength-text-weak", strength === "strong" && "password-strength-text-strong", strength === "excellent" && "password-strength-text-excellent"), children: strength === "weak" ? "Weak" : strength === "strong" ? "Strong" : "Excellent" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "input-password-confirm-wrapper", children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: randomConfirmId, className: (0, _utils_1.cn)("input-label", (0, _utils_1.pcn)(className, "label")), children: "Password Confirm" }), (0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("input", { ...props, id: randomConfirmId, type: "password", className: (0, _utils_1.cn)("input", leftIcon && "input-with-left-icon", rightIcon && "input-with-right-icon", (0, _utils_1.pcn)(className, "base"), isConfirmMismatch && "input-error"), value: confirmPassword, onChange: (e) => {
|
|
57
|
+
}, autoComplete: "off" }), leftIcon && ((0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { className: (0, _utils_1.cn)("input-icon", "input-icon-left", (0, _utils_1.pcn)(className, "icon")), icon: leftIcon })), rightIcon && ((0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { className: (0, _utils_1.cn)("input-icon", "input-icon-right", (0, _utils_1.pcn)(className, "icon")), icon: rightIcon }))] }), invalidMessage && ((0, jsx_runtime_1.jsx)("small", { className: "input-error-message", children: invalidMessage })), strength && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", strength === "weak" && "password-strength-bar-weak", strength === "strong" && "password-strength-bar-strong", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", strength === "weak" && "password-strength-bar-empty", strength === "strong" && "password-strength-bar-strong", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("password-strength-bar", (strength === "weak" || strength === "strong") && "password-strength-bar-empty", strength === "excellent" && "password-strength-bar-excellent") }), (0, jsx_runtime_1.jsx)("span", { className: (0, _utils_1.cn)("password-strength-text", strength === "weak" && "password-strength-text-weak", strength === "strong" && "password-strength-text-strong", strength === "excellent" && "password-strength-text-excellent"), children: strength === "weak" ? "Weak" : strength === "strong" ? "Strong" : "Excellent" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "input-password-confirm-wrapper", children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: randomConfirmId, className: (0, _utils_1.cn)("input-label", (0, _utils_1.pcn)(className, "label")), children: l.base.passwordConfirm ? l.base.passwordConfirm() : "Password Confirm" }), (0, jsx_runtime_1.jsx)("div", { className: "relative", children: (0, jsx_runtime_1.jsx)("input", { ...props, placeholder: l.base.passwordConfirm ? l.base.passwordConfirm() : "Repeat password...", id: randomConfirmId, type: "password", className: (0, _utils_1.cn)("input", leftIcon && "input-with-left-icon", rightIcon && "input-with-right-icon", (0, _utils_1.pcn)(className, "base"), isConfirmMismatch && "input-error"), value: confirmPassword, onChange: (e) => {
|
|
56
58
|
setConfirmPassword(e.target.value);
|
|
57
59
|
onChange?.(password, e.target.value);
|
|
58
|
-
}, autoComplete: "off" }) })] }), isConfirmMismatch && ((0, jsx_runtime_1.jsx)("small", { className: "input-error-message", children: "
|
|
60
|
+
}, autoComplete: "off" }) })] }), isConfirmMismatch && ((0, jsx_runtime_1.jsx)("small", { className: "input-error-message", children: l.base.passwordConfirmFailed ? l.base.passwordConfirmFailed() : "Passwords do not match!" }))] }));
|
|
59
61
|
}
|
|
@@ -271,6 +271,7 @@ function TableSupervisionComponent({ title, id, fetchControl, columnControl, for
|
|
|
271
271
|
: { idb: { ...fetchControl?.idb, id: selected?.id || "" } }),
|
|
272
272
|
method: "DELETE",
|
|
273
273
|
},
|
|
274
|
+
paint: "danger",
|
|
274
275
|
onSuccess: () => {
|
|
275
276
|
reset();
|
|
276
277
|
setTimeout(() => { setToggle(`MODAL_DELETE_${toggleKey}`, false); }, 900);
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { InputHTMLAttributes, ReactNode, useEffect, useState } from "react";
|
|
4
4
|
import { Icon } from "@skalfa/skalfa-icon";
|
|
5
5
|
import { cn, pcn, useInputHandler, useInputRandomId, useValidation, validation, ValidationRules } from "@utils";
|
|
6
|
+
import { useLang } from "@skalfa/skalfa-lang";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
@@ -45,6 +46,7 @@ export function InputPasswordComponent({
|
|
|
45
46
|
className = "",
|
|
46
47
|
...props
|
|
47
48
|
}: InputPasswordProps) {
|
|
49
|
+
const l = useLang()
|
|
48
50
|
const [password, setPassword] = useState("");
|
|
49
51
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
50
52
|
const [strength, setStrength] = useState<"weak" | "strong" | "excellent" | "">("");
|
|
@@ -214,10 +216,11 @@ export function InputPasswordComponent({
|
|
|
214
216
|
<label
|
|
215
217
|
htmlFor={randomConfirmId}
|
|
216
218
|
className={cn("input-label", pcn<CT>(className, "label"))}
|
|
217
|
-
>Password Confirm</label>
|
|
219
|
+
>{l.base.passwordConfirm ? l.base.passwordConfirm() : "Password Confirm"}</label>
|
|
218
220
|
<div className="relative">
|
|
219
221
|
<input
|
|
220
222
|
{...props}
|
|
223
|
+
placeholder={l.base.passwordConfirm ? l.base.passwordConfirm() : "Repeat password..."}
|
|
221
224
|
id={randomConfirmId}
|
|
222
225
|
type="password"
|
|
223
226
|
className={cn(
|
|
@@ -238,7 +241,7 @@ export function InputPasswordComponent({
|
|
|
238
241
|
</div>
|
|
239
242
|
|
|
240
243
|
{isConfirmMismatch && (
|
|
241
|
-
<small className="input-error-message">
|
|
244
|
+
<small className="input-error-message">{l.base.passwordConfirmFailed ? l.base.passwordConfirmFailed() : "Passwords do not match!"}</small>
|
|
242
245
|
)}
|
|
243
246
|
</div>
|
|
244
247
|
);
|