fui-fancyui
Version:
FancyUI Libary
64 lines (63 loc) • 1.61 kB
JavaScript
"use client";
import { jsx as o } from "react/jsx-runtime";
import s from "../FancyBox/FancyBox.js";
import f from "../../../design/designFunctions/arrayToCssValues/arrayToCssValues.js";
import { calculatePasswordStrength as g } from "../../../utils/functions/passwordStrengthCalculator/passwordStrengthCalculator.js";
import { StyledMeter as w } from "./PasswordSrengthMeter.style.js";
import { useMemo as y, useEffect as x } from "react";
function C(e) {
const {
password: a,
borderRadius: m = "complete",
borderRadiusBar: h = "complete",
layer: c = 2,
themeType: d,
height: n = "xxs",
padding: l,
margin: u,
notABar: p = !1,
compareWith: i,
onChangeStrength: t
} = e, r = y(() => g(a, i), [a, i]);
return x(() => {
t && t(r);
}, [r, t]), /* @__PURE__ */ o(
s,
{
borderRadius: m,
themeType: d,
padding: l,
margin: u,
layer: c,
externalStyle: { width: "100%", overflow: "hidden" },
children: p ? /* @__PURE__ */ o(
s,
{
as: "meter",
themeType: S(r),
externalStyle: {
width: "100%",
height: f(n, "spacing"),
transition: "background-color 0.4s ease-in-out"
}
}
) : /* @__PURE__ */ o(
w,
{
$borderRadius: h,
$height: n,
low: 33,
min: 0,
high: 66,
optimum: 100,
value: r,
max: 100
}
)
}
);
}
const S = (e) => e < 33 ? "error" : e < 66 ? "warning" : "success";
export {
C as default
};