Skip to content

Commit 03ed3de

Browse files
authored
Rename PrimitiveWithForwardRef => Primitive type (#909)
1 parent 6a0792d commit 03ed3de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+260
-307
lines changed

Diff for: .changeset/green-papayas-invent.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aws-amplify/ui-react": patch
3+
---
4+
5+
Rename PrimitiveWithForwardRef => Primitive type

Diff for: packages/react/src/primitives/Alert/Alert.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared/constants';
5-
import { AlertProps, PrimitiveWithForwardRef } from '../types';
5+
import { AlertProps, Primitive } from '../types';
66
import { View } from '../View';
77
import { Flex } from '../Flex';
88
import { Button } from '../Button';
99
import { AlertIcon } from './AlertIcon';
1010
import { IconClose } from '../Icon';
1111
import { isFunction } from '../shared/utils';
1212

13-
const AlertPrimitive: PrimitiveWithForwardRef<AlertProps, typeof Flex> = (
13+
const AlertPrimitive: Primitive<AlertProps, typeof Flex> = (
1414
{
1515
buttonRef,
1616
children,

Diff for: packages/react/src/primitives/Badge/Badge.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
33

4+
import { BadgeProps, Primitive } from '../types';
45
import { ComponentClassNames } from '../shared/constants';
5-
import { BadgeProps, PrimitiveWithForwardRef } from '../types';
66
import { View } from '../View';
77

8-
const BadgePrimitive: PrimitiveWithForwardRef<BadgeProps, 'span'> = (
8+
const BadgePrimitive: Primitive<BadgeProps, 'span'> = (
99
{ className, children, variation, size, ...rest },
1010
ref
1111
) => (

Diff for: packages/react/src/primitives/Button/Button.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import classNames from 'classnames';
22
import * as React from 'react';
33

4+
import { ButtonProps, Primitive } from '../types';
45
import { ComponentClassNames } from '../shared/constants';
5-
import { ButtonProps, PrimitiveWithForwardRef } from '../types';
66
import { Text } from '../Text';
77
import { View } from '../View';
88

9-
const ButtonPrimitive: PrimitiveWithForwardRef<ButtonProps, 'button'> = (
9+
const ButtonPrimitive: Primitive<ButtonProps, 'button'> = (
1010
{
1111
className,
1212
children,

Diff for: packages/react/src/primitives/ButtonGroup/ButtonGroup.tsx

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
33

4-
import { Flex } from '../Flex';
5-
import {
6-
ButtonProps,
7-
ButtonGroupProps,
8-
PrimitiveWithForwardRef,
9-
} from '../types';
4+
import { ButtonProps, ButtonGroupProps, Primitive } from '../types';
105
import { ComponentClassNames } from '../shared/constants';
6+
import { Flex } from '../Flex';
117

12-
const ButtonGroupPrimitive: PrimitiveWithForwardRef<
13-
ButtonGroupProps,
14-
typeof Flex
15-
> = (
8+
const ButtonGroupPrimitive: Primitive<ButtonGroupProps, typeof Flex> = (
169
{ className, children, role = 'group', size, variation, ...rest },
1710
ref
1811
) => (

Diff for: packages/react/src/primitives/Card/Card.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import classNames from 'classnames';
22
import * as React from 'react';
33

4+
import { CardProps, Primitive } from '../types';
45
import { ComponentClassNames } from '../shared/constants';
5-
import { CardProps, PrimitiveWithForwardRef } from '../types';
66
import { View } from '../View';
77

8-
const CardPrimitive: PrimitiveWithForwardRef<CardProps, 'div'> = (
8+
const CardPrimitive: Primitive<CardProps, 'div'> = (
99
{ className, children, variation, ...rest },
1010
ref
1111
) => (

Diff for: packages/react/src/primitives/Checkbox/Checkbox.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
33

4-
import { useCheckbox } from './useCheckbox';
4+
import { CheckboxProps } from '../types/checkbox';
5+
import { ComponentClassNames } from '../shared/constants';
56
import { Flex } from '../Flex';
67
import { IconCheck } from '../Icon';
78
import { Input } from '../Input';
9+
import { Primitive } from '../types/view';
10+
import { splitPrimitiveProps } from '../shared/styleUtils';
811
import { Text } from '../Text';
12+
import { useCheckbox } from './useCheckbox';
913
import { VisuallyHidden } from '../VisuallyHidden';
10-
import { CheckboxProps } from '../types/checkbox';
11-
import { PrimitiveWithForwardRef } from '../types/view';
12-
import { splitPrimitiveProps } from '../shared/styleUtils';
13-
import { ComponentClassNames } from '../shared/constants';
1414
import { useTestId } from '../utils/testUtils';
1515

16-
const CheckboxPrimitive: PrimitiveWithForwardRef<CheckboxProps, 'input'> = (
16+
const CheckboxPrimitive: Primitive<CheckboxProps, 'input'> = (
1717
{
1818
checked,
1919
className,

Diff for: packages/react/src/primitives/CheckboxField/CheckboxField.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { Checkbox } from '../Checkbox';
5+
import { CheckboxFieldProps, Primitive } from '../types';
6+
import { ComponentClassNames } from '../shared';
57
import { FieldErrorMessage } from '../Field';
68
import { Flex } from '../Flex';
7-
import { CheckboxFieldProps, PrimitiveWithForwardRef } from '../types';
8-
import { ComponentClassNames } from '../shared';
99
import { useTestId } from '../utils/testUtils';
1010

11-
const CheckboxFieldPrimitive: PrimitiveWithForwardRef<
12-
CheckboxFieldProps,
13-
'input'
14-
> = (
11+
const CheckboxFieldPrimitive: Primitive<CheckboxFieldProps, 'input'> = (
1512
{
1613
className,
1714
errorMessage,

Diff for: packages/react/src/primitives/Divider/Divider.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import classNames from 'classnames';
22
import * as React from 'react';
33

44
import { ComponentClassNames } from '../shared';
5-
import { DividerProps, PrimitiveWithForwardRef } from '../types';
5+
import { DividerProps, Primitive } from '../types';
66
import { View } from '../View';
77

8-
const DividerPrimitive: PrimitiveWithForwardRef<DividerProps, 'hr'> = (
8+
const DividerPrimitive: Primitive<DividerProps, 'hr'> = (
99
{ className, orientation = 'horizontal', size, ...rest },
1010
ref
1111
) => (

Diff for: packages/react/src/primitives/Expander/Expander.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import classNames from 'classnames';
2-
import { Root } from '@radix-ui/react-accordion';
31
import * as React from 'react';
2+
import { Root } from '@radix-ui/react-accordion';
3+
import classNames from 'classnames';
44

5-
import { PrimitiveWithForwardRef } from '../types/view';
6-
import { ExpanderProps } from '../types/expander';
75
import { ComponentClassNames } from '../shared/constants';
6+
import { ExpanderProps } from '../types/expander';
7+
import { Primitive } from '../types/view';
88
import { splitPrimitiveProps } from '../shared/styleUtils';
99

10-
const ExpanderPrimitive: PrimitiveWithForwardRef<ExpanderProps, typeof Root> = (
10+
const ExpanderPrimitive: Primitive<ExpanderProps, typeof Root> = (
1111
{
1212
children,
1313
className,

Diff for: packages/react/src/primitives/Expander/ExpanderItem.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import classNames from 'classnames';
2-
import { Item, Header, Trigger, Content } from '@radix-ui/react-accordion';
31
import * as React from 'react';
2+
import { Item, Header, Trigger, Content } from '@radix-ui/react-accordion';
3+
import classNames from 'classnames';
44

5-
import { IconExpandMore } from '../Icon';
6-
import { View } from '../View';
7-
import { PrimitiveWithForwardRef } from '../types/view';
8-
import { ExpanderItemProps } from '../types/expander';
95
import { ComponentClassNames } from '../shared/constants';
6+
import { ExpanderItemProps } from '../types/expander';
7+
import { IconExpandMore } from '../Icon';
8+
import { Primitive } from '../types/view';
109
import { splitPrimitiveProps } from '../shared/styleUtils';
1110
import { useStableId } from '../shared/utils';
11+
import { View } from '../View';
1212

1313
export const EXPANDER_ITEM_TEST_ID = 'expander-item';
1414
export const EXPANDER_HEADER_TEST_ID = 'expander-header';
1515
export const EXPANDER_ICON_TEST_ID = 'expander-icon';
1616
export const EXPANDER_CONTENT_TEXT_TEST_ID = 'expander-content-text';
1717

18-
const ExpanderItemPrimitive: PrimitiveWithForwardRef<
19-
ExpanderItemProps,
20-
typeof Item
21-
> = ({ children, className, title, ..._rest }, ref) => {
18+
const ExpanderItemPrimitive: Primitive<ExpanderItemProps, typeof Item> = (
19+
{ children, className, title, ..._rest },
20+
ref
21+
) => {
2222
const triggerId = useStableId();
2323
const contentId = useStableId();
2424
const { rest } = splitPrimitiveProps(_rest);

Diff for: packages/react/src/primitives/Field/FieldClearButton.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import * as React from 'react';
22

3-
import { FieldClearButtonProps, PrimitiveWithForwardRef } from '../types';
3+
import { FieldClearButtonProps, Primitive } from '../types';
44
import { FieldGroupIconButton } from '../FieldGroupIcon';
55
import { IconClose } from '../Icon';
66
import { SharedText } from '../shared/i18n';
77

88
const ariaLabelText = SharedText.Fields.ariaLabel.clearField;
99

10-
const FieldClearButtonPrimitive: PrimitiveWithForwardRef<
11-
FieldClearButtonProps,
12-
'button'
13-
> = (props, ref) => (
10+
const FieldClearButtonPrimitive: Primitive<FieldClearButtonProps, 'button'> = (
11+
props,
12+
ref
13+
) => (
1414
<FieldGroupIconButton ariaLabel={ariaLabelText} ref={ref} {...props}>
1515
<IconClose size={props.size} />
1616
</FieldGroupIconButton>

Diff for: packages/react/src/primitives/FieldGroup/FieldGroup.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared/constants';
5-
import { FieldGroupOptions, PrimitiveWithForwardRef } from '../types';
5+
import { FieldGroupOptions, Primitive } from '../types';
66
import { Flex } from '../Flex';
77
import { View } from '../View';
88

9-
const FieldGroupPrimitive: PrimitiveWithForwardRef<
10-
FieldGroupOptions,
11-
typeof Flex
12-
> = (
9+
const FieldGroupPrimitive: Primitive<FieldGroupOptions, typeof Flex> = (
1310
{
1411
children,
1512
className,

Diff for: packages/react/src/primitives/FieldGroupIcon/FieldGroupIcon.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared/constants';
5-
import { FieldGroupIconProps, PrimitiveWithForwardRef } from '../types';
5+
import { FieldGroupIconProps, Primitive } from '../types';
66
import { View } from '../View';
77

8-
const FieldGroupIconPrimitive: PrimitiveWithForwardRef<
8+
const FieldGroupIconPrimitive: Primitive<
99
FieldGroupIconProps,
1010
'button' | 'div'
1111
> = (

Diff for: packages/react/src/primitives/FieldGroupIcon/FieldGroupIconButton.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import classNames from 'classnames';
44
import { Button } from '../Button';
55
import { ComponentClassNames } from '../shared/constants';
66
import { FieldGroupIcon } from './FieldGroupIcon';
7-
import { FieldGroupIconButtonProps, PrimitiveWithForwardRef } from '../types';
7+
import { FieldGroupIconButtonProps, Primitive } from '../types';
88

9-
const FieldGroupIconButtonPrimitive: PrimitiveWithForwardRef<
9+
const FieldGroupIconButtonPrimitive: Primitive<
1010
FieldGroupIconButtonProps,
1111
'button'
1212
> = ({ children, className, ...rest }, ref) => (

Diff for: packages/react/src/primitives/Flex/Flex.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared/constants';
5-
import { FlexProps, PrimitiveWithForwardRef } from '../types';
5+
import { FlexProps, Primitive } from '../types';
66
import { View } from '../View';
77

8-
const FlexPrimitive: PrimitiveWithForwardRef<FlexProps, 'div'> = (
8+
const FlexPrimitive: Primitive<FlexProps, 'div'> = (
99
{ className, children, ...rest },
1010
ref
1111
) => (

Diff for: packages/react/src/primitives/Grid/Grid.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared/constants';
5-
import { GridProps, PrimitiveWithForwardRef } from '../types';
5+
import { GridProps, Primitive } from '../types';
66
import { View } from '../View';
77

8-
const GridPrimitive: PrimitiveWithForwardRef<GridProps, 'div'> = (
8+
const GridPrimitive: Primitive<GridProps, 'div'> = (
99
{ className, children, ...rest },
1010
ref
1111
) => (

Diff for: packages/react/src/primitives/Heading/Heading.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared/constants';
5-
import { HeadingProps, PrimitiveWithForwardRef } from '../types';
5+
import { HeadingProps, Primitive } from '../types';
66
import { View } from '../View';
77

88
type HeadingTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
@@ -20,7 +20,7 @@ const headingLevels: HeadingLevels = {
2020
6: 'h6',
2121
};
2222

23-
const HeadingPrimitive: PrimitiveWithForwardRef<HeadingProps, HeadingTag> = (
23+
const HeadingPrimitive: Primitive<HeadingProps, HeadingTag> = (
2424
{ className, children, level = 6, ...rest },
2525
ref
2626
) => (

Diff for: packages/react/src/primitives/Icon/Icon.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
33

4-
import { IconProps, PrimitiveWithForwardRef } from '../types';
54
import { ComponentClassNames } from '../shared';
5+
import { IconProps, Primitive } from '../types';
66
import { View } from '../View';
77

88
const defaultViewBox = { minX: 0, minY: 0, width: 24, height: 24 };
99

10-
const IconPrimitive: PrimitiveWithForwardRef<IconProps, 'svg'> = (
10+
const IconPrimitive: Primitive<IconProps, 'svg'> = (
1111
{
1212
className,
1313
fill = 'currentColor',

Diff for: packages/react/src/primitives/Image/Image.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared';
5-
import { ImageProps, PrimitiveWithForwardRef } from '../types';
5+
import { ImageProps, Primitive } from '../types';
66
import { View } from '../View';
77

8-
const ImagePrimitive: PrimitiveWithForwardRef<ImageProps, 'img'> = (
8+
const ImagePrimitive: Primitive<ImageProps, 'img'> = (
99
{ className, ...rest },
1010
ref
1111
) => (

Diff for: packages/react/src/primitives/Input/Input.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared';
5-
import { InputProps, PrimitiveWithForwardRef } from '../types';
5+
import { InputProps, Primitive } from '../types';
66
import { View } from '../View';
77

8-
const InputPrimitive: PrimitiveWithForwardRef<InputProps, 'input'> = (
8+
const InputPrimitive: Primitive<InputProps, 'input'> = (
99
{
1010
autoComplete,
1111
checked,

Diff for: packages/react/src/primitives/Label/Label.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared/constants';
5-
import { LabelProps, PrimitiveWithForwardRef } from '../types';
5+
import { LabelProps, Primitive } from '../types';
66
import { View } from '../View';
77

8-
const LabelPrimitive: PrimitiveWithForwardRef<LabelProps, 'label'> = (
8+
const LabelPrimitive: Primitive<LabelProps, 'label'> = (
99
{ children, className, visuallyHidden, ...rest },
1010
ref
1111
) => {

Diff for: packages/react/src/primitives/Link/Link.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
import { ComponentClassNames } from '../shared';
5-
import { LinkProps, PrimitiveWithForwardRef } from '../types';
5+
import { LinkProps, Primitive } from '../types';
66
import { View } from '../View';
77

8-
const LinkPrimitive: PrimitiveWithForwardRef<LinkProps, 'a'> = (
8+
const LinkPrimitive: Primitive<LinkProps, 'a'> = (
99
{ as = 'a', children, className, isExternal, ...rest },
1010
ref
1111
) => {

Diff for: packages/react/src/primitives/Loader/Loader.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
33

4-
import { View } from '../View';
5-
import { LoaderProps } from '../types/loader';
6-
import { PrimitiveWithForwardRef } from '../types/view';
74
import { ComponentClassNames } from '../shared/constants';
5+
import { LoaderProps } from '../types/loader';
6+
import { Primitive } from '../types/view';
7+
import { View } from '../View';
88

99
export const LINEAR_EMPTY = 'linear-empty';
1010
export const LINEAR_FILLED = 'linear-filled';
1111
export const CIRCULAR_EMPTY = 'circular-empty';
1212
export const CIRCULAR_FILLED = 'circular-filled';
1313

14-
const LoaderPrimitive: PrimitiveWithForwardRef<LoaderProps, 'svg'> = (
14+
const LoaderPrimitive: Primitive<LoaderProps, 'svg'> = (
1515
{ className, filledColor, emptyColor, size, variation, ...rest },
1616
ref
1717
) => {

0 commit comments

Comments
 (0)