refactor: upgrade react and add compiler

This commit is contained in:
Carlos Valente
2025-07-12 17:34:29 +02:00
parent d24d5c1365
commit 1c6adbd2fd
11 changed files with 176 additions and 250 deletions
@@ -22,7 +22,7 @@ type AllowedTags = 'div' | 'form';
type SectionProps<C extends AllowedTags> = {
as?: C;
children: ReactNode;
} & JSX.IntrinsicElements[C];
} & React.JSX.IntrinsicElements[C];
export function Section<C extends AllowedTags = 'div'>({ as, className, children, ...props }: SectionProps<C>) {
const Element = as ?? 'div';
@@ -46,7 +46,7 @@ export function Paragraph({ children }: { children: ReactNode }) {
return <p className={style.paragraph}>{children}</p>;
}
export function Card({ children, className, ...props }: { children: ReactNode } & JSX.IntrinsicElements['div']) {
export function Card({ children, className, ...props }: { children: ReactNode } & React.JSX.IntrinsicElements['div']) {
return (
<div className={cx([style.card, className])} {...props}>
{children}
@@ -107,7 +107,7 @@ export function BlockQuote({ children }: { children: ReactNode }) {
return <blockquote className={style.blockquote}>{children}</blockquote>;
}
export function Error({ children, className }: { children: ReactNode } & JSX.IntrinsicElements['div']) {
export function Error({ children, className }: { children: ReactNode } & React.JSX.IntrinsicElements['div']) {
return <div className={cx([style.fieldError, className])}>{children}</div>;
}
@@ -1,8 +1,8 @@
import { memo, RefObject, SyntheticEvent } from 'react';
import { useLongPress } from '@mantine/hooks';
import { MILLIS_PER_MINUTE, MILLIS_PER_SECOND } from 'ontime-utils';
import DelayIndicator from '../../../common/components/delay-indicator/DelayIndicator';
import useLongPress from '../../../common/hooks/useLongPress';
import { cx, getAccessibleColour } from '../../../common/utils/styleUtils';
import { formatDuration, useTimeUntilStart } from '../../../common/utils/time';
import RunningTime from '../../viewers/common/running-time/RunningTime';
@@ -23,7 +23,7 @@ interface OperatorEventProps {
isLinkedToLoaded: boolean;
isSelected: boolean;
isPast: boolean;
selectedRef?: RefObject<HTMLDivElement>;
selectedRef?: RefObject<HTMLDivElement | null>;
subscribed: Subscribed;
totalGap: number;
onLongPress: (event: EditEvent) => void;
@@ -48,6 +48,9 @@ function OperatorEvent({
totalGap,
onLongPress,
}: OperatorEventProps) {
/**
* gather behaviour for long press and context menu
*/
const handleLongPress = (event?: SyntheticEvent) => {
// we dont have an event out of useLongPress
event?.preventDefault();
@@ -56,7 +59,7 @@ function OperatorEvent({
}
};
const mouseHandlers = useLongPress(handleLongPress, { threshold: 800 });
const mouseHandlers = useLongPress(handleLongPress);
const cueColours = colour && getAccessibleColour(colour);
const operatorClasses = cx([