Created first disk

This commit is contained in:
2023-10-26 11:43:05 +02:00
parent 081b0f7784
commit bdb2f6427d
14 changed files with 393 additions and 25 deletions

View File

@ -18,6 +18,19 @@ export function TextInput(p: {
}): React.ReactElement {
if (((!p.editable && p.value) ?? "") === "") return <></>;
let valueError = undefined;
if (p.value && p.value.length > 0) {
if (p.size?.min && p.type !== "number" && p.value.length < p.size.min)
valueError = "Invalid value size";
if (p.checkValue && !p.checkValue(p.value)) valueError = "Invalid value!";
if (
p.type === "number" &&
p.size &&
(Number(p.value) > p.size.max || Number(p.value) < p.size.min)
)
valueError = "Invalide size range!";
}
return (
<TextField
label={p.label}
@ -39,13 +52,8 @@ export function TextInput(p: {
multiline={p.multiline}
minRows={p.minRows}
maxRows={p.maxRows}
error={
(p.checkValue &&
p.value &&
p.value.length > 0 &&
!p.checkValue(p.value)) ||
false
}
error={valueError !== undefined}
helperText={valueError}
/>
);
}