@uva-glass/component-library 1.59.1 → 1.59.2
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.
package/dist/assets/Periods.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._periods__container_1cv1o_1{display:flex;flex-wrap:nowrap}._periods__item_1cv1o_6{background-color:var(--color-grey-200);border:1px solid var(--color-grey-300);display:inline-block;height:.75rem;margin-right:.125rem;width:.5rem}._periods__item_1cv1o_6:nth-child(3n):not(:last-child){margin-right:.5rem}._periods__item_1cv1o_6:last-child{margin-right:0}._periods__item--active_1cv1o_23{background-color:var(--color-grey-500);border:unset}
|
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { useId as
|
|
4
|
-
import '../../assets/Periods.css';const N = "
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
},
|
|
9
|
-
const
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { c as y } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import { useId as P } from "react";
|
|
4
|
+
import '../../assets/Periods.css';const N = "_periods__container_1cv1o_1", g = "_periods__item_1cv1o_6", _ = {
|
|
5
|
+
periods__container: N,
|
|
6
|
+
periods__item: g,
|
|
7
|
+
"periods__item--active": "_periods__item--active_1cv1o_23"
|
|
8
|
+
}, S = 6, O = ({ periods: i, tooltipTranslations: u, maxPeriods: f = S }) => {
|
|
9
|
+
const l = Array.from({ length: f }, (e, t) => t + 1), $ = P(), a = i.some((e) => typeof e == "number"), b = (e) => {
|
|
10
10
|
const t = {};
|
|
11
|
-
return a ?
|
|
12
|
-
if (typeof
|
|
13
|
-
const r = Math.ceil(
|
|
11
|
+
return a ? i.forEach((s) => {
|
|
12
|
+
if (typeof s == "number") {
|
|
13
|
+
const r = Math.ceil(s / 3), o = (s - 1) % 3 + 1;
|
|
14
14
|
t[r] || (t[r] = []), t[r].push(o);
|
|
15
15
|
}
|
|
16
|
-
}) :
|
|
17
|
-
const { semesterNumber: r, periodInSemester: o } =
|
|
16
|
+
}) : i.forEach((s) => {
|
|
17
|
+
const { semesterNumber: r, periodInSemester: o } = s;
|
|
18
18
|
t[r] || (t[r] = []), t[r].push(o);
|
|
19
|
-
}), Object.keys(t).reduce((
|
|
20
|
-
const
|
|
19
|
+
}), Object.keys(t).reduce((s, r, o) => {
|
|
20
|
+
const n = Number(r), c = t[n];
|
|
21
21
|
let m = "";
|
|
22
|
-
const d =
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
m = `Semester ${
|
|
22
|
+
const d = c.length > 1 ? e.periods : e.period;
|
|
23
|
+
if (c.length > 1) {
|
|
24
|
+
const v = c.pop();
|
|
25
|
+
m = `Semester ${n} ${d} ${c.join(", ")} ${e.and} ${v}`;
|
|
26
26
|
} else
|
|
27
|
-
m = `Semester ${
|
|
28
|
-
return `${
|
|
27
|
+
m = `Semester ${n} ${d} ${c[0]}`;
|
|
28
|
+
return `${s}${o > 0 ? ". " : ""}${m}`;
|
|
29
29
|
}, "").trim() + ".";
|
|
30
|
-
}, h = (e) => a ?
|
|
31
|
-
return /* @__PURE__ */
|
|
30
|
+
}, h = (e) => a ? i.includes(e) : !!i.find((t) => t.number === e);
|
|
31
|
+
return /* @__PURE__ */ p("div", { className: _.periods__container, title: u ? b(u) : "", children: l.map((e) => /* @__PURE__ */ p(
|
|
32
32
|
"span",
|
|
33
33
|
{
|
|
34
|
-
className:
|
|
34
|
+
className: y(
|
|
35
|
+
_.periods__item,
|
|
36
|
+
h(e) ? _["periods__item--active"] : ""
|
|
37
|
+
)
|
|
35
38
|
},
|
|
36
39
|
`${$}-${e}`
|
|
37
40
|
)) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Periods.js","sources":["../../../src/components/Periods/Periods.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useId } from 'react';\n\nimport styles from './Periods.module.css';\n\ninterface Period {\n id: string;\n number: number;\n semesterNumber: number;\n periodInSemester: number;\n}\n\ninterface TooltipTranslations {\n period: string;\n periods: string;\n and: string;\n}\n\nexport interface PeriodsProps {\n /** Indicates which periods are selected. */\n periods: Period[] | number[];\n /** Indicates the maximum number of periods to show in the selector. */\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n maxPeriods?: 6 | 7;\n /** A object of translations for the tooltip. */\n tooltipTranslations?: TooltipTranslations;\n}\n\nconst MAX_PERIODS = 6;\n\n/** Represents a component for a period indicator. */\nexport const Periods = ({ periods, tooltipTranslations, maxPeriods = MAX_PERIODS }: PeriodsProps) => {\n const maxPeriodsList = Array.from({ length: maxPeriods }, (_, index) => index + 1);\n const idPrefix = useId();\n\n const isArrayOfNumbers = periods.some((value) => {\n return typeof value === 'number';\n });\n\n const getTitles = (tooltipTranslations: TooltipTranslations): string => {\n const semesterPeriods: Record<number, number[]> = {};\n\n // Group periods by semester\n isArrayOfNumbers\n ? periods.forEach((period) => {\n if (typeof period === 'number') {\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const groupKey = Math.ceil(period / 3); // Determine the semester (1, 2, or 3)\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const mappedValue = ((period - 1) % 3) + 1; // Map period to semester\n\n if (!semesterPeriods[groupKey]) {\n semesterPeriods[groupKey] = [];\n }\n semesterPeriods[groupKey].push(mappedValue);\n }\n })\n : periods.forEach((period) => {\n const { semesterNumber, periodInSemester } = period as Period;\n\n if (!semesterPeriods[semesterNumber]) {\n semesterPeriods[semesterNumber] = [];\n }\n semesterPeriods[semesterNumber].push(periodInSemester);\n });\n\n // Build the title string\n const title = Object.keys(semesterPeriods).reduce((acc, semesterKey, index) => {\n const semesterNumber = Number(semesterKey);\n const periodsInSemester = semesterPeriods[semesterNumber];\n let periodTitle = '';\n\n // Determine if we need singular or plural form for \"period\"\n const blokLabel = periodsInSemester.length > 1 ? tooltipTranslations.periods : tooltipTranslations.period;\n\n // Build period sequence for the current semester\n if (periodsInSemester.length > 1) {\n const lastPeriod = periodsInSemester.pop();\n periodTitle = `Semester ${semesterNumber} ${blokLabel} ${periodsInSemester.join(', ')} ${tooltipTranslations.and} ${lastPeriod}`;\n } else {\n periodTitle = `Semester ${semesterNumber} ${blokLabel} ${periodsInSemester[0]}`;\n }\n\n // Add proper spacing and periods\n return `${acc}${index > 0 ? '. ' : ''}${periodTitle}`;\n }, '');\n\n return title.trim() + '.';\n };\n\n const isPeriodActive = (periodIndex: number): boolean => {\n if (isArrayOfNumbers) {\n return (periods as number[]).includes(periodIndex);\n } else {\n return periods.find((period) => (period as Period).number === periodIndex) ? true : false;\n }\n };\n\n return (\n <div className={styles['
|
|
1
|
+
{"version":3,"file":"Periods.js","sources":["../../../src/components/Periods/Periods.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useId } from 'react';\n\nimport styles from './Periods.module.css';\n\ninterface Period {\n id: string;\n number: number;\n semesterNumber: number;\n periodInSemester: number;\n}\n\ninterface TooltipTranslations {\n period: string;\n periods: string;\n and: string;\n}\n\nexport interface PeriodsProps {\n /** Indicates which periods are selected. */\n periods: Period[] | number[];\n /** Indicates the maximum number of periods to show in the selector. */\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n maxPeriods?: 6 | 7;\n /** A object of translations for the tooltip. */\n tooltipTranslations?: TooltipTranslations;\n}\n\nconst MAX_PERIODS = 6;\n\n/** Represents a component for a period indicator. */\nexport const Periods = ({ periods, tooltipTranslations, maxPeriods = MAX_PERIODS }: PeriodsProps) => {\n const maxPeriodsList = Array.from({ length: maxPeriods }, (_, index) => index + 1);\n const idPrefix = useId();\n\n const isArrayOfNumbers = periods.some((value) => {\n return typeof value === 'number';\n });\n\n const getTitles = (tooltipTranslations: TooltipTranslations): string => {\n const semesterPeriods: Record<number, number[]> = {};\n\n // Group periods by semester\n isArrayOfNumbers\n ? periods.forEach((period) => {\n if (typeof period === 'number') {\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const groupKey = Math.ceil(period / 3); // Determine the semester (1, 2, or 3)\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const mappedValue = ((period - 1) % 3) + 1; // Map period to semester\n\n if (!semesterPeriods[groupKey]) {\n semesterPeriods[groupKey] = [];\n }\n semesterPeriods[groupKey].push(mappedValue);\n }\n })\n : periods.forEach((period) => {\n const { semesterNumber, periodInSemester } = period as Period;\n\n if (!semesterPeriods[semesterNumber]) {\n semesterPeriods[semesterNumber] = [];\n }\n semesterPeriods[semesterNumber].push(periodInSemester);\n });\n\n // Build the title string\n const title = Object.keys(semesterPeriods).reduce((acc, semesterKey, index) => {\n const semesterNumber = Number(semesterKey);\n const periodsInSemester = semesterPeriods[semesterNumber];\n let periodTitle = '';\n\n // Determine if we need singular or plural form for \"period\"\n const blokLabel = periodsInSemester.length > 1 ? tooltipTranslations.periods : tooltipTranslations.period;\n\n // Build period sequence for the current semester\n if (periodsInSemester.length > 1) {\n const lastPeriod = periodsInSemester.pop();\n periodTitle = `Semester ${semesterNumber} ${blokLabel} ${periodsInSemester.join(', ')} ${tooltipTranslations.and} ${lastPeriod}`;\n } else {\n periodTitle = `Semester ${semesterNumber} ${blokLabel} ${periodsInSemester[0]}`;\n }\n\n // Add proper spacing and periods\n return `${acc}${index > 0 ? '. ' : ''}${periodTitle}`;\n }, '');\n\n return title.trim() + '.';\n };\n\n const isPeriodActive = (periodIndex: number): boolean => {\n if (isArrayOfNumbers) {\n return (periods as number[]).includes(periodIndex);\n } else {\n return periods.find((period) => (period as Period).number === periodIndex) ? true : false;\n }\n };\n\n return (\n <div className={styles['periods__container']} title={tooltipTranslations ? getTitles(tooltipTranslations) : ''}>\n {maxPeriodsList.map((periodIndex) => {\n return (\n <span\n className={clsx(\n styles['periods__item'],\n isPeriodActive(periodIndex) ? styles['periods__item--active'] : ''\n )}\n key={`${idPrefix}-${periodIndex}`}\n />\n );\n })}\n </div>\n );\n};\n"],"names":["MAX_PERIODS","Periods","periods","tooltipTranslations","maxPeriods","maxPeriodsList","_","index","idPrefix","useId","isArrayOfNumbers","value","getTitles","semesterPeriods","period","groupKey","mappedValue","semesterNumber","periodInSemester","acc","semesterKey","periodsInSemester","periodTitle","blokLabel","lastPeriod","isPeriodActive","periodIndex","jsx","styles","clsx"],"mappings":";;;;;;;GA4BMA,IAAc,GAGPC,IAAU,CAAC,EAAE,SAAAC,GAAS,qBAAAC,GAAqB,YAAAC,IAAaJ,QAAgC;AAC7F,QAAAK,IAAiB,MAAM,KAAK,EAAE,QAAQD,KAAc,CAACE,GAAGC,MAAUA,IAAQ,CAAC,GAC3EC,IAAWC,KAEXC,IAAmBR,EAAQ,KAAK,CAACS,MAC9B,OAAOA,KAAU,QACzB,GAEKC,IAAY,CAACT,MAAqD;AACtE,UAAMU,IAA4C,CAAA;AAI9C,WAAAH,IAAAR,EAAQ,QAAQ,CAACY,MAAW;AACtB,UAAA,OAAOA,KAAW,UAAU;AAE9B,cAAMC,IAAW,KAAK,KAAKD,IAAS,CAAC,GAE/BE,KAAgBF,IAAS,KAAK,IAAK;AAErC,QAACD,EAAgBE,CAAQ,MACXF,EAAAE,CAAQ,IAAI,KAEdF,EAAAE,CAAQ,EAAE,KAAKC,CAAW;AAAA,MAC5C;AAAA,IACD,CAAA,IACDd,EAAQ,QAAQ,CAACY,MAAW;AACpB,YAAA,EAAE,gBAAAG,GAAgB,kBAAAC,EAAqB,IAAAJ;AAEzC,MAACD,EAAgBI,CAAc,MACjBJ,EAAAI,CAAc,IAAI,KAEpBJ,EAAAI,CAAc,EAAE,KAAKC,CAAgB;AAAA,IAAA,CACtD,GAGS,OAAO,KAAKL,CAAe,EAAE,OAAO,CAACM,GAAKC,GAAab,MAAU;AACvE,YAAAU,IAAiB,OAAOG,CAAW,GACnCC,IAAoBR,EAAgBI,CAAc;AACxD,UAAIK,IAAc;AAGlB,YAAMC,IAAYF,EAAkB,SAAS,IAAIlB,EAAoB,UAAUA,EAAoB;AAG/F,UAAAkB,EAAkB,SA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