|
| 1 | +/* |
| 2 | + * Copyright 2022 Adobe. All rights reserved. |
| 3 | + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. You may obtain a copy |
| 5 | + * of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | + * |
| 7 | + * Unless required by applicable law or agreed to in writing, software distributed under |
| 8 | + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS |
| 9 | + * OF ANY KIND, either express or implied. See the License for the specific language |
| 10 | + * governing permissions and limitations under the License. |
| 11 | + */ |
| 12 | + |
| 13 | +import {action} from '@storybook/addon-actions'; |
| 14 | +import {Button, Form, Input, Label, ListBox, ListBoxItem, Popover, Select, SelectValue, TextField} from 'react-aria-components'; |
| 15 | +import React from 'react'; |
| 16 | + |
| 17 | +export default { |
| 18 | + title: 'React Aria Components' |
| 19 | +}; |
| 20 | + |
| 21 | + |
| 22 | +export const FormAutoFillExample = () => { |
| 23 | + return ( |
| 24 | + <Form |
| 25 | + aria-label="Shipping information" |
| 26 | + onSubmit={e => { |
| 27 | + action('onSubmit')(Object.fromEntries(new FormData(e.target as HTMLFormElement).entries())); |
| 28 | + e.preventDefault(); |
| 29 | + }}> |
| 30 | + <TextField> |
| 31 | + <Label>Address</Label> |
| 32 | + <Input name="streetAddress" type="text" id="streetAddress" autoComplete="shipping street-address" /> |
| 33 | + </TextField> |
| 34 | + <TextField> |
| 35 | + <Label>City</Label> |
| 36 | + <Input name="city" type="text" id="city" autoComplete="shipping address-level2" /> |
| 37 | + </TextField> |
| 38 | + <TextField> |
| 39 | + <Label>State</Label> |
| 40 | + <Input name="state" type="text" id="state" autoComplete="shipping address-level1" /> |
| 41 | + </TextField> |
| 42 | + <TextField> |
| 43 | + <Label>Zip</Label> |
| 44 | + <Input name="city" type="text" id="city" autoComplete="shipping postal-code" /> |
| 45 | + </TextField> |
| 46 | + <Select name="country" id="country" autoComplete="shipping country"> |
| 47 | + <Label>Country</Label> |
| 48 | + <Button> |
| 49 | + <SelectValue /> |
| 50 | + <span aria-hidden="true">▼</span> |
| 51 | + </Button> |
| 52 | + <Popover> |
| 53 | + <ListBox> |
| 54 | + <ListBoxItem>Greece</ListBoxItem> |
| 55 | + <ListBoxItem>Italy</ListBoxItem> |
| 56 | + <ListBoxItem>Spain</ListBoxItem> |
| 57 | + <ListBoxItem>Mexico</ListBoxItem> |
| 58 | + <ListBoxItem>Canada</ListBoxItem> |
| 59 | + <ListBoxItem>United States</ListBoxItem> |
| 60 | + </ListBox> |
| 61 | + </Popover> |
| 62 | + </Select> |
| 63 | + <Button type="submit">Submit</Button> |
| 64 | + </Form> |
| 65 | + ); |
| 66 | +}; |
| 67 | + |
0 commit comments