-
Notifications
You must be signed in to change notification settings - Fork 278
/
View.tsx
47 lines (43 loc) · 960 Bytes
/
View.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
import * as React from 'react';
import { useStyles } from '../shared/styleUtils';
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef';
import {
ForwardRefPrimitive,
Primitive,
BaseViewProps,
ViewProps,
} from '../types';
const ViewPrimitive: Primitive<ViewProps, 'div'> = (
{
as = 'div',
children,
testId,
ariaLabel,
isDisabled,
style,
inert,
...rest
},
ref
) => {
const { propStyles, nonStyleProps } = useStyles(rest, style);
return React.createElement(
as,
{
'aria-label': ariaLabel,
'data-testid': testId,
disabled: isDisabled,
ref,
inert: inert ? '' : null,
style: propStyles,
...nonStyleProps,
},
children
);
};
/**
* [📖 Docs](https://ui.docs.amplify.aws/react/components/view)
*/
export const View: ForwardRefPrimitive<BaseViewProps, 'div'> =
primitiveWithForwardRef(ViewPrimitive);
View.displayName = 'View';