feat: update links for improved accessibility

This commit is contained in:
Amruth Pillai
2026-05-26 13:09:30 +02:00
parent dd1e37e579
commit 8da780c868
43 changed files with 952 additions and 189 deletions
+6 -8
View File
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useState } from "react";
import { useCallback, useState } from "react";
interface CommonControlledStateProps<T> {
value?: T;
@@ -13,19 +13,17 @@ export function useControlledState<T, Rest extends unknown[] = []>(
props: UseControlledStateProps<T, Rest>,
): readonly [T, (next: T, ...args: Rest) => void] {
const { value, defaultValue, onChange } = props;
const isControlled = value !== undefined;
const [state, setInternalState] = useState<T>(value !== undefined ? value : (defaultValue as T));
useEffect(() => {
if (value !== undefined) setInternalState(value);
}, [value]);
const [internalState, setInternalState] = useState<T>(value !== undefined ? value : (defaultValue as T));
const state = isControlled ? (value as T) : internalState;
const setState = useCallback(
(next: T, ...args: Rest) => {
setInternalState(next);
if (!isControlled) setInternalState(next);
onChange?.(next, ...args);
},
[onChange],
[isControlled, onChange],
);
return [state, setState] as const;