UNPKG

948 BPlain TextView Raw
1import { DayFlag, SelectionState, UI } from "../UI.js";
2import type { ModifiersClassNames, ClassNames } from "../types/index.js";
3
4export function getClassNamesForModifiers(
5 modifiers: Record<string, boolean>,
6 classNames: ClassNames,
7 modifiersClassNames: ModifiersClassNames = {}
8) {
9 const modifierClassNames = Object.entries(modifiers)
10 .filter(([, active]) => active === true)
11 .reduce(
12 (previousValue, [key]) => {
13 if (modifiersClassNames[key]) {
14 previousValue.push(modifiersClassNames[key as string]);
15 } else if (classNames[DayFlag[key as DayFlag]]) {
16 previousValue.push(classNames[DayFlag[key as DayFlag]]);
17 } else if (classNames[SelectionState[key as SelectionState]]) {
18 previousValue.push(classNames[SelectionState[key as SelectionState]]);
19 }
20 return previousValue;
21 },
22 [classNames[UI.Day]] as string[]
23 );
24
25 return modifierClassNames;
26}