Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forwardRef wrapper to clean up component types #19812

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use wrapper for forwardRef to clean up component type",
"packageName": "@fluentui/react-accordion",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use wrapper for forwardRef to clean up component type",
"packageName": "@fluentui/react-image",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use wrapper for forwardRef to clean up component type",
"packageName": "@fluentui/react-link",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use wrapper for forwardRef to clean up component type",
"packageName": "@fluentui/react-menu",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use wrapper for forwardRef to clean up component type",
"packageName": "@fluentui/react-popover",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use wrapper for forwardRef to clean up component type",
"packageName": "@fluentui/react-provider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use wrapper for forwardRef to clean up component type",
"packageName": "@fluentui/react-slider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Use wrapper for forwardRef to clean up component type",
"packageName": "@fluentui/react-switch",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add forwardRef wrapper, and clean up IntrinsicShorthandProps types",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
26 changes: 11 additions & 15 deletions packages/react-accordion/etc/react-accordion.api.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { renderAccordion } from './renderAccordion';
import { useAccordion } from './useAccordion';
import { useAccordionContextValues } from './useAccordionContextValues';
import type { AccordionProps } from './Accordion.types';
import { forwardRef } from '@fluentui/react-utilities';

/**
* Define a styled Accordion, using the `useAccordion` and `useAccordionStyles` hooks.
*/
export const Accordion = React.forwardRef<HTMLDivElement, AccordionProps>((props, ref) => {
export const Accordion = forwardRef<AccordionProps>((props, ref) => {
const state = useAccordion(props, ref);
const contextValues = useAccordionContextValues(state);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from 'react';
import { useAccordionHeader } from './useAccordionHeader';
import { renderAccordionHeader } from './renderAccordionHeader';
import { useAccordionHeaderStyles } from './useAccordionHeaderStyles';
import { useAccordionHeaderContextValues } from './useAccordionHeaderContextValues';
import type { AccordionHeaderProps } from './AccordionHeader.types';
import { forwardRef } from '@fluentui/react-utilities';

/**
* Define a styled AccordionHeader, using the `useAccordionHeader` and `useAccordionHeaderStyles` hooks.
*/
export const AccordionHeader = React.forwardRef<HTMLDivElement, AccordionHeaderProps>((props, ref) => {
export const AccordionHeader = forwardRef<AccordionHeaderProps>((props, ref) => {
const state = useAccordionHeader(props, ref);
const contextValues = useAccordionHeaderContextValues(state);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ import * as React from 'react';
import { useAccordionHeaderContext } from './AccordionHeaderContext';
import type { AccordionHeaderContextValue } from './AccordionHeader.types';
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
import type { ComponentProps } from '@fluentui/react-utilities';
import { forwardRef } from '@fluentui/react-utilities';

export type AccordionHeaderExpandIconProps = IntrinsicShorthandProps<'span'>;
export type AccordionHeaderExpandIconProps = ComponentProps<{ root: IntrinsicShorthandProps<'span'> }>;

export const AccordionHeaderExpandIcon = React.forwardRef<HTMLSpanElement, AccordionHeaderExpandIconProps>(
({ children, ...rest }, ref) => {
const { open, expandIconPosition } = useAccordionHeaderContext();
return (
<span {...rest} ref={ref}>
{children ?? (
<svg
fill="currentColor"
height="1em"
width="1em"
viewBox="0 0 2048 2048"
transform={`rotate(${mapStateToRotation({ open, expandIconPosition })})`}
>
<path d="M515 1955l930-931L515 93l90-90 1022 1021L605 2045l-90-90z" />
</svg>
)}
</span>
);
},
);
export const AccordionHeaderExpandIcon = forwardRef<AccordionHeaderExpandIconProps>(({ children, ...rest }, ref) => {
const { open, expandIconPosition } = useAccordionHeaderContext();
return (
<span {...rest} ref={ref}>
{children ?? (
<svg
fill="currentColor"
height="1em"
width="1em"
viewBox="0 0 2048 2048"
transform={`rotate(${mapStateToRotation({ open, expandIconPosition })})`}
>
<path d="M515 1955l930-931L515 93l90-90 1022 1021L605 2045l-90-90z" />
</svg>
)}
</span>
);
});

function mapStateToRotation({
open,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { useAccordionItem } from './useAccordionItem';
import { useAccordionItemContextValues } from './useAccordionItemContextValues';
import { renderAccordionItem } from './renderAccordionItem';
import type { AccordionItemProps } from './AccordionItem.types';
import { forwardRef } from '@fluentui/react-utilities';

/**
* Define a styled AccordionItem, using the `useAccordionItem` and `useAccordionItemStyles` hooks.
*/
export const AccordionItem = React.forwardRef<HTMLElement, AccordionItemProps>((props, ref) => {
export const AccordionItem = forwardRef<AccordionItemProps>((props, ref) => {
const state = useAccordionItem(props, ref);
const contextValues = useAccordionItemContextValues(state);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { useAccordionPanel } from './useAccordionPanel';
import { renderAccordionPanel } from './renderAccordionPanel';
import { useAccordionPanelStyles } from './useAccordionPanelStyles';
import type { AccordionPanelProps } from './AccordionPanel.types';
import { forwardRef } from '@fluentui/react-utilities';

/**
* Define a styled AccordionPanel, using the `useAccordionPanel` and `useAccordionPanelStyles` hooks.
*/
export const AccordionPanel = React.forwardRef<HTMLElement, AccordionPanelProps>((props, ref) => {
export const AccordionPanel = forwardRef<AccordionPanelProps>((props, ref) => {
const state = useAccordionPanel(props, ref);

useAccordionPanelStyles(state);
Expand Down
3 changes: 2 additions & 1 deletion packages/react-image/etc/react-image.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import { ForwardRefExoticComponent } from 'react';
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
import * as React_2 from 'react';

// @public
const Image_2: React_2.ForwardRefExoticComponent<ImageProps & React_2.RefAttributes<HTMLImageElement>>;
const Image_2: ForwardRefExoticComponent<ImageProps>;
export { Image_2 as Image }

// @public (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions packages/react-image/src/components/Image/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { renderImage } from './renderImage';
import { useImage } from './useImage';
import { useImageStyles } from './useImageStyles';
import type { ImageProps } from './Image.types';
import { forwardRef } from '@fluentui/react-utilities';

/**
* The Image component ensures the consistent styling of images.
*/
export const Image = React.forwardRef<HTMLImageElement, ImageProps>((props, ref) => {
export const Image = forwardRef<ImageProps>((props, ref) => {
const state = useImage(props, ref);
useImageStyles(state);

Expand Down
3 changes: 2 additions & 1 deletion packages/react-input/etc/react-input.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import { ForwardRefExoticComponent } from 'react';
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
import * as React_2 from 'react';

// @public
export const Input: React_2.ForwardRefExoticComponent<Pick<InputProps, "input" | "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css" | "size" | "inputWrapper" | "bookendBefore" | "bookendAfter" | "insideStart" | "insideEnd" | "as" | "appearance" | "inline"> & React_2.RefAttributes<HTMLSpanElement>>;
export const Input: ForwardRefExoticComponent<InputProps>;

// @public (undocumented)
export interface InputCommons {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-input/src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { useInput } from './useInput';
import { renderInput } from './renderInput';
import { useInputStyles } from './useInputStyles';
import type { InputProps } from './Input.types';
import { forwardRef } from '@fluentui/react-utilities';

/**
* Input component
*/
export const Input = React.forwardRef<HTMLSpanElement, InputProps>((props, ref) => {
export const Input = forwardRef<InputProps>((props, ref) => {
const state = useInput(props, ref);

useInputStyles(state);
Expand Down
Loading