[frontend] Better autocapitalize/spellcheck settings on forms (#3077)

This commit is contained in:
tobi 2024-07-08 09:38:27 +02:00 committed by GitHub
commit bbbf6ebe37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 205 additions and 38 deletions

View file

@ -22,9 +22,33 @@ import { TextInput } from "../../../../components/form/inputs";
import MutationButton from "../../../../components/form/mutation-button";
import { useTextInput } from "../../../../lib/form";
import { useInstanceKeysExpireMutation } from "../../../../lib/query/admin/actions";
import isValidDomain from "is-valid-domain";
export default function ExpireRemote({}) {
const domainField = useTextInput("domain");
const domainField = useTextInput("domain", {
validator: (v: string) => {
if (v.length === 0) {
return "";
}
if (v[v.length-1] === ".") {
return "invalid domain";
}
const valid = isValidDomain(v, {
subdomain: true,
wildcard: false,
allowUnicode: true,
topLevel: false,
});
if (valid) {
return "";
}
return "invalid domain";
}
});
const [expire, expireResult] = useInstanceKeysExpireMutation();
@ -52,11 +76,13 @@ export default function ExpireRemote({}) {
<TextInput
field={domainField}
label="Domain"
type="string"
type="text"
autoCapitalize="none"
spellCheck="false"
placeholder="example.org"
/>
<MutationButton
disabled={!domainField.value}
disabled={!domainField.value || !domainField.valid}
label="Expire keys"
result={expireResult}
/>