feat(react/settings): port note erasure timeout

This commit is contained in:
Elian Doran
2025-08-18 17:37:20 +03:00
parent 53d97047a3
commit 436fd16f3a
7 changed files with 153 additions and 202 deletions

View File

@@ -3,14 +3,13 @@ import type { InputHTMLAttributes, RefObject } from "preact/compat";
interface FormTextBoxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> {
id?: string;
currentValue?: string;
onChange?(newValue: string): void;
onChange?(newValue: string, validity: ValidityState): void | false;
inputRef?: RefObject<HTMLInputElement>;
}
export default function FormTextBox({ inputRef, className, type, currentValue, onChange, ...rest}: FormTextBoxProps) {
if (type === "number" && currentValue) {
const { min, max } = rest;
console.log(currentValue , min, max);
const currentValueNum = parseInt(currentValue, 10);
if (min && currentValueNum < parseInt(String(min), 10)) {
currentValue = String(min);
@@ -25,7 +24,10 @@ export default function FormTextBox({ inputRef, className, type, currentValue, o
className={`form-control ${className ?? ""}`}
type={type ?? "text"}
value={currentValue}
onInput={e => onChange?.(e.currentTarget.value)}
onInput={e => {
const target = e.currentTarget;
onChange?.(target.value, target.validity);
}}
{...rest}
/>
);