@lanaco/lnc-react-ui
Version:
React component library
328 lines (324 loc) • 9.9 kB
JavaScript
import { jsxs as E, Fragment as k } from "react/jsx-runtime";
import R, { cloneElement as x, isValidElement as S, Children as D } from "react";
import { s as f, a as N } from "./breakpoints-BubDitvo.js";
var M = {}, d = {};
Object.defineProperty(d, "__esModule", { value: !0 });
d.isNavigator = d.isBrowser = d.off = d.on = d.noop = void 0;
var T = function() {
};
d.noop = T;
function L(t) {
for (var e = [], n = 1; n < arguments.length; n++)
e[n - 1] = arguments[n];
t && t.addEventListener && t.addEventListener.apply(t, e);
}
d.on = L;
function z(t) {
for (var e = [], n = 1; n < arguments.length; n++)
e[n - 1] = arguments[n];
t && t.removeEventListener && t.removeEventListener.apply(t, e);
}
d.off = z;
d.isBrowser = typeof window < "u";
d.isNavigator = typeof navigator < "u";
Object.defineProperty(M, "__esModule", { value: !0 });
var w = R, B = d, I = function(t, e) {
return e !== void 0 ? e : B.isBrowser ? window.matchMedia(t).matches : (process.env.NODE_ENV !== "production" && console.warn("`useMedia` When server side rendering, defaultState should be defined to prevent a hydration mismatches."), !1);
}, K = function(t, e) {
var n = w.useState(I(t, e)), r = n[0], o = n[1];
return w.useEffect(function() {
var a = !0, i = window.matchMedia(t), l = function() {
a && o(!!i.matches);
};
return i.addEventListener("change", l), o(i.matches), function() {
a = !1, i.removeEventListener("change", l);
};
}, [t]), r;
}, g = M.default = K;
const U = (t, e) => {
var n = W(t, e);
return n && S(n) ? { current: n } : { current: null };
}, W = (t = "", e) => {
if (e && t) {
var n = D.toArray(e).reverse().find(
(r) => {
var o, a;
return ((o = r.props) == null ? void 0 : o.__TYPE__) === t || ((a = r.type) == null ? void 0 : a.displayName) === t;
}
);
if (n) return n;
}
return null;
}, Z = (t, e, n) => {
var r = _(t, e, n);
return r && S(r) ? { current: r } : { current: null };
}, _ = (t = "", e, n) => {
if (n && t) {
var r = D.toArray(n).reverse().find(
(o) => {
var a, i, l, s;
return (((a = o.props) == null ? void 0 : a.__TYPE__) === t || ((i = o.type) == null ? void 0 : i.displayName) === t) && (e ? ((l = o.props) == null ? void 0 : l.id) === e : !((s = o.props) != null && s.id));
}
);
if (r) return r;
}
return null;
}, A = () => {
const t = g(f.XS.mediaQuery), e = g(f.S.mediaQuery), n = g(f.M.mediaQuery), r = g(f.L.mediaQuery), o = g(f.XL.mediaQuery);
return t ? f.XS.type : e ? f.S.type : n ? f.M.type : r ? f.L.type : o ? f.XL.type : f.M.type;
}, Q = () => {
const t = A();
return N(t);
}, X = (t, e, n = null, r = !1) => t.current !== null ? (e.children = n !== null ? r == !0 ? /* @__PURE__ */ E(k, { children: [
t.current.props.children,
n
] }) : n : t.current.props.children, x(t.current, e)) : null, v = (t, e) => {
var n = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
let r = n ? {
r: parseInt(n[1], 16),
g: parseInt(n[2], 16),
b: parseInt(n[3], 16),
a: e
} : null;
return r ? `rgba(${r.r}, ${r.g}, ${r.b}, ${r.a})` : null;
}, Y = (t, e, n, r, o, a) => {
var b, m;
const i = t.colorContext[n], l = t.components[e].default, s = (m = (b = t.components[e]) == null ? void 0 : b[i]) == null ? void 0 : m[r], c = s == null ? void 0 : s[o], u = l[r][o], p = s == null ? void 0 : s[a], h = l[r][a], C = c || c == 0 ? t.palette[i][c] : t.palette[l.palette][u], $ = p || p == 0 ? t.palette.opacity[p] : t.palette.opacity[h];
return v(C, $ ?? "100%");
}, J = (t, e, n, r, o) => {
var u, p;
const a = t.colorContext[n], i = t.components[e].default, l = (p = (u = t.components[e]) == null ? void 0 : u[a]) == null ? void 0 : p[r], s = l == null ? void 0 : l[o], c = i[r][o];
return s || s == 0 ? s : c;
}, q = (t, e) => t.sizes[e], j = (t, e, n, r) => `
font-weight: ${t.components[e].default[r].fontWeight};
font-size: ${t.typography.component[n].fontSize};
line-height: ${t.typography.component[n].lineHeight};
`, tt = (t, e) => t.borderRadius[e], et = (t, e) => t.boxShadow[e], nt = (t, e) => {
const n = t.colorContext[t.palette.outline.context], r = t.palette[n][t.palette.outline.weight];
return `
outline: ${t.palette.outline.width} ${t.palette.outline.style} ${r};
${`outline-offset: ${t.palette.outline.offset}`};
`;
}, rt = (t) => {
const e = t.palette.disabled.color, n = t.palette[e][t.palette.disabled.background], r = t.palette[e][t.palette.disabled.text], o = t.palette.opacity[t.palette.disabled.opacity];
return `
background-color: ${v(n, o ?? "100%")};
color: ${r};
`;
}, ot = (t) => {
const e = t.palette.disabled.color, n = t.palette[e][t.palette.disabled.background], r = t.palette.opacity[t.palette.disabled.opacity];
return `
background-color: ${v(n, r ?? "100%")};
`;
}, F = () => `
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`, at = (t) => t == null || t == 0 || t == 1 ? F() : `
overflow: hidden;
text-overflow: ellipsis;
overflow-wrap: anywhere;
word-break: break-word;
@supports (-webkit-line-clamp: ${t}) {
overflow: hidden;
text-overflow: ellipsis;
white-space: initial;
display: -webkit-box;
-webkit-line-clamp: ${t};
-webkit-box-orient: vertical;
}
`, st = (t = "-45deg", e = "500% 500%", n = "#b3b9c4", r = "#e5e9f1") => `
@keyframes gradient {
0% {
background-position: 0% 0%;
}
50% {
background-position: 0% 50%;
}
100% {
background-position: 0% 100%;
}
500% {
background-position: 0% 0%;
}
}
background: linear-gradient(${t}, ${n}, ${r});
background-size: ${e};
animation: gradient 1s linear infinite alternate;
`, it = (t) => t != null && t !== "", lt = (t) => t != null, ct = (t) => new Intl.NumberFormat("de-DE", {
minimumFractionDigits: 2,
maximumFractionDigits: 2
}).format(t), O = {
EUR: "€",
BAM: "KM",
USD: "$",
GBP: "£",
CHF: "CHF",
HRK: "kn",
RSD: "RSD",
BGN: "лв",
MKD: "ден",
PLN: "zł",
CZK: "Kč",
HUF: "Ft",
RON: "lei",
TRY: "₺",
SEK: "kr",
DKK: "kr",
NOK: "kr",
ISK: "kr",
CAD: "C$",
AUD: "A$",
NZD: "NZ$",
JPY: "¥",
CNY: "¥",
KRW: "₩",
INR: "₹",
PKR: "₨",
AED: "د.إ",
SAR: "ر.س",
QAR: "ر.ق",
KWD: "د.ك",
OMR: "ر.ع.",
BHD: "د.ب",
JOD: "د.ا",
LBP: "ل.ل",
EGP: "E£",
ZAR: "R",
NGN: "₦",
GHS: "₵",
KES: "KSh",
TZS: "TSh"
}, ut = (t) => O[t] || "";
function P(t, e = { carbs: 0.5, protein: 0.25, fat: 0.25 }) {
const n = e.carbs + e.protein + e.fat;
if (Math.abs(n - 1) > 0.01)
throw new Error("Ratios must add up to 1.");
const r = { carbs: 4, protein: 4, fat: 9 };
return {
carbs: Math.round(t * e.carbs / r.carbs),
protein: Math.round(t * e.protein / r.protein),
fat: Math.round(t * e.fat / r.fat)
};
}
const dt = ({
gender: t,
age: e,
heightCm: n,
weightKg: r,
activityLevel: o,
goal: a
}) => {
let i;
if (t === "male")
i = 10 * +r + 6.25 * +n - 5 * +e + 5;
else if (t === "female")
i = 10 * +r + 6.25 * +n - 5 * +e - 161;
else
throw new Error("Invalid gender. Use 'male' or 'female'.");
const s = {
// sedentary: 1.2,
// light: 1.375,
// moderate: 1.55,
// active: 1.725,
// 'very active': 1.9
verylow: 1.2,
moderate: 1.55,
veryactive: 1.9
}[o.toLowerCase()];
if (!s)
throw new Error("Invalid activity level");
const c = i * s;
let u;
switch (a.toLowerCase()) {
case "loseweight":
u = c - 500;
break;
case "maintaining":
u = c;
break;
case "gainmuscle":
u = c + 500;
break;
default:
throw new Error("Invalid goal. Use: 'lose', 'maintain', or 'gain'.");
}
const p = P(u);
return {
calories: Math.round(u),
...p
};
}, ft = (t) => {
const e = String(Math.floor(t / 60)).padStart(2, "0"), n = String(t % 60).padStart(2, "0");
return `${e}:${n}`;
}, pt = (t, ...e) => t.replace(/{(\d+)}/g, function(n, r) {
return typeof e[r] < "u" ? e[r] : n;
}), gt = (t) => (t = t || 0, t > 999 ? Math.round(t / 1e3).toLocaleString() + "K" : t.toLocaleString()), yt = (t) => {
const e = new Date(t);
let n = e.getDate(), r = e.getMonth() + 1, o = e.getFullYear();
return `${n}. ${r}. ${o}`;
}, y = (t) => {
if (!t) return null;
if (t instanceof Date)
return t.toISOString();
const e = String(t);
return e.endsWith("Z") || /[+-]\d{2}:\d{2}$/.test(e) ? e : e + "Z";
}, vt = (t, e) => {
const n = y(t), r = y(e), o = n ? new Date(n) : null, a = r ? new Date(r) : null, i = /* @__PURE__ */ new Date();
if (!o || !a)
return -1;
const l = a.getTime() - o.getTime(), s = i.getTime() - o.getTime(), c = l / (1e3 * 60 * 60 * 24), u = s / (1e3 * 60 * 60 * 24);
return s < 0 ? -1 : s >= l ? {
day: Math.ceil(c),
totalDays: Math.ceil(c),
isEnded: !0
} : {
day: Math.floor(u),
// Make it 1-based (Day 1, 2, 3, 4 instead of 0, 1, 2, 3)
totalDays: Math.ceil(c),
isEnded: !1,
// Additional precision info for progress calculations
dayProgress: u / c,
// 0 to 1 progress within current day
totalProgress: s / l
// 0 to 1 overall progress
};
}, bt = (t) => {
if (!t) return null;
const e = y(t), n = e ? new Date(e) : null, r = /* @__PURE__ */ new Date();
if (!n) return null;
const o = n.getTime() - r.getTime(), a = 24 * 60 * 60 * 1e3;
return Math.ceil(o / a);
};
export {
bt as A,
y as B,
Z as C,
ut as G,
A as a,
tt as b,
Y as c,
j as d,
q as e,
nt as f,
J as g,
ot as h,
rt as i,
U as j,
et as k,
it as l,
lt as m,
at as n,
v as o,
ct as p,
yt as q,
X as r,
pt as s,
F as t,
Q as u,
gt as v,
st as w,
dt as x,
ft as y,
vt as z
};