@lanaco/lnc-react-ui
Version:
React component library
853 lines (810 loc) • 23.3 kB
JavaScript
import { jsxs as i, jsx as t, Fragment as z } from "react/jsx-runtime";
import { forwardRef as y, useState as N, useRef as E } from "react";
import { s as w } from "./emotion-styled.browser.esm-DfbrHHed.js";
import { d as T } from "./breakpoints-BubDitvo.js";
import R from "./Button.js";
import G from "./RangeSlider.js";
import Y from "./DropdownItem.js";
import K from "./DropdownMenu.js";
import P from "./IconButton.js";
import q from "./BannerSectionWithList.js";
import { x as J } from "./utils-BUdHa0nB.js";
const Q = w.div`
display: flex;
flex-direction: column;
width: 100%;
gap: 2.25rem;
@media ${T("S")} {
gap: 2rem;
}
`, U = w.div`
text-align: center;
display: flex;
justify-content: center;
flex-direction: column;
gap: 0.25rem;
& .header-title {
font-size: 1.5rem;
font-weight: 600;
}
& .header-subtitle {
color: var(--gray-600, #676e79);
font-size: 1rem;
font-weight: 500;
}
@media ${T("S")} {
}
`;
w.div`
display: flex;
flex-direction: column;
gap: 0.25rem;
font-size: 1.5rem;
font-weight: 600;
text-align: center;
& .subtitle {
font-size: 1rem;
font-weight: 500;
color: var(--gray-600, #676e79);
}
`;
const X = w.div`
display: flex;
flex-direction: column;
gap: 2.25rem;
align-items: center;
& .btns-footer {
display: flex;
flex-direction: column;
gap: 0.25rem;
& button {
width: 20rem;
max-width: 20rem;
}
}
@media ${T("S")} {
gap: 2rem;
& .btns-footer {
width: 100%;
align-items: center;
& button {
width: 100%;
max-width: 13.75rem;
}
}
}
`, Z = w.div`
display: grid;
grid-template-columns: auto auto;
width: fit-content;
gap: 0.5rem;
align-items: center;
& .lnc-ui-button {
padding-right: 0.75rem;
padding-left: 0.75rem;
}
& .caluclating-group {
display: flex;
align-items: center;
gap: 0.625rem;
& .range-input-lnc {
width: 22.75rem;
}
& .calculating-btn {
min-width: 4.5rem;
max-width: 4.5rem;
}
& .calculating-input {
min-height: 2.25rem;
max-height: 2.25rem;
min-width: 4.5rem;
max-width: 4.5rem;
padding: 0.38rem;
border-radius: 0.5rem;
border: 1px solid var(--gray-95012, rgba(20, 22, 26, 0.12));
background: var(--white, #fff);
text-align: center;
}
}
& .btn-cnt {
display: flex;
align-items: center;
gap: 0.38rem;
& i {
font-size: 1.5rem;
}
}
& .grid-label {
font-weight: 600;
font-size: 1rem;
min-width: 10rem;
padding-top: 0.75rem;
& .unit {
font-weight: 400;
color: var(--gray-600, #676e79);
}
}
& .grid-label:first-of-type {
padding-top: 0 !important;
}
@media ${T("S")} {
gap: 0.25rem;
grid-template-columns: auto;
& .grid-label {
font-size: 1rem;
}
& .caluclating-group {
flex-wrap: wrap;
gap: 1rem;
& .range-input-lnc {
width: unset;
flex: 1;
}
}
& .group-activity {
button {
width: 100%;
}
}
& .grid-label {
min-width: unset;
}
}
`, _ = w.div`
border-radius: 0.75rem;
border: 1px solid var(--neutral-95008);
background: var(--white);
padding: 1.25rem;
/* drop-shadow */
box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1),
0px 1px 2px 0px rgba(0, 0, 0, 0.06);
display: flex;
padding: 1.25rem;
align-items: center;
gap: 1rem;
& .dropdown-group {
display: flex;
align-items: center;
gap: 1rem;
}
& .vertical-line {
width: 1px;
height: 4rem;
background-color: var(--gray-95008);
margin: 0 0.62rem;
}
@media ${T("S")} {
padding: 0.75rem;
gap: 0.75rem;
& .vertical-line {
height: 100%;
min-height: 5.25rem;
}
& .dropdown-group {
gap: 0.75rem;
align-items: start;
}
}
`, ee = w.div`
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1rem;
flex: 1;
@media ${T("S")} {
grid-template-columns: repeat(2, 1fr);
gap: 0.75rem;
}
`, $ = w.div`
display: flex;
flex-direction: column;
gap: 0.75rem;
min-width: 7.125rem;
align-items: center;
text-align: center;
font-weight: 600;
font-size: 1.375rem;
& .subgroup {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
& .subtext {
font-size: 1rem;
font-weight: 400;
color: var(--gray-600, #676e79);
}
& i {
color: ${(s) => s.color};
font-size: 3rem;
}
@media ${T("S")} {
flex-direction: row;
gap: 0.25rem;
font-size: 0.875rem;
font-weight: 500;
align-items: start;
& i {
font-size: 1.75rem;
}
& .subtext {
font-size: 0.75rem;
font-weight: 400;
}
& .subgroup {
gap: 0;
}
}
`, te = w.label`
position: relative;
display: inline-flex;
align-items: center;
cursor: pointer;
background: var(--white, #fff);
border-radius: 30px;
user-select: none;
font-family: Arial, sans-serif;
font-weight: bold;
font-size: 1rem;
color: var(--gray-950, #14161a);
transition: background-color 0.3s;
min-height: 2.5rem;
max-height: 2.5rem;
font-size: 1rem;
font-weight: 50;
width: fit-content;
& i {
font-size: 1rem;
}
input {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
.knob {
position: absolute;
top: 0;
bottom: 0;
left: ${(s) => s.checked ? "4.6875rem" : "0"};
background: var(--success-600, #059669);
border-radius: 30px;
transition: left 0.3s;
width: fit-content;
display: flex;
justify-content: center;
align-items: center;
pointer-events: none;
font-weight: normal;
font-size: 0.9rem;
color: var(--white, #fff);
padding: 0 0.75rem;
min-height: 2.5rem;
max-height: 2.5rem;
border: 1px solid var(--success-600, #059669);
& .cont {
min-width: 6.25rem;
}
}
& .cont {
min-width: 4.6875rem;
justify-content: center;
}
.text {
width: 100%;
text-align: center;
pointer-events: none;
display: flex;
gap: 0.5rem;
padding: 0.75rem;
border: 1px solid var(--gray-95012, #14161a1f);
border-radius: 30px;
min-height: 2.5rem;
max-height: 2.5rem;
& .hidden-txt {
opacity: 0;
}
}
& .cont {
display: flex;
align-items: center;
gap: 0.38rem;
}
`, ae = y((s, x) => {
var g, u, v, f, p, d, k, C;
const {
onChange: m = () => {
},
items: a = [
{ name: "Male", icon: "mng-lnc-male-02", value: "male" },
{ name: "Female", value: "female", icon: "mng-lnc-female-02" }
],
...l
} = s, c = /* @__PURE__ */ i("div", { className: "cont", children: [
/* @__PURE__ */ t("i", { className: (g = a == null ? void 0 : a.at(0)) == null ? void 0 : g.icon }),
/* @__PURE__ */ t("span", { children: (u = a == null ? void 0 : a.at(0)) == null ? void 0 : u.name })
] }), n = /* @__PURE__ */ i("div", { className: "cont", children: [
/* @__PURE__ */ t("span", { children: (v = a == null ? void 0 : a.at(1)) == null ? void 0 : v.name }),
/* @__PURE__ */ t("i", { className: (f = a == null ? void 0 : a.at(1)) == null ? void 0 : f.icon })
] }), [e, r] = N(!1);
return /* @__PURE__ */ i(te, { ref: x, checked: e, ...l, children: [
/* @__PURE__ */ t("input", { type: "checkbox", checked: e, onChange: (h) => {
var S, j;
r(h.target.checked), m && m(
h.target.checked === !0 ? (S = a == null ? void 0 : a.at(1)) == null ? void 0 : S.value : (j = a == null ? void 0 : a.at(0)) == null ? void 0 : j.value
);
} }),
/* @__PURE__ */ t("span", { className: "knob", children: e ? n : c }),
/* @__PURE__ */ i("span", { className: "text", children: [
/* @__PURE__ */ i("div", { className: "cont", children: [
/* @__PURE__ */ t("i", { className: (p = a == null ? void 0 : a.at(0)) == null ? void 0 : p.icon }),
e === !0 && /* @__PURE__ */ t("span", { className: "hidden-txt", children: (d = a == null ? void 0 : a.at(0)) == null ? void 0 : d.name })
] }),
/* @__PURE__ */ i("div", { className: "cont", children: [
e !== !0 && /* @__PURE__ */ t("span", { className: "hidden-txt", children: (k = a == null ? void 0 : a.at(1)) == null ? void 0 : k.name }),
/* @__PURE__ */ t("i", { className: (C = a == null ? void 0 : a.at(1)) == null ? void 0 : C.icon })
] })
] })
] });
}), ne = y((s, x) => {
var C;
const {
yearsText: m,
heightText: a,
weightText: l,
genderText: c = "Gender",
calculateText: n = "Calculate",
closeText: e = "Close calculator",
onClose: r = () => {
},
genders: o = [
{ name: "Male", icon: "mng-lnc-male-02", value: "male" },
{ name: "Female", value: "female", icon: "mng-lnc-female-02" }
],
activityLevels: g = [
{ name: "Very low", code: "veryLow" },
{ name: "Moderate", code: "moderate" },
{ name: "Very active", code: "veryActive" }
],
activityLevelText: u,
goalText: v,
goals: f = [
{ name: "Lose weight", code: "loseWeight", icon: "mng-lnc-weight-scale" },
{ name: "Maintaining", code: "maintaining", icon: "mng-lnc-move" },
{ name: "Gain muscle", code: "gainMuscle", icon: "mng-lnc-muscule" }
],
onCalculate: p = () => {
}
} = s, d = E({
year: null,
height: null,
weight: null,
gender: (C = o == null ? void 0 : o.at(0)) == null ? void 0 : C.value,
activityLevel: null,
goal: null
}), k = () => {
p == null || p(d == null ? void 0 : d.current);
};
return /* @__PURE__ */ i(X, { children: [
/* @__PURE__ */ i(Z, { className: "calorie-calculating", children: [
/* @__PURE__ */ t("div", { className: "grid-label", children: c }),
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
ae,
{
items: o,
onChange: (h) => d.current.gender = h
}
) }),
/* @__PURE__ */ t(
ie,
{
text: m,
onChange: (h) => d.current.year = h
}
),
/* @__PURE__ */ t(
re,
{
text: a,
onChange: (h) => d.current.height = h
}
),
/* @__PURE__ */ t(
le,
{
text: l,
onChange: (h) => d.current.weight = h
}
),
/* @__PURE__ */ t(
ce,
{
text: u,
activityLevels: g,
onChange: (h) => d.current.activityLevel = h
}
),
/* @__PURE__ */ t(
oe,
{
text: v,
goals: f,
onChange: (h) => d.current.goal = h
}
)
] }),
/* @__PURE__ */ i("div", { className: "btns-footer", children: [
/* @__PURE__ */ t(
R,
{
type: "button",
color: "neutral",
size: "medium",
onClick: () => {
k();
},
children: n
}
),
/* @__PURE__ */ t(
R,
{
type: "button",
btnType: "basic",
color: "gray",
size: "medium",
onClick: () => r == null ? void 0 : r(),
children: e
}
)
] })
] });
}), ie = y((s, x) => {
const { text: m = "Years", onChange: a = () => {
} } = s, [l, c] = N(1);
return /* @__PURE__ */ i(z, { children: [
/* @__PURE__ */ t("div", { className: "grid-label", children: m }),
/* @__PURE__ */ i("div", { className: "caluclating-group", children: [
/* @__PURE__ */ t(
G,
{
className: "range-input-lnc",
max: 115,
min: 0,
step: 1,
value: l,
color: "success",
defaultValue: 0,
onChange: (n) => {
var e, r;
c((e = n == null ? void 0 : n.target) == null ? void 0 : e.value), a == null || a((r = n == null ? void 0 : n.target) == null ? void 0 : r.value);
}
}
),
/* @__PURE__ */ t(
"input",
{
tabIndex: 2,
type: "text",
className: "calculating-input",
onChange: (n) => {
var e, r, o, g, u, v, f, p;
!isNaN((e = n == null ? void 0 : n.target) == null ? void 0 : e.value) && +((r = n == null ? void 0 : n.target) == null ? void 0 : r.value) >= 0 && (c(
((g = (o = n == null ? void 0 : n.target) == null ? void 0 : o.value) == null ? void 0 : g.length) > 1 ? (v = (u = n == null ? void 0 : n.target) == null ? void 0 : u.value) == null ? void 0 : v.replace(/^0+/, "") : (f = n == null ? void 0 : n.target) == null ? void 0 : f.value
), a == null || a((p = n == null ? void 0 : n.target) == null ? void 0 : p.value));
},
value: l == null ? void 0 : l.toString()
}
)
] })
] });
}), re = y((s, x) => {
const { text: m = "Height", unitText: a = "cm", onChange: l = () => {
} } = s, [c, n] = N(1);
return /* @__PURE__ */ i(z, { children: [
/* @__PURE__ */ i("div", { className: "grid-label", children: [
m,
" ",
/* @__PURE__ */ t("span", { className: "unit", children: `(${a})` })
] }),
/* @__PURE__ */ i("div", { className: "caluclating-group", children: [
/* @__PURE__ */ t(
G,
{
className: "range-input-lnc",
max: 273,
min: 0,
step: 1,
value: c,
defaultValue: 0,
color: "success",
onChange: (e) => {
var r, o;
n((r = e == null ? void 0 : e.target) == null ? void 0 : r.value), l == null || l((o = e == null ? void 0 : e.target) == null ? void 0 : o.value);
}
}
),
/* @__PURE__ */ t(
"input",
{
type: "text",
tabIndex: 2,
className: "calculating-input",
onChange: (e) => {
var r, o, g, u, v, f, p, d;
!isNaN((r = e == null ? void 0 : e.target) == null ? void 0 : r.value) && +((o = e == null ? void 0 : e.target) == null ? void 0 : o.value) >= 0 && (n(
((u = (g = e == null ? void 0 : e.target) == null ? void 0 : g.value) == null ? void 0 : u.length) > 1 ? (f = (v = e == null ? void 0 : e.target) == null ? void 0 : v.value) == null ? void 0 : f.replace(/^0+/, "") : (p = e == null ? void 0 : e.target) == null ? void 0 : p.value
), l == null || l((d = e == null ? void 0 : e.target) == null ? void 0 : d.value));
},
value: c == null ? void 0 : c.toString()
}
)
] })
] });
}), le = y((s, x) => {
const { text: m = "Weight", unitText: a = "kg", onChange: l = () => {
} } = s, [c, n] = N(1);
return /* @__PURE__ */ i(z, { children: [
/* @__PURE__ */ i("div", { className: "grid-label", children: [
m,
" ",
/* @__PURE__ */ t("span", { className: "unit", children: `(${a})` })
] }),
/* @__PURE__ */ i("div", { className: "caluclating-group", children: [
/* @__PURE__ */ t(
G,
{
className: "range-input-lnc",
max: 400,
min: 0,
step: 1,
value: c,
color: "success",
defaultValue: 0,
onChange: (e) => {
var r, o;
n((r = e == null ? void 0 : e.target) == null ? void 0 : r.value), l == null || l((o = e == null ? void 0 : e.target) == null ? void 0 : o.value);
}
}
),
/* @__PURE__ */ t(
"input",
{
tabIndex: 2,
type: "text",
className: "calculating-input",
onChange: (e) => {
var r, o, g, u, v, f, p, d;
!isNaN((r = e == null ? void 0 : e.target) == null ? void 0 : r.value) && +((o = e == null ? void 0 : e.target) == null ? void 0 : o.value) >= 0 && (n(
((u = (g = e == null ? void 0 : e.target) == null ? void 0 : g.value) == null ? void 0 : u.length) > 1 ? (f = (v = e == null ? void 0 : e.target) == null ? void 0 : v.value) == null ? void 0 : f.replace(/^0+/, "") : (p = e == null ? void 0 : e.target) == null ? void 0 : p.value
), l == null || l((d = e == null ? void 0 : e.target) == null ? void 0 : d.value));
},
value: c == null ? void 0 : c.toString()
}
)
] })
] });
}), ce = y((s, x) => {
const {
text: m = "Activity level",
activityLevels: a,
onChange: l = () => {
}
} = s, [c, n] = N(null);
return /* @__PURE__ */ i(z, { children: [
/* @__PURE__ */ t("div", { className: "grid-label", children: m }),
/* @__PURE__ */ t("div", { className: "caluclating-group", children: a == null ? void 0 : a.map((e, r) => /* @__PURE__ */ t(
R,
{
type: "button",
btnType: c === (e == null ? void 0 : e.code) ? "filled" : "tinted",
color: "neutral",
borderRadius: "curved",
onClick: () => {
n(e == null ? void 0 : e.code), l(e == null ? void 0 : e.code);
},
children: e == null ? void 0 : e.name
},
r
)) })
] });
}), oe = y((s, x) => {
const { text: m = "Goal", goals: a, onChange: l = () => {
} } = s, [c, n] = N(null);
return /* @__PURE__ */ i(z, { children: [
/* @__PURE__ */ t("div", { className: "grid-label", children: m }),
/* @__PURE__ */ t("div", { className: "caluclating-group group-activity", children: a == null ? void 0 : a.map((e, r) => /* @__PURE__ */ t(
R,
{
type: "button",
btnType: c === (e == null ? void 0 : e.code) ? "filled" : "tinted",
color: "neutral",
borderRadius: "curved",
onClick: () => {
n(e == null ? void 0 : e.code), l(e == null ? void 0 : e.code);
},
children: /* @__PURE__ */ i("div", { className: "btn-cnt", children: [
/* @__PURE__ */ t("i", { className: e == null ? void 0 : e.icon }),
/* @__PURE__ */ t("span", { children: e == null ? void 0 : e.name })
] })
},
r
)) })
] });
}), se = y((s, x) => {
const {
caloriesText: m = "Calories",
carbsText: a = "Carbs",
proteinText: l = "Protein",
fatsText: c = "Fats",
calculateAgainText: n = "Calculate again",
calories: e,
carbs: r,
protein: o,
fats: g,
onGoBack: u = () => {
}
} = s;
return /* @__PURE__ */ i(_, { children: [
/* @__PURE__ */ i(ee, { children: [
/* @__PURE__ */ i($, { color: "var(--warning-600)", children: [
/* @__PURE__ */ t("i", { className: "mng-lnc-fire" }),
/* @__PURE__ */ i("div", { className: "subgroup", children: [
/* @__PURE__ */ i("div", { children: [
e,
" kcal"
] }),
/* @__PURE__ */ t("div", { className: "subtext", children: m })
] })
] }),
/* @__PURE__ */ i($, { color: "var(--secondary-400)", children: [
/* @__PURE__ */ t("i", { className: "mng-lnc-leaf" }),
/* @__PURE__ */ i("div", { className: "subgroup", children: [
/* @__PURE__ */ i("div", { children: [
r,
"g"
] }),
/* @__PURE__ */ t("div", { className: "subtext", children: a })
] })
] }),
/* @__PURE__ */ i($, { color: "var(--info-500)", children: [
/* @__PURE__ */ t("i", { className: "mng-lnc-meat" }),
/* @__PURE__ */ i("div", { className: "subgroup", children: [
/* @__PURE__ */ i("div", { children: [
o,
"g"
] }),
/* @__PURE__ */ t("div", { className: "subtext", children: l })
] })
] }),
/* @__PURE__ */ i($, { color: "var(--warning-300)", children: [
/* @__PURE__ */ t("i", { className: "mng-lnc-meat" }),
/* @__PURE__ */ i("div", { className: "subgroup", children: [
/* @__PURE__ */ i("div", { children: [
g,
"g"
] }),
/* @__PURE__ */ t("div", { className: "subtext", children: c })
] })
] })
] }),
/* @__PURE__ */ i("div", { className: "dropdown-group", children: [
/* @__PURE__ */ t("div", { className: "vertical-line" }),
/* @__PURE__ */ t(
K,
{
color: "neutral",
control: /* @__PURE__ */ t(
P,
{
borderRadius: "curved",
btnType: "basic",
className: "dropdown-btn",
color: "neutral",
icon: "ellipsis",
type: "button"
}
),
offsetValue: -10,
placement: "bottom-end",
children: /* @__PURE__ */ t(Y, { icon: "star", onClick: u, children: n })
}
)
] })
] });
}), de = y((s, x) => {
const {
caloriesText: m,
carbsText: a,
proteinText: l,
fatsText: c,
calculateAgainText: n,
yearsText: e,
heightText: r,
weightText: o,
genderText: g,
calculateText: u,
closeText: v,
genders: f,
activityLevels: p,
activityLevelText: d,
goalText: k,
goals: C,
title: h = "Daily calorie calculator",
subtitle: S = "Lorem ipsum dolor sit amet",
list: j = [
"Ovdje može pisati zašto je bitno da znamo kolika nam je dnevna kalorijska potreba.",
"Ovdje može pisati zašto je bitno da znamo kolikanam je dnevna kalorijska potreba.",
"From certified dealers from all over Europe"
],
buttonText: A = "Calculate calorie needs"
} = s, [W, L] = N(1), [b, B] = N(0);
return /* @__PURE__ */ i(Q, { ref: x, children: [
/* @__PURE__ */ i(U, { children: [
/* @__PURE__ */ t("div", { className: "header-title", children: h }),
/* @__PURE__ */ t("div", { className: "header-subtitle", children: S })
] }),
W === 1 && /* @__PURE__ */ t(
q,
{
buttonText: A,
onButtonAction: () => {
L(2);
},
list: j
}
),
W === 2 && /* @__PURE__ */ t(
ne,
{
yearsText: e,
heightText: r,
weightText: o,
genderText: g,
calculateText: u,
closeText: v,
onClose: () => L(1),
genders: f,
activityLevels: p,
activityLevelText: d,
goalText: k,
goals: C,
onCalculate: ({
gender: I,
year: M,
height: V,
weight: F,
activityLevel: H,
goal: O
}) => {
const D = J({
gender: I,
age: M,
heightCm: V,
weightKg: F,
activityLevel: H,
goal: O
});
B(D), L(3);
}
}
),
W === 3 && /* @__PURE__ */ t(
se,
{
caloriesText: m,
carbsText: a,
proteinText: l,
fatsText: c,
calculateAgainText: n,
onGoBack: () => L(2),
calories: b == null ? void 0 : b.calories,
fats: b == null ? void 0 : b.fat,
carbs: b == null ? void 0 : b.carbs,
protein: b == null ? void 0 : b.protein
}
)
] });
}), Ce = y((s, x) => /* @__PURE__ */ t("div", { className: "lp-section lp-calorie-calculator-section", children: /* @__PURE__ */ t(de, { ref: x, ...s }) }));
export {
Ce as default
};