/
FormPillGroup.tsx
50 lines (45 loc) · 1.44 KB
/
FormPillGroup.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as React from 'react';
import {Box, safelySpreadBoxProps} from '@twilio-paste/box';
import {Composite} from '@twilio-paste/reakit-library';
import type {CompositeProps} from '@twilio-paste/reakit-library';
export interface FormPillGroupProps
extends Omit<CompositeProps, 'unstable_virtual' | 'unstable_moves' | 'unstable_system' | 'wrapElement' | 'wrap'> {
'aria-label': string;
element?: string;
children: React.ReactNode;
}
const FormPillGroupStyles = React.forwardRef<HTMLUListElement, FormPillGroupProps>(
({element = 'FORM_PILL_GROUP', ...props}, ref) => (
<Box
{...safelySpreadBoxProps(props)}
element={element}
ref={ref}
role="listbox"
margin="space0"
padding="space0"
display="flex"
columnGap="space30"
>
{props.children}
</Box>
)
);
FormPillGroupStyles.displayName = 'StyledFormPillGroup';
/**
* FormPillGroup should be used to wrap a collection of FormPills. It should be used in conjunction with
* useFormPillGroupState hook
*
* @example
* <FormPillGroup {...pillState} aria-label="Your favorite sports:">
* ...
* </FormPillGroup>
* @see http://paste.twilio.design/components/form-pill-group
*/
export const FormPillGroup = React.forwardRef<HTMLUListElement, FormPillGroupProps>((props, ref) => {
return (
<Composite as={FormPillGroupStyles} {...props} ref={ref}>
{props.children}
</Composite>
);
});
FormPillGroup.displayName = 'FormPillGroup';