Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AutocompleteField and AsyncAutocompleteField components #2141

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

johnnyomair
Copy link
Collaborator

Examples

<AutocompleteField
    name="autocomplete"
    label="Autocomplete"
    options={[
        { value: "chocolate", label: "Chocolate" },
        { value: "strawberry", label: "Strawberry" },
        { value: "vanilla", label: "Vanilla" },
    ]}
    getOptionLabel={(option: Option) => option.label}
    isOptionEqualToValue={(option: Option, value: Option) => option.value === value.value}
    fullWidth
/>
<AsyncAutocompleteField
    name="asyncAutocomplete"
    label="Async Autocomplete"
    loadOptions={async () => {
        // Load options here
    }}
    getOptionLabel={(option: Option) => option.label}
    isOptionEqualToValue={(option: Option, value: Option) => option.value === value.value}
    fullWidth
/>

Depends on #2069

PR Checklist

  • Verify if the change requires a changeset. See CONTRIBUTING.md
  • Link to the respective task if one exists: COM-793

@johnnyomair johnnyomair self-assigned this Jun 4, 2024
@johnnyomair johnnyomair changed the title Autocomplete field Add AutocompleteField and AsyncAutocompleteField components Jun 4, 2024
nsams
nsams previously approved these changes Jun 4, 2024
jamesricky
jamesricky previously approved these changes Jun 5, 2024
**Examples**

```tsx
<AutocompleteField
    name="autocomplete"
    label="Autocomplete"
    options={[
        { value: "chocolate", label: "Chocolate" },
        { value: "strawberry", label: "Strawberry" },
        { value: "vanilla", label: "Vanilla" },
    ]}
    getOptionLabel={(option: Option) => option.label}
    isOptionEqualToValue={(option: Option, value: Option) => option.value === value.value}
    fullWidth
/>
```

```tsx
<AsyncAutocompleteField
    name="asyncAutocomplete"
    label="Async Autocomplete"
    loadOptions={async () => {
        // Load options here
    }}
    getOptionLabel={(option: Option) => option.label}
    isOptionEqualToValue={(option: Option, value: Option) => option.value === value.value}
    fullWidth
/>
```
@johnnyomair johnnyomair merged commit 796e832 into main Jun 11, 2024
11 checks passed
@johnnyomair johnnyomair deleted the autocomplete-field branch June 11, 2024 08:15
fichtnerma pushed a commit that referenced this pull request Jul 18, 2024
**Examples**

```tsx
<AutocompleteField
    name="autocomplete"
    label="Autocomplete"
    options={[
        { value: "chocolate", label: "Chocolate" },
        { value: "strawberry", label: "Strawberry" },
        { value: "vanilla", label: "Vanilla" },
    ]}
    getOptionLabel={(option: Option) => option.label}
    isOptionEqualToValue={(option: Option, value: Option) => option.value === value.value}
    fullWidth
/>
```

```tsx
<AsyncAutocompleteField
    name="asyncAutocomplete"
    label="Async Autocomplete"
    loadOptions={async () => {
        // Load options here
    }}
    getOptionLabel={(option: Option) => option.label}
    isOptionEqualToValue={(option: Option, value: Option) => option.value === value.value}
    fullWidth
/>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants