Prepare v0.1.0 release
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { PasswordField } from "@govoplan/core-webui";
|
||||
import { inputValueToFieldValue, normalizeFieldType, valueToInputText } from "../utils/fieldDefinitions";
|
||||
|
||||
export type FieldValueInputProps = {
|
||||
@@ -11,6 +12,19 @@ export type FieldValueInputProps = {
|
||||
|
||||
export default function FieldValueInput({ fieldType = "string", value, disabled = false, placeholder, className, onChange }: FieldValueInputProps) {
|
||||
const normalizedType = normalizeFieldType(fieldType);
|
||||
if (normalizedType === "password") {
|
||||
return (
|
||||
<PasswordField
|
||||
inputClassName={className}
|
||||
value={valueToInputText(value, normalizedType)}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
autoComplete="new-password"
|
||||
onValueChange={(nextValue) => onChange(inputValueToFieldValue(normalizedType, nextValue))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const inputType = inputTypeForField(normalizedType);
|
||||
const step = normalizedType === "integer" ? "1" : normalizedType === "double" ? "any" : undefined;
|
||||
|
||||
@@ -22,7 +36,6 @@ export default function FieldValueInput({ fieldType = "string", value, disabled
|
||||
value={valueToInputText(value, normalizedType)}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
autoComplete={normalizedType === "password" ? "new-password" : undefined}
|
||||
onChange={(event) => onChange(inputValueToFieldValue(normalizedType, event.target.value))}
|
||||
/>
|
||||
);
|
||||
@@ -31,6 +44,5 @@ export default function FieldValueInput({ fieldType = "string", value, disabled
|
||||
function inputTypeForField(fieldType: string): string {
|
||||
if (fieldType === "integer" || fieldType === "double") return "number";
|
||||
if (fieldType === "date") return "date";
|
||||
if (fieldType === "password") return "password";
|
||||
return "text";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user