Enable npm workspaces and update dependencies

This commit is contained in:
Gregor Vostrak
2026-02-02 03:19:22 +01:00
parent b2af9c6bf1
commit 7efb7e6071
31 changed files with 2502 additions and 7953 deletions

View File

@@ -23,11 +23,11 @@ export const colors = [
];
export function getRandomColor() {
return colors[Math.floor(Math.random() * colors.length)];
return colors[Math.floor(Math.random() * colors.length)]!;
}
export function getRandomColorWithSeed(seed: string) {
const pseudoRandom = new Prando(seed);
const index = pseudoRandom.nextInt(0, colors.length - 1);
return colors[index];
return colors[index]!;
}

View File

@@ -14,8 +14,8 @@ export type NumberFormat =
export function formatNumber(value: number, format?: string): string {
// Convert to fixed 2 decimal places first
const parts = value.toFixed(2).split('.');
const wholePart = parts[0];
const decimalPart = parts[1];
const wholePart = parts[0] ?? '0';
const decimalPart = parts[1] ?? '00';
// Format the whole number part based on the format
let formattedWhole: string;

View File

@@ -107,7 +107,7 @@ export default class Prando {
* @return An item from the array.
*/
public nextArrayItem<T>(array: T[]): T {
return array[this.nextInt(0, array.length - 1)];
return array[this.nextInt(0, array.length - 1)] as T;
}
/**

View File

@@ -12,16 +12,16 @@ export function useSelectEvents<Type>(
const currentHightlightedIndex = filteredItems.value.indexOf(highlightedItem.value);
if (currentHightlightedIndex === 0) {
highlightedItemId.value = getKeyFromItem(
filteredItems.value[filteredItems.value.length - 1]
filteredItems.value[filteredItems.value.length - 1]!
);
} else {
highlightedItemId.value = getKeyFromItem(
filteredItems.value[currentHightlightedIndex - 1]
filteredItems.value[currentHightlightedIndex - 1]!
);
}
} else {
highlightedItemId.value = getKeyFromItem(
filteredItems.value[filteredItems.value.length - 1]
filteredItems.value[filteredItems.value.length - 1]!
);
}
}
@@ -30,14 +30,14 @@ export function useSelectEvents<Type>(
if (highlightedItem.value) {
const currentHightlightedIndex = filteredItems.value.indexOf(highlightedItem.value);
if (currentHightlightedIndex === filteredItems.value.length - 1) {
highlightedItemId.value = getKeyFromItem(filteredItems.value[0]);
highlightedItemId.value = getKeyFromItem(filteredItems.value[0]!);
} else {
highlightedItemId.value = getKeyFromItem(
filteredItems.value[currentHightlightedIndex + 1]
filteredItems.value[currentHightlightedIndex + 1]!
);
}
} else {
highlightedItemId.value = getKeyFromItem(filteredItems.value[0]);
highlightedItemId.value = getKeyFromItem(filteredItems.value[0]!);
}
}

View File

@@ -227,9 +227,9 @@ export function parseTimeInput(
if (HHMMSStimeRegex.test(input)) {
const match = input.match(HHMMSStimeRegex);
if (match) {
const hours = parseInt(match[1]);
const minutes = parseInt(match[2]);
const seconds = parseInt(match[3]);
const hours = parseInt(match[1]!);
const minutes = parseInt(match[2]!);
const seconds = parseInt(match[3]!);
return hours * 3600 + minutes * 60 + seconds;
}
}
@@ -239,8 +239,8 @@ export function parseTimeInput(
if (HHMMtimeRegex.test(input)) {
const match = input.match(HHMMtimeRegex);
if (match) {
const hours = parseInt(match[1]);
const minutes = parseInt(match[2]);
const hours = parseInt(match[1]!);
const minutes = parseInt(match[2]!);
return (hours * 60 + minutes) * 60;
}
}