Docs Components Uncategorized

AsyncValidatedInput

React example follows below.
ts
import { AsyncValidatedInput } from "@grassroot/ui-react";
const asyncValidatedInputFixture = {
id: "async-validated-input",
ariaLabel: "Workspace slug",
placeholder: "workspace-slug",
submitLabel: "Validate",
validValue: "grassroot",
defaultValue: "grassroot",
} satisfies {
id: string;
ariaLabel: string;
placeholder: string;
submitLabel: string;
validValue: string;
defaultValue: string;
};
export default function AsyncValidatedInputDemo() {
return (
<AsyncValidatedInput
defaultValue={f.defaultValue}
ariaLabel={f.ariaLabel}
placeholder={f.placeholder}
submitLabel={f.submitLabel}
validate={async (value) => {
if (value !== f.validValue) throw new Error("Invalid");
}}
/>
);
}
ts
<script setup lang="ts">
import { AsyncValidatedInput } from "@grassroot/ui-vue";
const asyncValidatedInputFixture = {
id: "async-validated-input",
ariaLabel: "Workspace slug",
placeholder: "workspace-slug",
submitLabel: "Validate",
validValue: "grassroot",
defaultValue: "grassroot",
} satisfies {
id: string;
ariaLabel: string;
placeholder: string;
submitLabel: string;
validValue: string;
defaultValue: string;
};
async function validate(value: string) {
if (value !== f.validValue) throw new Error("Invalid");
}
</script>
<template>
<AsyncValidatedInput
:default-value="f.defaultValue"
:aria-label="f.ariaLabel"
:placeholder="f.placeholder"
:submit-label="f.submitLabel"
:validate="validate"
/>
</template>
ts
import { Component } from "@angular/core";
const asyncValidatedInputFixture = {
id: "async-validated-input",
ariaLabel: "Workspace slug",
placeholder: "workspace-slug",
submitLabel: "Validate",
validValue: "grassroot",
defaultValue: "grassroot",
} satisfies {
id: string;
ariaLabel: string;
placeholder: string;
submitLabel: string;
validValue: string;
defaultValue: string;
};
import { GrassrootAsyncValidatedInput } from "@grassroot/ui-angular";
@Component({
selector: "app-async-validated-input-demo",
standalone: true,
imports: [GrassrootAsyncValidatedInput],
host: { style: "display: contents" },
template: `
<grassroot-async-validated-input
[validate]="validate"
[defaultValue]="fixture.defaultValue"
[ariaLabel]="fixture.ariaLabel"
[placeholder]="fixture.placeholder"
[submitLabel]="fixture.submitLabel"
/>
`,
})
export class AsyncValidatedInputDemoComponent {
protected readonly fixture = f;
protected readonly validate = async (value: string): Promise<void> => {
if (value !== f.validValue) throw new Error("Invalid");
};
}
export default AsyncValidatedInputDemoComponent;
ts
<script lang="ts">
import { AsyncValidatedInput } from "@grassroot/ui-svelte";
const asyncValidatedInputFixture = {
id: "async-validated-input",
ariaLabel: "Workspace slug",
placeholder: "workspace-slug",
submitLabel: "Validate",
validValue: "grassroot",
defaultValue: "grassroot",
} satisfies {
id: string;
ariaLabel: string;
placeholder: string;
submitLabel: string;
validValue: string;
defaultValue: string;
};
async function validate(value: string) {
if (value !== f.validValue) throw new Error("Invalid");
}
</script>
<AsyncValidatedInput
defaultValue={f.defaultValue}
ariaLabel={f.ariaLabel}
placeholder={f.placeholder}
submitLabel={f.submitLabel}
{validate}
/>
ts
/** @jsxImportSource solid-js */
import { AsyncValidatedInput } from "@grassroot/ui-solid";
const asyncValidatedInputFixture = {
id: "async-validated-input",
ariaLabel: "Workspace slug",
placeholder: "workspace-slug",
submitLabel: "Validate",
validValue: "grassroot",
defaultValue: "grassroot",
} satisfies {
id: string;
ariaLabel: string;
placeholder: string;
submitLabel: string;
validValue: string;
defaultValue: string;
};
export default function AsyncValidatedInputDemo() {
return (
<AsyncValidatedInput
defaultValue={f.defaultValue}
ariaLabel={f.ariaLabel}
placeholder={f.placeholder}
submitLabel={f.submitLabel}
validate={async (value) => {
if (value !== f.validValue) throw new Error("Invalid");
}}
/>
);
}

Installation

API Reference

Import

import { AsyncValidatedInput } from "@grassroot/ui-react";

Props

Prop
Type
Default
Requirement
value
string | undefined
—
optional
defaultValue
string | undefined
—
optional
validate
(value: string) => void | Promise<void>
—
required
onValueChange
((value: string) => void) | undefined
—
optional
status
AsyncValidatedInputStatus | undefined
—
optional
pending
boolean | undefined
—
optional
message
string | undefined
—
optional
ariaLabel
string | undefined
—
optional
placeholder
string | undefined
—
optional
Prop
value
Type
string | undefined
Default
—
Requirement
optional
Prop
defaultValue
Type
string | undefined
Default
—
Requirement
optional
Prop
validate
Type
(value: string) => void | Promise<void>
Default
—
Requirement
required
Prop
onValueChange
Type
((value: string) => void) | undefined
Default
—
Requirement
optional
Prop
status
Type
AsyncValidatedInputStatus | undefined
Default
—
Requirement
optional
Prop
pending
Type
boolean | undefined
Default
—
Requirement
optional
Prop
message
Type
string | undefined
Default
—
Requirement
optional
Prop
ariaLabel
Type
string | undefined
Default
—
Requirement
optional
Prop
placeholder
Type
string | undefined
Default
—
Requirement
optional

Events

EventPayload
onValueChange((value: string) => void) | undefined

Content regions

  • children
  • submitLabel

Native attributes

Standard DOM and ARIA attributes not listed above spread onto the root element.

Import

import { AsyncValidatedInput } from "@grassroot/ui-vue";

Props

Prop
Type
Default
Requirement
value
string | undefined
—
optional
defaultValue
string | undefined
—
optional
validate
(value: string) => void | Promise<void>
—
required
onValueChange
((value: string) => void) | undefined
—
optional
status
AsyncValidatedInputStatus | undefined
"idle"
optional
pending
boolean | undefined
false
optional
message
string | undefined
—
optional
ariaLabel
string | undefined
"Value"
optional
placeholder
string | undefined
"Enter a value"
optional
submitLabel
string | undefined
"Validate"
optional
className
string | undefined
—
optional
Prop
value
Type
string | undefined
Default
—
Requirement
optional
Prop
defaultValue
Type
string | undefined
Default
—
Requirement
optional
Prop
validate
Type
(value: string) => void | Promise<void>
Default
—
Requirement
required
Prop
onValueChange
Type
((value: string) => void) | undefined
Default
—
Requirement
optional
Prop
status
Type
AsyncValidatedInputStatus | undefined
Default
"idle"
Requirement
optional
Prop
pending
Type
boolean | undefined
Default
false
Requirement
optional
Prop
message
Type
string | undefined
Default
—
Requirement
optional
Prop
ariaLabel
Type
string | undefined
Default
"Value"
Requirement
optional
Prop
placeholder
Type
string | undefined
Default
"Enter a value"
Requirement
optional
Prop
submitLabel
Type
string | undefined
Default
"Validate"
Requirement
optional
Prop
className
Type
string | undefined
Default
—
Requirement
optional

Import

import { Component } from "@angular/core";
import { GrassrootAsyncValidatedInput } from "@grassroot/ui-angular";

Props

Prop
Type
Default
Requirement
value
string
—
optional
defaultValue
string
—
optional
validate
(value: string) => void | Promise<void>
—
required
status
AsyncValidatedInputStatus
"idle"
optional
pending
boolean
false
optional
message
string
—
optional
ariaLabel
string
"Value"
optional
placeholder
string
"Enter a value"
optional
submitLabel
string
"Validate"
optional
className
string
—
optional
Prop
value
Type
string
Default
—
Requirement
optional
Prop
defaultValue
Type
string
Default
—
Requirement
optional
Prop
validate
Type
(value: string) => void | Promise<void>
Default
—
Requirement
required
Prop
status
Type
AsyncValidatedInputStatus
Default
"idle"
Requirement
optional
Prop
pending
Type
boolean
Default
false
Requirement
optional
Prop
message
Type
string
Default
—
Requirement
optional
Prop
ariaLabel
Type
string
Default
"Value"
Requirement
optional
Prop
placeholder
Type
string
Default
"Enter a value"
Requirement
optional
Prop
submitLabel
Type
string
Default
"Validate"
Requirement
optional
Prop
className
Type
string
Default
—
Requirement
optional

Events

EventPayload
valueChangestring

Import

import { AsyncValidatedInput } from "@grassroot/ui-svelte";

Props

Prop
Type
Default
Requirement
value
string
—
optional
defaultValue
string
—
optional
validate
(value: string) => void | Promise<void>
—
required
onValueChange
(value: string) => void
—
optional
status
AsyncValidatedInputStatus
"idle"
optional
pending
boolean
false
optional
message
string
—
optional
ariaLabel
string
"Value"
optional
placeholder
string
"Enter a value"
optional
submitLabel
string
"Validate"
optional
className
string
—
optional
Prop
value
Type
string
Default
—
Requirement
optional
Prop
defaultValue
Type
string
Default
—
Requirement
optional
Prop
validate
Type
(value: string) => void | Promise<void>
Default
—
Requirement
required
Prop
onValueChange
Type
(value: string) => void
Default
—
Requirement
optional
Prop
status
Type
AsyncValidatedInputStatus
Default
"idle"
Requirement
optional
Prop
pending
Type
boolean
Default
false
Requirement
optional
Prop
message
Type
string
Default
—
Requirement
optional
Prop
ariaLabel
Type
string
Default
"Value"
Requirement
optional
Prop
placeholder
Type
string
Default
"Enter a value"
Requirement
optional
Prop
submitLabel
Type
string
Default
"Validate"
Requirement
optional
Prop
className
Type
string
Default
—
Requirement
optional

Events

EventPayload
onValueChange(value: string) => void

Content regions

  • children

Import

import { AsyncValidatedInput } from "@grassroot/ui-solid";

Props

Prop
Type
Default
Requirement
value
string
—
optional
defaultValue
string
—
optional
validate
(value: string) => void | Promise<void>
—
required
onValueChange
(value: string) => void
—
optional
status
AsyncValidatedInputStatus
—
optional
pending
boolean
—
optional
message
string
—
optional
ariaLabel
string
—
optional
placeholder
string
—
optional
Prop
value
Type
string
Default
—
Requirement
optional
Prop
defaultValue
Type
string
Default
—
Requirement
optional
Prop
validate
Type
(value: string) => void | Promise<void>
Default
—
Requirement
required
Prop
onValueChange
Type
(value: string) => void
Default
—
Requirement
optional
Prop
status
Type
AsyncValidatedInputStatus
Default
—
Requirement
optional
Prop
pending
Type
boolean
Default
—
Requirement
optional
Prop
message
Type
string
Default
—
Requirement
optional
Prop
ariaLabel
Type
string
Default
—
Requirement
optional
Prop
placeholder
Type
string
Default
—
Requirement
optional

Events

EventPayload
onValueChange(value: string) => void

Content regions

  • children
  • submitLabel

Native attributes

Standard DOM and ARIA attributes not listed above spread onto the root element.