mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
feat(react/settings): port note erasure timeout
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user