Skip to content

Commit fb3b865

Browse files
authored
chore: add autofill stories (#7722)
* chore: add autofill stories * add more components to form stories * make autocomplete form more realistic * rename story * fix lint * add picker to s2 form story
1 parent cc08a8d commit fb3b865

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

packages/@react-spectrum/s2/stories/Form.stories.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export const Example = (args: any) => (
6767
<TextField label="First Name" name="firstName" />
6868
<TextField label="Last Name" name="firstName" />
6969
<TextField label="Email" name="email" type="email" description="Enter an email" />
70+
<Picker label="Country" name="country">
71+
<PickerItem id="canada">Canada</PickerItem>
72+
<PickerItem id="united-states">United States</PickerItem>
73+
<PickerItem id="mexico">Mexico</PickerItem>
74+
<PickerItem id="argentina">Argentina</PickerItem>
75+
</Picker>
7076
<CheckboxGroup label="Favorite sports">
7177
<Checkbox value="soccer">Soccer</Checkbox>
7278
<Checkbox value="baseball">Baseball</Checkbox>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

Comments
 (0)