@uva-glass/component-library
Version:
React components UvA
46 lines (45 loc) • 1.68 kB
JavaScript
import { jsx as l } from "react/jsx-runtime";
import { c as P } from "../../clsx-OuTLNxxd.js";
import { useId as N } from "react";
import '../../assets/Periods.css';const g = "_periods__container_197yl_1", v = "_periods__item_197yl_6", _ = {
periods__container: g,
periods__item: v,
"periods__item--active": "_periods__item--active_197yl_23"
}, S = 6, O = ({ periods: i, tooltipTranslations: u, maxPeriods: p = S }) => {
const f = Array.from({ length: p }, (e, t) => t + 1), $ = N(), a = i.some((e) => typeof e == "number"), b = (e) => {
const t = {};
return a ? i.forEach((s) => {
if (typeof s == "number") {
const r = Math.ceil(s / 3), o = (s - 1) % 3 + 1;
t[r] || (t[r] = []), t[r].push(o);
}
}) : i.forEach((s) => {
const { semesterNumber: r, periodInSemester: o } = s;
t[r] || (t[r] = []), t[r].push(o);
}), Object.keys(t).reduce((s, r, o) => {
const c = Number(r), n = t[c];
let m = "";
const d = n.length > 1 ? e.periods : e.period;
if (n.length > 1) {
const h = n.pop();
m = `Semester ${c} ${d} ${n.join(", ")} ${e.and} ${h}`;
} else
m = `Semester ${c} ${d} ${n[0]}`;
return `${s}${o > 0 ? ". " : ""}${m}`;
}, "").trim() + ".";
}, y = (e) => a ? i.includes(e) : !!i.find((t) => t.number === e);
return /* @__PURE__ */ l("div", { className: _.periods__container, title: u ? b(u) : "", children: f.map((e) => /* @__PURE__ */ l(
"span",
{
className: P(
_.periods__item,
y(e) ? _["periods__item--active"] : ""
)
},
`${$}-${e}`
)) });
};
export {
O as Periods
};
//# sourceMappingURL=Periods.js.map